From aa32e4b30560d634fd703aa2b8fe06ac9d4186b9 Mon Sep 17 00:00:00 2001 From: Tyler Ohlsen Date: Mon, 1 Apr 2024 09:42:08 -0700 Subject: [PATCH] Populate selected indices from query params on initial load Signed-off-by: Tyler Ohlsen --- public/pages/DetectorsList/containers/List/List.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/public/pages/DetectorsList/containers/List/List.tsx b/public/pages/DetectorsList/containers/List/List.tsx index d5172bc1..864f9951 100644 --- a/public/pages/DetectorsList/containers/List/List.tsx +++ b/public/pages/DetectorsList/containers/List/List.tsx @@ -14,7 +14,6 @@ import { EuiBasicTable, EuiButton, EuiComboBoxOptionProps, - EuiHorizontalRule, EuiPage, EuiPageBody, EuiSpacer, @@ -191,11 +190,14 @@ export const DetectorList = (props: ListProps) => { const visibleAliases = get(opensearchState, 'aliases', []) as IndexAlias[]; const indexOptions = getVisibleOptions(visibleIndices, visibleAliases); + const queryParams = getURLQueryParams(props.location); const [state, setState] = useState({ page: 0, - queryParams: getURLQueryParams(props.location), + queryParams, selectedDetectorStates: ALL_DETECTOR_STATES, - selectedIndices: ALL_INDICES, + selectedIndices: queryParams.indices + ? queryParams.indices.split(',') + : ALL_INDICES, }); // Set breadcrumbs on page initialization @@ -211,7 +213,7 @@ export const DetectorList = (props: ListProps) => { const { history, location } = props; const updatedParams = { ...state.queryParams, - indices: state.selectedIndices.join(' '), + indices: state.selectedIndices.join(','), from: state.page * state.queryParams.size, };