Files
threshold-ui/ui/admin/app/routes/scopes/scope/edit.js
T

37 lines
942 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
2020-10-29 16:58:15 -04:00
import { inject as service } from '@ember/service';
export default class ScopesScopeEditRoute extends Route {
2020-10-29 16:58:15 -04:00
// =services
@service session;
@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() {
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);
}
}
}