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

[embeddable] centralize should fetch embeddable observable logic #151799

Merged
merged 21 commits into from
Mar 1, 2023

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Feb 21, 2023

Fixes #151223 and #151128

PR does the following

  1. creates shouldFetch$ method that centralizes logic for checking when an embeddable should fetch.
  2. updates Lens and Maps embeddable to use shouldFetch$
  3. Adds unit tests for Maps embeddable to capture behavior of unique edge cases

@nreese
Copy link
Contributor Author

nreese commented Feb 23, 2023

@elasticmachine merge upstream

@nreese nreese marked this pull request as ready for review February 23, 2023 18:28
@nreese nreese requested review from a team as code owners February 23, 2023 18:28
@nreese nreese added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) Feature:Embedding Embedding content via iFrame Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas auto-backport Deprecated - use backport:version if exact versions are needed Feature:Maps v8.7.0 labels Feb 23, 2023
@nreese nreese added the v8.8.0 label Feb 23, 2023
@elasticmachine
Copy link
Contributor

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

@nreese nreese added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting and removed auto-backport Deprecated - use backport:version if exact versions are needed v8.7.0 labels Feb 23, 2023
@nreese nreese requested a review from drewdaemon February 23, 2023 19:02
Copy link
Contributor

@drewdaemon drewdaemon left a comment

Choose a reason for hiding this comment

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

Tested Lens embeddable—works great. Thanks

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Code review + tested locally in Chrome with dashboard containing a map and lens embeddable. Tested that the map and lens reload when an enabled, pinned, negated etc filter is changed, that they don't reload when a disabled filter is changed, and that only the lens reloads on change of a filter controlled by the map.

Great call to centralize the should refetch observable I left a few questions and some ideas for followups to clean this even further. LGTM!

shouldFetch$<MapEmbeddableInput>(this.getUpdated$(), () => {
return {
...this.getInput(),
filters: this._getFilters(),
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like these filters are only different from the ones on input due to filtering out disabled filters & those that are controlledBy this map.

It seems like disabled filters are already filtered out by onlyDisabledFiltersChanged - I wonder if we could get rid of this special treatment by adding a excludeControlledBy argument to FilterCompareOptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting idea and something to consider for future refactors.

@nreese
Copy link
Contributor Author

nreese commented Feb 28, 2023

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
embeddable 83 84 +1

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
embeddable 430 435 +5

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
embeddable 8 9 +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.3KB 385.3KB -7.0B
lens 1.3MB 1.3MB -176.0B
maps 2.7MB 2.7MB -355.0B
total -538.0B

Page load bundle

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

id before after diff
embeddable 74.5KB 75.1KB +548.0B
Unknown metric groups

API count

id before after diff
embeddable 532 538 +6

ESLint disabled line counts

id before after diff
maps 39 40 +1
securitySolution 428 430 +2
total +3

Total ESLint disabled count

id before after diff
maps 67 68 +1
securitySolution 506 508 +2
total +3

History

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

Copy link
Member

@nickpeihl nickpeihl left a comment

Choose a reason for hiding this comment

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

lgtm! Great to centralize the fetching logic!

code review and tested in chrome

@nreese nreese merged commit afb251c into elastic:main Mar 1, 2023
dej611 pushed a commit to dej611/kibana that referenced this pull request Mar 7, 2023
…stic#151799)

Fixes elastic#151223 and
elastic#151128

PR does the following
1) creates `shouldFetch$` method that centralizes logic for checking
when an embeddable should fetch.
2) updates Lens and Maps embeddable to use `shouldFetch$`
3) Adds unit tests for Maps embeddable to capture behavior of unique
edge cases

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit afb251c)
@dej611
Copy link
Contributor

dej611 commented Mar 7, 2023

💚 All backports created successfully

Status Branch Result
8.7

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

dej611 added a commit that referenced this pull request Mar 7, 2023
#151799) (#152838)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[embeddable] centralize should fetch embeddable observable logic
(#151799)](#151799)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-03-01T01:47:48Z","message":"[embeddable]
centralize should fetch embeddable observable logic (#151799)\n\nFixes
#151223
and\r\nhttps://github.com//issues/151128\r\n\r\nPR does
the following\r\n1) creates `shouldFetch# Backport

This will backport the following commits from `main` to `8.7`:
- [[embeddable] centralize should fetch embeddable observable logic
(#151799)](#151799)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT method that centralizes logic for checking\r\nwhen an
embeddable should fetch.\r\n2) updates Lens and Maps embeddable to use
`shouldFetch# Backport

This will backport the following commits from `main` to `8.7`:
- [[embeddable] centralize should fetch embeddable observable logic
(#151799)](#151799)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT \r\n3) Adds unit tests for Maps embeddable to capture
behavior of unique\r\nedge cases\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"afb251c624552024076ae75890de9c7d5f4458f0","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Visualizations","Feature:Embedding","Team:Presentation","release_note:skip","backport:skip","Feature:Maps","v8.8.0"],"number":151799,"url":"https://github.com/elastic/kibana/pull/151799","mergeCommit":{"message":"[embeddable]
centralize should fetch embeddable observable logic (#151799)\n\nFixes
#151223
and\r\nhttps://github.com//issues/151128\r\n\r\nPR does
the following\r\n1) creates `shouldFetch# Backport

This will backport the following commits from `main` to `8.7`:
- [[embeddable] centralize should fetch embeddable observable logic
(#151799)](#151799)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT method that centralizes logic for checking\r\nwhen an
embeddable should fetch.\r\n2) updates Lens and Maps embeddable to use
`shouldFetch# Backport

This will backport the following commits from `main` to `8.7`:
- [[embeddable] centralize should fetch embeddable observable logic
(#151799)](#151799)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT \r\n3) Adds unit tests for Maps embeddable to capture
behavior of unique\r\nedge cases\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"afb251c624552024076ae75890de9c7d5f4458f0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151799","number":151799,"mergeCommit":{"message":"[embeddable]
centralize should fetch embeddable observable logic (#151799)\n\nFixes
#151223
and\r\nhttps://github.com//issues/151128\r\n\r\nPR does
the following\r\n1) creates `shouldFetch# Backport

This will backport the following commits from `main` to `8.7`:
- [[embeddable] centralize should fetch embeddable observable logic
(#151799)](#151799)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT method that centralizes logic for checking\r\nwhen an
embeddable should fetch.\r\n2) updates Lens and Maps embeddable to use
`shouldFetch# Backport

This will backport the following commits from `main` to `8.7`:
- [[embeddable] centralize should fetch embeddable observable logic
(#151799)](#151799)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT \r\n3) Adds unit tests for Maps embeddable to capture
behavior of unique\r\nedge cases\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"afb251c624552024076ae75890de9c7d5f4458f0"}}]}]
BACKPORT-->

Co-authored-by: Nathan Reese <[email protected]>
bmorelli25 pushed a commit to bmorelli25/kibana that referenced this pull request Mar 10, 2023
…stic#151799)

Fixes elastic#151223 and
elastic#151128

PR does the following
1) creates `shouldFetch$` method that centralizes logic for checking
when an embeddable should fetch.
2) updates Lens and Maps embeddable to use `shouldFetch$`
3) Adds unit tests for Maps embeddable to capture behavior of unique
edge cases

---------

Co-authored-by: kibanamachine <[email protected]>
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:Embedding Embedding content via iFrame Feature:Maps Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[lens] changing disabled filter causes lens panel fetch when embedded on dashboard
8 participants