-
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
Replace EuiCodeBlock with Monaco editor in Discover #90781
Replace EuiCodeBlock with Monaco editor in Discover #90781
Conversation
@elasticmachine merge upstream |
@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.
@elasticmachine merge upstream |
defaultMessage: 'Copy to clipboard', | ||
}); | ||
|
||
export const JsonCodeEditor = (value: any) => { |
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.
Would be nice to omit any
here, because what you do here is, instead of props
you're using value. then you're using the component <JsonCodeEditor value={valueFromOutside} />
. So value.valueFromOutside
would be needed to get this value, which could be easily omitted by e.g.
interface JsonCodeEditorProps {
value: ElasticSearchHit;
}
Pinging @elastic/kibana-app (Team:KibanaApp) |
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.
Code LGTM, tested locally in Chrome, Firefox, Safari, MacOs. Works as expected! Thanks a lot for taking care of this 🙏
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.
LGTM, tested locally in Chrome & Safari 👍
Left only one nit, code could be cleaned up
</EuiCodeBlock> | ||
); | ||
} | ||
export const JsonCodeBlock = ({ hit }: DocViewRenderProps) => <JsonCodeEditor value={hit} />; |
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.
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.
One minor change request for the CSS class name. Thank you
@@ -0,0 +1,3 @@ | |||
.jsonCodeEditor { |
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.
To be on the safe side, we should use a prefix (.dscJsonCodeEditor
) so as to mitigate the potential for conflicting styles elsewhere in Kibana. The dsc
prefix is common in most other Discover scss
files.
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.
Thanks for the quick change!
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
* Update version of react-monaco-editor and monaco-editor libraries * Fix yarn lock file * Fix CI * Fix unit tests * Fix CI * Fix comment * move monaco instance in window.MonacoEnvironment * Replace EuiCodeBlock with Monaco editor in Discover expanded document * Replace EuiCodeBlock with EuiErrorBoundary * Revert changes done by mistake * Remove unused translations * Fix doc_viewer test and snapshots * Add comment and rename the function related to editor height calculation * Remove "value" from JSON tree and fix resizing * Update json_code_editor.test.tsx.snap * Fix JsonCodeEditor props * Fix json_code_editor test * Delete JsonCodeBlock and remove inline style in JsonCodeEditor * Rename jsonCodeEditor CSS class name to dscJsonCodeEditor Co-authored-by: Uladzislau Lasitsa <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
* Update version of react-monaco-editor and monaco-editor libraries * Fix yarn lock file * Fix CI * Fix unit tests * Fix CI * Fix comment * move monaco instance in window.MonacoEnvironment * Replace EuiCodeBlock with Monaco editor in Discover expanded document * Replace EuiCodeBlock with EuiErrorBoundary * Revert changes done by mistake * Remove unused translations * Fix doc_viewer test and snapshots * Add comment and rename the function related to editor height calculation * Remove "value" from JSON tree and fix resizing * Update json_code_editor.test.tsx.snap * Fix JsonCodeEditor props * Fix json_code_editor test * Delete JsonCodeBlock and remove inline style in JsonCodeEditor * Rename jsonCodeEditor CSS class name to dscJsonCodeEditor Co-authored-by: Uladzislau Lasitsa <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Uladzislau Lasitsa <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
Related to #59949
Summary
Added
JsonCodeEditor
component based onCodeEditor
to replaceJsonCodeBlock
and reuse in other places in DiscoverReplaced
JsonCodeBlock
in Discover expanded document withJsonCodeEditor
to enable the folding feature and fix line numbers mentioned in Discover is not showing line numbers in JSON anymore #69614Folding icons appear on hover
In

DocViewerError
removedEuiCodeBlock
and addedEuiErrorBoundary
insteadChecklist
Delete any items that are not applicable to this PR.
For maintainers