diff --git a/ui/app/components/auth-config-form/options.js b/ui/app/components/auth-config-form/options.js index 923ac27f68..da9e9b8f33 100644 --- a/ui/app/components/auth-config-form/options.js +++ b/ui/app/components/auth-config-form/options.js @@ -47,7 +47,7 @@ export default AuthConfigComponent.extend({ // because we're not calling model.save the model never updates with // the error. Forcing the error message by manually setting the errorMessage try { - this.model.set('errorMessage', err.errors.firstObject); + this.model.set('errorMessage', err.errors?.join(',')); } catch { // do nothing } diff --git a/ui/app/components/auth-form.js b/ui/app/components/auth-form.js index 76748f7cc9..7e5248186a 100644 --- a/ui/app/components/auth-form.js +++ b/ui/app/components/auth-form.js @@ -121,7 +121,7 @@ export default Component.extend(DEFAULTS, { }, firstMethod() { - const firstMethod = this.methodsToShow.firstObject; + const firstMethod = this.methodsToShow[0]; if (!firstMethod) return; // prefer backends with a path over those with a type return firstMethod.path || firstMethod.type; @@ -166,7 +166,7 @@ export default Component.extend(DEFAULTS, { return templateName; }), - hasCSPError: alias('csp.connectionViolations.firstObject'), + hasCSPError: alias('csp.connectionViolations'), cspErrorText: `This is a standby Vault node but can't communicate with the active node via request forwarding. Sign in at the active node to use the Vault UI.`, diff --git a/ui/app/components/identity/lookup-input.js b/ui/app/components/identity/lookup-input.js index 96a4986b5a..b683f44001 100644 --- a/ui/app/components/identity/lookup-input.js +++ b/ui/app/components/identity/lookup-input.js @@ -27,7 +27,7 @@ export default Component.extend({ this._super(...arguments); this.store.findAll('auth-method').then((methods) => { this.set('authMethods', methods); - this.set('aliasMountAccessor', methods.get('firstObject.accessor')); + this.set('aliasMountAccessor', methods[0].accessor); }); }, diff --git a/ui/app/components/mount-accessor-select.js b/ui/app/components/mount-accessor-select.js index bf72745544..84b6d34400 100644 --- a/ui/app/components/mount-accessor-select.js +++ b/ui/app/components/mount-accessor-select.js @@ -45,7 +45,7 @@ export default class MountAccessorSelect extends Component { @task *authMethods() { const methods = yield this.store.findAll('auth-method'); if (!this.args.value && !this.args.noDefault) { - const getValue = methods.get('firstObject.accessor'); + const getValue = methods[0].accessor; this.args.onChange(getValue); } return methods; diff --git a/ui/app/components/transit-key-actions.hbs b/ui/app/components/transit-key-actions.hbs index 26e394ee49..d9070392a9 100644 --- a/ui/app/components/transit-key-actions.hbs +++ b/ui/app/components/transit-key-actions.hbs @@ -2,7 +2,6 @@ Copyright (c) HashiCorp, Inc. SPDX-License-Identifier: BUSL-1.1 ~}} -
@@ -109,7 +108,7 @@ @submitIsRunning={{this.doSubmit.isRunning}} data-test-transit-action={{@selectedAction}} /> - {{else if (or (eq @selectedAction "export") (eq @key.supportedActions.firstObject "export"))}} + {{else if (or (eq @selectedAction "export") (eq (get @key.supportedActions 0) "export"))}} { if (model) { - return model.get('firstObject'); + return model[0]; } }); }, diff --git a/ui/app/routes/vault/cluster/secrets/backend/actions.js b/ui/app/routes/vault/cluster/secrets/backend/actions.js index 977cbff9dd..98a5981921 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/actions.js +++ b/ui/app/routes/vault/cluster/secrets/backend/actions.js @@ -30,6 +30,6 @@ export default EditBase.extend({ setupController(controller, model) { this._super(...arguments); const { selectedAction } = this.paramsFor(this.routeName); - controller.set('selectedAction', selectedAction || model.secret.get('supportedActions.firstObject')); + controller.set('selectedAction', selectedAction || model.secret.supportedActions[0]); }, }); diff --git a/ui/app/routes/vault/cluster/settings/auth/configure/index.js b/ui/app/routes/vault/cluster/settings/auth/configure/index.js index 7cd5138ee2..67db7cabb6 100644 --- a/ui/app/routes/vault/cluster/settings/auth/configure/index.js +++ b/ui/app/routes/vault/cluster/settings/auth/configure/index.js @@ -12,7 +12,7 @@ export default class SettingsAuthConfigureRoute extends Route { beforeModel() { const model = this.modelFor('vault.cluster.settings.auth.configure'); - const section = tabsForAuthSection([model]).firstObject.routeParams.lastObject; + const section = tabsForAuthSection([model])[0].routeParams.lastObject; return this.router.transitionTo('vault.cluster.settings.auth.configure.section', section); } } diff --git a/ui/app/routes/vault/cluster/settings/configure-secret-backend.js b/ui/app/routes/vault/cluster/settings/configure-secret-backend.js index d19bb624d8..a320c8104f 100644 --- a/ui/app/routes/vault/cluster/settings/configure-secret-backend.js +++ b/ui/app/routes/vault/cluster/settings/configure-secret-backend.js @@ -15,7 +15,7 @@ export default Route.extend({ model() { const { backend } = this.paramsFor(this.routeName); return this.store.query('secret-engine', { path: backend }).then((modelList) => { - const model = modelList && modelList.get('firstObject'); + const model = modelList && modelList[0]; if (!model || !CONFIGURABLE_BACKEND_TYPES.includes(model.get('type'))) { const error = new AdapterError(); set(error, 'httpStatus', 404); diff --git a/ui/app/services/csp-event.js b/ui/app/services/csp-event.js index 253b7b8be4..b53ccb9681 100644 --- a/ui/app/services/csp-event.js +++ b/ui/app/services/csp-event.js @@ -14,7 +14,7 @@ export default Service.extend({ return []; }), connectionViolations: computed('events.@each.violatedDirective', function () { - return this.events.filter((e) => e.violatedDirective.startsWith('connect-src')); + return this.events.some((e) => e.violatedDirective.startsWith('connect-src')); }), attach() { diff --git a/ui/lib/core/addon/components/search-select-with-modal.js b/ui/lib/core/addon/components/search-select-with-modal.js index 3ebcad12a0..313f148621 100644 --- a/ui/lib/core/addon/components/search-select-with-modal.js +++ b/ui/lib/core/addon/components/search-select-with-modal.js @@ -131,7 +131,7 @@ export default class SearchSelectWithModal extends Component { @action handleChange() { - if (this.selectedOptions.length && typeof this.selectedOptions.firstObject === 'object') { + if (this.selectedOptions.length && typeof this.selectedOptions[0] === 'object') { this.args.onChange(Array.from(this.selectedOptions, (option) => option.id)); } else { this.args.onChange(this.selectedOptions); @@ -139,7 +139,7 @@ export default class SearchSelectWithModal extends Component { } shouldShowCreate(id, searchResults) { - if (searchResults && searchResults.length && searchResults.firstObject.groupName) { + if (searchResults && searchResults.length && searchResults[0].groupName) { return !searchResults.some((group) => group.options.find((opt) => opt.id === id)); } const existingOption = diff --git a/ui/lib/core/addon/components/search-select.js b/ui/lib/core/addon/components/search-select.js index eb65bde171..f42dd2f27e 100644 --- a/ui/lib/core/addon/components/search-select.js +++ b/ui/lib/core/addon/components/search-select.js @@ -196,7 +196,7 @@ export default class SearchSelect extends Component { @action handleChange() { - if (this.selectedOptions.length && typeof this.selectedOptions.firstObject === 'object') { + if (this.selectedOptions.length && typeof this.selectedOptions[0] === 'object') { this.args.onChange( Array.from(this.selectedOptions, (option) => this.args.passObject ? this.customizeObject(option) : option.id @@ -208,7 +208,7 @@ export default class SearchSelect extends Component { } shouldShowCreate(id, searchResults) { - if (searchResults && searchResults.length && searchResults.firstObject.groupName) { + if (searchResults && searchResults.length && searchResults[0].groupName) { return !searchResults.some((group) => group.options.find((opt) => opt.id === id)); } const existingOption = diff --git a/ui/lib/kmip/addon/templates/components/edit-form-kmip-role.hbs b/ui/lib/kmip/addon/templates/components/edit-form-kmip-role.hbs index 0266f1ba69..3aea47a1d8 100644 --- a/ui/lib/kmip/addon/templates/components/edit-form-kmip-role.hbs +++ b/ui/lib/kmip/addon/templates/components/edit-form-kmip-role.hbs @@ -37,7 +37,7 @@
- {{#each-in this.model.operationFormFields.firstObject as |groupName fieldsInGroup|}} + {{#each-in (get this.model.operationFormFields 0) as |groupName fieldsInGroup|}}

{{groupName}}

{{#each fieldsInGroup as |attr|}} { if (name === 'keyType' && Object.keys(KEY_BITS_OPTIONS)?.includes(selection)) { const bitOptions = KEY_BITS_OPTIONS[selection as keyof TypeOptions]; - this.args.model.keyBits = bitOptions?.firstObject; + if (bitOptions) { + this.args.model.keyBits = bitOptions[0]; + } } } diff --git a/ui/lib/pki/addon/routes/configuration/index.js b/ui/lib/pki/addon/routes/configuration/index.js index 64b6381fae..7d01102c28 100644 --- a/ui/lib/pki/addon/routes/configuration/index.js +++ b/ui/lib/pki/addon/routes/configuration/index.js @@ -16,7 +16,7 @@ export default class ConfigurationIndexRoute extends Route { async fetchMountConfig(backend) { const mountConfig = await this.store.query('secret-engine', { path: backend }); if (mountConfig) { - return mountConfig.get('firstObject'); + return mountConfig[0]; } } diff --git a/ui/lib/pki/addon/templates/keys/index.hbs b/ui/lib/pki/addon/templates/keys/index.hbs index 09db5994a9..dd077ae68d 100644 --- a/ui/lib/pki/addon/templates/keys/index.hbs +++ b/ui/lib/pki/addon/templates/keys/index.hbs @@ -8,9 +8,9 @@ \ No newline at end of file diff --git a/ui/tests/integration/components/kubernetes/page/roles-test.js b/ui/tests/integration/components/kubernetes/page/roles-test.js index 67e9a4b4ca..59899983ab 100644 --- a/ui/tests/integration/components/kubernetes/page/roles-test.js +++ b/ui/tests/integration/components/kubernetes/page/roles-test.js @@ -92,9 +92,7 @@ module('Integration | Component | kubernetes | Page::Roles', function (hooks) { test('it should render roles list', async function (assert) { await this.renderComponent(); assert.dom('[data-test-list-item-content] svg').hasClass('flight-icon-user', 'List item icon renders'); - assert - .dom('[data-test-list-item-content]') - .hasText(this.roles.firstObject.name, 'List item name renders'); + assert.dom('[data-test-list-item-content]').hasText(this.roles[0].name, 'List item name renders'); await click('[data-test-popup-menu-trigger]'); assert.dom('[data-test-details]').hasText('Details', 'Details link renders in menu'); assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu'); diff --git a/ui/tests/integration/components/ldap/page/libraries-test.js b/ui/tests/integration/components/ldap/page/libraries-test.js index 42c27c99af..32ff5450cb 100644 --- a/ui/tests/integration/components/ldap/page/libraries-test.js +++ b/ui/tests/integration/components/ldap/page/libraries-test.js @@ -93,7 +93,7 @@ module('Integration | Component | ldap | Page::Libraries', function (hooks) { await this.renderComponent(); assert.dom('[data-test-list-item-content] svg').hasClass('flight-icon-folder', 'List item icon renders'); - assert.dom('[data-test-library]').hasText(this.libraries.firstObject.name, 'List item name renders'); + assert.dom('[data-test-library]').hasText(this.libraries[0].name, 'List item name renders'); await click('[data-test-popup-menu-trigger]'); assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu'); diff --git a/ui/tests/integration/components/ldap/page/roles-test.js b/ui/tests/integration/components/ldap/page/roles-test.js index 97d293a2de..ff5807992f 100644 --- a/ui/tests/integration/components/ldap/page/roles-test.js +++ b/ui/tests/integration/components/ldap/page/roles-test.js @@ -95,12 +95,10 @@ module('Integration | Component | ldap | Page::Roles', function (hooks) { await this.renderComponent(); assert.dom('[data-test-list-item-content] svg').hasClass('flight-icon-user', 'List item icon renders'); - assert - .dom('[data-test-role="static-test"]') - .hasText(this.roles.firstObject.name, 'List item name renders'); + assert.dom('[data-test-role="static-test"]').hasText(this.roles[0].name, 'List item name renders'); assert .dom('[data-test-role-type-badge="static-test"]') - .hasText(this.roles.firstObject.type, 'List item type badge renders'); + .hasText(this.roles[0].type, 'List item type badge renders'); await click('[data-test-popup-menu-trigger]'); assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu'); diff --git a/ui/tests/integration/components/mfa-login-enforcement-form-test.js b/ui/tests/integration/components/mfa-login-enforcement-form-test.js index dfe1e3ee64..b605d6d523 100644 --- a/ui/tests/integration/components/mfa-login-enforcement-form-test.js +++ b/ui/tests/integration/components/mfa-login-enforcement-form-test.js @@ -141,7 +141,8 @@ module('Integration | Component | mfa-login-enforcement-form', function (hooks) await click('[data-test-mlef-save]'); assert.true(this.didSave, 'onSave callback triggered'); assert.strictEqual(this.model.name, 'bar', 'Name property set on model'); - assert.strictEqual(this.model.mfa_methods.firstObject.id, '123456', 'Mfa method added to model'); + const methods = await this.model.mfa_methods; //hasManyPromise + assert.strictEqual(methods[0].id, '123456', 'Mfa method added to model'); assert.deepEqual( this.model.auth_method_accessors, ['auth_userpass_1234'], diff --git a/ui/tests/integration/components/pki/pki-generate-csr-test.js b/ui/tests/integration/components/pki/pki-generate-csr-test.js index 3b432d9fc5..7f4d6aa3f2 100644 --- a/ui/tests/integration/components/pki/pki-generate-csr-test.js +++ b/ui/tests/integration/components/pki/pki-generate-csr-test.js @@ -72,7 +72,7 @@ module('Integration | Component | pki-generate-csr', function (hooks) { await fillIn('[data-test-input="commonName"]', 'foo'); await click('[data-test-save]'); - const savedRecord = this.store.peekAll('pki/action').firstObject; + const savedRecord = this.store.peekAll('pki/action')[0]; assert.false(savedRecord.isNew, 'record is saved'); }); diff --git a/ui/tests/unit/adapters/ldap/role-test.js b/ui/tests/unit/adapters/ldap/role-test.js index d8c4dcfac5..cb8c50dc4e 100644 --- a/ui/tests/unit/adapters/ldap/role-test.js +++ b/ui/tests/unit/adapters/ldap/role-test.js @@ -33,7 +33,7 @@ module('Unit | Adapter | ldap/role', function (hooks) { this.models = await this.store.query('ldap/role', { backend: 'ldap-test' }); - const model = this.models.firstObject; + const model = this.models[0]; assert.strictEqual(this.models.length, 2, 'Returns responses from both endpoints'); assert.strictEqual(model.backend, 'ldap-test', 'Backend value is set on records returned from query'); // sorted alphabetically by name so dynamic should be first diff --git a/ui/tests/unit/serializers/transit-key-test.js b/ui/tests/unit/serializers/transit-key-test.js index 2812373ac2..96d533ec9c 100644 --- a/ui/tests/unit/serializers/transit-key-test.js +++ b/ui/tests/unit/serializers/transit-key-test.js @@ -73,23 +73,15 @@ module('Unit | Serializer | transit-key', function (hooks) { const aesExpected = AES.data.keys[1] * 1000; const chachaExpected = CHACHA.data.keys[1] * 1000; const aesData = serializer.normalizeSecrets({ ...AES }); - assert.strictEqual(aesData.firstObject.keys[1], aesExpected, 'converts seconds to millis for aes keys'); + assert.strictEqual(aesData[0].keys[1], aesExpected, 'converts seconds to millis for aes keys'); const chachaData = serializer.normalizeSecrets({ ...CHACHA }); - assert.strictEqual( - chachaData.firstObject.keys[1], - chachaExpected, - 'converts seconds to millis for chacha keys' - ); + assert.strictEqual(chachaData[0].keys[1], chachaExpected, 'converts seconds to millis for chacha keys'); }); test('it includes backend from the payload on the normalized data', function (assert) { const serializer = this.owner.lookup('serializer:transit-key'); const data = serializer.normalizeSecrets({ ...AES }); - assert.strictEqual( - data.firstObject.backend, - 'its-a-transit', - 'pulls backend from the payload onto the data' - ); + assert.strictEqual(data[0].backend, 'its-a-transit', 'pulls backend from the payload onto the data'); }); });