dify/web/app/components/app/deploy/use-undeploy-workflow.ts
Wu Tianwei 7aba539e82
feat: app deployment v2 (#39829)
Co-authored-by: zhangx1n <zhangxin@dify.ai>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-12 01:55:36 +00:00

29 lines
838 B
TypeScript

'use client'
import type { EnvironmentDeployment } from '@dify/contracts/enterprise-app-deploy/types.gen'
import { useMutation } from '@tanstack/react-query'
import { useCallback } from 'react'
import { consoleQuery } from '@/service/client'
export function useUndeployWorkflow(appId: string) {
const { mutateAsync } = useMutation(
consoleQuery.enterprise.appDeploy.deploymentService.undeployWorkflow.mutationOptions(),
)
return useCallback(
(deployment: EnvironmentDeployment) => {
const workflowId = deployment.deployment?.current_version?.id
if (!workflowId) return
return mutateAsync({
params: {
app_id: appId,
environment_id: deployment.environment.id,
workflow_id: workflowId,
},
}).then(() => undefined)
},
[appId, mutateAsync],
)
}