From 959c3df10ef1c54e32bca5220019e3fd4fc37eae Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 28 Nov 2024 08:13:45 +0530 Subject: [PATCH 01/17] fix: Chat - Most of the workspace modifying settings messages are not translated in #Admins. Signed-off-by: krishna2323 --- src/languages/en.ts | 6 +++ src/languages/es.ts | 6 +++ src/languages/params.ts | 6 +++ src/libs/ReportUtils.ts | 43 +++++++++++++++++++ src/libs/SidebarUtils.ts | 4 ++ .../report/ContextMenu/ContextMenuActions.tsx | 4 ++ src/pages/home/report/ReportActionItem.tsx | 4 ++ src/types/onyx/OriginalMessage.ts | 12 ++++++ 8 files changed, 85 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1dc859b007bc..d0f9b3187ebc 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -166,6 +166,8 @@ import type { UntilTimeParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, + UpdatedWorkspaceCurrencyParams, + UpdatedWorkspaceFrequencyParams, UpdateRoleParams, UsePlusButtonParams, UserIsAlreadyMemberParams, @@ -1487,6 +1489,7 @@ const translations = { }, frequencyDescription: 'Choose how often you’d like expenses to submit automatically, or make it manual', frequencies: { + instant: 'Instant', weekly: 'Weekly', monthly: 'Monthly', twiceAMonth: 'Twice a month', @@ -4464,6 +4467,9 @@ const translations = { }, workspaceActions: { renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/languages/es.ts b/src/languages/es.ts index ca1bc8f4680d..5f45f19caf5b 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -165,6 +165,8 @@ import type { UntilTimeParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, + UpdatedWorkspaceCurrencyParams, + UpdatedWorkspaceFrequencyParams, UpdateRoleParams, UsePlusButtonParams, UserIsAlreadyMemberParams, @@ -1488,6 +1490,7 @@ const translations = { }, frequencyDescription: 'Elige la frecuencia de presentación automática de gastos, o preséntalos manualmente', frequencies: { + instant: 'Instante', weekly: 'Semanal', monthly: 'Mensual', twiceAMonth: 'Dos veces al mes', @@ -4513,6 +4516,9 @@ const translations = { }, workspaceActions: { renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/languages/params.ts b/src/languages/params.ts index a2d5e1bee124..8a28b6a13d08 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -286,6 +286,10 @@ type ChangeFieldParams = {oldValue?: string; newValue: string; fieldName: string type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; +type UpdatedWorkspaceCurrencyParams = {oldCurrency: string; newCurrency: string}; + +type UpdatedWorkspaceFrequencyParams = {oldFrequency: string; newFrequency: string}; + type ChangeTypeParams = {oldType: string; newType: string}; type DelegateSubmitParams = {delegateUser: string; originalManager: string}; @@ -771,4 +775,6 @@ export type { WorkspaceLockedPlanTypeParams, CompanyNameParams, ChatWithAccountManagerParams, + UpdatedWorkspaceCurrencyParams, + UpdatedWorkspaceFrequencyParams, }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7ad8d3df1077..bf152c029156 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4817,6 +4817,47 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) { return message; } +function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { + const {oldCurrency, newCurrency} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + const message = + oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : ReportActionsUtils.getReportActionText(action); + return message; +} + +type AutoReportingFrequencyKey = ValueOf; +type AutoReportingFrequencyDisplayNames = Record; + +const getAutoReportingFrequencyDisplayNames = (): AutoReportingFrequencyDisplayNames => ({ + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.monthly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: Localize.translateLocal('workflowsPage.frequencies.daily'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: Localize.translateLocal('workflowsPage.frequencies.weekly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.twiceAMonth'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: Localize.translateLocal('workflowsPage.frequencies.byTrip'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: Localize.translateLocal('workflowsPage.frequencies.manually'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: Localize.translateLocal('workflowsPage.frequencies.instant'), +}); + +function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { + const {oldFrequency, newFrequency} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + + if (!oldFrequency || !newFrequency) { + return ReportActionsUtils.getReportActionText(action); + } + + const frequencyDisplayNames = getAutoReportingFrequencyDisplayNames(); + const oldFrequencyTranslation = frequencyDisplayNames[oldFrequency]?.toLowerCase(); + const newFrequencyTranslation = frequencyDisplayNames[newFrequency]?.toLowerCase(); + + if (!oldFrequencyTranslation || !newFrequencyTranslation) { + return ReportActionsUtils.getReportActionText(action); + } + + return Localize.translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { + oldFrequency: oldFrequencyTranslation, + newFrequency: newFrequencyTranslation, + }); +} + /** * @param iouReportID - the report ID of the IOU report the action belongs to * @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) @@ -8553,6 +8594,8 @@ export { getIOUForwardedMessage, getRejectedReportMessage, getWorkspaceNameUpdatedMessage, + getWorkspaceCurrencyUpdateMessage, + getWorkspaceFrequencyUpdateMessage, getReportAutomaticallySubmittedMessage, getIOUSubmittedMessage, getIcons, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index f4979f942363..dd7e593c96af 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -459,6 +459,10 @@ function getOptionData({ result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`; } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { result.alternateText = ReportUtils.getWorkspaceNameUpdatedMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { + result.alternateText = ReportUtils.getWorkspaceCurrencyUpdateMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { + result.alternateText = ReportUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 705b85d4c3fc..38a8264ef702 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -414,6 +414,10 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(logMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { Clipboard.setString(ReportUtils.getWorkspaceNameUpdatedMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { + Clipboard.setString(ReportUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { + Clipboard.setString(ReportUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 399550069c0a..288ddf57311d 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -704,6 +704,10 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index fd94531abb0f..2fcd5a0f08cb 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -276,6 +276,18 @@ type OriginalMessageChangeLog = { /** Old role of user */ oldValue?: string; + /** Old currency of the workspace */ + oldCurrency?: string; + + /** New currency of the workspace */ + newCurrency?: string; + + /** Old frequency of the workspace */ + oldFrequency?: ValueOf; + + /** New frequency of the workspace */ + newFrequency?: ValueOf; + /** Name of connection */ connectionName?: AllConnectionName; }; From b06352bb8a290e73a25e6f64293f7511bf8ae6b9 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 3 Dec 2024 07:29:59 +0530 Subject: [PATCH 02/17] add translations for 'CORPORATE_UPGRADE' & 'ADD_CATEGORY'. Signed-off-by: krishna2323 --- src/languages/en.ts | 8 +++++--- src/languages/es.ts | 8 +++++--- src/libs/ReportUtils.ts | 13 +++++++++++++ src/libs/SidebarUtils.ts | 4 ++++ .../home/report/ContextMenu/ContextMenuActions.tsx | 4 ++++ src/pages/home/report/ReportActionItem.tsx | 4 ++++ src/types/onyx/OriginalMessage.ts | 3 +++ 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1e83d951665d..33cb72ace5ef 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4444,10 +4444,8 @@ const translations = { }, }, workspaceActions: { + addCategory: ({categoryName}: {categoryName: string}) => `added the category "${categoryName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => - `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { @@ -4462,6 +4460,10 @@ const translations = { other: `removed you from ${joinedNames}'s approval workflows and workspace chats. Previously submitted reports will remain available for approval in your Inbox.`, }; }, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, + updatedWorkspaceCorporatePlan: 'upgraded this workspace to the Control plan', }, roomMembersPage: { memberNotFound: 'Member not found.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 0931fb0911a6..1f55efe3a2e6 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4493,10 +4493,8 @@ const translations = { }, }, workspaceActions: { + addCategory: ({categoryName}: {categoryName: string}) => `agregó la categoría "${categoryName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => - `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { @@ -4511,6 +4509,10 @@ const translations = { other: `te eliminó de los flujos de trabajo de aprobaciones y de los chats del espacio de trabajo de ${joinedNames}. Los informes enviados anteriormente seguirán estando disponibles para su aprobación en tu bandeja de entrada.`, }; }, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, + updatedWorkspaceCorporatePlan: 'mejoró este espacio de trabajo al plan Controlar', }, roomMembersPage: { memberNotFound: 'Miembro no encontrado.', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7402804a4990..067fb7e8aeca 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4868,6 +4868,18 @@ function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { }); } +function getWorkspaceAddCategoryMessage(action: ReportAction): string { + const {categoryName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + + if (!categoryName) { + return ReportActionsUtils.getReportActionText(action); + } + + return Localize.translateLocal('workspaceActions.addCategory', { + categoryName, + }); +} + /** * @param iouReportID - the report ID of the IOU report the action belongs to * @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) @@ -8822,6 +8834,7 @@ export { getAllReportErrors, getAllReportActionsErrorsAndReportActionThatRequiresAttention, hasInvoiceReports, + getWorkspaceAddCategoryMessage, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index dd7e593c96af..bce7cfacf524 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -463,6 +463,10 @@ function getOptionData({ result.alternateText = ReportUtils.getWorkspaceCurrencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { result.alternateText = ReportUtils.getWorkspaceFrequencyUpdateMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { + result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY)) { + result.alternateText = ReportUtils.getWorkspaceAddCategoryMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 38a8264ef702..523ec8362b52 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -418,6 +418,10 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(ReportUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { Clipboard.setString(ReportUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { + Clipboard.setString(ReportUtils.getWorkspaceAddCategoryMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 8c105d26bb9e..fd42a4910b9a 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -708,6 +708,10 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 2fcd5a0f08cb..8788153d9dde 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -290,6 +290,9 @@ type OriginalMessageChangeLog = { /** Name of connection */ connectionName?: AllConnectionName; + + /** Name of the added category */ + categoryName?: string; }; /** Model of `join policy changelog` report action */ From 0c5061a6307ae0f75d4cb1355585d3a00dc757e7 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 3 Dec 2024 08:00:17 +0530 Subject: [PATCH 03/17] refactor and added more translations. Signed-off-by: krishna2323 --- src/languages/en.ts | 5 +- src/languages/es.ts | 5 +- src/languages/params.ts | 3 + src/libs/ReportUtils.ts | 29 ++++++++-- src/libs/SidebarUtils.ts | 7 ++- .../report/ContextMenu/ContextMenuActions.tsx | 8 ++- src/pages/home/report/ReportActionItem.tsx | 8 ++- src/types/onyx/OriginalMessage.ts | 56 ++++++++++++++++++- 8 files changed, 106 insertions(+), 15 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 33cb72ace5ef..60c50b44b1ef 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -168,6 +168,7 @@ import type { UntilTimeParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, + UpdatedWorkspaceCategoryParams, UpdatedWorkspaceCurrencyParams, UpdatedWorkspaceFrequencyParams, UpdateRoleParams, @@ -4444,7 +4445,9 @@ const translations = { }, }, workspaceActions: { - addCategory: ({categoryName}: {categoryName: string}) => `added the category "${categoryName}"`, + addCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `added the category "${categoryName}"`, + deleteCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `removed the category "${categoryName}"`, + updateCategory: ({oldValue, categoryName}: UpdatedWorkspaceCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/es.ts b/src/languages/es.ts index 1f55efe3a2e6..4a388764d522 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -167,6 +167,7 @@ import type { UntilTimeParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, + UpdatedWorkspaceCategoryParams, UpdatedWorkspaceCurrencyParams, UpdatedWorkspaceFrequencyParams, UpdateRoleParams, @@ -4493,7 +4494,9 @@ const translations = { }, }, workspaceActions: { - addCategory: ({categoryName}: {categoryName: string}) => `agregó la categoría "${categoryName}"`, + addCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `agregó la categoría "${categoryName}"`, + deleteCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `eliminó la categoría "${categoryName}"`, + updateCategory: ({oldValue, categoryName}: UpdatedWorkspaceCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index 608eb1d10e52..47e1c51417df 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -288,6 +288,8 @@ type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; type UpdatedWorkspaceCurrencyParams = {oldCurrency: string; newCurrency: string}; +type UpdatedWorkspaceCategoryParams = {categoryName: string; oldValue?: boolean}; + type UpdatedWorkspaceFrequencyParams = {oldFrequency: string; newFrequency: string}; type ChangeTypeParams = {oldType: string; newType: string}; @@ -782,4 +784,5 @@ export type { ChatWithAccountManagerParams, UpdatedWorkspaceCurrencyParams, UpdatedWorkspaceFrequencyParams, + UpdatedWorkspaceCategoryParams, }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 067fb7e8aeca..fa0143f7ef0d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4868,16 +4868,33 @@ function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { }); } -function getWorkspaceAddCategoryMessage(action: ReportAction): string { - const {categoryName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; +function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { + const {categoryName, oldValue} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; if (!categoryName) { return ReportActionsUtils.getReportActionText(action); } - return Localize.translateLocal('workspaceActions.addCategory', { - categoryName, - }); + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { + return Localize.translateLocal('workspaceActions.addCategory', { + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) { + return Localize.translateLocal('workspaceActions.deleteCategory', { + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) { + return Localize.translateLocal('workspaceActions.updateCategory', { + oldValue: !!oldValue, + categoryName, + }); + } + + return ReportActionsUtils.getReportActionText(action); } /** @@ -8834,7 +8851,7 @@ export { getAllReportErrors, getAllReportActionsErrorsAndReportActionThatRequiresAttention, hasInvoiceReports, - getWorkspaceAddCategoryMessage, + getWorkspaceCategoryUpdateMessage, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index bce7cfacf524..e2910ae2f907 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -465,8 +465,11 @@ function getOptionData({ result.alternateText = ReportUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY)) { - result.alternateText = ReportUtils.getWorkspaceAddCategoryMessage(lastAction); + } else if ( + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) + ) { + result.alternateText = ReportUtils.getWorkspaceCategoryUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 523ec8362b52..5a69c434318b 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -420,8 +420,12 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(ReportUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { - Clipboard.setString(ReportUtils.getWorkspaceAddCategoryMessage(reportAction)); + } else if ( + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY + ) { + Clipboard.setString(ReportUtils.getWorkspaceCategoryUpdateMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index fd42a4910b9a..65d33203fff5 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -710,8 +710,12 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { children = ; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { - children = ; + } else if ( + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY + ) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 8788153d9dde..96f3ec5a6fec 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -295,6 +295,60 @@ type OriginalMessageChangeLog = { categoryName?: string; }; +/** Model of change log */ +type OriginalMessagePolicyChangeLog = { + /** Account IDs of users that either got invited or removed from the room */ + targetAccountIDs?: number[]; + + /** Name of the chat room */ + roomName?: string; + + /** Description of the chat room */ + description?: string; + + /** ID of the report */ + reportID?: number; + + /** Old name of the workspace */ + oldName?: string; + + /** New name of the workspace */ + newName?: string; + + /** Email of user */ + email?: string; + + /** Role of user */ + role?: string; + + /** When was it last modified */ + lastModified?: string; + + /** New Value */ + newValue?: boolean; + + /** Old Value */ + oldValue?: boolean; + + /** Old currency of the workspace */ + oldCurrency?: string; + + /** New currency of the workspace */ + newCurrency?: string; + + /** Old frequency of the workspace */ + oldFrequency?: ValueOf; + + /** New frequency of the workspace */ + newFrequency?: ValueOf; + + /** Name of connection */ + connectionName?: AllConnectionName; + + /** Name of the added category */ + categoryName?: string; +}; + /** Model of `join policy changelog` report action */ type OriginalMessageJoinPolicyChangeLog = { /** What was the invited user decision */ @@ -652,7 +706,7 @@ type OriginalMessageMap = { [CONST.REPORT.ACTIONS.TYPE.CARD_ASSIGNED]: OriginalMessageCard; [CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED]: OriginalMessageIntegrationSyncFailed; } & OldDotOriginalMessageMap & { - [T in ValueOf]: OriginalMessageChangeLog; + [T in ValueOf]: OriginalMessagePolicyChangeLog; } & { [T in ValueOf]: OriginalMessageChangeLog; }; From a2487bf5bae22195da05f25bb6016d9032e280a0 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 3 Dec 2024 08:02:21 +0530 Subject: [PATCH 04/17] minor fix. Signed-off-by: krishna2323 --- src/libs/SidebarUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index e2910ae2f907..d42e61638968 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -467,7 +467,8 @@ function getOptionData({ result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); } else if ( ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || - ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) ) { result.alternateText = ReportUtils.getWorkspaceCategoryUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { From bde1c30f7297cca5199389b486c7246cdb53bf19 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 9 Dec 2024 03:57:12 +0530 Subject: [PATCH 05/17] add translations form 'POLICYCHANGELOG_UPDATE_FIELD' & 'POLICYCHANGELOG_SET_CATEGORY_NAME'. Signed-off-by: krishna2323 --- src/CONST.ts | 8 +++++ src/languages/en.ts | 20 ++++++----- src/languages/es.ts | 19 ++++++----- src/languages/params.ts | 15 ++++---- src/libs/ReportActionsUtils.ts | 4 +-- src/libs/ReportUtils.ts | 34 ++++++++++++++----- src/libs/SidebarUtils.ts | 5 ++- .../report/ContextMenu/ContextMenuActions.tsx | 5 ++- src/pages/home/report/ReportActionItem.tsx | 5 ++- src/types/onyx/OriginalMessage.ts | 7 ++-- 10 files changed, 84 insertions(+), 38 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 44b2fd16f64c..cb78ebc3d5d1 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2490,6 +2490,14 @@ const CONST = { SMARTREPORT: 'SMARTREPORT', BILLCOM: 'BILLCOM', }, + APPROVAL_MODE_VALUES: { + OPTIONAL: 'Submit and Close', + BASIC: 'Submit and Approve', + ADVANCED: 'ADVANCED', + DYNAMICEXTERNAL: 'DYNAMIC_EXTERNAL', + SMARTREPORT: 'SMARTREPORT', + BILLCOM: 'BILLCOM', + }, ROOM_PREFIX: '#', CUSTOM_UNIT_RATE_BASE_OFFSET: 100, OWNER_EMAIL_FAKE: '_FAKE_', diff --git a/src/languages/en.ts b/src/languages/en.ts index 688929406363..2353f613fa3d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -166,11 +166,12 @@ import type { UnapproveWithIntegrationWarningParams, UnshareParams, UntilTimeParams, + UpdatedPolicyCategoryNameParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyFrequencyParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, - UpdatedWorkspaceCategoryParams, - UpdatedWorkspaceCurrencyParams, - UpdatedWorkspaceFrequencyParams, UpdateRoleParams, UsePlusButtonParams, UserIsAlreadyMemberParams, @@ -4451,9 +4452,10 @@ const translations = { }, }, workspaceActions: { - addCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `added the category "${categoryName}"`, - deleteCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `removed the category "${categoryName}"`, - updateCategory: ({oldValue, categoryName}: UpdatedWorkspaceCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, + addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `added the category "${categoryName}"`, + deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, + updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, + setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; @@ -4469,10 +4471,10 @@ const translations = { other: `removed you from ${joinedNames}'s approval workflows and workspace chats. Previously submitted reports will remain available for approval in your Inbox.`, }; }, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => - `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, updatedWorkspaceCorporatePlan: 'upgraded this workspace to the Control plan', + updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `updated the Approval Mode from "${oldValue}" to "${newValue}".`, }, roomMembersPage: { memberNotFound: 'Member not found.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 9f85a0e5f076..69a8e435d41a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -165,11 +165,12 @@ import type { UnapproveWithIntegrationWarningParams, UnshareParams, UntilTimeParams, + UpdatedPolicyCategoryNameParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyFrequencyParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, - UpdatedWorkspaceCategoryParams, - UpdatedWorkspaceCurrencyParams, - UpdatedWorkspaceFrequencyParams, UpdateRoleParams, UsePlusButtonParams, UserIsAlreadyMemberParams, @@ -4500,9 +4501,10 @@ const translations = { }, }, workspaceActions: { - addCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `agregó la categoría "${categoryName}"`, - deleteCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `eliminó la categoría "${categoryName}"`, - updateCategory: ({oldValue, categoryName}: UpdatedWorkspaceCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, + addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `agregó la categoría "${categoryName}"`, + deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, + updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, + setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; @@ -4518,10 +4520,11 @@ const translations = { other: `te eliminó de los flujos de trabajo de aprobaciones y de los chats del espacio de trabajo de ${joinedNames}. Los informes enviados anteriormente seguirán estando disponibles para su aprobación en tu bandeja de entrada.`, }; }, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, updatedWorkspaceCorporatePlan: 'mejoró este espacio de trabajo al plan Controlar', + updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `Actualizó el Modo de Aprobación de "${oldValue}" a "${newValue}".`, }, roomMembersPage: { memberNotFound: 'Miembro no encontrado.', diff --git a/src/languages/params.ts b/src/languages/params.ts index 47e1c51417df..c1b3bcc7b461 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -286,11 +286,13 @@ type ChangeFieldParams = {oldValue?: string; newValue: string; fieldName: string type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; -type UpdatedWorkspaceCurrencyParams = {oldCurrency: string; newCurrency: string}; +type UpdatedPolicyCurrencyParams = {oldCurrency: string; newCurrency: string}; -type UpdatedWorkspaceCategoryParams = {categoryName: string; oldValue?: boolean}; +type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; -type UpdatedWorkspaceFrequencyParams = {oldFrequency: string; newFrequency: string}; +type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; + +type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; type ChangeTypeParams = {oldType: string; newType: string}; @@ -782,7 +784,8 @@ export type { CompanyNameParams, CustomUnitRateParams, ChatWithAccountManagerParams, - UpdatedWorkspaceCurrencyParams, - UpdatedWorkspaceFrequencyParams, - UpdatedWorkspaceCategoryParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyFrequencyParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCategoryNameParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 8d828f457ece..ef1b5475bf49 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1710,8 +1710,8 @@ function getPolicyChangeLogChangeRoleMessage(reportAction: OnyxInputOrEntry) ?? {}; + const {categoryName, oldValue, newName, oldName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - if (!categoryName) { - return ReportActionsUtils.getReportActionText(action); - } - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY && categoryName) { return Localize.translateLocal('workspaceActions.addCategory', { categoryName, }); } - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY && categoryName) { return Localize.translateLocal('workspaceActions.deleteCategory', { categoryName, }); } - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY && categoryName) { return Localize.translateLocal('workspaceActions.updateCategory', { oldValue: !!oldValue, categoryName, }); } + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME && oldName && newName) { + return Localize.translateLocal('workspaceActions.setCategoryName', { + oldName, + newName, + }); + } + + return ReportActionsUtils.getReportActionText(action); +} + +function getWorkspaceUpdateFieldMessage(action: ReportAction): string { + const {newValue, oldValue, updatedField} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + + if (updatedField && updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && typeof newValue === 'string' && typeof oldValue === 'string') { + return Localize.translateLocal('workspaceActions.updateApprovalMode', { + oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ?? oldValue, + newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ?? newValue, + fieldName: updatedField, + }); + } + return ReportActionsUtils.getReportActionText(action); } @@ -8876,6 +8893,7 @@ export { hasInvoiceReports, getWorkspaceCategoryUpdateMessage, getReportMetadata, + getWorkspaceUpdateFieldMessage, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index d8c1a9234a27..aa1caf942fd4 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -471,7 +471,8 @@ function getOptionData({ } else if ( ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || - ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) || + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { result.alternateText = ReportUtils.getWorkspaceCategoryUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { @@ -490,6 +491,8 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { + result.alternateText = ReportUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 5a69c434318b..5d42e8f2525d 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -423,7 +423,8 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if ( reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { Clipboard.setString(ReportUtils.getWorkspaceCategoryUpdateMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { @@ -486,6 +487,8 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { + setClipboardMessage(ReportUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''}; setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage})); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 65d33203fff5..838b6442ea37 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -713,7 +713,8 @@ function ReportActionItem({ } else if ( action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || - action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { @@ -722,6 +723,8 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { + children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; } else if ( diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 96f3ec5a6fec..a4c550b33d20 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -325,10 +325,10 @@ type OriginalMessagePolicyChangeLog = { lastModified?: string; /** New Value */ - newValue?: boolean; + newValue?: boolean | string; /** Old Value */ - oldValue?: boolean; + oldValue?: boolean | string; /** Old currency of the workspace */ oldCurrency?: string; @@ -347,6 +347,9 @@ type OriginalMessagePolicyChangeLog = { /** Name of the added category */ categoryName?: string; + + /** Name of the updated field */ + updatedField?: string; }; /** Model of `join policy changelog` report action */ From 2e7cd0f0e9f25f41c58c27f4ccfe3555c20ff8f4 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 9 Dec 2024 03:58:25 +0530 Subject: [PATCH 06/17] minor update. Signed-off-by: krishna2323 --- src/types/onyx/OriginalMessage.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index a4c550b33d20..a27c5737110c 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -276,18 +276,6 @@ type OriginalMessageChangeLog = { /** Old role of user */ oldValue?: string; - /** Old currency of the workspace */ - oldCurrency?: string; - - /** New currency of the workspace */ - newCurrency?: string; - - /** Old frequency of the workspace */ - oldFrequency?: ValueOf; - - /** New frequency of the workspace */ - newFrequency?: ValueOf; - /** Name of connection */ connectionName?: AllConnectionName; From 5eb19d9f5b0a2dbd22c6dc6abb0a2a965f80f81d Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 9 Dec 2024 04:17:27 +0530 Subject: [PATCH 07/17] minor update. Signed-off-by: krishna2323 --- src/libs/ReportUtils.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e42aaa281d33..1e7409497554 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4903,10 +4903,15 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { function getWorkspaceUpdateFieldMessage(action: ReportAction): string { const {newValue, oldValue, updatedField} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - if (updatedField && updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && typeof newValue === 'string' && typeof oldValue === 'string') { + if ( + updatedField && + updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && + CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] && + CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] + ) { return Localize.translateLocal('workspaceActions.updateApprovalMode', { - oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ?? oldValue, - newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ?? newValue, + oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], + newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], fieldName: updatedField, }); } From 2e277b751b80afd6bbd1780bd82f41b5ffc6c2e6 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 9 Dec 2024 04:35:39 +0530 Subject: [PATCH 08/17] move action messages util function to ReportActionsUtils.ts. Signed-off-by: krishna2323 --- src/libs/ReportActionsUtils.ts | 102 +++++++++++++++++ src/libs/ReportUtils.ts | 103 ------------------ src/libs/SidebarUtils.ts | 10 +- .../report/ContextMenu/ContextMenuActions.tsx | 10 +- src/pages/home/report/ReportActionItem.tsx | 12 +- 5 files changed, 119 insertions(+), 118 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index ef1b5475bf49..9251301d69d2 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1721,6 +1721,103 @@ function isPolicyChangeLogDeleteMemberMessage( return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE); } +function getWorkspaceNameUpdatedMessage(action: ReportAction) { + const {oldName, newName} = getOriginalMessage(action as ReportAction) ?? {}; + const message = oldName && newName ? Localize.translateLocal('workspaceActions.renamedWorkspaceNameAction', {oldName, newName}) : getReportActionText(action); + return message; +} + +function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { + const {oldCurrency, newCurrency} = getOriginalMessage(action as ReportAction) ?? {}; + const message = oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : getReportActionText(action); + return message; +} + +type AutoReportingFrequencyKey = ValueOf; +type AutoReportingFrequencyDisplayNames = Record; + +const getAutoReportingFrequencyDisplayNames = (): AutoReportingFrequencyDisplayNames => ({ + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.monthly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: Localize.translateLocal('workflowsPage.frequencies.daily'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: Localize.translateLocal('workflowsPage.frequencies.weekly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.twiceAMonth'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: Localize.translateLocal('workflowsPage.frequencies.byTrip'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: Localize.translateLocal('workflowsPage.frequencies.manually'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: Localize.translateLocal('workflowsPage.frequencies.instant'), +}); + +function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { + const {oldFrequency, newFrequency} = getOriginalMessage(action as ReportAction) ?? {}; + + if (!oldFrequency || !newFrequency) { + return getReportActionText(action); + } + + const frequencyDisplayNames = getAutoReportingFrequencyDisplayNames(); + const oldFrequencyTranslation = frequencyDisplayNames[oldFrequency]?.toLowerCase(); + const newFrequencyTranslation = frequencyDisplayNames[newFrequency]?.toLowerCase(); + + if (!oldFrequencyTranslation || !newFrequencyTranslation) { + return getReportActionText(action); + } + + return Localize.translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { + oldFrequency: oldFrequencyTranslation, + newFrequency: newFrequencyTranslation, + }); +} + +function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { + const {categoryName, oldValue, newName, oldName} = getOriginalMessage(action as ReportAction) ?? {}; + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY && categoryName) { + return Localize.translateLocal('workspaceActions.addCategory', { + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY && categoryName) { + return Localize.translateLocal('workspaceActions.deleteCategory', { + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY && categoryName) { + return Localize.translateLocal('workspaceActions.updateCategory', { + oldValue: !!oldValue, + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME && oldName && newName) { + return Localize.translateLocal('workspaceActions.setCategoryName', { + oldName, + newName, + }); + } + + return getReportActionText(action); +} + +function getWorkspaceUpdateFieldMessage(action: ReportAction): string { + const {newValue, oldValue, updatedField} = getOriginalMessage(action as ReportAction) ?? {}; + + if ( + updatedField && + updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && + CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] && + CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] + ) { + return Localize.translateLocal('workspaceActions.updateApprovalMode', { + oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], + newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], + fieldName: updatedField, + }); + } + + return getReportActionText(action); +} + function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogDeleteMemberMessage(reportAction)) { return ''; @@ -1960,6 +2057,11 @@ export { getActionableJoinRequestPendingReportAction, getReportActionsLength, wasActionCreatedWhileOffline, + getWorkspaceCategoryUpdateMessage, + getWorkspaceUpdateFieldMessage, + getWorkspaceNameUpdatedMessage, + getWorkspaceCurrencyUpdateMessage, + getWorkspaceFrequencyUpdateMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 1e7409497554..72dff3aa0eff 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4821,104 +4821,6 @@ function getRejectedReportMessage() { return Localize.translateLocal('iou.rejectedThisReport'); } -function getWorkspaceNameUpdatedMessage(action: ReportAction) { - const {oldName, newName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - const message = oldName && newName ? Localize.translateLocal('workspaceActions.renamedWorkspaceNameAction', {oldName, newName}) : ReportActionsUtils.getReportActionText(action); - return message; -} - -function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { - const {oldCurrency, newCurrency} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - const message = - oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : ReportActionsUtils.getReportActionText(action); - return message; -} - -type AutoReportingFrequencyKey = ValueOf; -type AutoReportingFrequencyDisplayNames = Record; - -const getAutoReportingFrequencyDisplayNames = (): AutoReportingFrequencyDisplayNames => ({ - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.monthly'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: Localize.translateLocal('workflowsPage.frequencies.daily'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: Localize.translateLocal('workflowsPage.frequencies.weekly'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.twiceAMonth'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: Localize.translateLocal('workflowsPage.frequencies.byTrip'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: Localize.translateLocal('workflowsPage.frequencies.manually'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: Localize.translateLocal('workflowsPage.frequencies.instant'), -}); - -function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { - const {oldFrequency, newFrequency} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - - if (!oldFrequency || !newFrequency) { - return ReportActionsUtils.getReportActionText(action); - } - - const frequencyDisplayNames = getAutoReportingFrequencyDisplayNames(); - const oldFrequencyTranslation = frequencyDisplayNames[oldFrequency]?.toLowerCase(); - const newFrequencyTranslation = frequencyDisplayNames[newFrequency]?.toLowerCase(); - - if (!oldFrequencyTranslation || !newFrequencyTranslation) { - return ReportActionsUtils.getReportActionText(action); - } - - return Localize.translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { - oldFrequency: oldFrequencyTranslation, - newFrequency: newFrequencyTranslation, - }); -} - -function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { - const {categoryName, oldValue, newName, oldName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.addCategory', { - categoryName, - }); - } - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.deleteCategory', { - categoryName, - }); - } - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.updateCategory', { - oldValue: !!oldValue, - categoryName, - }); - } - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME && oldName && newName) { - return Localize.translateLocal('workspaceActions.setCategoryName', { - oldName, - newName, - }); - } - - return ReportActionsUtils.getReportActionText(action); -} - -function getWorkspaceUpdateFieldMessage(action: ReportAction): string { - const {newValue, oldValue, updatedField} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - - if ( - updatedField && - updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && - CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] && - CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] - ) { - return Localize.translateLocal('workspaceActions.updateApprovalMode', { - oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], - newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], - fieldName: updatedField, - }); - } - - return ReportActionsUtils.getReportActionText(action); -} - /** * @param iouReportID - the report ID of the IOU report the action belongs to * @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) @@ -8671,9 +8573,6 @@ export { getReportAutomaticallyForwardedMessage, getIOUForwardedMessage, getRejectedReportMessage, - getWorkspaceNameUpdatedMessage, - getWorkspaceCurrencyUpdateMessage, - getWorkspaceFrequencyUpdateMessage, getReportAutomaticallySubmittedMessage, getIOUSubmittedMessage, getIcons, @@ -8896,9 +8795,7 @@ export { getAllReportErrors, getAllReportActionsErrorsAndReportActionThatRequiresAttention, hasInvoiceReports, - getWorkspaceCategoryUpdateMessage, getReportMetadata, - getWorkspaceUpdateFieldMessage, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index aa1caf942fd4..0ef1b14da066 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -461,11 +461,11 @@ function getOptionData({ } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) { result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`; } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { - result.alternateText = ReportUtils.getWorkspaceNameUpdatedMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceNameUpdatedMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { - result.alternateText = ReportUtils.getWorkspaceCurrencyUpdateMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { - result.alternateText = ReportUtils.getWorkspaceFrequencyUpdateMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); } else if ( @@ -474,7 +474,7 @@ function getOptionData({ ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) || ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { - result.alternateText = ReportUtils.getWorkspaceCategoryUpdateMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { @@ -492,7 +492,7 @@ function getOptionData({ } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - result.alternateText = ReportUtils.getWorkspaceUpdateFieldMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 5d42e8f2525d..e59bd6a17f48 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -413,11 +413,11 @@ const ContextMenuActions: ContextMenuAction[] = [ const logMessage = ReportActionsUtils.getMemberChangeMessageFragment(reportAction).html ?? ''; setClipboardMessage(logMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { - Clipboard.setString(ReportUtils.getWorkspaceNameUpdatedMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getWorkspaceNameUpdatedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - Clipboard.setString(ReportUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - Clipboard.setString(ReportUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); } else if ( @@ -426,7 +426,7 @@ const ContextMenuActions: ContextMenuAction[] = [ reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { - Clipboard.setString(ReportUtils.getWorkspaceCategoryUpdateMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { @@ -488,7 +488,7 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - setClipboardMessage(ReportUtils.getWorkspaceUpdateFieldMessage(reportAction)); + setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''}; setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage})); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 838b6442ea37..8f96cd3227bc 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -703,11 +703,11 @@ function ReportActionItem({ } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { children = ; } else if ( @@ -716,7 +716,7 @@ function ReportActionItem({ action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { @@ -724,9 +724,11 @@ function ReportActionItem({ } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { - children = ; + children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { + children = ; } else if ( ReportActionsUtils.isActionOfType( action, From 1e8fc36b5b860e736b756fdfcef2b8c506e5dc5e Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sat, 14 Dec 2024 16:00:32 +0530 Subject: [PATCH 09/17] fix merge conflicts. Signed-off-by: krishna2323 --- src/languages/en.ts | 1 - src/languages/es.ts | 1 - src/pages/home/report/ReportActionItem.tsx | 1118 +------------------- 3 files changed, 50 insertions(+), 1070 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 2353f613fa3d..d4a6c0027c65 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4456,7 +4456,6 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, - renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/languages/es.ts b/src/languages/es.ts index 69a8e435d41a..0fff9ee2acb8 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4505,7 +4505,6 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, - renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 8f96cd3227bc..1887bf9d348a 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -1,170 +1,20 @@ -import lodashIsEqual from 'lodash/isEqual'; -import React, {memo, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; -import type {GestureResponderEvent, TextInput} from 'react-native'; -import {InteractionManager, View} from 'react-native'; -import type {OnyxEntry} from 'react-native-onyx'; +import React, {useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; -import type {Emoji} from '@assets/emojis/types'; -import {AttachmentContext} from '@components/AttachmentContext'; -import Button from '@components/Button'; -import DisplayNames from '@components/DisplayNames'; -import Hoverable from '@components/Hoverable'; -import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext'; -import Icon from '@components/Icon'; -import * as Expensicons from '@components/Icon/Expensicons'; -import InlineSystemMessage from '@components/InlineSystemMessage'; -import KYCWall from '@components/KYCWall'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import type {OnyxEntry} from 'react-native-onyx'; import {useBlockedFromConcierge, usePersonalDetails} from '@components/OnyxProvider'; -import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction'; -import ReportActionItemEmojiReactions from '@components/Reactions/ReportActionItemEmojiReactions'; -import RenderHTML from '@components/RenderHTML'; -import type {ActionableItem} from '@components/ReportActionItem/ActionableItemButtons'; -import ActionableItemButtons from '@components/ReportActionItem/ActionableItemButtons'; -import ChronosOOOListActions from '@components/ReportActionItem/ChronosOOOListActions'; -import ExportIntegration from '@components/ReportActionItem/ExportIntegration'; -import IssueCardMessage from '@components/ReportActionItem/IssueCardMessage'; -import MoneyRequestAction from '@components/ReportActionItem/MoneyRequestAction'; -import ReportPreview from '@components/ReportActionItem/ReportPreview'; -import TaskAction from '@components/ReportActionItem/TaskAction'; -import TaskPreview from '@components/ReportActionItem/TaskPreview'; -import TripRoomPreview from '@components/ReportActionItem/TripRoomPreview'; -import {ShowContextMenuContext} from '@components/ShowContextMenuContext'; -import Text from '@components/Text'; -import UnreadActionIndicator from '@components/UnreadActionIndicator'; -import useLocalize from '@hooks/useLocalize'; -import usePrevious from '@hooks/usePrevious'; -import useReportScrollManager from '@hooks/useReportScrollManager'; -import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useStyleUtils from '@hooks/useStyleUtils'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import ControlSelection from '@libs/ControlSelection'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as ErrorUtils from '@libs/ErrorUtils'; -import focusComposerWithDelay from '@libs/focusComposerWithDelay'; import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; -import Navigation from '@libs/Navigation/Navigation'; -import Permissions from '@libs/Permissions'; -import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; -import SelectionScraper from '@libs/SelectionScraper'; -import shouldRenderAddPaymentCard from '@libs/shouldRenderAppPaymentCard'; -import {ReactionListContext} from '@pages/home/ReportScreenContext'; -import * as BankAccounts from '@userActions/BankAccounts'; -import * as EmojiPickerAction from '@userActions/EmojiPickerAction'; -import * as Member from '@userActions/Policy/Member'; import * as Report from '@userActions/Report'; import * as ReportActions from '@userActions/ReportActions'; -import * as Session from '@userActions/Session'; import * as Transaction from '@userActions/Transaction'; -import * as User from '@userActions/User'; -import CONST from '@src/CONST'; +import type CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import type * as OnyxTypes from '@src/types/onyx'; -import type {JoinWorkspaceResolution} from '@src/types/onyx/OriginalMessage'; -import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import {RestrictedReadOnlyContextMenuActions} from './ContextMenu/ContextMenuActions'; -import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu'; -import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu'; -import {hideContextMenu} from './ContextMenu/ReportActionContextMenu'; -import LinkPreviewer from './LinkPreviewer'; -import ReportActionItemBasicMessage from './ReportActionItemBasicMessage'; -import ReportActionItemContentCreated from './ReportActionItemContentCreated'; -import ReportActionItemDraft from './ReportActionItemDraft'; -import ReportActionItemGrouped from './ReportActionItemGrouped'; -import ReportActionItemMessage from './ReportActionItemMessage'; -import ReportActionItemMessageEdit from './ReportActionItemMessageEdit'; -import ReportActionItemSingle from './ReportActionItemSingle'; -import ReportActionItemThread from './ReportActionItemThread'; -import ReportAttachmentsContext from './ReportAttachmentsContext'; - -type ReportActionItemProps = { - /** Report for this action */ - report: OnyxEntry; - - /** The transaction thread report associated with the report for this action, if any */ - transactionThreadReport?: OnyxEntry; - - /** Array of report actions for the report for this action */ - // eslint-disable-next-line react/no-unused-prop-types - reportActions: OnyxTypes.ReportAction[]; - - /** Report action belonging to the report's parent */ - parentReportAction: OnyxEntry; - - /** The transaction thread report's parentReportAction */ - /** It's used by withOnyx HOC */ - // eslint-disable-next-line react/no-unused-prop-types - parentReportActionForTransactionThread?: OnyxEntry; - - /** All the data of the action item */ - action: OnyxTypes.ReportAction; - - /** Should the comment have the appearance of being grouped with the previous comment? */ - displayAsGroup: boolean; - - /** Is this the most recent IOU Action? */ - isMostRecentIOUReportAction: boolean; - - /** Should we display the new marker on top of the comment? */ - shouldDisplayNewMarker: boolean; +import type {ReportAction} from '@src/types/onyx'; +import type {PureReportActionItemProps} from './PureReportActionItem'; +import PureReportActionItem from './PureReportActionItem'; - /** Determines if the avatar is displayed as a subscript (positioned lower than normal) */ - shouldShowSubscriptAvatar?: boolean; - - /** Position index of the report action in the overall report FlatList view */ - index: number; - - /** Flag to show, hide the thread divider line */ - shouldHideThreadDividerLine?: boolean; - - linkedReportActionID?: string; - - /** Callback to be called on onPress */ - onPress?: () => void; - - /** If this is the first visible report action */ - isFirstVisibleReportAction: boolean; - - /** - * Is the action a thread's parent reportAction viewed from within the thread report? - * It will be false if we're viewing the same parent report action from the report it belongs to rather than the thread. - */ - isThreadReportParentAction?: boolean; - - /** IF the thread divider line will be used */ - shouldUseThreadDividerLine?: boolean; - - /** Whether context menu should be displayed */ - shouldDisplayContextMenu?: boolean; -}; - -function ReportActionItem({ - action, - report, - transactionThreadReport, - linkedReportActionID, - displayAsGroup, - index, - isMostRecentIOUReportAction, - parentReportAction, - shouldDisplayNewMarker, - shouldHideThreadDividerLine = false, - shouldShowSubscriptAvatar = false, - onPress = undefined, - isFirstVisibleReportAction = false, - isThreadReportParentAction = false, - shouldUseThreadDividerLine = false, - shouldDisplayContextMenu = true, - parentReportActionForTransactionThread, -}: ReportActionItemProps) { - const {translate} = useLocalize(); - const {shouldUseNarrowLayout} = useResponsiveLayout(); - const blockedFromConcierge = useBlockedFromConcierge(); +function ReportActionItem({action, report, ...props}: PureReportActionItemProps) { const reportID = report?.reportID ?? ''; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const originalReportID = useMemo(() => ReportUtils.getOriginalReportID(reportID, action) || '-1', [reportID, action]); @@ -181,926 +31,58 @@ function ReportActionItem({ `${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID ?? -1 : -1}`, {selector: (transaction) => transaction?.errorFields?.route ?? null}, ); - const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID); - const theme = useTheme(); - const styles = useThemeStyles(); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- This is needed to prevent the app from crashing when the app is using imported state. const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || '-1'}`); - const StyleUtils = useStyleUtils(); - const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; - const [isContextMenuActive, setIsContextMenuActive] = useState(() => ReportActionContextMenu.isActiveReportAction(action.reportActionID)); - const [isEmojiPickerActive, setIsEmojiPickerActive] = useState(); - const [isPaymentMethodPopoverActive, setIsPaymentMethodPopoverActive] = useState(); - const [isHidden, setIsHidden] = useState(false); - const [moderationDecision, setModerationDecision] = useState(CONST.MODERATION.MODERATOR_DECISION_APPROVED); - const reactionListRef = useContext(ReactionListContext); - const {updateHiddenAttachments} = useContext(ReportAttachmentsContext); - const textInputRef = useRef(null); - const popoverAnchorRef = useRef>(null); - const downloadedPreviews = useRef([]); - const prevDraftMessage = usePrevious(draftMessage); const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated}); // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || -1}`); - const isReportActionLinked = linkedReportActionID && action.reportActionID && linkedReportActionID === action.reportActionID; - const reportScrollManager = useReportScrollManager(); - const isActionableWhisper = - ReportActionsUtils.isActionableMentionWhisper(action) || ReportActionsUtils.isActionableTrackExpense(action) || ReportActionsUtils.isActionableReportMentionWhisper(action); - const originalMessage = ReportActionsUtils.getOriginalMessage(action); - - const highlightedBackgroundColorIfNeeded = useMemo( - () => (isReportActionLinked ? StyleUtils.getBackgroundColorStyle(theme.messageHighlightBG) : {}), - [StyleUtils, isReportActionLinked, theme.messageHighlightBG], - ); - - const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); - const isOriginalMessageAnObject = originalMessage && typeof originalMessage === 'object'; - const hasResolutionInOriginalMessage = isOriginalMessageAnObject && 'resolution' in originalMessage; - const prevActionResolution = usePrevious(isActionableWhisper && hasResolutionInOriginalMessage ? originalMessage?.resolution : null); - - // IOUDetails only exists when we are sending money - const isSendingMoney = - ReportActionsUtils.isMoneyRequestAction(action) && - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && - ReportActionsUtils.getOriginalMessage(action)?.IOUDetails; - - const updateHiddenState = useCallback( - (isHiddenValue: boolean) => { - setIsHidden(isHiddenValue); - const message = Array.isArray(action.message) ? action.message?.at(-1) : action.message; - const isAttachment = ReportUtils.isReportMessageAttachment(message); - if (!isAttachment) { - return; - } - updateHiddenAttachments(action.reportActionID, isHiddenValue); - }, - [action.reportActionID, action.message, updateHiddenAttachments], - ); - - useEffect( - () => () => { - // ReportActionContextMenu, EmojiPicker and PopoverReactionList are global components, - // we should also hide them when the current component is destroyed - if (ReportActionContextMenu.isActiveReportAction(action.reportActionID)) { - ReportActionContextMenu.hideContextMenu(); - ReportActionContextMenu.hideDeleteModal(); - } - if (EmojiPickerAction.isActive(action.reportActionID)) { - EmojiPickerAction.hideEmojiPicker(true); - } - if (reactionListRef?.current?.isActiveReportAction(action.reportActionID)) { - reactionListRef?.current?.hideReactionList(); - } - }, - [action.reportActionID, reactionListRef], - ); - - useEffect(() => { - // We need to hide EmojiPicker when this is a deleted parent action - if (!isDeletedParentAction || !EmojiPickerAction.isActive(action.reportActionID)) { - return; - } - - EmojiPickerAction.hideEmojiPicker(true); - }, [isDeletedParentAction, action.reportActionID]); - - useEffect(() => { - if (prevDraftMessage !== undefined || draftMessage === undefined) { - return; - } - - focusComposerWithDelay(textInputRef.current)(true); - }, [prevDraftMessage, draftMessage]); - - useEffect(() => { - if (!Permissions.canUseLinkPreviews()) { - return; - } - - const urls = ReportActionsUtils.extractLinksFromMessageHtml(action); - if (lodashIsEqual(downloadedPreviews.current, urls) || action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { - return; - } - - downloadedPreviews.current = urls; - Report.expandURLPreview(reportID, action.reportActionID); - }, [action, reportID]); - - useEffect(() => { - if (draftMessage === undefined || !ReportActionsUtils.isDeletedAction(action)) { - return; - } - Report.deleteReportActionDraft(reportID, action); - }, [draftMessage, action, reportID]); - - // Hide the message if it is being moderated for a higher offense, or is hidden by a moderator - // Removed messages should not be shown anyway and should not need this flow - const latestDecision = ReportActionsUtils.getReportActionMessage(action)?.moderationDecision?.decision ?? ''; - useEffect(() => { - if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT) { - return; - } - - // Hide reveal message button and show the message if latestDecision is changed to empty - if (!latestDecision) { - setModerationDecision(CONST.MODERATION.MODERATOR_DECISION_APPROVED); - setIsHidden(false); - return; - } - - setModerationDecision(latestDecision); - if ( - ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && - !ReportActionsUtils.isPendingRemove(action) - ) { - setIsHidden(true); - return; - } - setIsHidden(false); - }, [latestDecision, action]); - - const toggleContextMenuFromActiveReportAction = useCallback(() => { - setIsContextMenuActive(ReportActionContextMenu.isActiveReportAction(action.reportActionID)); - }, [action.reportActionID]); - - const isArchivedRoom = ReportUtils.isArchivedRoomWithID(originalReportID); - const disabledActions = useMemo(() => (!ReportUtils.canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]); - const isChronosReport = ReportUtils.chatIncludesChronosWithID(originalReportID); - /** - * Show the ReportActionContextMenu modal popover. - * - * @param [event] - A press event. - */ - const showPopover = useCallback( - (event: GestureResponderEvent | MouseEvent) => { - // Block menu on the message being Edited or if the report action item has errors - if (draftMessage !== undefined || !isEmptyObject(action.errors) || !shouldDisplayContextMenu) { - return; - } - - setIsContextMenuActive(true); - const selection = SelectionScraper.getCurrentSelection(); - ReportActionContextMenu.showContextMenu( - CONST.CONTEXT_MENU_TYPES.REPORT_ACTION, - event, - selection, - popoverAnchorRef.current, - reportID, - action.reportActionID, - originalReportID, - draftMessage ?? '', - () => setIsContextMenuActive(true), - toggleContextMenuFromActiveReportAction, - isArchivedRoom, - isChronosReport, - false, - false, - disabledActions, - false, - setIsEmojiPickerActive as () => void, - undefined, - isThreadReportParentAction, - ); - }, - [ - draftMessage, - action, - reportID, - toggleContextMenuFromActiveReportAction, - originalReportID, - shouldDisplayContextMenu, - disabledActions, - isArchivedRoom, - isChronosReport, - isThreadReportParentAction, - ], - ); - - // Handles manual scrolling to the bottom of the chat when the last message is an actionable whisper and it's resolved. - // This fixes an issue where InvertedFlatList fails to auto scroll down and results in an empty space at the bottom of the chat in IOS. - useEffect(() => { - if (index !== 0 || !isActionableWhisper) { - return; - } - - if (prevActionResolution !== (hasResolutionInOriginalMessage ? originalMessage.resolution : null)) { - reportScrollManager.scrollToIndex(index); - } - }, [index, originalMessage, prevActionResolution, reportScrollManager, isActionableWhisper, hasResolutionInOriginalMessage]); - - const toggleReaction = useCallback( - (emoji: Emoji, ignoreSkinToneOnCompare?: boolean) => { - Report.toggleEmojiReaction(reportID, action, emoji, emojiReactions, undefined, ignoreSkinToneOnCompare); - }, - [reportID, action, emojiReactions], - ); - - const contextValue = useMemo( - () => ({ - anchor: popoverAnchorRef.current, - report: {...report, reportID: report?.reportID ?? ''}, - reportNameValuePairs, - action, - transactionThreadReport, - checkIfContextMenuActive: toggleContextMenuFromActiveReportAction, - isDisabled: false, - }), - [report, action, toggleContextMenuFromActiveReportAction, transactionThreadReport, reportNameValuePairs], - ); - - const attachmentContextValue = useMemo(() => ({reportID, type: CONST.ATTACHMENT_TYPE.REPORT}), [reportID]); - - const mentionReportContextValue = useMemo(() => ({currentReportID: report?.reportID ?? '-1'}), [report?.reportID]); - - const actionableItemButtons: ActionableItem[] = useMemo(() => { - if (ReportActionsUtils.isActionableAddPaymentCard(action) && userBillingFundID === undefined && shouldRenderAddPaymentCard()) { - return [ - { - text: 'subscription.cardSection.addCardButton', - key: `${action.reportActionID}-actionableAddPaymentCard-submit`, - onPress: () => { - Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION_ADD_PAYMENT_CARD); - }, - isMediumSized: true, - isPrimary: true, - }, - ]; - } - - if (!isActionableWhisper && (!ReportActionsUtils.isActionableJoinRequest(action) || ReportActionsUtils.getOriginalMessage(action)?.choice !== ('' as JoinWorkspaceResolution))) { - return []; - } - - if (ReportActionsUtils.isActionableTrackExpense(action)) { - const transactionID = ReportActionsUtils.getOriginalMessage(action)?.transactionID; - return [ - { - text: 'actionableMentionTrackExpense.submit', - key: `${action.reportActionID}-actionableMentionTrackExpense-submit`, - onPress: () => { - ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID); - }, - isMediumSized: true, - }, - { - text: 'actionableMentionTrackExpense.categorize', - key: `${action.reportActionID}-actionableMentionTrackExpense-categorize`, - onPress: () => { - ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.CATEGORIZE, action.reportActionID); - }, - isMediumSized: true, - }, - { - text: 'actionableMentionTrackExpense.share', - key: `${action.reportActionID}-actionableMentionTrackExpense-share`, - onPress: () => { - ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.SHARE, action.reportActionID); - }, - isMediumSized: true, - }, - { - text: 'actionableMentionTrackExpense.nothing', - key: `${action.reportActionID}-actionableMentionTrackExpense-nothing`, - onPress: () => { - Report.dismissTrackExpenseActionableWhisper(reportID, action); - }, - isMediumSized: true, - }, - ]; - } - - if (ReportActionsUtils.isActionableJoinRequest(action)) { - return [ - { - text: 'actionableMentionJoinWorkspaceOptions.accept', - key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT}`, - onPress: () => Member.acceptJoinRequest(reportID, action), - isPrimary: true, - }, - { - text: 'actionableMentionJoinWorkspaceOptions.decline', - key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE}`, - onPress: () => Member.declineJoinRequest(reportID, action), - }, - ]; - } - - if (ReportActionsUtils.isActionableReportMentionWhisper(action)) { - return [ - { - text: 'common.yes', - key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE}`, - onPress: () => Report.resolveActionableReportMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE), - isPrimary: true, - }, - { - text: 'common.no', - key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING}`, - onPress: () => Report.resolveActionableReportMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING), - }, - ]; - } - - return [ - { - text: 'actionableMentionWhisperOptions.invite', - key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE}`, - onPress: () => Report.resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE), - isPrimary: true, - }, - { - text: 'actionableMentionWhisperOptions.nothing', - key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING}`, - onPress: () => Report.resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING), - }, - ]; - }, [action, isActionableWhisper, reportID, userBillingFundID]); - - /** - * Get the content of ReportActionItem - * @param hovered whether the ReportActionItem is hovered - * @param isWhisper whether the report action is a whisper - * @param hasErrors whether the report action has any errors - * @returns child component(s) - */ - const renderItemContent = (hovered = false, isWhisper = false, hasErrors = false): React.JSX.Element => { - let children; - - // Show the MoneyRequestPreview for when expense is present - if ( - ReportActionsUtils.isMoneyRequestAction(action) && - ReportActionsUtils.getOriginalMessage(action) && - // For the pay flow, we only want to show MoneyRequestAction when sending money. When paying, we display a regular system message - (ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE || - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT || - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) - ) { - // There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID - const iouReportID = ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ? ReportActionsUtils.getOriginalMessage(action)?.IOUReportID?.toString() ?? '-1' : '-1'; - children = ( - - ); - } else if (ReportActionsUtils.isTripPreview(action)) { - children = ( - - ); - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) { - children = ReportUtils.isClosedExpenseReportWithNoExpenses(iouReport) ? ( - ${translate('parentReportAction.deletedReport')}`} /> - ) : ( - setIsPaymentMethodPopoverActive(true)} - onPaymentOptionsHide={() => setIsPaymentMethodPopoverActive(false)} - isWhisper={isWhisper} - /> - ); - } else if (ReportActionsUtils.isTaskAction(action)) { - children = ; - } else if (ReportActionsUtils.isCreatedTaskReportAction(action)) { - children = ( - - - - ); - } else if (ReportActionsUtils.isReimbursementQueuedAction(action)) { - const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; - const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails[linkedReport?.ownerAccountID ?? -1]); - const paymentType = ReportActionsUtils.getOriginalMessage(action)?.paymentType ?? ''; - - const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID ?? '-1', action); - children = ( - - <> - {missingPaymentMethod === 'bankAccount' && ( - - )} - {/** - These are the actionable buttons that appear at the bottom of a Concierge message - for example: Invite a user mentioned but not a member of the room - https://github.com/Expensify/App/issues/32741 - */} - {actionableItemButtons.length > 0 && ( - - )} - - ) : ( - - )} - - - - ); - } - const numberOfThreadReplies = action.childVisibleActionCount ?? 0; - - const shouldDisplayThreadReplies = ReportUtils.shouldDisplayThreadReplies(action, isThreadReportParentAction); - const oldestFourAccountIDs = - action.childOldestFourAccountIDs - ?.split(',') - .map((accountID) => Number(accountID)) - .filter((accountID): accountID is number => typeof accountID === 'number') ?? []; - const draftMessageRightAlign = draftMessage !== undefined ? styles.chatItemReactionsDraftRight : {}; - - return ( - <> - {children} - {Permissions.canUseLinkPreviews() && !isHidden && (action.linkMetadata?.length ?? 0) > 0 && ( - - !isEmptyObject(item))} /> - - )} - {!ReportActionsUtils.isMessageDeleted(action) && ( - - { - if (Session.isAnonymousUser()) { - hideContextMenu(false); - - InteractionManager.runAfterInteractions(() => { - Session.signOutAndRedirectToSignIn(); - }); - } else { - toggleReaction(emoji, ignoreSkinToneOnCompare); - } - }} - setIsEmojiPickerActive={setIsEmojiPickerActive} - /> - - )} - - {shouldDisplayThreadReplies && ( - - - - )} - - ); - }; - - /** - * Get ReportActionItem with a proper wrapper - * @param hovered whether the ReportActionItem is hovered - * @param isWhisper whether the ReportActionItem is a whisper - * @param hasErrors whether the report action has any errors - * @returns report action item - */ - - const renderReportActionItem = (hovered: boolean, isWhisper: boolean, hasErrors: boolean): React.JSX.Element => { - const content = renderItemContent(hovered || isContextMenuActive || isEmojiPickerActive, isWhisper, hasErrors); - - if (draftMessage !== undefined) { - return {content}; - } - - if (!displayAsGroup) { - return ( - item === moderationDecision) && - !ReportActionsUtils.isPendingRemove(action) - } - > - {content} - - ); - } - - return {content}; - }; - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { - const transactionID = ReportActionsUtils.isMoneyRequestAction(parentReportActionForTransactionThread) - ? ReportActionsUtils.getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID - : '-1'; - - return ( - - ); - } - if (ReportActionsUtils.isChronosOOOListAction(action)) { - return ( - - ); - } - - // For the `pay` IOU action on non-pay expense flow, we don't want to render anything if `isWaitingOnBankAccount` is true - // Otherwise, we will see two system messages informing the payee needs to add a bank account or wallet - if ( - ReportActionsUtils.isMoneyRequestAction(action) && - !!report?.isWaitingOnBankAccount && - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && - !isSendingMoney - ) { - return null; - } - - // If action is actionable whisper and resolved by user, then we don't want to render anything - if (isActionableWhisper && (hasResolutionInOriginalMessage ? originalMessage.resolution : null)) { - return null; - } - - // We currently send whispers to all report participants and hide them in the UI for users that shouldn't see them. - // This is a temporary solution needed for comment-linking. - // The long term solution will leverage end-to-end encryption and only targeted users will be able to decrypt. - if (ReportActionsUtils.isWhisperActionTargetedToOthers(action)) { - return null; - } - - const hasErrors = !isEmptyObject(action.errors); - const whisperedTo = ReportActionsUtils.getWhisperedTo(action); - const isMultipleParticipant = whisperedTo.length > 1; - - const iouReportID = - ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUReportID - ? (ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ?? '').toString() - : '-1'; - const transactionsWithReceipts = ReportUtils.getTransactionsWithReceipts(iouReportID); - const isWhisper = whisperedTo.length > 0 && transactionsWithReceipts.length === 0; - const whisperedToPersonalDetails = isWhisper - ? (Object.values(personalDetails ?? {}).filter((details) => whisperedTo.includes(details?.accountID ?? -1)) as OnyxTypes.PersonalDetails[]) - : []; - const isWhisperOnlyVisibleByUser = isWhisper && ReportUtils.isCurrentUserTheOnlyParticipant(whisperedTo); - const displayNamesWithTooltips = isWhisper ? ReportUtils.getDisplayNamesWithTooltips(whisperedToPersonalDetails, isMultipleParticipant) : []; + const personalDetails = usePersonalDetails(); + const blockedFromConcierge = useBlockedFromConcierge(); + const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID); + const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; + const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID ?? '-1', action); return ( - shouldUseNarrowLayout && DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} - onPressOut={() => ControlSelection.unblock()} - onSecondaryInteraction={showPopover} - preventDefaultContextMenu={draftMessage === undefined && !hasErrors} - withoutFocusOnSecondaryInteraction - accessibilityLabel={translate('accessibilityHints.chatMessage')} - accessible - > - - {(hovered) => ( - - {shouldDisplayNewMarker && (!shouldUseThreadDividerLine || !isFirstVisibleReportAction) && } - {shouldDisplayContextMenu && ( - - )} - - { - const transactionID = ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID : undefined; - if (transactionID) { - Transaction.clearError(transactionID); - } - ReportActions.clearAllRelatedReportActionErrors(reportID, action); - }} - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - pendingAction={ - draftMessage !== undefined ? undefined : action.pendingAction ?? (action.isOptimisticAction ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : undefined) - } - shouldHideOnDelete={!ReportActionsUtils.isThreadParentMessage(action, reportID)} - errors={linkedTransactionRouteError ?? ErrorUtils.getLatestErrorMessageField(action as ErrorUtils.OnyxDataWithErrors)} - errorRowStyles={[styles.ml10, styles.mr2]} - needsOffscreenAlphaCompositing={ReportActionsUtils.isMoneyRequestAction(action)} - shouldDisableStrikeThrough - > - {isWhisper && ( - - - - - - {translate('reportActionContextMenu.onlyVisible')} -   - - - - )} - {renderReportActionItem(!!hovered || !!isReportActionLinked, isWhisper, hasErrors)} - - - - )} - - - - - + >, + report, + )} + modifiedExpenseMessage={ModifiedExpenseMessage.getForReportAction(reportID, action)} + getTransactionsWithReceipts={ReportUtils.getTransactionsWithReceipts} + clearError={Transaction.clearError} + clearAllRelatedReportActionErrors={ReportActions.clearAllRelatedReportActionErrors} + dismissTrackExpenseActionableWhisper={Report.dismissTrackExpenseActionableWhisper} + userBillingFundID={userBillingFundID} + reportAutomaticallyForwardedMessage={ReportUtils.getReportAutomaticallyForwardedMessage(action as ReportAction, reportID)} + /> ); } -export default memo(ReportActionItem, (prevProps, nextProps) => { - const prevParentReportAction = prevProps.parentReportAction; - const nextParentReportAction = nextProps.parentReportAction; - return ( - prevProps.displayAsGroup === nextProps.displayAsGroup && - prevProps.isMostRecentIOUReportAction === nextProps.isMostRecentIOUReportAction && - prevProps.shouldDisplayNewMarker === nextProps.shouldDisplayNewMarker && - lodashIsEqual(prevProps.action, nextProps.action) && - lodashIsEqual(prevProps.report?.pendingFields, nextProps.report?.pendingFields) && - lodashIsEqual(prevProps.report?.isDeletedParentAction, nextProps.report?.isDeletedParentAction) && - lodashIsEqual(prevProps.report?.errorFields, nextProps.report?.errorFields) && - prevProps.report?.statusNum === nextProps.report?.statusNum && - prevProps.report?.stateNum === nextProps.report?.stateNum && - prevProps.report?.parentReportID === nextProps.report?.parentReportID && - prevProps.report?.parentReportActionID === nextProps.report?.parentReportActionID && - // TaskReport's created actions render the TaskView, which updates depending on certain fields in the TaskReport - ReportUtils.isTaskReport(prevProps.report) === ReportUtils.isTaskReport(nextProps.report) && - prevProps.action.actionName === nextProps.action.actionName && - prevProps.report?.reportName === nextProps.report?.reportName && - prevProps.report?.description === nextProps.report?.description && - ReportUtils.isCompletedTaskReport(prevProps.report) === ReportUtils.isCompletedTaskReport(nextProps.report) && - prevProps.report?.managerID === nextProps.report?.managerID && - prevProps.shouldHideThreadDividerLine === nextProps.shouldHideThreadDividerLine && - prevProps.report?.total === nextProps.report?.total && - prevProps.report?.nonReimbursableTotal === nextProps.report?.nonReimbursableTotal && - prevProps.report?.policyAvatar === nextProps.report?.policyAvatar && - prevProps.linkedReportActionID === nextProps.linkedReportActionID && - lodashIsEqual(prevProps.report?.fieldList, nextProps.report?.fieldList) && - lodashIsEqual(prevProps.transactionThreadReport, nextProps.transactionThreadReport) && - lodashIsEqual(prevProps.reportActions, nextProps.reportActions) && - lodashIsEqual(prevParentReportAction, nextParentReportAction) - ); -}); +export default ReportActionItem; From f086d7c2053f290006b7f65dbcc73d25c91057f5 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sat, 14 Dec 2024 16:22:52 +0530 Subject: [PATCH 10/17] update changes in PureReportActionItem. Signed-off-by: krishna2323 --- src/pages/home/report/PureReportActionItem.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 34dd2a9d1350..0194260ec667 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -818,13 +818,28 @@ function PureReportActionItem({ } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { - children = ; + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + children = ; + } else if ( + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME + ) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { + children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; } else if ( From 404a38254abe4a7ed5fadf4340fef0b0aaf2f103 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Dec 2024 08:52:50 +0530 Subject: [PATCH 11/17] add translation for UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT & PREVENT_SELF_APPROVAL change logs. Signed-off-by: krishna2323 --- src/CONST.ts | 3 +++ src/languages/en.ts | 6 +++++ src/languages/es.ts | 6 +++++ src/languages/params.ts | 6 +++++ src/libs/ReportActionsUtils.ts | 23 +++++++++++++++++++ src/libs/SidebarUtils.ts | 6 +++-- .../report/ContextMenu/ContextMenuActions.tsx | 6 +++-- .../home/report/PureReportActionItem.tsx | 6 +++-- src/types/onyx/OriginalMessage.ts | 9 ++++++++ 9 files changed, 65 insertions(+), 6 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 1feab5f29bd2..cbd54c9a4e5f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2581,6 +2581,9 @@ const CONST = { AUTOREPORTING_OFFSET: 'autoReportingOffset', GENERAL_SETTINGS: 'generalSettings', }, + EXPENSE_REPORT_RULES: { + PREVENT_SELF_APPROVAL: 'preventSelfApproval', + }, CONNECTIONS: { NAME: { // Here we will add other connections names when we add support for them diff --git a/src/languages/en.ts b/src/languages/en.ts index 04ad63113d8c..43b290dd9a68 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -170,6 +170,8 @@ import type { UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, UpdatedPolicyFrequencyParams, + UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -4467,6 +4469,10 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, + preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => + `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountNoReceiptParams) => + `changed the maximum receipt required expense amount from ${oldValue} to ${newValue}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/es.ts b/src/languages/es.ts index 0b6e2b29f186..43253f26bf25 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -169,6 +169,8 @@ import type { UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, UpdatedPolicyFrequencyParams, + UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -4516,6 +4518,10 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, + preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => + `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountNoReceiptParams) => + `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index a5603835aaba..4529fe3ebab2 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -292,6 +292,10 @@ type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; +type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; + +type UpdatedPolicyMaxExepenseAmountNoReceiptParams = {oldValue: string; newValue: string}; + type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; type ChangeTypeParams = {oldType: string; newType: string}; @@ -800,4 +804,6 @@ export type { UpdatedPolicyFrequencyParams, UpdatedPolicyCategoryParams, UpdatedPolicyCategoryNameParams, + UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyMaxExepenseAmountNoReceiptParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 6792228130d4..8dfaca55c929 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -16,6 +16,7 @@ import type ReportAction from '@src/types/onyx/ReportAction'; import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction'; import type ReportActionName from '@src/types/onyx/ReportActionName'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import * as CurrencyUtils from './CurrencyUtils'; import DateUtils from './DateUtils'; import * as Environment from './Environment/Environment'; import getBase62ReportID from './getBase62ReportID'; @@ -1830,6 +1831,27 @@ function getWorkspaceUpdateFieldMessage(action: ReportAction): string { }); } + if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.PREVENT_SELF_APPROVAL && typeof oldValue === 'string' && typeof newValue === 'string') { + return Localize.translateLocal('workspaceActions.preventSelfApproval', { + oldValue, + newValue, + }); + } + + return getReportActionText(action); +} + +function getPolicyChangeLogMaxAmmountNoReceiptMessage(action: ReportAction): string { + const {oldMaxExpenseAmountNoReceipt, newMaxExpenseAmountNoReceipt, currency} = + getOriginalMessage(action as ReportAction) ?? {}; + + if (typeof oldMaxExpenseAmountNoReceipt === 'number' && typeof newMaxExpenseAmountNoReceipt === 'number') { + return Localize.translateLocal('workspaceActions.updateMaxExpenseAmountNoReceipt', { + oldValue: CurrencyUtils.convertToDisplayString(oldMaxExpenseAmountNoReceipt, currency), + newValue: CurrencyUtils.convertToDisplayString(newMaxExpenseAmountNoReceipt, currency), + }); + } + return getReportActionText(action); } @@ -2077,6 +2099,7 @@ export { getWorkspaceNameUpdatedMessage, getWorkspaceCurrencyUpdateMessage, getWorkspaceFrequencyUpdateMessage, + getPolicyChangeLogMaxAmmountNoReceiptMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index d6ee1e51d5dc..80d7925a0344 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -476,6 +476,10 @@ function getOptionData({ ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { + result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { + result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxAmmountNoReceiptMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { @@ -492,8 +496,6 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction); - } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index f21a0fb2a347..9610c9c195a1 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -425,6 +425,10 @@ const ContextMenuActions: ContextMenuAction[] = [ reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { + setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxAmmountNoReceiptMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { @@ -485,8 +489,6 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(reportAction)); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''}; setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage})); diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 0194260ec667..f959eecae980 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -832,14 +832,16 @@ function PureReportActionItem({ action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { + children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { - children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; } else if ( diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 2d64e4c0b315..1600c95b1c07 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -338,6 +338,15 @@ type OriginalMessagePolicyChangeLog = { /** Name of the updated field */ updatedField?: string; + + /** Old value for max expense amount with no receipt */ + oldMaxExpenseAmountNoReceipt?: number; + + /** New value for max expense amount with no receipt */ + newMaxExpenseAmountNoReceipt?: number; + + /** Currency of the policy */ + currency?: string; }; /** Model of `join policy changelog` report action */ From a25ffafe25ae58f23b19747980dcaf96d70fea63 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Dec 2024 09:26:41 +0530 Subject: [PATCH 12/17] add translations form UPDATE_MAX_EXPENSE_AMOUNT & MAX_EXPENSE_AGE. Signed-off-by: krishna2323 --- src/CONST.ts | 1 + src/languages/en.ts | 7 +++-- src/languages/es.ts | 8 +++--- src/languages/params.ts | 4 +-- src/libs/ReportActionsUtils.ts | 26 +++++++++++++++++-- src/libs/SidebarUtils.ts | 4 ++- .../report/ContextMenu/ContextMenuActions.tsx | 4 ++- .../home/report/PureReportActionItem.tsx | 4 ++- src/types/onyx/OriginalMessage.ts | 6 +++++ 9 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index cbd54c9a4e5f..397b4fe905f1 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2583,6 +2583,7 @@ const CONST = { }, EXPENSE_REPORT_RULES: { PREVENT_SELF_APPROVAL: 'preventSelfApproval', + MAX_EXPENSE_AGE: 'maxExpenseAge', }, CONNECTIONS: { NAME: { diff --git a/src/languages/en.ts b/src/languages/en.ts index 43b290dd9a68..4a8074f41adf 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -170,7 +170,7 @@ import type { UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, UpdatedPolicyFrequencyParams, - UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyMaxExepenseAmountParams, UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, @@ -4471,8 +4471,11 @@ const translations = { setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, - updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountNoReceiptParams) => + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `changed the maximum receipt required expense amount from ${oldValue} to ${newValue}`, + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `changed the maximum expense amount for violations from ${oldValue} to ${newValue}`, + updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + `updated "Max Expense Age (Days)" from "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" to "${newValue}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/es.ts b/src/languages/es.ts index 43253f26bf25..13a5db13c717 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -169,7 +169,7 @@ import type { UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, UpdatedPolicyFrequencyParams, - UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyMaxExepenseAmountParams, UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, @@ -4520,8 +4520,10 @@ const translations = { setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, - updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountNoReceiptParams) => - `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `cambió el monto máximo de gasto para violaciones de ${oldValue} a ${newValue}`, + updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + `actualizó "Antigüedad Máxima de Gastos (días)" de "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" a "${newValue}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index 4529fe3ebab2..fc0c32a9eb4b 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -294,7 +294,7 @@ type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; -type UpdatedPolicyMaxExepenseAmountNoReceiptParams = {oldValue: string; newValue: string}; +type UpdatedPolicyMaxExepenseAmountParams = {oldValue: string; newValue: string}; type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; @@ -805,5 +805,5 @@ export type { UpdatedPolicyCategoryParams, UpdatedPolicyCategoryNameParams, UpdatedPolicyPreventSelfApprovalParams, - UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyMaxExepenseAmountParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 8dfaca55c929..5ec1e5c4efdb 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1838,10 +1838,17 @@ function getWorkspaceUpdateFieldMessage(action: ReportAction): string { }); } + if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.MAX_EXPENSE_AGE && typeof oldValue === 'string' && typeof newValue === 'string') { + return Localize.translateLocal('workspaceActions.updateMaxExpenseAge', { + oldValue, + newValue, + }); + } + return getReportActionText(action); } -function getPolicyChangeLogMaxAmmountNoReceiptMessage(action: ReportAction): string { +function getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(action: ReportAction): string { const {oldMaxExpenseAmountNoReceipt, newMaxExpenseAmountNoReceipt, currency} = getOriginalMessage(action as ReportAction) ?? {}; @@ -1855,6 +1862,20 @@ function getPolicyChangeLogMaxAmmountNoReceiptMessage(action: ReportAction): str return getReportActionText(action); } +function getPolicyChangeLogMaxExpenseAmountMessage(action: ReportAction): string { + const {oldMaxExpenseAmount, newMaxExpenseAmount, currency} = + getOriginalMessage(action as ReportAction) ?? {}; + + if (typeof oldMaxExpenseAmount === 'number' && typeof newMaxExpenseAmount === 'number') { + return Localize.translateLocal('workspaceActions.updateMaxExpenseAmount', { + oldValue: CurrencyUtils.convertToDisplayString(oldMaxExpenseAmount, currency), + newValue: CurrencyUtils.convertToDisplayString(newMaxExpenseAmount, currency), + }); + } + + return getReportActionText(action); +} + function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogDeleteMemberMessage(reportAction)) { return ''; @@ -2099,7 +2120,8 @@ export { getWorkspaceNameUpdatedMessage, getWorkspaceCurrencyUpdateMessage, getWorkspaceFrequencyUpdateMessage, - getPolicyChangeLogMaxAmmountNoReceiptMessage, + getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, + getPolicyChangeLogMaxExpenseAmountMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 80d7925a0344..96d3af9952f2 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -479,7 +479,9 @@ function getOptionData({ } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxAmmountNoReceiptMessage(lastAction); + result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { + result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 9610c9c195a1..c8a7e1ebcae0 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -428,7 +428,9 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { - Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxAmmountNoReceiptMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index f959eecae980..359b6b7832c5 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -835,7 +835,9 @@ function PureReportActionItem({ } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { - children = ; + children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 1600c95b1c07..3cea305cb05b 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -347,6 +347,12 @@ type OriginalMessagePolicyChangeLog = { /** Currency of the policy */ currency?: string; + + /** Old value for max expense amount for violations */ + oldMaxExpenseAmount?: number; + + /** New value for max expense amount for violations */ + newMaxExpenseAmount?: number; }; /** Model of `join policy changelog` report action */ From ea07da4eea1d1667d0be597768a6914f66d1ae99 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Dec 2024 09:55:31 +0530 Subject: [PATCH 13/17] add translations form UPDATE_DEFAULT_TITLE_ENFORCED & UPDATE_DEFAULT_BILLABLE. Signed-off-by: krishna2323 --- src/languages/en.ts | 3 ++- src/languages/es.ts | 12 ++++++--- src/languages/params.ts | 7 +++-- src/libs/ReportActionsUtils.ts | 27 +++++++++++++++++++ src/libs/SidebarUtils.ts | 4 +++ .../report/ContextMenu/ContextMenuActions.tsx | 4 +++ .../home/report/PureReportActionItem.tsx | 4 +++ src/types/onyx/OriginalMessage.ts | 9 +++++++ 8 files changed, 63 insertions(+), 7 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 4a8074f41adf..fe9878b554e7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -169,8 +169,9 @@ import type { UpdatedPolicyCategoryNameParams, UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, - UpdatedPolicyMaxExepenseAmountParams, UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, diff --git a/src/languages/es.ts b/src/languages/es.ts index 13a5db13c717..95de3fee6030 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -168,8 +168,9 @@ import type { UpdatedPolicyCategoryNameParams, UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, - UpdatedPolicyMaxExepenseAmountParams, UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, @@ -4520,10 +4521,13 @@ const translations = { setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, - updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, - updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `cambió el monto máximo de gasto para violaciones de ${oldValue} a ${newValue}`, - updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => + `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `cambió el monto máximo de gasto para violaciones de ${oldValue} a ${newValue}`, + updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `actualizó "Antigüedad Máxima de Gastos (días)" de "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" a "${newValue}"`, + updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `actualizó "Refacturar gastos a clientes" de "${oldValue}" a "${newValue}"`, + updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `cambió "Aplicar título predeterminado de informe" a ${value ? 'activado' : 'desactivado'}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index fc0c32a9eb4b..e4b2a754a5b3 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -294,7 +294,9 @@ type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; -type UpdatedPolicyMaxExepenseAmountParams = {oldValue: string; newValue: string}; +type UpdatedPolicyFieldWithNewAndOldValueParams = {oldValue: string; newValue: string}; + +type UpdatedPolicyFieldWithValueParam = {value: boolean}; type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; @@ -805,5 +807,6 @@ export type { UpdatedPolicyCategoryParams, UpdatedPolicyCategoryNameParams, UpdatedPolicyPreventSelfApprovalParams, - UpdatedPolicyMaxExepenseAmountParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 5ec1e5c4efdb..fa100b7ebf0f 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1876,6 +1876,31 @@ function getPolicyChangeLogMaxExpenseAmountMessage(action: ReportAction): string return getReportActionText(action); } +function getPolicyChangeLogDefaultBillableMessage(action: ReportAction): string { + const {oldDefaultBillable, newDefaultBillable} = getOriginalMessage(action as ReportAction) ?? {}; + + if (typeof oldDefaultBillable === 'string' && typeof newDefaultBillable === 'string') { + return Localize.translateLocal('workspaceActions.updateDefaultBillable', { + oldValue: oldDefaultBillable, + newValue: newDefaultBillable, + }); + } + + return getReportActionText(action); +} + +function getPolicyChangeLogDefaultTitleEnforcedMessage(action: ReportAction): string { + const {value} = getOriginalMessage(action as ReportAction) ?? {}; + + if (typeof value === 'boolean') { + return Localize.translateLocal('workspaceActions.updateDefaultTitleEnforced', { + value, + }); + } + + return getReportActionText(action); +} + function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogDeleteMemberMessage(reportAction)) { return ''; @@ -2122,6 +2147,8 @@ export { getWorkspaceFrequencyUpdateMessage, getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, getPolicyChangeLogMaxExpenseAmountMessage, + getPolicyChangeLogDefaultBillableMessage, + getPolicyChangeLogDefaultTitleEnforcedMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 96d3af9952f2..d5fe17934b2a 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -482,6 +482,10 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE) { + result.alternateText = ReportActionsUtils.getPolicyChangeLogDefaultBillableMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED) { + result.alternateText = ReportActionsUtils.getPolicyChangeLogDefaultTitleEnforcedMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index c8a7e1ebcae0..d515fe80a0ae 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -431,6 +431,10 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE) { + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogDefaultBillableMessage(reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED) { + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogDefaultTitleEnforcedMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 359b6b7832c5..5d52d4b9bb11 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -838,6 +838,10 @@ function PureReportActionItem({ children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE)) { + children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 3cea305cb05b..a90e322da80d 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -353,6 +353,15 @@ type OriginalMessagePolicyChangeLog = { /** New value for max expense amount for violations */ newMaxExpenseAmount?: number; + + /** Old default billable value */ + oldDefaultBillable?: string; + + /** New default billable value */ + newDefaultBillable?: string; + + /** value -- returned when updating "Auto-approve compliant reports" */ + value?: boolean; }; /** Model of `join policy changelog` report action */ From 4d164058ca4983d6845a1478673811c5f8e26d74 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Dec 2024 09:55:52 +0530 Subject: [PATCH 14/17] minor update. Signed-off-by: krishna2323 --- src/languages/en.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index fe9878b554e7..9edb87cee7c9 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4472,11 +4472,13 @@ const translations = { setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, - updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `changed the maximum receipt required expense amount from ${oldValue} to ${newValue}`, - updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `changed the maximum expense amount for violations from ${oldValue} to ${newValue}`, - updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `changed the maximum expense amount for violations from ${oldValue} to ${newValue}`, + updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `updated "Max Expense Age (Days)" from "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" to "${newValue}"`, + updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `updated "Re-bill expenses to clients" from "${oldValue}" to "${newValue}"`, + updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `turned "Enforce Default Report Title" ${value ? 'on' : 'off'}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; From e6552f5325fd190111433dc22c0bb5a45ce22f85 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 7 Jan 2025 17:19:50 +0530 Subject: [PATCH 15/17] add translation for description update. Signed-off-by: krishna2323 --- src/languages/en.ts | 3 +++ src/languages/es.ts | 5 +++++ src/languages/params.ts | 3 +++ src/libs/ReportActionsUtils.ts | 10 ++++++++++ src/libs/SidebarUtils.ts | 2 ++ .../home/report/ContextMenu/ContextMenuActions.tsx | 2 ++ src/pages/home/report/PureReportActionItem.tsx | 2 ++ src/types/onyx/OriginalMessage.ts | 6 ++++++ 8 files changed, 33 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 12ce4ae6fa33..4ba028ab0373 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -174,6 +174,7 @@ import type { UpdatedPolicyCategoryNameParams, UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, + UpdatedPolicyDescriptionParams, UpdatedPolicyFieldWithNewAndOldValueParams, UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, @@ -4611,6 +4612,8 @@ const translations = { updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `updated "Re-bill expenses to clients" from "${oldValue}" to "${newValue}"`, updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `turned "Enforce Default Report Title" ${value ? 'on' : 'off'}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, + updateWorkspaceDescription: ({newDescription, oldDescription}: UpdatedPolicyDescriptionParams) => + !oldDescription ? `set the description of this workspace to "${newDescription}"` : `updated the description of this workspace from "${oldDescription}" to "${newDescription}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/languages/es.ts b/src/languages/es.ts index fa3e568daa80..ac54f332e062 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -173,6 +173,7 @@ import type { UpdatedPolicyCategoryNameParams, UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, + UpdatedPolicyDescriptionParams, UpdatedPolicyFieldWithNewAndOldValueParams, UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, @@ -4658,6 +4659,10 @@ const translations = { `actualizó "Antigüedad Máxima de Gastos (días)" de "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" a "${newValue}"`, updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `actualizó "Refacturar gastos a clientes" de "${oldValue}" a "${newValue}"`, updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `cambió "Aplicar título predeterminado de informe" a ${value ? 'activado' : 'desactivado'}`, + updateWorkspaceDescription: ({newDescription, oldDescription}: UpdatedPolicyDescriptionParams) => + !oldDescription + ? `estableció la descripción de este espacio de trabajo en "${newDescription}"` + : `actualizó la descripción de este espacio de trabajo de "${oldDescription}" a "${newDescription}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index ea553433ddd1..7bdb79a4ae00 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -286,6 +286,8 @@ type ChangeFieldParams = {oldValue?: string; newValue: string; fieldName: string type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; +type UpdatedPolicyDescriptionParams = {oldDescription: string; newDescription: string}; + type UpdatedPolicyCurrencyParams = {oldCurrency: string; newCurrency: string}; type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; @@ -835,6 +837,7 @@ export type { UpdatedPolicyPreventSelfApprovalParams, UpdatedPolicyFieldWithNewAndOldValueParams, UpdatedPolicyFieldWithValueParam, + UpdatedPolicyDescriptionParams, FirstDayTextParams, LastDayTextParams, TripLengthTextParams, diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 8ca670cf098a..cac5bfc3a553 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1762,6 +1762,15 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) { return message; } +function getWorkspaceDescriptionUpdatedMessage(action: ReportAction) { + const {oldDescription, newDescription} = getOriginalMessage(action as ReportAction) ?? {}; + const message = + typeof oldDescription === 'string' && newDescription + ? Localize.translateLocal('workspaceActions.updateWorkspaceDescription', {newDescription, oldDescription}) + : getReportActionText(action); + return message; +} + function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { const {oldCurrency, newCurrency} = getOriginalMessage(action as ReportAction) ?? {}; const message = oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : getReportActionText(action); @@ -2168,6 +2177,7 @@ export { getPolicyChangeLogMaxExpenseAmountMessage, getPolicyChangeLogDefaultBillableMessage, getPolicyChangeLogDefaultTitleEnforcedMessage, + getWorkspaceDescriptionUpdatedMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 63ac74048e6c..9333f1f83c25 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -473,6 +473,8 @@ function getOptionData({ result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`; } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { result.alternateText = ReportActionsUtils.getWorkspaceNameUpdatedMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION)) { + result.alternateText = ReportActionsUtils.getWorkspaceDescriptionUpdatedMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { result.alternateText = ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index b3e882db5087..58852e883cf8 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -413,6 +413,8 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(logMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { Clipboard.setString(ReportActionsUtils.getWorkspaceNameUpdatedMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION) { + Clipboard.setString(ReportActionsUtils.getWorkspaceDescriptionUpdatedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { Clipboard.setString(ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 637f7dcc6d2e..9a3be083a2cd 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -820,6 +820,8 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index a90e322da80d..5bd0d5e310f6 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -362,6 +362,12 @@ type OriginalMessagePolicyChangeLog = { /** value -- returned when updating "Auto-approve compliant reports" */ value?: boolean; + + /** New desciption */ + newDescription?: string; + + /** Old desciption */ + oldDescription?: string; }; /** Model of `join policy changelog` report action */ From d26e83a08341748c96fdca0296d0c781fc134710 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 7 Jan 2025 18:04:09 +0530 Subject: [PATCH 16/17] add translation for team downgrade policy change. Signed-off-by: krishna2323 --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/SidebarUtils.ts | 2 ++ src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 2 ++ src/pages/home/report/PureReportActionItem.tsx | 2 ++ 5 files changed, 8 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 4ba028ab0373..29333638b27e 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4631,6 +4631,7 @@ const translations = { updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, updatedWorkspaceCorporatePlan: 'upgraded this workspace to the Control plan', + updatedWorkspaceCorporatePlanDowngrade: 'downgraded this workspace to the Collect plan', updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `updated the Approval Mode from "${oldValue}" to "${newValue}".`, }, roomMembersPage: { diff --git a/src/languages/es.ts b/src/languages/es.ts index ac54f332e062..eb077bfcc1f7 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4682,6 +4682,7 @@ const translations = { updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, updatedWorkspaceCorporatePlan: 'mejoró este espacio de trabajo al plan Controlar', + updatedWorkspaceCorporatePlanDowngrade: 'degradó este espacio de trabajo al plan Collect', updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `Actualizó el Modo de Aprobación de "${oldValue}" a "${newValue}".`, }, roomMembersPage: { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 9333f1f83c25..24a22bad988a 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -481,6 +481,8 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE)) { + result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlanDowngrade'); } else if ( ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 58852e883cf8..d6c982e0d166 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -421,6 +421,8 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { + Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlanDowngrade')); } else if ( reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 9a3be083a2cd..f4c064606ab8 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -828,6 +828,8 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { + children = ; } else if ( action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || From 206cb435c44dc321999851d273d35e12b0a44d02 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 7 Jan 2025 18:57:47 +0530 Subject: [PATCH 17/17] added report field addition policy change log translation. Signed-off-by: krishna2323 --- src/languages/en.ts | 2 ++ src/languages/es.ts | 2 ++ src/languages/params.ts | 3 +++ src/libs/ReportActionsUtils.ts | 14 ++++++++++++++ src/libs/SidebarUtils.ts | 2 ++ .../home/report/ContextMenu/ContextMenuActions.tsx | 2 ++ src/pages/home/report/PureReportActionItem.tsx | 2 ++ src/types/onyx/OriginalMessage.ts | 6 ++++++ 8 files changed, 33 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 29333638b27e..75f8c74b2bd5 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -5,6 +5,7 @@ import type {Country} from '@src/CONST'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, @@ -4602,6 +4603,7 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, + addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => diff --git a/src/languages/es.ts b/src/languages/es.ts index eb077bfcc1f7..05b1ce10638f 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4,6 +4,7 @@ import type en from './en'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, @@ -4649,6 +4650,7 @@ const translations = { addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `agregó la categoría "${categoryName}"`, deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, + addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, diff --git a/src/languages/params.ts b/src/languages/params.ts index 7bdb79a4ae00..be8bcd7ffe57 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -294,6 +294,8 @@ type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; +type AddedPolicyReportFieldParams = {fieldType: string; fieldName?: string}; + type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; type UpdatedPolicyFieldWithNewAndOldValueParams = {oldValue: string; newValue: string}; @@ -843,4 +845,5 @@ export type { TripLengthTextParams, EditDestinationSubtitleParams, FlightLayoverParams, + AddedPolicyReportFieldParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index cac5bfc3a553..7b97d12ba1ec 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1843,6 +1843,19 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { return getReportActionText(action); } +function getWorkspaceReportFieldAddMessage(action: ReportAction): string { + const {fieldName, fieldType} = getOriginalMessage(action as ReportAction) ?? {}; + + if (fieldName && fieldType) { + return Localize.translateLocal('workspaceActions.addedReportField', { + fieldName, + fieldType, + }); + } + + return getReportActionText(action); +} + function getWorkspaceUpdateFieldMessage(action: ReportAction): string { const {newValue, oldValue, updatedField} = getOriginalMessage(action as ReportAction) ?? {}; @@ -2178,6 +2191,7 @@ export { getPolicyChangeLogDefaultBillableMessage, getPolicyChangeLogDefaultTitleEnforcedMessage, getWorkspaceDescriptionUpdatedMessage, + getWorkspaceReportFieldAddMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 24a22bad988a..cadff63cce85 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -490,6 +490,8 @@ function getOptionData({ ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { + result.alternateText = ReportActionsUtils.getWorkspaceReportFieldAddMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index d6c982e0d166..309e17e1ed59 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -430,6 +430,8 @@ const ContextMenuActions: ContextMenuAction[] = [ reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { + Clipboard.setString(ReportActionsUtils.getWorkspaceReportFieldAddMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index f4c064606ab8..e1ed10e2c356 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -837,6 +837,8 @@ function PureReportActionItem({ action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { + children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 5bd0d5e310f6..848a423b45a7 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -368,6 +368,12 @@ type OriginalMessagePolicyChangeLog = { /** Old desciption */ oldDescription?: string; + + /** Report field type */ + fieldType?: string; + + /** Report field name */ + fieldName?: string; }; /** Model of `join policy changelog` report action */