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:
10
src/Umbraco.Core/Models/MediaTypeExtensions.cs
Normal file
10
src/Umbraco.Core/Models/MediaTypeExtensions.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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" />
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user