-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc Improvements to assist Connection Form Refactor #16303
Conversation
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.
Having this split out was really helpful for reviewing!
I left some comments, mostly questions.
@@ -104,10 +91,7 @@ const CreateConnectionContent: React.FC<CreateConnectionContentProps> = ({ | |||
const job = LogsRequestError.extractJobInfo(schemaErrorStatus); | |||
return ( | |||
<ContentCard> | |||
<TryAfterErrorBlock | |||
onClick={onDiscoverSchema} | |||
additionControl={<SkipButton>{additionBottomControls}</SkipButton>} |
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 believe this was removed because there were never any additionBottomControls
passed in, correct?
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.
Correct!
await onDiscoverSchema(); | ||
} | ||
})(); | ||
if (sourceId) { |
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.
async
removed because there is no need to await the resolution of this
@@ -21,7 +21,7 @@ interface DestinationFormProps { | |||
afterSelectConnector?: () => void; | |||
destinationDefinitions: DestinationDefinitionRead[]; | |||
hasSuccess?: boolean; | |||
error?: { message?: string; status?: number } | null; | |||
error?: FormError | null; |
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.
馃Ъ clean
status?: number; | ||
} | ||
|
||
export const createFormErrorMessage = (error: FormError): JSX.Element | string | null => { |
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.
Why is this specific to createForm
? This looks more generic than that. I'm also not sure from the name if this means there was an error creating the form or an error within the creation form (for connections? for connectors?)
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.
Maybe it's for creating a form error message! Again, this seems more generic than forms? and maybe parseErrorMessage
would be less ambiguous?
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'll rename 馃憤
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.
generateMessageFromError
fakeStatusError.status = 401; | ||
expect(createFormErrorMessage(fakeStatusError)).toMatchInlineSnapshot(` | ||
<Memo(MemoizedFormattedMessage) | ||
id="form.someError" |
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.
Why do we want this returning some error
rather than the actual error? We've run into a few places in the UI recently that we've undone places that we mask the actual error returned. Curious if that may apply here too.
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.
<FormattedMessage id="form.someError" />
It's the translation string.
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.
Right, but why do we want that instead of the actual error that is returned?
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 only occurs if the error does not have a message and returns a not-400 error.
I think it's just a "the server had a problem idk" type message since it didn't give us anything.
interface ConnectionFormProps { | ||
export type ConnectionOrPartialConnection = | ||
| WebBackendConnectionRead | ||
| (Partial<WebBackendConnectionRead> & Pick<WebBackendConnectionRead, "syncCatalog" | "source" | "destination">); |
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.
Can you help me understand this type? I'm trying to understand how we'd end up with a partial connection. Or is this in anticipation of the PATCH endpoints?
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.
airbyte/airbyte-webapp/src/components/CreateConnectionContent/CreateConnectionContent.tsx
Line 41 in 89ef25a
const connection = useMemo<ConnectionFormProps["connection"]>( |
When we create a connection we only pass in these properties.
|
||
interface FormikConnectionFormValues { | ||
export interface FormikConnectionFormValues { |
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.
It looks like this is just slightly different from the ValuesProps
type. Would it make sense to have them reference each other somehow?
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'm not sure it's worth trying to bridge the types. There's differences in what's optional.
@@ -41,9 +42,9 @@ interface FormikConnectionFormValues { | |||
normalization?: NormalizationType; | |||
} | |||
|
|||
type ConnectionFormValues = ValuesProps; | |||
export type ConnectionFormValues = ValuesProps; |
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.
Looking through the code, I believe what happens is the FormikConnectionFormValues
are what we use to interact with the form, then there's some casting/transforming and ConnectionFormValues
is what is submitted to the API?
I think we should add a comment explaining that in here (or if I'm wrong, add a comment explaining the right thing :) )
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.
const formValues: ConnectionFormValues = connectionValidationSchema.cast(values, { |
This?
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. Just thinking if it took me a few minutes to figure that out, we could save future someones a few minutes each by commenting why there are two types for values.
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 have a TODO comment in the main PR about aligning the types. Might not be easy though.
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.
Gotcha. We can resolve this then since it sounds like there's some clarification in the other PR. Thanks!
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.
lgtm
* Move exports to declaration for formConfig * Add ConnectionOrPartialConnection, move ConnectionForm exports * Removing additionBottomControls as it was unused * Create and use FormError, test createFormErrorMessage * Remove unnecessary eslint ignore, remove unnecessary async/await * rename createFormErrorMessage
* Move exports to declaration for formConfig * Add ConnectionOrPartialConnection, move ConnectionForm exports * Removing additionBottomControls as it was unused * Create and use FormError, test createFormErrorMessage * Remove unnecessary eslint ignore, remove unnecessary async/await * rename createFormErrorMessage
What
During the Connection Form Refactor work there were various improvements I made as I encountered certain challengers with the refactor. I have consolidated some here which improves the code base and will make the Connection Form Refactor review cleaner.
How
Various typing and stylistic improvements.
One test added.
Removed a unused property.
Recommended reading order
Any
馃毃 User Impact 馃毃
I do not anticipate any issues. This would affect the Refresh Schema button. Other changes would break on build or test.