disable buttons when processing in a pull request

This commit is contained in:
Alexander Machehin 2015-04-23 10:15:10 +05:00
parent 4009af4ff0
commit 29c027eb2a
2 changed files with 40 additions and 15 deletions

View File

@ -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

View File

@ -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'
@ -33,20 +37,24 @@ h5 ng-show = '!pullCtrl.pull.mergeable'
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-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' ]
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'" ]
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'" ]
ng-show= "pullCtrl.pull.status == 'ready' || pullCtrl.pull.status == 'open' || pullCtrl.pull.status == 'blocked'"
ng-disabled= 'pullCtrl.processing' ]
= t '.close'