-
Notifications
You must be signed in to change notification settings - Fork 916
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
[VisBuilder] 2 way communication using UI actions and bug fixes #3732
[VisBuilder] 2 way communication using UI actions and bug fixes #3732
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #3732 +/- ##
==========================================
+ Coverage 66.42% 66.44% +0.02%
==========================================
Files 3209 3209
Lines 61733 61741 +8
Branches 9534 9537 +3
==========================================
+ Hits 41005 41023 +18
+ Misses 18441 18429 -12
- Partials 2287 2289 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
8cbc8f8
to
f4f2cf0
Compare
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.
Looks good! I have a few clarifying questions and comments and a couple of minor requested changes. I still want to play with it a little locally, but my readthrough is done.
src/plugins/vis_builder/public/saved_visualizations/transforms.test.ts
Outdated
Show resolved
Hide resolved
src/plugins/vis_builder/public/application/utils/handle_vis_event.ts
Outdated
Show resolved
Hide resolved
src/plugins/vis_builder/public/application/utils/handle_vis_event.ts
Outdated
Show resolved
Hide resolved
import { VIS_EVENT_TO_TRIGGER } from '../../../../visualizations/public'; | ||
import { UiActionsStart } from '../../../../ui_actions/public'; | ||
|
||
export const handleVisEvent = async ( |
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 a question, do we need to add error handling 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.
How do see error handling being added 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.
Mmm i am mostly thinking if it's possible that await uiActions.getTrigger()
fail?
handleVisEvent(event, getUIActions(), indexPattern.timeFieldName); | ||
} | ||
}) | ||
); |
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 you explain more why we add the subscriptions to the events 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.
The underlying expression renderer may want to transmit user actions to the parent app, it does so by using the expression renderer's event bus. So when the parent application wants to listen to these events, it needs to subscribe to that bus. In the embeddable, the handler.events
is that bus, and for ReactExpressionRenderer
, the onEvent
callback is that bus. In both cases, we want to listen to the event, condition it and trasmit a corresponding UI Action for the event. handleVisEvent
is responsible for conditioning the event and transmitting the UIAction
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.
Got it, thanks for the explainations!
// TODO: add indexPatterns as part of configuration | ||
// indexPatterns?: IIndexPattern[]; | ||
editPath: string; | ||
editUrl: string; | ||
editable: boolean; | ||
} | ||
|
||
export type VisBuilderInput = SavedObjectEmbeddableInput; |
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.
nit: should we be more specific on the type name here? VisBuilderEmbeddableInput
and VisBuilderEmbeddableOutput
?
Think it would be clearer, but it's fine either way.
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.
You are right, that is much more explicit. However, since the UI state PR also affects the same files, i'd avoid making this change now though. Is that okay?
Signed-off-by: Ashwin P Chandran <[email protected]> Co-authored-by: Josh Romero <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]> Co-authored-by: Josh Romero <[email protected]>
…ent.ts Signed-off-by: Ashwin P Chandran <[email protected]> Co-authored-by: Josh Romero <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
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 - a couple minor nits and opinions, but nothing blocking.
@@ -121,3 +121,7 @@ const OptionItem = ({ icon, title }: { icon: IconType; title: string }) => ( | |||
<span>{title}</span> | |||
</> | |||
); | |||
|
|||
// The app uses EuiResizableContainer that triggers a rerender for ever mouseover action. |
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.
// The app uses EuiResizableContainer that triggers a rerender for ever mouseover action. | |
// The app uses EuiResizableContainer that triggers a rerender for every mouseover action. |
@@ -44,15 +46,17 @@ export const Workspace: FC = ({ children }) => { | |||
async function loadExpression() { | |||
const schemas = ui.containerConfig.data.schemas; | |||
|
|||
const noAggs = aggConfigs?.aggs?.length === 0; | |||
const noAggs = (aggConfigs?.aggs?.length ?? 0) === 0; |
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.
opinion - this reads worse to me than
const noAggs = !aggConfigs?.aggs?.length;
or even
const noAggs = aggConfigs?.aggs?.length == false;
Also, for conditionals like this I'd prefer hasNoAggs
.
src/plugins/vis_builder/public/application/utils/handle_vis_event.ts
Outdated
Show resolved
Hide resolved
* adds uiActions to visBuilder * prevents multiple errors on load * fixes visbuilder type errors * fixes save * updates changelog --------- Signed-off-by: Ashwin P Chandran <[email protected]> Co-authored-by: Josh Romero <[email protected]> (cherry picked from commit 1edb195) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
…bug fixes (#3857) * [VisBuilder] 2 way communication using UI actions and bug fixes (#3732) * adds uiActions to visBuilder * prevents multiple errors on load * fixes visbuilder type errors * fixes save * updates changelog --------- Signed-off-by: Ashwin P Chandran <[email protected]> Co-authored-by: Josh Romero <[email protected]> (cherry picked from commit 1edb195) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md * add changelog Signed-off-by: Josh Romero <[email protected]> --------- Signed-off-by: Josh Romero <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Josh Romero <[email protected]>
…search-project#3732) * adds uiActions to visBuilder * prevents multiple errors on load * fixes visbuilder type errors * fixes save * updates changelog --------- Signed-off-by: Ashwin P Chandran <[email protected]> Co-authored-by: Josh Romero <[email protected]> Signed-off-by: David Sinclair <[email protected]>
Description
This PR add 2 way communication to VisBuilder And fixes a few bugs along the way. I've added comments to the section of the code that are bug fixes and not related to the UIActions change.
To add 2 way communication, the existing UI actions framework was reused and the existing actions were simply passed along transparently to the UI. The main task long term is to document and standardize these actions so that a variety of visualization types can use the same actions
Demo:
Screen.Recording.2023-03-30.at.6.49.08.PM.mov
Issues Resolved
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr