Skip to content

Commit c264467

Browse files
committed
migrate SETTINGS_TAG_LIST_VIEW
1 parent 1459183 commit c264467

7 files changed

Lines changed: 26 additions & 26 deletions

File tree

src/ROUTES.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ const DYNAMIC_ROUTES = {
148148
path: 'tag-approver',
149149
entryScreens: [SCREENS.SETTINGS_TAGS.SETTINGS_TAG_SETTINGS],
150150
},
151+
SETTINGS_TAG_LIST_VIEW: {
152+
path: 'tag-list',
153+
entryScreens: [SCREENS.SETTINGS_TAGS.SETTINGS_TAGS_ROOT],
154+
getRoute: (orderWeight: number) => `tag-list?orderWeight=${orderWeight}`,
155+
queryParams: ['orderWeight'],
156+
},
151157
DETAILS_CONSTANT_PICKER: {
152158
path: 'constant-picker',
153159
entryScreens: [SCREENS.DEBUG.REPORT, SCREENS.DEBUG.REPORT_ACTION, SCREENS.DEBUG.TRANSACTION, SCREENS.DEBUG.TRANSACTION_VIOLATION],
@@ -1300,12 +1306,6 @@ const ROUTES = {
13001306
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
13011307
getUrlWithBackToParam(`settings/${policyID}/tag/${orderWeight}/${encodeURIComponent(tagName)}` as const, backTo),
13021308
},
1303-
SETTINGS_TAG_LIST_VIEW: {
1304-
route: 'settings/:policyID/tag-list/:orderWeight',
1305-
1306-
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
1307-
getRoute: (policyID: string, orderWeight: number, backTo = '') => getUrlWithBackToParam(`settings/${policyID}/tag-list/${orderWeight}` as const, backTo),
1308-
},
13091309
SETTINGS_TAG_GL_CODE: {
13101310
route: 'settings/:policyID/tag/:orderWeight/:tagName/gl-code',
13111311
getRoute: (policyID: string, orderWeight: number, tagName: string, backTo = '') =>

src/SCREENS.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ const SCREENS = {
454454
SETTINGS_TAG_EDIT: 'Settings_Tag_Edit',
455455
SETTINGS_TAG_SETTINGS: 'Settings_Tag_Settings',
456456
DYNAMIC_SETTINGS_TAG_APPROVER: 'Dynamic_Settings_Tag_Approver',
457-
SETTINGS_TAG_LIST_VIEW: 'Settings_Tag_List_View',
457+
DYNAMIC_SETTINGS_TAG_LIST_VIEW: 'Dynamic_Settings_Tag_List_View',
458458
SETTINGS_TAG_GL_CODE: 'Settings_Tag_GL_Code',
459459
SETTINGS_TAGS_IMPORT: 'Settings_Tags_Import',
460460
SETTINGS_TAGS_IMPORTED: 'Settings_Tags_Imported',

src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ const TagsModalStackNavigator = createModalStackNavigator({
321321
[SCREENS.WORKSPACE.TAGS_IMPORT_OPTIONS]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/ImportTagsOptionsPage').default,
322322
[SCREENS.SETTINGS_TAGS.SETTINGS_TAGS_IMPORTED]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/ImportedTagsPage').default,
323323
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_SETTINGS]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/TagSettingsPage').default,
324-
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/WorkspaceViewTagsPage').default,
324+
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/WorkspaceViewTagsPage').default,
325325
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_CREATE]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/WorkspaceCreateTagPage').default,
326326
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_EDIT]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/EditTagPage').default,
327327
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_APPROVER]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/TagApproverPage').default,

src/libs/Navigation/linkingConfig/config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,12 +1500,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
15001500
},
15011501
},
15021502
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_APPROVER]: DYNAMIC_ROUTES.SETTINGS_TAG_APPROVER.path,
1503-
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW]: {
1504-
path: ROUTES.SETTINGS_TAG_LIST_VIEW.route,
1505-
parse: {
1506-
orderWeight: Number,
1507-
},
1508-
},
1503+
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW]: DYNAMIC_ROUTES.SETTINGS_TAG_LIST_VIEW.path,
15091504
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_GL_CODE]: {
15101505
path: ROUTES.SETTINGS_TAG_GL_CODE.route,
15111506
parse: {

src/libs/Navigation/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,9 @@ type SettingsNavigatorParamList = {
553553
// eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md
554554
backTo?: Routes;
555555
};
556-
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW]: {
556+
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW]: {
557557
policyID: string;
558-
orderWeight: number;
559-
// eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md
560-
backTo?: Routes;
558+
orderWeight: number | string;
561559
};
562560
[SCREENS.WORKSPACE.TAGS_EDIT]: {
563561
policyID: string;

src/pages/workspace/tags/WorkspaceTagsPage.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
} from '@libs/actions/Policy/Tag';
5252
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
5353
import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
54+
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
5455
import Navigation from '@libs/Navigation/Navigation';
5556
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
5657
import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types';
@@ -76,7 +77,7 @@ import variables from '@styles/variables';
7677
import {close} from '@userActions/Modal';
7778
import CONST from '@src/CONST';
7879
import ONYXKEYS from '@src/ONYXKEYS';
79-
import ROUTES from '@src/ROUTES';
80+
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
8081
import SCREENS from '@src/SCREENS';
8182
import type {PendingAction} from '@src/types/onyx/OnyxCommon';
8283
import type DeepValueOf from '@src/types/utils/DeepValueOf';
@@ -484,7 +485,9 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
484485
}
485486
if (tag.orderWeight !== undefined) {
486487
Navigation.navigate(
487-
isQuickSettingsFlow ? ROUTES.SETTINGS_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight, backTo) : ROUTES.WORKSPACE_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight),
488+
isQuickSettingsFlow
489+
? createDynamicRoute(DYNAMIC_ROUTES.SETTINGS_TAG_LIST_VIEW.getRoute(tag.orderWeight))
490+
: ROUTES.WORKSPACE_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight),
488491
);
489492
} else {
490493
Navigation.navigate(isQuickSettingsFlow ? ROUTES.SETTINGS_TAG_SETTINGS.getRoute(policyID, 0, tag.value, backTo) : ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, 0, tag.value));

