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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc Improvements to assist Connection Form Refactor #16303

Merged
merged 6 commits into from
Sep 7, 2022

Conversation

krishnaglick
Copy link
Contributor

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.

@krishnaglick krishnaglick requested a review from a team as a code owner September 2, 2022 19:26
@github-actions github-actions bot added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Sep 2, 2022
Copy link
Contributor

@teallarson teallarson left a 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>}
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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;
Copy link
Contributor

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 => {
Copy link
Contributor

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?)

Copy link
Contributor

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?

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'll rename 馃憤

Copy link
Contributor Author

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"
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

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 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">);
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const connection = useMemo<ConnectionFormProps["connection"]>(

When we create a connection we only pass in these properties.


interface FormikConnectionFormValues {
export interface FormikConnectionFormValues {
Copy link
Contributor

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?

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'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;
Copy link
Contributor

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 :) )

Copy link
Contributor Author

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?

Copy link
Contributor

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.

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 have a TODO comment in the main PR about aligning the types. Might not be easy though.

Copy link
Contributor

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!

@teallarson teallarson self-requested a review September 7, 2022 14:18
Copy link
Contributor

@teallarson teallarson left a comment

Choose a reason for hiding this comment

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

lgtm

@krishnaglick krishnaglick merged commit a686508 into master Sep 7, 2022
@krishnaglick krishnaglick deleted the kc/misc-improvements branch September 7, 2022 16:32
robbinhan pushed a commit to robbinhan/airbyte that referenced this pull request Sep 29, 2022
* 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
jhammarstedt pushed a commit to jhammarstedt/airbyte that referenced this pull request Oct 31, 2022
* 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
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.

None yet

2 participants