From 2cc35556ab6481c1a23df9753c55480da8d0b913 Mon Sep 17 00:00:00 2001 From: Mathias Meyer Date: Sun, 8 Sep 2013 09:21:37 +0200 Subject: [PATCH] Pull job/repository actions out of cog menu. It's very hard to notice where something is, when it's hidden in that menu. --- assets/scripts/app/templates/builds/show.hbs | 2 + assets/scripts/app/templates/jobs/show.hbs | 1 + .../app/templates/repos/show/actions.hbs | 38 ++++++++ .../app/templates/repos/show/tools.hbs | 38 +------- assets/scripts/app/views/repo/show.coffee | 92 ++++++++++--------- assets/styles/main/tools.sass | 4 + 6 files changed, 95 insertions(+), 80 deletions(-) create mode 100644 assets/scripts/app/templates/repos/show/actions.hbs diff --git a/assets/scripts/app/templates/builds/show.hbs b/assets/scripts/app/templates/builds/show.hbs index 282c44d1..c72369d2 100644 --- a/assets/scripts/app/templates/builds/show.hbs +++ b/assets/scripts/app/templates/builds/show.hbs @@ -42,8 +42,10 @@
{{commit.committerName}}
{{/if}} + {{view Travis.RepoActionsView}} {{/with}} +
{{t builds.message}}
{{formatMessage build.commit.message repoBinding=build.repo}}
diff --git a/assets/scripts/app/templates/jobs/show.hbs b/assets/scripts/app/templates/jobs/show.hbs index fd233cc2..56e4a8ac 100644 --- a/assets/scripts/app/templates/jobs/show.hbs +++ b/assets/scripts/app/templates/jobs/show.hbs @@ -41,6 +41,7 @@
{{commit.committerName}}
{{/if}} + {{view Travis.RepoActionsView}} {{/with}}
{{t jobs.message}}
{{formatMessage job.commit.message repoBinding=job.repo}}
diff --git a/assets/scripts/app/templates/repos/show/actions.hbs b/assets/scripts/app/templates/repos/show/actions.hbs new file mode 100644 index 00000000..23de48d5 --- /dev/null +++ b/assets/scripts/app/templates/repos/show/actions.hbs @@ -0,0 +1,38 @@ +
+ +
diff --git a/assets/scripts/app/templates/repos/show/tools.hbs b/assets/scripts/app/templates/repos/show/tools.hbs index a394597d..df2e666a 100644 --- a/assets/scripts/app/templates/repos/show/tools.hbs +++ b/assets/scripts/app/templates/repos/show/tools.hbs @@ -1,34 +1,7 @@
@@ -57,7 +23,7 @@

- Yes! Do it! + Yes, do it! or Cancel

diff --git a/assets/scripts/app/views/repo/show.coffee b/assets/scripts/app/views/repo/show.coffee index d49b9330..cf10ed16 100644 --- a/assets/scripts/app/views/repo/show.coffee +++ b/assets/scripts/app/views/repo/show.coffee @@ -85,13 +85,47 @@ Travis.reopen $('#tools .menu').toggleClass('display') event.stopPropagation() + regenerateKeyPopup: -> + if @get('canRegenerateKey') + @set('active', true) + @closeMenu() + @popup(event) + event.stopPropagation() + + regenerateKey: -> + @popupCloseAll() + + (@get('repo.content') || @get('repo')).regenerateKey + success: => + @popup('regeneration-success') + error: -> + Travis.lookup('controller:flash').loadFlashes([{ error: 'Travis encountered an error while trying to regenerate the key, please try again.'}]) + + displayRegenerateKey: true + + canRegenerateKey: (-> + @get('displayRegenerateKey') && @get('hasPermission') + ).property('hasPermission') + + hasPermission: (-> + if permissions = @get('currentUser.permissions') + permissions.contains parseInt(@get('repo.id')) + ).property('currentUser.permissions.length', 'repo.id') + + RepoActionsView: Travis.View.extend + templateName: 'repos/show/actions' + + repoBinding: 'controller.repo' + buildBinding: 'controller.build' + jobBinding: 'controller.job' + tabBinding: 'controller.controllers.repo.tab' + currentUserBinding: 'controller.controllers.repo.currentUser' + requeue: -> - @closeMenu() @get('build').requeue() cancelBuild: -> if @get('canCancelBuild') - @closeMenu() Travis.flash(notice: 'Build cancelation has been scheduled.') @get('build').cancel().then -> Travis.flash(success: 'Build has been successfuly canceled.') @@ -105,7 +139,6 @@ Travis.reopen cancelJob: -> if @get('canCancelJob') - @closeMenu() Travis.flash(notice: 'Job cancelation has been scheduled.') @get('job').cancel().then -> Travis.flash(success: 'Job has been successfuly canceled.') @@ -118,41 +151,16 @@ Travis.reopen Travis.flash(error: 'An error occured when canceling the job') statusImages: -> - @set('active', true) - @closeMenu() @popupCloseAll() view = Travis.StatusImagesView.create(toolsView: this) - # TODO: create a general mechanism for managing current popup - # and move all popups to use it Travis.View.currentPopupView = view view.appendTo($('body')) event.stopPropagation() - regenerateKeyPopup: -> - if @get('canRegenerateKey') - @set('active', true) - @closeMenu() - @popup(event) - event.stopPropagation() - - requeueBuild: -> - if @get('canRequeueBuild') - @closeMenu() - @get('build').requeue() - - requeueJob: -> - if @get('canRequeueJob') - @closeMenu() - @get('job').requeue() - - regenerateKey: -> - @popupCloseAll() - - (@get('repo.content') || @get('repo')).regenerateKey - success: => - @popup('regeneration-success') - error: -> - Travis.lookup('controller:flash').loadFlashes([{ error: 'Travis encountered an error while trying to regenerate the key, please try again.'}]) + hasPermission: (-> + if permissions = @get('currentUser.permissions') + permissions.contains parseInt(@get('repo.id')) + ).property('currentUser.permissions.length', 'repo.id') displayRequeueBuild: (-> @get('isBuildTab') && @get('build.isFinished') @@ -200,22 +208,18 @@ Travis.reopen @get('isJobTab') && @get('job.canCancel') ).property('isJobTab', 'job.canCancel') - displayRegenerateKey: true - - canRegenerateKey: (-> - @get('displayRegenerateKey') && @get('hasPermission') - ).property('hasPermission') - - isJobTab: (-> @get('tab') == 'job' - ).property('tab') + ).property('tab', 'repo.id') isBuildTab: (-> ['current', 'build'].indexOf(@get('tab')) > -1 ).property('tab') - hasPermission: (-> - if permissions = @get('currentUser.permissions') - permissions.contains parseInt(@get('repo.id')) - ).property('currentUser.permissions.length', 'repo.id') + requeueBuild: -> + if @get('canRequeueBuild') + @get('build').requeue() + + requeueJob: -> + if @get('canRequeueJob') + @get('job').requeue() diff --git a/assets/styles/main/tools.sass b/assets/styles/main/tools.sass index 7f85a225..ecf17756 100644 --- a/assets/styles/main/tools.sass +++ b/assets/styles/main/tools.sass @@ -32,3 +32,7 @@ &.disabled cursor: default color: $color-link-disabled + +#actions + float: right + text-align: right