diff --git a/ui/app/adapters/deployment.js b/ui/app/adapters/deployment.js index 5530166d6beb..d24628c369ae 100644 --- a/ui/app/adapters/deployment.js +++ b/ui/app/adapters/deployment.js @@ -1,6 +1,16 @@ import Watchable from './watchable'; export default class DeploymentAdapter extends Watchable { + fail(deployment) { + const id = deployment.get('id'); + const url = urlForAction(this.urlForFindRecord(id, 'deployment'), '/fail'); + return this.ajax(url, 'POST', { + data: { + DeploymentId: id, + }, + }); + } + promote(deployment) { const id = deployment.get('id'); const url = urlForAction(this.urlForFindRecord(id, 'deployment'), '/promote'); diff --git a/ui/app/components/job-page/parts/latest-deployment.js b/ui/app/components/job-page/parts/latest-deployment.js index d8cfdd0b6600..4b5052a21a17 100644 --- a/ui/app/components/job-page/parts/latest-deployment.js +++ b/ui/app/components/job-page/parts/latest-deployment.js @@ -24,4 +24,22 @@ export default class LatestDeployment extends Component { } }) promote; + + @task(function*() { + try { + yield this.get('job.latestDeployment.content').fail(); + } catch (err) { + let message = messageFromAdapterError(err); + + if (err instanceof ForbiddenError) { + message = 'Your ACL token does not grant permission to fail deployments.'; + } + + this.handleError({ + title: 'Could Not Fail Deployment', + description: message, + }); + } + }) + fail; } diff --git a/ui/app/components/two-step-button.js b/ui/app/components/two-step-button.js index a3bb4f5f0673..4bf934eadb45 100644 --- a/ui/app/components/two-step-button.js +++ b/ui/app/components/two-step-button.js @@ -4,11 +4,12 @@ import { next } from '@ember/runloop'; import { equal } from '@ember/object/computed'; import { task, waitForEvent } from 'ember-concurrency'; import RSVP from 'rsvp'; -import { classNames } from '@ember-decorators/component'; +import { classNames, classNameBindings } from '@ember-decorators/component'; import classic from 'ember-classic-decorator'; @classic @classNames('two-step-button') +@classNameBindings('inlineText:has-inline-text') export default class TwoStepButton extends Component { idleText = ''; cancelText = ''; @@ -17,7 +18,7 @@ export default class TwoStepButton extends Component { awaitingConfirmation = false; disabled = false; alignRight = false; - isInfoAction = false; + inlineText = false; onConfirm() {} onCancel() {} diff --git a/ui/app/models/deployment.js b/ui/app/models/deployment.js index 66d6cb297e3f..5cbb7a0852c5 100644 --- a/ui/app/models/deployment.js +++ b/ui/app/models/deployment.js @@ -69,4 +69,9 @@ export default class Deployment extends Model { assert('A deployment needs to requirePromotion to be promoted', this.requiresPromotion); return this.store.adapterFor('deployment').promote(this); } + + fail() { + assert('A deployment must be running to be failed', this.isRunning); + return this.store.adapterFor('deployment').fail(this); + } } diff --git a/ui/app/styles/components/two-step-button.scss b/ui/app/styles/components/two-step-button.scss index 4c787f0264ce..c4dfcbb2665f 100644 --- a/ui/app/styles/components/two-step-button.scss +++ b/ui/app/styles/components/two-step-button.scss @@ -5,6 +5,20 @@ font-size: $body-size; line-height: 1; + &.has-inline-text { + display: inline-flex; + align-items: center; + + button { + margin-left: 0.5ch; + } + + .confirmation-text { + position: static; + margin-right: 0.5ch; + } + } + .confirmation-text { position: absolute; left: 0; diff --git a/ui/app/templates/clients/client/index.hbs b/ui/app/templates/clients/client/index.hbs index c1b327656eff..7c5587403c5f 100644 --- a/ui/app/templates/clients/client/index.hbs +++ b/ui/app/templates/clients/client/index.hbs @@ -212,7 +212,11 @@ {{this.job.latestDeployment.status}} - {{#if this.job.latestDeployment.requiresPromotion}} - - {{/if}} +
+ {{#if this.job.latestDeployment.isRunning}} + + {{/if}} + {{#if this.job.latestDeployment.requiresPromotion}} + + {{/if}} +
diff --git a/ui/app/templates/components/two-step-button.hbs b/ui/app/templates/components/two-step-button.hbs index af84491ae99c..5fea8862ea59 100644 --- a/ui/app/templates/components/two-step-button.hbs +++ b/ui/app/templates/components/two-step-button.hbs @@ -2,7 +2,7 @@