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

Refactor ReportActionItem to use hooks #18809

Merged
merged 50 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2e6b8e6
add back ReportActionItem
jasperhuangg May 12, 2023
c6304ee
add back ReportActionItemMessageEdit and refPropTypes
jasperhuangg May 12, 2023
29ac1a9
add back pressableWithSecondaryInteraction
jasperhuangg May 12, 2023
2f92de6
fix merge conflicts
jasperhuangg May 16, 2023
845a86b
merge main
jasperhuangg May 16, 2023
1eaf072
fix console warnings
jasperhuangg May 16, 2023
c49dff8
wip
jasperhuangg May 17, 2023
d633aad
merge main
jasperhuangg May 17, 2023
5b862a3
fix long press to pull up context menu
jasperhuangg May 17, 2023
666995b
remove unused
jasperhuangg May 17, 2023
dc04b9f
Merge branch 'main' into jasper-refactorReportActionItemHooks1
jasperhuangg May 17, 2023
0b01e76
remove weird stuff from merge
jasperhuangg May 17, 2023
b925ee1
Update src/pages/home/report/ReportActionItem.js
jasperhuangg May 18, 2023
a61a258
Update src/pages/home/report/ReportActionItem.js
jasperhuangg May 18, 2023
1abb820
add hasOutstandingIOU into proptypes
jasperhuangg May 18, 2023
a16830f
Merge branch 'jasper-refactorReportActionItemHooks1' of github.com:Ex…
jasperhuangg May 18, 2023
891495a
fix typo
jasperhuangg May 18, 2023
41b5cd6
Update src/pages/home/report/ReportActionItem.js
jasperhuangg May 18, 2023
1430ac0
default prop types
jasperhuangg May 18, 2023
19d3495
conflicts
jasperhuangg May 18, 2023
3c6dc29
Merge branch 'main' of github.com:Expensify/App into jasper-refactorR…
jasperhuangg May 18, 2023
25a09b7
fix right click
jasperhuangg May 18, 2023
575c306
remove unused line break
jasperhuangg May 18, 2023
5617258
typo
jasperhuangg May 18, 2023
cccebb8
Update src/components/PressableWithSecondaryInteraction/index.js
jasperhuangg May 19, 2023
49dff2b
Update src/components/PressableWithSecondaryInteraction/index.js
jasperhuangg May 19, 2023
c5b6350
Fix proptypes errors
jasperhuangg May 19, 2023
a73f05e
Merge branch 'jasper-refactorReportActionItemHooks1' of github.com:Ex…
jasperhuangg May 19, 2023
d7bcce7
Merge branch 'main' of github.com:Expensify/App into jasper-refactorR…
jasperhuangg May 19, 2023
99dd319
resolve merge conflicts
jasperhuangg May 19, 2023
7f326f1
fix error passing ref into tooltips
jasperhuangg May 19, 2023
7620f3a
remove unused
jasperhuangg May 19, 2023
852f7bc
consolidate logic
jasperhuangg May 19, 2023
8a9b271
fix condition
jasperhuangg May 19, 2023
d95494a
consolidate logic
jasperhuangg May 19, 2023
155ead3
resolve conflicts
jasperhuangg May 19, 2023
4a35a5a
prettier
jasperhuangg May 21, 2023
3a6dfe5
Merge branch 'main' of github.com:Expensify/App into jasper-refactorR…
jasperhuangg May 21, 2023
de7f990
use _.contains to simplify condition
jasperhuangg May 21, 2023
c52ac84
apply changes from #18523
jasperhuangg May 21, 2023
8a5cb7e
Update src/styles/getTooltipStyles.js
jasperhuangg May 21, 2023
78fecb9
use lodashGet
jasperhuangg May 21, 2023
e3367d2
fix merge conflict
jasperhuangg May 21, 2023
eb17e6a
change back to conditional logic
jasperhuangg May 21, 2023
11a9021
check tooltip.current first, in case tooltip.contains doesn't exist
jasperhuangg May 21, 2023
54c7a12
simplify logic with variable
jasperhuangg May 21, 2023
a98c97d
Update src/styles/getTooltipStyles.js
jasperhuangg May 21, 2023
992a4b6
Update src/styles/getTooltipStyles.js
jasperhuangg May 21, 2023
42c8ea7
merge main
jasperhuangg May 22, 2023
77c9d55
Merge branch 'jasper-refactorReportActionItemHooks1' of github.com:Ex…
jasperhuangg May 22, 2023
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
8 changes: 6 additions & 2 deletions src/components/PressableWithSecondaryInteraction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ class PressableWithSecondaryInteraction extends Component {
}

