Skip to content

Commit

Permalink
Merge pull request #47990 from bernhardoj/fix/46773-add-backto-to-man…
Browse files Browse the repository at this point in the history
…y-pages

Add backTo to many pages so it shows the correct screen below the RHP overlay
  • Loading branch information
luacmartins authored Sep 24, 2024
2 parents 9d051a7 + fc6eed0 commit a8e95b9
Show file tree
Hide file tree
Showing 71 changed files with 789 additions and 359 deletions.
3 changes: 3 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,9 @@ const CONST = {
ACCESS_VARIANTS: {
CREATE: 'create',
},
PAGE_INDEX: {
CONFIRM: 'confirm',
},
PAYMENT_SELECTED: {
BBA: 'BBA',
PBA: 'PBA',
Expand Down
100 changes: 59 additions & 41 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const ROUTES = {
SUBMIT_EXPENSE: 'submit-expense',
FLAG_COMMENT: {
route: 'flag/:reportID/:reportActionID',
getRoute: (reportID: string, reportActionID: string) => `flag/${reportID}/${reportActionID}` as const,
getRoute: (reportID: string, reportActionID: string, backTo?: string) => getUrlWithBackToParam(`flag/${reportID}/${reportActionID}` as const, backTo),
},
CHAT_FINDER: 'chat-finder',
PROFILE: {
Expand Down Expand Up @@ -287,11 +287,11 @@ const ROUTES = {
},
EDIT_REPORT_FIELD_REQUEST: {
route: 'r/:reportID/edit/policyField/:policyID/:fieldID',
getRoute: (reportID: string, policyID: string, fieldID: string) => `r/${reportID}/edit/policyField/${policyID}/${fieldID}` as const,
getRoute: (reportID: string, policyID: string, fieldID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/edit/policyField/${policyID}/${fieldID}` as const, backTo),
},
REPORT_WITH_ID_DETAILS_SHARE_CODE: {
route: 'r/:reportID/details/shareCode',
getRoute: (reportID: string) => `r/${reportID}/details/shareCode` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details/shareCode` as const, backTo),
},
ATTACHMENTS: {
route: 'attachment',
Expand All @@ -300,85 +300,85 @@ const ROUTES = {
},
REPORT_PARTICIPANTS: {
route: 'r/:reportID/participants',
getRoute: (reportID: string) => `r/${reportID}/participants` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/participants` as const, backTo),
},
REPORT_PARTICIPANTS_INVITE: {
route: 'r/:reportID/participants/invite',
getRoute: (reportID: string) => `r/${reportID}/participants/invite` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/participants/invite` as const, backTo),
},
REPORT_PARTICIPANTS_DETAILS: {
route: 'r/:reportID/participants/:accountID',
getRoute: (reportID: string, accountID: number) => `r/${reportID}/participants/${accountID}` as const,
getRoute: (reportID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/participants/${accountID}` as const, backTo),
},
REPORT_PARTICIPANTS_ROLE_SELECTION: {
route: 'r/:reportID/participants/:accountID/role',
getRoute: (reportID: string, accountID: number) => `r/${reportID}/participants/${accountID}/role` as const,
getRoute: (reportID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/participants/${accountID}/role` as const, backTo),
},
REPORT_WITH_ID_DETAILS: {
route: 'r/:reportID/details',
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details`, backTo),
},
REPORT_WITH_ID_DETAILS_EXPORT: {
route: 'r/:reportID/details/export/:connectionName',
getRoute: (reportID: string, connectionName: ConnectionName) => `r/${reportID}/details/export/${connectionName}` as const,
getRoute: (reportID: string, connectionName: ConnectionName, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details/export/${connectionName}` as const, backTo),
},
REPORT_SETTINGS: {
route: 'r/:reportID/settings',
getRoute: (reportID: string) => `r/${reportID}/settings` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/settings` as const, backTo),
},
REPORT_SETTINGS_NAME: {
route: 'r/:reportID/settings/name',
getRoute: (reportID: string) => `r/${reportID}/settings/name` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/settings/name` as const, backTo),
},
REPORT_SETTINGS_NOTIFICATION_PREFERENCES: {
route: 'r/:reportID/settings/notification-preferences',
getRoute: (reportID: string) => `r/${reportID}/settings/notification-preferences` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/settings/notification-preferences` as const, backTo),
},
REPORT_SETTINGS_WRITE_CAPABILITY: {
route: 'r/:reportID/settings/who-can-post',
getRoute: (reportID: string) => `r/${reportID}/settings/who-can-post` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/settings/who-can-post` as const, backTo),
},
REPORT_SETTINGS_VISIBILITY: {
route: 'r/:reportID/settings/visibility',
getRoute: (reportID: string) => `r/${reportID}/settings/visibility` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/settings/visibility` as const, backTo),
},
SPLIT_BILL_DETAILS: {
route: 'r/:reportID/split/:reportActionID',
getRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}` as const,
getRoute: (reportID: string, reportActionID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/split/${reportActionID}` as const, backTo),
},
TASK_TITLE: {
route: 'r/:reportID/title',
getRoute: (reportID: string) => `r/${reportID}/title` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/title` as const, backTo),
},
REPORT_DESCRIPTION: {
route: 'r/:reportID/description',
getRoute: (reportID: string) => `r/${reportID}/description` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/description` as const, backTo),
},
TASK_ASSIGNEE: {
route: 'r/:reportID/assignee',
getRoute: (reportID: string) => `r/${reportID}/assignee` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/assignee` as const, backTo),
},
PRIVATE_NOTES_LIST: {
route: 'r/:reportID/notes',
getRoute: (reportID: string) => `r/${reportID}/notes` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/notes` as const, backTo),
},
PRIVATE_NOTES_EDIT: {
route: 'r/:reportID/notes/:accountID/edit',
getRoute: (reportID: string, accountID: string | number) => `r/${reportID}/notes/${accountID}/edit` as const,
getRoute: (reportID: string, accountID: string | number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/notes/${accountID}/edit` as const, backTo),
},
ROOM_MEMBERS: {
route: 'r/:reportID/members',
getRoute: (reportID: string) => `r/${reportID}/members` as const,
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/members` as const, backTo),
},
ROOM_MEMBER_DETAILS: {
route: 'r/:reportID/members/:accountID',
getRoute: (reportID: string, accountID: string | number) => `r/${reportID}/members/${accountID}` as const,
getRoute: (reportID: string, accountID: string | number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/members/${accountID}` as const, backTo),
},
ROOM_INVITE: {
route: 'r/:reportID/invite/:role?',
getRoute: (reportID: string, role?: string) => {
getRoute: (reportID: string, role?: string, backTo?: string) => {
const route = role ? (`r/${reportID}/invite/${role}` as const) : (`r/${reportID}/invite` as const);
return route;
return getUrlWithBackToParam(route, backTo);
},
},
MONEY_REQUEST_HOLD_REASON: {
Expand Down Expand Up @@ -406,9 +406,9 @@ const ROUTES = {
`${action as string}/${iouType as string}/confirmation/${transactionID}/${reportID}${participantsAutoAssigned ? '?participantsAutoAssigned=true' : ''}` as const,
},
MONEY_REQUEST_STEP_AMOUNT: {
route: ':action/:iouType/amount/:transactionID/:reportID',
getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action as string}/${iouType as string}/amount/${transactionID}/${reportID}`, backTo),
route: ':action/:iouType/amount/:transactionID/:reportID/:pageIndex?',
getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, pageIndex: string, backTo = '') =>
getUrlWithBackToParam(`${action as string}/${iouType as string}/amount/${transactionID}/${reportID}/${pageIndex}`, backTo),
},
MONEY_REQUEST_STEP_TAX_RATE: {
route: ':action/:iouType/taxRate/:transactionID/:reportID?',
Expand Down Expand Up @@ -536,12 +536,27 @@ const ROUTES = {
IOU_SEND_ADD_DEBIT_CARD: 'pay/new/add-debit-card',
IOU_SEND_ENABLE_PAYMENTS: 'pay/new/enable-payments',

NEW_TASK: 'new/task',
NEW_TASK_ASSIGNEE: 'new/task/assignee',
NEW_TASK: {
route: 'new/task',
getRoute: (backTo?: string) => getUrlWithBackToParam('new/task', backTo),
},
NEW_TASK_ASSIGNEE: {
route: 'new/task/assignee',
getRoute: (backTo?: string) => getUrlWithBackToParam('new/task/assignee', backTo),
},
NEW_TASK_SHARE_DESTINATION: 'new/task/share-destination',
NEW_TASK_DETAILS: 'new/task/details',
NEW_TASK_TITLE: 'new/task/title',
NEW_TASK_DESCRIPTION: 'new/task/description',
NEW_TASK_DETAILS: {
route: 'new/task/details',
getRoute: (backTo?: string) => getUrlWithBackToParam('new/task/details', backTo),
},
NEW_TASK_TITLE: {
route: 'new/task/title',
getRoute: (backTo?: string) => getUrlWithBackToParam('new/task/title', backTo),
},
NEW_TASK_DESCRIPTION: {
route: 'new/task/description',
getRoute: (backTo?: string) => getUrlWithBackToParam('new/task/description', backTo),
},

TEACHERS_UNITE: 'settings/teachersunite',
I_KNOW_A_TEACHER: 'settings/teachersunite/i-know-a-teacher',
Expand Down Expand Up @@ -1097,7 +1112,10 @@ const ROUTES = {
route: 'referral/:contentType',
getRoute: (contentType: string, backTo?: string) => getUrlWithBackToParam(`referral/${contentType}`, backTo),
},
PROCESS_MONEY_REQUEST_HOLD: 'hold-expense-educational',
PROCESS_MONEY_REQUEST_HOLD: {
route: 'hold-expense-educational',
getRoute: (backTo?: string) => getUrlWithBackToParam('hold-expense-educational', backTo),
},
TRAVEL_MY_TRIPS: 'travel',
TRAVEL_TCS: 'travel/terms',
TRACK_TRAINING_MODAL: 'track-training',
Expand Down Expand Up @@ -1126,39 +1144,39 @@ const ROUTES = {
},
TRANSACTION_DUPLICATE_REVIEW_PAGE: {
route: 'r/:threadReportID/duplicates/review',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review` as const, backTo),
},
TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE: {
route: 'r/:threadReportID/duplicates/review/merchant',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/merchant` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/merchant` as const, backTo),
},
TRANSACTION_DUPLICATE_REVIEW_CATEGORY_PAGE: {
route: 'r/:threadReportID/duplicates/review/category',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/category` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/category` as const, backTo),
},
TRANSACTION_DUPLICATE_REVIEW_TAG_PAGE: {
route: 'r/:threadReportID/duplicates/review/tag',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/tag` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/tag` as const, backTo),
},
TRANSACTION_DUPLICATE_REVIEW_TAX_CODE_PAGE: {
route: 'r/:threadReportID/duplicates/review/tax-code',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/tax-code` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/tax-code` as const, backTo),
},
TRANSACTION_DUPLICATE_REVIEW_DESCRIPTION_PAGE: {
route: 'r/:threadReportID/duplicates/review/description',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/description` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/description` as const, backTo),
},
TRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE: {
route: 'r/:threadReportID/duplicates/review/reimbursable',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/reimbursable` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/reimbursable` as const, backTo),
},
TRANSACTION_DUPLICATE_REVIEW_BILLABLE_PAGE: {
route: 'r/:threadReportID/duplicates/review/billable',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/review/billable` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review/billable` as const, backTo),
},
TRANSACTION_DUPLICATE_CONFIRMATION_PAGE: {
route: 'r/:threadReportID/duplicates/confirm',
getRoute: (threadReportID: string) => `r/${threadReportID}/duplicates/confirm` as const,
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/confirm` as const, backTo),
},
POLICY_ACCOUNTING_XERO_IMPORT: {
route: 'settings/workspaces/:policyID/accounting/xero/import',
Expand Down
11 changes: 8 additions & 3 deletions src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ function AvatarWithDisplayName({
actorAccountID.current = parentReportAction?.actorAccountID ?? -1;
}, [parentReportActions, report]);

const goToDetailsPage = useCallback(() => {
ReportUtils.navigateToDetailsPage(report, Navigation.getReportRHPActiveRoute());
}, [report]);

const showActorDetails = useCallback(() => {
// We should navigate to the details page if the report is a IOU/expense report
if (shouldEnableDetailPageNavigation) {
return ReportUtils.navigateToDetailsPage(report);
goToDetailsPage();
return;
}

if (ReportUtils.isExpenseReport(report) && report?.ownerAccountID) {
Expand All @@ -107,7 +112,7 @@ function AvatarWithDisplayName({
// Report detail route is added as fallback but based on the current implementation this route won't be executed
Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID));
}
}, [report, shouldEnableDetailPageNavigation]);
}, [report, shouldEnableDetailPageNavigation, goToDetailsPage]);

const headerView = (
<View style={[styles.appContentHeaderTitle, styles.flex1]}>
Expand Down Expand Up @@ -172,7 +177,7 @@ function AvatarWithDisplayName({

return (
<PressableWithoutFeedback
onPress={() => ReportUtils.navigateToDetailsPage(report)}
onPress={goToDetailsPage}
style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}
accessibilityLabel={title}
role={CONST.ROLE.BUTTON}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
accountID = parseInt(htmlAttribAccountID, 10);
mentionDisplayText = LocalePhoneNumber.formatPhoneNumber(user?.login ?? '') || PersonalDetailsUtils.getDisplayNameOrDefault(user);
mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, user?.login ?? '');
navigationRoute = ROUTES.PROFILE.getRoute(htmlAttribAccountID);
navigationRoute = ROUTES.PROFILE.getRoute(htmlAttribAccountID, Navigation.getReportRHPActiveRoute());
} else if ('data' in tnodeClone && !isEmptyObject(tnodeClone.data)) {
// We need to remove the LTR unicode and leading @ from data as it is not part of the login
mentionDisplayText = tnodeClone.data.replace(CONST.UNICODE.LTR, '').slice(1);
// We need to replace tnode.data here because we will pass it to TNodeChildrenRenderer below
asMutable(tnodeClone).data = tnodeClone.data.replace(mentionDisplayText, Str.removeSMSDomain(getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID)));

accountID = PersonalDetailsUtils.getAccountIDsByLogins([mentionDisplayText])?.[0];
navigationRoute = ROUTES.PROFILE.getRoute(accountID, undefined, mentionDisplayText);
navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute(), mentionDisplayText);
mentionDisplayText = Str.removeSMSDomain(mentionDisplayText);
} else {
// If neither an account ID or email is provided, don't render anything
Expand All @@ -94,7 +94,11 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
}}
onPress={(event) => {
event.preventDefault();
Navigation.navigate(navigationRoute);
if (!isEmpty(htmlAttribAccountID)) {
Navigation.navigate(ROUTES.PROFILE.getRoute(htmlAttribAccountID, Navigation.getReportRHPActiveRoute()));
return;
}
Navigation.navigate(ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute(), mentionDisplayText));
}}
role={CONST.ROLE.LINK}
accessibilityLabel={`/${navigationRoute}`}
Expand Down
Loading

0 comments on commit a8e95b9

Please sign in to comment.