removes UmbracoNotificationSuccessResponse and use OK method
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Web.BackOffice.ActionResults
|
||||
{
|
||||
public class UmbracoNotificationSuccessResponse : OkObjectResult
|
||||
{
|
||||
public UmbracoNotificationSuccessResponse(string successMessage) : base(null)
|
||||
{
|
||||
var notificationModel = new SimpleNotificationModel
|
||||
{
|
||||
Message = successMessage
|
||||
};
|
||||
notificationModel.AddSuccessNotification(successMessage, string.Empty);
|
||||
|
||||
Value = notificationModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Web.BackOffice.ActionResults;
|
||||
using Umbraco.Cms.Web.BackOffice.Filters;
|
||||
using Umbraco.Cms.Web.Common.ActionsResults;
|
||||
using Umbraco.Extensions;
|
||||
@@ -15,18 +17,43 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
[AppendCurrentEventMessages]
|
||||
public abstract class BackOfficeNotificationsController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
/// <summary>
|
||||
/// returns a 200 OK response with a notification message
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
protected OkObjectResult Ok(string message)
|
||||
{
|
||||
var notificationModel = new SimpleNotificationModel
|
||||
{
|
||||
Message = message
|
||||
};
|
||||
notificationModel.AddSuccessNotification(message, string.Empty);
|
||||
|
||||
return new OkObjectResult(notificationModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to ensure that the error message is an error notification message
|
||||
/// </summary>
|
||||
/// <param name="errorMessage"></param>
|
||||
/// <returns></returns>
|
||||
protected override ActionResult ValidationProblem(string errorMessage)
|
||||
=> ValidationProblem(errorMessage, string.Empty);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a notofication validation problem with a header and message
|
||||
/// </summary>
|
||||
/// <param name="errorHeader"></param>
|
||||
/// <param name="errorMessage"></param>
|
||||
/// <returns></returns>
|
||||
protected ActionResult ValidationProblem(string errorHeader, string errorMessage)
|
||||
{
|
||||
var notificationModel = new SimpleNotificationModel
|
||||
{
|
||||
Message = errorMessage
|
||||
};
|
||||
notificationModel.AddErrorNotification(errorMessage, string.Empty);
|
||||
notificationModel.AddErrorNotification(errorHeader, errorMessage);
|
||||
return new ValidationErrorResult(notificationModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -1550,7 +1550,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
{
|
||||
_contentService.EmptyRecycleBin(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
|
||||
|
||||
return new UmbracoNotificationSuccessResponse(_localizedTextService.Localize("defaultdialogs/recycleBinIsEmpty"));
|
||||
return Ok(_localizedTextService.Localize("defaultdialogs/recycleBinIsEmpty"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2362,8 +2362,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
if (rollbackResult.Success)
|
||||
return Ok();
|
||||
|
||||
var notificationModel = new SimpleNotificationModel();
|
||||
|
||||
switch (rollbackResult.Result)
|
||||
{
|
||||
case OperationResultType.Failed:
|
||||
@@ -2371,22 +2369,12 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
case OperationResultType.FailedExceptionThrown:
|
||||
case OperationResultType.NoOperation:
|
||||
default:
|
||||
notificationModel.AddErrorNotification(
|
||||
_localizedTextService.Localize("speechBubbles/operationFailedHeader"),
|
||||
null); // TODO: There is no specific failed to save error message AFAIK
|
||||
break;
|
||||
return ValidationProblem(_localizedTextService.Localize("speechBubbles/operationFailedHeader"));
|
||||
case OperationResultType.FailedCancelledByEvent:
|
||||
notificationModel.AddErrorNotification(
|
||||
_localizedTextService.Localize("speechBubbles/operationCancelledHeader"),
|
||||
_localizedTextService.Localize("speechBubbles/operationCancelledText"));
|
||||
break;
|
||||
return ValidationProblem(
|
||||
_localizedTextService.Localize("speechBubbles/operationCancelledHeader"),
|
||||
_localizedTextService.Localize("speechBubbles/operationCancelledText"));
|
||||
}
|
||||
|
||||
return ValidationProblem(notificationModel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
/// </summary>
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
[PrefixlessBodyModelValidator]
|
||||
public abstract class ContentTypeControllerBase<TContentType> : UmbracoAuthorizedJsonController
|
||||
public abstract class ContentTypeControllerBase<TContentType> : BackOfficeNotificationsController
|
||||
where TContentType : class, IContentTypeComposition
|
||||
{
|
||||
private readonly EditorValidatorCollection _editorValidatorCollection;
|
||||
@@ -417,9 +417,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
case MoveOperationStatusType.FailedCancelledByEvent:
|
||||
return ValidationProblem();
|
||||
case MoveOperationStatusType.FailedNotAllowedByPath:
|
||||
var notificationModel = new SimpleNotificationModel();
|
||||
notificationModel.AddErrorNotification(LocalizedTextService.Localize("moveOrCopy/notAllowedByPath"), "");
|
||||
return ValidationProblem(notificationModel);
|
||||
return ValidationProblem(LocalizedTextService.Localize("moveOrCopy/notAllowedByPath"));
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@@ -455,10 +453,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
return NotFound();
|
||||
case MoveOperationStatusType.FailedCancelledByEvent:
|
||||
return ValidationProblem();
|
||||
case MoveOperationStatusType.FailedNotAllowedByPath:
|
||||
var notificationModel = new SimpleNotificationModel();
|
||||
notificationModel.AddErrorNotification(LocalizedTextService.Localize("moveOrCopy/notAllowedByPath"), "");
|
||||
return ValidationProblem(notificationModel);
|
||||
case MoveOperationStatusType.FailedNotAllowedByPath:
|
||||
return ValidationProblem(LocalizedTextService.Localize("moveOrCopy/notAllowedByPath"));
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
{
|
||||
_mediaService.EmptyRecycleBin(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
|
||||
|
||||
return new UmbracoNotificationSuccessResponse(_localizedTextService.Localize("defaultdialogs/recycleBinIsEmpty"));
|
||||
return Ok(_localizedTextService.Localize("defaultdialogs/recycleBinIsEmpty"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,7 +10,6 @@ using Umbraco.Cms.Core.Models.Membership;
|
||||
using Umbraco.Cms.Core.Security;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Strings;
|
||||
using Umbraco.Cms.Web.BackOffice.ActionResults;
|
||||
using Umbraco.Cms.Web.BackOffice.Filters;
|
||||
using Umbraco.Cms.Web.Common.Attributes;
|
||||
using Umbraco.Cms.Web.Common.Authorization;
|
||||
@@ -22,7 +21,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
[Authorize(Policy = AuthorizationPolicies.SectionAccessUsers)]
|
||||
[PrefixlessBodyModelValidator]
|
||||
public class UserGroupsController : UmbracoAuthorizedJsonController
|
||||
public class UserGroupsController : BackOfficeNotificationsController
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly IContentService _contentService;
|
||||
@@ -202,10 +201,11 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
_userService.DeleteUserGroup(userGroup);
|
||||
}
|
||||
if (userGroups.Length > 1)
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
_localizedTextService.Localize("speechBubbles/deleteUserGroupsSuccess", new[] {userGroups.Length.ToString()}));
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
_localizedTextService.Localize("speechBubbles/deleteUserGroupSuccess", new[] {userGroups[0].Name}));
|
||||
{
|
||||
return Ok(_localizedTextService.Localize("speechBubbles/deleteUserGroupsSuccess", new[] {userGroups.Length.ToString()}));
|
||||
}
|
||||
|
||||
return Ok(_localizedTextService.Localize("speechBubbles/deleteUserGroupSuccess", new[] {userGroups[0].Name}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,12 +733,10 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
if (users.Length > 1)
|
||||
{
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
_localizedTextService.Localize("speechBubbles/disableUsersSuccess", new[] {userIds.Length.ToString()}));
|
||||
return Ok(_localizedTextService.Localize("speechBubbles/disableUsersSuccess", new[] {userIds.Length.ToString()}));
|
||||
}
|
||||
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
_localizedTextService.Localize("speechBubbles/disableUserSuccess", new[] { users[0].Name }));
|
||||
return Ok(_localizedTextService.Localize("speechBubbles/disableUserSuccess", new[] { users[0].Name }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -757,11 +755,11 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
if (users.Length > 1)
|
||||
{
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
return Ok(
|
||||
_localizedTextService.Localize("speechBubbles/enableUsersSuccess", new[] { userIds.Length.ToString() }));
|
||||
}
|
||||
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
return Ok(
|
||||
_localizedTextService.Localize("speechBubbles/enableUserSuccess", new[] { users[0].Name }));
|
||||
}
|
||||
|
||||
@@ -793,12 +791,12 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
if (userIds.Length == 1)
|
||||
{
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
return Ok(
|
||||
_localizedTextService.Localize("speechBubbles/unlockUserSuccess", new[] {user.Name}));
|
||||
}
|
||||
}
|
||||
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
return Ok(
|
||||
_localizedTextService.Localize("speechBubbles/unlockUsersSuccess", new[] {(userIds.Length - notFound.Count).ToString()}));
|
||||
}
|
||||
|
||||
@@ -816,7 +814,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
}
|
||||
}
|
||||
_userService.Save(users);
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
return Ok(
|
||||
_localizedTextService.Localize("speechBubbles/setUserGroupOnUsersSuccess"));
|
||||
}
|
||||
|
||||
@@ -847,7 +845,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
var userName = user.Name;
|
||||
_userService.Delete(user, true);
|
||||
|
||||
return new UmbracoNotificationSuccessResponse(
|
||||
return Ok(
|
||||
_localizedTextService.Localize("speechBubbles/deleteUserSuccess", new[] { userName }));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user