Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2150,15 +2150,11 @@ const ROUTES = {
},
WORKSPACE_DUPLICATE: {
route: 'workspace/:policyID/duplicate',

// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getRoute: (policyID: string, backTo?: string) => getUrlWithBackToParam(`workspace/${policyID}/duplicate`, backTo),
getRoute: (policyID: string) => `workspace/${policyID}/duplicate` as const,
},
WORKSPACE_DUPLICATE_SELECT_FEATURES: {
route: 'workspace/:policyID/duplicate/select-features',

// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getRoute: (policyID: string, backTo?: string) => getUrlWithBackToParam(`workspace/${policyID}/duplicate/select-features`, backTo),
getRoute: (policyID: string) => `workspace/${policyID}/duplicate/select-features` as const,
},
WORKSPACE_RECEIPT_PARTNERS: {
route: 'workspaces/:policyID/receipt-partners',
Expand Down
10 changes: 9 additions & 1 deletion src/libs/Navigation/helpers/getAdaptedStateFromPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import Onyx from 'react-native-onyx';
import getInitialSplitNavigatorState from '@libs/Navigation/AppNavigator/createSplitNavigator/getInitialSplitNavigatorState';
import {config} from '@libs/Navigation/linkingConfig/config';
import {RHP_TO_SEARCH, RHP_TO_SETTINGS, RHP_TO_SIDEBAR, RHP_TO_WORKSPACE} from '@libs/Navigation/linkingConfig/RELATIONS';
import {RHP_TO_SEARCH, RHP_TO_SETTINGS, RHP_TO_SIDEBAR, RHP_TO_WORKSPACE, RHP_TO_WORKSPACES_LIST} from '@libs/Navigation/linkingConfig/RELATIONS';
import type {NavigationPartialRoute, RootNavigatorParamList} from '@libs/Navigation/types';
import CONST from '@src/CONST';
import NAVIGATORS from '@src/NAVIGATORS';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {Report} from '@src/types/onyx';
import getMatchingNewRoute from './getMatchingNewRoute';
Expand All @@ -18,7 +19,7 @@
import replacePathInNestedState from './replacePathInNestedState';

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 22 in src/libs/Navigation/helpers/getAdaptedStateFromPath.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -86,6 +87,13 @@
});
}

if (RHP_TO_WORKSPACES_LIST[route.name]) {
return {
name: SCREENS.WORKSPACES_LIST,
path: ROUTES.WORKSPACES_LIST.route,
};
}

if (RHP_TO_WORKSPACE[route.name]) {
const paramsFromRoute = getParamsFromRoute(RHP_TO_WORKSPACE[route.name]);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type {WorkspaceDuplicateNavigatorParamList} from '@navigation/types';
import SCREENS from '@src/SCREENS';

const WORKSPACES_LIST_TO_RHP: Partial<Record<keyof WorkspaceDuplicateNavigatorParamList, string[]>> = {
[SCREENS.WORKSPACE_DUPLICATE.ROOT]: [SCREENS.WORKSPACE_DUPLICATE.SELECT_FEATURES, SCREENS.WORKSPACE_DUPLICATE.ROOT],
};

export default WORKSPACES_LIST_TO_RHP;
3 changes: 3 additions & 0 deletions src/libs/Navigation/linkingConfig/RELATIONS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SIDEBAR_TO_RHP from './SIDEBAR_TO_RHP';
import SIDEBAR_TO_SPLIT from './SIDEBAR_TO_SPLIT';
import TAB_TO_FULLSCREEN from './TAB_TO_FULLSCREEN';
import WORKSPACE_TO_RHP from './WORKSPACE_TO_RHP';
import WORKSPACES_LIST_TO_RHP from './WORKSPACES_LIST_TO_RHP';

/**
* This module manages the relationships between different fullscreen navigators and screens in the app.
Expand All @@ -29,6 +30,7 @@ const RHP_TO_SETTINGS = createInverseRelation(SETTINGS_TO_RHP);
const RHP_TO_WORKSPACE = createInverseRelation(WORKSPACE_TO_RHP);
const RHP_TO_SIDEBAR = createInverseRelation(SIDEBAR_TO_RHP);
const SPLIT_TO_SIDEBAR = createInverseRelation(SIDEBAR_TO_SPLIT);
const RHP_TO_WORKSPACES_LIST = createInverseRelation(WORKSPACES_LIST_TO_RHP);
const RHP_TO_SEARCH = createInverseRelation(SEARCH_TO_RHP);
const FULLSCREEN_TO_TAB = createInverseRelation(TAB_TO_FULLSCREEN);

Expand All @@ -45,4 +47,5 @@ export {
SPLIT_TO_SIDEBAR,
TAB_TO_FULLSCREEN,
FULLSCREEN_TO_TAB,
RHP_TO_WORKSPACES_LIST,
};
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspacesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
threeDotsMenuItems.push({
icon: Expensicons.Copy,
text: translate('workspace.common.duplicateWorkspace'),
onSelected: () => (item.policyID ? Navigation.navigate(ROUTES.WORKSPACE_DUPLICATE.getRoute(item.policyID, ROUTES.WORKSPACES_LIST.route)) : undefined),
onSelected: () => (item.policyID ? Navigation.navigate(ROUTES.WORKSPACE_DUPLICATE.getRoute(item.policyID)) : undefined),
});
}

Expand Down Expand Up @@ -319,7 +319,7 @@
</OfflineWithFeedback>
);
},
[

Check warning on line 322 in src/pages/workspace/WorkspacesListPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has a duplicate dependency: 'styles.ph5'. Either omit it or remove the dependency array
session?.email,
session?.accountID,
activePolicyID,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/duplicate/WorkspaceDuplicateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function WorkspaceDuplicateForm({policyID}: WorkspaceDuplicateFormProps) {
}
const newPolicyID = generatePolicyID();
setDuplicateWorkspaceData({policyID: newPolicyID, name, file: avatarFile});
Navigation.navigate(ROUTES.WORKSPACE_DUPLICATE_SELECT_FEATURES.getRoute(policyID, ROUTES.WORKSPACES_LIST.route));
Navigation.navigate(ROUTES.WORKSPACE_DUPLICATE_SELECT_FEATURES.getRoute(policyID));
},
[policyID],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function WorkspaceDuplicateSelectFeaturesForm({policyID}: WorkspaceDuplicateForm
return (
<>
<HeaderWithBackButton
onBackButtonPress={policyID ? () => Navigation.goBack(ROUTES.WORKSPACE_DUPLICATE.getRoute(policyID, ROUTES.WORKSPACES_LIST.route)) : undefined}
onBackButtonPress={policyID ? () => Navigation.goBack(ROUTES.WORKSPACE_DUPLICATE.getRoute(policyID)) : undefined}
title={translate('workspace.common.duplicateWorkspace')}
/>
<>
Expand Down
Loading