diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index 9cfd4dd2d..9b36a5749 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -21,7 +21,7 @@ export default class TargetModel extends GeneratedTargetModel { host_sources; /** - * Credential library ids are read only and can be + * Credential source ids are read only and can be * persisted via a dedicated call to `addCredentialSources()`. */ @fragmentArray('fragment-string', { @@ -55,11 +55,8 @@ export default class TargetModel extends GeneratedTargetModel { @computed('application_credential_source_ids.[]', 'store') get credentialLibraries() { return this.application_credential_source_ids - .map((credential_library_fragment) => - this.store.peekRecord( - 'credential-library', - credential_library_fragment.value - ) + .map((source) => + this.store.peekRecord('credential-library', source.value) ) .filter(Boolean); } diff --git a/addons/api/addon/serializers/target.js b/addons/api/addon/serializers/target.js index a6ac73f73..8bf8b6882 100644 --- a/addons/api/addon/serializers/target.js +++ b/addons/api/addon/serializers/target.js @@ -31,8 +31,8 @@ export default class TargetSerializer extends ApplicationSerializer { } /** - * Returns a payload containing only the host_source_ids array using IDs - * passed into the function (rather than existing host sets on the model). + * Returns a payload containing only version and an array of passed IDs, + * rather than existing instances on the model. * @param {Snapshot} snapshot * @param {[string]} hostSetIDs * @return {object} @@ -45,10 +45,10 @@ export default class TargetSerializer extends ApplicationSerializer { } /** - * Returns a payload containing only the credential_library_ids array using IDs - * passed into the function (rather than existing credential libraries on the model). + * Returns a payload containing only version and an array of passed IDs, + * rather than existing instances on the model. * @param {Snapshot} snapshot - * @param {[string]} credentialLibraryIDs + * @param {[string]} credentialSourceIDs * @return {object} */ serializeWithCredentialSources(snapshot, credentialSourceIDs) { diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index a6817e634..68c7f6b94 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -367,7 +367,7 @@ export default function () { const updatedAttrs = { version: attrs.version, }; - // If adding host sets, push them into the array + // If adding host sources, push them into the array if (method === 'add-host-sources') { updatedAttrs.hostSetIds = target.hostSetIds; attrs.hostSourceIds.forEach((id) => { @@ -376,14 +376,14 @@ export default function () { } }); } - // If deleting host sets, filter them out of the array + // If deleting host sources, filter them out of the array if (method === 'remove-host-sources') { updatedAttrs.hostSetIds = target.hostSetIds; updatedAttrs.hostSetIds = updatedAttrs.hostSetIds.filter((id) => { return !attrs.hostSourceIds.includes(id); }); } - // If adding credential libraries, push them into the array + // If adding credential sources, push them into the array if (method === 'add-credential-sources') { updatedAttrs.credentialLibraryIds = target.credentialLibraryIds; attrs.applicationCredentialSourceIds.forEach((id) => { @@ -392,7 +392,7 @@ export default function () { } }); } - // If deleting credential libraries, filter them out of the array + // If deleting credential sources, filter them out of the array if (method === 'remove-credential-sources') { updatedAttrs.credentialLibraryIds = target.credentialLibraryIds; updatedAttrs.credentialLibraryIds = diff --git a/addons/api/tests/unit/serializers/target-test.js b/addons/api/tests/unit/serializers/target-test.js index 8f9c980c1..0c1bd089c 100644 --- a/addons/api/tests/unit/serializers/target-test.js +++ b/addons/api/tests/unit/serializers/target-test.js @@ -123,7 +123,7 @@ module('Unit | Serializer | target', function (hooks) { }); }); - test('it normalizes missing host_sources and credential libraries to empty array', function (assert) { + test('it normalizes missing host_sources and application_credential_source_ids to empty array', function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); const serializer = store.serializerFor('target'); diff --git a/ui/admin/app/components/form/target/add-credential-libraries/index.js b/ui/admin/app/components/form/target/add-credential-libraries/index.js index 24e827fc6..78b4a29b0 100644 --- a/ui/admin/app/components/form/target/add-credential-libraries/index.js +++ b/ui/admin/app/components/form/target/add-credential-libraries/index.js @@ -32,7 +32,7 @@ export default class FormTargetAddCredentialLibrariesIndexComponent extends Comp // Get IDs for credential libraries already added to the current target const currentCredentialLibraryIDs = this.args.model.application_credential_source_ids.map( - (credentialLibrary) => credentialLibrary.value + (source) => source.value ); const notAddedCredentialLibraries = this.args.credentialLibraries.filter( ({ id }) => !currentCredentialLibraryIDs.includes(id) diff --git a/ui/admin/app/routes/scopes/scope/targets/target/add-credential-sources.js b/ui/admin/app/routes/scopes/scope/targets/target/add-credential-sources.js index 9cfc43d03..88cfa0cb5 100644 --- a/ui/admin/app/routes/scopes/scope/targets/target/add-credential-sources.js +++ b/ui/admin/app/routes/scopes/scope/targets/target/add-credential-sources.js @@ -82,7 +82,7 @@ export default class ScopesScopeTargetsTargetAddCredentialSourcesRoute extends R } /** - * Redirect to target credential libraries as if nothing ever happened. + * Redirect to target credential sources as if nothing ever happened. */ @action cancel() { diff --git a/ui/admin/app/routes/scopes/scope/targets/target/add-host-sources.js b/ui/admin/app/routes/scopes/scope/targets/target/add-host-sources.js index cb4f2150c..19c4e6c37 100644 --- a/ui/admin/app/routes/scopes/scope/targets/target/add-host-sources.js +++ b/ui/admin/app/routes/scopes/scope/targets/target/add-host-sources.js @@ -76,7 +76,7 @@ export default class ScopesScopeTargetsTargetAddHostSourcesRoute extends Route { } /** - * Redirect to target host sets as if nothing ever happened. + * Redirect to target host sources as if nothing ever happened. */ @action cancel() { diff --git a/ui/admin/tests/acceptance/targets/host-sources-test.js b/ui/admin/tests/acceptance/targets/host-sources-test.js index 9cf02a4f4..e80ee4816 100644 --- a/ui/admin/tests/acceptance/targets/host-sources-test.js +++ b/ui/admin/tests/acceptance/targets/host-sources-test.js @@ -65,7 +65,7 @@ module('Acceptance | targets | host-sources', function (hooks) { authenticateSession({}); }); - test('visiting target host sets', async function (assert) { + test('visiting target host sources', async function (assert) { assert.expect(3); const targetHostSetCount = instances.target.hostSets.length; await visit(urls.targetHostSources);