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

Replace EuiCodeBlock with Monaco editor in Discover #90781

Merged
merged 29 commits into from
Feb 17, 2021

Conversation

DianaDerevyankina
Copy link
Contributor

@DianaDerevyankina DianaDerevyankina commented Feb 9, 2021

Related to #59949

Summary

  • Added JsonCodeEditor component based on CodeEditor to replace JsonCodeBlock and reuse in other places in Discover

  • Replaced JsonCodeBlock in Discover expanded document with JsonCodeEditor to enable the folding feature and fix line numbers mentioned in Discover is not showing line numbers in JSON anymore #69614

    image
    Folding icons appear on hover
    image

  • In DocViewerError removed EuiCodeBlock and added EuiErrorBoundary instead
    image

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@DianaDerevyankina DianaDerevyankina added Feature:Discover Discover Application Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.12.0 labels Feb 9, 2021
@DianaDerevyankina DianaDerevyankina self-assigned this Feb 9, 2021
@DianaDerevyankina
Copy link
Contributor Author

@elasticmachine merge upstream

@DianaDerevyankina DianaDerevyankina changed the title Replace EuiCodeBlock with Monaco editor in Discover expanded document Replace EuiCodeBlock with Monaco editor in Discover Feb 10, 2021
@DianaDerevyankina
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM 👍 , thank you so much for taking care of this, it's a nice improvements, found 2 issues while testing:
Elastic

@alexwizp
Copy link
Contributor

@elasticmachine merge upstream

defaultMessage: 'Copy to clipboard',
});

export const JsonCodeEditor = (value: any) => {
Copy link
Member

@kertal kertal Feb 16, 2021

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;
}

@DianaDerevyankina DianaDerevyankina marked this pull request as ready for review February 16, 2021 16:09
@DianaDerevyankina DianaDerevyankina requested a review from a team February 16, 2021 16:09
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@kertal kertal added release_note:enhancement and removed release_note:skip Skip the PR/issue when compiling release notes labels Feb 17, 2021
Copy link
Member

@kertal kertal left a 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 🙏

Copy link
Contributor

@sulemanof sulemanof left a 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} />;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a necessity of leaving this wrapping component?
Could be just removed and replaced in src/plugins/discover/public/plugin.ts
image

@DianaDerevyankina DianaDerevyankina requested a review from a team as a code owner February 17, 2021 11:01
Copy link
Contributor

@ryankeairns ryankeairns left a 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 {
Copy link
Contributor

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.

@ryankeairns ryankeairns self-requested a review February 17, 2021 15:10
Copy link
Contributor

@ryankeairns ryankeairns left a 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!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 339 348 +9

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 426.4KB 408.5KB -17.9KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
discover 69.3KB 79.5KB +10.2KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@DianaDerevyankina DianaDerevyankina merged commit 5bbbcb3 into elastic:master Feb 17, 2021
DianaDerevyankina added a commit to DianaDerevyankina/kibana that referenced this pull request Feb 17, 2021
* 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]>
DianaDerevyankina added a commit that referenced this pull request Feb 18, 2021
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants