Lock core relation types (#8022)

This commit is contained in:
Bjarne Fyrstenborg
2020-05-16 19:51:57 +02:00
committed by GitHub
parent ad280b47c9
commit 11f8628279
6 changed files with 24 additions and 3 deletions

View 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;
}
}

View File

@@ -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" />

View File

@@ -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"

View File

@@ -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>

View File

@@ -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)
{

View File

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