From 0b6746fb7f473b205e586ad01fadc5b0b04a243a Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Tue, 3 Jan 2023 05:48:28 +0000 Subject: [PATCH] filter system index and alias from destination Signed-off-by: Hailong Cui --- .../Reindex/components/IndexSelect/IndexSelect.tsx | 13 ++++++++++++- .../Reindex/container/Reindex/Reindex.test.tsx | 2 +- public/pages/Reindex/container/Reindex/Reindex.tsx | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/public/pages/Reindex/components/IndexSelect/IndexSelect.tsx b/public/pages/Reindex/components/IndexSelect/IndexSelect.tsx index b38a0cf8c..784b96b31 100644 --- a/public/pages/Reindex/components/IndexSelect/IndexSelect.tsx +++ b/public/pages/Reindex/components/IndexSelect/IndexSelect.tsx @@ -11,6 +11,8 @@ import React, { useContext, useEffect, useState } from "react"; import { CoreServicesContext } from "../../../../components/core_services"; import { IndexSelectItem } from "../../models/interfaces"; import { filterOverlaps } from "../../utils/helper"; +import { filterByMinimatch } from "../../../../../utils/helper"; +import { SYSTEM_ALIAS, SYSTEM_INDEX } from "../../../../../utils/constants"; interface IndexSelectProps extends Pick<_EuiComboBoxProps, "data-test-subj"> { getIndexOptions: (searchValue: string, excludeDataStreamIndex?: boolean) => Promise[]>; @@ -19,6 +21,7 @@ interface IndexSelectProps extends Pick<_EuiComboBoxProps, "dat selectedOption: EuiComboBoxOptionOption[]; excludeDataStreamIndex?: boolean; excludeList?: EuiComboBoxOptionOption[]; + excludeSystemIndex?: boolean; } export default function IndexSelect(props: IndexSelectProps) { @@ -29,6 +32,7 @@ export default function IndexSelect(props: IndexSelectProps) { props .getIndexOptions(searchValue ? searchValue : "", props.excludeDataStreamIndex) .then((options) => { + props.excludeSystemIndex && filterSystemIndices(options); setIndexOptions(filterOverlaps(options, props.excludeList)); }) .catch((err) => { @@ -38,12 +42,19 @@ export default function IndexSelect(props: IndexSelectProps) { useEffect(() => { searchIndex(); - }, [props.getIndexOptions, props.excludeList, props.excludeDataStreamIndex]); + }, [props.getIndexOptions, props.excludeList, props.excludeDataStreamIndex, props.excludeSystemIndex]); const onSearchChange = (searchValue: string) => { searchIndex(searchValue); }; + const filterSystemIndices = (list: EuiComboBoxOptionOption[]) => { + list.map((it) => { + it.options = it.options?.filter((item) => !filterByMinimatch(item.label, SYSTEM_ALIAS)); + it.options = it.options?.filter((item) => !filterByMinimatch(item.label, SYSTEM_INDEX)); + }); + }; + return (
spec", () => { userEvent.type(getByTestId("slices"), "0"); await waitFor(() => {}); - expect(getByText("Must be an integer greater or equal to 2.")).toBeInTheDocument(); + expect(getByText("Must be an integer greater than or equal to 2.")).toBeInTheDocument(); }); it("it goes to indices page when submit reindex successfully", async () => { diff --git a/public/pages/Reindex/container/Reindex/Reindex.tsx b/public/pages/Reindex/container/Reindex/Reindex.tsx index 3702bca1d..015dec41e 100644 --- a/public/pages/Reindex/container/Reindex/Reindex.tsx +++ b/public/pages/Reindex/container/Reindex/Reindex.tsx @@ -588,6 +588,7 @@ export default class Reindex extends Component { selectedOption={destination} excludeDataStreamIndex={true} excludeList={sources} + excludeSystemIndex={true} />