Skip to content

Commit

Permalink
fix: fix sdk not correctly handle delete
Browse files Browse the repository at this point in the history
  • Loading branch information
EiffelFly committed Jul 14, 2024
1 parent 30ad4d3 commit d5f7cef
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instill-sdk",
"version": "0.1.0-rc.5",
"version": "0.1.0-rc.6",
"description": "Instill AI's Typescript SDK",
"repository": "https://github.com/instill-ai/typescript-sdk.git",
"bugs": "https://github.com/instill-ai/community/issues",
Expand Down
4 changes: 4 additions & 0 deletions packages/sdk/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export class InstillAPIClient {
throw new Error(`Failed to fetch ${path}`);
}

if (method === "DELETE") {
return Promise.resolve() as Promise<Rsp>;
}

const data = (await response.json()) satisfies Rsp;
return Promise.resolve(data);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instill-ai/toolkit",
"version": "0.96.0-rc.13",
"version": "0.96.0-rc.14",
"description": "Instill AI's frontend toolkit",
"repository": "https://github.com/instill-ai/design-system.git",
"bugs": "https://github.com/instill-ai/design-system/issues",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export async function fetchNamespacePipelineReleases({
pageSize: env("NEXT_PUBLIC_QUERY_PAGE_SIZE"),
shareCode: shareCode,
enablePagination: false,
view: "VIEW_FULL",
});

return Promise.resolve(pipelineReleases);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export function useOperatorDefinition({
accessToken,
enabled,
retry,
view,
disableViewFull,
}: {
operatorDefinitionName: Nullable<string>;
accessToken: Nullable<string>;
enabled: boolean;
retry?: false | number;
view?: string;
disableViewFull?: boolean;
}) {
let enableQuery = false;

Expand All @@ -40,7 +40,7 @@ export function useOperatorDefinition({
const operatorDefinition =
await client.vdp.component.getOperatorDefinition({
operatorDefinitionName,
view,
view: disableViewFull ? undefined : "VIEW_FULL",
});

return Promise.resolve(operatorDefinition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export function useOperatorDefinitions({
accessToken,
enabled,
retry,
view,
disableViewFull,
}: {
accessToken: Nullable<string>;
enabled: boolean;
retry?: false | number;
view?: string;
disableViewFull?: boolean;
}) {
return useQuery({
queryKey: ["operator-definitions"],
Expand All @@ -30,7 +30,7 @@ export function useOperatorDefinitions({
await client.vdp.component.listOperatorDefinitions({
pageSize: env("NEXT_PUBLIC_QUERY_PAGE_SIZE"),
enablePagination: false,
view,
view: disableViewFull ? undefined : "VIEW_FULL",
});

return Promise.resolve(operatorDefinitions);
Expand Down
11 changes: 8 additions & 3 deletions packages/toolkit/src/view/pipeline/view-pipeline/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ export const Head = ({

const deletePipeline = useDeleteNamespacePipeline();
async function handleDeletePipeline() {
if (!accessToken || !pipeline.isSuccess) {
return;
}

try {
await deletePipeline.mutateAsync({
namespacePipelineName: pipeline.data?.name || "",
accessToken: accessToken ? accessToken : null,
namespacePipelineName: pipeline.data.name,
accessToken,
});

toast({
Expand All @@ -116,6 +120,7 @@ export const Head = ({
});
router.push(`/${routeInfo.data.namespaceId}/pipelines`);
} catch (error) {
console.log(error);
toastInstillError({
title: "Something went wrong when delete the pipeline",
error,
Expand All @@ -126,7 +131,7 @@ export const Head = ({

return (
<React.Fragment>
<style jsx={true}>{`
<style jsx>{`
.org-gradient {
background: linear-gradient(45deg, #dce7fe, #fef1f2);
}
Expand Down

0 comments on commit d5f7cef

Please sign in to comment.