Skip to content

Fix bugs in form behavior #13052

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

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Cypress.Commands.add("fillTestLocalJsonForm", (name) => {

cy.wait("@getDestinationSpecifications");

cy.get("input[name=name]").type(name);
cy.get("input[name=name]").clear().type(name);
cy.get("input[name='connectionConfiguration.destination_path']").type("/local");
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Cypress.Commands.add("fillPgSourceForm", (name) => {

cy.wait("@getSourceSpecifications");

cy.get("input[name=name]").type(name);
cy.get("input[name=name]").clear().type(name);
cy.get("input[name='connectionConfiguration.host']").type("localhost");
cy.get("input[name='connectionConfiguration.port']").type("{selectAll}{del}5433");
cy.get("input[name='connectionConfiguration.database']").type("airbyte_ci");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { FormattedMessage } from "react-intl";

import { ContentCard } from "components";
Expand Down Expand Up @@ -37,7 +37,13 @@ export const ConnectorCard: React.FC<
const [saved, setSaved] = useState(false);
const [errorStatusRequest, setErrorStatusRequest] = useState<Error | null>(null);

const { testConnector, isTestConnectionInProgress, onStopTesting, error } = useTestConnector(props);
const { testConnector, isTestConnectionInProgress, onStopTesting, error, reset } = useTestConnector(props);

useEffect(() => {
// Whenever the selected connector changed, reset the check connection call and other errors
reset();
setErrorStatusRequest(null);
}, [props.selectedConnectorDefinitionSpecification, reset]);

const trackNewSourceAction = useTrackAction(TrackActionType.NEW_SOURCE);
const trackNewDestinationAction = useTrackAction(TrackActionType.NEW_DESTINATION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const useTestConnector = (
onStopTesting: () => void;
testConnector: (v?: ServiceFormValues) => Promise<CheckConnectionRead>;
error: Error | null;
reset: () => void;
} => {
const { mutateAsync, isLoading, error, isSuccess, reset } = useCheckConnector(props.formType);

Expand All @@ -31,6 +32,7 @@ export const useTestConnector = (
isTestConnectionInProgress: isLoading,
isSuccess,
error,
reset,
onStopTesting: () => {
abortControllerRef.current?.abort();
reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ const SetDefaultName: React.FC = () => {

useEffect(() => {
if (selectedService) {
setFieldValue("name", selectedService.name);
const timeout = setTimeout(() => {
// We need to push this out one execution slot, so the form isn't still in its
// initialization status and won't react to this call but would just take the initialValues instead.
setFieldValue("name", selectedService.name);
});
return () => clearTimeout(timeout);
}
return;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedService]);

Expand Down