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

[No QA] Cleanup and organize routes #28050

Merged
merged 9 commits into from
Sep 25, 2023
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
343 changes: 133 additions & 210 deletions src/ROUTES.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ function AttachmentModal(props) {
icon: Expensicons.Camera,
text: props.translate('common.replace'),
onSelected: () => {
onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT));
onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT));
closeModal();
},
},
Expand Down
8 changes: 4 additions & 4 deletions src/components/AvatarWithDisplayName.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ const defaultProps = {

const showActorDetails = (report) => {
if (ReportUtils.isExpenseReport(report)) {
Navigation.navigate(ROUTES.getProfileRoute(report.ownerAccountID));
Navigation.navigate(ROUTES.PROFILE.getRoute(report.ownerAccountID));
return;
}

if (ReportUtils.isIOUReport(report)) {
Navigation.navigate(ROUTES.getReportParticipantsRoute(report.reportID));
Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(report.reportID));
return;
}

Expand All @@ -71,13 +71,13 @@ const showActorDetails = (report) => {
const actorAccountID = lodashGet(parentReportAction, 'actorAccountID', -1);
// in an ideal situation account ID won't be 0
if (actorAccountID > 0) {
Navigation.navigate(ROUTES.getProfileRoute(actorAccountID));
Navigation.navigate(ROUTES.PROFILE.getRoute(actorAccountID));
return;
}
}

// report detail route is added as fallback but based on the current implementation this route won't be executed
Navigation.navigate(ROUTES.getReportDetailsRoute(report.reportID));
Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID));
};

function AvatarWithDisplayName(props) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/DistanceRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken,
useEffect(updateGradientVisibility, [scrollContainerHeight, scrollContentHeight]);

const navigateBack = () => {
Navigation.goBack(isEditing ? ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID) : ROUTES.HOME);
Navigation.goBack(isEditing ? ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID) : ROUTES.HOME);
};

const navigateToNextPage = () => {
if (isEditing) {
Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID));
Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID));
return;
}

