-
Notifications
You must be signed in to change notification settings - Fork 926
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
Use monaco editor for Request Body in Query Editor #4516
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4516 +/- ##
=======================================
Coverage ? 74.08%
Complexity ? 18186
=======================================
Files ? 1537
Lines ? 67469
Branches ? 8537
=======================================
Hits ? 49987
Misses ? 13412
Partials ? 4070 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
## Motivation Allow viewing/editing files. ## Modification - Add monaco editor. https://www.npmjs.com/package/@monaco-editor/react - Update FileList to allow recursive structure for folder. - Add file content. - Add some placeholder components. - Add edit and preview modes ### Notes regarding the choice of file editor The old app is using Ace. It's quite stable but there are some warnings and it needs some workaround to make it work with Nextjs. https://github.com/securingsincity/react-ace Thus, we look into other options https://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors. Both Codemirror and Monaco seem to be a great choice in terms of setup and UI. There's a caveat when using Monaco for JSON. Need a workaround to format the code properly. Since Armeria is moving away from Codemirror line/armeria#4516, we go with Monaco. ## Result <img width="1253" alt="Screen Shot 2022-12-26 at 18 04 18" src="https://user-images.githubusercontent.com/5079588/209541874-48470cc4-fe25-4c63-9136-d7a977ef9123.png"> <img width="829" alt="Screen Shot 2022-12-27 at 11 52 15" src="https://user-images.githubusercontent.com/5079588/209612997-af4d8506-edb9-4767-95a0-99c863d5c20e.png">
Waiting until is merged so we can have the full autocomplete feature right away. |
Updated with the latest master ^ |
@ikhoon Can we release this in 1.22.0 ? This is ready to be tested and hopefully it will be useful. |
Thanks for your hard work. 🙇♂️ This is so a nice feature that users should love. That being said, we didn't have the time to review this PR. There are some features needed to release in a timely manner for LINE internal users. Let me review this after releasing 1.22.0 and ship it in 1.23.0. |
Sure, thanks for the heads-up 😉 |
bump |
Sorry 😅 We definitely didn't forget about this PR (it's going to be one of the highlights of the next release) |
I found a bug that a JSON schema for Lines 561 to 563 in ed1482a
We may apply useParameterAsRoot to the JSON request.
|
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.
This is so awesome for gRPC and Thrift.
However, we need to consider exceptional rules for annotated services.
Had a chat with other team members and we decided to support gRPC and Thrift at the moment. |
What is the easiest way to check whether a call is Maybe via this: const isRPC = grpcUnframedTransport.supportsMimeType(mimeType)
|| thriftTransport.supportsMimeType(mimeType); |
It looks like the easiest way. 😅 |
7235e1f
to
86fd7be
Compare
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.
Lovely. Thanks a lot, @Dogacel! 🙇
I am blocked by this: And I suppose my |
According to |
@Dogacel It seems like the npm and webpack don't complain anymore at least. Could you check if my fix works as intended? |
I had to downgrade nodejs from 18 to 16 because our CI machines are using old GLIBC, but it still seems to work. |
- Do not set the language option to 'json' if no JSON schema is available.
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 a ton, @Dogacel! ❤️
@@ -77,6 +80,19 @@ const GraphqlRequestBody: React.FunctionComponent<Props> = ({ | |||
const [variablesText, setVariablesText] = useState(''); | |||
const [schema, setSchema] = useState<GraphQLSchema | undefined>(); | |||
|
|||
const monacoEditor = useMonaco(); | |||
|
|||
useEffect(() => { |
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.
Recently, I read an article about useEffect()
https://react.dev/learn/you-might-not-need-an-effect
Based on the article, I thought this was not a good case of using useEffect
. So I used useMemo()
instead.
https://react.dev/learn/you-might-not-need-an-effect#caching-expensive-calculations
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.
Ah, I got confused for a second because commit title was [- Replace useMemo with useEffect.]
😅 I think it makes sense, thanks for adding this 👍
"codemirror": "^5.65.2", | ||
"codemirror-graphql": "^1.2.17", |
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.
👍
I will check this separetely. |
I found out that incompatibility with NodeJS 18 and AWS EC2 is a known issue. |
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.
The code changes itself look good to me! Also looking into the file issue mentioned here by @ikhoon #4516 (comment)
docs-client/webpack.config.ts
Outdated
excludedPackageTest: (packageName: string) => { | ||
// @monaco-editor/react and monaco-editor are the same package and causes license duplication. | ||
return packageName.includes("monaco-editor"); | ||
}, |
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.
Did you try running with perChunkOutput:false
by any chance? I don't think we want to generate license files per chunk anyways and it seemed to run without errors in my local env.
ref: https://github.com/xz64/license-webpack-plugin/blob/master/DOCUMENTATION.md
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.
That + @ikhoon 's changes regarding the number of chunks actually fixed the error and now we have a lot more licenses inside the license file. Probably it was what it should have been in the first place.
I have tested this one last time and everything looks good to me. Thanks, everyone for all the collaborative effort. It included lots of learning experiences for me, I hope people will enjoy using doc service more now 😄 |
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.
Great job, @Dogacel! 👍 👍 👍
This will be one of the key features of the year. 🎉 🎉 🎉 |
## Motivation Allow viewing/editing files. ## Modification - Add monaco editor. https://www.npmjs.com/package/@monaco-editor/react - Update FileList to allow recursive structure for folder. - Add file content. - Add some placeholder components. - Add edit and preview modes ### Notes regarding the choice of file editor The old app is using Ace. It's quite stable but there are some warnings and it needs some workaround to make it work with Nextjs. https://github.com/securingsincity/react-ace Thus, we look into other options https://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors. Both Codemirror and Monaco seem to be a great choice in terms of setup and UI. There's a caveat when using Monaco for JSON. Need a workaround to format the code properly. Since Armeria is moving away from Codemirror line/armeria#4516, we go with Monaco. ## Result <img width="1253" alt="Screen Shot 2022-12-26 at 18 04 18" src="https://user-images.githubusercontent.com/5079588/209541874-48470cc4-fe25-4c63-9136-d7a977ef9123.png"> <img width="829" alt="Screen Shot 2022-12-27 at 11 52 15" src="https://user-images.githubusercontent.com/5079588/209612997-af4d8506-edb9-4767-95a0-99c863d5c20e.png">
## Motivation Allow viewing/editing files. ## Modification - Add monaco editor. https://www.npmjs.com/package/@monaco-editor/react - Update FileList to allow recursive structure for folder. - Add file content. - Add some placeholder components. - Add edit and preview modes ### Notes regarding the choice of file editor The old app is using Ace. It's quite stable but there are some warnings and it needs some workaround to make it work with Nextjs. https://github.com/securingsincity/react-ace Thus, we look into other options https://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors. Both Codemirror and Monaco seem to be a great choice in terms of setup and UI. There's a caveat when using Monaco for JSON. Need a workaround to format the code properly. Since Armeria is moving away from Codemirror line/armeria#4516, we go with Monaco. ## Result <img width="1253" alt="Screen Shot 2022-12-26 at 18 04 18" src="https://user-images.githubusercontent.com/5079588/209541874-48470cc4-fe25-4c63-9136-d7a977ef9123.png"> <img width="829" alt="Screen Shot 2022-12-27 at 11 52 15" src="https://user-images.githubusercontent.com/5079588/209612997-af4d8506-edb9-4767-95a0-99c863d5c20e.png">
I've upgraded our self-hosted CI machines to the latest OS that will be compatible NodeJS 18. |
Motivation:
Update the debug form to use Microsoft's well-known
Monaco Editor
.Modifications:
Result:
Screen.Recording.2022-11-10.at.22.44.28.mov
The example used is
GrpcDocServiceTest
the method isUnaryMethod
.This PR is required to enable auto-complete:
Generate JSON Schema from ServiceSpecifications #4518
Part of Revamp DebugPage in DocService #2844