-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(index): add button to delete all pact versions
- Loading branch information
Showing
10 changed files
with
482 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%link{rel: 'stylesheet', href: '/stylesheets/index.css'} | ||
%link{rel: 'stylesheet', href: '/stylesheets/material-menu.css'} | ||
%link{rel: 'stylesheet', href: '/stylesheets/material-icon.css'} | ||
%script{type: 'text/javascript', src:'/javascripts/jquery.tablesorter.min.js'} | ||
%script{type: 'text/javascript', src:'/javascripts/material-menu.js'} | ||
%script{type: 'text/javascript', src:'/javascripts/index.js'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
$(document).ready(function() { | ||
$(".integration-settings") | ||
.materialMenu("init", { | ||
position: "overlay", | ||
animationSpeed: 1, | ||
items: [ | ||
{ | ||
type: "normal", | ||
text: "Delete all pact versions...", | ||
click: function(e) { | ||
promptToDeletePactVersions($(e).data(), $(e).closest("tr")); | ||
} | ||
} | ||
] | ||
}) | ||
.click(function() { | ||
$(this).materialMenu("open"); | ||
}); | ||
}); | ||
|
||
function promptToDeletePactVersions(rowData, row) { | ||
const agree = confirm( | ||
`This will delete all versions of the pact between ${ | ||
rowData.consumerName | ||
} and ${rowData.providerName}. It will keep ${rowData.consumerName} and ${ | ||
rowData.providerName | ||
}, and all other data related to them (webhooks, application versions, and tags). Do you wish to continue?` | ||
); | ||
if (agree) { | ||
deletePactVersions( | ||
rowData.pactVersionsUrl, | ||
function() { | ||
handleDeletionSuccess(row); | ||
}, | ||
handleDeletionFailure | ||
); | ||
} | ||
} | ||
|
||
function handleDeletionSuccess(row) { | ||
row | ||
.children("td, th") | ||
.animate({ padding: 0 }) | ||
.wrapInner("<div />") | ||
.children() | ||
.slideUp(function() { | ||
$(this) | ||
.closest("tr") | ||
.remove(); | ||
}); | ||
} | ||
|
||
function handleDeletionFailure(response) { | ||
let errorMessage = null; | ||
|
||
if (response.error && response.error.message && response.error.reference) { | ||
errorMessage = | ||
"Could not delete resources due to error: " + | ||
response.error.message + | ||
"\nError reference: " + | ||
response.error.reference; | ||
} else { | ||
errorMessage = | ||
"Could not delete resources due to error: " + JSON.stringify(response); | ||
} | ||
|
||
alert(errorMessage); | ||
} | ||
|
||
function deletePactVersions(url, successCallback, errorCallback) { | ||
$.ajax({ | ||
url: url, | ||
dataType: "json", | ||
type: "delete", | ||
accepts: { | ||
text: "application/hal+json" | ||
}, | ||
success: function(data, textStatus, jQxhr) { | ||
successCallback(); | ||
}, | ||
error: function(jqXhr, textStatus, errorThrown) { | ||
errorCallback(jqXhr.responseJSON); | ||
} | ||
}); | ||
} |
Oops, something went wrong.