66ab14144a
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.
34 lines
609 B
JavaScript
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();
|
|
}
|
|
},
|
|
});
|