Files
threshold-ui/ui/admin/app/controllers/scopes/scope/targets/target/add-injected-application-credential-sources.js
T
Devon AndersonandRandall Morey 764f4703e0 chore: 🤖 brokered and injected credential associations (#1512)
* chore: 🤖 brokered and injected credential associations

Verified JSON credentials show up as a source that can be added to a
target as `brokered`, and not show up as a source that can be added to a
target as `injected`.

✅ Closes: ICU-6833, ICU-6834, ICU-6835, ICU-6836

* Update ui/admin/app/controllers/scopes/scope/targets/target/add-injected-application-credential-sources.js

Co-authored-by: Randall Morey <randall@randallmorey.com>

Co-authored-by: Randall Morey <randall@randallmorey.com>
2022-12-06 13:37:55 -05:00

49 lines
1.4 KiB
JavaScript

import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default class ScopesScopeTargetsTargetAddInjectedApplicationCredentialSourcesController extends Controller {
// =services
@service intl;
// =attributes
/**
* Checks for unassigned credential sources.
* @type {boolean}
*/
get hasAvailableInjectedApplicationCredentialSources() {
return this.filteredCredentialSources.length > 0;
}
/**
* Filter out credential sources not already added to the target.
* @type {[CredentialLibraryModel, CredentialModel]}
*/
get filteredCredentialSources() {
// Get IDs for credential sources already added to the current target
const currentCredentialSourceIDs = new Set(
this.model.target.injected_application_credential_source_ids.map(
(source) => source.value
)
);
const notAddedCredentialLibraries = this.model.credentialLibraries.filter(
({ id }) => !currentCredentialSourceIDs.has(id)
);
const notAddedCredentials = this.model.credentials.filter(
({ id, type }) => !currentCredentialSourceIDs.has(id) && type !== 'json'
);
return [...notAddedCredentialLibraries, ...notAddedCredentials];
}
/**
* Translated roles breadcrumb
* @type {string}
*/
get breadCrumb() {
return this.intl.t(
'resources.target.actions.add-injected-application-credential-sources'
);
}
}