Files
threshold-ui/ui/admin/app/controllers/scopes/scope/targets/target/add-injected-application-credential-sources.js
T
Lisbet AlvarezandZhihe Li a20483d1af update breadcrumbs to use hds::breadcrumbs (#1934)
* refactor: 💡 initial changes for updating breadcrumbs to use hds

* refactor: 💡 add breadcrumbs to all paths

* refactor: 💡 add more hds breadcrumbs to remaining paths

* refactor: 💡 remove BreadCrumbs from templates

* refactor: 💡 remove breadcrumb only controller files

* test: 💍 remove unnused test files & add missing tests

* test: 💍 update tests

* test: 💍 add missing scope in test

* test: 💍 fix test

* refactor: 💡 remove icons

* refactor: 💡 remove addon and use service instead

* docs: ✏️ add comment to breadcrumb service

* test: 💍 update service unit test

* docs: ✏️ add comments to breadcrumb components

* Update ui/admin/app/components/breadcrumbs/container/index.js

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>

---------

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
2023-10-17 09:45:34 -07:00

41 lines
1.2 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Controller from '@ember/controller';
export default class ScopesScopeTargetsTargetAddInjectedApplicationCredentialSourcesController extends Controller {
// =services
// =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];
}
}