-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI-8532 - Take hidden columns into account during table migrations fr…
…om 4.3 to 5.0 (#114)
- Loading branch information
Showing
7 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/4.3_to_5.0/__test_resources__/legacyPivotTableWithCrossjoinOnColumnsAndHiddenColumns.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { LegacyWidgetState } from "../migration.types"; | ||
|
||
/** | ||
* The state of a legacy pivot table with Dates, LegalEntities, pnl.FOREX and pnl.SUM on columns and one column is hidden. | ||
*/ | ||
export const legacyPivotTableWithCrossjoinOnColumnsAndHiddenColumns: LegacyWidgetState = | ||
{ | ||
name: "Untitled Pivot Table", | ||
type: "container", | ||
value: { | ||
body: { | ||
mdx: "SELECT NON EMPTY Crossjoin([Time].[HistoricalDates].[AsOfDate].Members, Hierarchize(DrilldownLevel([Booking].[Desk].[ALL].[AllMember])), {[Measures].[pnl.FOREX], [Measures].[pnl.SUM]}) ON COLUMNS, NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS FROM [EquityDerivativesCube] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS", | ||
configuration: { | ||
tabular: { | ||
columns: [ | ||
{ | ||
key: "([Time].[HistoricalDates].[AsOfDate].[2023-09-05],[Booking].[Desk].[ALL].[AllMember].[LegalEntityA],[Measures].[pnl.FOREX])", | ||
hide: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
containerKey: "pivot-table", | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
src/4.3_to_5.0/__test_resources__/legacyPivotTableWithHiddenColumns.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { LegacyWidgetState } from "../migration.types"; | ||
|
||
/** | ||
* The state of a legacy pivot table with dates on columns and one column is hidden. | ||
*/ | ||
export const legacyPivotTableWithHiddenColumns: LegacyWidgetState = { | ||
name: "Untitled Pivot Table", | ||
type: "container", | ||
value: { | ||
body: { | ||
mdx: "SELECT NON EMPTY [Time].[HistoricalDates].[AsOfDate].Members ON COLUMNS, NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS FROM [EquityDerivativesCube] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS", | ||
configuration: { | ||
tabular: { | ||
columns: [ | ||
{ | ||
key: "[Time].[HistoricalDates].[AsOfDate].[2023-09-05]", | ||
hide: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
containerKey: "pivot-table", | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
src/4.3_to_5.0/__test_resources__/legacyTableWithHiddenColumns.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { LegacyWidgetState } from "../migration.types"; | ||
|
||
/** | ||
* The state of a legacy table with Currency and City on rows and contributors.COUNT on columns. | ||
* The "City" column is hidden. | ||
*/ | ||
export const legacyTableWithHiddenColumns: LegacyWidgetState = { | ||
type: "container", | ||
name: "Untitled Tabular View", | ||
value: { | ||
body: { | ||
mdx: "SELECT NON EMPTY Crossjoin([Currency].[Currency].[Currency].Members, [Geography].[City].[City].Members) ON ROWS, [Measures].[contributors.COUNT] ON COLUMNS FROM [EquityDerivativesCube] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS", | ||
configuration: { | ||
tabular: { | ||
columns: [ | ||
{ | ||
key: "[Geography].[City].[City]", | ||
hide: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
containerKey: "tabular-view", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { legacyPivotTableWithCrossjoinOnColumnsAndHiddenColumns } from "./__test_resources__/legacyPivotTableWithCrossjoinOnColumnsAndHiddenColumns"; | ||
import { legacyPivotTableWithHiddenColumns } from "./__test_resources__/legacyPivotTableWithHiddenColumns"; | ||
import { legacyTableWithHiddenColumns } from "./__test_resources__/legacyTableWithHiddenColumns"; | ||
import { _getHiddenColumnKeys } from "./_getHiddenColumnKeys"; | ||
|
||
describe("_getHiddenColumnKeys", () => { | ||
it("returns the hidden column keys in a table with a static header column hidden", () => { | ||
const hiddenColumnKeys = _getHiddenColumnKeys(legacyTableWithHiddenColumns); | ||
expect(hiddenColumnKeys).toMatchInlineSnapshot(` | ||
[ | ||
"[Geography].[City].[City]", | ||
] | ||
`); | ||
}); | ||
|
||
it("returns the hidden column keys in a pivot table with a body column hidden", () => { | ||
const hiddenColumnKeys = _getHiddenColumnKeys( | ||
legacyPivotTableWithHiddenColumns, | ||
); | ||
expect(hiddenColumnKeys).toMatchInlineSnapshot(` | ||
[ | ||
"[Time].[HistoricalDates].[AsOfDate].[2023-09-05]", | ||
] | ||
`); | ||
}); | ||
|
||
it("returns the hidden column keys in a table with a crossjoin on columns and a body column hidden", () => { | ||
const hiddenColumnKeys = _getHiddenColumnKeys( | ||
legacyPivotTableWithCrossjoinOnColumnsAndHiddenColumns, | ||
); | ||
expect(hiddenColumnKeys).toMatchInlineSnapshot(` | ||
[ | ||
"[Time].[HistoricalDates].[AsOfDate].[2023-09-05],[Booking].[Desk].[ALL].[AllMember].[LegalEntityA],[Measures].[pnl.FOREX]", | ||
] | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { LegacyWidgetState } from "./migration.types"; | ||
|
||
/** | ||
* Returns the keys identifying the hidden columns in `legacyTableState`. | ||
*/ | ||
export function _getHiddenColumnKeys( | ||
legacyTableState: LegacyWidgetState, | ||
): string[] | undefined { | ||
const columns: { key: string; hide?: boolean }[] | undefined = | ||
legacyTableState?.value?.body?.configuration?.tabular?.columns; | ||
|
||
if (!columns) { | ||
return; | ||
} | ||
|
||
const hiddenColumnKeys = columns | ||
.filter(({ hide }) => hide === true) | ||
.map(({ key }) => | ||
key.startsWith("(") && key.endsWith(")") ? key.slice(1, -1) : key, | ||
); | ||
|
||
return hiddenColumnKeys; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters