2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2020-10-27 17:47:59 -04:00
|
|
|
import Route from '@ember/routing/route';
|
2020-10-29 16:58:15 -04:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-10-27 17:47:59 -04:00
|
|
|
|
|
|
|
|
export default class ScopesScopeEditRoute extends Route {
|
2020-10-29 16:58:15 -04:00
|
|
|
// =services
|
|
|
|
|
|
|
|
|
|
@service session;
|
2022-01-03 12:35:48 -05:00
|
|
|
@service router;
|
2024-01-12 15:01:16 -08:00
|
|
|
@service store;
|
2020-10-29 16:58:15 -04:00
|
|
|
// =methods
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If arriving here unauthenticated, redirect to index for further processing.
|
|
|
|
|
*/
|
|
|
|
|
beforeModel() {
|
2022-01-03 12:35:48 -05:00
|
|
|
if (!this.session.isAuthenticated) this.router.transitionTo('index');
|
2020-10-29 16:58:15 -04:00
|
|
|
}
|
2024-01-12 15:01:16 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds storage policy name to the context.
|
|
|
|
|
* @param {Controller} controller
|
|
|
|
|
* @param {PolicyModel} policy
|
|
|
|
|
*/
|
|
|
|
|
async setupController(controller, policy) {
|
|
|
|
|
super.setupController(...arguments);
|
|
|
|
|
if (policy.storage_policy_id) {
|
|
|
|
|
const { storage_policy_id } = policy;
|
|
|
|
|
const record = await this.store.findRecord('policy', storage_policy_id);
|
|
|
|
|
controller.set('storage_policy', record);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-27 17:47:59 -04:00
|
|
|
}
|