diff --git a/src/4.3_to_5.0/__snapshots__/migrateSettingsFolder.test.ts.snap b/src/4.3_to_5.0/__snapshots__/migrateSettingsFolder.test.ts.snap index 7136cc4e..2b6527d3 100644 --- a/src/4.3_to_5.0/__snapshots__/migrateSettingsFolder.test.ts.snap +++ b/src/4.3_to_5.0/__snapshots__/migrateSettingsFolder.test.ts.snap @@ -97,7 +97,7 @@ exports[`migrateSettingsFolder returns the folders corresponding to the converte }, "settings": { "entry": { - "content": "{"userFilters.areEnabled":false}", + "content": "{"userFilters.areEnabled":false,"drillthrough.defaultSelectedColumns":{"MarketRiskCube":["riskCurrency","subTradeId","EntityName"],"SecondCube":["delta"]}}", "owners": [ "user1", ], diff --git a/src/4.3_to_5.0/__snapshots__/migrate_43_to_50.test.ts.snap b/src/4.3_to_5.0/__snapshots__/migrate_43_to_50.test.ts.snap index 10fab4a8..9dfbda93 100644 --- a/src/4.3_to_5.0/__snapshots__/migrate_43_to_50.test.ts.snap +++ b/src/4.3_to_5.0/__snapshots__/migrate_43_to_50.test.ts.snap @@ -1277,7 +1277,7 @@ exports[`migrate_43_to_50 returns a valid ActiveUI5 /ui folder on a real life in }, "settings": { "entry": { - "content": "{"userFilters.areEnabled":false}", + "content": "{"userFilters.areEnabled":false,"drillthrough.defaultSelectedColumns":{"MarketRiskCube":["riskCurrency","subTradeId","EntityName"],"SecondCube":["delta"]}}", "owners": [ "user1", ], @@ -2420,7 +2420,7 @@ exports[`migrate_43_to_50 returns a valid ActiveUI5 /ui folder on a small input }, "settings": { "entry": { - "content": "{"theme":"dark-activeviam","search.maxResults":10,"userFilters.areEnabled":true}", + "content": "{"theme":"dark-activeviam","search.maxResults":10,"userFilters.areEnabled":true,"drillthrough.defaultSelectedColumns":{"EquityDerivativesCube":["delta","gamma","pnlVega","Desk","Currency","Date","HostName"],"EquityDerivativesCubeDist":["BumpedMtmDown","ProductQtyMultiplier","vega","rho","productId","pnlVega","pnlDelta","pnl","gamma","delta","TradeId","ProductBaseMtm"]}}", "owners": [ "admin", ], diff --git a/src/4.3_to_5.0/legacySettingsFolder.ts b/src/4.3_to_5.0/legacySettingsFolder.ts index 179326a9..f2ac97af 100644 --- a/src/4.3_to_5.0/legacySettingsFolder.ts +++ b/src/4.3_to_5.0/legacySettingsFolder.ts @@ -14,6 +14,58 @@ const user1Preferences = { deny: [], map: { "userFilters.enabled": true, + "widgets.Tabular.drillthrough.selectedColumns": { + "https://activerisk.zone1.scb.net:8081/server": { + MarketRiskCube: [ + { + functionName: "MemberValue", + columnName: "riskCurrency", + }, + { + functionName: "Caption", + columnName: "riskCurrency", + }, + { + functionName: "MemberValue", + columnName: "subTradeId", + }, + { + functionName: "Caption", + columnName: "subTradeId", + }, + ], + SecondCube: [ + { + functionName: "MemberValue", + columnName: "delta", + }, + { + functionName: "Caption", + columnName: "delta", + }, + ], + }, + "https://second-server.com": { + MarketRiskCube: [ + { + functionName: "MemberValue", + columnName: "subTradeId", + }, + { + functionName: "Caption", + columnName: "subTradeId", + }, + { + functionName: "MemberValue", + columnName: "EntityName", + }, + { + functionName: "Caption", + columnName: "EntityName", + }, + ], + }, + }, }, }; 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; }