-
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
Support triple quoted JSON strings and Painless highlighting to Watcher and SearchProfiler #57563
Conversation
…use in Watcher) Renamed ace/mode -> ace/modes
Enable Watcher editor to parse XJson using XJsonMode
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
Import JSON highlight rules in XJSONHighlight rules
Exporting console_lang through the es_ui_shared/public barrel caused the XJsonMode to imported to a index_management too and any other plugin that may import something from that directory. console_lang was moved to it's own top level directory es_ui_shared/console_lang. We also included a mock for tests using XJsonMode to import from console_lang.
@elasticmachine merge upstream |
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.
@jloleysens thanks for adding this functionality to watcher! Console and search profiler syntax highlighting still worked as expected for me.
Syntax highlighting also works for watcher. However, I did notice that if you create a watch with painless syntax, switch to the "Simulate" tab, and then back to edit, the script is parsed and does not retain the highlighting. Similarly, if you save the watch and then go back to edit it.
I also think we should add the XJSON
mode to the "Alternative input" code editor under the "Simulate" tab.
@alisonelizabeth Those are excellent points! I'll address those points you mentioned for watcher 👍 |
@jloleysens forgot to add - if you could also add a release note to this PR, that would be awesome! |
Console Jest tests were still failing because they did not mock out the raw-loader imported worker file
Upon entering the advanced watcher creation view, the JSON should be scanned for triple quote expansion
Editors had github theme, which diverged from the textmate theme used in Console and SearchProfiler
Slight refactor to the logic for using XJSON mode. Created an adhoc hook for wrapping the logic of useState and moved lanugage util imports there too to reduce the number of imports in both the watcher form and simulate tabs in advanced creation.
@elasticmachine merge upstream |
x-json worker is currently only used inside of x-pack. Also testing for if this will fix the CI/prod build
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.
Latest LGTM. Thanks for making those changes!
@elasticmachine merge upstream |
@elasticmachine merge upstream |
…#57563) * Move mode and lexer rules to shared space * Update searchprofiler mode rules * Moved x-json worker out of searchprofiler and into es_ui_shared (for use in Watcher) Renamed ace/mode -> ace/modes * Moved collapse and expand literal string functions to es_ui_shared * Fix some imports Enable Watcher editor to parse XJson using XJsonMode * Fix imports Import JSON highlight rules in XJSONHighlight rules * Move console_lang, fix Jest tests Exporting console_lang through the es_ui_shared/public barrel caused the XJsonMode to imported to a index_management too and any other plugin that may import something from that directory. console_lang was moved to it's own top level directory es_ui_shared/console_lang. We also included a mock for tests using XJsonMode to import from console_lang. * Fixed OSS Jest tests Console Jest tests were still failing because they did not mock out the raw-loader imported worker file * Expand triple quotes in editor Upon entering the advanced watcher creation view, the JSON should be scanned for triple quote expansion * Bring all editors themes in line Editors had github theme, which diverged from the textmate theme used in Console and SearchProfiler * Added XJSON mode to simulate alternative input editor Slight refactor to the logic for using XJSON mode. Created an adhoc hook for wrapping the logic of useState and moved lanugage util imports there too to reduce the number of imports in both the watcher form and simulate tabs in advanced creation. * Moved x-json worker to x-pack x-json worker is currently only used inside of x-pack. Also testing for if this will fix the CI/prod build Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…re/files-and-filetree * 'master' of github.com:elastic/kibana: (139 commits) Move Ace XJSON lexer-rules, worker and utils to es_ui_shared (elastic#57563) [Upgrade Assistant] Fix filter deprecations search filter (elastic#57541) [ML] New Platform server shim: update indices routes (elastic#57685) Bump redux dependencies (elastic#53348) [Index management] Client-side NP ready (elastic#57295) change id of x-pack event_log plugin to eventLog (elastic#57612) [eventLog] get kibana.index name from config instead of hard-coding it (elastic#57607) revert allow using any path to generate fixes ui titles (elastic#57535) Fix login redirect for expired sessions (elastic#57157) Expose Vis on the contract as it requires visTypes (elastic#56968) [SIEM][Detection Engine] Fixes queries to ignore errors when signals index is not present [Remote clusters] Migrate client-side code out of legacy (elastic#57365) Fix failed test reporter for SIEM Cypress use (elastic#57240) skip flaky suite (elastic#45244) update chromedriver to 80.0.1 (elastic#57602) change slack action to only report on whitelisted host name (elastic#57582) [kbn/optimizer] throw errors into stream on invalid completion (elastic#57735) moving visualize/utils to new platform (elastic#56650) ...
…#57781) * Move mode and lexer rules to shared space * Update searchprofiler mode rules * Moved x-json worker out of searchprofiler and into es_ui_shared (for use in Watcher) Renamed ace/mode -> ace/modes * Moved collapse and expand literal string functions to es_ui_shared * Fix some imports Enable Watcher editor to parse XJson using XJsonMode * Fix imports Import JSON highlight rules in XJSONHighlight rules * Move console_lang, fix Jest tests Exporting console_lang through the es_ui_shared/public barrel caused the XJsonMode to imported to a index_management too and any other plugin that may import something from that directory. console_lang was moved to it's own top level directory es_ui_shared/console_lang. We also included a mock for tests using XJsonMode to import from console_lang. * Fixed OSS Jest tests Console Jest tests were still failing because they did not mock out the raw-loader imported worker file * Expand triple quotes in editor Upon entering the advanced watcher creation view, the JSON should be scanned for triple quote expansion * Bring all editors themes in line Editors had github theme, which diverged from the textmate theme used in Console and SearchProfiler * Added XJSON mode to simulate alternative input editor Slight refactor to the logic for using XJSON mode. Created an adhoc hook for wrapping the logic of useState and moved lanugage util imports there too to reduce the number of imports in both the watcher form and simulate tabs in advanced creation. * Moved x-json worker to x-pack x-json worker is currently only used inside of x-pack. Also testing for if this will fix the CI/prod build Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
💔 Build FailedTest FailuresKibana Pipeline / kibana-xpack-agent / Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/machine_learning/data_frame_analytics/classification_creation·ts.machine learning data frame analytics classification creation bank marketing starts the analytics jobStandard Out
Stack Trace
Kibana Pipeline / kibana-xpack-agent / Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/machine_learning/data_frame_analytics/classification_creation·ts.machine learning data frame analytics classification creation bank marketing starts the analytics jobStandard Out
Stack Trace
History
To update your PR or re-run it, just comment with: |
Summary
The XJSON mode is used currently in SearchProfiler and in Console. Watcher, and probably other plugins, may also want to make use of it if they present users with the Ace Editor.
Fixes #21752
How to review
No functionality should have changed except for that in Watcher. All other changes are just moving files around and one case (
collapseLiteralStrings
,expandLiteralStrings
) moving functionality out of a file.Console
Go to the Console plugin and test check highlighting. The following snippet should show all syntax highlighting in action:
You should have an error next the second "foo" object entry complaining about duplicate keys - indicating that grammar checking still works.
SearchProfiler
SearchProfiler should still work the same (it had XJsonMode before). But should now also provide Painless syntax highlighting.
Try running the default query, and one like the image above, they should both work. As with Console, duplicate keys should still result in a grammar error.
Watcher
Watcher advanced JSON editor also now understands XJSON mode. As with Console, duplicate keys should still result in a grammar error. Introducing a JSON error like
1"3"4
as a key name, should be flagged as invalid JSON. Creating the Watcher with valid JSON should work as before.Release Note
To make multiline script writing more user friendly, we add triple quote (
"""
) parsing and Painless syntax highlighting to Watcher's advanced create editors and SearchProfiler's editor.For maintainers