src/pages/workspace/tags/WorkspaceViewTagsPage.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import CustomListHeader from '@components/SelectionListWithModal/CustomListHeade
1616
import ListItemRightCaretWithLabel from '@components/SelectionListWithModal/ListItemRightCaretWithLabel';
1717
import Switch from '@components/Switch';
1818
import useConfirmModal from '@hooks/useConfirmModal';
19+
import useDynamicBackPath from '@hooks/useDynamicBackPath';
1920
import useFilteredSelection from '@hooks/useFilteredSelection';
2021
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
2122
import useLocalize from '@hooks/useLocalize';
@@ -48,18 +49,20 @@ import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
4849
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
4950
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
5051
import CONST from '@src/CONST';
51-
import ROUTES from '@src/ROUTES';
52+
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
5253
import SCREENS from '@src/SCREENS';
5354
import type {PolicyTag} from '@src/types/onyx';
5455
import type DeepValueOf from '@src/types/utils/DeepValueOf';
5556
import type {TagListItem} from './types';
5657

5758
type WorkspaceViewTagsProps =
5859
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.TAG_LIST_VIEW>
59-
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW>;
60+
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW>;
6061

6162
function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
62-
const {policyID, backTo, orderWeight} = route.params;
63+
const {policyID, orderWeight: orderWeightParam} = route.params;
64+
const backTo = 'backTo' in route.params ? route.params.backTo : undefined;
65+
const orderWeight = Number(orderWeightParam);
6366

6467
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout for the small screen selection mode
6568
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
@@ -77,7 +80,8 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
7780
const hasDependentTags = useMemo(() => hasDependentTagsPolicyUtils(policy, policyTags), [policy, policyTags]);
7881
const isMultiLevelTags = isMultiLevelTagsPolicyUtils(policyTags);
7982
const currentPolicyTag = policyTags?.[currentTagListName];
80-
const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW;
83+
const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW;
84+
const backPath = useDynamicBackPath(DYNAMIC_ROUTES.SETTINGS_TAG_LIST_VIEW.path);
8185
const fetchTags = useCallback(() => {
8286
openPolicyTagsPage(policyID);
8387
}, [policyID]);
@@ -108,7 +112,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
108112
onClearSelection: () => {
109113
setSelectedTags([]);
110114
},
111-
onNavigationCallBack: () => Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_TAGS_ROOT.getRoute(policyID) : undefined),
115+
onNavigationCallBack: () => Navigation.goBack(isQuickSettingsFlow ? backPath : undefined),
112116
});
113117

114118
const updateWorkspaceTagEnabled = useCallback(
@@ -364,7 +368,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
364368
turnOffMobileSelectionMode();
365369
return;
366370
}
367-
Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_TAGS_ROOT.getRoute(policyID) : undefined);
371+
Navigation.goBack(isQuickSettingsFlow ? backPath : undefined);
368372
}}
369373
>
370374
{!shouldUseNarrowLayout && getHeaderButtons()}

0 commit comments

Comments
 (0)