From f01460d75c98bc61b85881921f68a2021c8fdb44 Mon Sep 17 00:00:00 2001 From: Aleksy Date: Sat, 28 Sep 2024 15:14:59 +0200 Subject: [PATCH 1/2] setting isTabChanged variable to avoid overriding activeTab from url --- .../frontend/src/components/ConnectionLayout/index.tsx | 6 +++--- .../src/main/frontend/src/components/Header/index.tsx | 3 +++ .../src/main/frontend/src/redux/actions/job.actions.ts | 5 +++++ .../main/frontend/src/redux/reducers/job.reducer.ts | 10 +++++++++- dqops/src/main/frontend/src/redux/types/job.types.ts | 3 ++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dqops/src/main/frontend/src/components/ConnectionLayout/index.tsx b/dqops/src/main/frontend/src/components/ConnectionLayout/index.tsx index 42be5b6950..d9858c9cbd 100644 --- a/dqops/src/main/frontend/src/components/ConnectionLayout/index.tsx +++ b/dqops/src/main/frontend/src/components/ConnectionLayout/index.tsx @@ -37,7 +37,7 @@ import TableMonthlyPartitionedChecksView from '../../pages/TableMonthlyPartition import TablePartitionedChecksUIFilterView from '../../pages/TablePartitionedChecksUIFilterView'; import TableProfilingChecksUIFilterView from '../../pages/TableProfilingChecksUIFilterView'; import TableProfilingChecksView from '../../pages/TableProfilingChecksView'; -import { setJobAllert } from '../../redux/actions/job.actions'; +import { setIsTabChanged, setJobAllert } from '../../redux/actions/job.actions'; import { getFirstLevelActiveTab, getFirstLevelState @@ -56,10 +56,10 @@ const ConnectionLayout = ({ route }: ConnectionLayoutProps) => { checkTypes: CheckTypes; } = useDecodedParams(); const { objectNotFound, setObjectNotFound, setActiveTab } = useTree(); - const [isTabChanged, setIsTabChanged] = React.useState(false); const { tabs: pageTabs, activeTab } = useSelector( (state: IRootState) => state.source[checkTypes || CheckTypes.SOURCES] ); + const { isTabChanged } = useSelector((state: IRootState) => state.job); const { dailyMonitoring, monthlyMonitoring, @@ -86,7 +86,7 @@ const ConnectionLayout = ({ route }: ConnectionLayoutProps) => { setActiveTab(undefined); history.push(`/${checkTypes}`); } - setIsTabChanged(true); + dispatch(setIsTabChanged(true)); dispatch(closeFirstLevelTab(checkTypes, value)); }; diff --git a/dqops/src/main/frontend/src/components/Header/index.tsx b/dqops/src/main/frontend/src/components/Header/index.tsx index 471e14ac17..688cca8bf7 100644 --- a/dqops/src/main/frontend/src/components/Header/index.tsx +++ b/dqops/src/main/frontend/src/components/Header/index.tsx @@ -8,6 +8,7 @@ import { useActionDispatch } from '../../hooks/useActionDispatch'; import { setAdvisorJobId, setAdvisorObject, + setIsTabChanged, setJobAllert, toggleAdvisor } from '../../redux/actions/job.actions'; @@ -67,6 +68,7 @@ const Header = () => { const { isAdvisorOpen, job_dictionary_state, advisorJobId, job_allert } = useSelector((state: IRootState) => state.job); const onClick = (newCheckTypes: CheckTypes) => () => { + dispatch(setIsTabChanged(true)); dispatch(setJobAllert({})); let url = ''; let value = ''; @@ -140,6 +142,7 @@ const Header = () => { column ); } + console.log('url', url); if (!url) { url = `/` + newCheckTypes; history.push(url); diff --git a/dqops/src/main/frontend/src/redux/actions/job.actions.ts b/dqops/src/main/frontend/src/redux/actions/job.actions.ts index 6c4ee4684e..c96d94966e 100644 --- a/dqops/src/main/frontend/src/redux/actions/job.actions.ts +++ b/dqops/src/main/frontend/src/redux/actions/job.actions.ts @@ -165,3 +165,8 @@ export const setJobAllert = (job_allert: IJobAllert) => ({ type: JOB_ACTION.SET_JOB_ALLERT, job_allert }); + +export const setIsTabChanged = (isTabChanged: boolean) => ({ + type: JOB_ACTION.SET_IS_TAB_CHANGED, + isTabChanged +}); diff --git a/dqops/src/main/frontend/src/redux/reducers/job.reducer.ts b/dqops/src/main/frontend/src/redux/reducers/job.reducer.ts index 4ea95b3824..9a8e30215b 100644 --- a/dqops/src/main/frontend/src/redux/reducers/job.reducer.ts +++ b/dqops/src/main/frontend/src/redux/reducers/job.reducer.ts @@ -57,6 +57,7 @@ export interface IJobsState { notificationCount: number; newNotification: boolean; job_allert: IJobAllert; + isTabChanged: boolean; } const initialState: IJobsState = { @@ -80,7 +81,8 @@ const initialState: IJobsState = { isErrorModalOpen: false, notificationCount: 0, newNotification: false, - job_allert: {} + job_allert: {}, + isTabChanged: false }; const schemaReducer = (state = initialState, action: any) => { @@ -357,6 +359,12 @@ const schemaReducer = (state = initialState, action: any) => { job_allert: action.job_allert }; } + case JOB_ACTION.SET_IS_TAB_CHANGED: { + return { + ...state, + isTabChanged: action.isTabChanged + }; + } default: return state; } diff --git a/dqops/src/main/frontend/src/redux/types/job.types.ts b/dqops/src/main/frontend/src/redux/types/job.types.ts index f8ccb19fde..0d3327649c 100644 --- a/dqops/src/main/frontend/src/redux/types/job.types.ts +++ b/dqops/src/main/frontend/src/redux/types/job.types.ts @@ -41,5 +41,6 @@ export enum JOB_ACTION { SET_NOTIFICATION_COUNT = 'JOB_ACTION/SET_NOTIFICATION_COUNT', SET_NEW_NOTIFIACTION = 'JOB_ACTION/SET_NEW_NOTIFIACTION', - SET_JOB_ALLERT = 'JOB_ACTION/SET_JOB_ALLERT' + SET_JOB_ALLERT = 'JOB_ACTION/SET_JOB_ALLERT', + SET_IS_TAB_CHANGED = 'JOB_ACTION/SET_IS_TAB_CHANGED' } From afdf1d1393c4651c6c4120093e0b35fa47189f3e Mon Sep 17 00:00:00 2001 From: Aleksy Date: Sat, 28 Sep 2024 17:38:35 +0200 Subject: [PATCH 2/2] highlighting node in tree correctly --- .../src/main/frontend/src/components/ConnectionLayout/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dqops/src/main/frontend/src/components/ConnectionLayout/index.tsx b/dqops/src/main/frontend/src/components/ConnectionLayout/index.tsx index d9858c9cbd..11be871c98 100644 --- a/dqops/src/main/frontend/src/components/ConnectionLayout/index.tsx +++ b/dqops/src/main/frontend/src/components/ConnectionLayout/index.tsx @@ -185,6 +185,7 @@ const ConnectionLayout = ({ route }: ConnectionLayoutProps) => { newRoute = newRoute.replace(`:${key}`, String(value)); routeWithoutTab = routeWithoutTab.replace(`:${key}`, String(value)); }); + dispatch( addFirstLevelTab(checkTypes, { url: newRoute, @@ -193,7 +194,6 @@ const ConnectionLayout = ({ route }: ConnectionLayoutProps) => { routeWithoutTab.split('/')[routeWithoutTab.split('/').length - 1] }) ); - setActiveTab(newRoute); } } }, [location.pathname, isTabChanged]);