-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
🪟🔧 Move connector loading state into connector card #20127
Conversation
airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard.module.scss
Outdated
Show resolved
Hide resolved
airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard.tsx
Outdated
Show resolved
Hide resolved
….module.scss Co-authored-by: Tim Roes <[email protected]>
…or-form-loading-state
…irbytehq/airbyte into flash1293/connector-form-loading-state
…or-form-loading-state
…or-form-loading-state
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 haven't done a deep dive into the code but I feel like there could be an argument for adding a context to hold some of these reused and prop-drilled values. Don't hold this up on my account, merely an observation.
import { ConnectorFormValues } from "./types"; | ||
|
||
interface FormRootProps { | ||
formFields: FormBlock; | ||
hasSuccess?: boolean; | ||
isTestConnectionInProgress?: boolean; | ||
errorMessage?: React.ReactNode; | ||
fetchingConnectorError?: Error | null; | ||
successMessage?: React.ReactNode; | ||
onRetest?: () => void; | ||
onStopTestingConnector?: () => void; |
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 can't comment on it but I think the | undefined
on selectedConnector
prop type (the line below this one) can now be removed, because it is now being passed in from the ConnectorForm in a branch where it is verified to not be undefined.
This should also allow us to remove the selectedConnector && ()
around the <CreateControls>
component near the bottom of this file
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.
Good catch, removed that stuff as well!
selectedConnectorDefinition: ConnectorDefinition; | ||
selectedConnectorDefinitionSpecification: ConnectorDefinitionSpecification; |
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.
A side note that doesn't need to be addressed in this PR: when we eventually want to use the component in the Connector Builder (#17674), there won't be any concept of "connector definitions" to pass to that component. Instead we will just have a JSON schema object that we need to pass in and get back a rendered connector form (or something similar). So it would be great if this component could be generified in that way
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.
Yeah, I'm not sure yet at which level we can lift out the functionality required for the connector builder, I guess we need to move a few things around. I will go through with the rest of the cleanup and take a look then.
</div> | ||
)} | ||
{fetchingConnectorError && <FetchingConnectorError />} | ||
{selectedConnectorDefinition && selectedConnectorDefinitionSpecification && ( |
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.
Is it possible that one of these is nullish even though a user has clicked on a connector from the dropdown? If so we may want to show some sort of error message here indicating that the connector could not be loaded or something. Because based on this code it still seems possible for fetchingConnectorError
to be nullish, and for one of these values to be nullish as well, in which case we just won't render anything here which feels like a not great UX
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 don't think there is a way to run into this situation besides the desired one when the user navigates to a completely empty form.
If you look at the code where the component is used in SourceForm
and DestinationForm
, the props isLoading
,fetchingConnectorError
and selectedConnectorDefinition
are coming from a react-query hook, so one of them will always be set if there is a selection that has been made.
)} | ||
{fetchingConnectorError && <FetchingConnectorError />} | ||
{selectedConnectorDefinition && selectedConnectorDefinitionSpecification && ( | ||
<ConnectorForm |
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.
Also I'm getting a little confused here: your new code makes sense to me in that it only renders a <ConnectorForm>
if selectedConnectorDefinition
and selectedConnectorDefinitionSpecification
are not nullish, but I'm confused how the old code was handling that case -- it seems like the old code was always rendering a ConnectorForm which was always rendering a FormRoot which was always rendering a FormSection, so how does the UI currently look empty when no connector is selected?
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.
You are right, it would render all of the components, but if you follow all the branches in the tree they all used to end in an empty component eventually if nothing is selected (e.g. the form in this case only contains an empty form section which renders an empty fragment)
Tested it out locally and didn't notice any issues |
Thanks for the review @lmossman , could you check again? Removed the additional bit you found. |
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.
Changes LGTM. Tested locally and seems to work as expected
Part of #14250
What
This PR moves the loading spinner which is shown when the connection specification definition is loaded into the connector card component. This is done for a bunch of reasons:
How
In the current state, the formik form is always initialized and rendered, even if there is no specification. The form component is also responsible for rendering the loading spinner itself.
This PR lifts the loading spinner to the connector card level and only renders the form component if all the prerequisites are present.
Drive-by fixes
errorMessage
andsuccessMessage
on the connector card level, those were removed🚨 User Impact 🚨
Fixes a bunch of small bugs but otherwise no user-visible change.