diff --git a/src/CONST.ts b/src/CONST.ts index cd8b5d26c745..1262a3127eee 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2482,6 +2482,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_', @@ -2558,6 +2566,10 @@ const CONST = { AUTOREPORTING_OFFSET: 'autoReportingOffset', GENERAL_SETTINGS: 'generalSettings', }, + EXPENSE_REPORT_RULES: { + PREVENT_SELF_APPROVAL: 'preventSelfApproval', + MAX_EXPENSE_AGE: 'maxExpenseAge', + }, 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 eda70330d332..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, @@ -171,6 +172,14 @@ import type { UnapproveWithIntegrationWarningParams, UnshareParams, UntilTimeParams, + UpdatedPolicyCategoryNameParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyDescriptionParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, + UpdatedPolicyFrequencyParams, + UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -1528,6 +1537,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', @@ -4589,7 +4599,23 @@ const translations = { }, }, workspaceActions: { + 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}"`, + 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) => + `changed the maximum receipt required expense amount from ${oldValue} to ${newValue}`, + 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}")`, + 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) { @@ -4604,6 +4630,11 @@ 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}: 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: { memberNotFound: 'Member not found.', diff --git a/src/languages/es.ts b/src/languages/es.ts index ca12b0447bb6..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, @@ -170,6 +171,14 @@ import type { UnapproveWithIntegrationWarningParams, UnshareParams, UntilTimeParams, + UpdatedPolicyCategoryNameParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyDescriptionParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, + UpdatedPolicyFrequencyParams, + UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -1529,6 +1538,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', @@ -4637,6 +4647,24 @@ const translations = { }, }, workspaceActions: { + 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'}"`, + 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'}`, + 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 = ''; @@ -4652,6 +4680,12 @@ 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}: 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', + updatedWorkspaceCorporatePlanDowngrade: 'degradó este espacio de trabajo al plan Collect', + 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 969706eeeb2f..be8bcd7ffe57 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -286,6 +286,24 @@ 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}; + +type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; + +type AddedPolicyReportFieldParams = {fieldType: string; fieldName?: string}; + +type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; + +type UpdatedPolicyFieldWithNewAndOldValueParams = {oldValue: string; newValue: string}; + +type UpdatedPolicyFieldWithValueParam = {value: boolean}; + +type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; + type ChangeTypeParams = {oldType: string; newType: string}; type DelegateSubmitParams = {delegateUser: string; originalManager: string}; @@ -814,9 +832,18 @@ export type { CompanyNameParams, CustomUnitRateParams, ChatWithAccountManagerParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyFrequencyParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCategoryNameParams, + UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, + UpdatedPolicyDescriptionParams, FirstDayTextParams, LastDayTextParams, TripLengthTextParams, EditDestinationSubtitleParams, FlightLayoverParams, + AddedPolicyReportFieldParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index c1f4057199ee..7b97d12ba1ec 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'; @@ -1744,8 +1745,8 @@ function getPolicyChangeLogChangeRoleMessage(reportAction: OnyxInputOrEntry) ?? {}; + const message = oldName && newName ? Localize.translateLocal('workspaceActions.renamedWorkspaceNameAction', {oldName, newName}) : getReportActionText(action); + 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); + 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 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) ?? {}; + + 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, + }); + } + + if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.PREVENT_SELF_APPROVAL && typeof oldValue === 'string' && typeof newValue === 'string') { + return Localize.translateLocal('workspaceActions.preventSelfApproval', { + oldValue, + newValue, + }); + } + + 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 getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(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); +} + +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 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 ''; @@ -1994,6 +2181,17 @@ export { getActionableJoinRequestPendingReportAction, getReportActionsLength, wasActionCreatedWhileOffline, + getWorkspaceCategoryUpdateMessage, + getWorkspaceUpdateFieldMessage, + getWorkspaceNameUpdatedMessage, + getWorkspaceCurrencyUpdateMessage, + getWorkspaceFrequencyUpdateMessage, + getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, + getPolicyChangeLogMaxExpenseAmountMessage, + getPolicyChangeLogDefaultBillableMessage, + getPolicyChangeLogDefaultTitleEnforcedMessage, + getWorkspaceDescriptionUpdatedMessage, + getWorkspaceReportFieldAddMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9c6377474e78..3628cf052f9c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4949,12 +4949,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; -} - /** * @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) @@ -8737,7 +8731,6 @@ export { getReportAutomaticallyForwardedMessage, getIOUForwardedMessage, getRejectedReportMessage, - getWorkspaceNameUpdatedMessage, getReportAutomaticallySubmittedMessage, getIOUSubmittedMessage, getIcons, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 626dc8d5ed68..cadff63cce85 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -472,7 +472,36 @@ 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_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)) { + 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) || + 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 = 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) { + 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 b8cdde2ecff3..309e17e1ed59 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -412,7 +412,36 @@ 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_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) { + 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 || + 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(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) { + 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 bb3e04a90b84..e1ed10e2c356 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -819,7 +819,36 @@ 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_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) { + 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 || + 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_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)) { + 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 0cb9a735aad4..848a423b45a7 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -278,6 +278,102 @@ type OriginalMessageChangeLog = { /** Name of connection */ connectionName?: AllConnectionName; + + /** Name of the added category */ + 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 | string; + + /** Old Value */ + oldValue?: boolean | 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; + + /** Name of the added category */ + categoryName?: string; + + /** 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; + + /** Old value for max expense amount for violations */ + oldMaxExpenseAmount?: number; + + /** 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; + + /** New desciption */ + newDescription?: string; + + /** Old desciption */ + oldDescription?: string; + + /** Report field type */ + fieldType?: string; + + /** Report field name */ + fieldName?: string; }; /** Model of `join policy changelog` report action */ @@ -638,7 +734,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; };