Icu 9226 disable all actions for ldap accounts within users (#1688)

* refactor: 💡 disable all actions for ldap accounts within users

✅ Closes: ICU-9226
This commit is contained in:
lisbet-alvarez authored and GitHub committed 2023-05-22 15:46:13 -07:00
1 parent 379f317d8b
commit 8d77bc60b3
8 files changed
+190 -59

No files matched your search

@@ -3,7 +3,7 @@
SPDX-License-Identifier: MPL-2.0
}}
{{#if (can 'delete model' @model)}}
{{#if (can 'delete account' @model)}}
<Rose::Dropdown
@text={{t 'actions.manage'}}
@dropdownRight={{true}}
@@ -81,7 +81,7 @@
{{/if}}
{{/if}}
{{#if (can 'delete model' @model)}}
{{#if (can 'delete auth-method' @model)}}
<dropdown.separator />
<dropdown.button
@style='danger'
@@ -30,11 +30,13 @@
{{#each this.filteredAccounts as |account|}}
<body.row as |row|>
<row.cell>
<form.checkbox
@label={{account.id}}
@description={{account.description}}
@onChange={{fn this.toggleAccount account}}
/>
<Hds::Form::Checkbox::Field
{{on 'change' (fn this.toggleAccount account)}}
as |F|
>
<F.Label>{{account.id}}</F.Label>
<F.HelperText>{{account.description}}</F.HelperText>
</Hds::Form::Checkbox::Field>
</row.cell>
<row.cell>{{account.accountName}}</row.cell>
<row.cell>
@@ -4,12 +4,13 @@
*/
import Component from '@glimmer/component';
import { computed, action } from '@ember/object';
import { action } from '@ember/object';
import { A } from '@ember/array';
import { inject as service } from '@ember/service';
export default class FormUserAddAccountsComponent extends Component {
// =properties
@service can;
/**
* Array of selected account IDs.
* @type {EmberArray}
@@ -21,7 +22,6 @@ export default class FormUserAddAccountsComponent extends Component {
* @param {[AccountModel]} filteredAccounts
* @type {boolean}
*/
@computed('filteredAccounts.length')
get hasAvailableAccounts() {
return this.filteredAccounts.length > 0;
}
@@ -30,12 +30,13 @@ export default class FormUserAddAccountsComponent extends Component {
* Accounts not already added to the user.
* @type {[AccountModel]}
*/
@computed('args.{accounts.[],model.account_ids.[]}')
get filteredAccounts() {
// Get IDs for accounts already added to the current user
const alreadyAddedAccountIDs = this.args.model.account_ids;
const notAddedAccounts = this.args.accounts.filter(
({ id }) => !alreadyAddedAccountIDs.includes(id)
(account) =>
!alreadyAddedAccountIDs.includes(account.id) &&
this.can.can('addAccount user', this.args.model, { account })
);
return notAddedAccounts;
}