From 2dd7339c0149034aa5faa4029cff1a82aef35d21 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 4 Oct 2018 17:52:36 +0900 Subject: Add scheduled actions in deployment entity --- app/models/ci/build.rb | 6 +++++- app/models/deployment.rb | 6 +++++- app/serializers/deployment_entity.rb | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 8f1547463ba..9b0bb2e05fc 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -245,10 +245,14 @@ module Ci .fabricate! end - def other_actions + def other_manual_actions pipeline.manual_actions.where.not(name: name) end + def other_scheduled_actions + pipeline.scheduled_actions.where.not(name: name) + end + def pages_generator? Gitlab.config.pages.enabled && self.name == 'pages' diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 6962b54441b..ed61135cb47 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -44,7 +44,11 @@ class Deployment < ActiveRecord::Base end def manual_actions - @manual_actions ||= deployable.try(:other_actions) + @manual_actions ||= deployable.try(:other_manual_actions) + end + + def scheduled_actions + @scheduled_actions ||= deployable.try(:other_scheduled_actions) end def includes_commit?(commit) diff --git a/app/serializers/deployment_entity.rb b/app/serializers/deployment_entity.rb index 344148a1fb7..aa1d9e6292c 100644 --- a/app/serializers/deployment_entity.rb +++ b/app/serializers/deployment_entity.rb @@ -25,4 +25,5 @@ class DeploymentEntity < Grape::Entity expose :commit, using: CommitEntity expose :deployable, using: JobEntity expose :manual_actions, using: JobEntity + expose :scheduled_actions, using: JobEntity end -- cgit v1.2.1 From c12a78969315a8e25128653df2a7515861010b12 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 8 Oct 2018 15:06:00 +0200 Subject: Display scheduled job actions on environments list --- .../components/environment_actions.vue | 30 ++++++++++-- .../environments/components/environment_item.vue | 53 ++++++++-------------- app/assets/stylesheets/pages/environments.scss | 5 -- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index e1f9248bc4c..f4db968b882 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -1,4 +1,6 @@ @@ -77,12 +93,16 @@ export default { :class="{ disabled: isActionDisabled(action) }" :disabled="isActionDisabled(action)" type="button" - class="js-manual-action-link no-btn btn" - @click="onClickAction(action.play_path)" + class="js-manual-action-link no-btn btn d-flex align-items-center" + @click="onClickAction(action)" > - + {{ action.name }} + + + {{ remainingTime(action) }} + diff --git a/app/assets/javascripts/environments/components/environment_item.vue b/app/assets/javascripts/environments/components/environment_item.vue index 11e3b781e5a..ff50e75dbda 100644 --- a/app/assets/javascripts/environments/components/environment_item.vue +++ b/app/assets/javascripts/environments/components/environment_item.vue @@ -12,6 +12,7 @@ import TerminalButtonComponent from './environment_terminal_button.vue'; import MonitoringButtonComponent from './environment_monitoring.vue'; import CommitComponent from '../../vue_shared/components/commit.vue'; import eventHub from '../event_hub'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; /** * Envrionment Item Component @@ -71,21 +72,6 @@ export default { return false; }, - /** - * Verifies is the given environment has manual actions. - * Used to verify if we should render them or nor. - * - * @returns {Boolean|Undefined} - */ - hasManualActions() { - return ( - this.model && - this.model.last_deployment && - this.model.last_deployment.manual_actions && - this.model.last_deployment.manual_actions.length > 0 - ); - }, - /** * Checkes whether the environment is protected. * (`is_protected` currently only set in EE) @@ -152,23 +138,24 @@ export default { return ''; }, - /** - * Returns the manual actions with the name parsed. - * - * @returns {Array.|Undefined} - */ - manualActions() { - if (this.hasManualActions) { - return this.model.last_deployment.manual_actions.map(action => { - const parsedAction = { - name: humanize(action.name), - play_path: action.play_path, - playable: action.playable, - }; - return parsedAction; - }); + actions() { + if (!this.model || !this.model.last_deployment) { + return []; + } + + const { manualActions, scheduledActions } = convertObjectPropsToCamelCase( + this.model.last_deployment, + { deep: true }, + ); + let combinedActions = []; + if (this.canCreateDeployment) { + combinedActions = combinedActions.concat(manualActions || []); } - return []; + combinedActions = combinedActions.concat(scheduledActions || []); + return combinedActions.map(action => ({ + ...action, + name: humanize(action.name), + })); }, /** @@ -624,8 +611,8 @@ export default { /> Date: Tue, 9 Oct 2018 19:54:16 +0200 Subject: Add component test for scheduled jobs in environments actions component --- .../environments/environment_actions_spec.js | 122 +++++++++++++++------ 1 file changed, 88 insertions(+), 34 deletions(-) diff --git a/spec/javascripts/environments/environment_actions_spec.js b/spec/javascripts/environments/environment_actions_spec.js index ea40a1fcd4b..0fbfe95915e 100644 --- a/spec/javascripts/environments/environment_actions_spec.js +++ b/spec/javascripts/environments/environment_actions_spec.js @@ -1,15 +1,19 @@ import Vue from 'vue'; -import actionsComp from '~/environments/components/environment_actions.vue'; +import eventHub from '~/environments/event_hub'; +import EnvironmentActions from '~/environments/components/environment_actions.vue'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import { TEST_HOST } from 'spec/test_constants'; -describe('Actions Component', () => { - let ActionsComponent; - let actionsMock; - let component; +describe('EnvironmentActions Component', () => { + const Component = Vue.extend(EnvironmentActions); + let vm; - beforeEach(() => { - ActionsComponent = Vue.extend(actionsComp); + afterEach(() => { + vm.$destroy(); + }); - actionsMock = [ + describe('manual actions', () => { + const actions = [ { name: 'bar', play_path: 'https://gitlab.com/play', @@ -25,38 +29,88 @@ describe('Actions Component', () => { }, ]; - component = new ActionsComponent({ - propsData: { - actions: actionsMock, - }, - }).$mount(); - }); + beforeEach(() => { + vm = mountComponent(Component, { actions }); + }); - describe('computed', () => { - it('title', () => { - expect(component.title).toEqual('Deploy to...'); + it('should render a dropdown button with icon and title attribute', () => { + expect(vm.$el.querySelector('.fa-caret-down')).toBeDefined(); + expect(vm.$el.querySelector('.dropdown-new').getAttribute('data-original-title')).toEqual( + 'Deploy to...', + ); + expect(vm.$el.querySelector('.dropdown-new').getAttribute('aria-label')).toEqual( + 'Deploy to...', + ); }); - }); - it('should render a dropdown button with icon and title attribute', () => { - expect(component.$el.querySelector('.fa-caret-down')).toBeDefined(); - expect(component.$el.querySelector('.dropdown-new').getAttribute('data-original-title')).toEqual('Deploy to...'); - expect(component.$el.querySelector('.dropdown-new').getAttribute('aria-label')).toEqual('Deploy to...'); - }); + it('should render a dropdown with the provided list of actions', () => { + expect(vm.$el.querySelectorAll('.dropdown-menu li').length).toEqual(actions.length); + }); + + it("should render a disabled action when it's not playable", () => { + expect( + vm.$el.querySelector('.dropdown-menu li:last-child button').getAttribute('disabled'), + ).toEqual('disabled'); - it('should render a dropdown with the provided list of actions', () => { - expect( - component.$el.querySelectorAll('.dropdown-menu li').length, - ).toEqual(actionsMock.length); + expect( + vm.$el.querySelector('.dropdown-menu li:last-child button').classList.contains('disabled'), + ).toEqual(true); + }); }); - it('should render a disabled action when it\'s not playable', () => { - expect( - component.$el.querySelector('.dropdown-menu li:last-child button').getAttribute('disabled'), - ).toEqual('disabled'); + describe('scheduled jobs', () => { + const scheduledJobAction = { + name: 'scheduled action', + playPath: `${TEST_HOST}/scheduled/job/action`, + playable: true, + scheduledAt: '2063-04-05T00:42:00Z', + }; + const expiredJobAction = { + name: 'expired action', + playPath: `${TEST_HOST}/expired/job/action`, + playable: true, + scheduledAt: '2018-10-05T08:23:00Z', + }; + const findDropdownItem = action => { + const buttons = vm.$el.querySelectorAll('.dropdown-menu li button'); + return Array.prototype.find.call(buttons, element => + element.innerText.trim().startsWith(action.name), + ); + }; + + beforeEach(() => { + spyOn(Date, 'now').and.callFake(() => new Date('2063-04-04T00:42:00Z').getTime()); + vm = mountComponent(Component, { actions: [scheduledJobAction, expiredJobAction] }); + }); + + it('emits postAction event after confirming', () => { + const emitSpy = jasmine.createSpy('emit'); + eventHub.$on('postAction', emitSpy); + spyOn(window, 'confirm').and.callFake(() => true); + + findDropdownItem(scheduledJobAction).click(); + + expect(window.confirm).toHaveBeenCalled(); + expect(emitSpy).toHaveBeenCalledWith({ endpoint: scheduledJobAction.playPath }); + }); + + it('does not emit postAction event if confirmation is cancelled', () => { + const emitSpy = jasmine.createSpy('emit'); + eventHub.$on('postAction', emitSpy); + spyOn(window, 'confirm').and.callFake(() => false); + + findDropdownItem(scheduledJobAction).click(); - expect( - component.$el.querySelector('.dropdown-menu li:last-child button').classList.contains('disabled'), - ).toEqual(true); + expect(window.confirm).toHaveBeenCalled(); + expect(emitSpy).not.toHaveBeenCalled(); + }); + + it('displays the remaining time in the dropdown', () => { + expect(findDropdownItem(scheduledJobAction)).toContainText('24:00:00'); + }); + + it('displays 00:00:00 for expired jobs in the dropdown', () => { + expect(findDropdownItem(expiredJobAction)).toContainText('00:00:00'); + }); }); }); -- cgit v1.2.1 From 760fd6751940b0b681800110992b8100dfd10379 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Tue, 9 Oct 2018 22:04:56 +0200 Subject: Add feature flags for scheduled jobs in environments list --- .../components/environment_actions.vue | 2 +- .../projects/environments/environments_spec.rb | 68 +++++++++++++++++++++- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index f4db968b882..1fc571b57fb 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -70,7 +70,7 @@ export default { :aria-label="title" :disabled="isLoading" type="button" - class="dropdown btn btn-default dropdown-new js-dropdown-play-icon-container" + class="dropdown btn btn-default dropdown-new js-environment-actions-dropdown" data-container="body" data-toggle="dropdown" > diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index f0890018286..5671d4b907d 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -162,7 +162,7 @@ describe 'Environments page', :js do end it 'shows a play button' do - find('.js-dropdown-play-icon-container').click + find('.js-environment-actions-dropdown').click expect(page).to have_content(action.name.humanize) end @@ -170,7 +170,7 @@ describe 'Environments page', :js do it 'allows to play a manual action', :js do expect(action).to be_manual - find('.js-dropdown-play-icon-container').click + find('.js-environment-actions-dropdown').click expect(page).to have_content(action.name.humanize) expect { find('.js-manual-action-link').click } @@ -260,6 +260,70 @@ describe 'Environments page', :js do end end end + + context 'when there is a delayed job' do + let!(:pipeline) { create(:ci_pipeline, project: project) } + let!(:build) { create(:ci_build, pipeline: pipeline) } + + let!(:delayed_job) do + create(:ci_build, :scheduled, + pipeline: pipeline, + name: 'delayed job', + stage: 'test', + commands: 'test') + end + + let!(:deployment) do + create(:deployment, + environment: environment, + deployable: build, + sha: project.commit.id) + end + + before do + visit_environments(project) + end + + it 'has a dropdown for actionable jobs' do + expect(page).to have_selector('.dropdown-new.btn.btn-default .ic-play') + end + + it "has link to the delayed job's action" do + find('.js-environment-actions-dropdown').click + + time_diff = [0, delayed_job.scheduled_at - Time.now].max + expect(page).to have_button('Delayed job') + expect(page).to have_content(Time.at(time_diff).utc.strftime("%H:%M:%S")) + end + + context 'when delayed job is expired already' do + let!(:delayed_job) do + create(:ci_build, :expired_scheduled, + pipeline: pipeline, + name: 'delayed job', + stage: 'test', + commands: 'test') + end + + it "shows 00:00:00 as the remaining time" do + find('.js-environment-actions-dropdown').click + + expect(page).to have_content("00:00:00") + end + end + + context 'when user played a delayed job immediately' do + before do + find('.js-environment-actions-dropdown').click + page.accept_confirm { click_button('Delayed job') } + wait_for_requests + end + + it 'enqueues the delayed job', :js do + expect(delayed_job.reload).to be_pending + end + end + end end end -- cgit v1.2.1 From 4f49f54af5b49e28801f0934547ff3159161759b Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Tue, 9 Oct 2018 20:07:48 +0000 Subject: Fix issue URL of TODO in environment_actions.vue --- app/assets/javascripts/environments/components/environment_actions.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index 1fc571b57fb..3cebf68ea93 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -33,7 +33,7 @@ export default { onClickAction(action) { if (action.scheduledAt) { const confirmationMessage = sprintf(s__("DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes."), { jobName: action.name }); - // https://gitlab.com/gitlab-org/gitlab-ce/issues/52099 + // https://gitlab.com/gitlab-org/gitlab-ce/issues/52156 // eslint-disable-next-line no-alert if (!window.confirm(confirmationMessage)) { return; -- cgit v1.2.1 From 1f3f06668b273265a96f526039e139629959a890 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 10 Oct 2018 10:47:31 +0900 Subject: Fix and add spec --- spec/models/ci/build_spec.rb | 46 ++++++++++++++++++++++++++++-- spec/models/deployment_spec.rb | 1 + spec/serializers/deployment_entity_spec.rb | 22 ++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index a046541031e..df0851c1b6c 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1523,11 +1523,11 @@ describe Ci::Build do end end - describe '#other_actions' do + describe '#other_manual_actions' do let(:build) { create(:ci_build, :manual, pipeline: pipeline) } let!(:other_build) { create(:ci_build, :manual, pipeline: pipeline, name: 'other action') } - subject { build.other_actions } + subject { build.other_manual_actions } before do project.add_developer(user) @@ -1558,6 +1558,48 @@ describe Ci::Build do end end + describe '#other_scheduled_actions' do + let(:build) { create(:ci_build, :scheduled, pipeline: pipeline) } + + subject { build.other_scheduled_actions } + + before do + project.add_developer(user) + end + + context "when other build's status is success" do + let!(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: 'other action') } + + it 'returns other actions' do + is_expected.to contain_exactly(other_build) + end + end + + context "when other build's status is failed" do + let!(:other_build) { create(:ci_build, :schedulable, :failed, pipeline: pipeline, name: 'other action') } + + it 'returns other actions' do + is_expected.to contain_exactly(other_build) + end + end + + context "when other build's status is running" do + let!(:other_build) { create(:ci_build, :schedulable, :running, pipeline: pipeline, name: 'other action') } + + it 'does not return other actions' do + is_expected.to be_empty + end + end + + context "when other build's status is scheduled" do + let!(:other_build) { create(:ci_build, :scheduled, pipeline: pipeline, name: 'other action') } + + it 'does not return other actions' do + is_expected.to contain_exactly(other_build) + end + end + end + describe '#persisted_environment' do let!(:environment) do create(:environment, project: project, name: "foo-#{project.default_branch}") diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index b335e0fbeb3..86518c632df 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -12,6 +12,7 @@ describe Deployment do it { is_expected.to delegate_method(:commit).to(:project) } it { is_expected.to delegate_method(:commit_title).to(:commit).as(:try) } it { is_expected.to delegate_method(:manual_actions).to(:deployable).as(:try) } + it { is_expected.to delegate_method(:scheduled_actions).to(:deployable).as(:try) } it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:sha) } diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb index 522c92ce295..698fbd818c0 100644 --- a/spec/serializers/deployment_entity_spec.rb +++ b/spec/serializers/deployment_entity_spec.rb @@ -22,4 +22,26 @@ describe DeploymentEntity do it 'exposes creation date' do expect(subject).to include(:created_at) end + + describe 'scheduled_actions' do + let(:project) { create(:project, :repository) } + let(:pipeline) { create(:ci_pipeline, project: project, user: user) } + let(:build) { create(:ci_build, :success, pipeline: pipeline) } + let(:deployment) { create(:deployment, deployable: build) } + + context 'when deployment has another action' do + let(:other_build) { create(:ci_build, :scheduled, pipeline: pipeline, name: 'other build') } + let!(:other_deployment) { create(:deployment, deployable: other_build) } + + it 'returns other actions' do + expect(subject[:scheduled_actions][0][:name]).to eq 'other build' + end + end + + context 'when deployment does not have other actions' do + it 'does not return other actions' do + expect(subject[:scheduled_actions]).to be_empty + end + end + end end -- cgit v1.2.1 From 4f46fadd7e970b24d13f271596a8f3fd8c774aba Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 10 Oct 2018 13:58:30 +0900 Subject: Add changelog --- .../unreleased/scheduled-manual-jobs-environment-play-buttons.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/scheduled-manual-jobs-environment-play-buttons.yml diff --git a/changelogs/unreleased/scheduled-manual-jobs-environment-play-buttons.yml b/changelogs/unreleased/scheduled-manual-jobs-environment-play-buttons.yml new file mode 100644 index 00000000000..c89af78d989 --- /dev/null +++ b/changelogs/unreleased/scheduled-manual-jobs-environment-play-buttons.yml @@ -0,0 +1,5 @@ +--- +title: Add the Play button for delayed jobs in environment page +merge_request: 22106 +author: +type: added -- cgit v1.2.1 From f056bb1da97d01d6db822b52b733aace8887a588 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 12 Oct 2018 11:22:19 +0900 Subject: Improve deployment entity spec --- spec/serializers/deployment_entity_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb index 698fbd818c0..8793a762f9d 100644 --- a/spec/serializers/deployment_entity_spec.rb +++ b/spec/serializers/deployment_entity_spec.rb @@ -29,16 +29,16 @@ describe DeploymentEntity do let(:build) { create(:ci_build, :success, pipeline: pipeline) } let(:deployment) { create(:deployment, deployable: build) } - context 'when deployment has another action' do - let(:other_build) { create(:ci_build, :scheduled, pipeline: pipeline, name: 'other build') } + context 'when the same pipeline has a scheduled action' do + let(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: 'other build') } let!(:other_deployment) { create(:deployment, deployable: other_build) } - it 'returns other actions' do + it 'returns other scheduled actions' do expect(subject[:scheduled_actions][0][:name]).to eq 'other build' end end - context 'when deployment does not have other actions' do + context 'when the same pipeline does not have a scheduled action' do it 'does not return other actions' do expect(subject[:scheduled_actions]).to be_empty end -- cgit v1.2.1 From 8622763e6cbba52037964d573a8b40ae78abe747 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 12 Oct 2018 11:34:15 +0900 Subject: Use regex for the extecped time --- spec/features/projects/environments/environments_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 5671d4b907d..89e21fcd56b 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -291,9 +291,8 @@ describe 'Environments page', :js do it "has link to the delayed job's action" do find('.js-environment-actions-dropdown').click - time_diff = [0, delayed_job.scheduled_at - Time.now].max expect(page).to have_button('Delayed job') - expect(page).to have_content(Time.at(time_diff).utc.strftime("%H:%M:%S")) + expect(page).to have_content(/\d{2}:\d{2}:\d{2}/) end context 'when delayed job is expired already' do -- cgit v1.2.1 From c8c01bbe0229128f898df167aa7fcc3ef927c4d0 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 15 Oct 2018 12:27:59 +0200 Subject: Make frontend files prettier --- .../javascripts/environments/components/environment_actions.vue | 7 ++++++- app/assets/stylesheets/pages/environments.scss | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index 3cebf68ea93..7ee2bb61007 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -32,7 +32,12 @@ export default { methods: { onClickAction(action) { if (action.scheduledAt) { - const confirmationMessage = sprintf(s__("DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes."), { jobName: action.name }); + const confirmationMessage = sprintf( + s__( + "DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes.", + ), + { jobName: action.name }, + ); // https://gitlab.com/gitlab-org/gitlab-ce/issues/52156 // eslint-disable-next-line no-alert if (!window.confirm(confirmationMessage)) { diff --git a/app/assets/stylesheets/pages/environments.scss b/app/assets/stylesheets/pages/environments.scss index 6f64f1d1d24..676438969b5 100644 --- a/app/assets/stylesheets/pages/environments.scss +++ b/app/assets/stylesheets/pages/environments.scss @@ -360,7 +360,7 @@ } .arrow-shadow { - content: ""; + content: ''; position: absolute; width: 7px; height: 7px; -- cgit v1.2.1 From 3fb7a1f97a812b7b2b5e80a8a0575cb7bfd2d3c4 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 18 Oct 2018 15:47:30 +0900 Subject: Add spec for Deployment#scheduled_actions --- spec/models/deployment_spec.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 86518c632df..9007418ac35 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -12,11 +12,26 @@ describe Deployment do it { is_expected.to delegate_method(:commit).to(:project) } it { is_expected.to delegate_method(:commit_title).to(:commit).as(:try) } it { is_expected.to delegate_method(:manual_actions).to(:deployable).as(:try) } - it { is_expected.to delegate_method(:scheduled_actions).to(:deployable).as(:try) } it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:sha) } + describe '#scheduled_actions' do + subject { deployment.scheduled_actions } + + let(:project) { create(:project, :repository) } + let(:pipeline) { create(:ci_pipeline, project: project) } + let(:build) { create(:ci_build, :success, pipeline: pipeline) } + let(:deployment) { create(:deployment, deployable: build) } + + it 'delegates to other_scheduled_actions' do + expect_any_instance_of(Ci::Build) + .to receive(:other_scheduled_actions) + + subject + end + end + describe 'modules' do it_behaves_like 'AtomicInternalId' do let(:internal_id_attribute) { :iid } -- cgit v1.2.1 From 8ab27e64fe307ec75032a0597fd96caa80e40b67 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 22 Oct 2018 21:43:47 +0200 Subject: Update confirmation modal text for starting delayed jobs immediately --- app/assets/javascripts/environments/components/environment_actions.vue | 2 +- app/assets/javascripts/pipelines/components/pipelines_actions.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index 2d51a13d8a0..6f729676f89 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -34,7 +34,7 @@ export default { if (action.scheduledAt) { const confirmationMessage = sprintf( s__( - "DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes.", + "DelayedJobs|Are you sure you want to run %{jobName} immediately? Otherwise this job will run automatically after it's timer finishes.", ), { jobName: action.name }, ); diff --git a/app/assets/javascripts/pipelines/components/pipelines_actions.vue b/app/assets/javascripts/pipelines/components/pipelines_actions.vue index 16e69759091..83f16c0ffdb 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_actions.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_actions.vue @@ -28,7 +28,7 @@ export default { if (action.scheduled_at) { const confirmationMessage = sprintf( s__( - "DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes.", + "DelayedJobs|Are you sure you want to run %{jobName} immediately? Otherwise this job will run automatically after it's timer finishes.", ), { jobName: action.name }, ); -- cgit v1.2.1 From fc0e99df9f1c232a1d292137000e8ffebea1b259 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 22 Oct 2018 21:45:45 +0200 Subject: Add permission check for delayed job actions --- .../javascripts/environments/components/environment_item.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_item.vue b/app/assets/javascripts/environments/components/environment_item.vue index f2fb0074ea1..eb51118dcf2 100644 --- a/app/assets/javascripts/environments/components/environment_item.vue +++ b/app/assets/javascripts/environments/components/environment_item.vue @@ -141,7 +141,7 @@ export default { }, actions() { - if (!this.model || !this.model.last_deployment) { + if (!this.model || !this.model.last_deployment || !this.canCreateDeployment) { return []; } @@ -149,11 +149,7 @@ export default { this.model.last_deployment, { deep: true }, ); - let combinedActions = []; - if (this.canCreateDeployment) { - combinedActions = combinedActions.concat(manualActions || []); - } - combinedActions = combinedActions.concat(scheduledActions || []); + const combinedActions = (manualActions || []).concat(scheduledActions || []); return combinedActions.map(action => ({ ...action, name: humanize(action.name), -- cgit v1.2.1 From 3cb6607aeadfc53a418d3f8acaa5384d62b912d3 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 22 Oct 2018 22:00:09 +0200 Subject: Use secondary text color for delayed job timer --- .../javascripts/environments/components/environment_actions.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index 6f729676f89..0a3ae384afa 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -102,7 +102,10 @@ export default { {{ action.name }} - + {{ remainingTime(action) }} -- cgit v1.2.1 From 408d08151a3db9f0feac4fa9aa8562f917d5629e Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Wed, 24 Oct 2018 09:47:12 +0200 Subject: Update translations in locale/gitlab.pot --- locale/gitlab.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index bb18d4eccd8..767db59f5ef 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -2166,7 +2166,7 @@ msgstr "" msgid "Define a custom pattern with cron syntax" msgstr "" -msgid "DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes." +msgid "DelayedJobs|Are you sure you want to run %{jobName} immediately? Otherwise this job will run automatically after it's timer finishes." msgstr "" msgid "DelayedJobs|Are you sure you want to run %{job_name} immediately? This job will run automatically after it's timer finishes." -- cgit v1.2.1 From d520338ad4941c6cdfaca25fdcca9a087db12c83 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Wed, 24 Oct 2018 10:00:58 +0200 Subject: Add scheduled_actions to JSON schema --- spec/fixtures/api/schemas/deployment.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/fixtures/api/schemas/deployment.json b/spec/fixtures/api/schemas/deployment.json index 44835386cfc..0828f113495 100644 --- a/spec/fixtures/api/schemas/deployment.json +++ b/spec/fixtures/api/schemas/deployment.json @@ -48,6 +48,10 @@ "manual_actions": { "type": "array", "items": { "$ref": "job/job.json" } + }, + "scheduled_actions": { + "type": "array", + "items": { "$ref": "job/job.json" } } }, "additionalProperties": false -- cgit v1.2.1 From 13c091c443502a6824b78c4e93637b3fc794a47c Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 5 Nov 2018 09:37:09 +0100 Subject: Fix bad merge in app/assets/javascripts/environments/components/environment_item.vue --- app/assets/javascripts/environments/components/environment_item.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/environments/components/environment_item.vue b/app/assets/javascripts/environments/components/environment_item.vue index eb51118dcf2..3deef65f3f5 100644 --- a/app/assets/javascripts/environments/components/environment_item.vue +++ b/app/assets/javascripts/environments/components/environment_item.vue @@ -426,7 +426,7 @@ export default { displayEnvironmentActions() { return ( - this.hasManualActions || + this.actions.length > 0 || this.externalURL || this.monitoringUrl || this.canStopEnvironment || -- cgit v1.2.1