diff --git a/app/assets/javascripts/angularjs/pull_requests/pull_request_controller.js.coffee b/app/assets/javascripts/angularjs/pull_requests/pull_request_controller.js.coffee index b72a85eb3..b2c49e1d1 100644 --- a/app/assets/javascripts/angularjs/pull_requests/pull_request_controller.js.coffee +++ b/app/assets/javascripts/angularjs/pull_requests/pull_request_controller.js.coffee @@ -54,32 +54,49 @@ PullRequestController = (dataservice, $http, ApiPullRequest, ApiProject, DateTim vm.branch = branch vm.reopen = -> + return false if vm.processing + vm.processing = true vm.pull_resource.$update pull_request_action: "reopen" , -> vm.getPullRequest() + vm.processing = false vm.close = -> + return false if vm.processing + vm.processing = true vm.pull_resource.$update pull_request_action: "close" , -> vm.getPullRequest() + vm.processing = false vm.merge = -> + return false if vm.processing + vm.processing = true vm.pull_resource.$merge -> vm.getPullRequest() + vm.processing = false vm.deleteBranch = -> + return false if vm.processing + vm.processing = true vm.project_resource.$delete_branch vm.branch_params(), (-> # success vm.branch = null + vm.processing = false ), -> # error vm.getBranch() + vm.processing = false vm.restoreBranch = -> + return false if vm.processing + vm.processing = true vm.project_resource.$restore_branch vm.branch_params(), (-> # success vm.getBranch() + vm.processing = false ), -> # error vm.getBranch() + vm.processing = false vm.branch_params = -> owner: vm.pull_params.owner diff --git a/app/views/projects/pull_requests/_status.html.slim b/app/views/projects/pull_requests/_status.html.slim index f829f5a27..b94c27c3f 100644 --- a/app/views/projects/pull_requests/_status.html.slim +++ b/app/views/projects/pull_requests/_status.html.slim @@ -1,5 +1,9 @@ +i> class= 'fa fa-spinner fa-spin fa-lg offset10 boffset10' ng-show= 'pullCtrl.processing' - if policy(@pull).merge? - button.btn.btn-primary[ href = '' ng-click = 'pullCtrl.merge()' ng-show = "pullCtrl.pull.status == 'ready'" ] + button.btn.btn-success[ href= '' + ng-click= 'pullCtrl.merge()' + ng-show= "pullCtrl.pull.status == 'ready'" + ng-disabled= 'pullCtrl.processing' ] = t 'projects.pull_requests.ready' h5 ng-show = '!pullCtrl.pull.mergeable' @@ -29,24 +33,28 @@ h5 ng-show = '!pullCtrl.pull.mergeable' | ) - if !@pull.cross_pull? && policy(@project).write? - div[ ng-init = "pullCtrl.getBranch('#{@pull.from_ref}')" - ng-show = "pullCtrl.pull.status == 'closed' || pullCtrl.pull.status == 'merged'" ] - button.btn.btn-primary[ href = '' - ng-click = 'pullCtrl.deleteBranch()' - ng-show = "pullCtrl.branch && pullCtrl.branch.object.sha == pullCtrl.pull.from_ref.sha" ] + div[ ng-init= "pullCtrl.getBranch('#{@pull.from_ref}')" + ng-show= "pullCtrl.pull.status == 'closed' || pullCtrl.pull.status == 'merged'" ] + button.btn.btn-primary[ href= '' + ng-click= 'pullCtrl.deleteBranch()' + ng-show= "pullCtrl.branch && pullCtrl.branch.object.sha == pullCtrl.pull.from_ref.sha" + ng-disabled= 'pullCtrl.processing' ] = t 'layout.projects.delete_branch' - button.btn.btn-primary[ href = '' - ng-click = 'pullCtrl.restoreBranch()' - ng-hide = 'pullCtrl.branch' ] + button.btn.btn-primary[ href= '' + ng-click= 'pullCtrl.restoreBranch()' + ng-hide= 'pullCtrl.branch' + ng-disabled= 'pullCtrl.processing' ] = t 'layout.projects.restore_branch' .clearfix - if policy(@pull).update? - button.btn.btn-primary.pull-right[ href = '' - ng-click = 'pullCtrl.reopen()' - ng-show = "pullCtrl.pull.status == 'closed'" ] + button.btn.btn-primary.pull-right[ href= '' + ng-click= 'pullCtrl.reopen()' + ng-show= "pullCtrl.pull.status == 'closed'" + ng-disabled= 'pullCtrl.processing' ] = t '.reopen' - button.btn.btn-danger.pull-right[ href = '' - ng-click = 'pullCtrl.close()' - ng-show = "pullCtrl.pull.status == 'ready' || pullCtrl.pull.status == 'open' || pullCtrl.pull.status == 'blocked'" ] + button.btn.btn-danger.pull-right[ href= '' + ng-click= 'pullCtrl.close()' + ng-show= "pullCtrl.pull.status == 'ready' || pullCtrl.pull.status == 'open' || pullCtrl.pull.status == 'blocked'" + ng-disabled= 'pullCtrl.processing' ] = t '.close'