From 02f6e74e30c3f565d4d2859335d5ea9687cff028 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Mon, 11 Sep 2023 09:35:04 +0700 Subject: [PATCH 1/8] fix colon added to completed reopened task messages when copy pasting --- src/components/ReportActionItem/TaskAction.js | 24 ++------------- src/libs/getTaskReportActionMessage.js | 29 +++++++++++++++++++ .../BaseReportActionContextMenu.js | 1 + .../report/ContextMenu/ContextMenuActions.js | 6 ++-- src/pages/home/report/ReportActionItem.js | 7 +---- 5 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 src/libs/getTaskReportActionMessage.js diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js index c0b60ad996db..c5d17605d331 100644 --- a/src/components/ReportActionItem/TaskAction.js +++ b/src/components/ReportActionItem/TaskAction.js @@ -7,12 +7,9 @@ import compose from '../../libs/compose'; import ONYXKEYS from '../../ONYXKEYS'; import Text from '../Text'; import styles from '../../styles/styles'; -import CONST from '../../CONST'; +import getTaskReportActionMessage from '../../libs/getTaskReportActionMessage'; const propTypes = { - /** Name of the reportAction action */ - actionName: PropTypes.string.isRequired, - /** The ID of the associated taskReport */ // eslint-disable-next-line react/no-unused-prop-types -- This is used in the withOnyx HOC taskReportID: PropTypes.string.isRequired, @@ -36,27 +33,10 @@ const defaultProps = { taskReport: {}, }; function TaskAction(props) { - const taskReportName = props.taskReport.reportName || ''; - - let taskStatusText = ''; - switch (props.actionName) { - case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED: - taskStatusText = props.translate('task.messages.completed'); - break; - case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED: - taskStatusText = props.translate('task.messages.canceled'); - break; - case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED: - taskStatusText = props.translate('task.messages.reopened'); - break; - default: - taskStatusText = props.translate('task.task'); - } - return ( <> - {`${taskStatusText} ${taskReportName}`} + {getTaskReportActionMessage(props.reportAction, props.translate)} ); diff --git a/src/libs/getTaskReportActionMessage.js b/src/libs/getTaskReportActionMessage.js new file mode 100644 index 000000000000..8c7d168566f6 --- /dev/null +++ b/src/libs/getTaskReportActionMessage.js @@ -0,0 +1,29 @@ +import CONST from '../CONST'; +import * as ReportUtils from './ReportUtils'; +/** + * @param {Object} reportAction + * @param {Function} translate + * @returns {string} + */ +function getTaskReportActionMessage(reportAction, translate) { + const taskReport = ReportUtils.getReport(reportAction.originalMessage.taskReportID.toString()); + const taskReportName = taskReport.reportName || ''; + + let taskStatusText = ''; + switch (reportAction.actionName) { + case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED: + taskStatusText = translate('task.messages.completed'); + break; + case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED: + taskStatusText = translate('task.messages.canceled'); + break; + case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED: + taskStatusText = translate('task.messages.reopened'); + break; + default: + taskStatusText = translate('task.task'); + } + return `${taskStatusText} ${taskReportName}`; +} + +export default getTaskReportActionMessage; diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js index 362ce23f72ba..d87481e9e5f7 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js @@ -92,6 +92,7 @@ function BaseReportActionContextMenu(props) { close: () => setShouldKeepOpen(false), openContextMenu: () => setShouldKeepOpen(true), interceptAnonymousUser, + translate: props.translate, }; if (contextAction.renderContent) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index bac79e1863e5..56e02ec5a333 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -21,6 +21,7 @@ import QuickEmojiReactions from '../../../../components/Reactions/QuickEmojiReac import MiniQuickEmojiReactions from '../../../../components/Reactions/MiniQuickEmojiReactions'; import Navigation from '../../../../libs/Navigation/Navigation'; import ROUTES from '../../../../ROUTES'; +import getTaskReportActionMessage from '../../../../libs/getTaskReportActionMessage'; /** * Gets the HTML version of the message in an action. @@ -182,12 +183,11 @@ export default [ // If return value is true, we switch the `text` and `icon` on // `ContextMenuItem` with `successText` and `successIcon` which will fallback to // the `text` and `icon` - onPress: (closePopover, {reportAction, selection}) => { + onPress: (closePopover, {reportAction, selection, translate}) => { const isTaskAction = ReportActionsUtils.isTaskAction(reportAction); const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const message = _.last(lodashGet(reportAction, 'message', [{}])); - const originalMessage = _.get(reportAction, 'originalMessage', {}); - const messageHtml = isTaskAction ? lodashGet(originalMessage, 'html', '') : lodashGet(message, 'html', ''); + const messageHtml = isTaskAction ? getTaskReportActionMessage(reportAction, translate) : lodashGet(message, 'html', ''); const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); if (!isAttachment) { diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 22ded971898f..2b79e464fa55 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -296,12 +296,7 @@ function ReportActionItem(props) { props.action.actionName === CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED || props.action.actionName === CONST.REPORT.ACTIONS.TYPE.TASKREOPENED ) { - children = ( - - ); + children = ; } else if (ReportActionsUtils.isCreatedTaskReportAction(props.action)) { children = ( Date: Mon, 11 Sep 2023 14:25:27 +0700 Subject: [PATCH 2/8] fix change params passed to util function --- src/components/ReportActionItem/TaskAction.js | 7 +++-- src/libs/ReportActionsUtils.js | 26 +++++++++++++++++ src/libs/getTaskReportActionMessage.js | 29 ------------------- .../BaseReportActionContextMenu.js | 1 - .../report/ContextMenu/ContextMenuActions.js | 5 ++-- src/pages/home/report/ReportActionItem.js | 7 ++++- 6 files changed, 39 insertions(+), 36 deletions(-) delete mode 100644 src/libs/getTaskReportActionMessage.js diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js index c5d17605d331..da86d36a49f2 100644 --- a/src/components/ReportActionItem/TaskAction.js +++ b/src/components/ReportActionItem/TaskAction.js @@ -7,9 +7,12 @@ import compose from '../../libs/compose'; import ONYXKEYS from '../../ONYXKEYS'; import Text from '../Text'; import styles from '../../styles/styles'; -import getTaskReportActionMessage from '../../libs/getTaskReportActionMessage'; +import * as ReportActionUtils from '../../libs/ReportActionsUtils'; const propTypes = { + /** Name of the reportAction action */ + actionName: PropTypes.string.isRequired, + /** The ID of the associated taskReport */ // eslint-disable-next-line react/no-unused-prop-types -- This is used in the withOnyx HOC taskReportID: PropTypes.string.isRequired, @@ -36,7 +39,7 @@ function TaskAction(props) { return ( <> - {getTaskReportActionMessage(props.reportAction, props.translate)} + {ReportActionUtils.getTaskReportActionMessage(props.actionName, props.taskReportID)} ); diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index 9cbc414bf582..bab587457b94 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -9,6 +9,7 @@ import CONST from '../CONST'; import ONYXKEYS from '../ONYXKEYS'; import Log from './Log'; import isReportMessageAttachment from './isReportMessageAttachment'; +import * as Localize from './Localize'; const allReports = {}; Onyx.connect({ @@ -612,6 +613,30 @@ function getAllReportActions(reportID) { return lodashGet(allReportActions, reportID, []); } +/** + * @param {string} actionName + * @param {string} reportID + * @returns {string} + */ +function getTaskReportActionMessage(actionName, reportID) { + let taskStatusText = ''; + switch (actionName) { + case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED: + taskStatusText = Localize.translateLocal('task.messages.completed'); + break; + case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED: + taskStatusText = Localize.translateLocal('task.messages.canceled'); + break; + case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED: + taskStatusText = Localize.translateLocal('task.messages.reopened'); + break; + default: + taskStatusText = Localize.translateLocal('task.task'); + } + + return `${taskStatusText} ${allReports[reportID].reportName}`; +} + export { getSortedReportActions, getLastVisibleAction, @@ -649,4 +674,5 @@ export { isSplitBillAction, isTaskAction, getAllReportActions, + getTaskReportActionMessage, }; diff --git a/src/libs/getTaskReportActionMessage.js b/src/libs/getTaskReportActionMessage.js deleted file mode 100644 index 8c7d168566f6..000000000000 --- a/src/libs/getTaskReportActionMessage.js +++ /dev/null @@ -1,29 +0,0 @@ -import CONST from '../CONST'; -import * as ReportUtils from './ReportUtils'; -/** - * @param {Object} reportAction - * @param {Function} translate - * @returns {string} - */ -function getTaskReportActionMessage(reportAction, translate) { - const taskReport = ReportUtils.getReport(reportAction.originalMessage.taskReportID.toString()); - const taskReportName = taskReport.reportName || ''; - - let taskStatusText = ''; - switch (reportAction.actionName) { - case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED: - taskStatusText = translate('task.messages.completed'); - break; - case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED: - taskStatusText = translate('task.messages.canceled'); - break; - case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED: - taskStatusText = translate('task.messages.reopened'); - break; - default: - taskStatusText = translate('task.task'); - } - return `${taskStatusText} ${taskReportName}`; -} - -export default getTaskReportActionMessage; diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js index d87481e9e5f7..362ce23f72ba 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js @@ -92,7 +92,6 @@ function BaseReportActionContextMenu(props) { close: () => setShouldKeepOpen(false), openContextMenu: () => setShouldKeepOpen(true), interceptAnonymousUser, - translate: props.translate, }; if (contextAction.renderContent) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 56e02ec5a333..5745d01a8bfe 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -21,7 +21,6 @@ import QuickEmojiReactions from '../../../../components/Reactions/QuickEmojiReac import MiniQuickEmojiReactions from '../../../../components/Reactions/MiniQuickEmojiReactions'; import Navigation from '../../../../libs/Navigation/Navigation'; import ROUTES from '../../../../ROUTES'; -import getTaskReportActionMessage from '../../../../libs/getTaskReportActionMessage'; /** * Gets the HTML version of the message in an action. @@ -183,11 +182,11 @@ export default [ // If return value is true, we switch the `text` and `icon` on // `ContextMenuItem` with `successText` and `successIcon` which will fallback to // the `text` and `icon` - onPress: (closePopover, {reportAction, selection, translate}) => { + onPress: (closePopover, {reportAction, selection, reportID}) => { const isTaskAction = ReportActionsUtils.isTaskAction(reportAction); const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const message = _.last(lodashGet(reportAction, 'message', [{}])); - const messageHtml = isTaskAction ? getTaskReportActionMessage(reportAction, translate) : lodashGet(message, 'html', ''); + const messageHtml = isTaskAction ? ReportActionsUtils.getTaskReportActionMessage(reportAction.actionName, reportID) : lodashGet(message, 'html', ''); const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); if (!isAttachment) { diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 2b79e464fa55..22ded971898f 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -296,7 +296,12 @@ function ReportActionItem(props) { props.action.actionName === CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED || props.action.actionName === CONST.REPORT.ACTIONS.TYPE.TASKREOPENED ) { - children = ; + children = ( + + ); } else if (ReportActionsUtils.isCreatedTaskReportAction(props.action)) { children = ( Date: Mon, 11 Sep 2023 14:31:09 +0700 Subject: [PATCH 3/8] fix remove unused variables --- src/components/ReportActionItem/TaskAction.js | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js index da86d36a49f2..6cd4add29c01 100644 --- a/src/components/ReportActionItem/TaskAction.js +++ b/src/components/ReportActionItem/TaskAction.js @@ -1,10 +1,7 @@ import React from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; -import {withOnyx} from 'react-native-onyx'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; -import compose from '../../libs/compose'; -import ONYXKEYS from '../../ONYXKEYS'; import Text from '../Text'; import styles from '../../styles/styles'; import * as ReportActionUtils from '../../libs/ReportActionsUtils'; @@ -17,24 +14,9 @@ const propTypes = { // eslint-disable-next-line react/no-unused-prop-types -- This is used in the withOnyx HOC taskReportID: PropTypes.string.isRequired, - /* Onyx Props */ - taskReport: PropTypes.shape({ - /** Title of the task */ - reportName: PropTypes.string, - - /** AccountID of the manager in this iou report */ - managerID: PropTypes.number, - - /** AccountID of the creator of this iou report */ - ownerAccountID: PropTypes.number, - }), - ...withLocalizePropTypes, }; -const defaultProps = { - taskReport: {}, -}; function TaskAction(props) { return ( <> @@ -46,14 +28,6 @@ function TaskAction(props) { } TaskAction.propTypes = propTypes; -TaskAction.defaultProps = defaultProps; TaskAction.displayName = 'TaskAction'; -export default compose( - withLocalize, - withOnyx({ - taskReport: { - key: ({taskReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, - }, - }), -)(TaskAction); +export default withLocalize(TaskAction); From 1e537f3e21e0cb8f59d4623c2d31ef44e3c9ed6c Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Mon, 11 Sep 2023 15:51:27 +0700 Subject: [PATCH 4/8] fix move the util function to action folder --- src/components/ReportActionItem/TaskAction.js | 4 +-- src/libs/ReportActionsUtils.js | 26 ------------------- src/libs/actions/Task.js | 26 +++++++++++++++++++ .../report/ContextMenu/ContextMenuActions.js | 3 ++- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js index 6cd4add29c01..60c5736a0374 100644 --- a/src/components/ReportActionItem/TaskAction.js +++ b/src/components/ReportActionItem/TaskAction.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; import Text from '../Text'; import styles from '../../styles/styles'; -import * as ReportActionUtils from '../../libs/ReportActionsUtils'; +import * as Task from '../../libs/actions/Task'; const propTypes = { /** Name of the reportAction action */ @@ -21,7 +21,7 @@ function TaskAction(props) { return ( <> - {ReportActionUtils.getTaskReportActionMessage(props.actionName, props.taskReportID)} + {Task.getTaskReportActionMessage(props.actionName, props.taskReportID)} ); diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index bab587457b94..9cbc414bf582 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -9,7 +9,6 @@ import CONST from '../CONST'; import ONYXKEYS from '../ONYXKEYS'; import Log from './Log'; import isReportMessageAttachment from './isReportMessageAttachment'; -import * as Localize from './Localize'; const allReports = {}; Onyx.connect({ @@ -613,30 +612,6 @@ function getAllReportActions(reportID) { return lodashGet(allReportActions, reportID, []); } -/** - * @param {string} actionName - * @param {string} reportID - * @returns {string} - */ -function getTaskReportActionMessage(actionName, reportID) { - let taskStatusText = ''; - switch (actionName) { - case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED: - taskStatusText = Localize.translateLocal('task.messages.completed'); - break; - case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED: - taskStatusText = Localize.translateLocal('task.messages.canceled'); - break; - case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED: - taskStatusText = Localize.translateLocal('task.messages.reopened'); - break; - default: - taskStatusText = Localize.translateLocal('task.task'); - } - - return `${taskStatusText} ${allReports[reportID].reportName}`; -} - export { getSortedReportActions, getLastVisibleAction, @@ -674,5 +649,4 @@ export { isSplitBillAction, isTaskAction, getAllReportActions, - getTaskReportActionMessage, }; diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index d66cc243acf4..8a56f34aee3a 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -13,6 +13,7 @@ import * as ErrorUtils from '../ErrorUtils'; import * as ReportActionsUtils from '../ReportActionsUtils'; import * as Expensicons from '../../components/Icon/Expensicons'; import * as LocalePhoneNumber from '../LocalePhoneNumber'; +import * as Localize from '../Localize'; let currentUserEmail; let currentUserAccountID; @@ -894,6 +895,30 @@ function clearEditTaskErrors(reportID) { }); } +/** + * @param {string} actionName + * @param {string} reportID + * @returns {string} + */ +function getTaskReportActionMessage(actionName, reportID) { + let taskStatusText = ''; + switch (actionName) { + case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED: + taskStatusText = Localize.translateLocal('task.messages.completed'); + break; + case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED: + taskStatusText = Localize.translateLocal('task.messages.canceled'); + break; + case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED: + taskStatusText = Localize.translateLocal('task.messages.reopened'); + break; + default: + taskStatusText = Localize.translateLocal('task.task'); + } + + return `${taskStatusText} ${ReportUtils.getReport(reportID).reportName}`; +} + export { createTaskAndNavigate, editTaskAndNavigate, @@ -915,4 +940,5 @@ export { getTaskAssigneeAccountID, clearEditTaskErrors, canModifyTask, + getTaskReportActionMessage, }; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 5745d01a8bfe..369967788932 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -21,6 +21,7 @@ import QuickEmojiReactions from '../../../../components/Reactions/QuickEmojiReac import MiniQuickEmojiReactions from '../../../../components/Reactions/MiniQuickEmojiReactions'; import Navigation from '../../../../libs/Navigation/Navigation'; import ROUTES from '../../../../ROUTES'; +import * as Task from '../../../../libs/actions/Task'; /** * Gets the HTML version of the message in an action. @@ -186,7 +187,7 @@ export default [ const isTaskAction = ReportActionsUtils.isTaskAction(reportAction); const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const message = _.last(lodashGet(reportAction, 'message', [{}])); - const messageHtml = isTaskAction ? ReportActionsUtils.getTaskReportActionMessage(reportAction.actionName, reportID) : lodashGet(message, 'html', ''); + const messageHtml = isTaskAction ? Task.getTaskReportActionMessage(reportAction.actionName, reportID) : lodashGet(message, 'html', ''); const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); if (!isAttachment) { From d0ecf7301322b04af73b599a8f55ae2f5ec6de62 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 12 Sep 2023 15:17:40 +0700 Subject: [PATCH 5/8] fix remove param reportID --- src/pages/home/report/ContextMenu/ContextMenuActions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 369967788932..2a1dd49a7004 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -183,10 +183,11 @@ export default [ // If return value is true, we switch the `text` and `icon` on // `ContextMenuItem` with `successText` and `successIcon` which will fallback to // the `text` and `icon` - onPress: (closePopover, {reportAction, selection, reportID}) => { + onPress: (closePopover, {reportAction, selection}) => { const isTaskAction = ReportActionsUtils.isTaskAction(reportAction); const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const message = _.last(lodashGet(reportAction, 'message', [{}])); + const reportID = reportAction.originalMessage.taskReportID.toString(); const messageHtml = isTaskAction ? Task.getTaskReportActionMessage(reportAction.actionName, reportID) : lodashGet(message, 'html', ''); const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); From a9a3963babdf953598491e65529c2a7764a3fb1d Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 12 Sep 2023 15:26:10 +0700 Subject: [PATCH 6/8] fix using lodashGet to get reportID --- src/pages/home/report/ContextMenu/ContextMenuActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 2a1dd49a7004..eaa76e15d2aa 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -187,7 +187,7 @@ export default [ const isTaskAction = ReportActionsUtils.isTaskAction(reportAction); const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const message = _.last(lodashGet(reportAction, 'message', [{}])); - const reportID = reportAction.originalMessage.taskReportID.toString(); + const reportID = lodashGet(reportAction, 'originalMessage.taskReportID', '').toString(); const messageHtml = isTaskAction ? Task.getTaskReportActionMessage(reportAction.actionName, reportID) : lodashGet(message, 'html', ''); const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); From d8d98cdc3401d5c7b71d21927f7cae633352e913 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 15 Sep 2023 18:53:43 +0700 Subject: [PATCH 7/8] fix copy addcomment text --- src/components/ReportActionItem/TaskAction.js | 2 +- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/actions/Task.js | 9 +++++++-- src/pages/home/report/ContextMenu/ContextMenuActions.js | 3 ++- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js index 60c5736a0374..9d32fa7a1e77 100644 --- a/src/components/ReportActionItem/TaskAction.js +++ b/src/components/ReportActionItem/TaskAction.js @@ -21,7 +21,7 @@ function TaskAction(props) { return ( <> - {Task.getTaskReportActionMessage(props.actionName, props.taskReportID)} + {Task.getTaskReportActionMessage(props.actionName, props.taskReportID, false)} ); diff --git a/src/languages/en.ts b/src/languages/en.ts index f52848589663..6987c4f51c00 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1510,6 +1510,7 @@ export default { reopened: 'reopened task', error: 'You do not have the permission to do the requested action.', }, + createdTask: ({title}: {title: string}) => `Created a task: ${title}`, markAsDone: 'Mark as done', markAsIncomplete: 'Mark as incomplete', assigneeError: 'There was an error assigning this task, please try another assignee.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 8610f41308e1..db47f2d3901a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1541,6 +1541,7 @@ export default { reopened: 'tarea reabrir', error: 'No tiene permiso para realizar la acción solicitada.', }, + createdTask: ({title}: {title: string}) => `Creó una tarea: ${title}`, markAsDone: 'Marcar como completada', markAsIncomplete: 'Marcar como incompleta', assigneeError: 'Hubo un error al asignar esta tarea, inténtalo con otro usuario.', diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index 8a56f34aee3a..68e1e2a24d63 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -898,9 +898,14 @@ function clearEditTaskErrors(reportID) { /** * @param {string} actionName * @param {string} reportID + * @param {boolean} isCreateTaskAction * @returns {string} */ -function getTaskReportActionMessage(actionName, reportID) { +function getTaskReportActionMessage(actionName, reportID, isCreateTaskAction) { + const report = ReportUtils.getReport(reportID); + if (isCreateTaskAction) { + return Localize.translateLocal('task.createdTask', {title: report.reportName}); + } let taskStatusText = ''; switch (actionName) { case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED: @@ -916,7 +921,7 @@ function getTaskReportActionMessage(actionName, reportID) { taskStatusText = Localize.translateLocal('task.task'); } - return `${taskStatusText} ${ReportUtils.getReport(reportID).reportName}`; + return `${taskStatusText} ${report.reportName}`; } export { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index eaa76e15d2aa..78115bb4c084 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -185,10 +185,11 @@ export default [ // the `text` and `icon` onPress: (closePopover, {reportAction, selection}) => { const isTaskAction = ReportActionsUtils.isTaskAction(reportAction); + const isCreateTaskAction = ReportActionsUtils.isCreatedTaskReportAction(reportAction); const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const message = _.last(lodashGet(reportAction, 'message', [{}])); const reportID = lodashGet(reportAction, 'originalMessage.taskReportID', '').toString(); - const messageHtml = isTaskAction ? Task.getTaskReportActionMessage(reportAction.actionName, reportID) : lodashGet(message, 'html', ''); + const messageHtml = isTaskAction || isCreateTaskAction ? Task.getTaskReportActionMessage(reportAction.actionName, reportID, isCreateTaskAction) : lodashGet(message, 'html', ''); const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); if (!isAttachment) { From 935e720cf42de6499cbfeb01f54d3266f868da2e Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 15 Sep 2023 19:04:44 +0700 Subject: [PATCH 8/8] fix remove translation for create task --- src/languages/en.ts | 1 - src/languages/es.ts | 1 - src/libs/actions/Task.js | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 6987c4f51c00..f52848589663 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1510,7 +1510,6 @@ export default { reopened: 'reopened task', error: 'You do not have the permission to do the requested action.', }, - createdTask: ({title}: {title: string}) => `Created a task: ${title}`, markAsDone: 'Mark as done', markAsIncomplete: 'Mark as incomplete', assigneeError: 'There was an error assigning this task, please try another assignee.', diff --git a/src/languages/es.ts b/src/languages/es.ts index db47f2d3901a..8610f41308e1 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1541,7 +1541,6 @@ export default { reopened: 'tarea reabrir', error: 'No tiene permiso para realizar la acción solicitada.', }, - createdTask: ({title}: {title: string}) => `Creó una tarea: ${title}`, markAsDone: 'Marcar como completada', markAsIncomplete: 'Marcar como incompleta', assigneeError: 'Hubo un error al asignar esta tarea, inténtalo con otro usuario.', diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index 68e1e2a24d63..c34537ff9f72 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -904,7 +904,7 @@ function clearEditTaskErrors(reportID) { function getTaskReportActionMessage(actionName, reportID, isCreateTaskAction) { const report = ReportUtils.getReport(reportID); if (isCreateTaskAction) { - return Localize.translateLocal('task.createdTask', {title: report.reportName}); + return `Created a task: ${report.reportName}`; } let taskStatusText = ''; switch (actionName) {