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

Improve hook for setting the initial value #179658

Open
1 of 3 tasks
Tracked by #176723
ElenaStoeva opened this issue Mar 28, 2024 · 1 comment
Open
1 of 3 tasks
Tracked by #176723

Improve hook for setting the initial value #179658

ElenaStoeva opened this issue Mar 28, 2024 · 1 comment
Labels
Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more

Comments

@ElenaStoeva
Copy link
Contributor

ElenaStoeva commented Mar 28, 2024

The hook in src/plugins/console/public/application/containers/editor/monaco/use_set_initial_value.ts that provides a function for setting the initial value in the Console Monaco editor needs the following improvements:

Tasks

  1. Feature:Console Team:Kibana Management
    ElenaStoeva
@ElenaStoeva ElenaStoeva added the Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages label Mar 28, 2024
@botelastic botelastic bot added the needs-team Issues missing a team label label Mar 28, 2024
@ElenaStoeva ElenaStoeva added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more and removed Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages needs-team Issues missing a team label labels Mar 28, 2024
@alisonelizabeth alisonelizabeth removed the Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more label Sep 17, 2024
@botelastic botelastic bot added the needs-team Issues missing a team label label Sep 17, 2024
@alisonelizabeth alisonelizabeth added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more and removed Feature:Console Dev Tools Console Feature needs-team Issues missing a team label labels Sep 17, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

@alisonelizabeth alisonelizabeth added the Feature:Console Dev Tools Console Feature label Sep 17, 2024
ElenaStoeva added a commit that referenced this issue Oct 21, 2024
Fixes #195877
Addresses #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]>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Oct 21, 2024
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)
ElenaStoeva added a commit to ElenaStoeva/kibana that referenced this issue Oct 22, 2024
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)
ElenaStoeva added a commit that referenced this issue 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
Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

No branches or pull requests

3 participants