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

[Time to Visualize] Transition Embeddable State Transfer to Session Storage #85688

Conversation

ThomThomson
Copy link
Contributor

@ThomThomson ThomThomson commented Dec 11, 2020

Summary

closes #85493

Note - please ignore the pink header, It's there to easily distinguish between Kibana instances

This PR switches the Embeddable State Transfer service to use Session Storage. This means that the implicit behaviour of the state being reset to undefined is gone. Now the editor state is:

capable of persisting over reloads
Reloads

Working correctly with the browser back and forward buttons
back forward

Additionally, this PR fixes the incompatibility between #82909 and #83140

Things to Remember When Testing:

  • add dashboard.allowByValueEmbeddables: true to your kibana.dev.yml
  • Test the Create New flow from dashboards with Lens and Visualize
  • Ensure that there is no way duplicates can show up on a dashboard after save and return
  • Try with multiple tabs. Session Storage should not pollute other tabs
  • Try reloading while editing a by value visualization

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@ThomThomson ThomThomson added Feature:Dashboard Dashboard related features release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas Project:TimeToVisualize labels Dec 11, 2020
@ThomThomson ThomThomson marked this pull request as ready for review December 14, 2020 19:07
@ThomThomson ThomThomson requested a review from a team December 14, 2020 19:07
@ThomThomson ThomThomson requested review from a team as code owners December 14, 2020 19:07
@elasticmachine
Copy link
Contributor

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

@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Dec 14, 2020
Copy link
Contributor

@poffdeluxe poffdeluxe left a comment

Choose a reason for hiding this comment

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

Tested this with creating a view visualizations and seems to work as advertised. The amount of tests seem like they'll catch a bunch of issues

@@ -20,6 +20,8 @@
import { Optional } from '@kbn/utility-types';
import { EmbeddableInput, SavedObjectEmbeddableInput } from '..';

export const EMBEDDABLE_EDITOR_STATE_KEY = 'embeddable_editor_state';
Copy link
Contributor

Choose a reason for hiding this comment

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

bit of a nit but this is more of a constant rather than a type, right? maybe could go in a constants files if applicable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A constants file would be a good home for this, but the embeddable plugin doesn't have one yet.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
dashboard 186.2KB 186.1KB -11.0B
lens 1018.4KB 1018.5KB +77.0B
maps 2.8MB 2.8MB -4.0B
visualize 130.9KB 130.9KB +4.0B
total +66.0B

Distributable file count

id before after diff
default 47130 47890 +760

Page load bundle

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

id before after diff
dashboard 336.4KB 336.1KB -369.0B
embeddable 228.3KB 228.8KB +544.0B
total +175.0B

History

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

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Tested in Chrome and Firefox, transfer state seems to be reset in the relevant places (but take it with a grain of salt with regard to my track record in testing these changes :) )

However once the user starts to use the global search to navigate or to mess with the URL themselves, they can still end up in weird situations, e.g.:

  • User goes to dashboard, creates new embedded Lens panel
  • User uses global search to switch to another Library lens vis (or manually changes the URL)
  • New vis loads, but connection to dashboard is still in place

I'm not 100% sure whether that's even a problem or just expected behavior - leaving that up to you :)

Approving if this was the intended flow

@ThomThomson
Copy link
Contributor Author

I noticed that these sorts of in-between cases were possible during implementation. They are not strictly intended, but they also don't particularly break anything - which is why I would be okay with merging this, and having a follow up to remove them.

The problem stems from the state transfer state not being linked to the browser history in any way. If we clear the state upon returning to dashboard then it's cleared in all cases and the back / forward buttons won't restore it anymore. The only way I can think of to totally fix this is to introduce a short url param that determines whether the editor should check for incoming state or not.

Copy link
Contributor

@streamich streamich left a comment

Choose a reason for hiding this comment

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

AppServices code changes LGTM.

@ThomThomson ThomThomson merged commit ee37f6d into elastic:master Dec 15, 2020
ThomThomson added a commit to ThomThomson/kibana that referenced this pull request Dec 15, 2020
…torage (elastic#85688)

* Transitioned embeddable state transfer service to use sessionStorage
ThomThomson added a commit that referenced this pull request Dec 15, 2020
…torage (#85688) (#85996)

* Transitioned embeddable state transfer service to use sessionStorage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Dashboard Dashboard related features Feature:Embedding Embedding content via iFrame Project:TimeToVisualize release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discuss][Time to Visualize] Browser / Hash History Conflict
6 participants