Skip to content
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

[Embeddables Rebuild] Migrate Visualize #183197

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

Zacqary
Copy link
Contributor

@Zacqary Zacqary commented May 10, 2024

Summary

Closes #174958

This migrates the Visualize embeddable to the new React Embeddable framework.

Migrated:

  • Edit visualization action
  • Convert to lens action
  • Extracting/injecting references on serialize and deserialize
  • Dashboard settings

Also adds deprecation statements to legacy Embeddable factories

Checklist

@Zacqary Zacqary added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas release_note:skip Skip the PR/issue when compiling release notes Feature:Embeddables Relating to the Embeddable system v8.15.0 labels May 10, 2024
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@Zacqary Zacqary marked this pull request as ready for review May 13, 2024 15:11
@Zacqary Zacqary requested review from a team as code owners May 13, 2024 15:11
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@Zacqary
Copy link
Contributor Author

Zacqary commented May 13, 2024

@elasticmachine merge upstream

@Zacqary Zacqary marked this pull request as ready for review May 15, 2024 16:20
@Zacqary
Copy link
Contributor Author

Zacqary commented May 15, 2024

@elasticmachine merge upstream

@Zacqary Zacqary marked this pull request as draft May 15, 2024 16:21
@Zacqary
Copy link
Contributor Author

Zacqary commented May 15, 2024

/ci

},
references: [],
}}
parentApi={this._parentApi}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern really bugs me. unifiedSearch properties are expected to be passed in through a parentApi, and they're supposed to be in the form of PublishingSubjects. But in this case (and with DefaultEditor) the current published values of each property is just a React prop. It makes sense from a React point of view to pass these in as props.

We can't, though, because the framework is expecting Observables. So instead we have to kind of break the React paradigm in order to shoehorn these props into some RxJS logic that they don't really want to be in.

Is there any better way to handle this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any better way to handle this?

No. We want to avoid having multiple ways of doing things.

You could opt to create a component that takes timeRange, filters, and query as props and then encapsulates converting these to observables and passing via the parent API. Maps embeddable does this with the MapRenderer if you want to use this as an example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this frustration is warranted.

@nreese's suggestion may help - additionally you could use usePublishingSubject to handle the translation from Reactive variable -> PublishingSubject for you. I understand that neither of these solutions remove the translation requirement, they just make it a little easier.

I think the fundamental problem here is a mixup in the source of truth. Ideally if you were building an editor for a React Embeddable from scratch all state would be stored with RXJS. That said, it seems like changing the visualize architecture to be fully RXJS based is too large a lift for this PR, so you might be stuck translating for a while.

Ultimately, this is making me think that we shouldn't recommend folks use Embeddables in their standalone editors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also create a hook that could turn filters, timeRange, and query into a search API to turn this into a single line of code for consumers.

const searchApi = useSearchApi(filters, timeRange, query);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not a bad idea. Kinda the opposite of useFetchContext

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right I can add it to this PR #183772

Ultimately, this is making me think that we shouldn't recommend folks use Embeddables in their standalone editors.

I think this highlights the embeddable key principles and best practices to only use embeddables when you need a component that can render in dashboard. For all other cases, expose a react Component. The problems that embeddables are trying to solve make them more difficult to work with then standard react components.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added useSearchApi hook in #183772. You can check it out at https://github.com/elastic/kibana/blob/95428bd83f835ae8edefe833159fd2c60bd6da4a/packages/presentation/presentation_publishing/interfaces/fetch/publishes_unified_search.ts

Once that PR merges, you can just use that hook and this should save you a few lines and make working with embeddables more managable.

@Zacqary
Copy link
Contributor Author

Zacqary commented May 22, 2024

/ci

@Zacqary
Copy link
Contributor Author

Zacqary commented May 22, 2024

/ci

@Zacqary
Copy link
Contributor Author

Zacqary commented May 22, 2024

/ci

…e-react-converstion

# Conflicts:
#	src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx
@Zacqary
Copy link
Contributor Author

Zacqary commented May 23, 2024

/ci

@Zacqary
Copy link
Contributor Author

Zacqary commented May 23, 2024

/ci

@kibana-ci
Copy link
Collaborator

