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

🪟 🎉 Add yaml validation to Connector Builder and disable buttons when invalid #19001

Merged
merged 16 commits into from
Nov 8, 2022

Conversation

lmossman
Copy link
Contributor

@lmossman lmossman commented Nov 5, 2022

What

Resolves #18918

This PR adds logic to detect when the content of the yaml editor in the Connector Builder is invalid, and if so disables the Download and Test buttons.

Screenshot of what this looks like:
Screen Shot 2022-11-04 at 5 33 01 PM

How

This PR achieves the above by making a few changes:

  1. Move the yaml content state handling into the YamlEditor component, keeping only the json value in the shared state context as that is the only piece that is needed elsewhere
  2. Add logic to the YamlEditor component to catch when the yaml cannot be converted to JSON, and borrow code from this CodeSandbox to highlight the text in the YAML editor with the error that was thrown.
  3. Save the "invalid yaml" status to the shared state context, and refer to that in the download and test buttons, to disable them and add a tooltip explaining why when the yaml is invalid

Recommended reading order

  1. YamlEditor.tsx - most of the new yaml validation / error marking logic borrowed from here
  2. Only other large additions are the modifications to the buttons to disable and add tooltips when yaml is invalid

🚨 User Impact 🚨

Users will now have a better understanding of why their yaml is invalid in the connector builder, and will be unable to perform actions that wouldn't make sense to do anyway when invalid.

@lmossman lmossman marked this pull request as ready for review November 5, 2022 00:32
@lmossman lmossman requested a review from a team as a code owner November 5, 2022 00:32
@github-actions github-actions bot added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Nov 5, 2022
@lmossman lmossman requested a review from timroes November 5, 2022 00:32
setYamlIsValid(false);
const mark = err.mark;
if (yamlEditorModel) {
monaco.editor.setModelMarkers(yamlEditorModel, errOwner, [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One small issue with this is that the error display doesn't really match the current editor theme (it is grey instead of blue). I'm not exactly sure how to customize the theme of those error windows

useEffect(() => {
if (monaco && yamlEditorRef.current && yamlValue) {
const errOwner = "yaml";
console.log(yamlValue);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we planning to keep the console.log in production on purpose or is this a leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry that was a leftover, I will remove!

@lmossman lmossman requested a review from timroes November 7, 2022 22:29
Copy link
Collaborator

@timroes timroes 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. Smoke tested UI in Chrome Linux. Seems to work fine.

Base automatically changed from lmossman/connector-builder-logs-viewer to master November 8, 2022 23:21
akashkulk pushed a commit that referenced this pull request Dec 2, 2022
… invalid (#19001)

* change splitter to be single bar, and rename props

* add logs viewer to testing panel

* make log display height 100%

* remove comment

* clean up some styling, and add record count to tab title

* cleanup + only render paginator and slice selector when necessary

* move selected slice/page state into context and fix bug with state between streams

* fix tab keys

* pull LogsDisplay out into its own component to simplify ResultDisplay

* simplify ResultDisplay prop

* add yaml validation and error marking logic to yaml editor

* generify YamlEditor

* Revert "generify YamlEditor"

This reverts commit decf6d6.

* disable download and test buttons while yaml is invalid

* remove console log and add comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle invalid Connector Builder yaml well
2 participants