Icu 5253 add query to include credentials (#1227)

* refactor: 💡 add-credential-sources to include credentials

* refactor: 💡 update add-credential-sources template

Update to how AddCredentialSources form is rendered in the template

✅ Closes: ICU-5253

* refactor: 💡 Update add-credential-sources method signatures

* refactor: 💡 change how add-credential-source form is rendered

* refactor: 💡 Remove duplicate add-credential-sources message

Remove the duplicate No Credential Credential Sources message from
add-credential-sources form

* refactor: 💡 Move filter logic to controller

Move credential source filter logic from route to controller for
add-credential-sources

* test: 💍 Verify all available credential sources are listed
This commit is contained in:
Cameron Perera authored and GitHub committed 2022-08-02 11:55:26 -05:00
1 parent c8a76078ec
commit 9f09f01f36
9 files changed
+199 -143

No files matched your search

@@ -1,5 +1,6 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
export default class ScopesScopeTargetsTargetAddCredentialSourcesController extends Controller {
// =services
@@ -8,6 +9,36 @@ export default class ScopesScopeTargetsTargetAddCredentialSourcesController exte
// =attributes
/**
* Checks for unassigned credential sources.
* @type {boolean}
*/
get hasAvailableCredentialSources() {
return this.filteredCredentialSources.length > 0;
}
/**
* Filter out credential sources not already added to the target.
* @type {[CredentialLibraryModel, CredentialModel]}
*/
@computed(
'model.{target.application_credential_source_ids.[],credentialLibraries.[],credentials.[]}'
)
get filteredCredentialSources() {
// Get IDs for credential sources already added to the current target
const currentCredentialSourceIDs =
this.model.target.application_credential_source_ids.map(
(source) => source.value
);
const notAddedCredentialLibraries = this.model.credentialLibraries.filter(
({ id }) => !currentCredentialSourceIDs.includes(id)
);
const notAddedCredentials = this.model.credentials.filter(
({ id }) => !currentCredentialSourceIDs.includes(id)
);
return [...notAddedCredentialLibraries, ...notAddedCredentials];
}
/**
* Translated roles breadcrumb
* @type {string}