mirror of
https://github.com/langgenius/dify.git
synced 2025-10-30 10:23:03 +00:00
publish as pipeline
This commit is contained in:
parent
d3eedaf0ec
commit
5e71f7c825
@ -24,7 +24,7 @@ export const useDatasourceIcon = (data: DataSourceNodeType) => {
|
|||||||
useDataSourceList(!!pipelineId, handleUpdateDataSourceList)
|
useDataSourceList(!!pipelineId, handleUpdateDataSourceList)
|
||||||
|
|
||||||
const datasourceIcon = useMemo(() => {
|
const datasourceIcon = useMemo(() => {
|
||||||
return dataSourceList?.find(toolWithProvider => toolWithProvider.name === data.provider_id)?.icon
|
return dataSourceList?.find(toolWithProvider => toolWithProvider.plugin_id === data.plugin_id)?.icon
|
||||||
}, [data, dataSourceList])
|
}, [data, dataSourceList])
|
||||||
|
|
||||||
return datasourceIcon
|
return datasourceIcon
|
||||||
|
|||||||
@ -31,7 +31,10 @@ import { useToastContext } from '@/app/components/base/toast'
|
|||||||
import { useParams, useRouter } from 'next/navigation'
|
import { useParams, useRouter } from 'next/navigation'
|
||||||
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
||||||
import { useInvalid } from '@/service/use-base'
|
import { useInvalid } from '@/service/use-base'
|
||||||
import { publishedPipelineInfoQueryKeyPrefix } from '@/service/use-pipeline'
|
import {
|
||||||
|
publishedPipelineInfoQueryKeyPrefix,
|
||||||
|
usePublishAsCustomizedPipeline,
|
||||||
|
} from '@/service/use-pipeline'
|
||||||
import Confirm from '@/app/components/base/confirm'
|
import Confirm from '@/app/components/base/confirm'
|
||||||
|
|
||||||
const PUBLISH_SHORTCUT = ['⌘', '⇧', 'P']
|
const PUBLISH_SHORTCUT = ['⌘', '⇧', 'P']
|
||||||
@ -58,6 +61,10 @@ const Popup = () => {
|
|||||||
setFalse: hidePublishing,
|
setFalse: hidePublishing,
|
||||||
setTrue: showPublishing,
|
setTrue: showPublishing,
|
||||||
}] = useBoolean(false)
|
}] = useBoolean(false)
|
||||||
|
const {
|
||||||
|
mutate: publishAsCustomizedPipeline,
|
||||||
|
isPending: isPublishingAsCustomizedPipeline,
|
||||||
|
} = usePublishAsCustomizedPipeline()
|
||||||
|
|
||||||
const invalidPublishedPipelineInfo = useInvalid([...publishedPipelineInfoQueryKeyPrefix, pipelineId])
|
const invalidPublishedPipelineInfo = useInvalid([...publishedPipelineInfoQueryKeyPrefix, pipelineId])
|
||||||
|
|
||||||
@ -183,6 +190,8 @@ const Popup = () => {
|
|||||||
<Button
|
<Button
|
||||||
className='w-full hover:bg-state-accent-hover hover:text-text-accent'
|
className='w-full hover:bg-state-accent-hover hover:text-text-accent'
|
||||||
variant='tertiary'
|
variant='tertiary'
|
||||||
|
onClick={() => publishAsCustomizedPipeline({ pipelineId: pipelineId || '' })}
|
||||||
|
disabled={!publishedAt || isPublishingAsCustomizedPipeline}
|
||||||
>
|
>
|
||||||
<div className='flex grow items-center'>
|
<div className='flex grow items-center'>
|
||||||
<RiHammerLine className='mr-2 h-4 w-4' />
|
<RiHammerLine className='mr-2 h-4 w-4' />
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export const useNodeMetaData = (node: Node) => {
|
|||||||
const nodeMetaData = availableNodesMetaData.nodesMap?.[data.type]
|
const nodeMetaData = availableNodesMetaData.nodesMap?.[data.type]
|
||||||
const author = useMemo(() => {
|
const author = useMemo(() => {
|
||||||
if (data.type === BlockEnum.DataSource)
|
if (data.type === BlockEnum.DataSource)
|
||||||
return dataSourceList?.find(dataSource => dataSource.id === data.provider_id)?.author
|
return dataSourceList?.find(dataSource => dataSource.plugin_id === data.plugin_id)?.author
|
||||||
|
|
||||||
if (data.type === BlockEnum.Tool) {
|
if (data.type === BlockEnum.Tool) {
|
||||||
if (data.provider_type === CollectionType.builtIn)
|
if (data.provider_type === CollectionType.builtIn)
|
||||||
@ -44,7 +44,7 @@ export const useNodeMetaData = (node: Node) => {
|
|||||||
|
|
||||||
const description = useMemo(() => {
|
const description = useMemo(() => {
|
||||||
if (data.type === BlockEnum.DataSource)
|
if (data.type === BlockEnum.DataSource)
|
||||||
return dataSourceList?.find(dataSource => dataSource.id === data.provider_id)?.description[language]
|
return dataSourceList?.find(dataSource => dataSource.plugin_id === data.plugin_id)?.description[language]
|
||||||
if (data.type === BlockEnum.Tool) {
|
if (data.type === BlockEnum.Tool) {
|
||||||
if (data.provider_type === CollectionType.builtIn)
|
if (data.provider_type === CollectionType.builtIn)
|
||||||
return buildInTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.description[language]
|
return buildInTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.description[language]
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export const useToolIcon = (data: Node['data']) => {
|
|||||||
return targetTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.icon
|
return targetTools.find(toolWithProvider => canFindTool(toolWithProvider.id, data.provider_id))?.icon
|
||||||
}
|
}
|
||||||
if (data.type === BlockEnum.DataSource)
|
if (data.type === BlockEnum.DataSource)
|
||||||
return dataSourceList?.find(toolWithProvider => toolWithProvider.name === data.provider_id)?.icon
|
return dataSourceList?.find(toolWithProvider => toolWithProvider.plugin_id === data.plugin_id)?.icon
|
||||||
}, [data, buildInTools, customTools, workflowTools, dataSourceList])
|
}, [data, buildInTools, customTools, workflowTools, dataSourceList])
|
||||||
|
|
||||||
return toolIcon
|
return toolIcon
|
||||||
@ -61,7 +61,7 @@ export const useGetToolIcon = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.type === BlockEnum.DataSource)
|
if (data.type === BlockEnum.DataSource)
|
||||||
return dataSourceList?.find(toolWithProvider => toolWithProvider.name === data.provider_id)?.icon
|
return dataSourceList?.find(toolWithProvider => toolWithProvider.plugin_id === data.plugin_id)?.icon
|
||||||
}, [workflowStore])
|
}, [workflowStore])
|
||||||
|
|
||||||
return getToolIcon
|
return getToolIcon
|
||||||
|
|||||||
@ -342,3 +342,14 @@ export const useExportPipelineDSL = () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const usePublishAsCustomizedPipeline = () => {
|
||||||
|
return useMutation({
|
||||||
|
mutationKey: [NAME_SPACE, 'publish-as-customized-pipeline'],
|
||||||
|
mutationFn: ({
|
||||||
|
pipelineId,
|
||||||
|
}: { pipelineId: string }) => {
|
||||||
|
return get(`/rag/customized/pipelines/${pipelineId}/publish`)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user