From 51df83f44ebf0445a18c5cf17283ca7cde23fd53 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw Date: Fri, 8 Mar 2024 18:52:23 -0600 Subject: [PATCH] remove other superfluous slices --- ui/app/helpers/mountable-auth-methods.js | 2 +- ui/app/helpers/mountable-secret-engines.js | 2 +- ui/app/helpers/tabs-for-auth-section.js | 4 ++-- ui/app/models/kmip/role.js | 10 ++++------ ui/app/services/console.js | 2 +- ui/app/services/store.js | 1 + 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ui/app/helpers/mountable-auth-methods.js b/ui/app/helpers/mountable-auth-methods.js index 7871d19b86..7e503409dd 100644 --- a/ui/app/helpers/mountable-auth-methods.js +++ b/ui/app/helpers/mountable-auth-methods.js @@ -117,7 +117,7 @@ const MOUNTABLE_AUTH_METHODS = [ ]; export function methods() { - return MOUNTABLE_AUTH_METHODS.slice(); + return MOUNTABLE_AUTH_METHODS; } export function allMethods() { diff --git a/ui/app/helpers/mountable-secret-engines.js b/ui/app/helpers/mountable-secret-engines.js index 398ed5e367..cc4988e022 100644 --- a/ui/app/helpers/mountable-secret-engines.js +++ b/ui/app/helpers/mountable-secret-engines.js @@ -135,7 +135,7 @@ const MOUNTABLE_SECRET_ENGINES = [ ]; export function mountableEngines() { - return MOUNTABLE_SECRET_ENGINES.slice(); + return MOUNTABLE_SECRET_ENGINES; } export function allEngines() { diff --git a/ui/app/helpers/tabs-for-auth-section.js b/ui/app/helpers/tabs-for-auth-section.js index 46f95fe65a..d3c237fc16 100644 --- a/ui/app/helpers/tabs-for-auth-section.js +++ b/ui/app/helpers/tabs-for-auth-section.js @@ -83,7 +83,7 @@ const TABS_FOR_SHOW = {}; export function tabsForAuthSection([model, sectionType = 'authSettings', paths]) { let tabs; if (sectionType === 'authSettings') { - tabs = (TABS_FOR_SETTINGS[model.type] || []).slice(); + tabs = TABS_FOR_SETTINGS[model.type] || []; tabs.push({ label: 'Method Options', routeParams: ['vault.cluster.settings.auth.configure.section', 'options'], @@ -104,7 +104,7 @@ export function tabsForAuthSection([model, sectionType = 'authSettings', paths]) }; }); } else { - tabs = (TABS_FOR_SHOW[model.type] || []).slice(); + tabs = TABS_FOR_SHOW[model.type] || []; } tabs.push({ label: 'Configuration', diff --git a/ui/app/models/kmip/role.js b/ui/app/models/kmip/role.js index c0379ab4d2..91208eaa2b 100644 --- a/ui/app/models/kmip/role.js +++ b/ui/app/models/kmip/role.js @@ -15,7 +15,7 @@ export const COMPUTEDS = { }), operationFieldsWithoutSpecial: computed('operationFields', function () { - return this.operationFields.slice().removeObjects(['operationAll', 'operationNone']); + return this.operationFields.removeObjects(['operationAll', 'operationNone']); }), tlsFields: computed(function () { @@ -25,12 +25,12 @@ export const COMPUTEDS = { // For rendering on the create/edit pages defaultFields: computed('newFields', 'operationFields', 'tlsFields', function () { const excludeFields = ['role'].concat(this.operationFields, this.tlsFields); - return this.newFields.slice().removeObjects(excludeFields); + return this.newFields.removeObjects(excludeFields); }), // For adapter/serializer nonOperationFields: computed('newFields', 'operationFields', function () { - return this.newFields.slice().removeObjects(this.operationFields); + return this.newFields.removeObjects(this.operationFields); }), }; @@ -64,9 +64,7 @@ export default Model.extend(COMPUTEDS, { const attributes = ['operationAddAttribute', 'operationGetAttributes']; const server = ['operationDiscoverVersions']; - const others = this.operationFieldsWithoutSpecial - .slice() - .removeObjects(objects.concat(attributes, server)); + const others = this.operationFieldsWithoutSpecial.removeObjects(objects.concat(attributes, server)); const groups = [ { 'Managed Cryptographic Objects': objects }, { 'Object Attributes': attributes }, diff --git a/ui/app/services/console.js b/ui/app/services/console.js index 96ecc257d4..55f5e20024 100644 --- a/ui/app/services/console.js +++ b/ui/app/services/console.js @@ -46,7 +46,7 @@ export default Service.extend({ const log = this.log; let history; if (!clearAll) { - history = this.commandHistory.slice(); + history = this.commandHistory; history.setEach('hidden', true); } log.clear(); diff --git a/ui/app/services/store.js b/ui/app/services/store.js index d0b3e39dce..30a644256f 100644 --- a/ui/app/services/store.js +++ b/ui/app/services/store.js @@ -187,6 +187,7 @@ export default class StoreService extends Store { ); // Hack to make sure all records get in model correctly. remove with update to ember-data@4.12 this.peekAll(modelName).length; + // Removing .slice() causes list.empty in ListView to behave incorrectly const model = this.peekAll(modelName).slice(); model.set('meta', response.meta); resolve(model);