2018-08-14 20:06:26 +00:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { inject as service } from '@ember/service';
|
2020-06-11 21:23:00 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2018-08-14 20:06:26 +00:00
|
|
|
|
2020-06-11 21:23:00 +00:00
|
|
|
@classic
|
|
|
|
export default class RunRoute extends Route {
|
|
|
|
@service can;
|
|
|
|
@service store;
|
|
|
|
@service system;
|
2018-08-14 20:06:26 +00:00
|
|
|
|
2020-06-12 20:48:52 +00:00
|
|
|
breadcrumbs = [
|
2018-08-14 20:06:26 +00:00
|
|
|
{
|
|
|
|
label: 'Run',
|
|
|
|
args: ['jobs.run'],
|
|
|
|
},
|
2020-06-12 20:48:52 +00:00
|
|
|
];
|
2018-08-15 00:29:51 +00:00
|
|
|
|
2021-07-14 20:27:24 +00:00
|
|
|
beforeModel(transition) {
|
|
|
|
if (this.can.cannot('run job', null, { namespace: transition.to.queryParams.namespace })) {
|
2020-01-20 20:57:01 +00:00
|
|
|
this.transitionTo('jobs');
|
|
|
|
}
|
2020-06-11 21:23:00 +00:00
|
|
|
}
|
2020-01-20 20:57:01 +00:00
|
|
|
|
2018-08-15 00:29:51 +00:00
|
|
|
model() {
|
2021-04-29 20:00:59 +00:00
|
|
|
// When jobs are created with a namespace attribute, it is verified against
|
|
|
|
// available namespaces to prevent redirecting to a non-existent namespace.
|
|
|
|
return this.store.findAll('namespace').then(() => {
|
|
|
|
return this.store.createRecord('job');
|
2018-08-15 00:29:51 +00:00
|
|
|
});
|
2020-06-11 21:23:00 +00:00
|
|
|
}
|
2018-08-15 00:29:51 +00:00
|
|
|
|
|
|
|
resetController(controller, isExiting) {
|
|
|
|
if (isExiting) {
|
2019-03-26 07:46:44 +00:00
|
|
|
controller.model.deleteRecord();
|
2018-08-15 00:29:51 +00:00
|
|
|
}
|
2020-06-11 21:23:00 +00:00
|
|
|
}
|
|
|
|
}
|