-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Remove data from being sideloaded in the money request header #27286
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0102215
Mark methods as deprecated
tgolen 4a9d6f6
Fetch objects using withOnyx
tgolen a662d31
Merge branch 'main' into tgolen-remove-sideloading0
tgolen 96f46d3
Fix some issues with props loading
tgolen db642ba
Remove optional chaining
tgolen 0f2cfbf
Make lint warning go away
tgolen 3b14e96
Try to fix props dependency
tgolen 361c107
Remove references to props
tgolen 9aececd
Merge branch 'main' into tgolen-remove-sideloading0
tgolen 286adad
Merge branch 'main' into tgolen-remove-sideloading0
tgolen fdcc04b
Merge branch 'main' into tgolen-remove-sideloading0
tgolen 981f293
Fix lint and use hook for dimensions
tgolen 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import useLocalize from '../hooks/useLocalize'; | |
import MoneyRequestHeaderStatusBar from './MoneyRequestHeaderStatusBar'; | ||
import * as TransactionUtils from '../libs/TransactionUtils'; | ||
import reportActionPropTypes from '../pages/home/report/reportActionPropTypes'; | ||
import transactionPropTypes from './transactionPropTypes'; | ||
|
||
const propTypes = { | ||
/** The report currently being looked at */ | ||
|
@@ -34,7 +35,9 @@ const propTypes = { | |
/** Personal details so we can get the ones for the report participants */ | ||
personalDetails: PropTypes.objectOf(participantPropTypes).isRequired, | ||
|
||
/** Onyx Props */ | ||
...windowDimensionsPropTypes, | ||
|
||
/* Onyx Props */ | ||
/** Session info for the currently logged in user. */ | ||
session: PropTypes.shape({ | ||
/** Currently logged in user email */ | ||
|
@@ -47,11 +50,8 @@ const propTypes = { | |
/** The report action the transaction is tied to from the parent report */ | ||
parentReportAction: PropTypes.shape(reportActionPropTypes), | ||
|
||
/** The transaction from the parent report action */ | ||
transaction: PropTypes.shape({ | ||
/** The ID of the transaction */ | ||
transactionID: PropTypes.string, | ||
}), | ||
/** All the data for the transaction */ | ||
transaction: transactionPropTypes, | ||
|
||
...windowDimensionsPropTypes, | ||
}; | ||
|
@@ -65,24 +65,24 @@ const defaultProps = { | |
transaction: {}, | ||
}; | ||
|
||
function MoneyRequestHeader(props) { | ||
function MoneyRequestHeader({session, parentReport, report, parentReportAction, transaction, policy, personalDetails, isSmallScreenWidth, windowWidth}) { | ||
const {translate} = useLocalize(); | ||
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false); | ||
const moneyRequestReport = props.parentReport; | ||
const moneyRequestReport = parentReport; | ||
const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID); | ||
|
||
// Only the requestor can take delete the request, admins can only edit it. | ||
const isActionOwner = props.parentReportAction.actorAccountID === lodashGet(props.session, 'accountID', null); | ||
const isActionOwner = lodashGet(parentReportAction, 'actorAccountID') === lodashGet(session, 'accountID', null); | ||
const report = props.report; | ||
report.ownerAccountID = lodashGet(props, ['parentReport', 'ownerAccountID'], null); | ||
report.ownerEmail = lodashGet(props, ['parentReport', 'ownerEmail'], ''); | ||
|
||
const deleteTransaction = useCallback(() => { | ||
IOU.deleteMoneyRequest(props.parentReportAction.originalMessage.IOUTransactionID, props.parentReportAction, true); | ||
IOU.deleteMoneyRequest(lodashGet(parentReportAction, 'originalMessage.IOUTransactionID'), parentReportAction, true); | ||
setIsDeleteModalVisible(false); | ||
}, [props.parentReportAction, setIsDeleteModalVisible]); | ||
}, [parentReportAction, setIsDeleteModalVisible]); | ||
|
||
const isScanning = TransactionUtils.hasReceipt(props.transaction) && TransactionUtils.isReceiptBeingScanned(props.transaction); | ||
const isScanning = TransactionUtils.hasReceipt(transaction) && TransactionUtils.isReceiptBeingScanned(transaction); | ||
|
||
return ( | ||
<> | ||
|
@@ -98,11 +98,15 @@ function MoneyRequestHeader(props) { | |
onSelected: () => setIsDeleteModalVisible(true), | ||
}, | ||
]} | ||
threeDotsAnchorPosition={styles.threeDotsPopoverOffsetNoCloseButton(props.windowWidth)} | ||
report={report} | ||
policy={props.policy} | ||
personalDetails={props.personalDetails} | ||
shouldShowBackButton={props.isSmallScreenWidth} | ||
threeDotsAnchorPosition={styles.threeDotsPopoverOffsetNoCloseButton(windowWidth)} | ||
report={{ | ||
...report, | ||
ownerAccountID: lodashGet(parentReport, 'ownerAccountID', null), | ||
ownerEmail: lodashGet(parentReport, 'ownerEmail', null), | ||
}} | ||
policy={policy} | ||
personalDetails={personalDetails} | ||
shouldShowBackButton={isSmallScreenWidth} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.HOME, false, true)} | ||
/> | ||
{isScanning && <MoneyRequestHeaderStatusBar />} | ||
|
@@ -140,8 +144,7 @@ export default compose( | |
canEvict: false, | ||
}, | ||
transaction: { | ||
key: ({report, parentReportActions}) => | ||
`${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportActions, [report.parentReportActionID, 'originalMessage', 'IOUTransactionID'], '')}`, | ||
key: ({parentReportAction}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', 0)}`, | ||
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. Good catch! 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. Yes! I spotted that and wanted to fix it here. |
||
}, | ||
}), | ||
)(MoneyRequestHeader); |
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.
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.
As this is function component, let's use
useWindowDimensions
hook