From 4790917764fceb69f7a9b58929ea80b7454409a7 Mon Sep 17 00:00:00 2001 From: saimedhi Date: Thu, 12 Dec 2024 13:17:50 -0800 Subject: [PATCH] Fix MDS bug Signed-off-by: saimedhi --- public/pages/workflows/workflows.tsx | 45 +++++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/public/pages/workflows/workflows.tsx b/public/pages/workflows/workflows.tsx index 90a6f857..71958aec 100644 --- a/public/pages/workflows/workflows.tsx +++ b/public/pages/workflows/workflows.tsx @@ -116,12 +116,15 @@ export function Workflows(props: WorkflowsProps) { // If the user navigates back to the manage tab, re-fetch workflows useEffect(() => { if (selectedTabId === WORKFLOWS_TAB.MANAGE) { - dispatch( - searchWorkflows({ - apiBody: FETCH_ALL_QUERY, - dataSourceId: dataSourceId, - }) - ); + // wait until selected data source is ready before doing dispatch calls if mds is enabled + if (!dataSourceEnabled || (dataSourceId && dataSourceId !== '')) { + dispatch( + searchWorkflows({ + apiBody: FETCH_ALL_QUERY, + dataSourceId: dataSourceId, + }) + ); + } } }, [selectedTabId]); @@ -138,12 +141,15 @@ export function Workflows(props: WorkflowsProps) { // On initial render: fetch all workflows useEffect(() => { - dispatch( - searchWorkflows({ - apiBody: FETCH_ALL_QUERY, - dataSourceId: dataSourceId, - }) - ); + // wait until selected data source is ready before doing dispatch calls if mds is enabled + if (!dataSourceEnabled || (dataSourceId && dataSourceId !== '')) { + dispatch( + searchWorkflows({ + apiBody: FETCH_ALL_QUERY, + dataSourceId: dataSourceId, + }) + ); + } }, []); useEffect(() => { @@ -158,12 +164,15 @@ export function Workflows(props: WorkflowsProps) { search: queryString.stringify(updatedParams), }); } - dispatch( - searchWorkflows({ - apiBody: FETCH_ALL_QUERY, - dataSourceId: dataSourceId, - }) - ); + // wait until selected data source is ready before doing dispatch calls if mds is enabled + if (!dataSourceEnabled || (dataSourceId && dataSourceId !== '')) { + dispatch( + searchWorkflows({ + apiBody: FETCH_ALL_QUERY, + dataSourceId: dataSourceId, + }) + ); + } }, [dataSourceId, setDataSourceId]); const handleDataSourceChange = ([event]: DataSourceOption[]) => {