From 6a9397b88eb242eef9d196323fb6ca98f265b560 Mon Sep 17 00:00:00 2001 From: Benjamin Amelot Date: Thu, 14 Mar 2024 17:24:53 +0100 Subject: [PATCH] UI-9249 - The default selected drillthrough columns setting is migrated --- src/4.3_to_5.0/migrateSettingsFolder.ts | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/4.3_to_5.0/migrateSettingsFolder.ts b/src/4.3_to_5.0/migrateSettingsFolder.ts index 82b7ec79..d5907147 100644 --- a/src/4.3_to_5.0/migrateSettingsFolder.ts +++ b/src/4.3_to_5.0/migrateSettingsFolder.ts @@ -1,5 +1,6 @@ import _cloneDeep from "lodash/cloneDeep"; import _mapValues from "lodash/mapValues"; +import _uniq from "lodash/uniq"; import _pick from "lodash/pick"; import type { Activity, @@ -38,6 +39,43 @@ function migrateSettingsMap(legacySettingsMap: { migratedSettingsMap["userFilters.areEnabled"] = areUserFiltersEnabled; } + const legacyDrillthroughColumns: + | { + [serverUrl: string]: { + [cubeName: string]: { + functionName: "Value" | "Caption" | "MemberValue" | "MemberCaption"; + columnName: string; + }[]; + }; + } + | undefined = + legacySettingsMap["widgets.Tabular.drillthrough.selectedColumns"]; + + if (legacyDrillthroughColumns !== undefined) { + const migratedDrillthroughColumns: Settings["drillthrough.defaultSelectedColumns"] = + {}; + // The legacy settings are per server and per cube. + // The new ones are only per cube: the assumption is that no customer has multiple servers containing a cube with the same name but exposing a different data model. + for (const serverUrl in legacyDrillthroughColumns) { + for (const cubeName in legacyDrillthroughColumns[serverUrl]) { + if (migratedDrillthroughColumns[cubeName] === undefined) { + migratedDrillthroughColumns[cubeName] = []; + } + migratedDrillthroughColumns[cubeName].push( + ...legacyDrillthroughColumns[serverUrl][cubeName].map( + ({ columnName }) => columnName, + ), + ); + } + } + + // Remove duplicates. + migratedSettingsMap["drillthrough.defaultSelectedColumns"] = _mapValues( + migratedDrillthroughColumns, + _uniq, + ); + } + return migratedSettingsMap; }