componentDidMount() {
if (this.props.forwardedRef && _.isFunction(this.props.forwardedRef)) {
this.props.forwardedRef(this.pressableRef);
if (this.props.forwardedRef) {
if (_.isFunction(this.props.forwardedRef)) {
this.props.forwardedRef(this.pressableRef);
} else if (_.isObject(this.props.forwardedRef)) {
this.props.forwardedRef.current = this.pressableRef;
}
}
this.pressableRef.addEventListener('contextmenu', this.executeSecondaryInteractionOnContextMenu);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PropTypes from 'prop-types';
import refPropTypes from '../refPropTypes';
import stylePropTypes from '../../styles/stylePropTypes';

const propTypes = {
Expand All @@ -18,7 +19,7 @@ const propTypes = {
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,

/** The ref to the search input (may be null on small screen widths) */
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
forwardedRef: refPropTypes,

/** Prevent the default ContextMenu on web/Desktop */
preventDefaultContextMenu: PropTypes.bool,
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/IOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import * as OptionsListUtils from '../../libs/OptionsListUtils';
import * as CurrencyUtils from '../../libs/CurrencyUtils';
import * as IOUUtils from '../../libs/IOUUtils';
import * as ReportUtils from '../../libs/ReportUtils';
import refPropTypes from '../refPropTypes';

const propTypes = {
/** The active IOUReport, used for Onyx subscription */
Expand All @@ -43,7 +44,7 @@ const propTypes = {
action: PropTypes.shape(reportActionPropTypes),

/** Popover context menu anchor, used for showing context menu */
contextMenuAnchor: PropTypes.shape({current: PropTypes.elementType}),
contextMenuAnchor: refPropTypes,

/** Callback for updating context menu active state, used for showing context menu */
checkIfContextMenuActive: PropTypes.func,
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/MoneyRequestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as ReportUtils from '../../libs/ReportUtils';
import * as Report from '../../libs/actions/Report';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import * as ReportActionsUtils from '../../libs/ReportActionsUtils';
import refPropTypes from '../refPropTypes';

const propTypes = {
/** All the data of the action */
Expand All @@ -35,7 +36,7 @@ const propTypes = {
isMostRecentIOUReportAction: PropTypes.bool.isRequired,

/** Popover context menu anchor, used for showing context menu */
contextMenuAnchor: PropTypes.shape({current: PropTypes.elementType}),
contextMenuAnchor: refPropTypes,

/** Callback for updating context menu active state, used for showing context menu */
checkIfContextMenuActive: PropTypes.func,
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/ReportPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import SettlementButton from '../SettlementButton';
import themeColors from '../../styles/themes/default';
import getButtonState from '../../libs/getButtonState';
import * as IOU from '../../libs/actions/IOU';
import refPropTypes from '../refPropTypes';

const propTypes = {
/** All the data of the action */
Expand Down Expand Up @@ -71,7 +72,7 @@ const propTypes = {
}),

/** Popover context menu anchor, used for showing context menu */
contextMenuAnchor: PropTypes.shape({current: PropTypes.elementType}),
contextMenuAnchor: refPropTypes,

/** Callback for updating context menu active state, used for showing context menu */
checkIfContextMenuActive: PropTypes.func,
Expand Down
3 changes: 3 additions & 0 deletions src/components/refPropTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PropTypes from 'prop-types';

export default PropTypes.oneOfType([PropTypes.func, PropTypes.object]);
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class PopoverReportActionContextMenu extends React.Component {
getContextMenuMeasuredLocation() {
return new Promise((resolve) => {
if (this.contextMenuAnchor) {
this.contextMenuAnchor.measureInWindow((x, y) => resolve({x, y}));
this.contextMenuAnchor.current.measureInWindow((x, y) => resolve({x, y}));
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
} else {
resolve({x: 0, y: 0});
}
Expand Down
Loading
Loading