-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Console] Fix load from remote #52814
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
There was a problem hiding this 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.
...ugins/console/public/np_ready/application/containers/editor/legacy/console_editor/editor.tsx
Outdated
Show resolved
Hide resolved
}; | ||
|
||
if (/https?:\/\/api\.github\.com/.test(sourceLocation)) { | ||
loadFrom.headers = { Accept: 'application/vnd.github.v3.raw' }; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- Startup - when we want to figure out should we load from remote or should we load from localStorage
- 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
There was a problem hiding this 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!
* Fix load remote state * Clean up variable usage, add comment, move forceRetokenize to private method * Optimize sequence of checking hash on initial load
* Fix load remote state * Clean up variable usage, add comment, move forceRetokenize to private method * Optimize sequence of checking hash on initial load
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…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) ...
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.
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.