Skip to content
Open
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
22 changes: 10 additions & 12 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ const DYNAMIC_ROUTES = {
path: 'keyboard-shortcuts',
entryScreens: ['*'],
},
SETTINGS_TAG_APPROVER: {
path: 'tag-approver',
entryScreens: [SCREENS.SETTINGS_TAGS.SETTINGS_TAG_SETTINGS],
},
SETTINGS_TAG_LIST_VIEW: {
path: 'tag-list',
entryScreens: [SCREENS.SETTINGS_TAGS.SETTINGS_TAGS_ROOT],
getRoute: (orderWeight: number) => `tag-list?orderWeight=${orderWeight}`,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Are we moving the orderWeight to query params? The old path is settings/:policyID/tag-list/:orderWeight',

queryParams: ['orderWeight'],
},
DETAILS_CONSTANT_PICKER: {
path: 'constant-picker',
entryScreens: [SCREENS.DEBUG.REPORT, SCREENS.DEBUG.REPORT_ACTION, SCREENS.DEBUG.TRANSACTION, SCREENS.DEBUG.TRANSACTION_VIOLATION],
Expand Down Expand Up @@ -1390,18 +1400,6 @@ const ROUTES = {
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getUrlWithBackToParam(`settings/${policyID}/tag/${orderWeight}/${encodeURIComponent(tagName)}` as const, backTo),
},
SETTINGS_TAG_APPROVER: {
route: 'settings/:policyID/tag/:orderWeight/:tagName/approver',
getRoute: (policyID: string, orderWeight: number, tagName: string, backTo = '') =>
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getUrlWithBackToParam(`settings/${policyID}/tag/${orderWeight}/${encodeURIComponent(tagName)}/approver` as const, backTo),
},
SETTINGS_TAG_LIST_VIEW: {
route: 'settings/:policyID/tag-list/:orderWeight',

// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getRoute: (policyID: string, orderWeight: number, backTo = '') => getUrlWithBackToParam(`settings/${policyID}/tag-list/${orderWeight}` as const, backTo),
},
SETTINGS_TAG_GL_CODE: {
route: 'settings/:policyID/tag/:orderWeight/:tagName/gl-code',
getRoute: (policyID: string, orderWeight: number, tagName: string, backTo = '') =>
Expand Down
4 changes: 2 additions & 2 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ const SCREENS = {
SETTINGS_TAG_CREATE: 'Settings_Tag_Create',
SETTINGS_TAG_EDIT: 'Settings_Tag_Edit',
SETTINGS_TAG_SETTINGS: 'Settings_Tag_Settings',
SETTINGS_TAG_APPROVER: 'Settings_Tag_Approver',
SETTINGS_TAG_LIST_VIEW: 'Settings_Tag_List_View',
DYNAMIC_SETTINGS_TAG_APPROVER: 'Dynamic_Settings_Tag_Approver',
DYNAMIC_SETTINGS_TAG_LIST_VIEW: 'Dynamic_Settings_Tag_List_View',
SETTINGS_TAG_GL_CODE: 'Settings_Tag_GL_Code',
SETTINGS_TAGS_IMPORT: 'Settings_Tags_Import',
SETTINGS_TAGS_IMPORTED: 'Settings_Tags_Imported',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ const TagsModalStackNavigator = createModalStackNavigator({
[SCREENS.WORKSPACE.TAGS_IMPORT_OPTIONS]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/ImportTagsOptionsPage').default,
[SCREENS.SETTINGS_TAGS.SETTINGS_TAGS_IMPORTED]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/ImportedTagsPage').default,
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_SETTINGS]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/TagSettingsPage').default,
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/WorkspaceViewTagsPage').default,
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/WorkspaceViewTagsPage').default,
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_CREATE]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/WorkspaceCreateTagPage').default,
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_EDIT]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/EditTagPage').default,
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_APPROVER]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/TagApproverPage').default,
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_APPROVER]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/TagApproverPage').default,
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_GL_CODE]: () => require<ReactComponentModule>('../../../../pages/workspace/tags/TagGLCodePage').default,
});

