Skip to content

Commit

Permalink
Merged PR 3050: routing & highlighting tree navigation bugs
Browse files Browse the repository at this point in the history
- setting isTabChanged variable to avoid overriding activeTab from url
- highlighting node in tree correctly
  • Loading branch information
Aleksy Lisowski authored and Piotr Czarnas committed Sep 28, 2024
2 parents 8442415 + afdf1d1 commit 3c95426
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -86,7 +86,7 @@ const ConnectionLayout = ({ route }: ConnectionLayoutProps) => {
setActiveTab(undefined);
history.push(`/${checkTypes}`);
}
setIsTabChanged(true);
dispatch(setIsTabChanged(true));
dispatch(closeFirstLevelTab(checkTypes, value));
};

Expand Down Expand Up @@ -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,
Expand All @@ -193,7 +194,6 @@ const ConnectionLayout = ({ route }: ConnectionLayoutProps) => {
routeWithoutTab.split('/')[routeWithoutTab.split('/').length - 1]
})
);
setActiveTab(newRoute);
}
}
}, [location.pathname, isTabChanged]);
Expand Down
3 changes: 3 additions & 0 deletions dqops/src/main/frontend/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useActionDispatch } from '../../hooks/useActionDispatch';
import {
setAdvisorJobId,
setAdvisorObject,
setIsTabChanged,
setJobAllert,
toggleAdvisor
} from '../../redux/actions/job.actions';
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -140,6 +142,7 @@ const Header = () => {
column
);
}
console.log('url', url);
if (!url) {
url = `/` + newCheckTypes;
history.push(url);
Expand Down
5 changes: 5 additions & 0 deletions dqops/src/main/frontend/src/redux/actions/job.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
10 changes: 9 additions & 1 deletion dqops/src/main/frontend/src/redux/reducers/job.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface IJobsState {
notificationCount: number;
newNotification: boolean;
job_allert: IJobAllert;
isTabChanged: boolean;
}

const initialState: IJobsState = {
Expand All @@ -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) => {
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion dqops/src/main/frontend/src/redux/types/job.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

0 comments on commit 3c95426

Please sign in to comment.