diff --git a/babel.config.js b/babel.config.js index 1d9ebbecf..f8498b5fe 100644 --- a/babel.config.js +++ b/babel.config.js @@ -12,8 +12,8 @@ module.exports = function (api) { presets: [require("@babel/preset-env"), require("@babel/preset-react"), require("@babel/preset-typescript")], plugins: [ [require("@babel/plugin-transform-runtime"), { regenerator: true }], - require("@babel/plugin-proposal-class-properties"), - require("@babel/plugin-proposal-object-rest-spread"), + require("@babel/plugin-transform-class-properties"), + require("@babel/plugin-transform-object-rest-spread"), [require("@babel/plugin-transform-modules-commonjs"), { allowTopLevelThis: true }], ], }; diff --git a/cypress/integration/plugins/index-management-dashboards-plugin/aliases.js b/cypress/integration/plugins/index-management-dashboards-plugin/aliases.js index 55b0dfe72..97e84cb6e 100644 --- a/cypress/integration/plugins/index-management-dashboards-plugin/aliases.js +++ b/cypress/integration/plugins/index-management-dashboards-plugin/aliases.js @@ -26,11 +26,32 @@ describe("Aliases", () => { }); beforeEach(() => { + // Intercept the specific POST request + cy.intercept("POST", "/api/ism/apiCaller", (req) => { + if (req.body.data && req.body.data.name === "**" && req.body.data.s === "alias:desc" && req.body.endpoint === "cat.aliases") { + req.alias = "apiCaller"; // Assign an alias directly if the condition is met + } + }); + // Visit ISM OSD cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/aliases`); - // Common text to wait for to confirm page loaded, give up to 60 seconds for initial load - cy.contains("Rows per page", { timeout: 60000 }); + // Wait for 120 seconds for OSD to start. + // eslint-disable-next-line cypress/no-unnecessary-waiting + // cy.wait(120000); + + const startTime = new Date().getTime(); + + // Wait for the API call to complete + cy.wait("@apiCaller", { timeout: 240000 }).then(() => { + // Log the calculated duration + const endTime = new Date().getTime(); + const duration = endTime - startTime; // Duration in milliseconds + cy.log(`@apiCaller completed in ${duration} milliseconds`); + }); + + // Common text to wait for to confirm page loaded, give up to 120 seconds for initial load + cy.contains("Rows per page", { timeout: 120000 }).should("be.visible"); }); describe("can be searched / sorted / paginated", () => { diff --git a/cypress/integration/plugins/index-management-dashboards-plugin/indices_spec.js b/cypress/integration/plugins/index-management-dashboards-plugin/indices_spec.js index 4d32227c8..0989b017a 100644 --- a/cypress/integration/plugins/index-management-dashboards-plugin/indices_spec.js +++ b/cypress/integration/plugins/index-management-dashboards-plugin/indices_spec.js @@ -9,7 +9,7 @@ import samplePolicy from "../../../fixtures/plugins/index-management-dashboards- const POLICY_ID = "test_policy_id"; const SAMPLE_INDEX = "sample_index"; -describe("Indices", () => { +describe("Indexes", () => { beforeEach(() => { // Set welcome screen tracking to false localStorage.setItem("home:welcome:show", "false"); @@ -52,7 +52,7 @@ describe("Indices", () => { }); }); - describe("can show data stream indices", () => { + describe("can show data stream indexes", () => { before(() => { cy.deleteAllIndices(); cy.deleteIMJobs(); @@ -169,7 +169,7 @@ describe("Indices", () => { }); }); - describe("can make indices deleted", () => { + describe("can make indexes deleted", () => { before(() => { cy.deleteAllIndices(); cy.deleteIMJobs(); @@ -417,7 +417,7 @@ describe("Indices", () => { cy.get('[data-test-subj="Close Action"]').should("exist").should("not.have.class", "euiContextMenuItem-isDisabled").click(); // Check for close index modal - cy.contains("Close indices"); + cy.contains("Close indexes"); // Close confirm button should be disabled cy.get('[data-test-subj="Close Confirm button"]').should("have.class", "euiButton-isDisabled"); @@ -457,7 +457,7 @@ describe("Indices", () => { cy.get('[data-test-subj="Open Action"]').should("exist").should("not.have.class", "euiContextMenuItem-isDisabled").click(); // Check for open index modal - cy.contains("Open indices"); + cy.contains("Open indexes"); cy.get('[data-test-subj="Open Confirm button"]').click(); diff --git a/cypress/integration/plugins/index-management-dashboards-plugin/managed_indices_spec.js b/cypress/integration/plugins/index-management-dashboards-plugin/managed_indices_spec.js index 40e1a49cb..f9335e318 100644 --- a/cypress/integration/plugins/index-management-dashboards-plugin/managed_indices_spec.js +++ b/cypress/integration/plugins/index-management-dashboards-plugin/managed_indices_spec.js @@ -14,7 +14,7 @@ const POLICY_ID_ROLLOVER = "test_policy_rollover"; const SAMPLE_INDEX = "sample_index"; const SAMPLE_INDEX_ROLLOVER = "sample_index-01"; -describe("Managed indices", () => { +describe("Managed indexes", () => { beforeEach(() => { // Set welcome screen tracking to false localStorage.setItem("home:welcome:show", "false"); @@ -58,13 +58,13 @@ describe("Managed indices", () => { }); // Confirm we got a remove policy toaster - cy.contains("Removed policy from 1 managed indices"); + cy.contains("Removed policy from 1 managed indexes"); // Wait some time for remove policy to execute before reload cy.wait(3000).reload(); // Confirm we are back to empty loading state, give 20 seconds as OSD takes a while to load - cy.contains("There are no existing managed indices.", { timeout: 20000 }); + cy.contains("There are no existing managed indexes.", { timeout: 20000 }); }); }); @@ -121,7 +121,7 @@ describe("Managed indices", () => { cy.get(`[data-test-subj="retryModalRetryButton"]`).click({ force: true }); // Confirm we got retry toaster - cy.contains("Retried 1 managed indices"); + cy.contains("Retried 1 managed indexes"); // Reload the page cy.reload(); @@ -238,10 +238,10 @@ describe("Managed indices", () => { }); // Confirm we got the change policy toaster - cy.contains("Changed policy on 1 indices"); + cy.contains("Changed policy on 1 indexes"); // Click back to Managed Indices page by clicking "Managed indices" breadcrumb - cy.contains("Policy managed indices").click(); + cy.contains("Policy managed indexes").click(); // Speed up execution of managed index cy.updateManagedIndexConfigStartTime(SAMPLE_INDEX); @@ -257,7 +257,7 @@ describe("Managed indices", () => { }); }); - describe("can manage data stream indices", () => { + describe("can manage data stream indexes", () => { before(() => { cy.deleteAllIndices(); cy.deleteIMJobs(); diff --git a/cypress/integration/plugins/index-management-dashboards-plugin/rollups_spec.js b/cypress/integration/plugins/index-management-dashboards-plugin/rollups_spec.js index 339ebaee2..570481f18 100644 --- a/cypress/integration/plugins/index-management-dashboards-plugin/rollups_spec.js +++ b/cypress/integration/plugins/index-management-dashboards-plugin/rollups_spec.js @@ -142,7 +142,7 @@ describe("Rollups", () => { cy.get("button").contains("Next").click({ force: true }); // Confirm that we got to step 4 of creation page - cy.contains("Job name and indices"); + cy.contains("Job name and indexes"); // Click the create button cy.get("button").contains("Create").click({ force: true }); diff --git a/cypress/integration/plugins/index-management-dashboards-plugin/snapshots_spec.js b/cypress/integration/plugins/index-management-dashboards-plugin/snapshots_spec.js index 51560333a..2d1bc1afc 100644 --- a/cypress/integration/plugins/index-management-dashboards-plugin/snapshots_spec.js +++ b/cypress/integration/plugins/index-management-dashboards-plugin/snapshots_spec.js @@ -83,7 +83,7 @@ describe("Snapshots", () => { }); describe("Snapshot can be restored", () => { - it("Successfully restores indices from snapshot", () => { + it("Successfully restores indexes from snapshot", () => { // Must wait here before refreshing so snapshot status becomes 'success' cy.wait(5000); diff --git a/cypress/utils/commands.js b/cypress/utils/commands.js index 6e7ccbbc3..4dd68a224 100644 --- a/cypress/utils/commands.js +++ b/cypress/utils/commands.js @@ -97,13 +97,13 @@ Cypress.Commands.add("login", () => { }); Cypress.Commands.add("deleteAllIndices", () => { - cy.log("Deleting all indices"); + cy.log("Deleting all indexes"); cy.request("DELETE", `${Cypress.env("openSearchUrl")}/index*,sample*,opensearch_dashboards*`); cy.request("DELETE", `${Cypress.env("openSearchUrl")}/.opendistro-ism*?expand_wildcards=all`); }); Cypress.Commands.add("deleteADSystemIndices", () => { - cy.log("Deleting AD system indices"); + cy.log("Deleting AD system indexes"); cy.request("DELETE", `${Cypress.env("openSearchUrl")}/.opendistro-anomaly*`); }); diff --git a/integtest.sh b/integtest.sh deleted file mode 100755 index 9081d879d..000000000 --- a/integtest.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash - -set -e - -function usage() { - echo "" - echo "This script is used to run integration tests for plugin installed on a remote OpenSearch/Dashboards cluster." - echo "--------------------------------------------------------------------------" - echo "Usage: $0 [args]" - echo "" - echo "Required arguments:" - echo "None" - echo "" - echo "Optional arguments:" - echo -e "-b BIND_ADDRESS\t, defaults to localhost | 127.0.0.1, can be changed to any IP or domain name for the cluster location." - echo -e "-p BIND_PORT\t, defaults to 9200 or 5601 depends on OpenSearch or Dashboards, can be changed to any port for the cluster location." - echo -e "-s SECURITY_ENABLED\t(true | false), defaults to true. Specify the OpenSearch/Dashboards have security enabled or not." - echo -e "-c CREDENTIAL\t(usename:password), no defaults, effective when SECURITY_ENABLED=true." - echo -e "-h\tPrint this message." - echo "--------------------------------------------------------------------------" -} - -while getopts ":hb:p:s:c:" arg; do - case $arg in - h) - usage - exit 1 - ;; - b) - BIND_ADDRESS=$OPTARG - ;; - p) - BIND_PORT=$OPTARG - ;; - s) - SECURITY_ENABLED=$OPTARG - ;; - c) - CREDENTIAL=$OPTARG - ;; - :) - echo "-${OPTARG} requires an argument" - usage - exit 1 - ;; - ?) - echo "Invalid option: -${OPTARG}" - exit 1 - ;; - esac -done - - -if [ -z "$BIND_ADDRESS" ] -then - BIND_ADDRESS="localhost" -fi - -if [ -z "$BIND_PORT" ] -then - BIND_PORT="5601" -fi - -if [ -z "$SECURITY_ENABLED" ] -then - SECURITY_ENABLED="true" -fi - -if [ -z "$CREDENTIAL" ] -then - CREDENTIAL="admin:admin" - USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` - PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'` -fi - -yarn osd bootstrap -cypress run --env security_enabled=$SECURITY_ENABLED opensearch_dashboards=${BIND_ADDRESS}:${BIND_PORT} diff --git a/public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx b/public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx index df7fe9f9e..ed7b9d500 100644 --- a/public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx +++ b/public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx @@ -98,7 +98,7 @@ export default class ChangePolicy extends Component } bodyStyles={{ padding: "initial" }} - title="Job name and indices" + title="Job name and indexes" titleSize="m" >
diff --git a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.test.tsx b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.test.tsx index dfd17f797..e01642d13 100644 --- a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.test.tsx +++ b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.test.tsx @@ -303,7 +303,7 @@ describe(" creation", () => { userEvent.click(getByTestId("createRollupNextButton")); //Check that it routes to step 4 - expect(queryByText("Job name and indices")).not.toBeNull(); + expect(queryByText("Job name and indexes")).not.toBeNull(); //Test create userEvent.click(getByTestId("createRollupSubmitButton")); @@ -430,6 +430,6 @@ describe(" creation", () => { //Check that it routes to step 4 userEvent.click(getByTestId("createRollupNextButton")); - expect(queryByText("Job name and indices")).not.toBeNull(); + expect(queryByText("Job name and indexes")).not.toBeNull(); }); }); diff --git a/public/pages/Indices/components/CloseIndexModal/CloseIndexModal.tsx b/public/pages/Indices/components/CloseIndexModal/CloseIndexModal.tsx index 8da8bee1a..78af2117f 100644 --- a/public/pages/Indices/components/CloseIndexModal/CloseIndexModal.tsx +++ b/public/pages/Indices/components/CloseIndexModal/CloseIndexModal.tsx @@ -44,7 +44,7 @@ export default function CloseIndexModal(props: CloseIndexModalProps) { return ( - Close indices + Close indexes diff --git a/public/pages/Indices/components/CloseIndexModal/__snapshots__/CloseIndexModal.test.tsx.snap b/public/pages/Indices/components/CloseIndexModal/__snapshots__/CloseIndexModal.test.tsx.snap index 04fde70d1..dd244c1cf 100644 --- a/public/pages/Indices/components/CloseIndexModal/__snapshots__/CloseIndexModal.test.tsx.snap +++ b/public/pages/Indices/components/CloseIndexModal/__snapshots__/CloseIndexModal.test.tsx.snap @@ -39,7 +39,7 @@ HTMLCollection [
- Close indices + Close indexes
- Delete indices + Delete indexes diff --git a/public/pages/Indices/components/DeleteIndexModal/__snapshots__/DeleteIndexModal.test.tsx.snap b/public/pages/Indices/components/DeleteIndexModal/__snapshots__/DeleteIndexModal.test.tsx.snap index 19062a096..aca0331c2 100644 --- a/public/pages/Indices/components/DeleteIndexModal/__snapshots__/DeleteIndexModal.test.tsx.snap +++ b/public/pages/Indices/components/DeleteIndexModal/__snapshots__/DeleteIndexModal.test.tsx.snap @@ -39,7 +39,7 @@ HTMLCollection [
- Delete indices + Delete indexes
spec renders data streams selection field 1`] = ` class="euiSwitch__label" id="some_html_id" > - Show data stream indices + Show data stream indexes
@@ -215,7 +215,7 @@ exports[` spec renders the component 1`] = ` class="euiSwitch__label" id="some_html_id" > - Show data stream indices + Show data stream indexes diff --git a/public/pages/Indices/components/OpenIndexModal/OpenIndexModal.tsx b/public/pages/Indices/components/OpenIndexModal/OpenIndexModal.tsx index a8dd8e4e6..d55d0137c 100644 --- a/public/pages/Indices/components/OpenIndexModal/OpenIndexModal.tsx +++ b/public/pages/Indices/components/OpenIndexModal/OpenIndexModal.tsx @@ -31,7 +31,7 @@ export default function OpenIndexModal(props: OpenIndexModalProps) { return ( - Open indices + Open indexes diff --git a/public/pages/Indices/components/OpenIndexModal/__snapshots__/OpenIndexModal.test.tsx.snap b/public/pages/Indices/components/OpenIndexModal/__snapshots__/OpenIndexModal.test.tsx.snap index d9053e8aa..02283748a 100644 --- a/public/pages/Indices/components/OpenIndexModal/__snapshots__/OpenIndexModal.test.tsx.snap +++ b/public/pages/Indices/components/OpenIndexModal/__snapshots__/OpenIndexModal.test.tsx.snap @@ -39,7 +39,7 @@ HTMLCollection [
- Open indices + Open indexes
{ /> } bodyStyles={{ padding: "initial" }} - title="Indices" + title="Indexes" itemCount={totalIndices} > spec renders the component 1`] = `

- Indices + Indexes @@ -187,7 +187,7 @@ exports[` spec renders the component 1`] = ` class="euiSwitch__label" id="some_html_id" > - Show data stream indices + Show data stream indexes

@@ -349,21 +349,29 @@ exports[` spec renders the component 1`] = ` - - Managed by policy + + Managed by policy + - + spec renders data streams selection field 1`] class="euiSwitch__label" id="some_html_id" > - Show data stream indices + Show data stream indexes @@ -204,7 +204,7 @@ exports[` spec renders the component 1`] = ` class="euiSwitch__label" id="some_html_id" > - Show data stream indices + Show data stream indexes diff --git a/public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/ManagedIndexEmptyPrompt.tsx b/public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/ManagedIndexEmptyPrompt.tsx index e06b5e20d..0d9eb8b5a 100644 --- a/public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/ManagedIndexEmptyPrompt.tsx +++ b/public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/ManagedIndexEmptyPrompt.tsx @@ -11,9 +11,9 @@ import CreatePolicyModal from "../../../../components/CreatePolicyModal"; import { ROUTES } from "../../../../utils/constants"; export const TEXT = { - RESET_FILTERS: "There are no managed indices matching your applied filters. Reset your filters to view your managed indices.", - NO_MANAGED_INDICES: "There are no existing managed indices. Create a policy to add to an index.", - LOADING: "Loading managed indices...", + RESET_FILTERS: "There are no managed indexes matching your applied filters. Reset your filters to view your managed indexes.", + NO_MANAGED_INDICES: "There are no existing managed indexes. Create a policy to add to an index.", + LOADING: "Loading managed indexes...", }; const getMessagePrompt = ({ filterIsApplied, loading }: ManagedIndexEmptyPromptProps): string => { diff --git a/public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/__snapshots__/ManagedIndexEmptyPrompt.test.tsx.snap b/public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/__snapshots__/ManagedIndexEmptyPrompt.test.tsx.snap index 01dd27e23..b3000d8e9 100644 --- a/public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/__snapshots__/ManagedIndexEmptyPrompt.test.tsx.snap +++ b/public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/__snapshots__/ManagedIndexEmptyPrompt.test.tsx.snap @@ -15,7 +15,7 @@ exports[` spec renders the component 1`] = ` class="euiText euiText--medium" >

- There are no existing managed indices. Create a policy to add to an index. + There are no existing managed indexes. Create a policy to add to an index.

diff --git a/public/pages/ManagedIndices/components/RetryModal/RetryModal.test.tsx b/public/pages/ManagedIndices/components/RetryModal/RetryModal.test.tsx index 019afb2c6..620a3db0a 100644 --- a/public/pages/ManagedIndices/components/RetryModal/RetryModal.test.tsx +++ b/public/pages/ManagedIndices/components/RetryModal/RetryModal.test.tsx @@ -191,7 +191,7 @@ describe(" spec", () => { expect(browserServicesMock.managedIndexService.retryManagedIndexPolicy).toHaveBeenCalledWith(["some_index"], "two"); expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledTimes(1); - expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledWith("Retried 1 managed indices"); + expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledWith("Retried 1 managed indexes"); }); it("shows error toaster when error is thrown", async () => { diff --git a/public/pages/ManagedIndices/components/RetryModal/RetryModal.tsx b/public/pages/ManagedIndices/components/RetryModal/RetryModal.tsx index a8ea1ed22..0ea23909f 100644 --- a/public/pages/ManagedIndices/components/RetryModal/RetryModal.tsx +++ b/public/pages/ManagedIndices/components/RetryModal/RetryModal.tsx @@ -103,14 +103,14 @@ export default class RetryModal extends Component - + spec renders the component 1`] = ` class="euiFormHelpText euiFormRow__text" id="some_html_id-help-0" > - Only common states shared across all selected indices are available + Only common states shared across all selected indexes are available diff --git a/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.test.tsx b/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.test.tsx index 51478c29b..f1319ec49 100644 --- a/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.test.tsx +++ b/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.test.tsx @@ -156,7 +156,7 @@ describe(" spec", () => { await waitFor(() => {}); expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledTimes(1); - expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledWith("Removed policy from 1 managed indices"); + expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledWith("Removed policy from 1 managed indexes"); }); it("sorts/paginates the table", async () => { diff --git a/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.tsx b/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.tsx index 260104748..f393d6168 100644 --- a/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.tsx +++ b/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.tsx @@ -246,7 +246,7 @@ export default class ManagedIndices extends Component void) => () => onShow(ConfirmationModal, { title: `Remove ${ - selectedItems.length === 1 ? `policy from ${selectedItems[0].index}` : `policies from ${selectedItems.length} indices` + selectedItems.length === 1 ? `policy from ${selectedItems[0].index}` : `policies from ${selectedItems.length} indexes` }`, bodyMessage: `Remove ${ - selectedItems.length === 1 ? `policy from ${selectedItems[0].index}` : `policies from ${selectedItems.length} indices` + selectedItems.length === 1 ? `policy from ${selectedItems[0].index}` : `policies from ${selectedItems.length} indexes` } permanently? This action cannot be undone.`, actionMessage: "Remove", onAction: () => this.onClickRemovePolicy(selectedItems.map((item) => item.index)), @@ -442,7 +442,7 @@ export default class ManagedIndices extends Component} bodyStyles={{ padding: "initial" }} - title="Policy managed indices" + title="Policy managed indexes" itemCount={totalManagedIndices} > spec renders the component 1`] = `

- Policy managed indices + Policy managed indexes @@ -233,7 +233,7 @@ exports[` spec renders the component 1`] = ` class="euiSwitch__label" id="some_html_id" > - Show data stream indices + Show data stream indexes @@ -497,7 +497,7 @@ exports[` spec renders the component 1`] = ` class="euiText euiText--medium" >

- Loading managed indices... + Loading managed indexes...

diff --git a/public/pages/VisualCreatePolicy/components/States/State.tsx b/public/pages/VisualCreatePolicy/components/States/State.tsx index 47e0ce6e4..87bd87d00 100644 --- a/public/pages/VisualCreatePolicy/components/States/State.tsx +++ b/public/pages/VisualCreatePolicy/components/States/State.tsx @@ -102,7 +102,7 @@ const State = ({ state, isInitialState, idx, onClickEditState, onClickDeleteStat } paddingSize="l" > - +

Actions

diff --git a/public/pages/VisualCreatePolicy/components/States/__snapshots__/State.test.tsx.snap b/public/pages/VisualCreatePolicy/components/States/__snapshots__/State.test.tsx.snap index e602ff46a..aeade8c53 100644 --- a/public/pages/VisualCreatePolicy/components/States/__snapshots__/State.test.tsx.snap +++ b/public/pages/VisualCreatePolicy/components/States/__snapshots__/State.test.tsx.snap @@ -157,7 +157,6 @@ exports[` spec renders the component 1`] = ` >
spec renders the component 1`] = ` >
spec renders the component 1`] = ` >
{ + function customSort(array, key, sortDirection) { + return array.sort((a, b) => { let flag; - const aStatus = a.extraStatus as string; - const bStatus = b.extraStatus as string; + const aValue = a[key] as string; + const bValue = b[key] as string; + if (sortDirection === "asc") { - flag = aStatus < bStatus; + flag = aValue < bValue; } else { - flag = aStatus > bStatus; + flag = aValue > bValue; } return flag ? -1 : 1; }); } + if (sortField === "status") { + // add new more status to status field so we need to sort + customSort(indicesResponse, "extraStatus", sortDirection); + } + // Filtering out indices that belong to a data stream. This must be done before pagination. const filteredIndices = showDataStreams ? indicesResponse : indicesResponse.filter((index) => index.data_stream === null); @@ -169,17 +177,19 @@ export default class IndexService { const managedStatus = await this._getManagedStatus(request, indexNames); + const allIndices = paginatedIndices.map((catIndex: CatIndex) => ({ + ...catIndex, + managed: managedStatus[catIndex.index] ? "Yes" : "No", + managedPolicy: managedStatus[catIndex.index], + })); + // NOTE: Cannot use response.ok due to typescript type checking return response.custom({ statusCode: 200, body: { ok: true, response: { - indices: paginatedIndices.map((catIndex: CatIndex) => ({ - ...catIndex, - managed: managedStatus[catIndex.index] ? "Yes" : "No", - managedPolicy: managedStatus[catIndex.index], - })), + indices: sortField === "managed" ? customSort(allIndices, "managed", sortDirection) : allIndices, totalIndices: filteredIndices.length, }, },