Skip to content

Commit

Permalink
filter system index and alias from destination
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am committed Jan 3, 2023
1 parent e1b952e commit 0b6746f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion public/pages/Reindex/components/IndexSelect/IndexSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<IndexSelectItem>, "data-test-subj"> {
getIndexOptions: (searchValue: string, excludeDataStreamIndex?: boolean) => Promise<EuiComboBoxOptionOption<IndexSelectItem>[]>;
Expand All @@ -19,6 +21,7 @@ interface IndexSelectProps extends Pick<_EuiComboBoxProps<IndexSelectItem>, "dat
selectedOption: EuiComboBoxOptionOption<IndexSelectItem>[];
excludeDataStreamIndex?: boolean;
excludeList?: EuiComboBoxOptionOption<IndexSelectItem>[];
excludeSystemIndex?: boolean;
}

export default function IndexSelect(props: IndexSelectProps) {
Expand All @@ -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) => {
Expand All @@ -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<IndexSelectItem>[]) => {
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 (
<div>
<BetterComboBox
Expand Down
2 changes: 1 addition & 1 deletion public/pages/Reindex/container/Reindex/Reindex.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ describe("<Reindex /> 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 () => {
Expand Down
1 change: 1 addition & 0 deletions public/pages/Reindex/container/Reindex/Reindex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ export default class Reindex extends Component<ReindexProps, ReindexState> {
selectedOption={destination}
excludeDataStreamIndex={true}
excludeList={sources}
excludeSystemIndex={true}
/>
</CustomFormRow>
</EuiFlexItem>
Expand Down

0 comments on commit 0b6746f

Please sign in to comment.