Skip to content

[Embeddable Rebuild] Refactor enhanced embeddables#178896

Merged
Heenawter merged 16 commits intoelastic:mainfrom
Heenawter:refactor-dashboard-drilldowns_2024-03-18
Mar 21, 2024
Merged

[Embeddable Rebuild] Refactor enhanced embeddables#178896
Heenawter merged 16 commits intoelastic:mainfrom
Heenawter:refactor-dashboard-drilldowns_2024-03-18

Conversation

@Heenawter
Copy link
Copy Markdown
Contributor

@Heenawter Heenawter commented Mar 18, 2024

Closes #178742

Summary

In the old embeddable system, when an embeddable is created through its factory, it is "enhanced" via enhanceEmbeddableWithDynamicActions in EmbeddableEnhancedPlugin - this enhancement is responsible for adding the pieces necessary (for example, the DynamicActionManager) to the embeddable to manage drilldowns. In the new system, we are no longer using these class-based factories - so there is no longer a way to enhance embeddables on creation. Therefore, this PR does three main things:

  1. It adds a new method initializeDynamicActions to the EnhancedEmbeddablePlugin and returns it through its start contract (in order to bypass limitations around importing stuff from xpack) - this method can be used to enhance all React-based embeddables with the stuff necessary for drilldowns to work. As part of this, I had to add a few extra pieces to the HasDynamicActions API:
    • dynamicActionsState$: This is a publishing subject that will keep track of the events currently attached to the given embeddable (DynamicActionsState)
    • setDynamicActions: A setter for the above publishing subject
  2. It modifies all actions tied to dashboard drilldowns - PanelNotificationsAction, EmbeddableToDashboardDrilldown, FlyoutEditDrilldownAction, and FlyoutCreateDrilldownAction.
  3. It modifies the old enhanceEmbeddableWithDynamicActions to add the publishing subject + setter from (1) above to all legacy embeddables when they are enhanced - that way, they will still pass the apiHasDynamicActions type check + all modified actions continue to work for legacy embeddables.

How to Test
To test with a React embeddable, you can checkout the draft PR containing the new image embeddable.

Checklist

For maintainers

@Heenawter Heenawter added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes impact:critical This issue should be addressed immediately due to a critical level of impact on the product. labels Mar 18, 2024
@Heenawter Heenawter self-assigned this Mar 18, 2024
@Heenawter Heenawter force-pushed the refactor-dashboard-drilldowns_2024-03-18 branch 3 times, most recently from 6c67ac5 to fb1ba5e Compare March 18, 2024 22:05
@Heenawter
Copy link
Copy Markdown
Contributor Author

/ci

1 similar comment
@Heenawter
Copy link
Copy Markdown
Contributor Author

/ci

@Heenawter Heenawter force-pushed the refactor-dashboard-drilldowns_2024-03-18 branch 2 times, most recently from 6150063 to 0cd10cd Compare March 19, 2024 17:23
@Heenawter
Copy link
Copy Markdown
Contributor Author

/ci

1 similar comment
@Heenawter
Copy link
Copy Markdown
Contributor Author

/ci

@Heenawter Heenawter force-pushed the refactor-dashboard-drilldowns_2024-03-18 branch from b7bb7a6 to 22d0fe5 Compare March 19, 2024 20:20
@Heenawter
Copy link
Copy Markdown
Contributor Author

/ci

1 similar comment
@Heenawter
Copy link
Copy Markdown
Contributor Author

/ci

@Heenawter
Copy link
Copy Markdown
Contributor Author

