Browse Source

CmsKit - Fix conflict on feature/blog-feature

pull/7745/head
enisn 6 years ago
parent
commit
64dc3780e6
  1. 2022
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.Designer.cs
  2. 23
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.cs
  3. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  4. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs
  5. 7
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs
  6. 2
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureDto.cs
  7. 7
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs
  8. 16
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs
  9. 8
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs
  10. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentPublicAppService.cs
  11. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentPublicAppService.cs
  12. 6
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs
  13. 6
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Blogs/BlogPost.cshtml
  14. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs
  15. 8
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs
  16. 2
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs
  17. 2
      modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogFeatureRepository_Test.cs

2022
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.Designer.cs

File diff suppressed because it is too large

23
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.cs

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class BlogFeatureEnabledColumnRename : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Enabled",
table: "CmsBlogFeatures",
newName: "IsEnabled");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "IsEnabled",
table: "CmsBlogFeatures",
newName: "Enabled");
}
}
}

6
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs

@ -1220,9 +1220,6 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasColumnName("DeletionTime"); .HasColumnName("DeletionTime");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties") b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)") .HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties"); .HasColumnName("ExtraProperties");
@ -1238,6 +1235,9 @@ namespace Volo.CmsKit.Migrations
.HasDefaultValue(false) .HasDefaultValue(false)
.HasColumnName("IsDeleted"); .HasColumnName("IsDeleted");
b.Property<bool>("IsEnabled")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime") b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasColumnName("LastModificationTime"); .HasColumnName("LastModificationTime");

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs

@ -6,6 +6,6 @@ namespace Volo.CmsKit.Admin.Blogs
{ {
[Required] [Required]
public string FeatureName { get; set; } public string FeatureName { get; set; }
public bool Enabled { get; set; } public bool IsEnabled { get; set; }
} }
} }

7
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs

@ -4,12 +4,15 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Admin.Blogs; using Volo.CmsKit.Admin.Blogs;
using Volo.CmsKit.Blogs; using Volo.CmsKit.Blogs;
using Volo.CmsKit.GlobalFeatures;
using Volo.CmsKit.Permissions; using Volo.CmsKit.Permissions;
namespace Volo.CmsKit.Admin.Blogs namespace Volo.CmsKit.Admin.Blogs
{ {
[RequiresGlobalFeature(typeof(BlogsFeature))]
public class BlogFeatureAdminAppService : CmsKitAdminAppServiceBase, IBlogFeatureAdminAppService public class BlogFeatureAdminAppService : CmsKitAdminAppServiceBase, IBlogFeatureAdminAppService
{ {
protected IBlogFeatureRepository BlogFeatureRepository { get; } protected IBlogFeatureRepository BlogFeatureRepository { get; }
@ -37,12 +40,12 @@ namespace Volo.CmsKit.Admin.Blogs
var blogFeature = await BlogFeatureRepository.FindAsync(blogId, dto.FeatureName); var blogFeature = await BlogFeatureRepository.FindAsync(blogId, dto.FeatureName);
if (blogFeature == null) if (blogFeature == null)
{ {
var newBlogFeature = new BlogFeature(blogId, dto.FeatureName, dto.Enabled); var newBlogFeature = new BlogFeature(blogId, dto.FeatureName, dto.IsEnabled);
await BlogFeatureRepository.InsertAsync(newBlogFeature); await BlogFeatureRepository.InsertAsync(newBlogFeature);
} }
else else
{ {
blogFeature.Enabled = dto.Enabled; blogFeature.IsEnabled = dto.IsEnabled;
await BlogFeatureRepository.UpdateAsync(blogFeature); await BlogFeatureRepository.UpdateAsync(blogFeature);
} }
} }

2
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureDto.cs

@ -6,6 +6,6 @@ namespace Volo.CmsKit.Blogs
public class BlogFeatureDto : EntityDto<Guid> public class BlogFeatureDto : EntityDto<Guid>
{ {
public string FeatureName { get; set; } public string FeatureName { get; set; }
public bool Enabled { get; set; } public bool IsEnabled { get; set; }
} }
} }

7
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs

@ -32,12 +32,9 @@ namespace Volo.CmsKit.Blogs
private async Task<BlogFeatureDto> GetFromDatabaseAsync(Guid blogId, string featureName) private async Task<BlogFeatureDto> GetFromDatabaseAsync(Guid blogId, string featureName)
{ {
var feature = await BlogFeatureRepository.FindAsync(blogId, featureName); var feature = await BlogFeatureRepository.FindAsync(blogId, featureName);
if (feature == null) var blogFeature = feature ?? new BlogFeature(blogId, featureName);
{
feature = new BlogFeature(blogId, featureName);
}
return ObjectMapper.Map<BlogFeature, BlogFeatureDto>(feature); return ObjectMapper.Map<BlogFeature, BlogFeatureDto>(blogFeature);
} }
} }
} }

