mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
fix: dsl check
This commit is contained in:
parent
e908ecab8f
commit
e145dba487
@ -72,7 +72,6 @@ import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
|||||||
import NewFeaturePanel from '@/app/components/base/features/new-feature-panel'
|
import NewFeaturePanel from '@/app/components/base/features/new-feature-panel'
|
||||||
import { fetchFileUploadConfig } from '@/service/common'
|
import { fetchFileUploadConfig } from '@/service/common'
|
||||||
import { correctProvider } from '@/utils'
|
import { correctProvider } from '@/utils'
|
||||||
import PluginDependency from '@/app/components/workflow/plugin-dependency'
|
|
||||||
|
|
||||||
type PublishConfig = {
|
type PublishConfig = {
|
||||||
modelConfig: ModelConfig
|
modelConfig: ModelConfig
|
||||||
@ -1042,7 +1041,6 @@ const Configuration: FC = () => {
|
|||||||
onAutoAddPromptVariable={handleAddPromptVariable}
|
onAutoAddPromptVariable={handleAddPromptVariable}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<PluginDependency />
|
|
||||||
</>
|
</>
|
||||||
</FeaturesProvider>
|
</FeaturesProvider>
|
||||||
</ConfigContext.Provider>
|
</ConfigContext.Provider>
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
|||||||
import { getRedirection } from '@/utils/app-redirection'
|
import { getRedirection } from '@/utils/app-redirection'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import { useStore as usePluginDependencyStore } from '@/app/components/workflow/plugin-dependency/store'
|
import { useStore as usePluginDependencyStore } from '@/app/components/workflow/plugin-dependency/store'
|
||||||
|
import PluginDependency from '@/app/components/workflow/plugin-dependency'
|
||||||
|
|
||||||
type CreateFromDSLModalProps = {
|
type CreateFromDSLModalProps = {
|
||||||
show: boolean
|
show: boolean
|
||||||
@ -102,10 +103,10 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
|
|||||||
if (!response)
|
if (!response)
|
||||||
return
|
return
|
||||||
|
|
||||||
const { id, status, app_id, imported_dsl_version, current_dsl_version, leaked } = response
|
const { id, status, app_id, imported_dsl_version, current_dsl_version, leaked_dependencies } = response
|
||||||
if (leaked?.length) {
|
if (leaked_dependencies?.length) {
|
||||||
const { setDependencies } = usePluginDependencyStore.getState()
|
const { setDependencies } = usePluginDependencyStore.getState()
|
||||||
setDependencies(leaked)
|
setDependencies(leaked_dependencies)
|
||||||
}
|
}
|
||||||
if (status === DSLImportStatus.COMPLETED || status === DSLImportStatus.COMPLETED_WITH_WARNINGS) {
|
if (status === DSLImportStatus.COMPLETED || status === DSLImportStatus.COMPLETED_WITH_WARNINGS) {
|
||||||
if (onSuccess)
|
if (onSuccess)
|
||||||
@ -281,6 +282,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
|
|||||||
<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={onDSLConfirm}>{t('app.newApp.Confirm')}</Button>
|
<Button variant='primary' destructive onClick={onDSLConfirm}>{t('app.newApp.Confirm')}</Button>
|
||||||
|
|||||||
@ -72,7 +72,6 @@ import SyncingDataModal from './syncing-data-modal'
|
|||||||
import UpdateDSLModal from './update-dsl-modal'
|
import UpdateDSLModal from './update-dsl-modal'
|
||||||
import DSLExportConfirmModal from './dsl-export-confirm-modal'
|
import DSLExportConfirmModal from './dsl-export-confirm-modal'
|
||||||
import LimitTips from './limit-tips'
|
import LimitTips from './limit-tips'
|
||||||
import PluginDependency from './plugin-dependency'
|
|
||||||
import {
|
import {
|
||||||
useStore,
|
useStore,
|
||||||
useWorkflowStore,
|
useWorkflowStore,
|
||||||
@ -327,7 +326,6 @@ const Workflow: FC<WorkflowProps> = memo(({
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
<PluginDependency />
|
|
||||||
<LimitTips />
|
<LimitTips />
|
||||||
<ReactFlow
|
<ReactFlow
|
||||||
nodeTypes={nodeTypes}
|
nodeTypes={nodeTypes}
|
||||||
|
|||||||
@ -1,23 +1,43 @@
|
|||||||
import { useCallback } from 'react'
|
import {
|
||||||
|
useCallback,
|
||||||
|
useState,
|
||||||
|
} from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useStore } from './store'
|
import { useStore } from './store'
|
||||||
import InstallBundle from '@/app/components/plugins/install-plugin/install-bundle'
|
import ReadyToInstall from '@/app/components/plugins/install-plugin/install-bundle/ready-to-install'
|
||||||
|
import { InstallStep } from '@/app/components/plugins/types'
|
||||||
|
|
||||||
|
const i18nPrefix = 'plugin.installModal'
|
||||||
const PluginDependency = () => {
|
const PluginDependency = () => {
|
||||||
const dependencies = useStore(s => s.dependencies)
|
const dependencies = useStore(s => s.dependencies)
|
||||||
|
|
||||||
const handleCancelInstallBundle = useCallback(() => {
|
const [step, setStep] = useState<InstallStep>(InstallStep.readyToInstall)
|
||||||
const { setDependencies } = useStore.getState()
|
|
||||||
setDependencies([])
|
const { t } = useTranslation()
|
||||||
}, [])
|
const getTitle = useCallback(() => {
|
||||||
|
if (step === InstallStep.uploadFailed)
|
||||||
|
return t(`${i18nPrefix}.uploadFailed`)
|
||||||
|
if (step === InstallStep.installed)
|
||||||
|
return t(`${i18nPrefix}.installComplete`)
|
||||||
|
|
||||||
|
return t(`${i18nPrefix}.installPlugin`)
|
||||||
|
}, [step, t])
|
||||||
|
|
||||||
if (!dependencies.length)
|
if (!dependencies.length)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<InstallBundle
|
<div className='flex pt-6 pl-6 pb-3 pr-14 items-start gap-2 self-stretch'>
|
||||||
fromDSLPayload={dependencies}
|
<div className='self-stretch text-text-primary title-2xl-semi-bold'>
|
||||||
onClose={handleCancelInstallBundle}
|
{getTitle()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ReadyToInstall
|
||||||
|
step={step}
|
||||||
|
onStepChange={setStep}
|
||||||
|
allPlugins={dependencies}
|
||||||
|
onClose={() => {}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -38,6 +38,8 @@ 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 { useStore as usePluginDependencyStore } from '@/app/components/workflow/plugin-dependency/store'
|
||||||
|
import PluginDependency from '@/app/components/workflow/plugin-dependency'
|
||||||
|
|
||||||
type UpdateDSLModalProps = {
|
type UpdateDSLModalProps = {
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
@ -135,7 +137,11 @@ 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 } = response
|
const { id, status, app_id, imported_dsl_version, current_dsl_version, leaked_dependencies } = 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') })
|
||||||
@ -283,6 +289,7 @@ 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>
|
||||||
|
|||||||
@ -88,7 +88,7 @@ export type DSLImportResponse = {
|
|||||||
current_dsl_version?: string
|
current_dsl_version?: string
|
||||||
imported_dsl_version?: string
|
imported_dsl_version?: string
|
||||||
error: string
|
error: string
|
||||||
leaked: Dependency[]
|
leaked_dependencies: Dependency[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AppSSOResponse = { enabled: AppSSO['enable_sso'] }
|
export type AppSSOResponse = { enabled: AppSSO['enable_sso'] }
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import {
|
|||||||
useQuery,
|
useQuery,
|
||||||
useQueryClient,
|
useQueryClient,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
import { useStore as usePluginDependencyStore } from '@/app/components/workflow/plugin-dependency/store'
|
|
||||||
import { useInvalidateAllBuiltInTools } from './use-tools'
|
import { useInvalidateAllBuiltInTools } from './use-tools'
|
||||||
|
|
||||||
const NAME_SPACE = 'plugins'
|
const NAME_SPACE = 'plugins'
|
||||||
@ -324,36 +323,6 @@ export const useMutationClearAllTaskPlugin = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useDownloadPlugin = (info: { organization: string; pluginName: string; version: string }, needDownload: boolean) => {
|
export const useDownloadPlugin = (info: { organization: string; pluginName: string; version: string }, needDownload: boolean) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: [NAME_SPACE, 'downloadPlugin', info],
|
queryKey: [NAME_SPACE, 'downloadPlugin', info],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user