Merge pull request #267 from coreos-inc/deletethrob

Add a throbber and better dialog for deleting repo
This commit is contained in:
Jimmy Zelinskie 2015-07-23 11:28:06 -04:00
commit 242c322850
2 changed files with 24 additions and 6 deletions

View file

@ -103,4 +103,17 @@
</div>
</div>
</div>
<!-- Delete Repository Dialog -->
<div class="cor-confirm-dialog"
dialog-context="deleteRepoInfo"
dialog-action="deleteRepo(info, callback)"
dialog-title="Delete Repository"
dialog-action-title="Delete Repository">
<div class="co-alert co-alert-danger" style="margin-bottom: 10px;">
This action cannot be undone!
</div>
Continue with deletion of this repository?
</div>
</div>

View file

@ -13,6 +13,8 @@ angular.module('quay').directive('repoPanelSettings', function () {
'isEnabled': '=isEnabled'
},
controller: function($scope, $element, ApiService, Config) {
$scope.deleteDialogCounter = 0;
$scope.getBadgeFormat = function(format, repository) {
if (!repository) { return ''; }
@ -39,22 +41,25 @@ angular.module('quay').directive('repoPanelSettings', function () {
};
$scope.askDelete = function() {
bootbox.confirm('Are you sure you want delete this repository?', function(r) {
if (!r) { return; }
$scope.deleteRepo();
});
$scope.deleteDialogCounter++;
$scope.deleteRepoInfo = {
'counter': $scope.deleteDialogCounter
};
};
$scope.deleteRepo = function() {
$scope.deleteRepo = function(info, callback) {
var params = {
'repository': $scope.repository.namespace + '/' + $scope.repository.name
};
var errorHandler = ApiService.errorDisplay('Could not delete repository', callback);
ApiService.deleteRepository(null, params).then(function() {
callback(true);
setTimeout(function() {
document.location = '/repository/';
}, 100);
}, ApiService.errorDisplay('Could not delete repository'));
}, errorHandler);
};