open-nomad/ui/app/routes/jobs/run.js
Buck Doyle 66ab14144a
ui: Change Run Job availability based on ACLs (#5944)
This builds on API changes in #6017 and #6021 to conditionally turn off the
“Run Job” button based on the current token’s capabilities, or the capabilities
of the anonymous policy if no token is present.

If you try to visit the job-run route directly, it redirects to the job list.
2020-01-20 14:57:01 -06:00

34 lines
609 B
JavaScript

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default Route.extend({
can: service(),
store: service(),
system: service(),
breadcrumbs: [
{
label: 'Run',
args: ['jobs.run'],
},
],
beforeModel() {
if (this.can.cannot('run job')) {
this.transitionTo('jobs');
}
},
model() {
return this.store.createRecord('job', {
namespace: this.get('system.activeNamespace'),
});
},
resetController(controller, isExiting) {
if (isExiting) {
controller.model.deleteRecord();
}
},
});