From 2fbdbf95132543149d95e646e0439b3259e43e3a Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 13 May 2022 11:25:29 +0800 Subject: [PATCH 1/4] Document how to check global features in MVC UI. --- .../JavaScript-API/GlobalFeatures.md | 21 +++++++++++++++++++ docs/en/UI/AspNetCore/JavaScript-API/Index.md | 1 + 2 files changed, 22 insertions(+) create mode 100644 docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md diff --git a/docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md b/docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md new file mode 100644 index 0000000000..2f226724b8 --- /dev/null +++ b/docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md @@ -0,0 +1,21 @@ +# ASP.NET Core MVC / Razor Pages UI: JavaScript Global Features API + +`abp.globalFeatures` API allows you to get the enabled features of the [Global Features](../../../Global-Features.md) in the client side. + +> This document only explains the JavaScript API. See the [Global Features](../../../Global-Features.md) document to understand the ABP Global Features system. + +## Usage + +````js +> abp.globalFeatures.enabledFeatures + +[ 'Shopping.Payment', 'Ecommerce.Subscription' ] + +> abp.globalFeatures.moduleEnabledFeatures + +{ Ecommerce } + +> abp.globalFeatures.moduleEnabledFeatures.Ecommerce + +[ 'Ecommerce.Subscription', 'Ecommerce.Invoice' ] +```` diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Index.md b/docs/en/UI/AspNetCore/JavaScript-API/Index.md index 3473140392..21a3eeed93 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Index.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Index.md @@ -10,6 +10,7 @@ ABP provides a set of JavaScript APIs for ASP.NET Core MVC / Razor Pages applica * [DOM](DOM.md) * [Events](Events.md) * [Features](Features.md) +* [Global Features](GlobalFeatures.md) * [Localization](Localization.md) * [Logging](Logging.md) * [ResourceLoader](ResourceLoader.md) From cecc2c1baa53675906bbd96ac27e476783821bad Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 16 May 2022 16:45:03 +0800 Subject: [PATCH 2/4] Add `abp.globalFeatures.isEnabled` to `abp.js` --- .../en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md | 11 +++++++---- .../ApplicationGlobalFeatureConfigurationDto.cs | 3 --- .../AbpApplicationConfigurationAppService.cs | 6 ------ npm/packs/core/src/abp.js | 10 ++++++++++ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md b/docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md index 2f226724b8..7b451addcd 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md @@ -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 ```` diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs index e911cd911d..9854e85315 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs @@ -8,11 +8,8 @@ public class ApplicationGlobalFeatureConfigurationDto { public HashSet EnabledFeatures { get; set; } - public Dictionary> ModuleEnabledFeatures { get; set; } - public ApplicationGlobalFeatureConfigurationDto() { EnabledFeatures = new HashSet(); - ModuleEnabledFeatures = new Dictionary>(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index bfa2e6a285..b80a288e81 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -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>(module.Key, module.Value.GetFeatures().Select(x => x.FeatureName).ToList())); - } - return Task.FromResult(result); } - protected virtual async Task GetTimingConfigAsync() { var windowsTimeZoneId = await _settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js index 7cb0782f1a..f715b5004c 100644 --- a/npm/packs/core/src/abp.js +++ b/npm/packs/core/src/abp.js @@ -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; + } + })(); From 65be63b782e11d6348b9f4dfe31f8ad97ee37b16 Mon Sep 17 00:00:00 2001 From: muhammedaltug Date: Tue, 17 May 2022 11:16:16 +0300 Subject: [PATCH 3/4] fix angular service schematic version warning --- .../ServiceProxying/Angular/AngularServiceProxyGenerator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs index b9f1662a98..5f1698661e 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs @@ -100,8 +100,8 @@ public class AngularServiceProxyGenerator : ServiceProxyGeneratorBase Date: Tue, 17 May 2022 16:59:07 +0800 Subject: [PATCH 4/4] Update npm/packs/core/src/abp.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Halil İbrahim Kalkan --- npm/packs/core/src/abp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js index f715b5004c..b028c013d6 100644 --- a/npm/packs/core/src/abp.js +++ b/npm/packs/core/src/abp.js @@ -777,7 +777,7 @@ var abp = abp || {}; abp.globalFeatures = abp.globalFeatures || {}; - abp.globalFeatures.enabledFeatures = abp.globalFeatures.enabledFeatures || {}; + abp.globalFeatures.enabledFeatures = abp.globalFeatures.enabledFeatures || []; abp.globalFeatures.isEnabled = function(name){ return abp.globalFeatures.enabledFeatures.indexOf(name) != -1;