-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI-9249 - Migrate default selected drillthrough columns #123
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
|
@@ -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, | ||
); | ||
} | ||
Comment on lines
+72
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implies that two drillthrough columns with the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. In fact there are even two ways to have duplicates:
So we don't want to save each column twice in the new Atoti UI 5 setting. The other way is more rare. It is because UI4 was saving the columns per server and per cube whereas UI5 only stores them per cube. So you could have a duplicate because a column was save for a cube with the same name under two different servers. The current implementation in this PR should get rid of any duplicate, whether they come from the first way or the second one I described here. |
||
|
||
return migratedSettingsMap; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is considered duplicates, so we are testing that part of the implementation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is considered duplicates indeed. It's the first way to have duplicate I described above.
I also tested the second way of having duplicates, as I added the column
subTradeId
inMarketRiskCube
under two different servers.