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

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-10-27 16:50:10 -04:00
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
2020-10-28 09:15:27 -04:00
/**
* The scopes route lists subscopes under the currently active scope.
* For the global scope, the listed scopes are orgs.
* For org scopes, the listed scopes are projects.
*/
2020-10-27 16:50:10 -04:00
export default class ScopesScopeScopesRoute extends Route {
// =services
@service session;
@service router;
2020-10-27 16:50:10 -04:00
// =methods
/**
2020-10-29 16:58:15 -04:00
* If arriving here unauthenticated, redirect to index for further processing.
2020-10-27 16:50:10 -04:00
*/
beforeModel() {
if (!this.session.isAuthenticated) this.router.transitionTo('index');
2020-10-27 16:50:10 -04:00
}
/**
* Loads sub scopes for the current scope.
2020-10-28 09:15:27 -04:00
* @return {Promise
2020-10-27 16:50:10 -04:00
*/
async model() {
const currentScope = this.modelFor('scopes.scope');
const parentScope = !currentScope.isGlobal
? await this.store.findRecord('scope', currentScope.scopeID)
: null;
2020-11-16 15:08:59 -05:00
const subScopes = await this.store.query('scope', {
scope_id: currentScope.id,
});
2020-10-27 16:50:10 -04:00
return {
currentScope,
parentScope,
2020-11-16 15:08:59 -05:00
subScopes,
2020-10-27 16:50:10 -04:00
};
}
}