Handles trying to create a package with a duplicate name
This commit is contained in:
@@ -87,6 +87,11 @@ namespace Umbraco.Core.Packaging
|
||||
|
||||
if (definition.Id == default)
|
||||
{
|
||||
//check if the name already exists
|
||||
var existsByName = packagesXml.Root.Elements("package").Any(x => x.AttributeValue<string>("name") == definition.Name);
|
||||
if (existsByName)
|
||||
return false;
|
||||
|
||||
//need to gen an id and persist
|
||||
// Find max id
|
||||
var maxId = packagesXml.Root.Elements("package").Max(x => x.AttributeValue<int?>("id")) ?? 0;
|
||||
|
||||
@@ -110,7 +110,7 @@ function formHelper(angularHelper, serverValidationManager, notificationsService
|
||||
//Or, some strange server error
|
||||
if (err.status === 400) {
|
||||
//now we need to look through all the validation errors
|
||||
if (err.data && (err.data.ModelState)) {
|
||||
if (err.data && err.data.ModelState) {
|
||||
|
||||
//wire up the server validation errs
|
||||
this.handleServerValidation(err.data.ModelState);
|
||||
@@ -118,11 +118,11 @@ function formHelper(angularHelper, serverValidationManager, notificationsService
|
||||
//execute all server validation events and subscribers
|
||||
serverValidationManager.notifyAndClearAllSubscriptions();
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
|
||||
//TODO: All YSOD handling should be done with an interceptor
|
||||
overlayService.ysod(err);
|
||||
}
|
||||
//TODO: All YSOD handling should be done with an interceptor
|
||||
overlayService.ysod(err);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -57,7 +57,11 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
//save it
|
||||
if (!Services.PackagingService.SavePackage(model))
|
||||
throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("The package with id {definition.Id} was not found"));
|
||||
throw new HttpResponseException(
|
||||
Request.CreateNotificationValidationErrorResponse(
|
||||
model.Id == default
|
||||
? $"A package with the name {model.Name} already exists"
|
||||
: $"The package with id {model.Id} was not found"));
|
||||
|
||||
Services.PackagingService.ExportPackage(model);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user