Expand Down Expand Up @@ -237,7 +237,7 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken,
secondaryIcon={waypointIcon}
secondaryIconFill={theme.icon}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.getMoneyRequestWaypointRoute('request', index))}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_WAYPOINT.getRoute('request', index))}
key={key}
/>
);
Expand All @@ -263,7 +263,7 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken,
icon={Expensicons.Plus}
onPress={() => {
const newIndex = _.size(lodashGet(transaction, 'comment.waypoints', {}));
Navigation.navigate(ROUTES.getMoneyRequestWaypointRoute('request', newIndex));
Navigation.navigate(ROUTES.MONEY_REQUEST_WAYPOINT.getRoute('request', newIndex));
}}
text={translate('distance.addStop')}
isDisabled={numberOfWaypoints === MAX_WAYPOINTS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function AnchorRenderer(props) {
// the reportID is extracted from the URL and then opened as an internal link, taking the user straight to the chat in the same tab.
if (hasExpensifyOrigin && attrHref.indexOf('newdotreport?reportID=') > -1) {
const reportID = attrHref.split('newdotreport?reportID=').pop();
const reportRoute = ROUTES.getReportRoute(reportID);
const reportRoute = ROUTES.REPORT_WITH_ID.getRoute(reportID);
Navigation.navigate(reportRoute);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function ImageRenderer(props) {
<PressableWithoutFocus
style={[styles.noOutline]}
onPress={() => {
const route = ROUTES.getReportAttachmentRoute(report.reportID, source);
const route = ROUTES.REPORT_ATTACHMENTS.getRoute(report.reportID, source);
Navigation.navigate(route);
}}
onLongPress={(event) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ function MentionUserRenderer(props) {
const user = lodashGet(props.personalDetails, htmlAttribAccountID);
accountID = parseInt(htmlAttribAccountID, 10);
displayNameOrLogin = lodashGet(user, 'login', '') || lodashGet(user, 'displayName', '') || translate('common.hidden');
navigationRoute = ROUTES.getProfileRoute(htmlAttribAccountID);
navigationRoute = ROUTES.PROFILE.getRoute(htmlAttribAccountID);
} else if (!_.isEmpty(props.tnode.data)) {
// We need to remove the LTR unicode and leading @ from data as it is not part of the login
displayNameOrLogin = props.tnode.data.replace(CONST.UNICODE.LTR, '').slice(1);

accountID = _.first(PersonalDetailsUtils.getAccountIDsByLogins([displayNameOrLogin]));
navigationRoute = ROUTES.getDetailsRoute(displayNameOrLogin);
navigationRoute = ROUTES.DETAILS.getRoute(displayNameOrLogin);
} else {
// If neither an account ID or email is provided, don't render anything
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderWithBackButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function HeaderWithBackButton({
{shouldShowGetAssistanceButton && (
<Tooltip text={translate('getAssistancePage.questionMarkButtonTooltip')}>
<PressableWithoutFeedback
onPress={() => Navigation.navigate(ROUTES.getGetAssistanceRoute(guidesCallTaskID))}
onPress={() => Navigation.navigate(ROUTES.GET_ASSISTANCE.getRoute(guidesCallTaskID))}
style={[styles.touchableButtonImage]}
accessibilityRole="button"
accessibilityLabel={translate('getAssistancePage.questionMarkButtonTooltip')}
Expand Down
18 changes: 9 additions & 9 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ function MoneyRequestConfirmationList(props) {
if (option.accountID) {
const activeRoute = Navigation.getActiveRoute().replace(/\?.*/, '');

Navigation.navigate(ROUTES.getProfileRoute(option.accountID, activeRoute));
Navigation.navigate(ROUTES.PROFILE.getRoute(option.accountID, activeRoute));
} else if (option.reportID) {
Navigation.navigate(ROUTES.getReportDetailsRoute(option.reportID));
Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(option.reportID));
}
};

Expand Down Expand Up @@ -463,7 +463,7 @@ function MoneyRequestConfirmationList(props) {
shouldShowRightIcon={!props.isReadOnly && !props.isDistanceRequest}
title={formattedAmount}
description={translate('iou.amount')}
onPress={() => !props.isDistanceRequest && Navigation.navigate(ROUTES.getMoneyRequestAmountRoute(props.iouType, props.reportID))}
onPress={() => !props.isDistanceRequest && Navigation.navigate(ROUTES.MONEY_REQUEST_AMOUNT.getRoute(props.iouType, props.reportID))}
style={[styles.moneyRequestMenuItem, styles.mt2]}
titleStyle={styles.moneyRequestConfirmationAmount}
disabled={didConfirm || props.isReadOnly}
Expand All @@ -474,7 +474,7 @@ function MoneyRequestConfirmationList(props) {
shouldParseTitle
title={props.iouComment}
description={translate('common.description')}
onPress={() => Navigation.navigate(ROUTES.getMoneyRequestDescriptionRoute(props.iouType, props.reportID))}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_DESCRIPTION.getRoute(props.iouType, props.reportID))}
style={[styles.moneyRequestMenuItem, styles.mb2]}
titleStyle={styles.flex1}
disabled={didConfirm || props.isReadOnly}
Expand Down Expand Up @@ -503,7 +503,7 @@ function MoneyRequestConfirmationList(props) {
description={translate('common.date')}
style={[styles.moneyRequestMenuItem, styles.mb2]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.getMoneyRequestCreatedRoute(props.iouType, props.reportID))}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_DATE.getRoute(props.iouType, props.reportID))}
disabled={didConfirm || props.isReadOnly || !isTypeRequest}
/>
{props.isDistanceRequest ? (
Expand All @@ -513,7 +513,7 @@ function MoneyRequestConfirmationList(props) {
description={translate('common.distance')}
style={[styles.moneyRequestMenuItem, styles.mb2]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.getMoneyRequestAddressRoute(props.iouType, props.reportID))}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_ADDRESS.getRoute(props.iouType, props.reportID))}
disabled={didConfirm || props.isReadOnly || !isTypeRequest}
/>
) : (
Expand All @@ -523,7 +523,7 @@ function MoneyRequestConfirmationList(props) {
description={translate('common.merchant')}
style={[styles.moneyRequestMenuItem, styles.mb2]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.getMoneyRequestMerchantRoute(props.iouType, props.reportID))}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_MERCHANT.getRoute(props.iouType, props.reportID))}
disabled={didConfirm || props.isReadOnly || !isTypeRequest}
/>
)}
Expand All @@ -532,7 +532,7 @@ function MoneyRequestConfirmationList(props) {
shouldShowRightIcon={!props.isReadOnly}
title={props.iouCategory}
description={translate('common.category')}
onPress={() => Navigation.navigate(ROUTES.getMoneyRequestCategoryRoute(props.iouType, props.reportID))}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_CATEGORY.getRoute(props.iouType, props.reportID))}
style={[styles.moneyRequestMenuItem, styles.mb2]}
disabled={didConfirm || props.isReadOnly}
/>
Expand All @@ -542,7 +542,7 @@ function MoneyRequestConfirmationList(props) {
shouldShowRightIcon={!props.isReadOnly}
title={props.iouTag}
description={tagListName || translate('common.tag')}
onPress={() => Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID))}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID))}
style={[styles.moneyRequestMenuItem, styles.mb2]}
disabled={didConfirm || props.isReadOnly}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ParentNavigationSubtitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function ParentNavigationSubtitle(props) {
return (
<PressableWithoutFeedback
onPress={() => {
Navigation.navigate(ROUTES.getReportRoute(props.parentReportID));
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.parentReportID));
}}
accessibilityLabel={translate('threads.parentNavigationSummary', {rootReportName, workspaceName})}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.LINK}
Expand Down
6 changes: 3 additions & 3 deletions src/components/ReportActionItem/MoneyRequestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function MoneyRequestAction({
const onMoneyRequestPreviewPressed = () => {
if (isSplitBillAction) {
const reportActionID = lodashGet(action, 'reportActionID', '0');
Navigation.navigate(ROUTES.getSplitBillDetailsRoute(chatReportID, reportActionID));
Navigation.navigate(ROUTES.SPLIT_BILL_DETAILS.getRoute(chatReportID, reportActionID));
return;
}

Expand All @@ -108,11 +108,11 @@ function MoneyRequestAction({
const thread = ReportUtils.buildTransactionThread(action, requestReportID);
const userLogins = PersonalDetailsUtils.getLoginsByAccountIDs(thread.participantAccountIDs);
Report.openReport(thread.reportID, userLogins, thread, action.reportActionID);
Navigation.navigate(ROUTES.getReportRoute(thread.reportID));
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(thread.reportID));
return;
}
Report.openReport(childReportID);
Navigation.navigate(ROUTES.getReportRoute(childReportID));
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID));
};

