[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 <ashwinpc@amazon.com>
Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com>
Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com>
Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com>
Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com>
8cbc8f8 to
f4f2cf0
Compare
joshuarrrr
left a comment
There was a problem hiding this comment.
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.
| 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.
Just a question, do we need to add error handling here?
There was a problem hiding this comment.
How do see error handling being added here?
There was a problem hiding this comment.
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.
Can you explain more why we add the subscriptions to the events here?
There was a problem hiding this comment.
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.
Got it, thanks for the explainations!
| editable: boolean; | ||
| } | ||
|
|
||
| export type VisBuilderInput = SavedObjectEmbeddableInput; |
There was a problem hiding this comment.
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.
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 <ashwinpc@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com>
Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com>
…ent.ts Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com>
Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com>
Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com>
joshuarrrr
left a comment
There was a problem hiding this comment.
LGTM - a couple minor nits and opinions, but nothing blocking.
| </> | ||
| ); | ||
|
|
||
| // The app uses EuiResizableContainer that triggers a rerender for ever mouseover action. |
There was a problem hiding this comment.
| // The app uses EuiResizableContainer that triggers a rerender for ever mouseover action. | |
| // The app uses EuiResizableContainer that triggers a rerender for every mouseover action. |
| 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.
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.
* adds uiActions to visBuilder * prevents multiple errors on load * fixes visbuilder type errors * fixes save * updates changelog --------- Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com> (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 <ashwinpc@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com> (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 <rmerqg@amazon.com> --------- Signed-off-by: Josh Romero <rmerqg@amazon.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Josh Romero <rmerqg@amazon.com>
…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 <ashwinpc@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com> Signed-off-by: David Sinclair <david@sinclair.tech>
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:jestyarn test:jest_integrationyarn test:ftr