Skip to content

Commit 4572bba

Browse files
chore: fe router refactoring (#1551)
1 parent 4a182f1 commit 4572bba

File tree

86 files changed

+319
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+319
-622
lines changed

odd-platform-ui/src/components/Activity/ActivityResults/ActivityItem/ActivityItem.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
} from 'components/shared/elements/Activity';
1919
import { useAppDateTime } from 'lib/hooks';
2020
import type { Activity } from 'redux/interfaces';
21-
import { useIsEmbeddedPath } from 'lib/hooks/useAppPaths/useIsEmbeddedPath';
2221
import { dataEntityDetailsPath } from 'routes';
2322
import * as S from './ActivityItemStyles';
2423

@@ -33,7 +32,6 @@ const ActivityItem: React.FC<ActivityItemProps> = ({
3332
hideAllDetails,
3433
dataQA,
3534
}) => {
36-
const { updatePath } = useIsEmbeddedPath();
3735
const { activityFormattedDateTime } = useAppDateTime();
3836

3937
const tagStateItem = React.useCallback(
@@ -50,7 +48,7 @@ const ActivityItem: React.FC<ActivityItemProps> = ({
5048
<S.Container container data-qa={dataQA}>
5149
<Grid container justifyContent='space-between' flexWrap='nowrap'>
5250
<Grid item display='flex' flexWrap='nowrap' alignItems='center'>
53-
<Link to={updatePath(dataEntityDetailsPath(activity.dataEntity.id))}>
51+
<Link to={dataEntityDetailsPath(activity.dataEntity.id)}>
5452
<Typography variant='h3' sx={{ mr: 1, width: 'max-content' }}>
5553
{activity.dataEntity.externalName || activity.dataEntity.internalName}
5654
</Typography>

odd-platform-ui/src/components/Alerts/AlertsList/AlertItem/AlertItem.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { GearIcon, UserIcon } from 'components/shared/icons';
99
import { AlertStatusItem, Button, EntityClassItem } from 'components/shared/elements';
1010
import { alertTitlesMap } from 'lib/constants';
1111
import { getGlobalPermissions } from 'redux/selectors';
12-
import { useIsEmbeddedPath } from 'lib/hooks/useAppPaths/useIsEmbeddedPath';
1312
import { dataEntityDetailsPath } from 'routes';
1413
import * as S from './AlertItemStyles';
1514

@@ -31,7 +30,6 @@ const AlertItem: React.FC<AlertItemProps> = ({
3130
}) => {
3231
const dispatch = useAppDispatch();
3332
const { alertFormattedDateTime } = useAppDateTime();
34-
const { updatePath } = useIsEmbeddedPath();
3533

3634
const [showHistory, setShowHistory] = React.useState(false);
3735
const [disableResolve, setDisableResolve] = React.useState(false);
@@ -119,7 +117,7 @@ const AlertItem: React.FC<AlertItemProps> = ({
119117
<>
120118
<Button
121119
text={dataEntity.externalName || dataEntity.internalName}
122-
to={updatePath(dataEntityDetailsPath(dataEntity.id))}
120+
to={dataEntityDetailsPath(dataEntity.id)}
123121
buttonType='link-m'
124122
/>
125123
{dataEntity?.entityClasses?.map(entityClass => (

odd-platform-ui/src/components/Alerts/AlertsTabs/AlertsTabs.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { type AppTabItem, AppTabs } from 'components/shared/elements';
44
import { changeAlertsFilterAction } from 'redux/slices/alerts.slice';
55
import { useAppDispatch } from 'redux/lib/hooks';
66
import type { AlertTotals } from 'generated-sources';
7-
import { useIsEmbeddedPath } from 'lib/hooks/useAppPaths/useIsEmbeddedPath';
87
import { alertsPath } from 'routes';
9-
import { useLocation, useMatch } from 'react-router-dom';
108
import useSetSelectedTab from 'components/shared/elements/AppTabs/useSetSelectedTab';
119

1210
interface AlertsTabsProps {
@@ -17,35 +15,32 @@ interface AlertsTabsProps {
1715
const AlertsTabs: React.FC<AlertsTabsProps> = ({ totals, showMyAndDepends }) => {
1816
const { t } = useTranslation();
1917
const dispatch = useAppDispatch();
20-
const { updatePath } = useIsEmbeddedPath();
21-
const match = useMatch(useLocation().pathname);
22-
2318
const [selectedTab, setSelectedTab] = useState(-1);
2419

2520
const tabs = useMemo<AppTabItem[]>(
2621
() => [
2722
{
2823
name: t('All'),
2924
hint: totals?.total ?? 0,
30-
link: updatePath(alertsPath('all')),
25+
link: alertsPath('all'),
3126
},
3227
{
3328
name: t('My Objects'),
3429
hint: totals?.myTotal ?? 0,
35-
link: updatePath(alertsPath('my')),
30+
link: alertsPath('my'),
3631
hidden: !showMyAndDepends,
3732
},
3833
{
3934
name: t('Dependents'),
4035
hint: totals?.dependentTotal ?? 0,
41-
link: updatePath(alertsPath('dependents')),
36+
link: alertsPath('dependents'),
4237
hidden: !showMyAndDepends,
4338
},
4439
],
4540
[totals, showMyAndDepends, t]
4641
);
4742

48-
useSetSelectedTab(tabs, match, setSelectedTab);
43+
useSetSelectedTab(tabs, setSelectedTab);
4944

5045
const alertsFilterUpdateAction = useCallback(() => {
5146
dispatch(changeAlertsFilterAction());

odd-platform-ui/src/components/App.tsx

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ import {
1010
fetchIdentity,
1111
fetchTagsList,
1212
} from 'redux/thunks';
13-
import { useAppPaths } from 'lib/hooks';
1413
import {
14+
activityPath,
1515
alertsPath,
16+
dataEntitiesPath,
1617
dataModellingPath,
1718
dataQualityPath,
1819
directoryPath,
1920
managementPath,
21+
searchPath,
22+
termsPath,
23+
termsSearchPath,
2024
} from 'routes';
2125

2226
// lazy elements
@@ -35,16 +39,6 @@ const DataModeling = lazy(() => import('./DataModelling/DataModelling'));
3539
const App: React.FC = () => {
3640
const dispatch = useAppDispatch();
3741

38-
const {
39-
isPathEmbedded,
40-
SearchRoutes,
41-
basePath,
42-
TermsRoutes,
43-
ActivityRoutes,
44-
getNonExactPath,
45-
getNonExactParamPath,
46-
} = useAppPaths();
47-
4842
useEffect(() => {
4943
dispatch(fetchDataEntitiesClassesAndTypes()).catch(() => {});
5044
dispatch(fetchIdentity()).catch(() => {});
@@ -55,38 +49,25 @@ const App: React.FC = () => {
5549
return (
5650
<div className='App'>
5751
<Toaster position='bottom-right' toastOptions={{ custom: { duration: 6000 } }} />
58-
{!isPathEmbedded && <AppToolbar />}
52+
<AppToolbar />
5953
<div style={{ paddingTop: `${toolbarHeight}px` }}>
6054
<AppSuspenseWrapper>
6155
<Routes>
62-
<Route path={basePath} element={<Overview />} />
63-
<Route path={getNonExactPath(SearchRoutes.search)} element={<Search />} />
64-
<Route path={getNonExactPath(managementPath())} element={<Management />} />
65-
<Route
66-
path={getNonExactPath(TermsRoutes.termSearch)}
67-
element={<TermSearch />}
68-
/>
69-
<Route path={getNonExactPath(alertsPath())} element={<Alerts />} />
70-
<Route
71-
path={getNonExactPath(ActivityRoutes.activity)}
72-
element={<Activity />}
73-
/>
74-
<Route path={getNonExactPath(TermsRoutes.terms)} element={<TermDetails />}>
75-
<Route path={getNonExactParamPath(TermsRoutes.termIdParam)} />
56+
<Route path='/' element={<Overview />} />
57+
<Route path={`${searchPath()}/*`} element={<Search />} />
58+
<Route path={`${managementPath()}/*`} element={<Management />} />
59+
<Route path={`${termsSearchPath()}/*`} element={<TermSearch />} />
60+
<Route path={`${alertsPath()}/*`} element={<Alerts />} />
61+
<Route path={activityPath()} element={<Activity />} />
62+
<Route path={termsPath()}>
63+
<Route path=':termId/*' element={<TermDetails />} />
64+
</Route>
65+
<Route path={dataEntitiesPath()}>
66+
<Route path=':dataEntityId/*' element={<DataEntityDetails />} />
7667
</Route>
77-
<Route
78-
path={getNonExactPath('/dataentities/:dataEntityId')}
79-
element={<DataEntityDetails />}
80-
/>
81-
<Route
82-
path={getNonExactPath(directoryPath())}
83-
element={<DirectoryRoutes />}
84-
/>
85-
<Route path={getNonExactPath(dataQualityPath())} element={<DataQuality />} />
86-
<Route
87-
path={getNonExactPath(dataModellingPath())}
88-
element={<DataModeling />}
89-
/>
68+
<Route path={`${directoryPath()}/*`} element={<DirectoryRoutes />} />
69+
<Route path={dataQualityPath()} element={<DataQuality />} />
70+
<Route path={`${dataModellingPath()}/*`} element={<DataModeling />} />
9071
</Routes>
9172
</AppSuspenseWrapper>
9273
</div>

odd-platform-ui/src/components/DataEntityDetails/DataCollaboration/CreateMessageForm/CreateMessageForm.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from 'components/shared/elements';
1414
import { type MessageRequest } from 'generated-sources';
1515
import { getMessageToSlackCreatingStatuses } from 'redux/selectors';
16-
import { useIsEmbeddedPath } from 'lib/hooks/useAppPaths/useIsEmbeddedPath';
1716
import { dataEntityDetailsPath } from 'routes';
1817

1918
interface CreateMessageFormProps {
@@ -28,13 +27,12 @@ const CreateMessageForm: React.FC<CreateMessageFormProps> = ({
2827
const { t } = useTranslation();
2928
const dispatch = useAppDispatch();
3029
const navigate = useNavigate();
31-
const { updatePath } = useIsEmbeddedPath();
3230

3331
const { isLoading: isMessageCreating, isLoaded: isMessageCreated } = useAppSelector(
3432
getMessageToSlackCreatingStatuses
3533
);
3634

37-
const toCollaboration = updatePath(dataEntityDetailsPath(dataEntityId, 'discussions'));
35+
const toCollaboration = dataEntityDetailsPath(dataEntityId, 'discussions');
3836

3937
type MessageFormData = Omit<MessageRequest, 'dataEntityId'>;
4038

odd-platform-ui/src/components/DataEntityDetails/DataCollaboration/CurrentMessage/Thread/Thread.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from 'redux/selectors';
1111
import { fetchRelatedMessages, messagesListSize as size } from 'redux/thunks';
1212
import { clearThreadState } from 'redux/slices/dataCollaboration.slice';
13-
import { useIsEmbeddedPath } from 'lib/hooks/useAppPaths/useIsEmbeddedPath';
1413
import { dataEntityDetailsPath, useDataEntityRouteParams } from 'routes';
1514
import ThreadContent from './ThreadContent/ThreadContent';
1615

@@ -21,7 +20,6 @@ const Thread: React.FC<ThreadProps> = ({ messageDate }) => {
2120
const dispatch = useAppDispatch();
2221
const navigate = useNavigate();
2322
const { dataEntityId, messageId } = useDataEntityRouteParams();
24-
const { updatePath } = useIsEmbeddedPath();
2523

2624
const mainMessage = useAppSelector(getDataEntityMessage(messageDate, messageId));
2725
const relatedMessages = useAppSelector(getRelatedMessages);
@@ -32,7 +30,7 @@ const Thread: React.FC<ThreadProps> = ({ messageDate }) => {
3230

3331
React.useEffect(() => {
3432
if (relatedMessagesError) {
35-
navigate(updatePath(dataEntityDetailsPath(dataEntityId, 'discussions')));
33+
navigate(dataEntityDetailsPath(dataEntityId, 'discussions'));
3634
}
3735
dispatch(
3836
fetchRelatedMessages({ dataEntityId, messageId, size, lastMessageId: lastId })

odd-platform-ui/src/components/DataEntityDetails/DataCollaboration/CurrentMessage/Thread/ThreadContent/ThreadContent.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { useTranslation } from 'react-i18next';
55
import { type Message } from 'redux/interfaces';
66
import { Button, EmptyContentPlaceholder } from 'components/shared/elements';
77
import { ClearIcon } from 'components/shared/icons';
8-
import { useIsEmbeddedPath } from 'lib/hooks/useAppPaths/useIsEmbeddedPath';
98
import { dataEntityDetailsPath } from 'routes';
109
import ThreadMessage from './ThreadMessage/ThreadMessage';
1110
import MainThreadMessage from './MainThreadMessage/MainThreadMessage';
@@ -31,7 +30,6 @@ const ThreadContent: React.FC<ThreadContentProps> = ({
3130
isRelatedMessagesLoaded,
3231
}) => {
3332
const { t } = useTranslation();
34-
const { updatePath } = useIsEmbeddedPath();
3533

3634
return (
3735
<Grid
@@ -46,7 +44,7 @@ const ThreadContent: React.FC<ThreadContentProps> = ({
4644
{t('Thread')}
4745
</Typography>
4846
<Button
49-
to={updatePath(dataEntityDetailsPath(dataEntityId, 'discussions'))}
47+
to={dataEntityDetailsPath(dataEntityId, 'discussions')}
5048
buttonType='linkGray-m'
5149
icon={<ClearIcon viewBox='0 0 16 16' width={24} height={24} />}
5250
sx={{ ml: 2 }}

odd-platform-ui/src/components/DataEntityDetails/DataCollaboration/MessagesList/MessagesList.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useNavigate } from 'react-router-dom';
44
import InfiniteScroll from 'react-infinite-scroll-component';
55
import { type MessagesByDate } from 'redux/interfaces';
66
import { EmptyContentPlaceholder } from 'components/shared/elements';
7-
import { useIsEmbeddedPath } from 'lib/hooks/useAppPaths/useIsEmbeddedPath';
87
import { dataEntityDiscussionsPath, useDataEntityRouteParams } from 'routes';
98
import Message from './Message/Message';
109
import * as S from './MessagesListStyles';
@@ -31,11 +30,9 @@ const MessagesList: React.FC<MessagesListProps> = ({
3130
}) => {
3231
const navigate = useNavigate();
3332
const { dataEntityId, messageId: routerMessageId } = useDataEntityRouteParams();
34-
const { updatePath } = useIsEmbeddedPath();
35-
3633
const handleMessageOnClick = React.useCallback(
3734
(messageId: string) => () => {
38-
navigate(updatePath(dataEntityDiscussionsPath(dataEntityId, messageId)));
35+
navigate(dataEntityDiscussionsPath(dataEntityId, messageId));
3936
},
4037
[dataEntityId]
4138
);

odd-platform-ui/src/components/DataEntityDetails/DataEntityDetailsTabs/DataEntityDetailsTabs.tsx

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ import {
1414
type ActivityQuery,
1515
defaultActivityQuery,
1616
} from 'components/shared/elements/Activity/common';
17-
import { useLocation, useMatch } from 'react-router-dom';
1817
import {
1918
dataEntityDetailsPath,
2019
dataEntityLineagePath,
2120
dataEntityTestReportsPath,
2221
useDataEntityRouteParams,
2322
} from 'routes';
2423
import useSetSelectedTab from 'components/shared/elements/AppTabs/useSetSelectedTab';
25-
import { useIsEmbeddedPath } from 'lib/hooks/useAppPaths/useIsEmbeddedPath';
2624
import { defaultLineageQuery } from '../Lineage/HierarchyLineage/lineageLib/constants';
2725
import { defaultDEGLineageQuery } from '../Lineage/DEGLineage/lib/constants';
2826

@@ -35,7 +33,6 @@ const DataEntityDetailsTabs: React.FC = () => {
3533
const { defaultQueryString: activityQueryString } =
3634
useQueryParams<ActivityQuery>(defaultActivityQuery);
3735

38-
const { updatePath } = useIsEmbeddedPath();
3936
const openAlertsCount = useAppSelector(getDataEntityAlertsCount(dataEntityId));
4037
const dataEntityDetails = useAppSelector(getDataEntityDetails(dataEntityId));
4138
const datasetQualityTestReportTotal = useAppSelector(
@@ -45,63 +42,59 @@ const DataEntityDetailsTabs: React.FC = () => {
4542
getIsDataEntityBelongsToClass(dataEntityId)
4643
);
4744
const isStatusDeleted = useAppSelector(getIsEntityStatusDeleted(dataEntityId));
48-
const match = useMatch(useLocation().pathname);
49-
5045
const tabs = useMemo<AppTabItem[]>(
5146
() => [
5247
{
5348
name: t('Overview'),
54-
link: updatePath(dataEntityDetailsPath(dataEntityId, 'overview')),
49+
link: dataEntityDetailsPath(dataEntityId, 'overview'),
5550
},
5651
{
5752
name: t('Structure'),
58-
link: updatePath(dataEntityDetailsPath(dataEntityId, 'structure')),
53+
link: dataEntityDetailsPath(dataEntityId, 'structure'),
5954
hidden: !isDataset,
6055
},
6156
{
6257
name: t('Lineage'),
63-
link: updatePath(
64-
dataEntityLineagePath(
65-
dataEntityId,
66-
isDEG ? degLineageQueryString : lineageQueryString
67-
)
58+
link: dataEntityLineagePath(
59+
dataEntityId,
60+
isDEG ? degLineageQueryString : lineageQueryString
6861
),
6962
hidden: isQualityTest || isStatusDeleted,
7063
},
7164
{
7265
name: t('Test reports'),
73-
link: updatePath(dataEntityTestReportsPath(dataEntityId)),
66+
link: dataEntityTestReportsPath(dataEntityId),
7467
hidden: !isDataset || !datasetQualityTestReportTotal || isStatusDeleted,
7568
},
7669
{
7770
name: t('History'),
78-
link: updatePath(dataEntityDetailsPath(dataEntityId, 'history')),
71+
link: dataEntityDetailsPath(dataEntityId, 'history'),
7972
hidden: (!isQualityTest && !isTransformer) || isStatusDeleted,
8073
},
8174
{
8275
name: t('Alerts'),
83-
link: updatePath(dataEntityDetailsPath(dataEntityId, 'alerts')),
76+
link: dataEntityDetailsPath(dataEntityId, 'alerts'),
8477
hint: openAlertsCount > 0 ? openAlertsCount : undefined,
8578
hintType: 'alert',
8679
hidden: isStatusDeleted,
8780
},
8881
{
8982
name: t('Linked entities'),
90-
link: updatePath(dataEntityDetailsPath(dataEntityId, 'linked-entities')),
83+
link: dataEntityDetailsPath(dataEntityId, 'linked-entities'),
9184
hidden: !dataEntityDetails?.hasChildren || isStatusDeleted,
9285
},
9386
{
9487
name: t('Query examples'),
95-
link: updatePath(dataEntityDetailsPath(dataEntityId, 'query-examples')),
88+
link: dataEntityDetailsPath(dataEntityId, 'query-examples'),
9689
hidden: !isDataset,
9790
},
9891
{
9992
name: t('Activity'),
100-
link: updatePath(dataEntityDetailsPath(dataEntityId, 'activity')),
93+
link: dataEntityDetailsPath(dataEntityId, 'activity'),
10194
},
10295
{
10396
name: t('Discussions'),
104-
link: updatePath(dataEntityDetailsPath(dataEntityId, 'discussions')),
97+
link: dataEntityDetailsPath(dataEntityId, 'discussions'),
10598
hidden: isStatusDeleted,
10699
},
107100
],
@@ -124,7 +117,7 @@ const DataEntityDetailsTabs: React.FC = () => {
124117
);
125118

126119
const [selectedTab, setSelectedTab] = React.useState(-1);
127-
useSetSelectedTab(tabs, match, setSelectedTab);
120+
useSetSelectedTab(tabs, setSelectedTab);
128121

129122
return (
130123
<>

0 commit comments

Comments
 (0)