Skip to content
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

Remove recreate source/destination as it is not used #11199

Merged
merged 1 commit into from
Mar 23, 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
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 @@ -86,13 +86,6 @@ type DestinationService = {
values: ValuesProps;
destinationConnector?: ConnectorProps;
}) => Promise<Destination>;
recreateDestination: ({
values,
destinationId,
}: {
values: ValuesProps;
destinationId: string;
}) => Promise<Destination>;
deleteDestination: ({
destination,
connectionsWithDestination,
Expand All @@ -118,8 +111,6 @@ const useDestination = (): DestinationService => {
DestinationResource.partialUpdateShape()
);

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

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

const updateConnectionsStore = useFetcher(
Expand Down Expand Up @@ -217,38 +208,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 @@ -293,7 +252,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 @@ -47,10 +47,6 @@ export const useSourceDefinitionSpecificationLoad = (
};

type SourceService = {
recreateSource: (recreateSourcePayload: {
values: ValuesProps;
sourceId: string;
}) => Promise<Source>;
checkSourceConnection: (checkSourceConnectionPayload: {
sourceId: string;
values?: ValuesProps;
Expand Down Expand Up @@ -81,8 +77,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 @@ -185,35 +179,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 @@ -239,7 +204,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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this seems to be the root place this was triggered, could you explain when this was triggered earlier, and why this is no longer happening in the app? I am not fully understanding the scenario where this happened and what the user-flow was when this was still in use.

Copy link
Contributor Author

@jamakase jamakase Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I am also not sure when this was happening exactly, but as I remember in the past it was possible to go back and forward during onboarding. So we were recreating destination in some cases. After this functionality was disabled - this endpoint was never called.

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

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