Skip to content

Commit

Permalink
Remove recreate source/destination as it is not used (#11199)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamakase authored Mar 23, 2022
1 parent 8771ba9 commit eaf364e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 141 deletions.
21 changes: 0 additions & 21 deletions airbyte-webapp/src/core/resources/Destination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,6 @@ export class DestinationResource extends BaseResource implements Destination {
};
}

// TODO: remove?
static recreateShape<T extends typeof Resource>(
this: T
): MutateShape<SchemaDetail<Destination>> {
return {
...super.updateShape(),
fetch: async (
_: Readonly<Record<string, string | number>>,
body: Record<string, unknown>
): Promise<Destination> => {
const response = await this.fetch(
"post",
`${super.rootUrl()}web_backend/destinations/recreate`,
body
);
return response;
},
schema: this,
};
}

static createShape<T extends typeof Resource>(
this: T
): MutateShape<SchemaDetail<Destination>> {
Expand Down
21 changes: 0 additions & 21 deletions airbyte-webapp/src/core/resources/Source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,6 @@ export class SourceResource extends BaseResource implements Source {
};
}

// TODO: fix detailShape here as it is actually createShape
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
// TODO: remove?
static recreateShape<T extends typeof Resource>(this: T) {
return {
...super.detailShape(),
fetch: async (
_: Readonly<Record<string, string | number>>,
body: Readonly<Partial<Source>>
): Promise<Source> => {
const response = await this.fetch(
"post",
`${super.rootUrl()}web_backend/sources/recreate`,
body
);
return response;
},
schema: this,
};
}

static createShape<T extends typeof Resource>(
this: T
): MutateShape<SchemaDetail<Source>> {
Expand Down
42 changes: 0 additions & 42 deletions airbyte-webapp/src/hooks/services/useDestinationHook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ type DestinationService = {
values: ValuesProps;
destinationConnector?: ConnectorProps;
}) => Promise<Destination>;
recreateDestination: ({
values,
destinationId,
}: {
values: ValuesProps;
destinationId: string;
}) => Promise<Destination>;
deleteDestination: ({
destination,
connectionsWithDestination,
Expand All @@ -73,8 +66,6 @@ const useDestination = (): DestinationService => {
DestinationResource.partialUpdateShape()
);

const recreatedestination = useFetcher(DestinationResource.recreateShape());

const destinationDelete = useFetcher(DestinationResource.deleteShape());

const updateConnectionsStore = useFetcher(
Expand Down Expand Up @@ -172,38 +163,6 @@ const useDestination = (): DestinationService => {
);
};

const recreateDestination = async ({
values,
destinationId,
}: {
values: ValuesProps;
destinationId: string;
}) => {
return await recreatedestination(
{
destinationId,
},
{
name: values.name,
destinationId,
connectionConfiguration: values.connectionConfiguration,
workspaceId: workspace.workspaceId,
destinationDefinitionId: values.serviceType,
},
// Method used only in onboarding.
// Replace all destination List to new item in UpdateParams (to change id)
[
[
DestinationResource.listShape(),
{ workspaceId: workspace.workspaceId },
(newdestinationId: string) => ({
destinations: [newdestinationId],
}),
],
]
);
};

const checkDestinationConnection = useCallback(
async ({
destinationId,
Expand Down Expand Up @@ -248,7 +207,6 @@ const useDestination = (): DestinationService => {
return {
createDestination,
updateDestination,
recreateDestination,
deleteDestination,
checkDestinationConnection,
};
Expand Down
36 changes: 0 additions & 36 deletions airbyte-webapp/src/hooks/services/useSourceHook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ type ValuesProps = {
type ConnectorProps = { name: string; sourceDefinitionId: string };

type SourceService = {
recreateSource: (recreateSourcePayload: {
values: ValuesProps;
sourceId: string;
}) => Promise<Source>;
checkSourceConnection: (checkSourceConnectionPayload: {
sourceId: string;
values?: ValuesProps;
Expand Down Expand Up @@ -56,8 +52,6 @@ const useSource = (): SourceService => {

const updatesource = useFetcher(SourceResource.partialUpdateShape());

const recreatesource = useFetcher(SourceResource.recreateShape());

const sourceDelete = useFetcher(SourceResource.deleteShape());

const updateConnectionsStore = useFetcher(
Expand Down Expand Up @@ -160,35 +154,6 @@ const useSource = (): SourceService => {
[sourceCheckConnectionShape]
);

const recreateSource: SourceService["recreateSource"] = async ({
values,
sourceId,
}) => {
return await recreatesource(
{
sourceId: sourceId,
},
{
name: values.name,
sourceId,
connectionConfiguration: values.connectionConfiguration,
workspaceId: workspace.workspaceId,
sourceDefinitionId: values.serviceType,
},
// Method used only in onboarding.
// Replace all source List to new item in UpdateParams (to change id)
[
[
SourceResource.listShape(),
{ workspaceId: workspace.workspaceId },
(newsourceId: string) => ({
sources: [newsourceId],
}),
],
]
);
};

const deleteSource: SourceService["deleteSource"] = async ({
source,
connectionsWithSource,
Expand All @@ -214,7 +179,6 @@ const useSource = (): SourceService => {
return {
createSource,
updateSource,
recreateSource,
deleteSource,
checkSourceConnection,
};
Expand Down
28 changes: 7 additions & 21 deletions airbyte-webapp/src/pages/OnboardingPage/OnboardingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ const OnboardingPage: React.FC = () => {
{}
);

const { createSource, recreateSource } = useSource();
const { createDestination, recreateDestination } = useDestination();
const { createSource } = useSource();
const { createDestination } = useDestination();
const { finishOnboarding } = useWorkspace();

const [successRequest, setSuccessRequest] = useState(false);
Expand Down Expand Up @@ -132,14 +132,7 @@ const OnboardingPage: React.FC = () => {
const sourceConnector = getSourceDefinitionById(values.serviceType);

try {
if (!!sources.length) {
await recreateSource({
values,
sourceId: sources[0].sourceId,
});
} else {
await createSource({ values, sourceConnector });
}
await createSource({ values, sourceConnector });

setSuccessRequest(true);
setTimeout(() => {
Expand Down Expand Up @@ -173,17 +166,10 @@ const OnboardingPage: React.FC = () => {
);

try {
if (!!destinations.length) {
await recreateDestination({
values,
destinationId: destinations[0].destinationId,
});
} else {
await createDestination({
values,
destinationConnector,
});
}
await createDestination({
values,
destinationConnector,
});

setSuccessRequest(true);
setTimeout(() => {
Expand Down

0 comments on commit eaf364e

Please sign in to comment.