Skip to content

Commit

Permalink
fix: fix cant clone pipeline from pipeline list page (#1567)
Browse files Browse the repository at this point in the history
Because

- console wrongly handle namespaceId and resourceId when clone the
pipeline on pipeline list page

This commit

-  fix cant clone pipeline from pipeline list page
  • Loading branch information
EiffelFly authored Oct 28, 2024
1 parent 014f3ae commit d9945a9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
11 changes: 7 additions & 4 deletions packages/sdk/src/vdp/pipeline/PipelineClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,15 @@ export class PipelineClient extends APIResource {
}

async cloneNamespacePipeline(props: CloneNamespacePipelineRequest) {
const { namespacePipelineName, ...payload } = props;
const { namespaceId, pipelineId, ...payload } = props;

try {
await this._client.post(`/${namespacePipelineName}/clone`, {
body: JSON.stringify(payload),
});
await this._client.post(
`/namespaces/${namespaceId}/pipelines/${pipelineId}/clone`,
{
body: JSON.stringify(payload),
},
);
} catch (error) {
return Promise.reject(error);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/vdp/pipeline/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ export type RenameNamespacePipelineResponse = {
};

export type CloneNamespacePipelineRequest = {
namespacePipelineName: string;
namespaceId: string;
pipelineId: string;
targetNamespaceId: string;
targetPipelineId: string;
description?: string;
Expand Down
6 changes: 5 additions & 1 deletion packages/toolkit/src/components/ClonePipelineDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
import * as React from "react";
import { useRouter } from "next/navigation";
import { zodResolver } from "@hookform/resolvers/zod";
import { InstillNameInterpreter } from "instill-sdk";
import { useForm } from "react-hook-form";
import * as z from "zod";

Expand Down Expand Up @@ -155,7 +156,8 @@ export const ClonePipelineDialog = ({

if (targetNamespace) {
const payload: CloneNamespacePipelineRequest = {
namespacePipelineName: `namespaces/${routeInfo.data.namespaceId}/pipelines/${routeInfo.data.resourceId}`,
namespaceId: InstillNameInterpreter.pipeline(pipeline.name).namespaceId,
pipelineId: pipeline.id,
targetNamespaceId: targetNamespace.id,
targetPipelineId: data.id,
description: data.description ?? undefined,
Expand All @@ -164,9 +166,11 @@ export const ClonePipelineDialog = ({

try {
await clonePipeline.mutateAsync({ payload, accessToken });

if (amplitudeIsInit) {
sendAmplitudeData("clone_pipeline");
}

updateNavigationNamespaceAnchor(() => targetNamespace.id);
router.push(`/${targetNamespace.id}/pipelines/${data.id}/playground`);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export function useCloneNamespacePipeline() {

await client.vdp.pipeline.cloneNamespacePipeline(payload);

return Promise.resolve({ pipelineName: payload.namespacePipelineName });
return Promise.resolve({
pipelineName: `namespaces/${payload.namespaceId}/pipelines/${payload.pipelineId}`,
});
},
onSuccess: async ({ pipelineName }) => {
const namespace = pipelineName.split("/").splice(0, 2).join("/");
Expand Down

0 comments on commit d9945a9

Please sign in to comment.