Browse Source
Merge pull request #16943 from abpframework/AllowChangingTimeZoneSettingsFeatureSimpleStateChecker
Remove `EnableTimeZone` feature.
pull/16946/head
liangshiwei
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with
7 additions and
71 deletions
-
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/AllowChangingTimeZoneSettingsFeatureSimpleStateChecker.cs
-
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs
-
modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/TimeZoneSettingsAppService.cs
-
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/TimeZonePageContributor.cs
-
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/en.json
-
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/tr.json
-
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hans.json
-
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/zh-Hant.json
-
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs
-
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatures.cs
-
modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/TimeZonePageContributor.cs
|
|
|
@ -1,24 +0,0 @@ |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Volo.Abp.Authorization.Permissions; |
|
|
|
using Volo.Abp.Features; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
using Volo.Abp.SimpleStateChecking; |
|
|
|
|
|
|
|
namespace Volo.Abp.SettingManagement; |
|
|
|
|
|
|
|
public class AllowChangingTimeZoneSettingsFeatureSimpleStateChecker : ISimpleStateChecker<PermissionDefinition> |
|
|
|
{ |
|
|
|
public async Task<bool> IsEnabledAsync(SimpleStateCheckerContext<PermissionDefinition> context) |
|
|
|
{ |
|
|
|
var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>(); |
|
|
|
|
|
|
|
if (!currentTenant.IsAvailable) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
var featureChecker = context.ServiceProvider.GetRequiredService<IFeatureChecker>(); |
|
|
|
return await featureChecker.IsEnabledAsync(SettingManagementFeatures.EnableTimeZone); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -17,7 +17,6 @@ public class SettingManagementPermissionDefinitionProvider : PermissionDefinitio |
|
|
|
emailPermission.AddChild(SettingManagementPermissions.EmailingTest, L("Permission:EmailingTest")); |
|
|
|
|
|
|
|
moduleGroup.AddPermission(SettingManagementPermissions.TimeZone, L("Permission:TimeZone")); |
|
|
|
emailPermission.StateCheckers.Add(new AllowChangingTimeZoneSettingsFeatureSimpleStateChecker()); |
|
|
|
} |
|
|
|
|
|
|
|
private static LocalizableString L(string name) |
|
|
|
|
|
|
|
@ -4,25 +4,20 @@ using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using TimeZoneConverter; |
|
|
|
using Volo.Abp.Features; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
using Volo.Abp.Settings; |
|
|
|
using Volo.Abp.Timing; |
|
|
|
|
|
|
|
namespace Volo.Abp.SettingManagement; |
|
|
|
|
|
|
|
[RequiresFeature(SettingManagementFeatures.EnableTimeZone)] |
|
|
|
[Authorize(SettingManagementPermissions.TimeZone)] |
|
|
|
public class TimeZoneSettingsAppService : SettingManagementAppServiceBase, ITimeZoneSettingsAppService |
|
|
|
{ |
|
|
|
protected ISettingManager SettingManager { get; } |
|
|
|
protected ISettingProvider SettingProvider { get; } |
|
|
|
protected ITimezoneProvider TimezoneProvider { get; } |
|
|
|
|
|
|
|
public TimeZoneSettingsAppService(ISettingManager settingManager, ISettingProvider settingProvider, ITimezoneProvider timezoneProvider) |
|
|
|
public TimeZoneSettingsAppService(ISettingManager settingManager, ITimezoneProvider timezoneProvider) |
|
|
|
{ |
|
|
|
SettingManager = settingManager; |
|
|
|
SettingProvider = settingProvider; |
|
|
|
TimezoneProvider = timezoneProvider; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -13,8 +13,6 @@ public class TimeZonePageContributor : ISettingComponentContributor |
|
|
|
{ |
|
|
|
public async Task ConfigureAsync(SettingComponentCreationContext context) |
|
|
|
{ |
|
|
|
await CheckFeatureAsync(context); |
|
|
|
|
|
|
|
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>(); |
|
|
|
if (context.ServiceProvider.GetRequiredService<IClock>().SupportsMultipleTimezone) |
|
|
|
{ |
|
|
|
@ -30,20 +28,8 @@ public class TimeZonePageContributor : ISettingComponentContributor |
|
|
|
|
|
|
|
public async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context) |
|
|
|
{ |
|
|
|
if (!await CheckFeatureAsync(context)) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); |
|
|
|
|
|
|
|
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.TimeZone); |
|
|
|
} |
|
|
|
|
|
|
|
private async Task<bool> CheckFeatureAsync(SettingComponentCreationContext context) |
|
|
|
{ |
|
|
|
var featureCheck = context.ServiceProvider.GetRequiredService<IFeatureChecker>(); |
|
|
|
|
|
|
|
return await featureCheck.IsEnabledAsync(SettingManagementFeatures.EnableTimeZone); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -32,7 +32,6 @@ |
|
|
|
"Feature:SettingManagementEnable": "Enable setting management", |
|
|
|
"Feature:SettingManagementEnableDescription": "Enable setting management system in the application.", |
|
|
|
"Feature:AllowChangingEmailSettings": "Allow changing email settings.", |
|
|
|
"Feature:AllowChangingEmailSettingsDescription": "Allow changing email settings.", |
|
|
|
"Feature:EnableTimeZone": "Enable time zone" |
|
|
|
"Feature:AllowChangingEmailSettingsDescription": "Allow changing email settings." |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -32,7 +32,6 @@ |
|
|
|
"Feature:SettingManagementEnable": "Ayar yönetimini etkinleştir", |
|
|
|
"Feature:SettingManagementEnableDescription": "Uygulamada ayar yönetim sistemini etkinleştirin.", |
|
|
|
"Feature:AllowChangingEmailSettings": "E-posta ayarlarını değiştirmeye izin verin.", |
|
|
|
"Feature:AllowChangingEmailSettingsDescription": "E-posta ayarlarını değiştirmeye izin verin.", |
|
|
|
"Feature:EnableTimeZone": "Zaman dilimini etkinleştir" |
|
|
|
"Feature:AllowChangingEmailSettingsDescription": "E-posta ayarlarını değiştirmeye izin verin." |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -32,7 +32,6 @@ |
|
|
|
"Feature:SettingManagementEnable": "启用设置管理", |
|
|
|
"Feature:SettingManagementEnableDescription": "在应用程序中启用设置管理系统.", |
|
|
|
"Feature:AllowChangingEmailSettings": "允许更改邮件设置.", |
|
|
|
"Feature:AllowChangingEmailSettingsDescription": "允许更改邮件设置.", |
|
|
|
"Feature:EnableTimeZone": "启用时区", |
|
|
|
"Feature:AllowChangingEmailSettingsDescription": "允许更改邮件设置." |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -32,7 +32,6 @@ |
|
|
|
"Feature:SettingManagementEnable": "啟用設定管理", |
|
|
|
"Feature:SettingManagementEnableDescription": "在應用程序中啟用設定管理系統.", |
|
|
|
"Feature:AllowChangingEmailSettings": "允許更改電子郵件設置。", |
|
|
|
"Feature:AllowChangingEmailSettingsDescription": "允許更改電子郵件設置。", |
|
|
|
"Feature:EnableTimeZone": "啟用時區" |
|
|
|
"Feature:AllowChangingEmailSettingsDescription": "允許更改電子郵件設置。" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -27,14 +27,6 @@ public class SettingManagementFeatureDefinitionProvider : FeatureDefinitionProvi |
|
|
|
null, |
|
|
|
new ToggleStringValueType(), |
|
|
|
isAvailableToHost: false); |
|
|
|
|
|
|
|
settingEnableFeature.CreateChild( |
|
|
|
SettingManagementFeatures.EnableTimeZone, |
|
|
|
"false", |
|
|
|
L("Feature:EnableTimeZone"), |
|
|
|
null, |
|
|
|
new ToggleStringValueType(), |
|
|
|
isAvailableToHost: true); |
|
|
|
} |
|
|
|
|
|
|
|
private static LocalizableString L(string name) |
|
|
|
|
|
|
|
@ -7,6 +7,4 @@ public class SettingManagementFeatures |
|
|
|
public const string Enable = GroupName + ".Enable"; |
|
|
|
|
|
|
|
public const string AllowChangingEmailSettings = GroupName + ".AllowChangingEmailSettings"; |
|
|
|
|
|
|
|
public const string EnableTimeZone = GroupName + ".EnableTimeZone"; |
|
|
|
} |
|
|
|
|
|
|
|
@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Localization; |
|
|
|
using Volo.Abp.SettingManagement.Localization; |
|
|
|
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; |
|
|
|
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup; |
|
|
|
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.TimeZoneSettingGroup; |
|
|
|
using Volo.Abp.Timing; |
|
|
|
|
|
|
|
@ -11,15 +10,10 @@ namespace Volo.Abp.SettingManagement.Web.Settings; |
|
|
|
|
|
|
|
public class TimeZonePageContributor : SettingPageContributorBase |
|
|
|
{ |
|
|
|
public TimeZonePageContributor() |
|
|
|
{ |
|
|
|
RequiredFeatures(SettingManagementFeatures.EnableTimeZone); |
|
|
|
} |
|
|
|
|
|
|
|
public override Task ConfigureAsync(SettingPageCreationContext context) |
|
|
|
{ |
|
|
|
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>(); |
|
|
|
|
|
|
|
|
|
|
|
if (context.ServiceProvider.GetRequiredService<IClock>().SupportsMultipleTimezone) |
|
|
|
{ |
|
|
|
context.Groups.Add( |
|
|
|
@ -33,4 +27,4 @@ public class TimeZonePageContributor : SettingPageContributorBase |
|
|
|
|
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|