Skip to content

feat: integrate new ParserJS with Spectral - #434

Merged
asyncapi-bot merged 3 commits into
asyncapi:masterfrom
magicmatatjahu:spectral-integration
Nov 21, 2022
Merged

asyncapi-bot merged 3 commits into
asyncapi:masterfrom
magicmatatjahu:spectral-integration

Conversation

@magicmatatjahu

@magicmatatjahu magicmatatjahu commented Sep 27, 2022 •

Copy link
Copy Markdown
Member

Description

  • Integrate new v2 ParserJS with Spectral support.
  • Update SpecificationService to handle new parsing behaviour.
  • Studio still uses in rendering old parser-api - it will be rewritten to new one in the next PRs.
  • update webpack config to handle internal Spectral deps.
  • added config for governance in Settings Modal - now we can show/hide warnings/info/hint governance issues.

Example:

image

Related issue(s)
Part of asyncapi/parser-js#481

@magicmatatjahu magicmatatjahu added the enhancement New feature or request label Sep 27, 2022
@netlify

netlify Bot commented Sep 27, 2022 •

Copy link
Copy Markdown

✅ Deploy Preview for modest-rosalind-098b67 ready!

Name Link
🔨 Latest commit 73e6211
🔍 Latest deploy log https://app.netlify.com/sites/modest-rosalind-098b67/deploys/637b4f65a8de26000807e5bf
😎 Deploy Preview https://deploy-preview-434--modest-rosalind-098b67.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@smoya

smoya commented Oct 10, 2022 •

Copy link
Copy Markdown
Member

Netlify build fails because of asyncapi/parser-js#650

Why our CI didn't fail? 🤔

cc @magicmatatjahu @derberg any idea?

@smoya

smoya commented Oct 10, 2022

Copy link
Copy Markdown
Member

@magicmatatjahu can you please bump @asyncapi/parser to 2.0.0-next-major.6 so we fix Netlify build? (I have no permissions to push to your branch unfortunately).

@magicmatatjahu
magicmatatjahu force-pushed the spectral-integration branch 2 times, most recently from c36e682 to 7d64025 Compare October 28, 2022 11:19
@magicmatatjahu
magicmatatjahu marked this pull request as ready for review October 28, 2022 11:22

@jonaslagoni jonaslagoni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Love the new error handling! 🔥 And how accurately it highlights the areas that has problems.

Hate the warning system though 😆 As you are entering the realm of governance rules, which highly vary from user to user. I would HATE to see warnings for an arbitrary rule that someone says I should support, for example, Info object must have "contact" object., as it's not a requirement from the AsyncAPI spec, but spectral.

For some, this will become highly confusing.

