mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
feat: dsl check plugin
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { useCallback, useState } from 'react'
|
||||
import type {
|
||||
DebugInfo as DebugInfoTypes,
|
||||
Dependency,
|
||||
InstallPackageResponse,
|
||||
InstalledPluginListResponse,
|
||||
Permissions,
|
||||
@ -16,6 +17,7 @@ import {
|
||||
useQuery,
|
||||
useQueryClient,
|
||||
} from '@tanstack/react-query'
|
||||
import { useStore as usePluginDependencyStore } from '@/app/components/workflow/plugin-dependency/store'
|
||||
|
||||
const NAME_SPACE = 'plugins'
|
||||
|
||||
@ -161,3 +163,33 @@ export const useMutationClearTaskPlugin = () => {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const useMutationCheckDependenciesBeforeImportDSL = () => {
|
||||
const mutation = useMutation({
|
||||
mutationFn: ({ dslString, url }: { dslString?: string, url?: string }) => {
|
||||
if (url) {
|
||||
return post<{ leaked: Dependency[] }>(
|
||||
'/apps/import/url/dependencies/check',
|
||||
{
|
||||
body: {
|
||||
url,
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
return post<{ leaked: Dependency[] }>(
|
||||
'/apps/import/dependencies/check',
|
||||
{
|
||||
body: {
|
||||
data: dslString,
|
||||
},
|
||||
})
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
const { setDependencies } = usePluginDependencyStore.getState()
|
||||
setDependencies(data.leaked || [])
|
||||
},
|
||||
})
|
||||
|
||||
return mutation
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user