diff --git a/ui/core/app/components/form/role/add-principals/index.hbs b/ui/core/app/components/form/role/add-principals/index.hbs index c47e8e51d..bbf95f605 100644 --- a/ui/core/app/components/form/role/add-principals/index.hbs +++ b/ui/core/app/components/form/role/add-principals/index.hbs @@ -1,45 +1,47 @@ - +{{#if this.hasAvailablePrincipals}} + - + - - - - {{t 'form.label.id'}} - {{t 'form.label.name'}} - {{t 'form.label.type'}} - - - - {{#each this.filteredPrincipals as |principal|}} - - - - - {{principal.name}} - - {{t (concat 'resources.' principal.constructor.modelName)}} - - - {{/each}} - - - - + + + + {{t 'form.label.id'}} + {{t 'form.label.name'}} + {{t 'form.label.type'}} + + + + {{#each this.filteredPrincipals as |principal|}} + + + + + {{principal.name}} + + {{t (concat 'resources.' principal.constructor.modelName)}} + + + {{/each}} + + + +{{/if}} +{{#unless this.hasAvailablePrincipals}} @@ -51,3 +53,4 @@ +{{/unless}} \ No newline at end of file diff --git a/ui/core/app/components/form/role/add-principals/index.js b/ui/core/app/components/form/role/add-principals/index.js index 913a53e03..de1a8a5de 100644 --- a/ui/core/app/components/form/role/add-principals/index.js +++ b/ui/core/app/components/form/role/add-principals/index.js @@ -13,17 +13,23 @@ export default class FormRoleAddPrincipalsIndexComponent extends Component { selectedPrincipalIDs = A(); /** + * Checks for unassigned principals. * True if there are users or groups not yet added to this role. - * TODO: this must be computed on users, groups, and role principals. + * @param {RoleModel} role + * @param {[UserModel]} users + * @param {[GroupModel]} groups * @type {boolean} */ - hasAvailablePrincipals = true; + @computed('args.{model,users,groups}') + get hasAvailablePrincipals() { + return this.args.model.principals.length != (this.args.users.length + this.args.groups.length); + } /** * Principals not currently assigned to a role. * @type {[UserModel, GroupModel]} */ - @computed('args.{users,groups}') + @computed('args.{model,users,groups}') get filteredPrincipals() { // Retrieve principal IDs assigned to current role const currentPrincipalIDs = this.args.model.principals.map((principal) => principal.principal_id); diff --git a/ui/core/app/routes/scopes/scope/roles/role/add-principals.js b/ui/core/app/routes/scopes/scope/roles/role/add-principals.js index 73d8cd7e1..29baf7f54 100644 --- a/ui/core/app/routes/scopes/scope/roles/role/add-principals.js +++ b/ui/core/app/routes/scopes/scope/roles/role/add-principals.js @@ -29,21 +29,11 @@ export default class ScopesScopeRolesRoleAddPrincipalsRoute extends Route { const { scopeID } = role; const options = { adapterOptions: { scopeID } }; - return { + return hash({ role, users: this.store.findAll('user', options), groups: this.store.findAll('group', options) - }; - } - - /** - * Checks for unassigned principals. - * @param {RoleModel} role - * @param {[UserModel]} users - * @param {[GroupModel]} groups - */ - canAssignPrincipals(role, users, groups) { - return role.principals.length != (users.length + groups.length); + }); } /**