-
Notifications
You must be signed in to change notification settings - Fork 122
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
refactor(partition): improving on chart events and callbacks #991
Conversation
* - replace users' use of `s.parent` with `s[MODEL_KEY]` for the ShapeTreeNode -> ArrayNode access | ||
* - change MODEL_KEY to something other than 'parent' when it's done (might still be breaking change) | ||
*/ | ||
export const MODEL_KEY = 'whatever'; |
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 specific string "whatever"
is of course just for while it's WIP; it'll be parent
in the final form of this PR for API compat, but then the usage of .parent
can/should be deprecated, to allow us to eventually rename it to eg. model
, or even, provide direct access to the model
props in the callback functions so this internal representation detail doesn't leak out (my preference, for flatness, not sure if in this PR or in the future)
{ | ||
groupByRollup: 'b', | ||
value: 2, | ||
depth: 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.
More props for the event callback!
@@ -35,6 +35,10 @@ export const Example = () => { | |||
legendStrategy={LegendStrategy.PathWithDescendants} | |||
legendMaxDepth={maxDepth} | |||
theme={STORYBOOK_LIGHT_THEME} | |||
onElementClick={(e) => { | |||
// eslint-disable-next-line no-console | |||
console.log(e); |
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.
WIP, to see the change in playground
Codecov Report
@@ Coverage Diff @@
## master #991 +/- ##
==========================================
- Coverage 72.63% 72.57% -0.06%
==========================================
Files 350 366 +16
Lines 11050 10669 -381
Branches 2433 2197 -236
==========================================
- Hits 8026 7743 -283
+ Misses 3010 2828 -182
- Partials 14 98 +84
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -159,7 +159,7 @@ export interface ShapeTreeNode extends TreeNode, SectorGeomSpecY { | |||
path: LegendPath; | |||
dataName: DataName; | |||
value: number; | |||
parent: ArrayNode; | |||
[MODEL_KEY]: ArrayNode; |
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.
That seems fine to me. Are you trying to avoid breaking changes? I'd say this would be breaking.
One way to somewhat deafen a breaking change would be to keep the parent
key but add the @deprecated
flag. Replace all usage in kibana with the MODEL_KEY
string. Then later we could change the name but it would be a cleaner breaking change when we remove parent
.
[MODEL_KEY]: ArrayNode; | |
/** @deprecated use `MODEL_KEY` instead */ | |
parent: ArrayNode; | |
[MODEL_KEY]: ArrayNode; |
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.
Thanks Nick! The plan would be:
Full compatibility stage, no breaking API, eg. after merging this PR ("whatever"
changed back to "parent"
)
- we still call it
parent
- everything still works and compliant with our API
- a new value appears in the API,
MODEL_KEY
Deprecation stage:
- we and users can start replace
.parent
with[MODEL_KEY]
- still compatible with the API as is; something gets a
@deprecated
tag, at least conceptually, as I think we can't have two identically named props at the same time, though haven't tried
Breaking change:
- When nobody in at least Kibana uses
.parent
for the model, we make the breaking change ofconst MODEL_KEY = 'model'
- though it's a breaking change, it'll no longer impact known users due to our assist during deprecation, while other users simply need to deal with a changing API
I'm not sure if the proposed commit would still work, pls. indicate if that's the case, glad to try. At least from the diff, it's not clear what the deprecation line belongs to
Cherrypicked commit e1bef27 is just tighter types, a rename and solving linter warnings with class methods that don't use |
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.
LGTM, provided the class methods are changed to non-fat arrow functions. 👍🏼
@@ -60,6 +60,7 @@ interface MapNode extends NodeDescriptor { | |||
/** @internal */ | |||
export const HIERARCHY_ROOT_KEY: Key = '__root_key__'; | |||
|
|||
/** @public */ | |||
export type PrimitiveValue = string | number | null; // there could be more but sufficient for now | |||
type Key = CategoryKey; |
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.
Not a huge fan of redefining types like this. But can be changed later.
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.
yes, let's chat
🎉 This PR is included in version 24.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
This PR
any
s and inferred typespath
,depth
not complete; I've some further simplification plan, subject to discussionChecklist
Delete any items that are not applicable to this PR.
src/index.ts
(and stories only import from../src
except for test data & storybook)