Skip to content

Commit

Permalink
🪟 🐛 Fix broken UI build on master (#19078)
Browse files Browse the repository at this point in the history
* update ServiceForm => ConnectorForm test file

* fixed broken import after merge

* last fixes regarding "ServiceForm => ConnectorForm" renaming
  • Loading branch information
dizel852 authored Nov 7, 2022
1 parent 3365660 commit 9a83342
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import { Text } from "components/ui/Text";

import { ReleaseStage } from "core/request/AirbyteClient";
import { useModalService } from "hooks/services/Modal";
import styles from "views/Connector/ConnectorForm/components/Controls/ConnectorServiceTypeControl/ConnectorServiceTypeControl.module.scss";
import { useAnalyticsTrackFunctions } from "views/Connector/ConnectorForm/components/Controls/ConnectorServiceTypeControl/useAnalyticsTrackFunctions";
import { WarningMessage } from "views/Connector/ConnectorForm/components/WarningMessage";
import RequestConnectorModal from "views/Connector/RequestConnectorModal";
import styles from "views/Connector/ServiceForm/components/Controls/ConnectorServiceTypeControl/ConnectorServiceTypeControl.module.scss";
import { useAnalyticsTrackFunctions } from "views/Connector/ServiceForm/components/Controls/ConnectorServiceTypeControl/useAnalyticsTrackFunctions";
import { WarningMessage } from "views/Connector/ServiceForm/components/WarningMessage";

import { useGetSourceDefinitions } from "./useGetSourceDefinitions";
import { getSortedDropdownData } from "./utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ describe("Service Form", () => {
});

describe("conditionally render form submit button", () => {
const renderServiceForm = (props: ConnectorFormProps) =>
const renderConnectorForm = (props: ConnectorFormProps) =>
render(<ConnectorForm {...props} formValues={{ name: "test-name" }} />);
// eslint-disable-next-line @typescript-eslint/no-empty-function
const onSubmitClb = () => {};
Expand All @@ -388,7 +388,7 @@ describe("Service Form", () => {
};

it("should render <CreateControls /> if connector is selected", async () => {
const { getByText } = await renderServiceForm({
const { getByText } = await renderConnectorForm({
selectedConnectorDefinitionSpecification:
// @ts-expect-error Partial objects for testing
connectorDefSpec as DestinationDefinitionSpecificationRead,
Expand All @@ -399,7 +399,7 @@ describe("Service Form", () => {
});

it("should not render <CreateControls /> if connector is not selected", async () => {
const { container } = await renderServiceForm({
const { container } = await renderConnectorForm({
selectedConnectorDefinitionSpecification: undefined,
formType: "destination",
onSubmit: onSubmitClb,
Expand All @@ -411,7 +411,7 @@ describe("Service Form", () => {
});

it("should render <EditControls /> if connector is selected", async () => {
const { getByText } = await renderServiceForm({
const { getByText } = await renderConnectorForm({
selectedConnectorDefinitionSpecification:
// @ts-expect-error Partial objects for testing
connectorDefSpec as DestinationDefinitionSpecificationRead,
Expand All @@ -424,7 +424,7 @@ describe("Service Form", () => {
});

it("should render <EditControls /> if connector is not selected", async () => {
const { container } = await renderServiceForm({
const { container } = await renderConnectorForm({
selectedConnectorDefinitionSpecification: undefined,
formType: "destination",
onSubmit: onSubmitClb,
Expand Down
4 changes: 2 additions & 2 deletions airbyte-webapp/src/views/Connector/ConnectorForm/FormRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const FormRoot: React.FC<FormRootProps> = ({
selectedConnector,
}) => {
const { dirty, isSubmitting, isValid } = useFormikContext<ConnectorFormValues>();
const { resetServiceForm, isLoadingSchema, selectedService, isEditMode, formType } = useConnectorForm();
const { resetConnectorForm, isLoadingSchema, selectedService, isEditMode, formType } = useConnectorForm();

return (
<Form>
Expand All @@ -63,7 +63,7 @@ export const FormRoot: React.FC<FormRootProps> = ({
isValid={isValid}
dirty={dirty}
onCancelClick={() => {
resetServiceForm();
resetConnectorForm();
}}
successMessage={successMessage}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ConnectorFormContext {
unfinishedFlows: Record<string, { startValue: string; id: number | string }>;
addUnfinishedFlow: (key: string, info?: Record<string, unknown>) => void;
removeUnfinishedFlow: (key: string) => void;
resetServiceForm: () => void;
resetConnectorForm: () => void;
selectedService?: ConnectorDefinition;
selectedConnector?: ConnectorDefinitionSpecification;
isLoadingSchema?: boolean;
Expand All @@ -26,11 +26,11 @@ interface ConnectorFormContext {
const connectorFormContext = React.createContext<ConnectorFormContext | null>(null);

export const useConnectorForm = (): ConnectorFormContext => {
const serviceFormHelpers = useContext(connectorFormContext);
if (!serviceFormHelpers) {
throw new Error("useServiceForm should be used within ServiceFormContextProvider");
const connectorFormHelpers = useContext(connectorFormContext);
if (!connectorFormHelpers) {
throw new Error("useConnectorForm should be used within ConnectorFormContextProvider");
}
return serviceFormHelpers;
return connectorFormHelpers;
};

interface ConnectorFormContextProviderProps {
Expand Down Expand Up @@ -84,7 +84,7 @@ export const ConnectorFormContextProvider: React.FC<React.PropsWithChildren<Conn
"_common.unfinishedFlows",
Object.fromEntries(Object.entries(unfinishedFlows).filter(([key]) => key !== path))
),
resetServiceForm: () => {
resetConnectorForm: () => {
resetForm();
resetUiWidgetsInfo();
},
Expand Down

0 comments on commit 9a83342

Please sign in to comment.