Skip to content

Commit

Permalink
UI-9249 - The default selected drillthrough columns setting is migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
Nouzbe committed Mar 14, 2024
1 parent d408ca6 commit 6a9397b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/4.3_to_5.0/migrateSettingsFolder.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 6a9397b

Please sign in to comment.