Open Closed

How to changed GlobalFeatureManager.Instance which is enabled in each module PreConfigureServices when it is disabled from Saas Module -> Edition -> Features Modal #2034


User avatar
0
ElifKaya created

Hi,

We have some questions about feature managment. We want to manage features on backend and also UI side. Firstly, we add GlobalDocsFeatures.cs,

using Volo.Abp.GlobalFeatures;
using Volo.Abp.Reflection;

namespace Siemens.Docs.Features
{
    [GlobalFeatureName("GlobalDocsFeatures")]
    public class DocsFeatures : GlobalFeature
    {
        public const string GroupName = DocsConsts.Name;


        public new const string Enable = GroupName + ".Enable";

        public static string[] GetAll()
        {
            return ReflectionHelper.GetPublicConstantsRecursively(typeof(DocsFeatures));
        }
        public DocsFeatures(GlobalModuleFeatures module)
           : base(module)
        {
        }
    }
}

and then, we enabled in domain module.

      public override void PreConfigureServices(ServiceConfigurationContext context)
        {
            GlobalFeatureManager.Instance.Enable<DocsFeatures>();
        }

Then we check if its enabled, we are adding data tables and, creating seed data of this module. We have no problem so far.

But, we want to manage same feature on UI side. But, it can not be ignored backend code. Forexample, if we disabled this feature on Edition Features Modal, we hope that does not contains this module entitiy and seeder data when we create new tenant.

Can you give an advice to us about this problem?

Thanks, Elif

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

ABP Framework version: v4.4.3 UI type: MVC DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): yes / no Exception message and stack trace: Steps to reproduce the issue:"


1 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Firstly Global-Features and Features aren't same thing.

    Basically:

    • Features allows to manage features at runtime.
    • But Global-Featuers allows to manage features at development-time. It doesn't allow change features at runtime.

    According to this information, If you want to change features at runtime, you have to implement Feature. You should use [RequiresFeature("FeatureName")] attribute over classes or methods. If that feature is not enabled, that method, or entire class won't work.

    About DataSeeders, you can inject IFeatureChecker service to your DataSeederContributor and call IsEnabledAsync() method, check if feature is enabled and then do rest of operation.


Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11