* 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>
49 lines
1.4 KiB
JavaScript
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'
|
|
);
|
|
}
|
|
}
|