mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 10:35:51 +08:00
fix: workflow sync before export (#6380)
This commit is contained in:
parent
4ed1476531
commit
984658f5e9
@ -1,4 +1,7 @@
|
|||||||
import { useCallback } from 'react'
|
import {
|
||||||
|
useCallback,
|
||||||
|
useState,
|
||||||
|
} from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useReactFlow } from 'reactflow'
|
import { useReactFlow } from 'reactflow'
|
||||||
import { useWorkflowStore } from '../store'
|
import { useWorkflowStore } from '../store'
|
||||||
@ -10,6 +13,7 @@ import {
|
|||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { useEdgesInteractions } from './use-edges-interactions'
|
import { useEdgesInteractions } from './use-edges-interactions'
|
||||||
import { useNodesInteractions } from './use-nodes-interactions'
|
import { useNodesInteractions } from './use-nodes-interactions'
|
||||||
|
import { useNodesSyncDraft } from './use-nodes-sync-draft'
|
||||||
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
||||||
import { fetchWorkflowDraft } from '@/service/workflow'
|
import { fetchWorkflowDraft } from '@/service/workflow'
|
||||||
import { exportAppConfig } from '@/service/apps'
|
import { exportAppConfig } from '@/service/apps'
|
||||||
@ -79,12 +83,21 @@ export const useWorkflowUpdate = () => {
|
|||||||
export const useDSL = () => {
|
export const useDSL = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { notify } = useToastContext()
|
const { notify } = useToastContext()
|
||||||
|
const [exporting, setExporting] = useState(false)
|
||||||
|
const { doSyncWorkflowDraft } = useNodesSyncDraft()
|
||||||
|
|
||||||
const appDetail = useAppStore(s => s.appDetail)
|
const appDetail = useAppStore(s => s.appDetail)
|
||||||
|
|
||||||
const handleExportDSL = useCallback(async () => {
|
const handleExportDSL = useCallback(async () => {
|
||||||
if (!appDetail)
|
if (!appDetail)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if (exporting)
|
||||||
|
return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setExporting(true)
|
||||||
|
await doSyncWorkflowDraft()
|
||||||
const { data } = await exportAppConfig(appDetail.id)
|
const { data } = await exportAppConfig(appDetail.id)
|
||||||
const a = document.createElement('a')
|
const a = document.createElement('a')
|
||||||
const file = new Blob([data], { type: 'application/yaml' })
|
const file = new Blob([data], { type: 'application/yaml' })
|
||||||
@ -95,7 +108,10 @@ export const useDSL = () => {
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
notify({ type: 'error', message: t('app.exportFailed') })
|
notify({ type: 'error', message: t('app.exportFailed') })
|
||||||
}
|
}
|
||||||
}, [appDetail, notify, t])
|
finally {
|
||||||
|
setExporting(false)
|
||||||
|
}
|
||||||
|
}, [appDetail, notify, t, doSyncWorkflowDraft, exporting])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleExportDSL,
|
handleExportDSL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user