2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2022-12-06 17:45:36 +00:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import withForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
|
|
|
|
import WithModelErrorHandling from 'nomad-ui/mixins/with-model-error-handling';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { hash } from 'rsvp';
|
|
|
|
|
|
|
|
export default class PoliciesRoute extends Route.extend(
|
|
|
|
withForbiddenState,
|
|
|
|
WithModelErrorHandling
|
|
|
|
) {
|
|
|
|
@service can;
|
|
|
|
@service store;
|
|
|
|
@service router;
|
|
|
|
|
|
|
|
beforeModel() {
|
|
|
|
if (this.can.cannot('list policies')) {
|
|
|
|
this.router.transitionTo('/jobs');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async model() {
|
|
|
|
return await hash({
|
|
|
|
policies: this.store.query('policy', { reload: true }),
|
2022-12-15 18:11:28 +00:00
|
|
|
tokens:
|
|
|
|
this.can.can('list tokens') &&
|
|
|
|
this.store.query('token', { reload: true }),
|
2022-12-06 17:45:36 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|