|
|
|
@ -38,8 +38,7 @@ import { ToastContext } from '@/app/components/base/toast'
|
|
|
|
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
|
|
|
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
|
|
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
|
|
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
|
|
|
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
|
|
|
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
|
|
|
import PluginDependency from '@/app/components/workflow/plugin-dependency'
|
|
|
|
import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'
|
|
|
|
import { useStore as usePluginDependencyStore } from '@/app/components/workflow/plugin-dependency/store'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type UpdateDSLModalProps = {
|
|
|
|
type UpdateDSLModalProps = {
|
|
|
|
onCancel: () => void
|
|
|
|
onCancel: () => void
|
|
|
|
@ -63,6 +62,7 @@ const UpdateDSLModal = ({
|
|
|
|
const [showErrorModal, setShowErrorModal] = useState(false)
|
|
|
|
const [showErrorModal, setShowErrorModal] = useState(false)
|
|
|
|
const [versions, setVersions] = useState<{ importedVersion: string; systemVersion: string }>()
|
|
|
|
const [versions, setVersions] = useState<{ importedVersion: string; systemVersion: string }>()
|
|
|
|
const [importId, setImportId] = useState<string>()
|
|
|
|
const [importId, setImportId] = useState<string>()
|
|
|
|
|
|
|
|
const { handleCheckPluginDependencies } = usePluginDependencies()
|
|
|
|
|
|
|
|
|
|
|
|
const readFile = (file: File) => {
|
|
|
|
const readFile = (file: File) => {
|
|
|
|
const reader = new FileReader()
|
|
|
|
const reader = new FileReader()
|
|
|
|
@ -137,11 +137,8 @@ const UpdateDSLModal = ({
|
|
|
|
if (appDetail && fileContent) {
|
|
|
|
if (appDetail && fileContent) {
|
|
|
|
setLoading(true)
|
|
|
|
setLoading(true)
|
|
|
|
const response = await importDSL({ mode: DSLImportMode.YAML_CONTENT, yaml_content: fileContent, app_id: appDetail.id })
|
|
|
|
const response = await importDSL({ mode: DSLImportMode.YAML_CONTENT, yaml_content: fileContent, app_id: appDetail.id })
|
|
|
|
const { id, status, app_id, imported_dsl_version, current_dsl_version, leaked_dependencies } = response
|
|
|
|
const { id, status, app_id, imported_dsl_version, current_dsl_version } = response
|
|
|
|
if (leaked_dependencies?.length) {
|
|
|
|
|
|
|
|
const { setDependencies } = usePluginDependencyStore.getState()
|
|
|
|
|
|
|
|
setDependencies(leaked_dependencies)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status === DSLImportStatus.COMPLETED || status === DSLImportStatus.COMPLETED_WITH_WARNINGS) {
|
|
|
|
if (status === DSLImportStatus.COMPLETED || status === DSLImportStatus.COMPLETED_WITH_WARNINGS) {
|
|
|
|
if (!app_id) {
|
|
|
|
if (!app_id) {
|
|
|
|
notify({ type: 'error', message: t('workflow.common.importFailure') })
|
|
|
|
notify({ type: 'error', message: t('workflow.common.importFailure') })
|
|
|
|
@ -155,6 +152,7 @@ const UpdateDSLModal = ({
|
|
|
|
message: t(status === DSLImportStatus.COMPLETED ? 'workflow.common.importSuccess' : 'workflow.common.importWarning'),
|
|
|
|
message: t(status === DSLImportStatus.COMPLETED ? 'workflow.common.importSuccess' : 'workflow.common.importWarning'),
|
|
|
|
children: status === DSLImportStatus.COMPLETED_WITH_WARNINGS && t('workflow.common.importWarningDetails'),
|
|
|
|
children: status === DSLImportStatus.COMPLETED_WITH_WARNINGS && t('workflow.common.importWarningDetails'),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
await handleCheckPluginDependencies(app_id)
|
|
|
|
setLoading(false)
|
|
|
|
setLoading(false)
|
|
|
|
onCancel()
|
|
|
|
onCancel()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -175,12 +173,13 @@ const UpdateDSLModal = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
|
|
catch (e) {
|
|
|
|
catch (e) {
|
|
|
|
setLoading(false)
|
|
|
|
setLoading(false)
|
|
|
|
notify({ type: 'error', message: t('workflow.common.importFailure') })
|
|
|
|
notify({ type: 'error', message: t('workflow.common.importFailure') })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isCreatingRef.current = false
|
|
|
|
isCreatingRef.current = false
|
|
|
|
}, [currentFile, fileContent, onCancel, notify, t, appDetail, onImport, handleWorkflowUpdate])
|
|
|
|
}, [currentFile, fileContent, onCancel, notify, t, appDetail, onImport, handleWorkflowUpdate, handleCheckPluginDependencies])
|
|
|
|
|
|
|
|
|
|
|
|
const onUpdateDSLConfirm: MouseEventHandler = async () => {
|
|
|
|
const onUpdateDSLConfirm: MouseEventHandler = async () => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -198,6 +197,7 @@ const UpdateDSLModal = ({
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleWorkflowUpdate(app_id)
|
|
|
|
handleWorkflowUpdate(app_id)
|
|
|
|
|
|
|
|
await handleCheckPluginDependencies(app_id)
|
|
|
|
if (onImport)
|
|
|
|
if (onImport)
|
|
|
|
onImport()
|
|
|
|
onImport()
|
|
|
|
notify({ type: 'success', message: t('workflow.common.importSuccess') })
|
|
|
|
notify({ type: 'success', message: t('workflow.common.importSuccess') })
|
|
|
|
@ -209,6 +209,7 @@ const UpdateDSLModal = ({
|
|
|
|
notify({ type: 'error', message: t('workflow.common.importFailure') })
|
|
|
|
notify({ type: 'error', message: t('workflow.common.importFailure') })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
|
|
catch (e) {
|
|
|
|
catch (e) {
|
|
|
|
setLoading(false)
|
|
|
|
setLoading(false)
|
|
|
|
notify({ type: 'error', message: t('workflow.common.importFailure') })
|
|
|
|
notify({ type: 'error', message: t('workflow.common.importFailure') })
|
|
|
|
@ -289,7 +290,6 @@ const UpdateDSLModal = ({
|
|
|
|
<div>{t('app.newApp.appCreateDSLErrorPart4')}<span className='system-md-medium'>{versions?.systemVersion}</span></div>
|
|
|
|
<div>{t('app.newApp.appCreateDSLErrorPart4')}<span className='system-md-medium'>{versions?.systemVersion}</span></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<PluginDependency />
|
|
|
|
|
|
|
|
<div className='flex pt-6 justify-end items-start gap-2 self-stretch'>
|
|
|
|
<div className='flex pt-6 justify-end items-start gap-2 self-stretch'>
|
|
|
|
<Button variant='secondary' onClick={() => setShowErrorModal(false)}>{t('app.newApp.Cancel')}</Button>
|
|
|
|
<Button variant='secondary' onClick={() => setShowErrorModal(false)}>{t('app.newApp.Cancel')}</Button>
|
|
|
|
<Button variant='primary' destructive onClick={onUpdateDSLConfirm}>{t('app.newApp.Confirm')}</Button>
|
|
|
|
<Button variant='primary' destructive onClick={onUpdateDSLConfirm}>{t('app.newApp.Confirm')}</Button>
|
|
|
|
|