/ci

}: {
context: { embeddable: FlyoutEditDrilldownActionApi };
}) => {
const dynamicActionsState = useStateFromPublishingSubject(embeddable.dynamicActionsState$);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using the state container from DynamicActionManager was falling out of sync, so the badge beside the "edit" menu option would often reflect the wrong number (especially after the dashboard was reset) - switching to the dynamicActionsState$ publishing subject, which should be our source of truth, fixed this.

if (!isApiCompatible(embeddable)) return;

return merge(
getViewModeSubject(embeddable) ?? new BehaviorSubject(ViewMode.VIEW),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure how to better handle optional behaviour subjects?

@Heenawter
Copy link
Copy Markdown
Contributor Author

/ci

@Heenawter Heenawter marked this pull request as ready for review March 20, 2024 20:11
@Heenawter Heenawter requested a review from a team as a code owner March 20, 2024 20:11
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@nreese nreese self-requested a review March 21, 2024 14:37
Copy link
Copy Markdown
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 with a few nits about typings. This is a heavy lift and your changes are really streamlined and easy to follow. Great job bringing drilldowns across the line for react embeddables.
code review, tested in chrome

@botelastic botelastic bot added the Feature:Drilldowns Embeddable panel Drilldowns label Mar 21, 2024
@Heenawter Heenawter force-pushed the refactor-dashboard-drilldowns_2024-03-18 branch from d7c452a to c07c945 Compare March 21, 2024 21:58
@Heenawter Heenawter enabled auto-merge (squash) March 21, 2024 22:01
@Heenawter Heenawter merged commit 3f1dcff into elastic:main Mar 21, 2024
@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
embeddableEnhanced 11 32 +21

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
embeddableEnhanced 18 23 +5

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
embeddableEnhanced 0 1 +1

Page load bundle

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

id before after diff
dashboardEnhanced 14.3KB 14.6KB +348.0B
embeddableEnhanced 7.2KB 9.9KB +2.8KB
total +3.1KB
Unknown metric groups

API count

id before after diff
embeddableEnhanced 18 23 +5

ESLint disabled line counts

id before after diff
embeddableEnhanced 3 2 -1

References to deprecated APIs

id before after diff
dashboardEnhanced 15 13 -2

Total ESLint disabled count

id before after diff
embeddableEnhanced 5 4 -1

Unreferenced deprecated APIs

id before after diff
embeddableEnhanced 0 1 +1

History

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

cc @Heenawter

@kibanamachine kibanamachine added v8.14.0 backport:skip This PR does not require backporting labels Mar 21, 2024
@Heenawter Heenawter deleted the refactor-dashboard-drilldowns_2024-03-18 branch March 21, 2024 23:06
davismcphee added a commit that referenced this pull request Feb 21, 2025
…11678)

## Summary

This PR re-adds drilldown support to the Discover session embeddable
after it was accidentally removed during the refactoring in #180536
(related PR where drilldowns / dynamic actions were refactored:
#178896). A new functional test has also been added to prevent future
regressions.

Fixes #211677.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
davismcphee added a commit to davismcphee/kibana that referenced this pull request Feb 21, 2025
…astic#211678)

## Summary

This PR re-adds drilldown support to the Discover session embeddable
after it was accidentally removed during the refactoring in elastic#180536
(related PR where drilldowns / dynamic actions were refactored:
elastic#178896). A new functional test has also been added to prevent future
regressions.

Fixes elastic#211677.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
(cherry picked from commit 257971d)
davismcphee added a commit to davismcphee/kibana that referenced this pull request Feb 21, 2025
…astic#211678)

## Summary

This PR re-adds drilldown support to the Discover session embeddable
after it was accidentally removed during the refactoring in elastic#180536
(related PR where drilldowns / dynamic actions were refactored:
elastic#178896). A new functional test has also been added to prevent future
regressions.

Fixes elastic#211677.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
(cherry picked from commit 257971d)

# Conflicts:
#	src/platform/plugins/shared/discover/public/types.ts
#	src/platform/plugins/shared/discover/tsconfig.json
davismcphee added a commit to davismcphee/kibana that referenced this pull request Feb 21, 2025
…astic#211678)

## Summary

This PR re-adds drilldown support to the Discover session embeddable
after it was accidentally removed during the refactoring in elastic#180536
(related PR where drilldowns / dynamic actions were refactored:
elastic#178896). A new functional test has also been added to prevent future
regressions.

Fixes elastic#211677.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
(cherry picked from commit 257971d)

# Conflicts:
#	src/plugins/discover/public/build_services.ts
#	src/plugins/discover/public/embeddable/get_search_embeddable_factory.tsx
#	src/plugins/discover/public/embeddable/types.ts
#	src/plugins/discover/public/embeddable/utils/serialization_utils.test.ts
#	src/plugins/discover/public/types.ts
#	src/plugins/discover/tsconfig.json
JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Feb 27, 2025
…astic#211678)

## Summary

This PR re-adds drilldown support to the Discover session embeddable
after it was accidentally removed during the refactoring in elastic#180536
(related PR where drilldowns / dynamic actions were refactored:
elastic#178896). A new functional test has also been added to prevent future
regressions.

Fixes elastic#211677.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
…astic#211678)

## Summary

This PR re-adds drilldown support to the Discover session embeddable
after it was accidentally removed during the refactoring in elastic#180536
(related PR where drilldowns / dynamic actions were refactored:
elastic#178896). A new functional test has also been added to prevent future
regressions.

Fixes elastic#211677.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Drilldowns Embeddable panel Drilldowns impact:critical This issue should be addressed immediately due to a critical level of impact on the 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 t// v8.14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Embeddable Rebuild] Refactor how drilldowns are handled

5 participants