Skip to content

Commit

Permalink
add translations for UPDATE_REPORT_FIELD & DELETE_REPORT_FIELD.
Browse files Browse the repository at this point in the history
Signed-off-by: krishna2323 <[email protected]>
  • Loading branch information
Krishna2323 committed Jan 21, 2025
1 parent 8a44aeb commit 3fb3870
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type {Country} from '@src/CONST';
import type {
AccountOwnerParams,
ActionsAreCurrentlyRestricted,
AddedOrDeletedPolicyReportFieldParams,
AddedPolicyCustomUnitRateParams,
AddedPolicyReportFieldParams,
AddEmployeeParams,
AddressLineParams,
AdminCanceledRequestParams,
Expand Down Expand Up @@ -178,6 +178,7 @@ import type {
UpdatedPolicyFieldWithValueParam,
UpdatedPolicyFrequencyParams,
UpdatedPolicyPreventSelfApprovalParams,
UpdatedPolicyReportFieldDefaultValueParams,
UpdatedPolicyTagFieldParams,
UpdatedPolicyTagNameParams,
UpdatedPolicyTagParams,
Expand Down Expand Up @@ -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) =>
Expand Down
8 changes: 6 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type en from './en';
import type {
AccountOwnerParams,
ActionsAreCurrentlyRestricted,
AddedOrDeletedPolicyReportFieldParams,
AddedPolicyCustomUnitRateParams,
AddedPolicyReportFieldParams,
AddEmployeeParams,
AddressLineParams,
AdminCanceledRequestParams,
Expand Down Expand Up @@ -177,6 +177,7 @@ import type {
UpdatedPolicyFieldWithValueParam,
UpdatedPolicyFrequencyParams,
UpdatedPolicyPreventSelfApprovalParams,
UpdatedPolicyReportFieldDefaultValueParams,
UpdatedPolicyTagFieldParams,
UpdatedPolicyTagNameParams,
UpdatedPolicyTagParams,
Expand Down Expand Up @@ -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'}"`,
Expand Down
7 changes: 5 additions & 2 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -838,9 +840,10 @@ export type {
UpdatedPolicyDescriptionParams,
EditDestinationSubtitleParams,
FlightLayoverParams,
AddedPolicyReportFieldParams,
AddedOrDeletedPolicyReportFieldParams,
AddedPolicyCustomUnitRateParams,
UpdatedPolicyTagParams,
UpdatedPolicyTagNameParams,
UpdatedPolicyTagFieldParams,
UpdatedPolicyReportFieldDefaultValueParams,
};
32 changes: 31 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -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<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY>) ?? {};

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<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY>) ?? {};

if (fieldType && fieldName) {
return translateLocal('workspaceActions.deleteReportField', {
fieldName,
fieldType: translateLocal(getReportFieldAlternativeTextTranslationKey(fieldType as PolicyReportFieldType)),
});
}

Expand Down Expand Up @@ -2259,6 +2287,8 @@ export {
getWorkspaceReportFieldAddMessage,
getWorkspaceCustomUnitRateAddedMessage,
getWorkspaceTagUpdateMessage,
getWorkspaceReportFieldUpdateMessage,
getWorkspaceReportFieldDeleteMessage,
};

export type {LastVisibleMessage};
6 changes: 6 additions & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import {
getWorkspaceFrequencyUpdateMessage,
getWorkspaceNameUpdatedMessage,
getWorkspaceReportFieldAddMessage,
getWorkspaceReportFieldDeleteMessage,
getWorkspaceReportFieldUpdateMessage,
getWorkspaceTagUpdateMessage,
getWorkspaceUpdateFieldMessage,
isActionOfType,
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import {
getWorkspaceDescriptionUpdatedMessage,
getWorkspaceFrequencyUpdateMessage,
getWorkspaceReportFieldAddMessage,
getWorkspaceReportFieldDeleteMessage,
getWorkspaceReportFieldUpdateMessage,
getWorkspaceTagUpdateMessage,
getWorkspaceUpdateFieldMessage,
isActionableMentionWhisper,
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ import {
getWorkspaceFrequencyUpdateMessage,
getWorkspaceNameUpdatedMessage,
getWorkspaceReportFieldAddMessage,
getWorkspaceReportFieldDeleteMessage,
getWorkspaceReportFieldUpdateMessage,
getWorkspaceTagUpdateMessage,
getWorkspaceUpdateFieldMessage,
isActionableAddPaymentCard,
Expand Down Expand Up @@ -899,6 +901,10 @@ function PureReportActionItem({
children = <ReportActionItemBasicMessage message={getWorkspaceCustomUnitRateAddedMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) {
children = <ReportActionItemBasicMessage message={getWorkspaceReportFieldAddMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) {
children = <ReportActionItemBasicMessage message={getWorkspaceReportFieldUpdateMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) {
children = <ReportActionItemBasicMessage message={getWorkspaceReportFieldDeleteMessage(action)} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) {
children = <ReportActionItemBasicMessage message={getWorkspaceUpdateFieldMessage(action)} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) {
Expand Down
9 changes: 9 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 3fb3870

Please sign in to comment.