From 32e346a60fb32748157e865ed60c5f21275cf3ba Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Mon, 9 Jun 2025 13:20:38 -0700 Subject: [PATCH] fix a mds bug (#1039) * fix a mds bug Signed-off-by: Jackie Han * make sure dataSourceId will be parsed as undefined when mds is not enabled Signed-off-by: Jackie Han --------- Signed-off-by: Jackie Han (cherry picked from commit 4bbded77c913ba5b58a480efddcbfa908fb555d6) --- .../Dashboard/Container/DashboardOverview.tsx | 26 +++++++------------ .../DetectorsList/containers/List/List.tsx | 23 ++++++++-------- public/pages/DetectorsList/utils/helpers.ts | 2 +- .../containers/AnomalyDetectionOverview.tsx | 3 --- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/public/pages/Dashboard/Container/DashboardOverview.tsx b/public/pages/Dashboard/Container/DashboardOverview.tsx index 13c6d70e..111b66c1 100644 --- a/public/pages/Dashboard/Container/DashboardOverview.tsx +++ b/public/pages/Dashboard/Container/DashboardOverview.tsx @@ -206,21 +206,6 @@ export function DashboardOverview(props: OverviewProps) { setCurrentDetectors(finalFilteredDetectors); }; - const intializeDetectors = async () => { - // wait until selected data source is ready before doing dispatch calls if mds is enabled - if (!dataSourceEnabled || (MDSOverviewState.selectedDataSourceId && MDSOverviewState.selectedDataSourceId !== "")) { - dispatch( - getDetectorList( - getAllDetectorsQueryParamsWithDataSourceId( - MDSOverviewState.selectedDataSourceId - ) - ) - ); - dispatch(getIndices('', MDSOverviewState.selectedDataSourceId)); - dispatch(getAliases('', MDSOverviewState.selectedDataSourceId)); - } - }; - useEffect(() => { const { history, location } = props; if (dataSourceEnabled) { @@ -232,7 +217,16 @@ export function DashboardOverview(props: OverviewProps) { search: queryString.stringify(updatedParams), }); } - intializeDetectors(); + ++ dispatch( + getDetectorList( + getAllDetectorsQueryParamsWithDataSourceId( + MDSOverviewState.selectedDataSourceId + ) + ) + ); + dispatch(getIndices('', MDSOverviewState.selectedDataSourceId)); + dispatch(getAliases('', MDSOverviewState.selectedDataSourceId)); }, [MDSOverviewState]); useEffect(() => { diff --git a/public/pages/DetectorsList/containers/List/List.tsx b/public/pages/DetectorsList/containers/List/List.tsx index 09b31ae4..872c1eb2 100644 --- a/public/pages/DetectorsList/containers/List/List.tsx +++ b/public/pages/DetectorsList/containers/List/List.tsx @@ -278,8 +278,12 @@ export const DetectorList = (props: ListProps) => { }); setIsLoadingFinalDetectors(true); - - getUpdatedDetectors(); + + dispatch( + getDetectorList( + getAllDetectorsQueryParamsWithDataSourceId(state.selectedDataSourceId) + ) + ); }, [ state.page, state.queryParams, @@ -330,14 +334,11 @@ export const DetectorList = (props: ListProps) => { }, [confirmModalState.isRequestingToClose, isLoading]); const getUpdatedDetectors = async () => { - // wait until selected data source is ready before doing dispatch calls if mds is enabled - if (!dataSourceEnabled || (state.selectedDataSourceId && state.selectedDataSourceId !== "")) { - dispatch( - getDetectorList( - getAllDetectorsQueryParamsWithDataSourceId(state.selectedDataSourceId) - ) - ); - } + dispatch( + getDetectorList( + getAllDetectorsQueryParamsWithDataSourceId(state.selectedDataSourceId) + ) + ); }; const handlePageChange = (pageNumber: number) => { @@ -845,4 +846,4 @@ export const DetectorList = (props: ListProps) => { ); -}; +}; \ No newline at end of file diff --git a/public/pages/DetectorsList/utils/helpers.ts b/public/pages/DetectorsList/utils/helpers.ts index 7e59bdb5..580cf02d 100644 --- a/public/pages/DetectorsList/utils/helpers.ts +++ b/public/pages/DetectorsList/utils/helpers.ts @@ -47,7 +47,7 @@ export const getURLQueryParams = (location: { typeof sortDirection !== 'string' ? DEFAULT_QUERY_PARAMS.sortDirection : (sortDirection as SORT_DIRECTION), - dataSourceId: dataSourceId === undefined ? undefined : dataSourceId, + dataSourceId: typeof dataSourceId === 'string' ? dataSourceId : undefined, }; }; diff --git a/public/pages/Overview/containers/AnomalyDetectionOverview.tsx b/public/pages/Overview/containers/AnomalyDetectionOverview.tsx index 4a02aa5e..29145bfd 100644 --- a/public/pages/Overview/containers/AnomalyDetectionOverview.tsx +++ b/public/pages/Overview/containers/AnomalyDetectionOverview.tsx @@ -155,8 +155,6 @@ export function AnomalyDetectionOverview(props: AnomalyDetectionOverviewProps) { // fetch smaple detectors and sample indices const fetchData = async () => { - // wait until selected data source is ready before doing dispatch calls if mds is enabled - if (!dataSourceEnabled || (MDSOverviewState.selectedDataSourceId && MDSOverviewState.selectedDataSourceId !== "")) { await dispatch( getDetectorList( getSampleDetectorsQueryParamsWithDataSouceId( @@ -174,7 +172,6 @@ export function AnomalyDetectionOverview(props: AnomalyDetectionOverviewProps) { ).catch((error: any) => { console.error('Error getting sample indices: ', error); }); - } }; // Create and populate sample index, create and start sample detector