2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-01 09:39:41 -06:00
|
|
|
*/
|
|
|
|
|
|
2021-11-03 14:35:55 -07:00
|
|
|
import Route from '@ember/routing/route';
|
2021-11-10 07:32:40 -08:00
|
|
|
import { inject as service } from '@ember/service';
|
2021-11-03 14:35:55 -07:00
|
|
|
|
2021-11-08 11:16:32 -08:00
|
|
|
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends Route {
|
2021-11-09 12:01:30 -08:00
|
|
|
// =services
|
|
|
|
|
|
2022-11-07 15:17:23 -08:00
|
|
|
@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
|
|
|
}
|
|
|
|
|
}
|