Expand Down
14 changes: 2 additions & 12 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1523,18 +1523,8 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
orderWeight: Number,
},
},
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_APPROVER]: {
path: ROUTES.SETTINGS_TAG_APPROVER.route,
parse: {
orderWeight: Number,
},
},
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW]: {
path: ROUTES.SETTINGS_TAG_LIST_VIEW.route,
parse: {
orderWeight: Number,
},
},
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_APPROVER]: DYNAMIC_ROUTES.SETTINGS_TAG_APPROVER.path,
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW]: DYNAMIC_ROUTES.SETTINGS_TAG_LIST_VIEW.path,
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_GL_CODE]: {
path: ROUTES.SETTINGS_TAG_GL_CODE.route,
parse: {
Expand Down
10 changes: 3 additions & 7 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,9 @@ type SettingsNavigatorParamList = {
// 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
backTo?: Routes;
};
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW]: {
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW]: {
policyID: string;
orderWeight: number;
// 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
backTo?: Routes;
orderWeight: number | string;
};
[SCREENS.WORKSPACE.TAGS_EDIT]: {
policyID: string;
Expand Down Expand Up @@ -590,12 +588,10 @@ type SettingsNavigatorParamList = {
// 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
backTo?: Routes;
};
[SCREENS.SETTINGS_TAGS.SETTINGS_TAG_APPROVER]: {
[SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_APPROVER]: {
policyID: string;
orderWeight: number;
tagName: string;
// 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
backTo?: Routes;
};
[SCREENS.WORKSPACE.TAG_GL_CODE]: {
policyID: string;
Expand Down
14 changes: 7 additions & 7 deletions src/pages/workspace/tags/TagApproverPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import WorkspaceMembersSelectionList from '@components/WorkspaceMembersSelectionList';
import useDynamicBackPath from '@hooks/useDynamicBackPath';
import useLocalize from '@hooks/useLocalize';
import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -12,27 +13,26 @@ import {getTagApproverRule} from '@libs/PolicyUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';

type TagApproverPageProps =
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.TAG_APPROVER>
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS_TAGS.SETTINGS_TAG_APPROVER>;
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_APPROVER>;

function TagApproverPage({route}: TagApproverPageProps) {
const {policyID, tagName, orderWeight, backTo} = route.params;
const {policyID, tagName, orderWeight} = route.params;

const styles = useThemeStyles();
const {translate} = useLocalize();
const policy = usePolicy(policyID);

const tagApprover = getTagApproverRule(policy, tagName)?.approver;
const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_TAGS.SETTINGS_TAG_APPROVER;
const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_APPROVER;
const backPath = useDynamicBackPath(DYNAMIC_ROUTES.SETTINGS_TAG_APPROVER.path);

const goBack = () => {
Navigation.goBack(
isQuickSettingsFlow ? ROUTES.SETTINGS_TAG_SETTINGS.getRoute(policyID, orderWeight, tagName, backTo) : ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, orderWeight, tagName),
);
Navigation.goBack(isQuickSettingsFlow ? backPath : ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, orderWeight, tagName));
};

return (
Expand Down
7 changes: 3 additions & 4 deletions src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import useLocalize from '@hooks/useLocalize';
import usePolicyData from '@hooks/usePolicyData';
import useThemeStyles from '@hooks/useThemeStyles';
import {getLatestErrorMessageField} from '@libs/ErrorUtils';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import {isDisablingOrDeletingLastEnabledTag} from '@libs/OptionsListUtils';
Expand All @@ -35,7 +36,7 @@ import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import {clearPolicyTagErrors, deletePolicyTags, setWorkspaceTagEnabled} from '@userActions/Policy/Tag';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';

type TagSettingsPageProps =
Expand Down Expand Up @@ -118,9 +119,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) {

const navigateToEditTagApprover = () => {
Navigation.navigate(
isQuickSettingsFlow
? ROUTES.SETTINGS_TAG_APPROVER.getRoute(policyID, orderWeight, currentPolicyTag.name, backTo)
: ROUTES.WORKSPACE_TAG_APPROVER.getRoute(policyID, orderWeight, currentPolicyTag.name),
isQuickSettingsFlow ? createDynamicRoute(DYNAMIC_ROUTES.SETTINGS_TAG_APPROVER.path) : ROUTES.WORKSPACE_TAG_APPROVER.getRoute(policyID, orderWeight, currentPolicyTag.name),
);
};

Expand Down
7 changes: 5 additions & 2 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
} from '@libs/actions/Policy/Tag';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types';
Expand All @@ -76,7 +77,7 @@ import variables from '@styles/variables';
import {close} from '@userActions/Modal';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {PendingAction} from '@src/types/onyx/OnyxCommon';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
Expand Down Expand Up @@ -485,7 +486,9 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
}
if (tag.orderWeight !== undefined) {
Navigation.navigate(
isQuickSettingsFlow ? ROUTES.SETTINGS_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight, backTo) : ROUTES.WORKSPACE_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight),
isQuickSettingsFlow
? createDynamicRoute(DYNAMIC_ROUTES.SETTINGS_TAG_LIST_VIEW.getRoute(tag.orderWeight))
: ROUTES.WORKSPACE_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight),
);
} else {
Navigation.navigate(isQuickSettingsFlow ? ROUTES.SETTINGS_TAG_SETTINGS.getRoute(policyID, 0, tag.value, backTo) : ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, 0, tag.value));
Expand Down
16 changes: 10 additions & 6 deletions src/pages/workspace/tags/WorkspaceViewTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import CustomListHeader from '@components/SelectionListWithModal/CustomListHeade
import ListItemRightCaretWithLabel from '@components/SelectionListWithModal/ListItemRightCaretWithLabel';
import Switch from '@components/Switch';
import useConfirmModal from '@hooks/useConfirmModal';
import useDynamicBackPath from '@hooks/useDynamicBackPath';
import useFilteredSelection from '@hooks/useFilteredSelection';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -48,18 +49,20 @@ import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {PolicyTag} from '@src/types/onyx';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type {TagListItem} from './types';

