Skip to content

Commit

Permalink
warn on navigating away from unsaved connector form with error (#20072)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Reuter committed Dec 6, 2022
1 parent f1c9d8d commit 4ea4417
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface DestinationFormProps {
serviceType: string;
destinationDefinitionId?: string;
connectionConfiguration?: ConnectionConfiguration;
}) => void;
}) => Promise<void>;
destinationDefinitions: DestinationDefinitionRead[];
hasSuccess?: boolean;
error?: FormError | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface SourceFormProps {
serviceType: string;
sourceDefinitionId?: string;
connectionConfiguration?: ConnectionConfiguration;
}) => void;
}) => Promise<void>;
sourceDefinitions: SourceDefinitionReadWithLatestTag[];
hasSuccess?: boolean;
error?: FormError | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export const ConnectorCard: React.FC<ConnectorCardCreateProps | ConnectorCardEdi
} catch (e) {
setErrorStatusRequest(e);
setIsFormSubmitting(false);
// keep throwing the exception to inform the component the submit did not go through
throw e;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ describe("Service Form", () => {
<ConnectorForm
formType="source"
formValues={{ name: "test-name" }}
onSubmit={(values) => {
onSubmit={async (values) => {
result = values;
}}
selectedConnectorDefinitionSpecification={
Expand Down Expand Up @@ -381,7 +381,7 @@ describe("Service Form", () => {
const renderConnectorForm = (props: ConnectorFormProps) =>
render(<ConnectorForm {...props} formValues={{ name: "test-name" }} />);
// eslint-disable-next-line @typescript-eslint/no-empty-function
const onSubmitClb = () => {};
const onSubmitClb = async () => {};
const connectorDefSpec = {
connectionSpecification: schema,
sourceDefinitionId: "test-service-type",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface ConnectorFormProps {
formId?: string;
selectedConnectorDefinition?: ConnectorDefinition;
selectedConnectorDefinitionSpecification?: ConnectorDefinitionSpecification;
onSubmit: (values: ConnectorFormValues) => Promise<void> | void;
onSubmit: (values: ConnectorFormValues) => Promise<void>;
isLoading?: boolean;
isEditMode?: boolean;
formValues?: Partial<ConnectorFormValues>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
formValues: {
serviceType: TempConnector.sourceDefinitionId,
},
onSubmit: (v) => console.log(v),
onSubmit: async (v) => console.log(v),
availableServices: [TempConnector],
},
decorators: [withMock],
Expand Down

0 comments on commit 4ea4417

Please sign in to comment.