Ends in:
4 DAYS
10 HRS
33 MIN
4 SEC
Ends in:
4 D
10 H
33 M
4 S
Open Closed

Edition based Menu configuration #3584


User avatar
0
shobhit created
  • ABP Framework version: v4.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"
  • How i can configure menu accessibiity based on tenant edition

12 Answer(s)
  • User Avatar
    0
    mahmut.gundogdu created

    If we are talking about "access management" of the menu. All menu have their permission. You can manage permissions for any edition. Then if the tenant has permission, the user of the tenant sees the menu. I hope I've understood your issue. otherwise you should give us more information about your primary goal of the issue

  • User Avatar
    0
    shobhit created

    Hello mahmut, Let's take one example. assume similar to role/user access permission we have permission for tenant edition.

           Now i want menu's to be displayed to tenant admin based on edition only i.e. maximum menus allowed.
           
    

    in the current exmaple for "organizatoin" edition, tenant will have permission for "Home" and "Dashboard" menu only.

    i hope i am bit clear now.

  • User Avatar
    0
    shobhit created

    In simple words Host admin should be able to define featurs allowed for any tenant admin. currently Host admin can select very specific features but not the custom features for the tenant. Tenant admin already have feature to define the access permission for roles/users.

  • User Avatar
    0
    mahmut.gundogdu created

    1- Define a FeatureDefinitionProvider https://docs.abp.io/en/abp/latest/Features

    
    using support3518.Localization;
    using Volo.Abp.Features;
    using Volo.Abp.Localization;
    using Volo.Abp.Validation.StringValues;
    
    public class MyFeatureDefinitionProvider : FeatureDefinitionProvider {
        public override void Define(IFeatureDefinitionContext context)
            {
                var myGroup = context.AddGroup(MyCustomFeatures.GroupName);
      
                myGroup.AddFeature(MyCustomFeatures.PdfReporting, "false",L("PdfReporting"), L("Pdf Reporting Desc"), new ToggleStringValueType());
             }
        
        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<support3518Resource>(name);
        }
    }
    
    public static class  MyCustomFeatures
    {
        public const string GroupName = "MyFeature";
    
        public const string PdfReporting = GroupName + ".PdfReporting";
    }
    

    2- Add [RequiresFeature] attribute on AppService

    3- Get Feature status and add or remove menu.

    import { Component } from '@angular/core';
    import { ConfigStateService, RoutesService } from '@abp/ng.core';
    
    @Component({
      selector: 'app-root',
      template: `
        &lt;abp-loader-bar&gt;&lt;/abp-loader-bar&gt;
        &lt;abp-dynamic-layout&gt;&lt;/abp-dynamic-layout&gt;
      `,
    })
    export class AppComponent {
      constructor(config: ConfigStateService, routes: RoutesService) {
        
        const isFeatureActive = config.getFeature('MyFeature.PdfReporting');
        if (isFeatureActive !== 'true') {
          routes.remove(['::Menu:Books']);
        }
    
      }
    }
    
    

    I have implemented on App.component.ts but you can make whenever you want like router provider or even you can make custom guard.

  • User Avatar
    0
    shobhit created

    Hi Mahmut, Thanks. Can you help me with sample for router.provider.

  • User Avatar
    0
    shobhit created

    Also how can i save the set/get into the "AppFeatureValue" table as with the above example i cannot find the new record in this table.

  • User Avatar
    0
    mahmut.gundogdu created

    Also how can I save the set/get into the "AppFeatureValue" table as with the above example I cannot find the new record in this table.

    You shouldn't get or set it in the database table it has its own logic like storing in Redis and much more. You can get or set it via c#. See the documentation *. You can change in UI. https://docs.abp.io/en/abp/latest/Features#feature-management

  • User Avatar
    0
    mahmut.gundogdu created

    Hi Mahmut, Thanks. Can you help me with sample for router.provider.

    Nothing is changed. It still has the same logic when using the router.provider. So you can use the sample whenever you want on the app.

  • User Avatar
    0
    shobhit created

    Ok so we should not save the custom features setting in DB table and it will be saved only in cache.

  • User Avatar
    0
    shobhit created

    Hi Team, Can i access the configuration values in the C#. Please share the sample

  • User Avatar
    0
    mahmut.gundogdu created

    Hi Team, Can i access the configuration values in the C#. Please share the sample

    There is an example that is related to "how to check feature in C#" in docs. Please check the link https://docs.abp.io/en/abp/latest/Features

  • User Avatar
    0
    mahmut.gundogdu created

    Ok so we should not save the custom features setting in DB table and it will be saved only in cache.

    The If you want to add or remove some feature, please use the Abp feature service/Api. Feature API handle storing data and invalidate cache operations.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 02, 2024, 12:35