-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Search v1] Add ReportScreen to RHP #40570
Changes from 16 commits
796379f
997e19e
2243bb5
8993263
8650c30
d5af8be
0e07013
b29a5a7
32208d6
5469522
8c89050
a97e10b
eb3add3
a0c302b
4a07096
4fcb07c
ccb36e9
ae9fb91
a45ae4f
f5fbd15
5575b53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,9 +50,21 @@ type MoneyRequestHeaderProps = MoneyRequestHeaderOnyxProps & { | |
|
||
/** The report action the transaction is tied to from the parent report */ | ||
parentReportAction: OnyxEntry<ReportAction>; | ||
|
||
/** Whether we should display the header as in narrow layout */ | ||
shouldUseNarrowLayout?: boolean; | ||
}; | ||
|
||
function MoneyRequestHeader({session, parentReport, report, parentReportAction, transaction, shownHoldUseExplanation = false, policy}: MoneyRequestHeaderProps) { | ||
function MoneyRequestHeader({ | ||
session, | ||
parentReport, | ||
report, | ||
parentReportAction, | ||
transaction, | ||
shownHoldUseExplanation = false, | ||
policy, | ||
shouldUseNarrowLayout = false, | ||
}: MoneyRequestHeaderProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false); | ||
|
@@ -61,7 +73,7 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, | |
const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID); | ||
const isApproved = ReportUtils.isReportApproved(moneyRequestReport); | ||
const isOnHold = TransactionUtils.isOnHold(transaction); | ||
const {isSmallScreenWidth, windowWidth} = useWindowDimensions(); | ||
const {windowWidth} = useWindowDimensions(); | ||
|
||
// Only the requestor can take delete the expense, admins can only edit it. | ||
const isActionOwner = typeof parentReportAction?.actorAccountID === 'number' && typeof session?.accountID === 'number' && parentReportAction.actorAccountID === session?.accountID; | ||
|
@@ -144,14 +156,14 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, | |
return; | ||
} | ||
|
||
if (isSmallScreenWidth) { | ||
if (shouldUseNarrowLayout) { | ||
if (Navigation.getActiveRoute().slice(1) === ROUTES.PROCESS_MONEY_REQUEST_HOLD) { | ||
Navigation.goBack(); | ||
} | ||
} else { | ||
Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD); | ||
} | ||
}, [isSmallScreenWidth, shouldShowHoldMenu]); | ||
}, [shouldUseNarrowLayout, shouldShowHoldMenu]); | ||
|
||
const handleHoldRequestClose = () => { | ||
IOU.setShownHoldUseExplanation(); | ||
|
@@ -180,7 +192,7 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, | |
ownerAccountID: parentReport?.ownerAccountID, | ||
}} | ||
policy={policy} | ||
shouldShowBackButton={isSmallScreenWidth} | ||
shouldShowBackButton={shouldUseNarrowLayout} | ||
onBackButtonPress={() => Navigation.goBack(undefined, false, true)} | ||
/> | ||
{isPending && ( | ||
|
@@ -209,7 +221,7 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, | |
cancelText={translate('common.cancel')} | ||
danger | ||
/> | ||
{isSmallScreenWidth && shouldShowHoldMenu && ( | ||
{shouldUseNarrowLayout && shouldShowHoldMenu && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ProcessMoneyRequestHoldMenu is to be shown for small screen devices. However, since |
||
<ProcessMoneyRequestHoldMenu | ||
onClose={handleHoldRequestClose} | ||
onConfirm={handleHoldRequestClose} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type {NavigationState, PartialState} from '@react-navigation/native'; | ||
|
||
// Get the name of topmost route in the navigation stack. | ||
function getTopmostRouteName(state: NavigationState | PartialState<NavigationState>): string | undefined { | ||
if (!state) { | ||
return; | ||
} | ||
|
||
return state.routes.at(-1)?.name; | ||
} | ||
|
||
export default getTopmostRouteName; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -960,7 +960,7 @@ function deleteTask(report: OnyxEntry<OnyxTypes.Report>) { | |
* Closes the current open task modal and clears out the task info from the store. | ||
*/ | ||
function dismissModalAndClearOutTaskInfo() { | ||
Navigation.dismissModal(); | ||
Navigation.goBack(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's the same. Could you elaborate on why did you make a change here to ensure it won't cause any regression bugs? |
||
clearOutTaskInfo(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing the
shouldUseNarrowLayout
value asisSmallScreenWidth
will stretch the confirmation modal in the web. We should not have changed theisSmallScreenWidth
value, as this change caused the issue #45002