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

🪟🎨 Clean up connector form form controls #21698

Merged
merged 13 commits into from
Jan 27, 2023

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Jan 23, 2023

What

Fixes #20967

  • Remove legacy styled components
  • Unify look of edit connector form and new connector form
  • Make it possible to check connection without saving
  • Make "retest" button test current form state instead of saved state

Old look

Empty
Screenshot 2023-01-23 at 12 40 01

Selected connector
Screenshot 2023-01-23 at 12 40 11

Check in progress
Screenshot 2023-01-23 at 12 40 19

Error on unsaved connector
Screenshot 2023-01-23 at 12 40 26

Passed checks:
Screenshot 2023-01-23 at 12 40 35

Edit form:
Screenshot 2023-01-23 at 12 40 44

Error on edit form:
Screenshot 2023-01-23 at 12 40 52

New look

Empty
Screenshot 2023-01-23 at 12 41 05

Selected connector
Screenshot 2023-01-23 at 12 41 15

Check in progress
Screenshot 2023-01-23 at 12 41 20

Error on unsaved connector
Screenshot 2023-01-23 at 12 41 24

Passed checks:
Screenshot 2023-01-23 at 12 41 31

Edit form:
Screenshot 2023-01-23 at 12 41 36

Error on edit form:
Screenshot 2023-01-23 at 12 41 42

