Lock core relation types (#8022)
This commit is contained in:
committed by
GitHub
parent
ad280b47c9
commit
11f8628279
12
src/Umbraco.Core/Models/RelationTypeExtensions.cs
Normal file
12
src/Umbraco.Core/Models/RelationTypeExtensions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
internal static class RelationTypeExtensions
|
||||
{
|
||||
internal static bool IsSystemRelationType(this IRelationType relationType) =>
|
||||
relationType.Alias == Constants.Conventions.RelationTypes.RelatedDocumentAlias
|
||||
|| relationType.Alias == Constants.Conventions.RelationTypes.RelatedMediaAlias
|
||||
|| relationType.Alias == Constants.Conventions.RelationTypes.RelateDocumentOnCopyAlias
|
||||
|| relationType.Alias == Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias
|
||||
|| relationType.Alias == Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias;
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,7 @@
|
||||
<Compile Include="Models\ContentDataIntegrityReportEntry.cs" />
|
||||
<Compile Include="Models\ContentDataIntegrityReportOptions.cs" />
|
||||
<Compile Include="Models\InstallLog.cs" />
|
||||
<Compile Include="Models\RelationTypeExtensions.cs" />
|
||||
<Compile Include="Persistence\Repositories\IInstallationRepository.cs" />
|
||||
<Compile Include="Persistence\Repositories\Implement\InstallationRepository.cs" />
|
||||
<Compile Include="Services\Implement\InstallationService.cs" />
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<umb-editor-header
|
||||
name="vm.relationType.name"
|
||||
alias="vm.relationType.alias"
|
||||
alias-locked="vm.relationType.isSystemRelationType"
|
||||
hide-description="true"
|
||||
hide-icon="true"
|
||||
navigation="vm.page.navigation"
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
[DataMember(Name = "isSystemRelationType")]
|
||||
public bool IsSystemRelationType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the RelationType is Bidirectional (true) or Parent to Child (false)
|
||||
/// </summary>
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Udi = Udi.Create(Constants.UdiEntityType.RelationType, source.Key);
|
||||
target.Path = "-1," + source.Id;
|
||||
|
||||
target.IsSystemRelationType = source.IsSystemRelationType();
|
||||
|
||||
// Set the "friendly" and entity names for the parent and child object types
|
||||
if (source.ParentObjectType.HasValue)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Actions;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -16,8 +17,6 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
//TODO: Do not allow deleting built in types
|
||||
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.RootString)
|
||||
@@ -34,7 +33,10 @@ namespace Umbraco.Web.Trees
|
||||
var relationType = Services.RelationService.GetRelationTypeById(int.Parse(id));
|
||||
if (relationType == null) return new MenuItemCollection();
|
||||
|
||||
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.ActionAlias));
|
||||
if (relationType.IsSystemRelationType() == false)
|
||||
{
|
||||
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.ActionAlias));
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user