Add `abp.globalFeatures.isEnabled` to `abp.js`

pull/12553/head
maliming 4 years ago
parent 89fac3be8d
commit cecc2c1baa
No known key found for this signature in database
GPG Key ID: 096224957E51C89E

@ -7,15 +7,18 @@
## Usage
````js
//Gets all enabled global features.
> abp.globalFeatures.enabledFeatures
[ 'Shopping.Payment', 'Ecommerce.Subscription' ]
> abp.globalFeatures.moduleEnabledFeatures
{ Ecommerce }
//Check the global feature is enabled
> abp.globalFeatures.isEnabled('Ecommerce.Subscription')
> abp.globalFeatures.moduleEnabledFeatures.Ecommerce
true
[ 'Ecommerce.Subscription', 'Ecommerce.Invoice' ]
> abp.globalFeatures.isEnabled('My.Subscription')
false
````

@ -8,11 +8,8 @@ public class ApplicationGlobalFeatureConfigurationDto
{
public HashSet<string> EnabledFeatures { get; set; }
public Dictionary<string, List<string>> ModuleEnabledFeatures { get; set; }
public ApplicationGlobalFeatureConfigurationDto()
{
EnabledFeatures = new HashSet<string>();
ModuleEnabledFeatures = new Dictionary<string, List<string>>();
}
}

@ -295,15 +295,9 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp
result.EnabledFeatures.AddIfNotContains(enabledFeatureName);
}
foreach (var module in GlobalFeatureManager.Instance.Modules)
{
result.ModuleEnabledFeatures.AddIfNotContains(new KeyValuePair<string, List<string>>(module.Key, module.Value.GetFeatures().Select(x => x.FeatureName).ToList()));
}
return Task.FromResult(result);
}
protected virtual async Task<TimingDto> GetTimingConfigAsync()
{
var windowsTimeZoneId = await _settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone);

@ -773,4 +773,14 @@ var abp = abp || {};
return abp.features.values[name];
};
/* GLOBAL FEATURES *************************************************/
abp.globalFeatures = abp.globalFeatures || {};
abp.globalFeatures.enabledFeatures = abp.globalFeatures.enabledFeatures || {};
abp.globalFeatures.isEnabled = function(name){
return abp.globalFeatures.enabledFeatures.indexOf(name) != -1;
}
})();

Loading…
Cancel
Save