From 9933e8308a9bbf0bff0624b8844af4f1b0cfa5c3 Mon Sep 17 00:00:00 2001 From: Someshwar Tripathi Date: Sat, 20 Jul 2024 22:40:51 +0530 Subject: [PATCH 1/7] use ReportActionBasicMessage for rename actions --- src/pages/home/report/ReportActionItem.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index b5ee3607f359..95752de7eaef 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -23,7 +23,6 @@ import ActionableItemButtons from '@components/ReportActionItem/ActionableItemBu import ChronosOOOListActions from '@components/ReportActionItem/ChronosOOOListActions'; import ExportIntegration from '@components/ReportActionItem/ExportIntegration'; import MoneyRequestAction from '@components/ReportActionItem/MoneyRequestAction'; -import RenameAction from '@components/ReportActionItem/RenameAction'; import ReportPreview from '@components/ReportActionItem/ReportPreview'; import TaskAction from '@components/ReportActionItem/TaskAction'; import TaskPreview from '@components/ReportActionItem/TaskPreview'; @@ -658,6 +657,12 @@ function ReportActionItem({ children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION)) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { + const originalMessage = ReportActionsUtils.isRenamedAction(action) ? ReportActionsUtils.getOriginalMessage(action) : null; + const oldName = originalMessage?.oldName ?? ''; + const newName = originalMessage?.newName ?? ''; + const message = translate('newRoomPage.renamedRoomAction', {oldName, newName}); + children = ; } else { const hasBeenFlagged = ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && @@ -839,9 +844,6 @@ function ReportActionItem({ /> ); } - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { - return ; - } if (ReportActionsUtils.isChronosOOOListAction(action)) { return ( Date: Sat, 20 Jul 2024 22:41:25 +0530 Subject: [PATCH 2/7] Remove unused RenameAction component --- .../ReportActionItem/RenameAction.tsx | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/components/ReportActionItem/RenameAction.tsx diff --git a/src/components/ReportActionItem/RenameAction.tsx b/src/components/ReportActionItem/RenameAction.tsx deleted file mode 100644 index e65fc68ecd42..000000000000 --- a/src/components/ReportActionItem/RenameAction.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import Text from '@components/Text'; -import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; -import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import * as ReportActionsUtils from '@libs/ReportActionsUtils'; -import type {ReportAction} from '@src/types/onyx'; - -type RenameActionProps = WithCurrentUserPersonalDetailsProps & { - /** All the data of the action */ - action: ReportAction; -}; - -function RenameAction({currentUserPersonalDetails, action}: RenameActionProps) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - - const currentUserAccountID = currentUserPersonalDetails.accountID ?? '-1'; - const userDisplayName = action.person?.[0]?.text; - const actorAccountID = action.actorAccountID ?? '-1'; - const displayName = actorAccountID === currentUserAccountID ? `${translate('common.you')}` : `${userDisplayName}`; - const originalMessage = ReportActionsUtils.isRenamedAction(action) ? ReportActionsUtils.getOriginalMessage(action) : null; - const oldName = originalMessage?.oldName ?? ''; - const newName = originalMessage?.newName ?? ''; - - return ( - - {displayName} - {translate('newRoomPage.renamedRoomAction', {oldName, newName})} - - ); -} - -RenameAction.displayName = 'RenameAction'; - -export default withCurrentUserPersonalDetails(RenameAction); From 517581ddd2ee32cf2b73ceca63cd4e4c41333fc8 Mon Sep 17 00:00:00 2001 From: Someshwar Tripathi Date: Sat, 20 Jul 2024 22:41:39 +0530 Subject: [PATCH 3/7] Fix rename copy --- src/languages/en.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index a8281e609305..b32e74464c2a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3442,7 +3442,7 @@ export default { roomNameInvalidError: 'Room names can only include lowercase letters, numbers, and hyphens.', pleaseEnterRoomName: 'Please enter a room name.', pleaseSelectWorkspace: 'Please select a workspace.', - renamedRoomAction: ({oldName, newName}: RenamedRoomActionParams) => ` renamed this room from ${oldName} to ${newName}`, + renamedRoomAction: ({oldName, newName}: RenamedRoomActionParams) => `renamed this room from ${oldName} to ${newName}`, roomRenamedTo: ({newName}: RoomRenamedToParams) => `Room renamed to ${newName}`, social: 'social', selectAWorkspace: 'Select a workspace', From 0ded0ee31de7feb2fb4b4d776ecdf010dbde28d9 Mon Sep 17 00:00:00 2001 From: Someshwar Tripathi Date: Mon, 22 Jul 2024 18:13:11 +0530 Subject: [PATCH 4/7] fix lint --- src/pages/home/report/ReportActionItem.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 95752de7eaef..a6e2f628f92a 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -658,10 +658,11 @@ function ReportActionItem({ } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { - const originalMessage = ReportActionsUtils.isRenamedAction(action) ? ReportActionsUtils.getOriginalMessage(action) : null; - const oldName = originalMessage?.oldName ?? ''; - const newName = originalMessage?.newName ?? ''; - const message = translate('newRoomPage.renamedRoomAction', {oldName, newName}); + const initialMessage = ReportActionsUtils.isRenamedAction(action) ? ReportActionsUtils.getOriginalMessage(action) : null; + const message = translate('newRoomPage.renamedRoomAction', { + oldName: initialMessage?.oldName ?? '', + newName: initialMessage?.newName ?? '', + }); children = ; } else { const hasBeenFlagged = From d7a5d932c8bfe36ef3e4201ceb4d76aad2bccab1 Mon Sep 17 00:00:00 2001 From: Someshwar Tripathi Date: Wed, 24 Jul 2024 21:43:46 +0530 Subject: [PATCH 5/7] Remove leading space from es string --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index e56ae303a813..a2d36dff4c41 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3522,7 +3522,7 @@ export default { roomNameInvalidError: 'Los nombres de las salas solo pueden contener minúsculas, números y guiones.', pleaseEnterRoomName: 'Por favor, escribe el nombre de una sala.', pleaseSelectWorkspace: 'Por favor, selecciona un espacio de trabajo.', - renamedRoomAction: ({oldName, newName}: RenamedRoomActionParams) => ` cambió el nombre de la sala de ${oldName} a ${newName}`, + renamedRoomAction: ({oldName, newName}: RenamedRoomActionParams) => `cambió el nombre de la sala de ${oldName} a ${newName}`, roomRenamedTo: ({newName}: RoomRenamedToParams) => `Sala renombrada a ${newName}`, social: 'social', selectAWorkspace: 'Seleccionar un espacio de trabajo', From a9f48e3941c8a6ac804cd9c203a390b9238ddc08 Mon Sep 17 00:00:00 2001 From: Someshwar Tripathi <64629613+neonbhai@users.noreply.github.com> Date: Tue, 6 Aug 2024 02:37:34 +0530 Subject: [PATCH 6/7] Update src/pages/home/report/ReportActionItem.tsx Co-authored-by: Rory Abraham <47436092+roryabraham@users.noreply.github.com> --- src/pages/home/report/ReportActionItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 8f73c7b96ba4..ea674402a8d2 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -657,7 +657,7 @@ function ReportActionItem({ children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION)) { children = ; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { + } else if (ReportActionsUtils.isRenamedAction(action)) { const initialMessage = ReportActionsUtils.isRenamedAction(action) ? ReportActionsUtils.getOriginalMessage(action) : null; const message = translate('newRoomPage.renamedRoomAction', { oldName: initialMessage?.oldName ?? '', From f80d19bdca0abc31ee5f0e0f3afb334738103337 Mon Sep 17 00:00:00 2001 From: Someshwar Tripathi Date: Tue, 6 Aug 2024 02:42:37 +0530 Subject: [PATCH 7/7] Simplify logic for initialMessage --- src/pages/home/report/ReportActionItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index ea674402a8d2..b56576bd9cce 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -658,7 +658,7 @@ function ReportActionItem({ } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION)) { children = ; } else if (ReportActionsUtils.isRenamedAction(action)) { - const initialMessage = ReportActionsUtils.isRenamedAction(action) ? ReportActionsUtils.getOriginalMessage(action) : null; + const initialMessage = ReportActionsUtils.getOriginalMessage(action); const message = translate('newRoomPage.renamedRoomAction', { oldName: initialMessage?.oldName ?? '', newName: initialMessage?.newName ?? '',