feat: 🎸 add search and filtering to scopes tab in a role (#2371)

* feat: 🎸 add search and filtering to scopes tab in a role

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13886
This commit is contained in:
Lisbet Alvarez authored and Lisbet Alvarez committed 2024-07-15 17:23:00 -07:00
1 parent 3bcc5aabd8
commit c340d9ab89
17 files changed
+638 -135

No files matched your search

+17 -2
View File
@@ -7,6 +7,11 @@ import factory from '../generated/factories/role';
import { trait } from 'miragejs';
import permissions from '../helpers/permissions';
import generateId from '../helpers/id';
import {
TYPE_SCOPE_GLOBAL,
TYPE_SCOPE_ORG,
TYPE_SCOPE_PROJECT,
} from 'api/models/scope';
export default factory.extend({
authorized_actions: () =>
@@ -33,9 +38,19 @@ export default factory.extend({
* Adds grant scopes to the role.
*/
withScopes: trait({
afterCreate(role) {
afterCreate(role, server) {
const { scope } = role;
role.update({ grant_scope_ids: ['this', scope.id] });
const newScope =
scope.id === 'global'
? server.create('scope', {
scope: { id: 'global', type: TYPE_SCOPE_GLOBAL },
type: 'org',
})
: server.create('scope', {
scope: { id: scope.id, type: TYPE_SCOPE_ORG },
type: TYPE_SCOPE_PROJECT,
});
role.update({ grant_scope_ids: ['this', newScope.id] });
},
}),