Merge pull request #6943 from kjac/v8/fix/protect-system-media-types

V8: Protect "system media types" from alias changes and deletion
This commit is contained in:
Poornima Nayar
2020-01-09 14:18:10 +00:00
committed by GitHub
6 changed files with 19 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
namespace Umbraco.Core.Models
{
internal static class MediaTypeExtensions
{
internal static bool IsSystemMediaType(this IMediaType mediaType) =>
mediaType.Alias == Constants.Conventions.MediaTypes.File
|| mediaType.Alias == Constants.Conventions.MediaTypes.Folder
|| mediaType.Alias == Constants.Conventions.MediaTypes.Image;
}
}

View File

@@ -277,6 +277,7 @@
<Compile Include="Models\Entities\MediaEntitySlim.cs" />
<Compile Include="Models\PagedResult.cs" />
<Compile Include="Models\Entities\MemberEntitySlim.cs" />
<Compile Include="Models\MediaTypeExtensions.cs" />
<Compile Include="Models\PublishedContent\ILivePublishedModelFactory.cs" />
<Compile Include="Models\PublishedContent\IPublishedContentType.cs" />
<Compile Include="Models\PublishedContent\IPublishedPropertyType.cs" />

View File

@@ -9,6 +9,7 @@
<umb-editor-header
name="vm.contentType.name"
alias="vm.contentType.alias"
alias-locked="vm.contentType.isSystemMediaType"
key="vm.contentType.key"
description="vm.contentType.description"
navigation="vm.page.navigation"

View File

@@ -5,6 +5,7 @@ namespace Umbraco.Web.Models.ContentEditing
[DataContract(Name = "contentType", Namespace = "")]
public class MediaTypeDisplay : ContentTypeCompositionDisplay<PropertyTypeDisplay>
{
[DataMember(Name = "isSystemMediaType")]
public bool IsSystemMediaType { get; set; }
}
}

View File

@@ -145,6 +145,7 @@ namespace Umbraco.Web.Models.Mapping
//default listview
target.ListViewEditorName = Constants.Conventions.DataTypes.ListViewPrefix + "Media";
target.IsSystemMediaType = source.IsSystemMediaType();
if (string.IsNullOrEmpty(source.Name)) return;

View File

@@ -120,7 +120,10 @@ namespace Umbraco.Web.Trees
}
menu.Items.Add<ActionCopy>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
if(ct.IsSystemMediaType() == false)
{
menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
}
menu.Items.Add(new RefreshNode(Services.TextService, true));
}