From 68a36ae62a725eb4fc5ae4687397b297c5f3fe36 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Fri, 21 Jul 2023 15:52:39 -0600 Subject: [PATCH 1/9] Add longPress support for TaskPreview Signed-off-by: Pierre Michel --- src/components/ReportActionItem/TaskPreview.js | 17 +++++++++++++++++ src/pages/home/report/ReportActionItem.js | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 472c71298852f..7f18a65e420eb 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -22,6 +22,10 @@ import * as ReportUtils from '../../libs/ReportUtils'; import RenderHTML from '../RenderHTML'; import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback'; import personalDetailsPropType from '../../pages/personalDetailsPropType'; +import {showContextMenuForReport} from '../ShowContextMenuContext'; +import reportPropTypes from '../../pages/reportPropTypes'; +import refPropTypes from '../refPropTypes'; +import * as DeviceCapabilities from '../../libs/DeviceCapabilities'; const propTypes = { /** All personal details asssociated with user */ @@ -49,6 +53,16 @@ const propTypes = { ownerAccountID: PropTypes.number, }), + /* Onyx Props */ + /** chatReport associated with taskReport */ + chatReport: reportPropTypes, + + /** Popover context menu anchor, used for showing context menu */ + contextMenuAnchor: refPropTypes, + + /** Callback for updating context menu active state, used for showing context menu */ + checkIfContextMenuActive: PropTypes.func, + ...withLocalizePropTypes, }; @@ -74,6 +88,9 @@ function TaskPreview(props) { Navigation.navigate(ROUTES.getReportRoute(props.taskReportID))} + onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} + onPressOut={() => ControlSelection.unblock()} + onLongPress={(event) => showContextMenuForReport(event, props.contextMenuAnchor, props.chatReportID, props.action, props.checkIfContextMenuActive)} style={[styles.flexRow, styles.justifyContentBetween]} accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} accessibilityLabel={props.translate('task.task')} diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 0b67a728ba0e5..b15e92e29b62c 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -281,8 +281,11 @@ function ReportActionItem(props) { children = ( ); } else { From 0efba40908b3ea408f222edee2d6e9b23d855387 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Fri, 21 Jul 2023 16:27:14 -0600 Subject: [PATCH 2/9] Add ControlSelection to imports Signed-off-by: Pierre Michel --- src/components/ReportActionItem/TaskPreview.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 7f18a65e420eb..9d66d16b9b547 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -26,6 +26,7 @@ import {showContextMenuForReport} from '../ShowContextMenuContext'; import reportPropTypes from '../../pages/reportPropTypes'; import refPropTypes from '../refPropTypes'; import * as DeviceCapabilities from '../../libs/DeviceCapabilities'; +import ControlSelection from '../../libs/ControlSelection'; const propTypes = { /** All personal details asssociated with user */ From 67125d17037f34d45c35d77862148cfd08995638 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Wed, 4 Oct 2023 10:08:53 -0600 Subject: [PATCH 3/9] The merge was wrong Signed-off-by: Pierre Michel --- src/components/ReportActionItem/TaskPreview.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 79d016fa297fd..6fbe2c175799d 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -57,16 +57,17 @@ const propTypes = { ownerAccountID: PropTypes.number, }), - /* Onyx Props */ /** chatReport associated with taskReport */ chatReport: reportPropTypes, - + /** Popover context menu anchor, used for showing context menu */ contextMenuAnchor: refPropTypes, /** Callback for updating context menu active state, used for showing context menu */ checkIfContextMenuActive: PropTypes.func, - ...withLocalizePropTypes, + + /* Onyx Props */ + ...withLocalizePropTypes, ...withCurrentUserPersonalDetailsPropTypes, }; @@ -87,8 +88,7 @@ function TaskPreview(props) { : props.action.childStateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.action.childStatusNum === CONST.REPORT.STATUS.APPROVED; const taskTitle = props.taskReport.reportName || props.action.childReportName; const taskAssigneeAccountID = Task.getTaskAssigneeAccountID(props.taskReport) || props.action.childManagerAccountID; - const taskAssignee = lodashGet(props.personalDetailsList, [taskAssigneeAccountID, 'login'], lodashGet(props.personalDetailsList, [taskAssigneeAccountID, 'displayName'], '')); - const htmlForTaskPreview = taskAssignee ? `@${taskAssignee} ${taskTitle}` : `${taskTitle}`; + const assigneeLogin = lodashGet(props.personalDetailsList, [taskAssigneeAccountID, 'login'], ''); const assigneeDisplayName = lodashGet(props.personalDetailsList, [taskAssigneeAccountID, 'displayName'], ''); const taskAssignee = assigneeDisplayName || LocalePhoneNumber.formatPhoneNumber(assigneeLogin); const htmlForTaskPreview = From eb4fe936253d86232d0e096ca4c6328471d95e96 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Wed, 4 Oct 2023 11:09:07 -0600 Subject: [PATCH 4/9] We use chatReportID not chatReport Signed-off-by: Pierre Michel --- src/components/ReportActionItem/TaskPreview.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 6fbe2c175799d..3635e8dbb24d8 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -57,8 +57,8 @@ const propTypes = { ownerAccountID: PropTypes.number, }), - /** chatReport associated with taskReport */ - chatReport: reportPropTypes, + /** The chat report associated with taskReport */ + chatReportID: PropTypes.string.isRequired, /** Popover context menu anchor, used for showing context menu */ contextMenuAnchor: refPropTypes, From eb985defedccd75ff4d347cff2c7adb433e068d6 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Wed, 4 Oct 2023 11:16:09 -0600 Subject: [PATCH 5/9] reportPropTypes is not used Signed-off-by: Pierre Michel --- src/components/ReportActionItem/TaskPreview.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 3635e8dbb24d8..8c757b51790c1 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -26,7 +26,6 @@ import personalDetailsPropType from '../../pages/personalDetailsPropType'; import * as Session from '../../libs/actions/Session'; import * as LocalePhoneNumber from '../../libs/LocalePhoneNumber'; import {showContextMenuForReport} from '../ShowContextMenuContext'; -import reportPropTypes from '../../pages/reportPropTypes'; import refPropTypes from '../refPropTypes'; import * as DeviceCapabilities from '../../libs/DeviceCapabilities'; import ControlSelection from '../../libs/ControlSelection'; From 1976e13f5a46f8429d870bd5f91f022b78bb68a6 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Thu, 26 Oct 2023 14:36:52 -0300 Subject: [PATCH 6/9] Adding the provider for context menu around task preview Signed-off-by: Pierre Michel --- src/pages/home/report/ReportActionItem.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 20f814cc6a85c..8277ae0742c9f 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -353,14 +353,16 @@ function ReportActionItem(props) { ); } else if (ReportActionsUtils.isCreatedTaskReportAction(props.action)) { children = ( - + + + ); } else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED) { const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails, [props.report.ownerAccountID, 'displayName'], props.report.ownerEmail); From 61da9cdcd5b09a079d41f3fd6fbe93ee12e59a3b Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Mon, 30 Oct 2023 16:20:50 -0300 Subject: [PATCH 7/9] Merge was wrong Signed-off-by: Pierre Michel --- src/components/ReportActionItem/TaskPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 628ef42839b66..7b0066ecb152c 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -24,7 +24,7 @@ import * as Session from '@userActions/Session'; import * as Task from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '../../libs/LocalePhoneNumber'; +import ROUTES from '@src/ROUTES'; import {showContextMenuForReport} from '../ShowContextMenuContext'; import refPropTypes from '../refPropTypes'; import * as DeviceCapabilities from '../../libs/DeviceCapabilities'; From 58cecfa74b6359f9c078e2dd64417beadefcad4a Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Mon, 30 Oct 2023 16:35:43 -0300 Subject: [PATCH 8/9] Improve the imports for lint Signed-off-by: Pierre Michel --- src/components/ReportActionItem/TaskPreview.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 7b0066ecb152c..eddd8c695b4c6 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -11,11 +11,15 @@ import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeed import RenderHTML from '@components/RenderHTML'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; +import {showContextMenuForReport} from '@components/ShowContextMenuContext'; +import refPropTypes from '@components/refPropTypes'; import compose from '@libs/compose'; import getButtonState from '@libs/getButtonState'; import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; import Navigation from '@libs/Navigation/Navigation'; import * as ReportUtils from '@libs/ReportUtils'; +import * as DeviceCapabilities from '@libs/DeviceCapabilities'; +import ControlSelection from '@libs/ControlSelection'; import reportActionPropTypes from '@pages/home/report/reportActionPropTypes'; import personalDetailsPropType from '@pages/personalDetailsPropType'; import styles from '@styles/styles'; @@ -25,10 +29,6 @@ import * as Task from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import {showContextMenuForReport} from '../ShowContextMenuContext'; -import refPropTypes from '../refPropTypes'; -import * as DeviceCapabilities from '../../libs/DeviceCapabilities'; -import ControlSelection from '../../libs/ControlSelection'; const propTypes = { /** All personal details asssociated with user */ From 6d8043ad739edc212ed0fccbef868f516605493b Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Mon, 30 Oct 2023 19:19:46 -0300 Subject: [PATCH 9/9] After npm run prettier Signed-off-by: Pierre Michel --- src/components/ReportActionItem/TaskPreview.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index eddd8c695b4c6..954799246857b 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -8,18 +8,18 @@ import Checkbox from '@components/Checkbox'; import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; +import refPropTypes from '@components/refPropTypes'; import RenderHTML from '@components/RenderHTML'; +import {showContextMenuForReport} from '@components/ShowContextMenuContext'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; -import {showContextMenuForReport} from '@components/ShowContextMenuContext'; -import refPropTypes from '@components/refPropTypes'; import compose from '@libs/compose'; +import ControlSelection from '@libs/ControlSelection'; +import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import getButtonState from '@libs/getButtonState'; import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; import Navigation from '@libs/Navigation/Navigation'; import * as ReportUtils from '@libs/ReportUtils'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import ControlSelection from '@libs/ControlSelection'; import reportActionPropTypes from '@pages/home/report/reportActionPropTypes'; import personalDetailsPropType from '@pages/personalDetailsPropType'; import styles from '@styles/styles';