From 10ab7ba0fce07b2ef203b441596b79f3b440dc96 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Tue, 29 Dec 2020 16:33:22 +0300 Subject: [PATCH 1/2] pages feature has been added. --- .../GlobalFeatures/GlobalCmsKitFeatures.cs | 5 ++++ .../CmsKit/GlobalFeatures/PagesFeature.cs | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs index db987784fd..5a7adc34b2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs @@ -15,6 +15,10 @@ namespace Volo.CmsKit.GlobalFeatures public TagsFeature Tags => GetFeature(); + public ContentsFeature Contents => GetFeature(); + + public PagesFeature Pages => GetFeature(); + public GlobalCmsKitFeatures([NotNull] GlobalFeatureManager featureManager) : base(featureManager) { @@ -23,6 +27,7 @@ namespace Volo.CmsKit.GlobalFeatures AddFeature(new RatingsFeature(this)); AddFeature(new TagsFeature(this)); AddFeature(new ContentsFeature(this)); + AddFeature(new PagesFeature(this)); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs new file mode 100644 index 0000000000..c41e217999 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs @@ -0,0 +1,29 @@ +using JetBrains.Annotations; +using Volo.Abp.GlobalFeatures; + +namespace Volo.CmsKit.GlobalFeatures +{ + [GlobalFeatureName(Name)] + public class PagesFeature:GlobalFeature + { + public const string Name = "CmsKit.Pages"; + + internal PagesFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) + { + + } + + public override void Enable() + { + var contentsFeature = FeatureManager.Modules.CmsKit().Contents; + if (!contentsFeature.IsEnabled) + { + contentsFeature.Enable(); + } + + base.Enable(); + } + } +} \ No newline at end of file From bd88ef7b0f2f6aacd88bbccd77e331a4da0de799 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Tue, 29 Dec 2020 16:33:40 +0300 Subject: [PATCH 2/2] page feature test has been added. --- .../Features/GlobalCmsKitFeatures_Tests.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs new file mode 100644 index 0000000000..97e53daeb8 --- /dev/null +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs @@ -0,0 +1,30 @@ +using Shouldly; +using Volo.Abp.GlobalFeatures; +using Volo.CmsKit.GlobalFeatures; +using Xunit; + +namespace Volo.CmsKit.Features +{ + public class GlobalCmsKitFeatures_Tests : CmsKitDomainTestBase + { + private readonly GlobalCmsKitFeatures _cmsKitFeatures; + + public GlobalCmsKitFeatures_Tests() + { + _cmsKitFeatures = new GlobalCmsKitFeatures(GlobalFeatureManager.Instance); + } + + [Fact] + public void Page_Feature_Should_Enable_Dependent_Features() + { + _cmsKitFeatures.DisableAll(); + _cmsKitFeatures.Contents.IsEnabled.ShouldBeFalse(); + _cmsKitFeatures.Pages.IsEnabled.ShouldBeFalse(); + + _cmsKitFeatures.Pages.Enable(); + + _cmsKitFeatures.Contents.IsEnabled.ShouldBeTrue(); + _cmsKitFeatures.Pages.IsEnabled.ShouldBeTrue(); + } + } +} \ No newline at end of file