From b763a00baca2c12b6e27c1250f01f14e1b3c0431 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 13 Mar 2015 10:30:05 +0100 Subject: [PATCH] Fix remove-log popup --- app/components/code-climate-popup.coffee | 10 ++++++++ app/components/remove-log-popup.coffee | 23 +++++++++++++++++++ .../components/code-climate-popup.hbs | 2 +- app/templates/components/remove-log-popup.hbs | 10 ++++++++ app/templates/components/repo-actions.hbs | 12 ---------- app/templates/jobs/pre.hbs | 2 ++ app/templates/remove-log.hbs | 8 ------- app/views/pre.coffee | 15 ------------ remove-log-popup.coffee | 10 ++++++++ 9 files changed, 56 insertions(+), 36 deletions(-) create mode 100644 app/components/code-climate-popup.coffee create mode 100644 app/components/remove-log-popup.coffee create mode 100644 app/templates/components/remove-log-popup.hbs delete mode 100644 app/templates/remove-log.hbs create mode 100644 remove-log-popup.coffee diff --git a/app/components/code-climate-popup.coffee b/app/components/code-climate-popup.coffee new file mode 100644 index 00000000..206106e5 --- /dev/null +++ b/app/components/code-climate-popup.coffee @@ -0,0 +1,10 @@ +`import Ember from 'ember'` + +Component = Ember.Component.extend( + actions: + close: -> + $('.popup').removeClass('display') + return false +) + +`export default Component` diff --git a/app/components/remove-log-popup.coffee b/app/components/remove-log-popup.coffee new file mode 100644 index 00000000..4ec49473 --- /dev/null +++ b/app/components/remove-log-popup.coffee @@ -0,0 +1,23 @@ +`import Ember from 'ember'` + +Component = Ember.Component.extend( + actions: + close: -> + $('.popup').removeClass('display') + return false + + removeLog: -> + $('.popup').removeClass('display') + job = @get('job') + 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') +) + +`export default Component` diff --git a/app/templates/components/code-climate-popup.hbs b/app/templates/components/code-climate-popup.hbs index 372f41ef..7035909b 100644 --- a/app/templates/components/code-climate-popup.hbs +++ b/app/templates/components/code-climate-popup.hbs @@ -1,6 +1,6 @@ - - - {{code-climate-popup}} diff --git a/app/templates/jobs/pre.hbs b/app/templates/jobs/pre.hbs index 9ab267bd..e969488b 100644 --- a/app/templates/jobs/pre.hbs +++ b/app/templates/jobs/pre.hbs @@ -1,3 +1,5 @@ +{{remove-log-popup job=view.job}} +
{{#if view.job.notStarted}}
Hang tight, the log cannot be shown until the build has started.
diff --git a/app/templates/remove-log.hbs b/app/templates/remove-log.hbs deleted file mode 100644 index ad8e2fa7..00000000 --- a/app/templates/remove-log.hbs +++ /dev/null @@ -1,8 +0,0 @@ - -

This action will remove the log permanently!

-

Do you want to continue?

-

- Yes, please! - or - Cancel -

diff --git a/app/views/pre.coffee b/app/views/pre.coffee index bda4bd62..89f475d5 100644 --- a/app/views/pre.coffee +++ b/app/views/pre.coffee @@ -121,23 +121,8 @@ View = BasicView.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 diff --git a/remove-log-popup.coffee b/remove-log-popup.coffee new file mode 100644 index 00000000..ce0299b7 --- /dev/null +++ b/remove-log-popup.coffee @@ -0,0 +1,10 @@ +