Add links to role principals with ability (#1545)
chore: 🤖 add links to role/principals
This commit is contained in:
1 parent
f2c0458fb5
commit
f3dbd7cdab
6 files changed
+67
-15
No files matched your search
@@ -155,7 +155,6 @@ export default class RoleModel extends GeneratedRoleModel {
|
|||||||
// return a promise resolving to an empty array
|
// return a promise resolving to an empty array
|
||||||
return resolve([]);
|
return resolve([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =methods
|
// =methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{{#if this.isManagedGroup}}
|
||||||
|
<LinkTo
|
||||||
|
@route={{this.link}}
|
||||||
|
@models={{array @model.auth_method_id @model.id}}
|
||||||
|
>
|
||||||
|
{{@model.displayName}}
|
||||||
|
</LinkTo>
|
||||||
|
{{else}}
|
||||||
|
<LinkTo @route={{this.link}} @model={{@model.id}}>
|
||||||
|
{{@model.displayName}}
|
||||||
|
</LinkTo>
|
||||||
|
{{/if}}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import Component from '@glimmer/component';
|
||||||
|
|
||||||
|
const principalTypeRoutes = {
|
||||||
|
user: 'scopes.scope.users.user',
|
||||||
|
group: 'scopes.scope.groups.group',
|
||||||
|
'managed-group':
|
||||||
|
'scopes.scope.auth-methods.auth-method.managed-groups.managed-group',
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class LinkToPrincipalComponent extends Component {
|
||||||
|
/**
|
||||||
|
* return true if its a managed group model
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
get isManagedGroup() {
|
||||||
|
return this.args.model.constructor.modelName === 'managed-group';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return route based on principal type
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
get link() {
|
||||||
|
return principalTypeRoutes[this.args.model.constructor.modelName];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<Hds::Badge
|
||||||
|
@icon={{this.icon}}
|
||||||
|
@text={{t
|
||||||
|
(concat 'resources.role.principal.types.' @model.constructor.modelName)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import Component from '@glimmer/component';
|
||||||
|
|
||||||
|
const principalTypes = {
|
||||||
|
user: 'user',
|
||||||
|
group: 'folder-users',
|
||||||
|
'managed-group': 'cloud-lock',
|
||||||
|
};
|
||||||
|
export default class PrincipalTypeBadgeComponent extends Component {
|
||||||
|
/**
|
||||||
|
* Display icons based on the pricipal type
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
|
||||||
|
get icon() {
|
||||||
|
return principalTypes[this.args.model.constructor.modelName];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,7 +46,11 @@
|
|||||||
{{#each @model.principals as |principal|}}
|
{{#each @model.principals as |principal|}}
|
||||||
<body.row as |row|>
|
<body.row as |row|>
|
||||||
<row.headerCell>
|
<row.headerCell>
|
||||||
{{principal.displayName}}
|
{{#if (can 'readPrincipal role' principal)}}
|
||||||
|
<LinkToPrincipal @model={{principal}} />
|
||||||
|
{{else}}
|
||||||
|
{{principal.displayName}}
|
||||||
|
{{/if}}
|
||||||
{{#if principal.accountName}}
|
{{#if principal.accountName}}
|
||||||
<br /><Hds::Badge @text={{principal.accountName}} />
|
<br /><Hds::Badge @text={{principal.accountName}} />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@@ -61,19 +65,7 @@
|
|||||||
</Copyable>
|
</Copyable>
|
||||||
</row.cell>
|
</row.cell>
|
||||||
<row.cell>
|
<row.cell>
|
||||||
<Hds::Badge
|
<PrincipalTypeBadge @model={{principal}} />
|
||||||
@icon={{if
|
|
||||||
(eq principal.constructor.modelName 'group')
|
|
||||||
'folder-users'
|
|
||||||
'user'
|
|
||||||
}}
|
|
||||||
@text={{t
|
|
||||||
(concat
|
|
||||||
'resources.role.principal.types.'
|
|
||||||
principal.constructor.modelName
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</row.cell>
|
</row.cell>
|
||||||
<row.cell>
|
<row.cell>
|
||||||
<ScopeBadge @scope={{principal.scopeModel}} />
|
<ScopeBadge @scope={{principal.scopeModel}} />
|
||||||
|
|||||||
Reference in new issue
Block a user