16
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs

@ -7,19 +7,19 @@ namespace Volo.CmsKit.Blogs
{ {
public class BlogFeature : FullAuditedAggregateRoot<Guid>, IEquatable<BlogFeature> public class BlogFeature : FullAuditedAggregateRoot<Guid>, IEquatable<BlogFeature>
{ {
public BlogFeature(Guid blogId, [NotNull] string featureName, bool enabled = true)
{
BlogId = blogId;
FeatureName = Check.NotNullOrWhiteSpace(featureName, nameof(featureName));
Enabled = enabled;
}
public Guid BlogId { get; protected set; } public Guid BlogId { get; protected set; }
public string FeatureName { get; protected set; } public string FeatureName { get; protected set; }
public bool Enabled { get; set; } = true; public bool IsEnabled { get; set; } = true;
public BlogFeature(Guid blogId, [NotNull] string featureName, bool isEnabled = true)
{
BlogId = blogId;
FeatureName = Check.NotNullOrWhiteSpace(featureName, nameof(featureName));
IsEnabled = isEnabled;
}
public bool Equals(BlogFeature other) public bool Equals(BlogFeature other)
{ {
return BlogId == other?.BlogId && FeatureName == other?.FeatureName; return BlogId == other?.BlogId && FeatureName == other?.FeatureName;

8
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultDefaultBlogFeatureProvider.cs → modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs

@ -1,22 +1,20 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Volo.CmsKit.Blogs namespace Volo.CmsKit.Blogs
{ {
public class DefaultDefaultBlogFeatureProvider : IDefaultBlogFeatureProvider, ITransientDependency public class DefaultBlogFeatureProvider : IDefaultBlogFeatureProvider, ITransientDependency
{ {
public Task<List<BlogFeature>> GetDefaultFeaturesAsync(Guid blogId) public virtual Task<List<BlogFeature>> GetDefaultFeaturesAsync(Guid blogId)
{ {
return Task.FromResult(new List<BlogFeature> return Task.FromResult(new List<BlogFeature>
{ {
new BlogFeature(blogId, BlogPostConsts.CommentsFeatureName), new BlogFeature(blogId, BlogPostConsts.CommentsFeatureName),
new BlogFeature(blogId, BlogPostConsts.ReactionsFeatureName), new BlogFeature(blogId, BlogPostConsts.ReactionsFeatureName),
new BlogFeature(blogId, BlogPostConsts.RatingsFeatureName), new BlogFeature(blogId, BlogPostConsts.RatingsFeatureName),
new BlogFeature(blogId, BlogPostConsts.RatingsFeatureName), new BlogFeature(blogId, BlogPostConsts.TagsFeatureName),
}); });
} }
} }

4
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentAppService.cs → modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentPublicAppService.cs

@ -3,8 +3,8 @@ using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Public.Contents namespace Volo.CmsKit.Public.Contents
{ {
public interface IContentAppService public interface IContentPublicAppService
{ {
Task<ContentDto> GetAsync(GetContentInput input); Task<ContentDto> GetAsync(GetContentInput input);
} }
} }

2
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentPublicAppService.cs

@ -3,7 +3,7 @@ using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Public.Contents namespace Volo.CmsKit.Public.Contents
{ {
public class ContentPublicAppService : CmsKitAppServiceBase, IContentAppService public class ContentPublicAppService : CmsKitPublicAppServiceBase, IContentPublicAppService
{ {
protected IContentRepository ContentRepository { get; } protected IContentRepository ContentRepository { get; }

6
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs

@ -9,11 +9,11 @@ namespace Volo.CmsKit.Public.Contents
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] [RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")] [Area("cms-kit")]
[Route("api/cms-kit-public/contents")] [Route("api/cms-kit-public/contents")]
public class ContentController : CmsKitControllerBase, IContentAppService public class ContentController : CmsKitControllerBase, IContentPublicAppService
{ {
protected readonly IContentAppService _contentAppService; protected readonly IContentPublicAppService _contentAppService;
public ContentController(IContentAppService contentAppService) public ContentController(IContentPublicAppService contentAppService)
{ {
_contentAppService = contentAppService; _contentAppService = contentAppService;
} }

6
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Blogs/BlogPost.cshtml

@ -35,7 +35,7 @@
@if (GlobalFeatureManager.Instance.IsEnabled<ReactionsFeature>()) @if (GlobalFeatureManager.Instance.IsEnabled<ReactionsFeature>())
{ {
if (Model.ReactionsFeature?.Enabled == true) if (Model.ReactionsFeature?.IsEnabled == true)
{ {
@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new @await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new
{ {
@ -48,7 +48,7 @@
@if (GlobalFeatureManager.Instance.IsEnabled<RatingsFeature>()) @if (GlobalFeatureManager.Instance.IsEnabled<RatingsFeature>())
{ {
if (Model.RatingsFeature?.Enabled == true) if (Model.RatingsFeature?.IsEnabled == true)
{ {
@await Component.InvokeAsync(typeof(RatingViewComponent), new @await Component.InvokeAsync(typeof(RatingViewComponent), new
{ {
@ -62,7 +62,7 @@
@if (GlobalFeatureManager.Instance.IsEnabled<CommentsFeature>()) @if (GlobalFeatureManager.Instance.IsEnabled<CommentsFeature>())
{ {
if (Model.CommentsFeature?.Enabled == true) if (Model.CommentsFeature?.IsEnabled == true)
{ {
@await Component.InvokeAsync(typeof(DefaultBlogPostCommentViewComponent), new @await Component.InvokeAsync(typeof(DefaultBlogPostCommentViewComponent), new
{ {

4
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs

@ -12,11 +12,11 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents
public class ContentViewComponent : AbpViewComponent public class ContentViewComponent : AbpViewComponent
{ {
private readonly IContentRenderer contentRenderer; private readonly IContentRenderer contentRenderer;
private readonly IContentAppService contentAppService; private readonly IContentPublicAppService contentAppService;
public ContentViewComponent( public ContentViewComponent(
IContentRenderer contentRenderer, IContentRenderer contentRenderer,
IContentAppService contentAppService) IContentPublicAppService contentAppService)
{ {
this.contentRenderer = contentRenderer; this.contentRenderer = contentRenderer;
this.contentAppService = contentAppService; this.contentAppService = contentAppService;

8
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs

@ -24,7 +24,7 @@ namespace Volo.CmsKit.Blogs
var dto = new BlogFeatureInputDto var dto = new BlogFeatureInputDto
{ {
FeatureName = "My.Awesome.Feature", FeatureName = "My.Awesome.Feature",
Enabled = true IsEnabled = true
}; };
await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto); await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto);
@ -33,7 +33,7 @@ namespace Volo.CmsKit.Blogs
feature.ShouldNotBeNull(); feature.ShouldNotBeNull();
feature.BlogId.ShouldBe(testData.Blog_Id); feature.BlogId.ShouldBe(testData.Blog_Id);
feature.Enabled.ShouldBe(dto.Enabled); feature.IsEnabled.ShouldBe(dto.IsEnabled);
} }
[Fact] [Fact]
@ -42,7 +42,7 @@ namespace Volo.CmsKit.Blogs
var dto = new BlogFeatureInputDto var dto = new BlogFeatureInputDto
{ {
FeatureName = testData.BlogFeature_2_FeatureName, FeatureName = testData.BlogFeature_2_FeatureName,
Enabled = !testData.BlogFeature_2_Enabled IsEnabled = !testData.BlogFeature_2_Enabled
}; };
await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto); await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto);
@ -51,7 +51,7 @@ namespace Volo.CmsKit.Blogs
feature.ShouldNotBeNull(); feature.ShouldNotBeNull();
feature.BlogId.ShouldBe(testData.Blog_Id); feature.BlogId.ShouldBe(testData.Blog_Id);
feature.Enabled.ShouldBe(dto.Enabled); feature.IsEnabled.ShouldBe(dto.IsEnabled);
} }
[Fact] [Fact]

2
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs

@ -37,7 +37,7 @@ namespace Volo.CmsKit.Blogs
var defaultFeature = new BlogFeature(Guid.Empty, nonExistingFeatureName); var defaultFeature = new BlogFeature(Guid.Empty, nonExistingFeatureName);
result.ShouldNotBeNull(); result.ShouldNotBeNull();
result.Enabled.ShouldBe(defaultFeature.Enabled); result.IsEnabled.ShouldBe(defaultFeature.IsEnabled);
} }
} }
} }

2
modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogFeatureRepository_Test.cs

@ -45,7 +45,7 @@ namespace Volo.CmsKit.Blogs
result.ShouldNotBeNull(); result.ShouldNotBeNull();
result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName); result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName);
result.Enabled.ShouldBe(testData.BlogFeature_1_Enabled); result.IsEnabled.ShouldBe(testData.BlogFeature_1_Enabled);
} }
[Fact] [Fact]

Loading…
Cancel
Save