open-nomad/ui/app/routes/jobs/run.js
Jai Bhagat cc61ad66bf refactoring for same regression in job versions
In job versions, if you have an ACL token with a write policy
you should be able to revert a job, however, that was not the
case here. This is because we're using ember-can to check if
the user can run a job. That permission relies on policiesSupportRunning
which uses a function called namespaceIncludesCapability. We're going to
need to refactor any cases that use this function.
2021-07-20 16:24:42 -04:00

38 lines
903 B
JavaScript

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import classic from 'ember-classic-decorator';
@classic
export default class RunRoute extends Route {
@service can;
@service store;
@service system;
breadcrumbs = [
{
label: 'Run',
args: ['jobs.run'],
},
];
beforeModel(transition) {
if (this.can.cannot('run job', null, { namespace: transition.to.queryParams.namespace })) {
this.transitionTo('jobs');
}
}
model() {
// 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');
});
}
resetController(controller, isExiting) {
if (isExiting) {
controller.model.deleteRecord();
}
}
}