Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Umbraco.Core/Configuration/Models/ContentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ @keyframes umbraco-preview-badge--effect {{
internal const string StaticLoginBackgroundImage = "assets/img/login.jpg";
internal const string StaticLoginLogoImage = "assets/img/application/umbraco_logo_white.svg";
internal const bool StaticHideBackOfficeLogo = false;
internal const bool StaticDisableDeleteWhenReferenced = false;
internal const bool StaticDisableUnpublishWhenReferenced = false;

/// <summary>
/// Gets or sets a value for the content notification settings.
Expand Down Expand Up @@ -226,6 +228,18 @@ @keyframes umbraco-preview-badge--effect {{
[DefaultValue(StaticHideBackOfficeLogo)]
public bool HideBackOfficeLogo { get; set; } = StaticHideBackOfficeLogo;

/// <summary>
/// Gets or sets a value indicating whether to disable the deletion of items referenced by other items.
/// </summary>
[DefaultValue(StaticDisableDeleteWhenReferenced)]
public bool DisableDeleteWhenReferenced { get; set; } = StaticDisableDeleteWhenReferenced;

/// <summary>
/// Gets or sets a value indicating whether to disable the unpublishing of items referenced by other items.
/// </summary>
[DefaultValue(StaticDisableUnpublishWhenReferenced)]
public bool DisableUnpublishWhenReferenced { get; set; } = StaticDisableUnpublishWhenReferenced;

/// <summary>
/// Get or sets the model representing the global content version cleanup policy
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal async Task<Dictionary<string, object>> BareMinimumServerVariablesAsync(
var keepOnlyKeys = new Dictionary<string, string[]>
{
{"umbracoUrls", new[] {"authenticationApiBaseUrl", "serverVarsJs", "externalLoginsUrl", "currentUserApiBaseUrl", "previewHubUrl", "iconApiBaseUrl"}},
{"umbracoSettings", new[] {"allowPasswordReset", "imageFileTypes", "maxFileSize", "loginBackgroundImage", "loginLogoImage", "canSendRequiredEmail", "usernameIsEmail", "minimumPasswordLength", "minimumPasswordNonAlphaNum", "hideBackofficeLogo"}},
{"umbracoSettings", new[] {"allowPasswordReset", "imageFileTypes", "maxFileSize", "loginBackgroundImage", "loginLogoImage", "canSendRequiredEmail", "usernameIsEmail", "minimumPasswordLength", "minimumPasswordNonAlphaNum", "hideBackofficeLogo", "disableDeleteWhenReferenced", "disableUnpublishWhenReferenced"}},
{"application", new[] {"applicationPath", "cacheBuster"}},
{"isDebuggingEnabled", new string[] { }},
{"features", new [] {"disabledFeatures"}}
Expand Down Expand Up @@ -413,6 +413,8 @@ internal async Task<Dictionary<string, object>> GetServerVariablesAsync()
{"loginBackgroundImage", _contentSettings.LoginBackgroundImage},
{"loginLogoImage", _contentSettings.LoginLogoImage },
{"hideBackofficeLogo", _contentSettings.HideBackOfficeLogo },
{"disableDeleteWhenReferenced", _contentSettings.DisableDeleteWhenReferenced },
{"disableUnpublishWhenReferenced", _contentSettings.DisableUnpublishWhenReferenced },
{"showUserInvite", _emailSender.CanSendRequiredEmail()},
{"canSendRequiredEmail", _emailSender.CanSendRequiredEmail()},
{"showAllowSegmentationForDocumentTypes", false},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function ContentDeleteController($scope, $timeout, contentResource, treeService,

$scope.checkingReferences = true;
$scope.warningText = null;
$scope.disableDelete = false;

$scope.performDelete = function() {

Expand Down Expand Up @@ -85,9 +86,20 @@ function ContentDeleteController($scope, $timeout, contentResource, treeService,
};

$scope.onReferencesWarning = () => {
localizationService.localize("references_deleteWarning").then((value) => {
$scope.warningText = value;
});
// check if the deletion of items that have references has been disabled
if (Umbraco.Sys.ServerVariables.umbracoSettings.disableDeleteWhenReferenced) {
// this will only be set to true if we have a warning, indicating that this item or its descendants have reference
$scope.disableDelete = true;

localizationService.localize("references_deleteDisabledWarning").then((value) => {
$scope.warningText = value;
});
}
else {
localizationService.localize("references_deleteWarning").then((value) => {
$scope.warningText = value;
});
}
};

$scope.cancel = function() {
Expand Down
6 changes: 4 additions & 2 deletions src/Umbraco.Web.UI.Client/src/views/content/delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>

<div ng-hide="success">
<p class="abstract">
<p class="abstract" ng-if="!disableDelete">
<localize key="defaultdialogs_confirmdelete">Are you sure you want to delete</localize> <strong>{{currentNode.name}}</strong>?
</p>

Expand All @@ -28,7 +28,9 @@
<localize key="defaultdialogs_recycleBinWarning">When items are deleted from the recycle bin, they will be gone forever</localize>.
</div>

<umb-confirm on-confirm="performDelete" confirm-button-style="danger" on-cancel="cancel" ng-hide="checkingReferences"></umb-confirm>
<umb-confirm ng-if="!disableDelete" on-confirm="performDelete" confirm-button-style="danger" on-cancel="cancel" ng-hide="checkingReferences"></umb-confirm>

<umb-confirm ng-if="disableDelete" confirm-button-style="danger" on-cancel="cancel"></umb-confirm>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@

vm.onReferencesWarning = () => {
$scope.model.submitButtonStyle = "danger";

// check if the unpublishing of items that have references has been disabled
if (Umbraco.Sys.ServerVariables.umbracoSettings.disableUnpublishWhenReferenced) {
// this will only be disabled if we have a warning, indicating that this item or its descendants have reference
$scope.model.disableSubmitButton = true;
}

localizationService.localize("references_unpublishWarning").then((value) => {
vm.warningText = value;
});
Expand Down
6 changes: 4 additions & 2 deletions src/Umbraco.Web.UI.Client/src/views/media/delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>

<div ng-hide="success">
<p class="abstract">
<p class="abstract" ng-if="!disableDelete">
<localize key="defaultdialogs_confirmdelete">Are you sure you want to delete</localize> <strong>{{currentNode.name}}</strong>?
</p>

Expand All @@ -24,7 +24,9 @@
<localize key="defaultdialogs_recycleBinWarning">When items are deleted from the recycle bin, they will be gone forever</localize>.
</div>

<umb-confirm on-confirm="performDelete" on-cancel="close" confirm-button-style="danger" ng-hide="checkingReferences"></umb-confirm>
<umb-confirm ng-if="!disableDelete" on-confirm="performDelete" confirm-button-style="danger" on-cancel="close" ng-hide="checkingReferences"></umb-confirm>

<umb-confirm ng-if="disableDelete" confirm-button-style="danger" on-cancel="close"></umb-confirm>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function MediaDeleteController($scope, mediaResource, treeService, navigationSer

$scope.checkingReferences = true;
$scope.warningText = null;
$scope.disableDelete = false;

$scope.performDelete = function() {

Expand Down Expand Up @@ -73,9 +74,20 @@ function MediaDeleteController($scope, mediaResource, treeService, navigationSer
};

$scope.onReferencesWarning = () => {
localizationService.localize("references_deleteWarning").then((value) => {
$scope.warningText = value;
});
// check if the deletion of items that have references has been disabled
if (Umbraco.Sys.ServerVariables.umbracoSettings.disableDeleteWhenReferenced) {
// this will only be set to true if we have a warning, indicating that this item or its descendants have reference
$scope.disableDelete = true;

localizationService.localize("references_deleteDisabledWarning").then((value) => {
$scope.warningText = value;
});
}
else {
localizationService.localize("references_deleteWarning").then((value) => {
$scope.warningText = value;
});
}
};

$scope.close = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

var vm = this;
vm.loading = true;
vm.disableDelete = false;

function onInit() {
$scope.model.hideSubmitButton = true;
Expand All @@ -17,6 +18,13 @@
vm.onReferencesWarning = () => {
$scope.model.submitButtonStyle = "danger";

// check if the deletion of items that have references has been disabled
if (Umbraco.Sys.ServerVariables.umbracoSettings.disableDeleteWhenReferenced) {
// this will only be set to true if we have a warning, indicating that this item or its descendants have reference
vm.disableDelete = true;
$scope.model.disableSubmitButton = true;
}

localizationService.localize("general_delete").then(function (action) {
localizationService.localize("references_listViewDialogWarning", [action.toLowerCase()]).then((value) => {
vm.warningText = value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div ng-controller="Umbraco.Overlays.ListViewDeleteController as vm">

<p class="abstract">
<p class="abstract" ng-if="!vm.disableDelete">
<localize key="defaultdialogs_confirmdeleteNumberOfItems" tokens="[model.numberOfItems, model.totalItems]">Are you sure you want to delete</localize>?
</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
vm.onReferencesWarning = () => {
$scope.model.submitButtonStyle = "danger";

// check if the unpublishing of items that have references has been disabled
if (Umbraco.Sys.ServerVariables.umbracoSettings.disableUnpublishWhenReferenced) {
// this will only be disabled if we have a warning, indicating that this item or its descendants have reference
$scope.model.disableSubmitButton = true;
}

localizationService.localize("content_unpublish").then(function (action) {
localizationService.localize("references_listViewDialogWarning", [action.toLowerCase()]).then((value) => {
vm.warningText = value;
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI/umbraco/config/lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="labelUsedInMemberDescendants">One or more of this item's descendants is being used in a member.</key>
<key alias="deleteWarning">This item or its descendants is being used. Deletion can lead to broken links on your website.</key>
<key alias="unpublishWarning">This item or its descendants is being used. Unpublishing can lead to broken links on your website. Please take the appropriate actions.</key>
<key alias="deleteDisabledWarning">This item or its descendants is being used. Therefore, deletion has been disabled.</key>
<key alias="listViewDialogWarning">The following items you are trying to %0% are used by other content.</key>
</area>
<area alias="logViewer">
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2556,6 +2556,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="labelUsedInMemberDescendants">One or more of this item's descendants is being used in a member.</key>
<key alias="deleteWarning">This item or its descendants is being used. Deletion can lead to broken links on your website.</key>
<key alias="unpublishWarning">This item or its descendants is being used. Unpublishing can lead to broken links on your website. Please take the appropriate actions.</key>
<key alias="deleteDisabledWarning">This item or its descendants is being used. Therefore, deletion has been disabled.</key>
<key alias="listViewDialogWarning">The following items you are trying to %0% are used by other content.</key>
</area>
<area alias="logViewer">
Expand Down