-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Embeddable Rebuild] Support grouping in ADD_PANEL_TRIGGER #179872
[Embeddable Rebuild] Support grouping in ADD_PANEL_TRIGGER #179872
Conversation
/ci |
Pinging @elastic/kibana-presentation (Team:Presentation) |
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 works great! Tested in chrome and the groupings were applied as expected.
I'm wondering though, if you would do another pass on DX for this change? It seems to me that this file is (and has been) in need of a bit of an organizational cleanup to lower the number of lines + the cognitive load.
The jest tests are looking great also, and I see you've added coverage for all the new functionality. Thanks for that!
@@ -21,8 +21,40 @@ describe('getAddPanelActionMenuItems', () => { | |||
isCompatible: () => Promise.resolve(true), | |||
execute: jest.fn(), | |||
}, | |||
{ |
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 new test case is great! Really good test coverage in this PR as a whole.
}; | ||
}; | ||
|
||
export const mergeGroupedItemsProvider = |
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.
Is there a reason these need to be curried functions? Could it be simpler with all arguments taken in one function call?
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.
Just to separate the dependencies of the function and the input arguments. I don't have strong preferences here, so whatever pattern the team prefer
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 usually avoid curried functions unless they're necessary, but it's completely up to you. I consider this file to mainly be temporary as we have a cleanup followup issue.
@@ -41,6 +46,97 @@ interface UnwrappedEmbeddableFactory { | |||
isEditable: boolean; | |||
} | |||
|
|||
export type GetEmbeddableFactoryMenuItem = ReturnType<typeof getEmbeddableFactoryMenuItemProvider>; | |||
|
|||
export const getEmbeddableFactoryMenuItemProvider = |
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.
Does this need to be a separate function? I see it's exported for test coverage, but I suspect it might be more robust to test this editor menu as a React component via @testing-library/react
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, I made it a separate function to test the functionality I added.
It's indeed can be a jest test with @testing-library/react
, but there were no tests for this file whatsoever. I want to keep changes to a minimum to unblock #179547
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.
Ideally, it should be covered with functional tests using FTR. I plan to add some in #179547, because first it needs this PR to get into main
.
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 strategy sounds good to me. These tests provide good coverage for the time being.
src/plugins/dashboard/public/dashboard_app/top_nav/add_panel_action_menu_items.ts
Outdated
Show resolved
Hide resolved
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.
Approving to unblock - even though the file is still quite messy, it's more important to move forward for the time being Likely we can do this cleanup I'm imagining once we remove the legacy Embeddable system. I've opened a followup issue here.
@@ -41,6 +46,97 @@ interface UnwrappedEmbeddableFactory { | |||
isEditable: boolean; | |||
} | |||
|
|||
export type GetEmbeddableFactoryMenuItem = ReturnType<typeof getEmbeddableFactoryMenuItemProvider>; | |||
|
|||
export const getEmbeddableFactoryMenuItemProvider = |
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 strategy sounds good to me. These tests provide good coverage for the time being.
}; | ||
}; | ||
|
||
export const mergeGroupedItemsProvider = |
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 usually avoid curried functions unless they're necessary, but it's completely up to you. I consider this file to mainly be temporary as we have a cleanup followup issue.
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!
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @darnautov |
Summary
Resolves #179565
Adds support for the
grouping
property in actions assigned to theADD_PANEL_TRIGGER
trigger.In the "Add panel" context menu, groups from the embeddable factories and
ADD_PANEL_TRIGGER
actions are merged, allowing us to group legacy embeddables with the react ones.Checklist