From 959c3df10ef1c54e32bca5220019e3fd4fc37eae Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 28 Nov 2024 08:13:45 +0530 Subject: [PATCH] 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 1dc859b007b..d0f9b3187eb 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 ca1bc8f4680..5f45f19caf5 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 a2d5e1bee12..8a28b6a13d0 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 7ad8d3df107..bf152c02915 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 f4979f94236..dd7e593c96a 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 705b85d4c3f..38a8264ef70 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 399550069c0..288ddf57311 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 fd94531abb0..2fcd5a0f08c 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; };