From ae35d0339f46467a91695f3243ec22be34a164df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre=20=28lul=29?= Date: Fri, 20 Sep 2024 13:02:08 +0000 Subject: [PATCH] [FIX] pivot: divergent collaborative duplicated pivot name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, if two users are connected to the same spreadsheet, both have different languages and one of them duplicates a pivot: the spreadsheet states have diverged because `_t(...)` gives two different results on both sides. Note that the command should ideally be upgraded with a script, but it's not possible to get the original pivot name on the upgrade platform. closes odoo/o-spreadsheet#5075 Task: 4199949 X-original-commit: e98ad44c1f2567c4d2ead1e509a47fc6020c9504 Signed-off-by: RĂ©mi Rahir (rar) --- src/plugins/core/pivot.ts | 2 +- src/plugins/ui_feature/insert_pivot.ts | 1 + src/types/commands.ts | 2 ++ tests/test_helpers/constants.ts | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/core/pivot.ts b/src/plugins/core/pivot.ts index 99766dac54..1849b542c5 100644 --- a/src/plugins/core/pivot.ts +++ b/src/plugins/core/pivot.ts @@ -115,7 +115,7 @@ export class PivotCorePlugin extends CorePlugin implements CoreState case "DUPLICATE_PIVOT": { const { pivotId, newPivotId } = cmd; const pivot = deepCopy(this.getPivotCore(pivotId).definition); - pivot.name = _t("%s (copy)", pivot.name); + pivot.name = cmd.duplicatedPivotName ?? pivot.name + " (copy)"; this.addPivot(newPivotId, pivot); break; } diff --git a/src/plugins/ui_feature/insert_pivot.ts b/src/plugins/ui_feature/insert_pivot.ts index 2fdca18b70..5eb438b809 100644 --- a/src/plugins/ui_feature/insert_pivot.ts +++ b/src/plugins/ui_feature/insert_pivot.ts @@ -80,6 +80,7 @@ export class InsertPivotPlugin extends UIPlugin { this.dispatch("DUPLICATE_PIVOT", { pivotId, newPivotId, + duplicatedPivotName: _t("%s (copy)", this.getters.getPivotCoreDefinition(pivotId).name), }); const activeSheetId = this.getters.getActiveSheetId(); const position = this.getters.getSheetIds().indexOf(activeSheetId) + 1; diff --git a/src/types/commands.ts b/src/types/commands.ts index 5310291d2e..30d1a6bd99 100644 --- a/src/types/commands.ts +++ b/src/types/commands.ts @@ -653,6 +653,8 @@ export interface DuplicatePivotCommand { type: "DUPLICATE_PIVOT"; pivotId: UID; newPivotId: string; + // an early version of the command did not include the duplicatedPivotName + duplicatedPivotName?: string; } // ------------------------------------------------ diff --git a/tests/test_helpers/constants.ts b/tests/test_helpers/constants.ts index 1c4b09d0df..21a9343c69 100644 --- a/tests/test_helpers/constants.ts +++ b/tests/test_helpers/constants.ts @@ -447,6 +447,7 @@ export const TEST_COMMANDS: CommandMapping = { type: "DUPLICATE_PIVOT", pivotId: "1", newPivotId: "2", + duplicatedPivotName: "newName", }, RENAME_PIVOT: { type: "RENAME_PIVOT",