-
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-8742 - More robust MDX cleanup #115
Changes from 5 commits
3f04f98
66f86d6
c2b436b
90ca332
30f7167
f747c99
cb3e7c4
605b821
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This module is a transitive dependency of @activeviam packages. | ||
// It is used in the browser in Atoti UI, but it is not necessary for atoti-ui-migration. | ||
// See https://github.com/activeviam/atoti-ui-migration/blob/c06e91517d4898bf54e919944e49fae6e270036c/jest.config.js#L7-L8 | ||
module.exports = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,15 +28,15 @@ | |
"trailingComma": "all" | ||
}, | ||
"devDependencies": { | ||
"@activeviam/activeui-sdk-5.0": "npm:@activeviam/[email protected]20230915115910-fc34c05", | ||
"@activeviam/activeui-sdk-5.1": "npm:@activeviam/[email protected].8", | ||
"@activeviam/activeui-sdk-scripts": "5.0.29-20230915115910-fc34c05", | ||
"@activeviam/content-server-initialization-5.0": "npm:@activeviam/[email protected]20230915115910-fc34c05", | ||
"@activeviam/dashboard-base-5.1": "npm:@activeviam/[email protected].8", | ||
"@activeviam/data-model-5.0": "npm:@activeviam/[email protected]20230915115910-fc34c05", | ||
"@activeviam/data-model-5.1": "npm:@activeviam/[email protected].8", | ||
"@activeviam/mdx-5.0": "npm:@activeviam/[email protected]20230915115910-fc34c05", | ||
"@activeviam/mdx-5.1": "npm:@activeviam/[email protected].8", | ||
"@activeviam/activeui-sdk-5.0": "npm:@activeviam/[email protected]20230925104351-05a6f39", | ||
"@activeviam/activeui-sdk-5.1": "npm:@activeviam/[email protected].9-20230925084242-888ae49", | ||
"@activeviam/activeui-sdk-scripts": "5.0.29-20230925104351-05a6f39", | ||
"@activeviam/content-server-initialization-5.0": "npm:@activeviam/[email protected]20230925104351-05a6f39", | ||
"@activeviam/dashboard-base-5.1": "npm:@activeviam/[email protected].9-20230925084242-888ae49", | ||
"@activeviam/data-model-5.0": "npm:@activeviam/[email protected]20230925104351-05a6f39", | ||
"@activeviam/data-model-5.1": "npm:@activeviam/[email protected].9-20230925084242-888ae49", | ||
"@activeviam/mdx-5.0": "npm:@activeviam/[email protected]20230925104351-05a6f39", | ||
"@activeviam/mdx-5.1": "npm:@activeviam/[email protected].9-20230925084242-888ae49", | ||
"@swc/core": "^1.3.31", | ||
"@swc/jest": "^0.2.24", | ||
"@types/cli-progress": "^3.11.0", | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,9 @@ | ||||||
import { Mdx, Cube } from "@activeviam/activeui-sdk-5.0"; | ||||||
import { getHierarchy, getLevelIndex } from "@activeviam/data-model-5.0"; | ||||||
import { | ||||||
getHierarchy, | ||||||
getLevelIndex, | ||||||
areHierarchiesEqual, | ||||||
} from "@activeviam/data-model-5.0"; | ||||||
import { | ||||||
MdxFunction, | ||||||
findDescendant, | ||||||
|
@@ -17,15 +21,26 @@ const canDrilldownLevelBeReplacedByItsFirstArgument = ( | |||||
drilldownLevelNode: MdxFunction, | ||||||
cube: Cube, | ||||||
) => { | ||||||
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 function seems to have been improved in some cases. Don't clean up drilldownlevel if:
Can you add unit tests in order to illustrate and test these improvements? 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. Replace if both these conditions are met:
I'll add a comment. |
||||||
const set = drilldownLevelNode.arguments[0]; | ||||||
const levelsInSet = getLevels(set, { cube }); | ||||||
const [set, ...otherArguments] = drilldownLevelNode.arguments; | ||||||
if (otherArguments.length > 0) { | ||||||
// Do not attempt to cleanup the more complex DrilldownLevel expressions. | ||||||
return false; | ||||||
} | ||||||
|
||||||
const hierarchyCoordinates = getHierarchies(set, { cube })[0]; | ||||||
const hierarchy = getHierarchy(hierarchyCoordinates, cube); | ||||||
|
||||||
const levelsInSet = getLevels(set, { | ||||||
cube, | ||||||
}).filter((levelCorodinates) => | ||||||
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.
Suggested change
|
||||||
areHierarchiesEqual(levelCorodinates, hierarchyCoordinates), | ||||||
); | ||||||
const deepestLevelIndexInSet = Math.max( | ||||||
...levelsInSet.map((levelCoordinates) => | ||||||
getLevelIndex({ cube, ...levelCoordinates }), | ||||||
), | ||||||
); | ||||||
const hierarchyCoordinates = getHierarchies(set, { cube })[0]; | ||||||
const hierarchy = getHierarchy(hierarchyCoordinates, cube); | ||||||
|
||||||
return deepestLevelIndexInSet === hierarchy.levels.length - 1; | ||||||
}; | ||||||
|
||||||
|
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.
We were actually checking something invalid with the previous input:
should NOT be replaced by just
LegalEntityA
.Indeed the level at distance 1 from
LegalEntityA
isBusinessUnit
.However in the new test input:
the Descendants node should be replaced by the
0
BookId, since it doesn't have descendants anyway.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.
Can we also keep a test for the
LegalEntityA
case which seems to have been broken but that you fixed in this PR (right?)