From b311a2fb035e2dcb7a888c26f23ad0c14f8c4823 Mon Sep 17 00:00:00 2001 From: josephkmh Date: Tue, 22 Nov 2022 11:09:03 +0100 Subject: [PATCH 1/3] fix custom connection creation endpoint --- .../core/domain/connector/DestinationDefinitionService.ts | 8 ++++---- .../src/core/domain/connector/SourceDefinitionService.ts | 8 ++++---- .../services/connector/DestinationDefinitionService.ts | 3 ++- .../src/services/connector/SourceDefinitionService.ts | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/airbyte-webapp/src/core/domain/connector/DestinationDefinitionService.ts b/airbyte-webapp/src/core/domain/connector/DestinationDefinitionService.ts index 1f8e960f2736..ee192adeda66 100644 --- a/airbyte-webapp/src/core/domain/connector/DestinationDefinitionService.ts +++ b/airbyte-webapp/src/core/domain/connector/DestinationDefinitionService.ts @@ -1,8 +1,8 @@ import { AirbyteRequestService } from "core/request/AirbyteRequestService"; import { - createDestinationDefinition, - DestinationDefinitionCreate, + createCustomDestinationDefinition, + CustomDestinationDefinitionCreate, DestinationDefinitionIdWithWorkspaceId, DestinationDefinitionUpdate, getDestinationDefinitionForWorkspace, @@ -28,7 +28,7 @@ export class DestinationDefinitionService extends AirbyteRequestService { return updateDestinationDefinition(body, this.requestOptions); } - public create(body: DestinationDefinitionCreate) { - return createDestinationDefinition(body, this.requestOptions); + public createCustom(body: CustomDestinationDefinitionCreate) { + return createCustomDestinationDefinition(body, this.requestOptions); } } diff --git a/airbyte-webapp/src/core/domain/connector/SourceDefinitionService.ts b/airbyte-webapp/src/core/domain/connector/SourceDefinitionService.ts index 701450ff6d10..1578f63106af 100644 --- a/airbyte-webapp/src/core/domain/connector/SourceDefinitionService.ts +++ b/airbyte-webapp/src/core/domain/connector/SourceDefinitionService.ts @@ -7,8 +7,8 @@ import { SourceDefinitionIdWithWorkspaceId, updateSourceDefinition, SourceDefinitionUpdate, - createSourceDefinition, - SourceDefinitionCreate, + CustomSourceDefinitionCreate, + createCustomSourceDefinition, } from "../../request/AirbyteClient"; export class SourceDefinitionService extends AirbyteRequestService { @@ -28,7 +28,7 @@ export class SourceDefinitionService extends AirbyteRequestService { return updateSourceDefinition(body, this.requestOptions); } - public create(body: SourceDefinitionCreate) { - return createSourceDefinition(body, this.requestOptions); + public createCustom(body: CustomSourceDefinitionCreate) { + return createCustomSourceDefinition(body, this.requestOptions); } } diff --git a/airbyte-webapp/src/services/connector/DestinationDefinitionService.ts b/airbyte-webapp/src/services/connector/DestinationDefinitionService.ts index 72b957dcbc65..bd6ef4533749 100644 --- a/airbyte-webapp/src/services/connector/DestinationDefinitionService.ts +++ b/airbyte-webapp/src/services/connector/DestinationDefinitionService.ts @@ -76,9 +76,10 @@ const useDestinationDefinition = ( const useCreateDestinationDefinition = () => { const service = useGetDestinationDefinitionService(); const queryClient = useQueryClient(); + const workspaceId = useCurrentWorkspaceId(); return useMutation( - (destinationDefinition) => service.create(destinationDefinition), + (destinationDefinition) => service.createCustom({ workspaceId, destinationDefinition }), { onSuccess: (data) => { queryClient.setQueryData( diff --git a/airbyte-webapp/src/services/connector/SourceDefinitionService.ts b/airbyte-webapp/src/services/connector/SourceDefinitionService.ts index 6359ee3c431b..1eb287de555f 100644 --- a/airbyte-webapp/src/services/connector/SourceDefinitionService.ts +++ b/airbyte-webapp/src/services/connector/SourceDefinitionService.ts @@ -74,9 +74,10 @@ const useSourceDefinition = ( const useCreateSourceDefinition = () => { const service = useGetSourceDefinitionService(); const queryClient = useQueryClient(); + const workspaceId = useCurrentWorkspaceId(); return useMutation( - (sourceDefinition) => service.create(sourceDefinition), + (sourceDefinition) => service.createCustom({ workspaceId, sourceDefinition }), { onSuccess: (data) => { queryClient.setQueryData( From 320618256b725c17c94a447abdc698c0227b323e Mon Sep 17 00:00:00 2001 From: josephkmh Date: Tue, 22 Nov 2022 21:36:51 +0100 Subject: [PATCH 2/3] fix: redirect after custom connector creation --- .../pages/ConnectorsPage/components/CreateConnector.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnector.tsx b/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnector.tsx index 654e33790bc2..bc53b468d6f1 100644 --- a/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnector.tsx +++ b/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnector.tsx @@ -45,7 +45,7 @@ const CreateConnector: React.FC = ({ type }) => { navigate( { - pathname: `${RoutePaths.Source}${RoutePaths.SourceNew}`, + pathname: `../../${RoutePaths.Source}/${RoutePaths.SourceNew}`, }, { state: { sourceDefinitionId: result.sourceDefinitionId } } ); @@ -61,7 +61,7 @@ const CreateConnector: React.FC = ({ type }) => { navigate( { - pathname: `${RoutePaths.Destination}${DestinationPaths.NewDestination}`, + pathname: `../../${RoutePaths.Destination}/${DestinationPaths.NewDestination}`, }, { state: { destinationDefinitionId: result.destinationDefinitionId } } ); From 0aff942ecc30b2c51b2f037980da4701d7ae475e Mon Sep 17 00:00:00 2001 From: josephkmh Date: Tue, 22 Nov 2022 22:15:23 +0100 Subject: [PATCH 3/3] use explicit paths --- .../pages/ConnectorsPage/components/CreateConnector.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnector.tsx b/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnector.tsx index bc53b468d6f1..265bc4d08aa8 100644 --- a/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnector.tsx +++ b/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnector.tsx @@ -9,6 +9,7 @@ import { Button } from "components/ui/Button"; import { RoutePaths, DestinationPaths } from "pages/routePaths"; import { useCreateDestinationDefinition } from "services/connector/DestinationDefinitionService"; import { useCreateSourceDefinition } from "services/connector/SourceDefinitionService"; +import { useCurrentWorkspaceId } from "services/workspaces/WorkspacesService"; import CreateConnectorModal from "./CreateConnectorModal"; @@ -25,6 +26,7 @@ interface ICreateProps { const CreateConnector: React.FC = ({ type }) => { const navigate = useNavigate(); + const workspaceId = useCurrentWorkspaceId(); const [isModalOpen, setIsModalOpen] = useState(false); const [errorMessage, setErrorMessage] = useState(""); const onChangeModalState = () => { @@ -45,7 +47,7 @@ const CreateConnector: React.FC = ({ type }) => { navigate( { - pathname: `../../${RoutePaths.Source}/${RoutePaths.SourceNew}`, + pathname: `/${RoutePaths.Workspaces}/${workspaceId}/${RoutePaths.Source}/${RoutePaths.SourceNew}`, }, { state: { sourceDefinitionId: result.sourceDefinitionId } } ); @@ -61,7 +63,7 @@ const CreateConnector: React.FC = ({ type }) => { navigate( { - pathname: `../../${RoutePaths.Destination}/${DestinationPaths.NewDestination}`, + pathname: `/${RoutePaths.Workspaces}/${workspaceId}/${RoutePaths.Destination}/${DestinationPaths.NewDestination}`, }, { state: { destinationDefinitionId: result.destinationDefinitionId } } );