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

[8.x] [Console] Fix load_from param (#196836) #197131

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

Fixes elastic#195877
Addresses elastic#179658

## Summary

This PR fixes the bug in Console where using the `load_from` param in
the URL made Console uneditable because every re-render reset the
initial value in the editor. This is fixed by restricting the hook to
only set the initial value once. This PR also adds some unit tests for
the hook, as I realized that this was a long-standing improvement.

### How to test:

Try loading the following URL (making the necessary replacement in the
URL) and verify that the data is correctly loaded into the editor and
value can be edited:

`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=data:text/plain,AoeQygKgBA9A+gRwK4FMBOBPGBDAzhgOwGMB+AEzQHsAHOApAGwbiMoaQFsDcAoAbx5QoAImToMwgFwiAZgCVKAWShoUHSgBcUAWgBUkgJYEyKAB4pcwgDSCRDSkWwMUUkSgLXbwmQYZa0rgJCQsIARpRsgbbBIhxIuBquANoAujYxIT5+6Mlp0cHCuAAWlIxkuekZwnEJdJq5+QC+ts2NQA`

`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/86.console`

Co-authored-by: Matthew Kime <[email protected]>
(cherry picked from commit e6e4e34)
@kibanamachine kibanamachine merged commit a5ad3e5 into elastic:8.x Oct 21, 2024
23 checks passed
@elasticmachine
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
console 205.6KB 205.7KB +49.0B

cc @ElenaStoeva

ElenaStoeva added a commit that referenced this pull request Oct 22, 2024
# Backport

This will backport the following commits from `main` to `8.16`:
- [[Console] Fix load_from param
(#196836)](#196836)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-21T19:20:30Z","message":"[Console]
Fix load_from param (#196836)\n\nFixes
https://github.com/elastic/kibana/issues/195877\r\nAddresses
https://github.com/elastic/kibana/issues/179658\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in Console where using the
`load_from` param in\r\nthe URL made Console uneditable because every
re-render reset the\r\ninitial value in the editor. This is fixed by
restricting the hook to\r\nonly set the initial value once. This PR also
adds some unit tests for\r\nthe hook, as I realized that this was a
long-standing improvement.\r\n\r\n### How to test:\r\n\r\nTry loading
the following URL (making the necessary replacement in the\r\nURL) and
verify that the data is correctly loaded into the editor and\r\nvalue
can be
edited:\r\n\r\n\r\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=data:text/plain,AoeQygKgBA9A+gRwK4FMBOBPGBDAzhgOwGMB+AEzQHsAHOApAGwbiMoaQFsDcAoAbx5QoAImToMwgFwiAZgCVKAWShoUHSgBcUAWgBUkgJYEyKAB4pcwgDSCRDSkWwMUUkSgLXbwmQYZa0rgJCQsIARpRsgbbBIhxIuBquANoAujYxIT5+6Mlp0cHCuAAWlIxkuekZwnEJdJq5+QC+ts2NQA`\r\n\r\n\r\n\r\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/86.console`\r\n\r\nCo-authored-by:
Matthew Kime
<[email protected]>","sha":"e6e4e343aa700f1b489915f8df233a0abf2ea058","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana
Management","release_note:skip","v9.0.0","backport:prev-minor","v8.16.0","v8.17.0"],"number":196836,"url":"https://github.com/elastic/kibana/pull/196836","mergeCommit":{"message":"[Console]
Fix load_from param (#196836)\n\nFixes
https://github.com/elastic/kibana/issues/195877\r\nAddresses
https://github.com/elastic/kibana/issues/179658\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in Console where using the
`load_from` param in\r\nthe URL made Console uneditable because every
re-render reset the\r\ninitial value in the editor. This is fixed by
restricting the hook to\r\nonly set the initial value once. This PR also
adds some unit tests for\r\nthe hook, as I realized that this was a
long-standing improvement.\r\n\r\n### How to test:\r\n\r\nTry loading
the following URL (making the necessary replacement in the\r\nURL) and
verify that the data is correctly loaded into the editor and\r\nvalue
can be
edited:\r\n\r\n\r\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=data:text/plain,AoeQygKgBA9A+gRwK4FMBOBPGBDAzhgOwGMB+AEzQHsAHOApAGwbiMoaQFsDcAoAbx5QoAImToMwgFwiAZgCVKAWShoUHSgBcUAWgBUkgJYEyKAB4pcwgDSCRDSkWwMUUkSgLXbwmQYZa0rgJCQsIARpRsgbbBIhxIuBquANoAujYxIT5+6Mlp0cHCuAAWlIxkuekZwnEJdJq5+QC+ts2NQA`\r\n\r\n\r\n\r\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/86.console`\r\n\r\nCo-authored-by:
Matthew Kime
<[email protected]>","sha":"e6e4e343aa700f1b489915f8df233a0abf2ea058"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196836","number":196836,"mergeCommit":{"message":"[Console]
Fix load_from param (#196836)\n\nFixes
https://github.com/elastic/kibana/issues/195877\r\nAddresses
https://github.com/elastic/kibana/issues/179658\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in Console where using the
`load_from` param in\r\nthe URL made Console uneditable because every
re-render reset the\r\ninitial value in the editor. This is fixed by
restricting the hook to\r\nonly set the initial value once. This PR also
adds some unit tests for\r\nthe hook, as I realized that this was a
long-standing improvement.\r\n\r\n### How to test:\r\n\r\nTry loading
the following URL (making the necessary replacement in the\r\nURL) and
verify that the data is correctly loaded into the editor and\r\nvalue
can be
edited:\r\n\r\n\r\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=data:text/plain,AoeQygKgBA9A+gRwK4FMBOBPGBDAzhgOwGMB+AEzQHsAHOApAGwbiMoaQFsDcAoAbx5QoAImToMwgFwiAZgCVKAWShoUHSgBcUAWgBUkgJYEyKAB4pcwgDSCRDSkWwMUUkSgLXbwmQYZa0rgJCQsIARpRsgbbBIhxIuBquANoAujYxIT5+6Mlp0cHCuAAWlIxkuekZwnEJdJq5+QC+ts2NQA`\r\n\r\n\r\n\r\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/86.console`\r\n\r\nCo-authored-by:
Matthew Kime
<[email protected]>","sha":"e6e4e343aa700f1b489915f8df233a0abf2ea058"}},{"branch":"8.16","label":"v8.16.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/197131","number":197131,"state":"MERGED","mergeCommit":{"sha":"a5ad3e5d937ee5cfed4e78dfb10e2e40aad4e075","message":"[8.x]
[Console] Fix load_from param (#196836) (#197131)\n\n# Backport\n\nThis
will backport the following commits from `main` to `8.x`:\n- [[Console]
Fix load_from
param\n(#196836)](https://github.com/elastic/kibana/pull/196836)\n\n<!---
Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Elena\nStoeva\",\"email\":\"[email protected]\"},\"sourceCommit\":{\"committedDate\":\"2024-10-21T19:20:30Z\",\"message\":\"[Console]\nFix
load_from param
(#196836)\\n\\nFixes\nhttps://github.com//issues/195877\\r\\nAddresses\nhttps://github.com//issues/179658\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nThis
PR fixes the bug in Console where using the\n`load_from` param
in\\r\\nthe URL made Console uneditable because every\nre-render reset
the\\r\\ninitial value in the editor. This is fixed by\nrestricting the
hook to\\r\\nonly set the initial value once. This PR also\nadds some
unit tests for\\r\\nthe hook, as I realized that this was
a\nlong-standing improvement.\\r\\n\\r\\n### How to test:\\r\\n\\r\\nTry
loading\nthe following URL (making the necessary replacement in
the\\r\\nURL) and\nverify that the data is correctly loaded into the
editor and\\r\\nvalue\ncan
be\nedited:\\r\\n\\r\\n\\r\\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=data:text/plain,AoeQygKgBA9A+gRwK4FMBOBPGBDAzhgOwGMB+AEzQHsAHOApAGwbiMoaQFsDcAoAbx5QoAImToMwgFwiAZgCVKAWShoUHSgBcUAWgBUkgJYEyKAB4pcwgDSCRDSkWwMUUkSgLXbwmQYZa0rgJCQsIARpRsgbbBIhxIuBquANoAujYxIT5+6Mlp0cHCuAAWlIxkuekZwnEJdJq5+QC+ts2NQA`\\r\\n\\r\\n\\r\\n\\r\\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/86.console`\\r\\n\\r\\nCo-authored-by:\nMatthew
Kime\n<[email protected]>\",\"sha\":\"e6e4e343aa700f1b489915f8df233a0abf2ea058\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"Feature:Console\",\"Team:Kibana\nManagement\",\"release_note:skip\",\"v9.0.0\",\"backport:prev-minor\"],\"title\":\"[Console]\nFix
load_from\nparam\",\"number\":196836,\"url\":\"https://github.com/elastic/kibana/pull/196836\",\"mergeCommit\":{\"message\":\"[Console]\nFix
load_from param
(#196836)\\n\\nFixes\nhttps://github.com//issues/195877\\r\\nAddresses\nhttps://github.com//issues/179658\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nThis
PR fixes the bug in Console where using the\n`load_from` param
in\\r\\nthe URL made Console uneditable because every\nre-render reset
the\\r\\ninitial value in the editor. This is fixed by\nrestricting the
hook to\\r\\nonly set the initial value once. This PR also\nadds some
unit tests for\\r\\nthe hook, as I realized that this was
a\nlong-standing improvement.\\r\\n\\r\\n### How to test:\\r\\n\\r\\nTry
loading\nthe following URL (making the necessary replacement in
the\\r\\nURL) and\nverify that the data is correctly loaded into the
editor and\\r\\nvalue\ncan
be\nedited:\\r\\n\\r\\n\\r\\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=data:text/plain,AoeQygKgBA9A+gRwK4FMBOBPGBDAzhgOwGMB+AEzQHsAHOApAGwbiMoaQFsDcAoAbx5QoAImToMwgFwiAZgCVKAWShoUHSgBcUAWgBUkgJYEyKAB4pcwgDSCRDSkWwMUUkSgLXbwmQYZa0rgJCQsIARpRsgbbBIhxIuBquANoAujYxIT5+6Mlp0cHCuAAWlIxkuekZwnEJdJq5+QC+ts2NQA`\\r\\n\\r\\n\\r\\n\\r\\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/86.console`\\r\\n\\r\\nCo-authored-by:\nMatthew
Kime\n<[email protected]>\",\"sha\":\"e6e4e343aa700f1b489915f8df233a0abf2ea058\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/196836\",\"number\":196836,\"mergeCommit\":{\"message\":\"[Console]\nFix
load_from param
(#196836)\\n\\nFixes\nhttps://github.com//issues/195877\\r\\nAddresses\nhttps://github.com//issues/179658\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nThis
PR fixes the bug in Console where using the\n`load_from` param
in\\r\\nthe URL made Console uneditable because every\nre-render reset
the\\r\\ninitial value in the editor. This is fixed by\nrestricting the
hook to\\r\\nonly set the initial value once. This PR also\nadds some
unit tests for\\r\\nthe hook, as I realized that this was
a\nlong-standing improvement.\\r\\n\\r\\n### How to test:\\r\\n\\r\\nTry
loading\nthe following URL (making the necessary replacement in
the\\r\\nURL) and\nverify that the data is correctly loaded into the
editor and\\r\\nvalue\ncan
be\nedited:\\r\\n\\r\\n\\r\\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=data:text/plain,AoeQygKgBA9A+gRwK4FMBOBPGBDAzhgOwGMB+AEzQHsAHOApAGwbiMoaQFsDcAoAbx5QoAImToMwgFwiAZgCVKAWShoUHSgBcUAWgBUkgJYEyKAB4pcwgDSCRDSkWwMUUkSgLXbwmQYZa0rgJCQsIARpRsgbbBIhxIuBquANoAujYxIT5+6Mlp0cHCuAAWlIxkuekZwnEJdJq5+QC+ts2NQA`\\r\\n\\r\\n\\r\\n\\r\\n`http://localhost:5601/<REPLACE-THIS>/app/dev_tools#/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/86.console`\\r\\n\\r\\nCo-authored-by:\nMatthew
Kime\n<[email protected]>\",\"sha\":\"e6e4e343aa700f1b489915f8df233a0abf2ea058\"}}]}]\nBACKPORT-->\n\nCo-authored-by:
Elena Stoeva <[email protected]>"}}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants