-
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
[Controls] [Dashboard] Allow existing controls to change type #129385
[Controls] [Dashboard] Allow existing controls to change type #129385
Conversation
e7ce8a1
to
af7e998
Compare
af7e998
to
dca35f2
Compare
src/plugins/controls/public/control_group/component/control_frame_component.tsx
Show resolved
Hide resolved
src/plugins/controls/public/control_group/editor/edit_control.tsx
Outdated
Show resolved
Hide resolved
src/plugins/controls/public/control_types/options_list/options_list_editor.tsx
Show resolved
Hide resolved
70db39d
to
54bf146
Compare
54bf146
to
7a7fdac
Compare
5bcdf06
to
26f84ec
Compare
Pinging @elastic/kibana-presentation (Team:Presentation) |
src/plugins/controls/public/control_group/embeddable/control_group_container.tsx
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.
This is looking great! Left one DX / style comment, and a couple questions, but I think this is overall very well done! As I said in our sync earlier, I can't wait to use this code to simplify all the other places where embeddable panels get swapped out. This could go a long way towards making our containers more responsive.
Also, it looks as though you've accomplished this while keeping the same embeddable id, which is super cool.
src/plugins/controls/public/control_group/editor/edit_control.tsx
Outdated
Show resolved
Hide resolved
src/plugins/controls/public/control_group/embeddable/control_group_container.tsx
Outdated
Show resolved
Hide resolved
src/plugins/controls/public/control_types/options_list/options_list_editor.tsx
Show resolved
Hide resolved
test/functional/apps/dashboard_elements/controls/control_group_settings.ts
Show resolved
Hide resolved
throw new EmbeddableFactoryNotFoundError(newType); | ||
} | ||
|
||
newExplicitInput.id = id; |
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 way to avoid mutation here?
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.
@tsullivan Good catch! I did it this way instead:
this.updateInput({
panels: {
...
explicitInput: { ...newExplicitInput, id },
...
…nawter/kibana into allow-control-type-change_2022-03-28
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.
embeddable Code lgtm,
I also tested in an example plugin that updating input of dashboard controller panel with a different type/input properly replaces it ( which matches internal implementation of the new replace method)
Does this replace functionality covered by functional tests? I assume so and looks like yes
@Dosant Yes, I added functional tests to test this! :) Only for controls for now, but we can expand the other replace-related functional tests and the related Jest tests in a follow up PR that will make use of this new functionality in other places, such as panel cloning - I felt as though it was best to keep all changes in this PR as contained within control as possible 👍 |
e528126
to
9c55499
Compare
💚 Build SucceededMetrics [docs]Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: cc @Heenawter |
…c#129385) * Replace is half working * Child embeddable listens for change in type * Fix control order on replace * Fix factory & remove duplicated onPanelAdded/Removed * Comments + clean up code * Set invalid editor state on type change * Add functional tests and clean test code * Comment out time slider tests * Remove getReplacementPanelState * Fix promise syntax * Fix mutation * Fix flaky test * Fix conflicts
Closes #128195
Summary
This PR introduces the ability to replace an existing control embeddable with one of a different type via the new container function
replaceEmbeddable
.While the
replaceEmbeddable
function is designed to be a generic function that could apply to other embeddables, for the sake of keeping this PR simple, I only used it for controls for now - in future PRs, we could use thisreplaceEmbeddable
function in other places, such as in thereplacePanel
code in the Dashboard container (dashboard_container.ts
) to reduce duplicated code.Video
2022-05-02_ReplaceControlType.mp4
Flaky Test Runner
Checklist
For maintainers