Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Chat - Most of the workspace modifying settings messages are not translated in #Admins. #53238

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ import type {
UntilTimeParams,
UpdatedTheDistanceMerchantParams,
UpdatedTheRequestParams,
UpdatedWorkspaceCurrencyParams,
UpdatedWorkspaceFrequencyParams,
UpdateRoleParams,
UsePlusButtonParams,
UserIsAlreadyMemberParams,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ import type {
UntilTimeParams,
UpdatedTheDistanceMerchantParams,
UpdatedTheRequestParams,
UpdatedWorkspaceCurrencyParams,
UpdatedWorkspaceFrequencyParams,
UpdateRoleParams,
UsePlusButtonParams,
UserIsAlreadyMemberParams,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -771,4 +775,6 @@ export type {
WorkspaceLockedPlanTypeParams,
CompanyNameParams,
ChatWithAccountManagerParams,
UpdatedWorkspaceCurrencyParams,
UpdatedWorkspaceFrequencyParams,
};
43 changes: 43 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4817,6 +4817,47 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) {
return message;
}

function getWorkspaceCurrencyUpdateMessage(action: ReportAction) {
const {oldCurrency, newCurrency} = ReportActionsUtils.getOriginalMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY>) ?? {};
const message =
oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : ReportActionsUtils.getReportActionText(action);
return message;
}

type AutoReportingFrequencyKey = ValueOf<typeof CONST.POLICY.AUTO_REPORTING_FREQUENCIES>;
type AutoReportingFrequencyDisplayNames = Record<AutoReportingFrequencyKey, string>;

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

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)
Expand Down Expand Up @@ -8553,6 +8594,8 @@ export {
getIOUForwardedMessage,
getRejectedReportMessage,
getWorkspaceNameUpdatedMessage,
getWorkspaceCurrencyUpdateMessage,
getWorkspaceFrequencyUpdateMessage,
getReportAutomaticallySubmittedMessage,
getIOUSubmittedMessage,
getIcons,
Expand Down
4 changes: 4 additions & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,10 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={PolicyUtils.getCleanedTagName(ReportActionsUtils.getReportActionMessage(action)?.text ?? '')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) {
children = <ReportActionItemBasicMessage message={ReportUtils.getWorkspaceNameUpdatedMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) {
children = <ReportActionItemBasicMessage message={ReportUtils.getWorkspaceCurrencyUpdateMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) {
children = <ReportActionItemBasicMessage message={ReportUtils.getWorkspaceFrequencyUpdateMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getPolicyChangeLogAddEmployeeMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) {
Expand Down
12 changes: 12 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.POLICY.AUTO_REPORTING_FREQUENCIES>;

/** New frequency of the workspace */
newFrequency?: ValueOf<typeof CONST.POLICY.AUTO_REPORTING_FREQUENCIES>;

/** Name of connection */
connectionName?: AllConnectionName;
};
Expand Down
Loading