-
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-8630 - Hidden table columns are taken into account by the 4.3 -> 5…
….0 migration
- Loading branch information
Showing
7 changed files
with
107 additions
and
19 deletions.
There are no files selected for viewing
37 changes: 20 additions & 17 deletions
37
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 |
---|---|---|
@@ -1,23 +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 = { | ||
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, | ||
}, | ||
], | ||
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", | ||
}, | ||
containerKey: "pivot-table", | ||
}, | ||
}; | ||
}; |
4 changes: 3 additions & 1 deletion
4
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
4 changes: 3 additions & 1 deletion
4
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
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