Skip to content

Commit

Permalink
Changed site delete endpoint to HTTP DELETE. See #1725
Browse files Browse the repository at this point in the history
  • Loading branch information
tidyui committed Oct 20, 2021
1 parent 976c4fd commit c504166
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 31 deletions.
6 changes: 3 additions & 3 deletions core/Piranha.Manager/Controllers/SiteApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ public async Task<StatusMessage> SaveContent(SiteContentEditModel model)
/// </summary>
/// <param name="id">The unique id</param>
/// <returns>The result of the operation</returns>
[Route("delete/{id}")]
[HttpGet]
[Route("delete")]
[HttpDelete]
[Authorize(Policy = Permission.SitesDelete)]
public async Task<StatusMessage> Delete(Guid id)
public async Task<StatusMessage> Delete([FromBody]Guid id)
{
try
{
Expand Down
32 changes: 19 additions & 13 deletions core/Piranha.Manager/assets/dist/js/piranha.siteedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,28 @@ piranha.siteedit = new Vue({

var self = this;

fetch(piranha.baseUrl + "manager/api/site/delete/" + self.id)
.then(function (response) { return response.json(); })
.then(function (result) {
piranha.notifications.push(result);
fetch(piranha.baseUrl + "manager/api/site/delete", {
method: "delete",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(self.id)
})
.then(function (response) { return response.json(); })
.then(function (result) {
piranha.notifications.push(result);

if (result.type === "success") {
$("#siteedit").modal("hide");
if (result.type === "success") {
$("#siteedit").modal("hide");

if (self.callback)
{
self.callback();
self.callback = null;
}
if (self.callback)
{
self.callback();
self.callback = null;
}
})
.catch(function (error) { console.log("error:", error ); });
}
})
.catch(function (error) { console.log("error:", error ); });
},
selectRegion: function (region) {
this.selectedRegion = region;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 19 additions & 13 deletions core/Piranha.Manager/assets/src/js/piranha.siteedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,28 @@ piranha.siteedit = new Vue({

var self = this;

fetch(piranha.baseUrl + "manager/api/site/delete/" + self.id)
.then(function (response) { return response.json(); })
.then(function (result) {
piranha.notifications.push(result);
fetch(piranha.baseUrl + "manager/api/site/delete", {
method: "delete",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(self.id)
})
.then(function (response) { return response.json(); })
.then(function (result) {
piranha.notifications.push(result);

if (result.type === "success") {
$("#siteedit").modal("hide");
if (result.type === "success") {
$("#siteedit").modal("hide");

if (self.callback)
{
self.callback();
self.callback = null;
}
if (self.callback)
{
self.callback();
self.callback = null;
}
})
.catch(function (error) { console.log("error:", error ); });
}
})
.catch(function (error) { console.log("error:", error ); });
},
selectRegion: function (region) {
this.selectedRegion = region;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ piranha.useredit= new Vue({
confirmText: piranha.resources.texts.delete,
onConfirm: function () {
var ok = false;
fetch(piranha.baseUrl + "manager/user/delete/" + userId)
fetch(piranha.baseUrl + "manager/user/delete", {
method: "delete",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(userId)
})
.then(function (response) {
ok = response.ok;
return response.json();
Expand Down

0 comments on commit c504166

Please sign in to comment.