[Console] Move out of quarantined#52270
Conversation
…vider test working. Still need to delete some files
Still working on sense editor's integration test Not running yet.
- remove ace ranges from sense editor spec and fix spec 🤦
|
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
💚 Build Succeeded |
src/legacy/core_plugins/console/public/np_ready/application/components/editor_example.tsx
Outdated
Show resolved
Hide resolved
...ugins/console/public/np_ready/application/containers/editor/legacy/console_editor/editor.tsx
Outdated
Show resolved
Hide resolved
...onsole/public/np_ready/application/containers/editor/legacy/console_editor/editor_output.tsx
Outdated
Show resolved
Hide resolved
...public/np_ready/application/containers/editor/legacy/console_editor/apply_editor_settings.ts
Outdated
Show resolved
Hide resolved
...le/public/np_ready/application/containers/editor/legacy/console_editor/keyboard_shortcuts.ts
Outdated
Show resolved
Hide resolved
...plugins/console/public/np_ready/application/containers/editor/legacy/console_menu_actions.ts
Outdated
Show resolved
Hide resolved
...e/public/np_ready/application/models/legacy_core_editor/__tests__/input_tokenization.test.js
Outdated
Show resolved
Hide resolved
...ore_plugins/console/public/np_ready/application/models/legacy_core_editor/create_readonly.ts
Outdated
Show resolved
Hide resolved
Clean up use of jquery Remove use of `done` inside async tests (input_tokenization.test.js) Capitalize elasticsearch Introduce helper for converting to AceRange inside legacy core editor Update typings Clean up imports Cleaner variable assignment
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/curl.ts
Outdated
Show resolved
Hide resolved
| import { CoreEditor, Token } from '../types'; | ||
| import { TokenIterator } from './token_iterator'; | ||
|
|
||
| export const MODE = { |
There was a problem hiding this comment.
Feels like a good candidate for conversion to an enum, but not in this PR.
| clearSelection(): void; | ||
|
|
||
| /** | ||
| * TODO: Document |
There was a problem hiding this comment.
Is this TODO supposed to be completed in this PR? The other new functions have documentation.
💔 Build Failed |
…dels/sense_editor/curl.ts Co-Authored-By: Rory Hunter <pugnascotia@users.noreply.github.com>
💚 Build Succeeded |
cjcenizal
left a comment
There was a problem hiding this comment.
Great work @jloleysens! I tested the scenarios listed in #42029, tried out the different settings, and used the history dropdown. Everything behaved as expected. Code LGTM, just had a few nitpicks and questions but nothing worth blocking on.
The architecture looks like a big improvement. I think we can continue to look for ways to make the the roles of and relationship between SenseEditor and LegacyCoreEditor more apparent. This could be as simple as a name change, or maybe we reconsider whether SenseEditor should be a class and is better broken up into a number of pure functions (just speculating!). Just a casual thought based on some initial confusion I had about these two entities that was partially resolved by reading the source.
| return false; | ||
| } | ||
|
|
||
| export function parseCURL(text: string) { |
There was a problem hiding this comment.
Wow, I had no idea Console supported curl! This is really impressive but it seems like an undocumented feature which adds maintenance overhead, and I'm not sure it's particularly useful or if people even know about it. What do you think about planning for deprecating this feature in the future, e.g. 8.0?
There was a problem hiding this comment.
Check with the Training folks - I have a feeling it was mentioned when I took the ES Engineer 1 training recently.
"Copy as curl" I can see being more useful, but auto-parsing curl is unexpected. Well, to me, anyway.
There was a problem hiding this comment.
Yeah, tbh I didn't really know about this feature either 😅 happy to remove in future!
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/utils.ts
Outdated
Show resolved
Hide resolved
| pos: any, | ||
| prefix: any, | ||
| callback: any | ||
| DO_NOT_USE_SESSION: IEditSession, |
There was a problem hiding this comment.
I love the way you've named things that are deprecated!
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/sense_editor.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/sense_editor.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/sense_editor.ts
Outdated
Show resolved
Hide resolved
lib/utils.js -> lib/utils.ts Rename engulfling range (sense_editor)
|
@elasticmachine merge upstream |
src/legacy/core_plugins/console/public/np_ready/lib/utils/utils.ts
Outdated
Show resolved
Hide resolved
| .replace('^s*\n', '') | ||
| .replace('\ns*^', ''); | ||
| .replace('^\s*\n', '') // prettier-ignore | ||
| .replace('\n\s*$', ''); // prettier-ignore |
There was a problem hiding this comment.
I think Prettier is correct here - these patterns be surrounded in forward-slashes.
const jsonValue = JSON.parse(rawStringifiedValue)
.replace(/^\s*\n/, '')
.replace(/\n\s*$/, '');I see what you mean about the difference with trim() - it would remove all whitespace at the start or end of string, whereas these patterns are a little more subtle. Maybe it would be worth a comment, in case someone comes along later and replaces it with trim(). 😀
There was a problem hiding this comment.
(Although I still query the usefulness of this vs. a simple trim())
There was a problem hiding this comment.
Come to think of it, this replace behaviour was part of legacy and was carried over from a previous alteration. I'm not convinced we want replace behaviour here at all. The value being altered was inside of """ which means string literal in Console. Newlines and whitespace should be preserved. I don't think those replace functions where actually doing anything when the behaviour was considered "correct":
"\n SELECT * FROM \"TABLE\"\n "
.replace('^\s*\n', '')
.replace('\n\s*$', '')
===
"\n SELECT * FROM \"TABLE\"\n "
// trueAutomated and manual testing seem to confirm this. Would you mind taking a look too @pugnascotia ?
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* WiP, lotta broken things, working through new editor.ts * RowParser -> TS * Utils to TS and regular module * Finished first version of core & sense editor wrappers. Tokenizer provider test working. Still need to delete some files * WiP - moved A LOT of code around and busy fixing sense-editor tests * Fix sense editor test * Clean up mocks * Moved A LOT of code out of quarantined. Still working on sense editor's integration test Not running yet. * WiP still finishing up manual testing * Fix use of Ace Range and fix open documentation * Move out of quarantined! * Remove load remote editor state for now * - fix use of token iterator - remove ace ranges from sense editor spec and fix spec 🤦 * Address getSelectionRange document TODO Clean up use of jquery Remove use of `done` inside async tests (input_tokenization.test.js) Capitalize elasticsearch Introduce helper for converting to AceRange inside legacy core editor Update typings Clean up imports Cleaner variable assignment * Update src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/curl.ts Co-Authored-By: Rory Hunter <pugnascotia@users.noreply.github.com> * Remove commented-out code lib/utils.js -> lib/utils.ts Rename engulfling range (sense_editor) * Rename format request function * utils.ts default export usage cleanup * Update replace regex and add another utils test * Remove legacy replace behaviour * Fix typo in comment
* WiP, lotta broken things, working through new editor.ts * RowParser -> TS * Utils to TS and regular module * Finished first version of core & sense editor wrappers. Tokenizer provider test working. Still need to delete some files * WiP - moved A LOT of code around and busy fixing sense-editor tests * Fix sense editor test * Clean up mocks * Moved A LOT of code out of quarantined. Still working on sense editor's integration test Not running yet. * WiP still finishing up manual testing * Fix use of Ace Range and fix open documentation * Move out of quarantined! * Remove load remote editor state for now * - fix use of token iterator - remove ace ranges from sense editor spec and fix spec 🤦 * Address getSelectionRange document TODO Clean up use of jquery Remove use of `done` inside async tests (input_tokenization.test.js) Capitalize elasticsearch Introduce helper for converting to AceRange inside legacy core editor Update typings Clean up imports Cleaner variable assignment * Update src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/curl.ts Co-Authored-By: Rory Hunter <pugnascotia@users.noreply.github.com> * Remove commented-out code lib/utils.js -> lib/utils.ts Rename engulfling range (sense_editor) * Rename format request function * utils.ts default export usage cleanup * Update replace regex and add another utils test * Remove legacy replace behaviour * Fix typo in comment
Summary
This is a continuation (and completion) of a refactor to the public code in Console started with #43346.
Primary objectives
public/quarantined. This entails reviewing and ensuring that we minimise/demarcate direct usage ofbrace. We are not planning on switching to Monaco in the immediate future, but this contribution should help a lot with any such future effort.CoreEditorinterface and implement the newSenseEditormodel which uses it.Overview of
public/np_readydirectory structure (and architecture):applicationshould contain all application relevant logicmodels: contain business logic for our special console language (legacy_core_editor) and knowledge of requests (sense_editor).1.
legacy_core_editorshould contain all wiring up ofbracecontainers: all UI components that interact withcontextcomponents: all pure/function UI componentscontexts: contain the mechanism for how we share our flux-like stores ([Console] Refactoring more legacy code and implementing minor fixes #51312)stores: contain the logic for how state can change and the shape of state sliceshooks: contain all actions that can affect state changes and don't directly speak to rendering UIlibtypesshould live here (e.g.,ace_token_provider) surfaces an implementation ofTokenProviderwithout leaking Ace interfaces.types- folder can be renamed, but named istypesto follow conventions in ES UI management apps. This houses only types + interfaces, no real values.How to review
CoreEditorandSenseEditorinterfaces. They contain new logic and will benefit from having their interfaces reviewed!row->lineNumberfor our position interfaces there is risk of "off-by-one" regressions. These will probably be very hard to spot, but manual and automated testing has caught a large number of these - but still keep an eye out for them!Other goodies
Some fixes were made as part of this PR:
RowParser.ts'sgetRowParseModewhich had an off-by-one regression (example of fix:if (lineNumber < linesCount + 1)...)sense_editor.test.jshad an issue where tests where not correctly reporting failure 🤦♂onDoubleClickinside ofconsole_historycontainer