Add Start Job action on the job overview page for when a job is dead
This commit is contained in:
parent
e9454e1b05
commit
a4d951a757
|
@ -1,4 +1,5 @@
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
|
import messageFromAdapterError from 'nomad-ui/utils/message-from-adapter-error';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: '',
|
tagName: '',
|
||||||
|
@ -19,5 +20,35 @@ export default Component.extend({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
startJob() {
|
||||||
|
const job = this.get('job');
|
||||||
|
job
|
||||||
|
.fetchRawDefinition()
|
||||||
|
.then(definition => {
|
||||||
|
// A stopped job will have this Stop = true metadata
|
||||||
|
// If Stop is true when submitted to the cluster, the job
|
||||||
|
// won't transition from the Dead to Running state.
|
||||||
|
delete definition.Stop;
|
||||||
|
job.set('_newDefinition', JSON.stringify(definition));
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return job.parse();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return job.update();
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
let message = messageFromAdapterError(err);
|
||||||
|
if (!message || message === 'Forbidden') {
|
||||||
|
message = 'Your ACL token does not grant permission to stop jobs.';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.get('handleError')({
|
||||||
|
title: 'Could Not Start Job',
|
||||||
|
description: message,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,5 +10,13 @@
|
||||||
confirmText="Yes, Stop"
|
confirmText="Yes, Stop"
|
||||||
confirmationMessage="Are you sure you want to stop this job?"
|
confirmationMessage="Are you sure you want to stop this job?"
|
||||||
onConfirm=(action "stopJob")}}
|
onConfirm=(action "stopJob")}}
|
||||||
|
{{else}}
|
||||||
|
{{two-step-button
|
||||||
|
data-test-start
|
||||||
|
idleText="Start"
|
||||||
|
cancelText="Cancel"
|
||||||
|
confirmText="Yes, Start"
|
||||||
|
confirmationMessage="Are you sure you want to start this job?"
|
||||||
|
onConfirm=(action "startJob")}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
Loading…
Reference in New Issue