Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10552,6 +10552,7 @@ Fügen Sie weitere Ausgabelimits hinzu, um den Cashflow Ihres Unternehmens zu sc
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `${fieldName} auf „${newValue}“ geändert (zuvor „${oldValue}“)`,
changeFieldEmpty: (newValue: string, fieldName: string) => `setze ${fieldName} auf „${newValue}“`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `${fieldName} entfernt (zuvor „${oldValue}“)`,
changeFieldCleared: (fieldName: string) => `${fieldName} entfernt`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `hat den Arbeitsbereich${fromPolicyName ? `(zuvor ${fromPolicyName})` : ''} geändert`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10752,6 +10752,7 @@ ${reportName}`,
changeField: (oldValue, newValue, fieldName) => `άλλαξε το ${fieldName} σε «${newValue}» (προηγουμένως «${oldValue}»)`,
changeFieldEmpty: (newValue, fieldName) => `ορίστε το ${fieldName} σε «${newValue}»`,
changeFieldRemoved: (oldValue, fieldName) => `αφαίρεσε το ${fieldName} (προηγουμένως «${oldValue}»)`,
changeFieldCleared: (fieldName) => `αφαίρεσε το ${fieldName}`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `άλλαξε τον χώρο εργασίας${fromPolicyName ? `(προηγουμένως ${fromPolicyName})` : ''}`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10789,6 +10789,7 @@ const translations = {
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `changed ${fieldName} to "${newValue}" (previously "${oldValue}")`,
changeFieldEmpty: (newValue: string, fieldName: string) => `set ${fieldName} to "${newValue}"`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `removed ${fieldName} (previously "${oldValue}")`,
changeFieldCleared: (fieldName: string) => `removed ${fieldName}`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `changed the workspace${fromPolicyName ? ` (previously ${fromPolicyName})` : ''}`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10354,6 +10354,7 @@ ${reportName}`,
changeField: (oldValue, newValue, fieldName) => `cambió ${fieldName} a "${newValue}" (previamente "${oldValue}")`,
changeFieldEmpty: (newValue, fieldName) => `estableció ${fieldName} a ${newValue}`,
changeFieldRemoved: (oldValue, fieldName) => `eliminó ${fieldName} (previamente "${oldValue}")`,
changeFieldCleared: (fieldName) => `eliminó ${fieldName}`,
changeReportPolicy: (toPolicyName, fromPolicyName) => {
if (!toPolicyName) {
return `cambió el espacio de trabajo${fromPolicyName ? ` (previamente ${fromPolicyName})` : ''}`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10578,6 +10578,7 @@ Ajoutez davantage de règles de dépenses pour protéger la trésorerie de l’e
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `a modifié ${fieldName} en « ${newValue} » (auparavant « ${oldValue} »)`,
changeFieldEmpty: (newValue: string, fieldName: string) => `définir ${fieldName} sur « ${newValue} »`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `a supprimé ${fieldName} (auparavant « ${oldValue} »)`,
changeFieldCleared: (fieldName: string) => `a supprimé ${fieldName}`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `a modifié l’espace de travail${fromPolicyName ? `(précédemment ${fromPolicyName})` : ''}`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10500,6 +10500,7 @@ Aggiungi altre regole di spesa per proteggere il flusso di cassa aziendale.`,
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `ha modificato ${fieldName} in "${newValue}" (in precedenza "${oldValue}")`,
changeFieldEmpty: (newValue: string, fieldName: string) => `imposta ${fieldName} su "${newValue}"`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `ha rimosso ${fieldName} (in precedenza "${oldValue}")`,
changeFieldCleared: (fieldName: string) => `ha rimosso ${fieldName}`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `ha modificato il workspace${fromPolicyName ? `(precedentemente ${fromPolicyName})` : ''}`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10346,6 +10346,7 @@ ${reportName}`,
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `${fieldName} を「${newValue}」(以前は「${oldValue}」)に変更しました`,
changeFieldEmpty: (newValue: string, fieldName: string) => `${fieldName} を「${newValue}」に設定`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `${fieldName} を削除しました(以前は「${oldValue}」)`,
changeFieldCleared: (fieldName: string) => `${fieldName} を削除しました`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `ワークスペース${fromPolicyName ? `(以前は${fromPolicyName})` : ''}を変更しました`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10470,6 +10470,7 @@ er bestedingsregels toe om de kasstroom van het bedrijf te beschermen.`,
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `heeft ${fieldName} gewijzigd in „${newValue}” (voorheen „${oldValue}”)`,
changeFieldEmpty: (newValue: string, fieldName: string) => `stel ${fieldName} in op "${newValue}"`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `heeft ${fieldName} verwijderd (voorheen „${oldValue}”)`,
changeFieldCleared: (fieldName: string) => `heeft ${fieldName} verwijderd`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `heeft de werkruimte${fromPolicyName ? `(voorheen ${fromPolicyName})` : ''} gewijzigd`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10485,6 +10485,7 @@ Dodaj więcej zasad wydatków, żeby chronić płynność finansową firmy.`,
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `zmieniono ${fieldName} na „${newValue}” (wcześniej „${oldValue}”)`,
changeFieldEmpty: (newValue: string, fieldName: string) => `ustaw ${fieldName} na „${newValue}”`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `usunięto ${fieldName} (wcześniej „${oldValue}”)`,
changeFieldCleared: (fieldName: string) => `usunięto ${fieldName}`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `zmieniono przestrzeń roboczą${fromPolicyName ? `(wcześniej ${fromPolicyName})` : ''}`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10467,6 +10467,7 @@ Adicione mais regras de gasto para proteger o fluxo de caixa da empresa.`,
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `alterou ${fieldName} para "${newValue}" (antes "${oldValue}")`,
changeFieldEmpty: (newValue: string, fieldName: string) => `definir ${fieldName} como "${newValue}"`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `removeu ${fieldName} (antes "${oldValue}")`,
changeFieldCleared: (fieldName: string) => `removeu ${fieldName}`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `alterou o espaço de trabalho${fromPolicyName ? `(antes ${fromPolicyName})` : ''}`;
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10065,6 +10065,7 @@ ${reportName}`,
changeField: (oldValue: string | undefined, newValue: string, fieldName: string) => `将${fieldName}更改为“${newValue}”(先前为“${oldValue}”)`,
changeFieldEmpty: (newValue: string, fieldName: string) => `将 ${fieldName} 设置为“${newValue}”`,
changeFieldRemoved: (oldValue: string, fieldName: string) => `已移除${fieldName}(先前为“${oldValue}”)`,
changeFieldCleared: (fieldName: string) => `已移除${fieldName}`,
changeReportPolicy: (toPolicyName: string, fromPolicyName?: string) => {
if (!toPolicyName) {
return `更改了工作区${fromPolicyName ? `(原为 ${fromPolicyName})` : ''}`;
Expand Down
5 changes: 3 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2432,8 +2432,9 @@ function getMessageOfOldDotReportAction(translate: LocalizedTranslate, oldDotAct
switch (actionName) {
case CONST.REPORT.ACTIONS.TYPE.CHANGE_FIELD: {
const {oldValue, newValue, fieldName} = originalMessage;
if (oldValue && !newValue) {
return translate('report.actions.type.changeFieldRemoved', oldValue, fieldName);
if (!newValue) {
// A cleared field has no new value to show, so it must never fall through to `set {field} to ""`
return oldValue ? translate('report.actions.type.changeFieldRemoved', oldValue, fieldName) : translate('report.actions.type.changeFieldCleared', fieldName);
}
if (!oldValue) {
return translate('report.actions.type.changeFieldEmpty', newValue, fieldName);
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/ReportActionsUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,22 @@ describe('ReportActionsUtils', () => {
expect(message).toBe('removed Project (previously "Apollo")');
});

it('should return the cleared field message when a field without a saved value is cleared', () => {
// Given a field change where both values are empty, which is what clearing a field that only showed its default can send
const action: Parameters<typeof ReportActionsUtils.getMessageOfOldDotReportAction>[1] = {
reportActionID: '1',
created: '2024-01-01 00:00:00.000',
actionName: CONST.REPORT.ACTIONS.TYPE.CHANGE_FIELD,
originalMessage: {fieldName: 'Project', oldValue: '', newValue: ''},
};

// When the message is built
const message = ReportActionsUtils.getMessageOfOldDotReportAction(translateLocal, action);

// Then it says the field was removed, instead of `set Project to ""`
expect(message).toBe('removed Project');
});

it('should return the set field message when a field without a value is filled in', () => {
// Given a field change whose old value is empty
const action: Parameters<typeof ReportActionsUtils.getMessageOfOldDotReportAction>[1] = {
Expand Down
40 changes: 40 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
buildOptimisticApprovedReportAction,
buildOptimisticCancelPaymentReportAction,
buildOptimisticCardAssignedReportAction,
buildOptimisticChangeFieldAction,
buildOptimisticChatReport,
buildOptimisticClosedReportAction,
buildOptimisticCreatedReportAction,
Expand Down Expand Up @@ -24701,6 +24702,45 @@ describe('ReportUtils', () => {
});
});

describe('buildOptimisticChangeFieldAction', () => {
const textField: PolicyReportField = {
name: 'text',
fieldID: 'text_field',
defaultValue: 'Initial',
orderWeight: 1,
type: 'text',
deletable: true,
target: CONST.REPORT.TYPE.EXPENSE,
values: [],
keys: [],
externalIDs: [],
disabledOptions: [],
isTax: false,
};

it('should not use the default value as the old value when the field was never saved on the report', () => {
// Given a text field that has no saved value on the report, so the user sees its workspace default
const previousReportField = {...textField, value: undefined};

// When the user clears it
const action = buildOptimisticChangeFieldAction({...textField, value: ''}, previousReportField, 1);

// Then the action leaves the old value empty, matching the server's action so the message doesn't change when it arrives
expect(action).toMatchObject({originalMessage: {oldValue: undefined, newValue: ''}});
});

it('should use the saved value as the old value when the field has one', () => {
// Given a text field whose saved value differs from its default
const previousReportField = {...textField, value: 'Saved'};

// When the user clears it
const action = buildOptimisticChangeFieldAction({...textField, value: ''}, previousReportField, 1);

// Then the action records the saved value, not the default
expect(action).toMatchObject({originalMessage: {oldValue: 'Saved', newValue: ''}});
});
});

describe('hasVisibleReportFieldViolations', () => {
const policyID = 'policy-field-violations';

Expand Down
Loading