mirror of
https://github.com/langgenius/dify.git
synced 2025-10-29 01:48:44 +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)
|
||||
|
||||
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])
|
||||
|
||||
return datasourceIcon
|
||||
|
||||
@ -31,7 +31,10 @@ import { useToastContext } from '@/app/components/base/toast'
|
||||
import { useParams, useRouter } from 'next/navigation'
|
||||
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
||||
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'
|
||||
|
||||
const PUBLISH_SHORTCUT = ['⌘', '⇧', 'P']
|
||||
@ -58,6 +61,10 @@ const Popup = () => {
|
||||
setFalse: hidePublishing,
|
||||
setTrue: showPublishing,
|
||||
}] = useBoolean(false)
|
||||
const {
|
||||
mutate: publishAsCustomizedPipeline,
|
||||
isPending: isPublishingAsCustomizedPipeline,
|
||||
} = usePublishAsCustomizedPipeline()
|
||||
|
||||
const invalidPublishedPipelineInfo = useInvalid([...publishedPipelineInfoQueryKeyPrefix, pipelineId])
|
||||
|
||||
@ -183,6 +190,8 @@ const Popup = () => {
|
||||
<Button
|
||||
className='w-full hover:bg-state-accent-hover hover:text-text-accent'
|
||||
variant='tertiary'
|
||||
onClick={() => publishAsCustomizedPipeline({ pipelineId: pipelineId || '' })}
|
||||
disabled={!publishedAt || isPublishingAsCustomizedPipeline}
|
||||
>
|
||||
<div className='flex grow items-center'>
|
||||
<RiHammerLine className='mr-2 h-4 w-4' />
|
||||
|
||||
@ -30,7 +30,7 @@ export const useNodeMetaData = (node: Node) => {
|
||||
const nodeMetaData = availableNodesMetaData.nodesMap?.[data.type]
|
||||
const author = useMemo(() => {
|
||||
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.provider_type === CollectionType.builtIn)
|
||||
@ -44,7 +44,7 @@ export const useNodeMetaData = (node: Node) => {
|
||||
|
||||
const description = useMemo(() => {
|
||||
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.provider_type === CollectionType.builtIn)
|
||||
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
|
||||
}
|
||||
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])
|
||||
|
||||
return toolIcon
|
||||
@ -61,7 +61,7 @@ export const useGetToolIcon = () => {
|
||||
}
|
||||
|
||||
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])
|
||||
|
||||
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