Skip to content

Commit

Permalink
🪟 🎉 Re-validate connection edit form after schema refresh to highligh…
Browse files Browse the repository at this point in the history
…t any missing keys or cursors (#20327)

* Re-validate form after schema refresh to highlight any missing keys or cursors

* Update ValidateFormOnSchemaRefresh to only set syncCatalog to touched
  • Loading branch information
edmundito committed Dec 12, 2022
1 parent 4335354 commit 6f63e76
Showing 1 changed file with 16 additions and 2 deletions.
@@ -1,5 +1,5 @@
import { Form, Formik, FormikHelpers } from "formik";
import React, { useCallback, useState } from "react";
import { Form, Formik, FormikHelpers, useFormikContext } from "formik";
import React, { useCallback, useEffect, useState } from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { useUnmount } from "react-use";

Expand Down Expand Up @@ -31,6 +31,19 @@ import {
import styles from "./ConnectionReplicationTab.module.scss";
import { ResetWarningModal } from "./ResetWarningModal";

const ValidateFormOnSchemaRefresh: React.FC = () => {
const { schemaHasBeenRefreshed } = useConnectionEditService();
const { setTouched } = useFormikContext();

useEffect(() => {
if (schemaHasBeenRefreshed) {
setTouched({ syncCatalog: true }, true);
}
}, [setTouched, schemaHasBeenRefreshed]);

return null;
};

export const ConnectionReplicationTab: React.FC = () => {
const allowAutoDetectSchemaChanges = useFeature(FeatureItem.AllowAutoDetectSchemaChanges);
const analyticsService = useAnalyticsService();
Expand Down Expand Up @@ -181,6 +194,7 @@ export const ConnectionReplicationTab: React.FC = () => {
>
{({ values, isSubmitting, isValid, dirty, resetForm, status }) => (
<Form>
<ValidateFormOnSchemaRefresh />
<ConnectionFormFields
values={values}
isSubmitting={isSubmitting}
Expand Down

0 comments on commit 6f63e76

Please sign in to comment.