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> </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> </div>

View file

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