type WorkspaceViewTagsProps =
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.TAG_LIST_VIEW>
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW>;
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW>;

function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
const {policyID, backTo, orderWeight} = route.params;
const {policyID, orderWeight: orderWeightParam} = route.params;
const backTo = 'backTo' in route.params ? route.params.backTo : undefined;
const orderWeight = Number(orderWeightParam);

// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout for the small screen selection mode
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
Expand All @@ -77,7 +80,8 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
const hasDependentTags = useMemo(() => hasDependentTagsPolicyUtils(policy, policyTags), [policy, policyTags]);
const isMultiLevelTags = isMultiLevelTagsPolicyUtils(policyTags);
const currentPolicyTag = policyTags?.[currentTagListName];
const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_TAGS.SETTINGS_TAG_LIST_VIEW;
const isQuickSettingsFlow = route.name === SCREENS.SETTINGS_TAGS.DYNAMIC_SETTINGS_TAG_LIST_VIEW;
const backPath = useDynamicBackPath(DYNAMIC_ROUTES.SETTINGS_TAG_LIST_VIEW.path);
const fetchTags = useCallback(() => {
openPolicyTagsPage(policyID);
}, [policyID]);
Expand Down Expand Up @@ -108,7 +112,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
onClearSelection: () => {
setSelectedTags([]);
},
onNavigationCallBack: () => Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_TAGS_ROOT.getRoute(policyID) : undefined),
onNavigationCallBack: () => Navigation.goBack(isQuickSettingsFlow ? backPath : undefined),
});

const updateWorkspaceTagEnabled = useCallback(
Expand Down Expand Up @@ -364,7 +368,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
turnOffMobileSelectionMode();
return;
}
Navigation.goBack(isQuickSettingsFlow ? ROUTES.SETTINGS_TAGS_ROOT.getRoute(policyID) : undefined);
Navigation.goBack(isQuickSettingsFlow ? backPath : undefined);
}}
>
{!shouldUseNarrowLayout && getHeaderButtons()}
Expand Down
Loading