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

[Console] Fix load from remote #52814

Merged
merged 3 commits into from
Dec 12, 2019

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Dec 11, 2019

Summary

Addresses this issue #52747.

Some functionality was erroneously removed from Console here #52270, but in that PR the functionality was already not being used anywhere - looks like this PR broke it #45627.

  • Test on IE11
  • Test on FF
  • Test on Safari
  • Test on Chrome

This will have to be backported to 7.x and 7.5 as a fix release.

Release note

We fixed "View in Console" behaviour used when viewing a Console snippet from Elasticsearch docs.

@jloleysens jloleysens added Feature:Console Dev Tools Console Feature release_note:fix v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.6.0 v7.5.1 labels Dec 11, 2019
@jloleysens jloleysens requested a review from cjcenizal December 11, 2019 20:34
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@jloleysens jloleysens changed the title [Console] Fix load remote from remote [Console] Fix load from remote Dec 11, 2019
Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

I tested locally and these changes fix the bug, but as I noted in one of my comments it looks like the loaded data overwrites everything in the request panel. This seems like a poor UX. Was the original behavior also destructive? Maybe we should prepend the loaded request to the saved requests?

The code LGTM, I just had a couple questions/suggestions but nothing worth blocking on.

};

if (/https?:\/\/api\.github\.com/.test(sourceLocation)) {
loadFrom.headers = { Accept: 'application/vnd.github.v3.raw' };
Copy link
Contributor

Choose a reason for hiding this comment

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

What use case does this support?

Copy link
Contributor Author

@jloleysens jloleysens Dec 12, 2019

Choose a reason for hiding this comment

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

This was copied from the previous behaviour, perhaps there is specific case for loading from github that required an additional header? I thought I would keep the legacy behaviour unchanged until we decide to officially deprecate "load from" behaviour or revisit it in future.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks for the explanation!

}

$.ajax(loadFrom).done(async data => {
await editorInstanceRef.current!.update(data);
Copy link
Contributor

Choose a reason for hiding this comment

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

The behavior I'm seeing is that the loaded data overwrites everything in the request panel. Is this intended? Perhaps we should prepend it to the saved requests instead?

Copy link
Contributor Author

@jloleysens jloleysens Dec 12, 2019

Choose a reason for hiding this comment

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

It looks like this is consistent with legacy behaviour:

Starting here:

$.ajax(loadFrom).done((data) => {

Which would ultimately call:

editor.update = function (data, callback) {

Which sets the value for the entire current buffer. Also checked to on 7.4 branch to make doubly sure 😂

I agree that changing the current behaviour to rather prepend would be better, but I think once we have multiple buffers we can deal with this in a more elegant manner, perhaps with a dedicated "view in console" buffer - I wouldn't want to change the legacy behaviour in this fix. Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't want to change the legacy behaviour in this fix.

I agree!

window.addEventListener('hashchange', onHashChange);

const firstParamsCheck = getQueryParams();
if (firstParamsCheck && firstParamsCheck.load_from) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check looks like a duplicate of the check on line 96. Maybe we only need one or the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the two checks are for different points in time:

  1. Startup - when we want to figure out should we load from remote or should we load from localStorage
  2. Later, when hash changes occur, should we load from remote - we don't want to load from localStorage if not from remote in this case.

I guess the alternative could be to set a Ref and check if we have done the "initial load". But this way can be restructured to only do the check once

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Tested locally, code LGTM. Thanks for fixing this and for the refactor!

@jloleysens jloleysens merged commit 21334e7 into elastic:master Dec 12, 2019
@jloleysens jloleysens deleted the fix/console-load-remote branch December 12, 2019 15:15
jloleysens added a commit to jloleysens/kibana that referenced this pull request Dec 12, 2019
* Fix load remote state

* Clean up variable usage, add comment, move forceRetokenize to private method

* Optimize sequence of checking hash on initial load
jloleysens added a commit to jloleysens/kibana that referenced this pull request Dec 12, 2019
* Fix load remote state

* Clean up variable usage, add comment, move forceRetokenize to private method

* Optimize sequence of checking hash on initial load
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

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

jloleysens added a commit that referenced this pull request Dec 13, 2019
* Fix load remote state

* Clean up variable usage, add comment, move forceRetokenize to private method

* Optimize sequence of checking hash on initial load
jloleysens added a commit that referenced this pull request Dec 13, 2019
* [Console] Fix load from remote (#52814)

* Fix load remote state

* Clean up variable usage, add comment, move forceRetokenize to private method

* Optimize sequence of checking hash on initial load

* Fix backport
jloleysens added a commit to jloleysens/kibana that referenced this pull request Dec 30, 2019
…aved-objects

* upstream/master: (134 commits)
  [Dashboard] Add visualization from dasbhoard empty screen (elastic#52670)
  Print out agent debugging links during CI (elastic#52812)
  Add babel-plugin-styled-components to webpack config (elastic#52862)
  [Console] Fix load from remote (elastic#52814)
  Ensure APM agent config file path respects CWD (elastic#52880)
  [Watcher] Removed overwritten property (elastic#49998)
  [Data Plugin]: Remove `export *` for common code from public/server index files (elastic#52821)
  Hide stderr git output during APM agent configuration (elastic#52878)
  Polish migration.md (elastic#52764)
  Change ajax_stream to use new-line delimited JSON (elastic#52797)
  Stabilize dashboard save modal functional test (elastic#52761)
  [Discover] Place tooltip at bottom of filter button (elastic#52720)
  Disable/enable filter with click+shift on a filter badge (elastic#52751)
  [APM] Make client-side routes static (elastic#52574)
  [Maps] Get basic structure of NP client shim in place (elastic#52551)
  update chromedriver to 79 (elastic#52784)
  [DOCS] Adds example of assigning roles in Reporting (elastic#52757)
  Add instructions for setting up remote clusters needed for CCS and CCR (elastic#52796)
  [docs] max-old-space-size (elastic#52310)
  [Monitoring] Fix 7.5 cloud test issues (elastic#51781)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Console Dev Tools Console Feature release_note:fix Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.5.1 v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants