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.branch = branch
vm.reopen = -> vm.reopen = ->
return false if vm.processing
vm.processing = true
vm.pull_resource.$update vm.pull_resource.$update
pull_request_action: "reopen" pull_request_action: "reopen"
, -> , ->
vm.getPullRequest() vm.getPullRequest()
vm.processing = false
vm.close = -> vm.close = ->
return false if vm.processing
vm.processing = true
vm.pull_resource.$update vm.pull_resource.$update
pull_request_action: "close" pull_request_action: "close"
, -> , ->
vm.getPullRequest() vm.getPullRequest()
vm.processing = false
vm.merge = -> vm.merge = ->
return false if vm.processing
vm.processing = true
vm.pull_resource.$merge -> vm.pull_resource.$merge ->
vm.getPullRequest() vm.getPullRequest()
vm.processing = false
vm.deleteBranch = -> vm.deleteBranch = ->
return false if vm.processing
vm.processing = true
vm.project_resource.$delete_branch vm.branch_params(), (-> # success vm.project_resource.$delete_branch vm.branch_params(), (-> # success
vm.branch = null vm.branch = null
vm.processing = false
), -> # error ), -> # error
vm.getBranch() vm.getBranch()
vm.processing = false
vm.restoreBranch = -> vm.restoreBranch = ->
return false if vm.processing
vm.processing = true
vm.project_resource.$restore_branch vm.branch_params(), (-> # success vm.project_resource.$restore_branch vm.branch_params(), (-> # success
vm.getBranch() vm.getBranch()
vm.processing = false
), -> # error ), -> # error
vm.getBranch() vm.getBranch()
vm.processing = false
vm.branch_params = -> vm.branch_params = ->
owner: vm.pull_params.owner 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? - 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' = t 'projects.pull_requests.ready'
h5 ng-show = '!pullCtrl.pull.mergeable' h5 ng-show = '!pullCtrl.pull.mergeable'
@ -29,24 +33,28 @@ h5 ng-show = '!pullCtrl.pull.mergeable'
| ) | )
- if !@pull.cross_pull? && policy(@project).write? - if !@pull.cross_pull? && policy(@project).write?
div[ ng-init = "pullCtrl.getBranch('#{@pull.from_ref}')" div[ ng-init= "pullCtrl.getBranch('#{@pull.from_ref}')"
ng-show = "pullCtrl.pull.status == 'closed' || pullCtrl.pull.status == 'merged'" ] ng-show= "pullCtrl.pull.status == 'closed' || pullCtrl.pull.status == 'merged'" ]
button.btn.btn-primary[ href = '' button.btn.btn-primary[ href= ''
ng-click = 'pullCtrl.deleteBranch()' 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' = t 'layout.projects.delete_branch'
button.btn.btn-primary[ href = '' button.btn.btn-primary[ href= ''
ng-click = 'pullCtrl.restoreBranch()' ng-click= 'pullCtrl.restoreBranch()'
ng-hide = 'pullCtrl.branch' ] ng-hide= 'pullCtrl.branch'
ng-disabled= 'pullCtrl.processing' ]
= t 'layout.projects.restore_branch' = t 'layout.projects.restore_branch'
.clearfix .clearfix
- if policy(@pull).update? - if policy(@pull).update?
button.btn.btn-primary.pull-right[ href = '' button.btn.btn-primary.pull-right[ href= ''
ng-click = 'pullCtrl.reopen()' ng-click= 'pullCtrl.reopen()'
ng-show = "pullCtrl.pull.status == 'closed'" ] ng-show= "pullCtrl.pull.status == 'closed'"
ng-disabled= 'pullCtrl.processing' ]
= t '.reopen' = t '.reopen'
button.btn.btn-danger.pull-right[ href = '' button.btn.btn-danger.pull-right[ href= ''
ng-click = 'pullCtrl.close()' 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' = t '.close'