From 60938b6eb692367e6fde923a0cbbf10af91397d4 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 19 Apr 2018 10:14:59 -0700 Subject: [PATCH] Move common title parts into a part component --- ui/app/components/job-page/parts/title.js | 23 +++++++++++++++++++ .../components/job-page/parts/title.hbs | 13 +++++++++++ 2 files changed, 36 insertions(+) create mode 100644 ui/app/components/job-page/parts/title.js create mode 100644 ui/app/templates/components/job-page/parts/title.hbs diff --git a/ui/app/components/job-page/parts/title.js b/ui/app/components/job-page/parts/title.js new file mode 100644 index 000000000..fb8e3232c --- /dev/null +++ b/ui/app/components/job-page/parts/title.js @@ -0,0 +1,23 @@ +import Component from '@ember/component'; + +export default Component.extend({ + tagName: '', + + job: null, + title: null, + + handleError() {}, + + actions: { + stopJob() { + this.get('job') + .stop() + .catch(() => { + this.get('handleError')({ + title: 'Could Not Stop Job', + description: 'Your ACL token does not grant permission to stop jobs.', + }); + }); + }, + }, +}); diff --git a/ui/app/templates/components/job-page/parts/title.hbs b/ui/app/templates/components/job-page/parts/title.hbs new file mode 100644 index 000000000..2de3064d3 --- /dev/null +++ b/ui/app/templates/components/job-page/parts/title.hbs @@ -0,0 +1,13 @@ +

+ {{or title job.name}} + {{job.status}} + {{yield}} + {{#if (not (eq job.status "dead"))}} + {{two-step-button + idleText="Stop" + cancelText="Cancel" + confirmText="Yes, Stop" + confirmationMessage="Are you sure you want to stop this job?" + onConfirm=(action "stopJob")}} + {{/if}} +