mirror of
https://github.com/langgenius/dify.git
synced 2026-09-06 17:25:12 +08:00
Co-authored-by: zhangx1n <zhangxin@dify.ai> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
29 lines
838 B
TypeScript
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],
|
|
)
|
|
}
|