From 3fb38707fe1c7572d68384daf3d2c88b24987334 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 21 Jan 2025 06:27:27 +0530 Subject: [PATCH] add translations for UPDATE_REPORT_FIELD & DELETE_REPORT_FIELD. Signed-off-by: krishna2323 --- src/languages/en.ts | 8 +++-- src/languages/es.ts | 8 +++-- src/languages/params.ts | 7 ++-- src/libs/ReportActionsUtils.ts | 32 ++++++++++++++++++- src/libs/SidebarUtils.ts | 6 ++++ .../report/ContextMenu/ContextMenuActions.tsx | 6 ++++ .../home/report/PureReportActionItem.tsx | 6 ++++ src/types/onyx/OriginalMessage.ts | 9 ++++++ 8 files changed, 75 insertions(+), 7 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 36b043441e54..c863fc7eae02 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -5,8 +5,8 @@ import type {Country} from '@src/CONST'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedOrDeletedPolicyReportFieldParams, AddedPolicyCustomUnitRateParams, - AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, @@ -178,6 +178,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyReportFieldDefaultValueParams, UpdatedPolicyTagFieldParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, @@ -4643,7 +4644,10 @@ const translations = { return `updated the tag "${tagName}" on the list "${tagListName}" by adding a ${updatedField} of "${newValue}"`; }, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `added a new "${customUnitName}" rate "${rateName}"`, - addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, + addedReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, + updateReportFieldDefaultValue: ({defaultValue, fieldName}: UpdatedPolicyReportFieldDefaultValueParams) => + `updated Report Field "${fieldName}"; set the default value to be "${defaultValue}"`, + deleteReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `removed ${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 85605302e944..804bb3349c11 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4,8 +4,8 @@ import type en from './en'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedOrDeletedPolicyReportFieldParams, AddedPolicyCustomUnitRateParams, - AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, @@ -177,6 +177,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyReportFieldDefaultValueParams, UpdatedPolicyTagFieldParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, @@ -4690,7 +4691,10 @@ const translations = { } return `actualizó la etiqueta "${tagName}" en la lista "${tagListName}" añadiendo un ${updatedField} de "${newValue}"`; }, - addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, + addedReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, + updateReportFieldDefaultValue: ({defaultValue, fieldName}: UpdatedPolicyReportFieldDefaultValueParams) => + `actualizó el campo del informe "${fieldName}"; estableció el valor predeterminado como "${defaultValue}"`, + deleteReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `eliminó el campo de informe ${fieldType} "${fieldName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `agregó una nueva tasa de "${rateName}" para "${customUnitName}"`, 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 6723b8b7a882..6f57eb27d43a 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -302,7 +302,9 @@ type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type AddedPolicyCustomUnitRateParams = {customUnitName: string; rateName: string}; -type AddedPolicyReportFieldParams = {fieldType: string; fieldName?: string}; +type AddedOrDeletedPolicyReportFieldParams = {fieldType: string; fieldName?: string}; + +type UpdatedPolicyReportFieldDefaultValueParams = {fieldName?: string; defaultValue?: string}; type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; @@ -838,9 +840,10 @@ export type { UpdatedPolicyDescriptionParams, EditDestinationSubtitleParams, FlightLayoverParams, - AddedPolicyReportFieldParams, + AddedOrDeletedPolicyReportFieldParams, AddedPolicyCustomUnitRateParams, UpdatedPolicyTagParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagFieldParams, + UpdatedPolicyReportFieldDefaultValueParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 0fddaad97118..861bbd534c30 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -11,6 +11,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {Locale, OnyxInputOrEntry, PrivatePersonalDetails} from '@src/types/onyx'; import type {JoinWorkspaceResolution, OriginalMessageChangeLog, OriginalMessageExportIntegration} from '@src/types/onyx/OriginalMessage'; +import type {PolicyReportFieldType} from '@src/types/onyx/Policy'; import type Report from '@src/types/onyx/Report'; import type ReportAction from '@src/types/onyx/ReportAction'; import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction'; @@ -31,6 +32,7 @@ import {getPolicy, isPolicyAdmin as isPolicyAdminPolicyUtils} from './PolicyUtil import type {OptimisticIOUReportAction, PartialReportAction} from './ReportUtils'; import StringUtils from './StringUtils'; import {isOnHoldByTransactionID} from './TransactionUtils'; +import {getReportFieldAlternativeTextTranslationKey} from './WorkspaceReportFieldUtils'; type LastVisibleMessage = { lastMessageText: string; @@ -1916,7 +1918,33 @@ function getWorkspaceReportFieldAddMessage(action: ReportAction): string { if (fieldName && fieldType) { return translateLocal('workspaceActions.addedReportField', { fieldName, - fieldType, + fieldType: translateLocal(getReportFieldAlternativeTextTranslationKey(fieldType as PolicyReportFieldType)), + }); + } + + return getReportActionText(action); +} + +function getWorkspaceReportFieldUpdateMessage(action: ReportAction): string { + const {updateType, fieldName, defaultValue} = getOriginalMessage(action as ReportAction) ?? {}; + + if (updateType === 'updatedDefaultValue' && fieldName && defaultValue) { + return translateLocal('workspaceActions.updateReportFieldDefaultValue', { + fieldName, + defaultValue, + }); + } + + return getReportActionText(action); +} + +function getWorkspaceReportFieldDeleteMessage(action: ReportAction): string { + const {fieldType, fieldName} = getOriginalMessage(action as ReportAction) ?? {}; + + if (fieldType && fieldName) { + return translateLocal('workspaceActions.deleteReportField', { + fieldName, + fieldType: translateLocal(getReportFieldAlternativeTextTranslationKey(fieldType as PolicyReportFieldType)), }); } @@ -2259,6 +2287,8 @@ export { getWorkspaceReportFieldAddMessage, getWorkspaceCustomUnitRateAddedMessage, getWorkspaceTagUpdateMessage, + getWorkspaceReportFieldUpdateMessage, + getWorkspaceReportFieldDeleteMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 5723165808c7..0ce6db622c11 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -46,6 +46,8 @@ import { getWorkspaceFrequencyUpdateMessage, getWorkspaceNameUpdatedMessage, getWorkspaceReportFieldAddMessage, + getWorkspaceReportFieldDeleteMessage, + getWorkspaceReportFieldUpdateMessage, getWorkspaceTagUpdateMessage, getWorkspaceUpdateFieldMessage, isActionOfType, @@ -571,6 +573,10 @@ function getOptionData({ result.alternateText = getWorkspaceCustomUnitRateAddedMessage(lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { result.alternateText = getWorkspaceReportFieldAddMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD)) { + result.alternateText = getWorkspaceReportFieldUpdateMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD)) { + result.alternateText = getWorkspaceReportFieldDeleteMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { result.alternateText = 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 2cea58bdf7e1..1cb17075c522 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -47,6 +47,8 @@ import { getWorkspaceDescriptionUpdatedMessage, getWorkspaceFrequencyUpdateMessage, getWorkspaceReportFieldAddMessage, + getWorkspaceReportFieldDeleteMessage, + getWorkspaceReportFieldUpdateMessage, getWorkspaceTagUpdateMessage, getWorkspaceUpdateFieldMessage, isActionableMentionWhisper, @@ -515,6 +517,10 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(getWorkspaceCustomUnitRateAddedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { Clipboard.setString(getWorkspaceReportFieldAddMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) { + Clipboard.setString(getWorkspaceReportFieldUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) { + Clipboard.setString(getWorkspaceReportFieldDeleteMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { setClipboardMessage(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 8ed42a67816f..42883606fd6d 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -79,6 +79,8 @@ import { getWorkspaceFrequencyUpdateMessage, getWorkspaceNameUpdatedMessage, getWorkspaceReportFieldAddMessage, + getWorkspaceReportFieldDeleteMessage, + getWorkspaceReportFieldUpdateMessage, getWorkspaceTagUpdateMessage, getWorkspaceUpdateFieldMessage, isActionableAddPaymentCard, @@ -899,6 +901,10 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) { + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { children = ; } else if (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 5e710c2a55b6..ca0e9724cdde 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -389,6 +389,15 @@ type OriginalMessagePolicyChangeLog = { /** Updated tag enabled/disabled value */ enabled?: boolean; + + /** Default value of a report field */ + defaultValue?: string; + + /** field ID of a report field */ + fieldID?: string; + + /** update type of a report field */ + updateType?: string; }; /** Model of `join policy changelog` report action */