I suggest anything beyond requirements from the spec should be turned off, until (if it's being planned) it's possible to personally select linting rules.

And it makes the editor almost unusable with yellow markings all over 😄 Which almost forces you to take action on the warnings.
image

Also, are warnings supposed to be defined as problems? 🤔
image

@magicmatatjahu

magicmatatjahu commented Oct 28, 2022 •

Copy link
Copy Markdown
Member Author

@jonaslagoni Thanks for quick review!

Hate the warning system though 😆 As you are entering the realm of governance rules, which highly vary from user to user. I would HATE to see warnings for an arbitrary rule that someone says I should support, for example, Info object must have "contact" object., as it's not a requirement from the AsyncAPI spec, but spectral.

Warnings inform you about some good practices and we should enable them by default - it's not treated as error and studio will render html documentation on the right, it's only a info to user that something is a good practice 😄 Of course description of such a warning should be defined as Info object should have "contact" object. not "must" but it's a "bug" on Spectral side not our. I don't wanna wait for fixing such a thing on Spectral side, because we will make integration next 1-2 months and it's not a big bug at all.

I suggest anything beyond requirements from the spec should be turned off, until (if it's being planned) it's possible to personally select linting rules.

Yeah, custom rules and overrides are in plan, but probably it will be enabled in next year.

And it makes the editor almost unusable with yellow markings all over 😄 Which almost forces you to take action on the warnings.

Yeah, I hate it either 😆 so I added suggestion (if you didn't see that) in slack:

The only problem I have with the current integration is that we underline even warnings/hints in the editor and not just errors (which should be underlined), making the document itself in the editor have too many "colors" and difficult to read, even document may be correct. Should we inform about warnings and hints in the left side of the editor (where the line numbers are) with warning and hint icons? What do you think about this.

So we should underline only errors (by red color) and warning and hints should be displayed in the left panel (where lines number are) as icon - example: https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-rendering-glyphs-in-the-margin check this red square in editor.


Also, are warnings supposed to be defined as problems? 🤔

We use monaco-editor, this same which VSC uses, so "warnings", "hints" etc are also considering as "problems" - VSC treats every error/waring/hint as problem not "diagnostic" as we do and I don't think so that we can change description of such a warnings.

@jonaslagoni

jonaslagoni commented Oct 28, 2022 •

Copy link
Copy Markdown
Member

Warnings inform you about some good practices and we should enable them by default

I understand that it makes sense to have good practices highlighted, but the matter of the facts is that its only relevant for some users. And it comes down to their use-case and what they would like to see as good practice.

If you develop an internal application and use AsyncAPI to describe it and you are a small team, adding contact info makes no sense.

^just an example, sure in some cases it might be, but for small teams or solos, it does not and does nothing but create friction 🙂

If you really want it, I suggest it be added as part of the settings so it can be turned off at the will of the user.

Of course description of such a warning should be defined as Info object should have "contact" object. not "must" but it's a "bug" on Spectral side not our. I don't wanna wait for fixing such a thing on Spectral side, because we will make integration next 1-2 months and it's not a big bug at all.

That's understandable 🙂

So we should underline only errors (by red color) and warning and hints should be displayed in the left panel (where lines number are) as icon - example: https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-rendering-glyphs-in-the-margin check this red square in editor.

Hard to say 😆 Cause if you then have to add one for each line where the yellow is currently highlighted, it's also quite a lot still 😄

@magicmatatjahu

magicmatatjahu commented Oct 28, 2022 •

Copy link
Copy Markdown
Member Author

I understand that it makes sense to have good practices highlighted, but the matter of the facts is that its only relevant for some users. And it comes down to their use-case and what they would like to see as good practice.

If you really want it, I suggest it be added as part of the settings so it can be turned off at the will of the user.

I understand but I don't like such "filtering", because warning contact is indeed unnecessary but for operationId that should define is good imho 😄 I personally would leave it, for me it's no problem, but I can add options to enable/disable these warnings. I will make it, but probably not today 😄

Hard to say 😆 Cause if you then have to add one for each line where the yellow is currently highlighted, it's also quite a lot still 😄

That icon will be only visible in starting line, so if your object is defined in 20 lines you will only see that icon on first line.

@jonaslagoni

Copy link
Copy Markdown
Member

I understand but I don't like such "filtering", because warning contact is indeed unnecessary but for operationId that should define is good imho 😄 I personally would leave it, for me it's no problem, but I can add options to enable/disable these warnings. I will make it, but probably not today 😄

Just a global one for all warnings I think should be enough, for example, disable good practice warnings or something like that.

That icon will be only visible in starting line, so if your object is defined in 20 lines you will only see that icon on first line.

That would probably make sense then 👍

@magicmatatjahu

Copy link
Copy Markdown
Member Author

I added vertical lines in the left side of editor (where lines are):

image

Errors are still visible as markers:

image

cc @smoya @jonaslagoni what do you think?

@derberg

derberg commented Nov 8, 2022

Copy link
Copy Markdown
Member

I would never guess I can modify the diagnostic settings. Imho there should be some icon/link that I can click, and it will open up a setting for me, with a focus on the proper tab.

Comment thread src/components/Terminal/ProblemsTab.tsx Resolved
@magicmatatjahu

Copy link
Copy Markdown
Member Author

@derberg Ok I will do that, thanks for suggestion!

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@derberg Done :) We have gear icon in the diagnostics tab.

image

Comment on lines +75 to 94
case 1: return (
<div className='flex flex-row items-center justify-center'>
<VscWarning className='text-yellow-500 w-4 h-4' />
</div>
);
case 2: return (
<div className='flex flex-row items-center justify-center'>
<VscInfo className='text-blue-500 w-4 h-4' />
</div>
);
case 3: return (
<div className='flex flex-row items-center justify-center'>
<VscLightbulb className='text-green-500 w-4 h-4' />
</div>
);
default: return (
<div className='flex flex-row items-center justify-center'>
<VscError className='text-red-500 w-4 h-4' />
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be awesome to have tooltips in these icons. Until I came to the code, I couldn't figure out what the green light bulb meant.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I hope that you like it :)

image

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@fmvilas I applied all suggestions. Could you check again? Thanks!
@derberg You added suggestion to have button in tab to open the Governance settings. Could you check and let me know if you like it. I'll be very grateful :)

@derberg

derberg commented Nov 9, 2022

Copy link
Copy Markdown
Member

works like a charm ❤️

fmvilas
fmvilas previously approved these changes Nov 14, 2022

@fmvilas fmvilas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🐑 🇮🇹

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@fmvilas Conflicts are resolved. Could you accept again?

@fmvilas fmvilas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Getting better but still got UX issues.

Comment thread src/components/Terminal/ProblemsTab.tsx Outdated

return (
<ul className='flex flex-row items-center'>
<Tooltip content="Show only errors">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The tooltip is great if this option is not selected but when I click on the button it still says "Show only errors", and it's wrong. It should probably say "Show everything" or "Stop showing only errors" or something like that.

That said, playing with these buttons I realized it's acting as a "select" or "option". Wouldn't it make more sense to accept selecting multiple options? For instance, I want to see errors and warnings only. This is a common thing when you're fixing problems and don't want to have much noise. Also, tooltips will become easier. They'd be something like "Show errors" or "Hide errors".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, I implemented this second approach with Show all diagnostics text if user select only one option :) Play with it and you will see what I have in mind. Thanks for suggestion!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Captura de Pantalla 2022-11-15 a las 18 35 15

The default state doesn't make sense. It says "Show warnings" but I'm already seeing warnings 😅 I think, by default, all buttons should be checked.

@magicmatatjahu magicmatatjahu Nov 16, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think, by default, all buttons should be checked.

It doesn't have a sense, because then people will need to uncheck three buttons if they will want to see only warnings. I changed state to show messages like:

  • buttons are unchecked: Show only {diagnostic type}
  • one button is checked and we hover this checked button: Show all diagnostics and for other Show {diagnostic type}
  • for rest: Show {diagnostic type} or Hide {diagnostic type}

WDYT? :) You can check in preview :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok. Fair. It's weird that all buttons checked and all buttons unchecked will show you the same thing 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One more thing. I clicked on the Settings cog icon:

Captura de Pantalla 2022-11-18 a las 7 33 37

And it lets me disable warning, information, and hint messages. In such case, I think we should disable the buttons in this menu too and when you hover over them you'll see a tooltip saying it's been disabled in the settings and that you have to enable them back if you want to use them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok. Fair. It's weird that all buttons checked and all buttons unchecked will show you the same thing 😅

We should leave it as it's now, because people should have option to disable only one particular kind of diagnostics, when you have enabled others. The current solution isn't perfect but by changing it, people may have a worse UX.

And it lets me disable warning, information, and hint messages. In such case, I think we should disable the buttons in this menu too and when you hover over them you'll see a tooltip saying it's been disabled in the settings and that you have to enable them back if you want to use them.

I will add.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

image

Can it be?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alright, this is looking much better now 👏

Comment thread src/components/Terminal/ProblemsTab.tsx Resolved
Comment thread src/components/Terminal/ProblemsTab.tsx Resolved
@magicmatatjahu

Copy link
Copy Markdown
Member Author

@fmvilas Thanks for review! Could you check again?

Comment thread src/components/Terminal/ProblemsTab.tsx Resolved
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@fmvilas Could you make review again?

@magicmatatjahu

Copy link
Copy Markdown
Member Author

Finally 🚀 Thanks for everyone for review!

@magicmatatjahu

Copy link
Copy Markdown
Member Author

/rtm

@asyncapi-bot
asyncapi-bot merged commit 0a6d9fb into asyncapi:master Nov 21, 2022
@magicmatatjahu
magicmatatjahu deleted the spectral-integration branch November 21, 2022 14:33
@asyncapi-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

KhudaDad414 pushed a commit to KhudaDad414/studio that referenced this pull request Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants