mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-31 18:48:08 +00:00
Deprecations: Remove firstObject from RecordArray (#25583)
* wip * focusing on js files * rest of the js files * round up the last bits focusing on hbs * address test failures * Update transit-key-test.js * Update ui/app/services/csp-event.js Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com> * Update options.js * build error push --------- Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
This commit is contained in:
@@ -47,7 +47,7 @@ export default AuthConfigComponent.extend({
|
|||||||
// because we're not calling model.save the model never updates with
|
// because we're not calling model.save the model never updates with
|
||||||
// the error. Forcing the error message by manually setting the errorMessage
|
// the error. Forcing the error message by manually setting the errorMessage
|
||||||
try {
|
try {
|
||||||
this.model.set('errorMessage', err.errors.firstObject);
|
this.model.set('errorMessage', err.errors?.join(','));
|
||||||
} catch {
|
} catch {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export default Component.extend(DEFAULTS, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
firstMethod() {
|
firstMethod() {
|
||||||
const firstMethod = this.methodsToShow.firstObject;
|
const firstMethod = this.methodsToShow[0];
|
||||||
if (!firstMethod) return;
|
if (!firstMethod) return;
|
||||||
// prefer backends with a path over those with a type
|
// prefer backends with a path over those with a type
|
||||||
return firstMethod.path || firstMethod.type;
|
return firstMethod.path || firstMethod.type;
|
||||||
@@ -166,7 +166,7 @@ export default Component.extend(DEFAULTS, {
|
|||||||
return templateName;
|
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.`,
|
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.`,
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default Component.extend({
|
|||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.store.findAll('auth-method').then((methods) => {
|
this.store.findAll('auth-method').then((methods) => {
|
||||||
this.set('authMethods', methods);
|
this.set('authMethods', methods);
|
||||||
this.set('aliasMountAccessor', methods.get('firstObject.accessor'));
|
this.set('aliasMountAccessor', methods[0].accessor);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default class MountAccessorSelect extends Component {
|
|||||||
@task *authMethods() {
|
@task *authMethods() {
|
||||||
const methods = yield this.store.findAll('auth-method');
|
const methods = yield this.store.findAll('auth-method');
|
||||||
if (!this.args.value && !this.args.noDefault) {
|
if (!this.args.value && !this.args.noDefault) {
|
||||||
const getValue = methods.get('firstObject.accessor');
|
const getValue = methods[0].accessor;
|
||||||
this.args.onChange(getValue);
|
this.args.onChange(getValue);
|
||||||
}
|
}
|
||||||
return methods;
|
return methods;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
Copyright (c) HashiCorp, Inc.
|
Copyright (c) HashiCorp, Inc.
|
||||||
SPDX-License-Identifier: BUSL-1.1
|
SPDX-License-Identifier: BUSL-1.1
|
||||||
~}}
|
~}}
|
||||||
|
|
||||||
<div {{did-update this.updateProps @selectedAction}}>
|
<div {{did-update this.updateProps @selectedAction}}>
|
||||||
<MessageError @errorMessage={{this.errors}} />
|
<MessageError @errorMessage={{this.errors}} />
|
||||||
|
|
||||||
@@ -109,7 +108,7 @@
|
|||||||
@submitIsRunning={{this.doSubmit.isRunning}}
|
@submitIsRunning={{this.doSubmit.isRunning}}
|
||||||
data-test-transit-action={{@selectedAction}}
|
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"))}}
|
||||||
<TransitKeyAction::Export
|
<TransitKeyAction::Export
|
||||||
@key={{@key}}
|
@key={{@key}}
|
||||||
@keys={{this.props.keys}}
|
@keys={{this.props.keys}}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default Route.extend({
|
|||||||
})
|
})
|
||||||
.then((model) => {
|
.then((model) => {
|
||||||
if (model) {
|
if (model) {
|
||||||
return model.get('firstObject');
|
return model[0];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ export default EditBase.extend({
|
|||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
const { selectedAction } = this.paramsFor(this.routeName);
|
const { selectedAction } = this.paramsFor(this.routeName);
|
||||||
controller.set('selectedAction', selectedAction || model.secret.get('supportedActions.firstObject'));
|
controller.set('selectedAction', selectedAction || model.secret.supportedActions[0]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default class SettingsAuthConfigureRoute extends Route {
|
|||||||
|
|
||||||
beforeModel() {
|
beforeModel() {
|
||||||
const model = this.modelFor('vault.cluster.settings.auth.configure');
|
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);
|
return this.router.transitionTo('vault.cluster.settings.auth.configure.section', section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default Route.extend({
|
|||||||
model() {
|
model() {
|
||||||
const { backend } = this.paramsFor(this.routeName);
|
const { backend } = this.paramsFor(this.routeName);
|
||||||
return this.store.query('secret-engine', { path: backend }).then((modelList) => {
|
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'))) {
|
if (!model || !CONFIGURABLE_BACKEND_TYPES.includes(model.get('type'))) {
|
||||||
const error = new AdapterError();
|
const error = new AdapterError();
|
||||||
set(error, 'httpStatus', 404);
|
set(error, 'httpStatus', 404);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default Service.extend({
|
|||||||
return [];
|
return [];
|
||||||
}),
|
}),
|
||||||
connectionViolations: computed('events.@each.violatedDirective', function () {
|
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() {
|
attach() {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ export default class SearchSelectWithModal extends Component {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
handleChange() {
|
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));
|
this.args.onChange(Array.from(this.selectedOptions, (option) => option.id));
|
||||||
} else {
|
} else {
|
||||||
this.args.onChange(this.selectedOptions);
|
this.args.onChange(this.selectedOptions);
|
||||||
@@ -139,7 +139,7 @@ export default class SearchSelectWithModal extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shouldShowCreate(id, searchResults) {
|
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));
|
return !searchResults.some((group) => group.options.find((opt) => opt.id === id));
|
||||||
}
|
}
|
||||||
const existingOption =
|
const existingOption =
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ export default class SearchSelect extends Component {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
handleChange() {
|
handleChange() {
|
||||||
if (this.selectedOptions.length && typeof this.selectedOptions.firstObject === 'object') {
|
if (this.selectedOptions.length && typeof this.selectedOptions[0] === 'object') {
|
||||||
this.args.onChange(
|
this.args.onChange(
|
||||||
Array.from(this.selectedOptions, (option) =>
|
Array.from(this.selectedOptions, (option) =>
|
||||||
this.args.passObject ? this.customizeObject(option) : option.id
|
this.args.passObject ? this.customizeObject(option) : option.id
|
||||||
@@ -208,7 +208,7 @@ export default class SearchSelect extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shouldShowCreate(id, searchResults) {
|
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));
|
return !searchResults.some((group) => group.options.find((opt) => opt.id === id));
|
||||||
}
|
}
|
||||||
const existingOption =
|
const existingOption =
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<div class="is-flex">
|
<div class="is-flex">
|
||||||
<div class="kmip-role-allowed-operations">
|
<div class="kmip-role-allowed-operations">
|
||||||
{{#each-in this.model.operationFormFields.firstObject as |groupName fieldsInGroup|}}
|
{{#each-in (get this.model.operationFormFields 0) as |groupName fieldsInGroup|}}
|
||||||
<h4 class="title is-7">{{groupName}}</h4>
|
<h4 class="title is-7">{{groupName}}</h4>
|
||||||
{{#each fieldsInGroup as |attr|}}
|
{{#each fieldsInGroup as |attr|}}
|
||||||
<FormField
|
<FormField
|
||||||
|
|||||||
@@ -56,7 +56,9 @@ export default class PkiKeyParameters extends Component<Args> {
|
|||||||
|
|
||||||
if (name === 'keyType' && Object.keys(KEY_BITS_OPTIONS)?.includes(selection)) {
|
if (name === 'keyType' && Object.keys(KEY_BITS_OPTIONS)?.includes(selection)) {
|
||||||
const bitOptions = KEY_BITS_OPTIONS[selection as keyof TypeOptions];
|
const bitOptions = KEY_BITS_OPTIONS[selection as keyof TypeOptions];
|
||||||
this.args.model.keyBits = bitOptions?.firstObject;
|
if (bitOptions) {
|
||||||
|
this.args.model.keyBits = bitOptions[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default class ConfigurationIndexRoute extends Route {
|
|||||||
async fetchMountConfig(backend) {
|
async fetchMountConfig(backend) {
|
||||||
const mountConfig = await this.store.query('secret-engine', { path: backend });
|
const mountConfig = await this.store.query('secret-engine', { path: backend });
|
||||||
if (mountConfig) {
|
if (mountConfig) {
|
||||||
return mountConfig.get('firstObject');
|
return mountConfig[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
<Page::PkiKeyList
|
<Page::PkiKeyList
|
||||||
@keyModels={{this.model.keyModels}}
|
@keyModels={{this.model.keyModels}}
|
||||||
@mountPoint={{this.mountPoint}}
|
@mountPoint={{this.mountPoint}}
|
||||||
@canImportKey={{this.model.keyModels.firstObject.canImportKey}}
|
@canImportKey={{(get (get this.model.keyModels 0) "canImportKey")}}
|
||||||
@canGenerateKey={{this.model.keyModels.firstObject.canGenerateKey}}
|
@canGenerateKey={{(get (get this.model.keyModels 0) "canGenerateKey")}}
|
||||||
@canRead={{this.model.keyModels.firstObject.canRead}}
|
@canRead={{(get (get this.model.keyModels 0) "canRead")}}
|
||||||
@canEdit={{this.model.keyModels.firstObject.canEdit}}
|
@canEdit={{(get (get this.model.keyModels 0) "canEdit")}}
|
||||||
@hasConfig={{this.model.hasConfig}}
|
@hasConfig={{this.model.hasConfig}}
|
||||||
/>
|
/>
|
||||||
@@ -92,9 +92,7 @@ module('Integration | Component | kubernetes | Page::Roles', function (hooks) {
|
|||||||
test('it should render roles list', async function (assert) {
|
test('it should render roles list', async function (assert) {
|
||||||
await this.renderComponent();
|
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] svg').hasClass('flight-icon-user', 'List item icon renders');
|
||||||
assert
|
assert.dom('[data-test-list-item-content]').hasText(this.roles[0].name, 'List item name renders');
|
||||||
.dom('[data-test-list-item-content]')
|
|
||||||
.hasText(this.roles.firstObject.name, 'List item name renders');
|
|
||||||
await click('[data-test-popup-menu-trigger]');
|
await click('[data-test-popup-menu-trigger]');
|
||||||
assert.dom('[data-test-details]').hasText('Details', 'Details link renders in menu');
|
assert.dom('[data-test-details]').hasText('Details', 'Details link renders in menu');
|
||||||
assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu');
|
assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu');
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ module('Integration | Component | ldap | Page::Libraries', function (hooks) {
|
|||||||
await this.renderComponent();
|
await this.renderComponent();
|
||||||
|
|
||||||
assert.dom('[data-test-list-item-content] svg').hasClass('flight-icon-folder', 'List item icon renders');
|
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]');
|
await click('[data-test-popup-menu-trigger]');
|
||||||
assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu');
|
assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu');
|
||||||
|
|||||||
@@ -95,12 +95,10 @@ module('Integration | Component | ldap | Page::Roles', function (hooks) {
|
|||||||
await this.renderComponent();
|
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] svg').hasClass('flight-icon-user', 'List item icon renders');
|
||||||
assert
|
assert.dom('[data-test-role="static-test"]').hasText(this.roles[0].name, 'List item name renders');
|
||||||
.dom('[data-test-role="static-test"]')
|
|
||||||
.hasText(this.roles.firstObject.name, 'List item name renders');
|
|
||||||
assert
|
assert
|
||||||
.dom('[data-test-role-type-badge="static-test"]')
|
.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]');
|
await click('[data-test-popup-menu-trigger]');
|
||||||
assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu');
|
assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu');
|
||||||
|
|||||||
@@ -141,7 +141,8 @@ module('Integration | Component | mfa-login-enforcement-form', function (hooks)
|
|||||||
await click('[data-test-mlef-save]');
|
await click('[data-test-mlef-save]');
|
||||||
assert.true(this.didSave, 'onSave callback triggered');
|
assert.true(this.didSave, 'onSave callback triggered');
|
||||||
assert.strictEqual(this.model.name, 'bar', 'Name property set on model');
|
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(
|
assert.deepEqual(
|
||||||
this.model.auth_method_accessors,
|
this.model.auth_method_accessors,
|
||||||
['auth_userpass_1234'],
|
['auth_userpass_1234'],
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ module('Integration | Component | pki-generate-csr', function (hooks) {
|
|||||||
await fillIn('[data-test-input="commonName"]', 'foo');
|
await fillIn('[data-test-input="commonName"]', 'foo');
|
||||||
await click('[data-test-save]');
|
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');
|
assert.false(savedRecord.isNew, 'record is saved');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ module('Unit | Adapter | ldap/role', function (hooks) {
|
|||||||
|
|
||||||
this.models = await this.store.query('ldap/role', { backend: 'ldap-test' });
|
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(this.models.length, 2, 'Returns responses from both endpoints');
|
||||||
assert.strictEqual(model.backend, 'ldap-test', 'Backend value is set on records returned from query');
|
assert.strictEqual(model.backend, 'ldap-test', 'Backend value is set on records returned from query');
|
||||||
// sorted alphabetically by name so dynamic should be first
|
// sorted alphabetically by name so dynamic should be first
|
||||||
|
|||||||
@@ -73,23 +73,15 @@ module('Unit | Serializer | transit-key', function (hooks) {
|
|||||||
const aesExpected = AES.data.keys[1] * 1000;
|
const aesExpected = AES.data.keys[1] * 1000;
|
||||||
const chachaExpected = CHACHA.data.keys[1] * 1000;
|
const chachaExpected = CHACHA.data.keys[1] * 1000;
|
||||||
const aesData = serializer.normalizeSecrets({ ...AES });
|
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 });
|
const chachaData = serializer.normalizeSecrets({ ...CHACHA });
|
||||||
assert.strictEqual(
|
assert.strictEqual(chachaData[0].keys[1], chachaExpected, 'converts seconds to millis for chacha keys');
|
||||||
chachaData.firstObject.keys[1],
|
|
||||||
chachaExpected,
|
|
||||||
'converts seconds to millis for chacha keys'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('it includes backend from the payload on the normalized data', function (assert) {
|
test('it includes backend from the payload on the normalized data', function (assert) {
|
||||||
const serializer = this.owner.lookup('serializer:transit-key');
|
const serializer = this.owner.lookup('serializer:transit-key');
|
||||||
const data = serializer.normalizeSecrets({ ...AES });
|
const data = serializer.normalizeSecrets({ ...AES });
|
||||||
assert.strictEqual(
|
assert.strictEqual(data[0].backend, 'its-a-transit', 'pulls backend from the payload onto the data');
|
||||||
data.firstObject.backend,
|
|
||||||
'its-a-transit',
|
|
||||||
'pulls backend from the payload onto the data'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user