Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backTo to many pages so it shows the correct screen below the RHP overlay #47990

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d1fd086
add backTo to many pages so it shows the correct screen below the RHP…
bernhardoj Aug 26, 2024
549bafa
add more backTo to currency page
bernhardoj Aug 26, 2024
61177b5
lint
bernhardoj Aug 26, 2024
caea4ae
remove unused import
bernhardoj Aug 26, 2024
a27aeee
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Aug 27, 2024
5530ac7
use const
bernhardoj Aug 27, 2024
74e4de7
prettier
bernhardoj Aug 27, 2024
dac49f3
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Aug 29, 2024
e0ee34f
null safety
bernhardoj Aug 29, 2024
de211c1
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Aug 31, 2024
4317aaa
add and update backTo
bernhardoj Aug 31, 2024
7a8bf3a
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Sep 5, 2024
56b4de1
add backTo to flag comment page
bernhardoj Sep 5, 2024
2844291
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Sep 9, 2024
d7b8229
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Sep 10, 2024
6d25227
add more backTo to many pages
bernhardoj Sep 10, 2024
86b83ca
fix react compiler
bernhardoj Sep 10, 2024
bb876e6
merged with main
bernhardoj Sep 13, 2024
8ad27c9
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Sep 18, 2024
7dfd657
use const
bernhardoj Sep 18, 2024
2f73622
go back if no changes needed
bernhardoj Sep 18, 2024
fe0a987
early return inside the update function
bernhardoj Sep 18, 2024
16cd1fe
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Sep 19, 2024
321cdd6
Merge branch 'main' into fix/46773-add-backto-to-many-pages
bernhardoj Sep 20, 2024
9cf4eb6
fix broken hold modal is shown
bernhardoj Sep 20, 2024
77a3e07
fix infinite back loop
bernhardoj Sep 20, 2024
99406bd
revert changes that was used for testing only
bernhardoj Sep 20, 2024
04f1078
fix incorrect backTo
bernhardoj Sep 23, 2024
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
44 changes: 31 additions & 13 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,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 @@ -278,7 +278,7 @@ 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',
Expand All @@ -302,7 +302,7 @@ const ROUTES = {
},
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',
Expand Down Expand Up @@ -377,9 +377,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 @@ -508,12 +508,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 @@ -969,7 +984,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
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
4 changes: 2 additions & 2 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
}

if (isSmallScreenWidth) {
if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD) {
if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD.route) {
Navigation.goBack();
}
} else {
Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD);
Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD.getRoute(Navigation.getReportRHPActiveRoute()));
}
}, [isSmallScreenWidth, shouldShowHoldMenu]);

Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyRequestConfirmationListFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function MoneyRequestConfirmationListFooter({
return;
}

Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()));
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, 'confirm', Navigation.getActiveRouteWithoutParams()));
luacmartins marked this conversation as resolved.
Show resolved Hide resolved
}}
style={[styles.moneyRequestMenuItem, styles.mt2]}
titleStyle={styles.moneyRequestConfirmationAmount}
Expand Down
4 changes: 2 additions & 2 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow
}

if (isSmallScreenWidth) {
if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD) {
if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD.route) {
Navigation.goBack();
}
} else {
Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD);
Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD.getRoute(Navigation.getReportRHPActiveRoute()));
}
}, [isSmallScreenWidth, shouldShowHoldMenu]);

Expand Down
8 changes: 5 additions & 3 deletions src/components/PromotedActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ type PromotedAction = {
key: string;
} & ThreeDotsMenuItem;

type BasePromotedActions = typeof CONST.PROMOTED_ACTIONS.PIN | typeof CONST.PROMOTED_ACTIONS.SHARE | typeof CONST.PROMOTED_ACTIONS.JOIN;
type BasePromotedActions = typeof CONST.PROMOTED_ACTIONS.PIN | typeof CONST.PROMOTED_ACTIONS.JOIN;

type PromotedActionsType = Record<BasePromotedActions, (report: OnyxReport) => PromotedAction> & {
share: (report: OnyxReport, backTo?: string) => PromotedAction;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
share: (report: OnyxReport, backTo?: string) => PromotedAction;
CONST.PROMOTED_ACTIONS.SHARE: (report: OnyxReport, backTo?: string) => PromotedAction;

} & {
message: (params: {reportID?: string; accountID?: number; login?: string}) => PromotedAction;
} & {
hold: (params: {isTextHold: boolean; reportAction: ReportAction | undefined; reportID?: string}) => PromotedAction;
Expand All @@ -37,9 +39,9 @@ const PromotedActions = {
key: CONST.PROMOTED_ACTIONS.PIN,
...HeaderUtils.getPinMenuItem(report),
}),
share: (report) => ({
share: (report, backTo) => ({
key: CONST.PROMOTED_ACTIONS.SHARE,
...HeaderUtils.getShareMenuItem(report),
...HeaderUtils.getShareMenuItem(report, backTo),
}),
join: (report) => ({
key: CONST.PROMOTED_ACTIONS.JOIN,
Expand Down
11 changes: 10 additions & 1 deletion src/components/ReportActionItem/MoneyReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,16 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo
<MenuItemWithTopDescription
description={Str.UCFirst(reportField.name)}
title={fieldValue}
onPress={() => Navigation.navigate(ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute(report.reportID, report.policyID ?? '-1', reportField.fieldID))}
onPress={() =>
Navigation.navigate(
ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute(
report.reportID,
report.policyID ?? '-1',
reportField.fieldID,
Navigation.getReportRHPActiveRoute(),
),
)
}
shouldShowRightIcon
disabled={isFieldDisabled}
wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]}
Expand Down
Loading
Loading