CmsKit - Fix conflict on feature/blog-feature

pull/7745/head
enisn 5 years ago
commit 64dc3780e6

@ -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");
}
}
}

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

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

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

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

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

@ -7,19 +7,19 @@ namespace Volo.CmsKit.Blogs
{
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 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)
{
return BlogId == other?.BlogId && FeatureName == other?.FeatureName;

@ -1,22 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
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>
{
new BlogFeature(blogId, BlogPostConsts.CommentsFeatureName),
new BlogFeature(blogId, BlogPostConsts.ReactionsFeatureName),
new BlogFeature(blogId, BlogPostConsts.RatingsFeatureName),
new BlogFeature(blogId, BlogPostConsts.RatingsFeatureName),
new BlogFeature(blogId, BlogPostConsts.TagsFeatureName),
});
}
}

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

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

@ -9,11 +9,11 @@ namespace Volo.CmsKit.Public.Contents
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[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;
}

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

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

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

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

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

Loading…
Cancel
Save