How

  • To pull the controls out of the card, the ConnectorForm had to be changed:
    • Do not render the card as part of ConnectorCard anymore (move it down to the FormRoot level)
    • Pass down the connector definition select as headerBlock, so it can be rendered inside the card within FormRoot
    • Introduce a renderFooter render prop which is responsible for rendering the form controls:
      • in case of the connector card, it is rendering the testing card as well as the buttons for saving/deleting/canceling (depending on whether it's editing or a new actor)
      • in case of connector builder, it's rendering reset, cancel and save buttons
  • As the connector form is always rendered now even if there is no definition selected yet, the selector specification definition gets optional (which needs to be handled throughout the component)
  • Custom styling of various elements (success message, error message, spacings) are replaced by standard components (flex container and item, text, callout)

@octavia-squidington-iv octavia-squidington-iv added the area/frontend Related to the Airbyte webapp label Jan 23, 2023
@flash1293 flash1293 marked this pull request as ready for review January 23, 2023 15:15
@flash1293 flash1293 requested a review from lmossman January 23, 2023 15:16
Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Left some comments, main changes requested are about issues I found when locally testing.

Overall this is looking great though!

Comment on lines +37 to +39
title?: React.ReactNode;
description?: React.ReactNode;
full?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it might be nice to group these props with the renderWithCard prop somehow, so indicate that these are being applied to the card and are only used if renderWithCard is true

(same comment for FormRoot since these props are drilled into there)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I specified this in the types using a union of an interface for props with renderWithCard: true and title/description/full and one with renderWithCard?: false without them - we use the same pattern for destinations vs. sources.

Also while doing this I deduped the type between form root and connector form and removed a bunch of stuff that's not used anymore.

Comment on lines 127 to 129
onClick={() => {
setTestInputJson({});
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

If the inputs in this ConfigMenu are blank (e.g. first time filling them out, or Reset was clicked to clear them), then you type a value into an input, and click Reset again without saving, it doesn't clear out the value.

I think we need to also clear the formik state here to make that work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, it needs to call resetConnectorForm which is passed in as well, forgot about that.

Comment on lines +56 to +65
<Button
variant="clear"
type="button"
icon={<FontAwesomeIcon icon={logsVisible ? faChevronDown : faChevronRight} />}
onClick={() => {
setLogsVisible(!logsVisible);
}}
>
<FormattedMessage id="connector.testLogs" />
</Button>
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like these logs are only showing up when I click Test and save to perform the test.

If I click the Retest source button instead, the Connector logs tray is not rendered. I would expect as a user that the logs should be shown in both cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is existing behavior but I agree it doesn't make sense. Unified the connection check behavior on submit vs. the test button (we need to set the errorStatusRequest state)

onClick={onRetestClick}
variant="secondary"
icon={<FontAwesomeIcon icon={faRefresh} />}
disabled={!isValid || (!isEditMode && !dirty)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
disabled={!isValid || (!isEditMode && !dirty)}
disabled={!isValid || (isEditMode && !dirty)}

I think this was a mistake. The current logic means that if you set up a new connector and don't change any of the values (e.g set up an E2E Testing destination and don't change any of the defaults), then it won't let you test or submit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, actually it's even simpler - it should always be possible to re-test as long as the form is valid right now.

<FormattedMessage id="form.cancel" />
</Button>
)}
<Button type="submit" disabled={isSubmitting || !dirty}>
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to fix this disabled logic in a similar way, so that if we arent in edit mode, the form can still be submitted even if its not dirty (see above comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjustted

@flash1293
Copy link
Contributor Author

Thanks for the review @lmossman , addressed your points

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Tested out the changes and it looks like all of the things I pointed out have been fixed 👍

@flash1293
Copy link
Contributor Author

flash1293 commented Jan 26, 2023

I had to make a change because I realized we can't use the updated config values when testing an existing source/destination because with #21041 the check_for_update call can potentially update the actor in the database.

This is what I did for now (but we should probably re-visit this in the future):

  • Make the test button test the saved config again (reverting to the existing behavior)
  • Adjust the copy of the button to make it clearer what's happening
  • Disable the button when the form is dirty to avoid people thinking they test the updated state

Also, this change makes me think that we might just want to hide the testing card for new actors and only pop them in if the user tries to save - the current solution is more consistent but I'm not sure.

@lmossman
Copy link
Contributor

@flash1293 to confirm my understanding here:

  1. We cannot call the scheduler/sources/check_connection endpoint (i.e. the one we use when testing new connectors) for testing changes to existing connectors, because we don't have the actual secret values in the webapp, as they are saved to the database
  2. We cannot call the check_connection_for_update endpoint for testing changes to existing connectors, because if there is a control message returned then that could result in the server writing the unsaved form values to the actor database record

If the above is correct, then I think the changes you made make sense to me as a temporary solution.

However, it still feels pretty bad to me that users have no way of testing changes to an existing connector without saving those changes. To solve this, it seems like we need a new API endpoint, or a boolean param added to check_connection_for_update, which causes the API to just run the connection check with the provided values, ignoring control messages and not updating the actor config in the database. Since that is exactly what we want to be able to do with the Test button in the UI.

cc @evantahler @pedroslopez to get your thoughts on the above

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Approving the current state of the PR as a good intermediate solution (see my comment above for my thoughts on follow-up changes here).

Also, this change makes me think that we might just want to hide the testing card for new actors and only pop them in if the user tries to save

I think the current solution is good, since as a user I like being able to test my configuration before I commit to actually saving it.

Tested locally and it works well. There is a merge conflict that needs to be fixed before merging.

@pedroslopez
Copy link
Contributor

pedroslopez commented Jan 26, 2023

However, it still feels pretty bad to me that users have no way of testing changes to an existing connector without saving those changes. To solve this, it seems like we need a new API endpoint, or a boolean param added to check_connection_for_update, which causes the API to just run the connection check with the provided values, ignoring control messages and not updating the actor config in the database. Since that is exactly what we want to be able to do with the Test button in the UI.

@lmossman In general I agree that it's weird that invalid configurations could potentially be saved. However, this comes up because of single-use refresh tokens, which are part of the config. Once that refresh token is used, the previous config would be invalidated. Because of the way the UI worked (I haven't reviewed the actual changes in this PR), you could get into a situation where the check runs, refreshes tokens, and then the UI would call an "update" with the (invalid) values that were in the form. The problem is described more in #20913.

To at least make it clearer to the user we introduced a connectorConfigurationUpdated bool in the response on #21466 so that we could at least show the updated values to the user.

We could add an input to the check that avoids persisting config updates, but this would have to be on some separate button so that we make sure your credentials are valid and properly update refresh tokens if necessary on the check that runs when saving.

@flash1293
Copy link
Contributor Author

@pedroslopez thanks for taking a look!

Because of the way the UI worked (I haven't reviewed the actual changes in this PR), you could get into a situation where the check runs, refreshes tokens, and then the UI would call an "update" with the (invalid) values that were in the form.

Yes, this is handled on a separate PR

We could add an input to the check that avoids persisting config updates, but this would have to be on some separate button so that we make sure your credentials are valid and properly update refresh tokens if necessary on the check that runs when saving.

There is a separate button in the UI for this:
Screenshot 2023-01-27 at 11 14 59

I can open a separate issue for this, I don't think it's a super pressing task though - the UI worked like this probably since the beginning.

@flash1293
Copy link
Contributor Author

@pedroslopez created an issue here: #21960

@flash1293 flash1293 enabled auto-merge (squash) January 27, 2023 11:09
@flash1293 flash1293 merged commit 1697b8e into master Jan 27, 2023
@flash1293 flash1293 deleted the flash1293/form-controls-refactor branch January 27, 2023 13:26
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connector form: Refactor form controls and improve UX
4 participants