let shouldShowPendingConversionMessage = false;
Expand Down
10 changes: 5 additions & 5 deletions src/components/ReportActionItem/MoneyRequestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should
titleStyle={styles.newKansasLarge}
interactive={canEdit}
shouldShowRightIcon={canEdit}
onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.AMOUNT))}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.AMOUNT))}
brickRoadIndicator={hasErrors && transactionAmount === 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
subtitle={hasErrors && transactionAmount === 0 ? translate('common.error.enterAmount') : ''}
subtitleTextStyle={styles.textLabelError}
Expand All @@ -157,7 +157,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION))}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION))}
wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]}
numberOfLinesTitle={0}
/>
Expand All @@ -169,7 +169,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DATE))}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DATE))}
brickRoadIndicator={hasErrors && transactionDate === '' ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
subtitle={hasErrors && transactionDate === '' ? translate('common.error.enterDate') : ''}
subtitleTextStyle={styles.textLabelError}
Expand All @@ -182,7 +182,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.MERCHANT))}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.MERCHANT))}
brickRoadIndicator={hasErrors && isEmptyMerchant ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
subtitle={hasErrors && isEmptyMerchant ? translate('common.error.enterMerchant') : ''}
subtitleTextStyle={styles.textLabelError}
Expand All @@ -196,7 +196,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.CATEGORY))}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.CATEGORY))}
/>
</OfflineWithFeedback>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/ReportActionItemImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal}) {
<PressableWithoutFocus
style={[styles.noOutline, styles.w100, styles.h100]}
onPress={() => {
const route = ROUTES.getReportAttachmentRoute(report.reportID, imageSource);
const route = ROUTES.REPORT_ATTACHMENTS.getRoute(report.reportID, imageSource);
Navigation.navigate(route);
}}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/ReportPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function ReportPreview(props) {
<View style={[styles.chatItemMessage, ...props.containerStyles]}>
<PressableWithoutFeedback
onPress={() => {
Navigation.navigate(ROUTES.getReportRoute(props.iouReportID));
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.iouReportID));
}}
onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()}
onPressOut={() => ControlSelection.unblock()}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/TaskPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function TaskPreview(props) {
return (
<View style={[styles.chatItemMessage]}>
<PressableWithoutFeedback
onPress={() => Navigation.navigate(ROUTES.getReportRoute(props.taskReportID))}
onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.taskReportID))}
style={[styles.flexRow, styles.justifyContentBetween]}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
accessibilityLabel={props.translate('task.task')}
Expand Down
Loading
Loading