From d6885fdaa1eed82f148994d8bf0398b737bd160c Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 26 Feb 2015 11:31:51 +0100 Subject: [PATCH 1/4] Remove unneeded log related functions from repo-actions --- app/views/repo-actions.coffee | 53 ----------------------------------- 1 file changed, 53 deletions(-) diff --git a/app/views/repo-actions.coffee b/app/views/repo-actions.coffee index f40f5942..7674ea73 100644 --- a/app/views/repo-actions.coffee +++ b/app/views/repo-actions.coffee @@ -1,5 +1,4 @@ `import Ember from 'ember'` -`import { plainTextLog as plainTextLogUrl } from 'travis/utils/urls'` `import Job from 'travis/models/job'` `import config from 'travis/config/environment'` `import BasicView from 'travis/views/basic'` @@ -36,20 +35,6 @@ View = BasicView.extend Travis.flash(error: 'An error occured when canceling the build') - 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') - cancelJob: -> if @get('canCancelJob') Travis.flash(notice: 'Job cancellation has been scheduled.') @@ -94,44 +79,6 @@ View = BasicView.extend @get('displayRequeueJob') && @get('hasPermission') ).property('displayRequeueJob', 'hasPermission') - showDownloadLog: (-> - @get('jobIdForLog') && (@get('isJobTab') || @get('isBuildTab')) - ).property('jobIdForLog', 'isJobTab', 'isBuildTab') - - _job: (-> - if id = @get('jobIdForLog') - store =Travis.__container__.lookup('store:main') - store.find('job', id) - store.recordForId('job', id) - ).property('jobIdForLog') - - jobIdForLog: (-> - job = @get('job.id') - unless job - if @get('build.jobs.length') == 1 - job = @get('build.jobs').objectAt?(0).get?('id') - job - ).property('job.id', 'build.jobs.firstObject.id', 'build.jobs.length') - - plainTextLogUrl: (-> - if id = @get('jobIdForLog') - url = plainTextLogUrl(id) - if config.pro - token = @get('job.log.token') || @get('build.jobs.firstObject.log.token') - url += "&access_token=#{token}" - url - ).property('jobIdForLog', 'job.log.token', 'build.jobs.firstObject.log.token') - - canRemoveLog: (-> - @get('displayRemoveLog') - ).property('displayRemoveLog') - - displayRemoveLog: (-> - if job = @get('_job') - (@get('isJobTab') || (@get('isBuildTab') && @get('build.jobs.length') == 1)) && - job.get('canRemoveLog') && @get('hasPermission') - ).property('isJobTab', 'isBuildTab', 'build.jobs.length', '_job.canRemoveLog', 'jobIdForLog', 'canRemoveLog', 'hasPermission') - canCancelBuild: (-> @get('displayCancelBuild') && @get('hasPermission') ).property('displayCancelBuild', 'hasPermission') From c72db42231df93fcb60efba8db6261c305b8d801 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 26 Feb 2015 11:32:08 +0100 Subject: [PATCH 2/4] Fix displaying restart build button --- app/views/repo-actions.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repo-actions.coffee b/app/views/repo-actions.coffee index 7674ea73..c7577ed4 100644 --- a/app/views/repo-actions.coffee +++ b/app/views/repo-actions.coffee @@ -69,7 +69,7 @@ View = BasicView.extend canRequeueBuild: (-> @get('displayRequeueBuild') && @get('hasPermission') - ).property('displayRequireBuild', 'hasPermission') + ).property('displayRequeueBuild', 'hasPermission') displayRequeueJob: (-> @get('isJobTab') && @get('job.isFinished') From 2cf1b5b6790a894352e5616809d7b1a1c612e43c Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 26 Feb 2015 11:33:32 +0100 Subject: [PATCH 3/4] Revert "Remove unneeded log related functions from repo-actions" This reverts commit d6885fdaa1eed82f148994d8bf0398b737bd160c. It seems that we still use some actions from there. --- app/views/repo-actions.coffee | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/app/views/repo-actions.coffee b/app/views/repo-actions.coffee index c7577ed4..66656445 100644 --- a/app/views/repo-actions.coffee +++ b/app/views/repo-actions.coffee @@ -1,4 +1,5 @@ `import Ember from 'ember'` +`import { plainTextLog as plainTextLogUrl } from 'travis/utils/urls'` `import Job from 'travis/models/job'` `import config from 'travis/config/environment'` `import BasicView from 'travis/views/basic'` @@ -35,6 +36,20 @@ View = BasicView.extend Travis.flash(error: 'An error occured when canceling the build') + 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') + cancelJob: -> if @get('canCancelJob') Travis.flash(notice: 'Job cancellation has been scheduled.') @@ -79,6 +94,44 @@ View = BasicView.extend @get('displayRequeueJob') && @get('hasPermission') ).property('displayRequeueJob', 'hasPermission') + showDownloadLog: (-> + @get('jobIdForLog') && (@get('isJobTab') || @get('isBuildTab')) + ).property('jobIdForLog', 'isJobTab', 'isBuildTab') + + _job: (-> + if id = @get('jobIdForLog') + store =Travis.__container__.lookup('store:main') + store.find('job', id) + store.recordForId('job', id) + ).property('jobIdForLog') + + jobIdForLog: (-> + job = @get('job.id') + unless job + if @get('build.jobs.length') == 1 + job = @get('build.jobs').objectAt?(0).get?('id') + job + ).property('job.id', 'build.jobs.firstObject.id', 'build.jobs.length') + + plainTextLogUrl: (-> + if id = @get('jobIdForLog') + url = plainTextLogUrl(id) + if config.pro + token = @get('job.log.token') || @get('build.jobs.firstObject.log.token') + url += "&access_token=#{token}" + url + ).property('jobIdForLog', 'job.log.token', 'build.jobs.firstObject.log.token') + + canRemoveLog: (-> + @get('displayRemoveLog') + ).property('displayRemoveLog') + + displayRemoveLog: (-> + if job = @get('_job') + (@get('isJobTab') || (@get('isBuildTab') && @get('build.jobs.length') == 1)) && + job.get('canRemoveLog') && @get('hasPermission') + ).property('isJobTab', 'isBuildTab', 'build.jobs.length', '_job.canRemoveLog', 'jobIdForLog', 'canRemoveLog', 'hasPermission') + canCancelBuild: (-> @get('displayCancelBuild') && @get('hasPermission') ).property('displayCancelBuild', 'hasPermission') From dfc4c9077d624481cda94bffb0d4e6b96d51ed8b Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 26 Feb 2015 11:35:56 +0100 Subject: [PATCH 4/4] Fix favicon specs for async behaviour --- tests/unit/utils/favicon-manager-test.coffee | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/unit/utils/favicon-manager-test.coffee b/tests/unit/utils/favicon-manager-test.coffee index d5013381..b35a7543 100644 --- a/tests/unit/utils/favicon-manager-test.coffee +++ b/tests/unit/utils/favicon-manager-test.coffee @@ -25,9 +25,13 @@ test 'set favicon if there is no link tag in head', -> link = fakeHead.find('link')[0] ok link, 'link tag should be added by favicon manager' - equal link.getAttribute('href'), 'foobar', 'href attribute for the link should be properly set' - equal link.getAttribute('rel'), 'icon', 'rel attribute for the link should be properly set' - equal link.getAttribute('type'), 'image/png', 'type attribute for the link should be properly set' + stop() + setTimeout -> + start() + equal link.getAttribute('href'), 'foobar', 'href attribute for the link should be properly set' + equal link.getAttribute('rel'), 'icon', 'rel attribute for the link should be properly set' + equal link.getAttribute('type'), 'image/png', 'type attribute for the link should be properly set' + , 20 test 'replace exisiting link tag', -> fakeHead.append($('')) @@ -42,9 +46,13 @@ test 'replace exisiting link tag', -> link = links[0] ok !link.getAttribute('id'), 'existing link should be replaced with a new one' - equal link.getAttribute('href'), 'foobar', 'href attribute for the link should be properly set' - equal link.getAttribute('rel'), 'icon', 'rel attribute for the link should be properly set' - equal link.getAttribute('type'), 'image/png', 'type attribute for the link should be properly set' + stop() + setTimeout -> + start() + equal link.getAttribute('href'), 'foobar', 'href attribute for the link should be properly set' + equal link.getAttribute('rel'), 'icon', 'rel attribute for the link should be properly set' + equal link.getAttribute('type'), 'image/png', 'type attribute for the link should be properly set' + , 20 test 'find link with rel=icon only', -> fakeHead.append($(''))