diff --git a/app/styles/app/_mixins/mixins.sass b/app/styles/app/_mixins/mixins.sass index 0e44cb0b..443d540a 100644 --- a/app/styles/app/_mixins/mixins.sass +++ b/app/styles/app/_mixins/mixins.sass @@ -30,6 +30,9 @@ border-top-left-radius: $radius border-top-right-radius: $radius +%border-radius-4px + border-radius: 4px + %border-top-4px border-top-left-radius: 4px border-top-right-radius: 4px diff --git a/app/styles/app/components/buttons.sass b/app/styles/app/components/buttons.sass index 87772870..bde80e4e 100644 --- a/app/styles/app/components/buttons.sass +++ b/app/styles/app/components/buttons.sass @@ -83,3 +83,14 @@ $button-border-color: #d4d4d4 #auth #navigation .button--signin display: none +.button--grey + height: 24px + padding: 0 10px 0 10px + background-color: #696867 + color: #f2f2f2 + font-size: $font-size-small + border: none + @extend %border-radius-4px + &:hover, + &:active + background-color: lighten(#696867, 10) diff --git a/app/styles/app/main/log.sass b/app/styles/app/main/log.sass index be32a1f5..bbe0986b 100644 --- a/app/styles/app/main/log.sass +++ b/app/styles/app/main/log.sass @@ -67,10 +67,28 @@ background: inline-image('ui/workers-close.svg') no-repeat right 6px .log-header - height: 40px + height: 44px margin: 0 + padding: .8em + text-align: right background-color: $log-header-bg @extend %border-top-4px + .icon + display: inline-block + background: + size: 100% + repeat: no-repeat + width: 1.3em + height: 1.2em + margin-right: 6px + vertical-align: middle + .icon--downloadLog + background-image: inline-image('icons/download-log-icon.svg') + .icon--removeLog + background-image: inline-image('icons/remove-log-icon.svg') + button + margin-left: .4em + .log-body position: relative diff --git a/app/styles/app/main/tools.sass b/app/styles/app/main/tools.sass index 15062e94..6e3ccefe 100644 --- a/app/styles/app/main/tools.sass +++ b/app/styles/app/main/tools.sass @@ -88,12 +88,6 @@ li.cancel-build a, li.cancel-job a background-image: inline-image('icons/off.svg') - li.download-log a - background-image: inline-image('icons/download-log.svg') - - li.remove-log a - background-image: inline-image('icons/delete-log.svg') - li.code-climate a background-image: inline-image('icons/code-climate-icon.svg') diff --git a/app/templates/jobs/pre.hbs b/app/templates/jobs/pre.hbs index 9c2d06cc..2435ddce 100644 --- a/app/templates/jobs/pre.hbs +++ b/app/templates/jobs/pre.hbs @@ -1,7 +1,9 @@
- - + {{#if view.canRemoveLog}} + + {{/if}} + Download Log
diff --git a/app/views/pre.coffee b/app/views/pre.coffee index 5f86af96..de867224 100644 --- a/app/views/pre.coffee +++ b/app/views/pre.coffee @@ -2,6 +2,7 @@ `import LogFolder from 'travis/utils/log-folder'` `import config from 'travis/config/environment'` `import { plainTextLog as plainTextLogUrl } from 'travis/utils/urls'` +`import BasicView from 'travis/views/basic'` Log.DEBUG = false Log.LIMIT = 10000 @@ -22,8 +23,9 @@ Log.Scroll.prototype = $.extend new Log.Listener, $('#main').scrollTop(0) $('html, body').scrollTop(element.offset()?.top - (window.innerHeight / 3)) # weird, html works in chrome, body in firefox -View = Ember.View.extend +View = BasicView.extend templateName: 'jobs/pre' + currentUserBinding: 'controller.currentUser' logWillChange: (-> console.log 'log view: log will change' if Log.DEBUG @@ -99,6 +101,16 @@ View = Ember.View.extend url ).property('job.log.id', 'job.log.token') + hasPermission: (-> + if permissions = @get('currentUser.permissions') + permissions.contains parseInt(@get('job.repo.id')) + ).property('currentUser.permissions.length', 'job.repo.id') + + canRemoveLog: (-> + if job = @get('job') + job.get('canRemoveLog') && @get('hasPermission') + ).property('job.canRemoveLog', 'hasPermission') + actions: toTop: () -> $(window).scrollTop(0) @@ -108,6 +120,26 @@ View = Ember.View.extend @engine.autoCloseFold = !Travis.tailing.isActive() event.preventDefault() + removeLog: -> + @popupCloseAll() + if @get('canRemoveLog') + job = @get('_job') || @get('build.jobs.firstObject') + job.removeLog().then -> + Travis.flash(success: 'Log has been successfully removed.') + , (xhr) -> + if xhr.status == 409 + Travis.flash(error: 'Log can\'t be removed') + else if xhr.status == 401 + Travis.flash(error: 'You don\'t have sufficient access to remove the log') + else + Travis.flash(error: 'An error occured when removing the log') + + removeLogPopup: -> + # if @get('canRemoveLog') + @set('active', true) + @popup('remove-log-popup') + return false + noop: -> # TODO required? `export default View` diff --git a/public/images/icons/delete-log.svg b/public/images/icons/delete-log.svg deleted file mode 100644 index ae4f5553..00000000 --- a/public/images/icons/delete-log.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/public/images/icons/download-log-icon.svg b/public/images/icons/download-log-icon.svg new file mode 100644 index 00000000..1df8b979 --- /dev/null +++ b/public/images/icons/download-log-icon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/public/images/icons/download-log.svg b/public/images/icons/download-log.svg deleted file mode 100644 index 2d4ff02b..00000000 --- a/public/images/icons/download-log.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/public/images/icons/remove-log-icon.svg b/public/images/icons/remove-log-icon.svg new file mode 100644 index 00000000..a75c8bd8 --- /dev/null +++ b/public/images/icons/remove-log-icon.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + +