-
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
Merged
luacmartins
merged 21 commits into
Expensify:main
from
software-mansion-labs:search-v1/rhp-report
Apr 25, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
796379f
Add ReportScreen to RHP
WojtekBoman 997e19e
Add shouldUseNarrowLayout prop to report header components
WojtekBoman 2243bb5
Adjust position of PopoverMenu in ReportScreen displayed in RHP
WojtekBoman 8993263
Merge branch 'main' into search-v1/rhp-report
WojtekBoman 8650c30
Add useIsNarrowLayout hook
WojtekBoman d5af8be
Fix perf tests
WojtekBoman 0e07013
Merge branch 'main' into search-v1/rhp-report
WojtekBoman b29a5a7
Fix navigating back from RHP screens
WojtekBoman 32208d6
Run prettier
WojtekBoman 5469522
Handle deleting reportID param from search central pane page
WojtekBoman 8c89050
Refactor AttachmentPickerWithMenuItems
WojtekBoman a97e10b
Refactor useIsNarrowLayout, add adjustments to ReportScreen in RHP
WojtekBoman eb3add3
Add checking shouldUseNarrowLayout
WojtekBoman a0c302b
Run prettier
WojtekBoman 4a07096
Refactor getAdaptedStateFromPath, fix perf tests
WojtekBoman 4fcb07c
Fix lint
WojtekBoman ccb36e9
Refactor FullPageNotFoundView in ReportScreen
WojtekBoman ae9fb91
Add closeRHPFlow function to Navigation
WojtekBoman a45ae4f
Refactor closeRHPFlow
WojtekBoman f5fbd15
Add useIsReportOpenInRHP
WojtekBoman 5575b53
Fix perf tests
WojtekBoman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {useNavigationState} from '@react-navigation/native'; | ||
import getTopmostRouteName from '@libs/Navigation/getTopmostRouteName'; | ||
import SCREENS from '@src/SCREENS'; | ||
|
||
// This hook checks if the currently open route is ReportScreen in RHP. | ||
export default function useIsReportOpenInRHP() { | ||
const activeRoute = useNavigationState(getTopmostRouteName); | ||
return activeRoute === SCREENS.SEARCH.REPORT_RHP; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type {NavigationContainerRef} from '@react-navigation/native'; | ||
import {StackActions} from '@react-navigation/native'; | ||
import Log from '@libs/Log'; | ||
import NAVIGATORS from '@src/NAVIGATORS'; | ||
import type {RootStackParamList} from './types'; | ||
|
||
/** | ||
* Closes the last RHP flow, if there is only one, closes the entire RHP. | ||
*/ | ||
export default function closeRHPFlow(navigationRef: NavigationContainerRef<RootStackParamList>) { | ||
if (!navigationRef.isReady()) { | ||
return; | ||
} | ||
const state = navigationRef.getState(); | ||
const lastRoute = state.routes.at(-1); | ||
const isLastRouteRHP = lastRoute?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR; | ||
|
||
if (!isLastRouteRHP) { | ||
Log.warn('RHP Navigator has not been found when calling closeRHPFlow function'); | ||
return; | ||
} | ||
|
||
let target = state.key; | ||
|
||
const hasMoreThanOneRoute = lastRoute?.state?.routes?.length && lastRoute.state.routes.length > 1; | ||
if (lastRoute?.state?.key && hasMoreThanOneRoute) { | ||
target = lastRoute.state.key; | ||
} | ||
navigationRef.dispatch({...StackActions.pop(), target}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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