Open Closed

Modify ToolBar Items from "Main" #5979


User avatar
0
WilliamT created
  • ABP Framework version: v7.1.2
  • UI Type: MVC
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Hi,

How Can I remove these 4 items from "Main" Toolbar:

  • Linked Accounts
  • Authority delegation
  • security logs
  • Personal data

Is there a way to control those items via permission?

Regards,


3 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello WilliamT,

    Please add this code to CustomMenuContributor under *.Web/Menus

    public async Task ConfigureMenuAsync(MenuConfigurationContext context)
        {
            if (context.Menu.Name == StandardMenus.User)
            {
                context.Menu.Items.RemoveAll(x => x.Name == "Account.SecurityLogs");
                context.Menu.Items.RemoveAll(x => x.Name == "Account.LinkedAccounts");
                context.Menu.Items.RemoveAll(x => x.Name == "Account.AuthorityDelegation");
            }
        }
    

    It will gives output like

  • User Avatar
    0
    WilliamT created

    Hi Anjali,

    Thank you. However, is there a cleaner approach? Such as creating a new StandardMenu config where I can define what items it will have?

    Regards,

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello WilliamT,

    please try to add the below code to add new menu item

    context.Menu.AddItem(
                   new ApplicationMenuItem(demo5979Menus.Home,"My New Menu Item", "/My/NewMenuItem", icon: "fa fa-home"));
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19