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] Decouple add panel trigger #176110

Conversation

ThomThomson
Copy link
Contributor

@ThomThomson ThomThomson commented Feb 1, 2024

Summary

Closes #176230

This PR decouples the ADD_PANEL_TRIGGER from the Embeddables framework by making it take a PresentationContainer as context instead.

This PR also adds the ability to create new panels to the PresentationContainer interface. This allows us to register actions to create new React Embeddables.

How to test

The example has been updated to include an action that creates Eui Markdown React Embeddables. You should be able to run yarn start --run-examples then build Dashboards with Eui Markdown panels.

Add new

@ThomThomson
Copy link
Contributor Author

/ci

@ThomThomson
Copy link
Contributor Author

/ci

@ThomThomson
Copy link
Contributor Author

/ci

@ThomThomson ThomThomson added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. Feature:Embeddables Relating to the Embeddable system labels Feb 5, 2024
@ThomThomson ThomThomson marked this pull request as ready for review February 5, 2024 22:53
@ThomThomson ThomThomson requested review from a team as code owners February 5, 2024 22:53
@elasticmachine
Copy link
Contributor

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

@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Feb 6, 2024
@stratoula
Copy link
Contributor

/ci

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Changes LGTM, tested ES|QL panel creation and everything works as expected. Very nice simplification Devon at least on the consumer side. Me gusta! 👏

@nreese nreese self-requested a review February 6, 2024 19:09
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

Really nice to see it all come together.

// Create and register an action which allows this embeddable to be created from
// the dashboard toolbar context menu.
// -----------------------------------------------------------------------------
uiActions.registerAction<EmbeddableApiContext>({
Copy link
Contributor

Choose a reason for hiding this comment

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

How about moving action registration to plugin.setup method. That way, the action can be moved to its own file as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 192fd05

}

export type PresentationContainer = Partial<PublishesViewMode> &
PublishesLastSavedState & {
addNewPanel: <ApiType extends unknown = unknown>(
panel: PanelPackage,
silent?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

how about renaming silent to something less cryptic, like displaySuccessToast

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually purposefully went more crypic with this one, because the presentation container interface could be fulfilled with any implementation, and they may not use a toast or anything of the sort.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about displaySuccess? Its vague on how success is displayed but conveys what this value toogles.

Copy link
Contributor Author

@ThomThomson ThomThomson Feb 6, 2024

Choose a reason for hiding this comment

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

Sure that works! displaySuccess also has the bonus of being the default when no argument is passed in. Likely, most implementations will want to avoid the toast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 192fd05

throw new EmbeddableFactoryNotFoundError(panelPackage.panelType);
}

if (this.trackPanelAddMetric) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should trackPanelAddMetric be moved to top of function so it can track react embeddables as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, done in 192fd05

this.setScrollToPanelId(newEmbeddable.id);
this.setHighlightPanelId(newEmbeddable.id);

if (!silent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should toast also be displayed when react embeddables are added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Done in 192fd05

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #31 / cases security and spaces enabled: trial get_connectors push needsToBePushed sets needs to push to false when the status of a case was changed after the last push
  • [job] [logs] FTR Configs #57 / fleet rejects request to create a new fleet server hosts if host url is different from default

Metrics [docs]

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-publishing 115 114 -1
embeddable 452 454 +2
total +1

Async chunks

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

id before after diff
dashboard 385.8KB 382.0KB -3.8KB
lens 1.4MB 1.4MB -88.0B
total -3.9KB

Page load bundle

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

id before after diff
embeddable 65.8KB 65.9KB +125.0B
lens 41.9KB 42.3KB +406.0B
presentationPanel 40.4KB 40.4KB +41.0B
total +572.0B
Unknown metric groups

API count

id before after diff
embeddable 557 559 +2

History

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

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

LGTM
code review, tested in chrome

@ThomThomson ThomThomson merged commit 23b4b53 into elastic:main Feb 7, 2024
19 checks passed
@kibanamachine kibanamachine added v8.13.0 backport:skip This commit does not require backporting labels Feb 7, 2024
fkanout pushed a commit to fkanout/kibana that referenced this pull request Feb 8, 2024
Decouples the `ADD_PANEL_TRIGGER` from the Embeddables framework  by making it take a `PresentationContainer` as context instead.
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
Decouples the `ADD_PANEL_TRIGGER` from the Embeddables framework  by making it take a `PresentationContainer` as context instead.
fkanout pushed a commit to fkanout/kibana that referenced this pull request Mar 4, 2024
Decouples the `ADD_PANEL_TRIGGER` from the Embeddables framework  by making it take a `PresentationContainer` as context instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Embeddables Relating to the Embeddable system Feature:Embedding Embedding content via iFrame impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort project:embeddableRebuild release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Embeddable Rebuild] Allow Dashboard to create React Embeddables
6 participants