|
|
|
@ -5,6 +5,7 @@ import {
|
|
|
|
} from 'react'
|
|
|
|
} from 'react'
|
|
|
|
import { useStore } from '@/app/components/workflow/store'
|
|
|
|
import { useStore } from '@/app/components/workflow/store'
|
|
|
|
import { RiCloseLine } from '@remixicon/react'
|
|
|
|
import { RiCloseLine } from '@remixicon/react'
|
|
|
|
|
|
|
|
import type { Node } from '@/app/components/workflow/types'
|
|
|
|
import { BlockEnum } from '@/app/components/workflow/types'
|
|
|
|
import { BlockEnum } from '@/app/components/workflow/types'
|
|
|
|
import DialogWrapper from './dialog-wrapper'
|
|
|
|
import DialogWrapper from './dialog-wrapper'
|
|
|
|
import FieldList from './field-list'
|
|
|
|
import FieldList from './field-list'
|
|
|
|
@ -33,15 +34,14 @@ const InputFieldDialog = ({
|
|
|
|
const setRagPipelineVariables = useStore(state => state.setRagPipelineVariables)
|
|
|
|
const setRagPipelineVariables = useStore(state => state.setRagPipelineVariables)
|
|
|
|
const { doSyncWorkflowDraft } = useNodesSyncDraft()
|
|
|
|
const { doSyncWorkflowDraft } = useNodesSyncDraft()
|
|
|
|
|
|
|
|
|
|
|
|
const datasourceTitleMap = useMemo(() => {
|
|
|
|
const datasourceNodeDataMap = useMemo(() => {
|
|
|
|
const datasourceNameMap: Record<string, string> = {}
|
|
|
|
const datasourceNodeDataMap: Record<string, DataSourceNodeType> = {}
|
|
|
|
const datasourceNodes = nodes.filter(node => node.data.type === BlockEnum.DataSource)
|
|
|
|
const datasourceNodes: Node<DataSourceNodeType>[] = nodes.filter(node => node.data.type === BlockEnum.DataSource)
|
|
|
|
datasourceNodes.forEach((node) => {
|
|
|
|
datasourceNodes.forEach((node) => {
|
|
|
|
const { id, data } = node
|
|
|
|
const { id, data } = node
|
|
|
|
if (data?.title)
|
|
|
|
datasourceNodeDataMap[id] = data
|
|
|
|
datasourceNameMap[id] = data.title
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return datasourceNameMap
|
|
|
|
return datasourceNodeDataMap
|
|
|
|
}, [nodes])
|
|
|
|
}, [nodes])
|
|
|
|
|
|
|
|
|
|
|
|
const inputFieldsMap = useMemo(() => {
|
|
|
|
const inputFieldsMap = useMemo(() => {
|
|
|
|
@ -56,10 +56,6 @@ const InputFieldDialog = ({
|
|
|
|
return inputFieldsMap
|
|
|
|
return inputFieldsMap
|
|
|
|
}, [ragPipelineVariables])
|
|
|
|
}, [ragPipelineVariables])
|
|
|
|
|
|
|
|
|
|
|
|
const datasourceKeys = useMemo(() => {
|
|
|
|
|
|
|
|
return Object.keys(inputFieldsMap).filter(key => key !== 'shared')
|
|
|
|
|
|
|
|
}, [inputFieldsMap])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateInputFields = useCallback(async (key: string, value: InputVar[]) => {
|
|
|
|
const updateInputFields = useCallback(async (key: string, value: InputVar[]) => {
|
|
|
|
const NewInputFieldsMap = produce(inputFieldsMap, (draft) => {
|
|
|
|
const NewInputFieldsMap = produce(inputFieldsMap, (draft) => {
|
|
|
|
draft[key] = value
|
|
|
|
draft[key] = value
|
|
|
|
@ -106,12 +102,12 @@ const InputFieldDialog = ({
|
|
|
|
<div className='flex grow flex-col overflow-y-auto'>
|
|
|
|
<div className='flex grow flex-col overflow-y-auto'>
|
|
|
|
{/* Datasources Inputs */}
|
|
|
|
{/* Datasources Inputs */}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
datasourceKeys.map((key) => {
|
|
|
|
Object.keys(datasourceNodeDataMap).map((key) => {
|
|
|
|
const inputFields = inputFieldsMap[key] || []
|
|
|
|
const inputFields = inputFieldsMap[key] || []
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<FieldList
|
|
|
|
<FieldList
|
|
|
|
key={key}
|
|
|
|
key={key}
|
|
|
|
LabelRightContent={<Datasource title={datasourceTitleMap[key]} />}
|
|
|
|
LabelRightContent={<Datasource nodeData={datasourceNodeDataMap[key]} />}
|
|
|
|
inputFields={inputFields}
|
|
|
|
inputFields={inputFields}
|
|
|
|
readonly={readonly}
|
|
|
|
readonly={readonly}
|
|
|
|
labelClassName='pt-2 pb-1'
|
|
|
|
labelClassName='pt-2 pb-1'
|
|
|
|
|