Files
threshold-ui/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/managed-groups.js
T

40 lines
878 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Route from '@ember/routing/route';
2021-11-10 07:32:40 -08:00
import { inject as service } from '@ember/service';
2021-11-08 11:16:32 -08:00
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends Route {
2021-11-09 12:01:30 -08:00
// =services
@service store;
2021-11-10 09:07:17 -08:00
@service can;
//=methods
2021-11-08 11:16:32 -08:00
/**
*
* @returns {Promise{[ManagedGroupsModel]}}
*/
2022-01-14 16:56:59 -05:00
async model() {
2021-11-08 11:16:32 -08:00
const authMethod = this.modelFor('scopes.scope.auth-methods.auth-method');
const { id: auth_method_id } = authMethod;
2022-01-31 12:02:37 -05:00
const canListManagedGroups = this.can.can('list model', authMethod, {
2021-11-10 14:07:19 -08:00
collection: 'managed-groups',
});
2022-01-14 16:56:59 -05:00
let managedGroups;
2021-11-10 14:07:19 -08:00
if (canListManagedGroups) {
2022-01-14 16:56:59 -05:00
managedGroups = await this.store.query('managed-group', {
auth_method_id,
});
2021-11-10 14:07:19 -08:00
}
2022-01-14 16:56:59 -05:00
return {
authMethod,
managedGroups,
};
2021-11-08 11:16:32 -08:00
}
}