Skip to content

Commit

Permalink
Restart a single task from the task detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
DingoEatingFuzz committed May 20, 2019
1 parent a699e1b commit 769aae7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ui/app/controllers/allocations/allocation/task/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import { task } from 'ember-concurrency';

export default Controller.extend({
network: alias('model.resources.networks.firstObject'),
Expand All @@ -20,4 +21,25 @@ export default Controller.extend({
)
.sortBy('name');
}),

error: computed(() => {
// { title, description }
return null;
}),

onDismiss() {
this.set('error', null);
},

restartTask: task(function*() {
try {
yield this.model.restart();
} catch (err) {
console.log('OOPs', err);
this.set('error', {
title: 'Could Not Restart Task',
description: 'Your ACL token does not grant allocation lifecyle permissions.',
});
}
}),
});
25 changes: 25 additions & 0 deletions ui/app/templates/allocations/allocation/task/index.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
{{partial "allocations/allocation/task/subnav"}}
<section class="section">
{{#if error}}
<div class="notification is-danger">
<div class="columns">
<div class="column">
<h3 data-test-error-title class="title is-4">{{error.title}}</h3>
<p data-test-error-body>{{error.description}}</p>
</div>
<div class="column is-centered is-minimum">
<button data-test-error-close class="button is-danger" onclick={{action onDismiss}}>Okay</button>
</div>
</div>
</div>
{{/if}}

<h1 class="title" data-test-title>
{{model.name}}
<span class="bumper-left tag {{model.stateClass}}" data-test-state>{{model.state}}</span>
{{#if model.isRunning}}
{{two-step-button
data-test-restart
idleText="Restart"
cancelText="Cancel"
confirmText="Yes, Restart"
confirmationMessage="Are you sure? This will restart the task in-place."
awaitingConfirmation=restartTask.isRunning
disabled=restartTask.isRunning
onConfirm=(perform restartTask)}}
{{/if}}
</h1>

<div class="boxed-section is-small">
Expand Down

0 comments on commit 769aae7

Please sign in to comment.