kibana-ci commented May 23, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #7 / a11y tests using flights sample data Dashboard add a visualization
  • [job] [logs] FTR Configs #7 / a11y tests using flights sample data Dashboard add a visualization
  • [job] [logs] FTR Configs #50 / Canvas Canvas app visualization in canvas by-reference adds existing visualize embeddable from the visualize library
  • [job] [logs] FTR Configs #50 / Canvas Canvas app visualization in canvas by-reference adds existing visualize embeddable from the visualize library
  • [job] [logs] FTR Configs #102 / Controls Dashboard control group apply button "before all" hook for "able to set apply button setting"
  • [job] [logs] FTR Configs #102 / Controls Dashboard control group apply button "before all" hook for "able to set apply button setting"
  • [job] [logs] FTR Configs #58 / custom visualizations self changing vis should allow updating params via the editor
  • [job] [logs] FTR Configs #58 / custom visualizations self changing vis should allow updating params via the editor
  • [job] [logs] FTR Configs #6 / dashboard app - group 1 edit embeddable redirects redirects via save as button after edit, renaming itself
  • [job] [logs] FTR Configs #6 / dashboard app - group 1 edit embeddable redirects redirects via save as button after edit, renaming itself
  • [job] [logs] FTR Configs #17 / dashboard app - group 2 full screen mode hides the chrome
  • [job] [logs] FTR Configs #17 / dashboard app - group 2 full screen mode hides the chrome
  • [job] [logs] FTR Configs #41 / dashboard app - group 3 dashboard time picker Visualization updated when time picker changes
  • [job] [logs] FTR Configs #56 / dashboard app - group 3 dashboard time picker Visualization updated when time picker changes
  • [job] [logs] FTR Configs #56 / dashboard app - group 3 dashboard time picker Visualization updated when time picker changes
  • [job] [logs] FTR Configs #41 / dashboard app - group 3 dashboard time picker Visualization updated when time picker changes
  • [job] [logs] FTR Configs #64 / dashboard app - group 4 dashboard time dashboard without stored timed is saved
  • [job] [logs] FTR Configs #64 / dashboard app - group 4 dashboard time dashboard without stored timed is saved
  • [job] [logs] FTR Configs #34 / dashboard app - group 5 empty dashboard "after all" hook for "should open editor menu when editor button is clicked"
  • [job] [logs] FTR Configs #34 / dashboard app - group 5 empty dashboard "after all" hook for "should open editor menu when editor button is clicked"
  • [job] [logs] FTR Configs #34 / dashboard app - group 5 empty dashboard should add new visualization from dashboard
  • [job] [logs] FTR Configs #34 / dashboard app - group 5 empty dashboard should add new visualization from dashboard
  • [job] [logs] FTR Configs #63 / dashboard app - group 6 dashboard view edit mode shows lose changes warning and loses changes on confirmation when an existing vis is added
  • [job] [logs] FTR Configs #63 / dashboard app - group 6 dashboard view edit mode shows lose changes warning and loses changes on confirmation when an existing vis is added
  • [job] [logs] FTR Configs #94 / Dashboard dashboard with async search multiple searches are grouped and only single error popup is shown
  • [job] [logs] FTR Configs #94 / Dashboard dashboard with async search multiple searches are grouped and only single error popup is shown
  • [job] [logs] FTR Configs #51 / dashboard Export import saved objects between versions should retain all panel drilldowns from 7.12.1
  • [job] [logs] FTR Configs #51 / dashboard Export import saved objects between versions should retain all panel drilldowns from 7.12.1
  • [job] [logs] FTR Configs #60 / dashboard feature controls dashboard feature controls security global dashboard all privileges, no embeddable application privileges does not allow a visualization to be edited
  • [job] [logs] FTR Configs #60 / dashboard feature controls dashboard feature controls security global dashboard all privileges, no embeddable application privileges does not allow a visualization to be edited
  • [job] [logs] FTR Configs #67 / dashboard Reporting Dashboard Reporting Screenshots Print Layout downloads a PDF file
  • [job] [logs] FTR Configs #67 / dashboard Reporting Dashboard Reporting Screenshots Print Layout downloads a PDF file
  • [job] [logs] FTR Configs #9 / Execution context Browser apps dashboard app propagates context for Vega visualizations propagates to Elasticsearch via "x-opaque-id" header
  • [job] [logs] FTR Configs #9 / Execution context Browser apps dashboard app propagates context for Vega visualizations propagates to Elasticsearch via "x-opaque-id" header
  • [job] [logs] FTR Configs #13 / Getting Started new charts library Shakespeare should create initial vertical bar chart
  • [job] [logs] FTR Configs #13 / Getting Started new charts library Shakespeare should create initial vertical bar chart
  • [job] [logs] Jest Tests #7 / getVisualizationInstance should subscribe on embeddable handler updates and send toasts on errors
  • [job] [logs] Jest Tests #7 / getVisualizationInstance should subscribe on embeddable handler updates and send toasts on errors
  • [job] [logs] FTR Configs #98 / input controls chained controls should create a seperate filter pill for parent control and child control
  • [job] [logs] FTR Configs #98 / input controls chained controls should create a seperate filter pill for parent control and child control
  • [job] [logs] FTR Configs #51 / input controls input control options should not have inspector enabled
  • [job] [logs] FTR Configs #51 / input controls input control options should not have inspector enabled
  • [job] [logs] FTR Configs #97 / Journey[ecommerce_dashboard_tsvb_gauge_only] Go to Ecommerce Dashboard with TSVB Gauge only
  • [job] [logs] FTR Configs #97 / Journey[ecommerce_dashboard_tsvb_gauge_only] Go to Ecommerce Dashboard with TSVB Gauge only
  • [job] [logs] FTR Configs #8 / Journey[ecommerce_dashboard] Go to Ecommerce Dashboard
  • [job] [logs] FTR Configs #8 / Journey[ecommerce_dashboard] Go to Ecommerce Dashboard
  • [job] [logs] FTR Configs #3 / Journey[flight_dashboard] Go to Flights Dashboard
  • [job] [logs] FTR Configs #3 / Journey[flight_dashboard] Go to Flights Dashboard
  • [job] [logs] FTR Configs #94 / Journey[promotion_tracking_dashboard] Wait for visualization animations to finish
  • [job] [logs] FTR Configs #94 / Journey[promotion_tracking_dashboard] Wait for visualization animations to finish
  • [job] [logs] FTR Configs #12 / Journey[web_logs_dashboard] Go to Web Logs Dashboard
  • [job] [logs] FTR Configs #12 / Journey[web_logs_dashboard] Go to Web Logs Dashboard
  • [job] [logs] FTR Configs #29 / lens app - Agg based Vis Open in Lens Pie should show the "Edit Visualization in Lens" menu item
  • [job] [logs] FTR Configs #29 / lens app - Agg based Vis Open in Lens Pie should show the "Edit Visualization in Lens" menu item
  • [job] [logs] FTR Configs #73 / lens app - TSVB Open in Lens Dashboard to TSVB to Lens should convert a by value TSVB viz to a Lens viz
  • [job] [logs] FTR Configs #73 / lens app - TSVB Open in Lens Dashboard to TSVB to Lens should convert a by value TSVB viz to a Lens viz
  • [job] [logs] FTR Configs #23 / lens serverless - group 1 vega chart in visualize app "before all" hook in "vega chart in visualize app"
  • [job] [logs] FTR Configs #27 / lens serverless - group 1 vega chart in visualize app "before all" hook in "vega chart in visualize app"
  • [job] [logs] FTR Configs #33 / lens serverless - group 1 vega chart in visualize app "before all" hook in "vega chart in visualize app"
  • [job] [logs] FTR Configs #33 / lens serverless - group 1 vega chart in visualize app "before all" hook in "vega chart in visualize app"
  • [job] [logs] FTR Configs #27 / lens serverless - group 1 vega chart in visualize app "before all" hook in "vega chart in visualize app"
  • [job] [logs] FTR Configs #23 / lens serverless - group 1 vega chart in visualize app "before all" hook in "vega chart in visualize app"
  • [job] [logs] FTR Configs #75 / machine learning - data frame analytics results view content and total feature importance binary classification job should link to custom visualization UI from scatterplot charts
  • [job] [logs] FTR Configs #75 / machine learning - data frame analytics results view content and total feature importance binary classification job should link to custom visualization UI from scatterplot charts
  • [job] [logs] FTR Configs #71 / management rollup jobs crud delete should delete a job that has been stopped
  • [job] [logs] FTR Configs #71 / management rollup jobs crud delete should delete a job that has been stopped
  • [job] [logs] FTR Configs #92 / markdown app in visualize app "before all" hook in "markdown app in visualize app"
  • [job] [logs] FTR Configs #92 / markdown app in visualize app "before all" hook in "markdown app in visualize app"
  • [job] [logs] FTR Configs #36 / Observability AI Assistant Functional tests contextual_insights/index.spec.ts Contextual insights for APM errors when there are connectors should show the contextual insight component on the APM error details page
  • [job] [logs] FTR Configs #36 / Observability AI Assistant Functional tests contextual_insights/index.spec.ts Contextual insights for APM errors when there are connectors should show the contextual insight component on the APM error details page
  • [job] [logs] FTR Configs #68 / Options list control Dashboard options list creation and editing "after all" hook in "Dashboard options list creation and editing"
  • [job] [logs] FTR Configs #68 / Options list control Dashboard options list creation and editing "after all" hook in "Dashboard options list creation and editing"
  • [job] [logs] FTR Configs #68 / Options list control Dashboard options list creation and editing Options List Control Editor selects relevant data views selects a relevant data view based on the panels on the dashboard
  • [job] [logs] FTR Configs #68 / Options list control Dashboard options list creation and editing Options List Control Editor selects relevant data views selects a relevant data view based on the panels on the dashboard
  • [job] [logs] FTR Configs #56 / Reporting APIs Job parameter validation printablePdfV2 allows width and height to have decimal
  • [job] [logs] FTR Configs #56 / Reporting APIs Job parameter validation printablePdfV2 allows width and height to have decimal
  • [job] [logs] FTR Configs #34 / Reporting Functional Tests with Deprecated Security configuration enabled Security with reporting_user built-in role Dashboard: Generate Screenshot does not allow user that does not have reporting_user role
  • [job] [logs] FTR Configs #34 / Reporting Functional Tests with Deprecated Security configuration enabled Security with reporting_user built-in role Dashboard: Generate Screenshot does not allow user that does not have reporting_user role
  • [job] [logs] FTR Configs #100 / Reporting Functional Tests with Security enabled Security with reporting_user built-in role Dashboard: Generate Screenshot does allow PDF generation user with reporting privileges
  • [job] [logs] FTR Configs #100 / Reporting Functional Tests with Security enabled Security with reporting_user built-in role Dashboard: Generate Screenshot does allow PDF generation user with reporting privileges
  • [job] [logs] FTR Configs #17 / rollup app tsvb integration "after all" hook for "create rollup tsvb"
  • [job] [logs] FTR Configs #17 / rollup app tsvb integration "after all" hook for "create rollup tsvb"
  • [job] [logs] FTR Configs #17 / rollup app tsvb integration create rollup tsvb
  • [job] [logs] FTR Configs #17 / rollup app tsvb integration create rollup tsvb
  • [job] [logs] FTR Configs #99 / saved objects tagging - functional tests visualize integration creating allows to assign tags to the new visualization
  • [job] [logs] FTR Configs #99 / saved objects tagging - functional tests visualize integration creating allows to assign tags to the new visualization
  • [job] [logs] FTR Configs #21 / Visualizations - Group 3 lens app - TSVB Open in Lens Dashboard to TSVB to Lens should convert a by value TSVB viz to a Lens viz
  • [job] [logs] FTR Configs #83 / Visualizations - Group 3 lens app - TSVB Open in Lens Dashboard to TSVB to Lens should convert a by value TSVB viz to a Lens viz
  • [job] [logs] FTR Configs #86 / Visualizations - Group 3 lens app - TSVB Open in Lens Dashboard to TSVB to Lens should convert a by value TSVB viz to a Lens viz
  • [job] [logs] FTR Configs #21 / Visualizations - Group 3 lens app - TSVB Open in Lens Dashboard to TSVB to Lens should convert a by value TSVB viz to a Lens viz
  • [job] [logs] FTR Configs #83 / Visualizations - Group 3 lens app - TSVB Open in Lens Dashboard to TSVB to Lens should convert a by value TSVB viz to a Lens viz
  • [job] [logs] FTR Configs #86 / Visualizations - Group 3 lens app - TSVB Open in Lens Dashboard to TSVB to Lens should convert a by value TSVB viz to a Lens viz
  • [job] [logs] FTR Configs #34 / visualize app - group1 embedding a data table "before all" hook for "should allow opening table vis in embedded mode"
  • [job] [logs] FTR Configs #34 / visualize app - group1 embedding a data table "before all" hook for "should allow opening table vis in embedded mode"
  • [job] [logs] FTR Configs #32 / visualize app - new charts library visualize area charts "before all" hook for "should save and load with special characters"
  • [job] [logs] FTR Configs #32 / visualize app - new charts library visualize area charts "before all" hook for "should save and load with special characters"
  • [job] [logs] FTR Configs #87 / visualize app data-shared-item should have the correct data-shared-item title and description, and sharedItemContainer should exist
  • [job] [logs] FTR Configs #87 / visualize app data-shared-item should have the correct data-shared-item title and description, and sharedItemContainer should exist
  • [job] [logs] FTR Configs #96 / visualize app inspector advanced input JSON "after all" hook for "should have "missing" property with value 10"
  • [job] [logs] FTR Configs #96 / visualize app inspector advanced input JSON "after all" hook for "should have "missing" property with value 10"
  • [job] [logs] FTR Configs #96 / visualize app inspector advanced input JSON should have "missing" property with value 10
  • [job] [logs] FTR Configs #96 / visualize app inspector advanced input JSON should have "missing" property with value 10
  • [job] [logs] FTR Configs #84 / visualize app tag cloud chart "before all" hook for "should have inspector enabled"
  • [job] [logs] FTR Configs #84 / visualize app tag cloud chart "before all" hook for "should have inspector enabled"
  • [job] [logs] FTR Configs #25 / visualize app visual builder metric should show correct data
  • [job] [logs] FTR Configs #25 / visualize app visual builder metric should show correct data
  • [job] [logs] FTR Configs #76 / visualize app visual builder Time Series basics should show the correct count in the legend
  • [job] [logs] FTR Configs #99 / visualize app visual builder Time Series basics should show the correct count in the legend
  • [job] [logs] FTR Configs #99 / visualize app visual builder Time Series basics should show the correct count in the legend
  • [job] [logs] FTR Configs #76 / visualize app visual builder Time Series basics should show the correct count in the legend
  • [job] [logs] FTR Configs #65 / Visualize visualize feature controls security global visualize all privileges can view existing Visualization
  • [job] [logs] FTR Configs #65 / Visualize visualize feature controls security global visualize all privileges can view existing Visualization
  • [job] [logs] Jest Tests #7 / visualize_embeddable injects data view reference into search source state even if it is injected already
  • [job] [logs] Jest Tests #7 / visualize_embeddable injects data view reference into search source state even if it is injected already

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiops 620 621 +1
dashboardEnhanced 92 93 +1
embeddable 139 140 +1
imageEmbeddable 137 138 +1
lens 1470 1471 +1
links 131 132 +1
ml 2013 2014 +1
presentationPanel 101 102 +1
slo 840 841 +1
visualizations 431 426 -5
total +4

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/presentation-containers 64 68 +4
visualizations 833 798 -35
total -31

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
aiops 547.1KB 547.3KB +228.0B
dashboard 495.1KB 495.2KB +106.0B
imageEmbeddable 66.5KB 66.6KB +114.0B
ml 4.2MB 4.2MB +456.0B
visDefaultEditor 142.3KB 142.5KB +255.0B
visTypeTimeseries 512.7KB 512.8KB +147.0B
visualizations 285.8KB 271.7KB -14.1KB
total -12.8KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/presentation-containers 1 0 -1
visualizations 19 17 -2
total -3

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
visDefaultEditor 23.9KB 24.1KB +197.0B
visTypeTimeseries 20.5KB 20.7KB +149.0B
visualizations 62.0KB 60.6KB -1.3KB
total -1.0KB
Unknown metric groups

API count

id before after diff
@kbn/presentation-containers 70 74 +4
visualizations 864 825 -39
total -35

async chunk count

id before after diff
visualizations 15 13 -2

ESLint disabled line counts

id before after diff
visualizations 17 15 -2

References to deprecated APIs

id before after diff
visualizations 60 51 -9

Total ESLint disabled count

id before after diff
visualizations 19 17 -2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Embeddables Relating to the Embeddable system release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Embeddables Rebuild] Migrate Visualize
7 participants