Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

If there is no feature, hide the menu (Angular) #10436


User avatar
0
QuickApp created

What is your product version? v10.2.0 What is your product type (Angular or MVC)? Angular What is product framework type (.net framework or .net core)? .Net Core

Hi, I want some menus to be hidden if there is no related feature in the edition that the tenant is included in.If you could help with this situation, I would greatly appreciate it.

`getMenu(): AppMenu { return new AppMenu('MainMenu', 'MainMenu', [ new AppMenuItem('Dashboard', 'Pages.Administration.Host.Dashboard', 'flaticon-line-graph', '/app/admin/hostDashboard'), new AppMenuItem('Dashboard', 'Pages.Tenant.Dashboard', 'flaticon-line-graph', '/app/main/dashboard'), ...... new AppMenuItem('QTranslations', 'Pages.QTranslations', 'flaticon-list-1', '/app/main/qTranslate') //here, new AppMenuItem('Tenants', 'Pages.Tenants', 'flaticon-list-3', '/app/admin/tenants'), new AppMenuItem('Editions', 'Pages.Editions', 'flaticon-app', '/app/admin/editions'),

         new AppMenuItem('Administration', '', 'flaticon-interface-8', '', [], [
            new AppMenuItem('OrganizationUnits', 'Pages.Administration.OrganizationUnits', 'flaticon-map', '/app/admin/organization-units'),
            new AppMenuItem('Roles', 'Pages.Administration.Roles', 'flaticon-suitcase', '/app/admin/roles'),
            new AppMenuItem('Users', 'Pages.Administration.Users', 'flaticon-users', '/app/admin/users'),
            new AppMenuItem('Languages', 'Pages.Administration.Languages', 'flaticon-tabs', '/app/admin/languages', ['/app/admin/languages/{name}/texts']),
            new AppMenuItem('AuditLogs', 'Pages.Administration.AuditLogs', 'flaticon-folder-1', '/app/admin/auditLogs'),
            new AppMenuItem('Maintenance', 'Pages.Administration.Host.Maintenance', 'flaticon-lock', '/app/admin/maintenance'),
            new AppMenuItem('Subscription', 'Pages.Administration.Tenant.SubscriptionManagement', 'flaticon-refresh', '/app/admin/subscription-management'),
            new AppMenuItem('VisualSettings', 'Pages.Administration.UiCustomization', 'flaticon-medical', '/app/admin/ui-customization'),
            new AppMenuItem('WebhookSubscriptions', 'Pages.Administration.Host.Settings', 'flaticon2-world', '/app/admin/webhook-subscriptions'),
            new AppMenuItem('DynamicProperties', 'Pages.Administration.Host.Settings', 'flaticon-interface-8', '/app/admin/dynamic-property'),
            new AppMenuItem('Settings', 'Pages.Administration.Host.Settings', 'flaticon-settings', '/app/admin/hostSettings'),
            new AppMenuItem('Settings', 'Pages.Administration.Tenant.Settings', 'flaticon-settings', '/app/admin/tenantSettings')
        ]),
        new AppMenuItem('DemoUiComponents', 'Pages.DemoUiComponents', 'flaticon-shapes', '/app/admin/demo-ui-components')
    ]);
}`

4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    AppMenuItem already supports feature dependency, you can use it as shown below;

    new AppMenuItem('Users', 'Pages.Administration.Users', 'flaticon-users', '/app/admin/users', undefined, undefined, undefined, () => {
    	return this._featureCheckerService.isEnabled('App.ChatFeature');
    })
    
  • User Avatar
    0
    QuickApp created

    Hi @ismcagdas, I tried as follows, but users without features can also see this menu. Where am I doing wrong? new AppMenuItem('QTranslations', 'Pages.QTranslations', 'flaticon-list-1', '/app/main/qTranslate', undefined, undefined, undefined, () => { return this._featureCheckerService.isEnabled('App.MultiLanguageSupportFeature'); }),

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Is the user you are trying a host user ? Could you check the value of abp.multiTenancy.ignoreFeatureCheckForHostUsers ?

    The menu item should be hidden according to this condition;

    if (this._appSessionService.tenant || !abp.multiTenancy.ignoreFeatureCheckForHostUsers) {
                if (menuItem.hasFeatureDependency() && !menuItem.featureDependencySatisfied()) {
                    hideMenuItem = true;
                }
            }
    
  • User Avatar
    0
    QuickApp created

    Sorry, I missed a parameter.It was fixed by doing the following.

    new AppMenuItem('QTranslations', 'Pages.QTranslations', 'flaticon-list-1', '/app/main/qTranslate', undefined, undefined, undefined, null, () => { return this._featureCheckerService.isEnabled('App.MultiLanguageSupportFeature'); }),