Hi!
I have implemented a FeatureValueProvider for roles (RoleBasedFeatureValueProvider) and registered it as the first provider in the list of FeatureValueProviders.
However, I noticed that when I specify a defaultValue in .AddFeature, my RoleBasedFeatureValueProvider is not invoked.
If I leave out the defaultValue in .AddFeature, the text fields of type FreeTextStringValueType appear disabled in the Blazor UI under Administrator → Saas → Editions → Default Edition → Features.
This behavior seems quite unexpected. As a workaround, I had to modify my RoleBasedFeatureValueProvider so that, upon the first call to FeatureChecker.IsEnabledAsync, an entry is created in the AbpFeatureValues table.
Could you please explain why my RoleBasedFeatureValueProvider, although registered first in the list, is ignored when a defaultValue is provided in .AddFeature?
Thank you!
10 Answer(s)
-
0
hi
Can you share full code or a test project to reproduce?
liming.ma@volosoft.com
Thanks.
-
0
hi
Can you try to override the Blazor
FeatureManagementModal?Typically, a feature will have a default value
using Volo.Abp.DependencyInjection; using Volo.Abp.FeatureManagement.Blazor.Components; using Volo.Abp.Features; namespace EagEz.Fvp.Blazor; [ExposeServices(typeof(FeatureManagementModal))] [Dependency(ReplaceServices = true)] public class MyFeatureManagementModal : FeatureManagementModal { protected override bool IsDisabled(string providerName) { return providerName != null && providerName != ProviderName && providerName != DefaultValueFeatureValueProvider.ProviderName; } } -
0
Hi!
... Typically, a feature will have a default value
Yes, that's what I intended to do as well. But then my
FvpRoleBasedFeatureValueProvideris not invoked, even though it’s registered first in the list. Instead, a defaultFeatureValueProvideris used, which doesn’t know how to handle my default values and throws an exception. See the test project underscreenshot\02 Test-2 Exception.png. And that's the problem.- Without a default value,
FvpRoleBasedFeatureValueProvideris used. - With a default value,
FvpRoleBasedFeatureValueProvideris not used.
What do I need to do to ensure that my
FvpRoleBasedFeatureValueProvideris always used when it is registered first? - Without a default value,
-
0
hi
I will test it again.
Thanks.
-
0
-
0
hi
Configure<AbpFeatureOptions>(options => { options.ValueProviders.Insert(0, typeof(FvpRoleBasedFeatureValueProvider)); });The
valueProvidersorder isDefaultValueFeatureValueProvider EditionFeatureValueProvider TenantFeatureValueProviderYour
FvpRoleBasedFeatureValueProvidershould be added afterDefaultValueFeatureValueProvider,eg:
DefaultValueFeatureValueProvider FvpRoleBasedFeatureValueProvider EditionFeatureValueProvider TenantFeatureValueProviderBut this depends on your business logic. You can add before
TenantFeatureValueProvider.eg:
DefaultValueFeatureValueProvider EditionFeatureValueProvider TenantFeatureValueProviderr FvpRoleBasedFeatureValueProvider -
0
hi,
With my configuration:
Configure<AbpFeatureOptions>(options => { options.ValueProviders.Insert(0, typeof(FvpRoleBasedFeatureValueProvider)); });In which order is the
ValueProviderinserted? I assume that theValueProvideris inserted at the beginning of the list and is therefore the first one to be called.Is that correct?
-
0
is therefore the first one to be called.
Add it to the last position.
Configure<AbpFeatureOptions>(options => { options.ValueProviders.Add<FvpRoleBasedFeatureValueProvider>(); }); -
0
Thanks, that was it!
-
0
: )
