Spaces:
Build error
Build error
File size: 5,458 Bytes
a8b3f00 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import RemoveEffectVarConfirm from '../_base/components/remove-effect-var-confirm'
import VarList from './components/var-list'
import VarItem from './components/var-item'
import useConfig from './use-config'
import type { StartNodeType } from './types'
import Split from '@/app/components/workflow/nodes/_base/components/split'
import Field from '@/app/components/workflow/nodes/_base/components/field'
import AddButton from '@/app/components/base/button/add-button'
import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal'
import type { InputVar, NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.start'
const Panel: FC<NodePanelProps<StartNodeType>> = ({
id,
data,
}) => {
const { t } = useTranslation()
const {
readOnly,
isChatMode,
inputs,
isShowAddVarModal,
showAddVarModal,
handleAddVariable,
hideAddVarModal,
handleVarListChange,
isShowRemoveVarConfirm,
hideRemoveVarConfirm,
onRemoveVarConfirm,
} = useConfig(id, data)
const handleAddVarConfirm = (payload: InputVar) => {
handleAddVariable(payload)
hideAddVarModal()
}
return (
<div className='mt-2'>
<div className='px-4 pb-2 space-y-4'>
<Field
title={t(`${i18nPrefix}.inputField`)}
operations={
!readOnly ? <AddButton onClick={showAddVarModal} /> : undefined
}
>
<>
<VarList
readonly={readOnly}
list={inputs.variables || []}
onChange={handleVarListChange}
/>
<div className='mt-1 space-y-1'>
<Split className='my-2' />
{
isChatMode && (
<VarItem
readonly
payload={{
variable: 'sys.query',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
String
</div>
}
/>)
}
<VarItem
readonly
showLegacyBadge={!isChatMode}
payload={{
variable: 'sys.files',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
Array[File]
</div>
}
/>
{
isChatMode && (
<>
<VarItem
readonly
payload={{
variable: 'sys.dialogue_count',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
Number
</div>
}
/>
<VarItem
readonly
payload={{
variable: 'sys.conversation_id',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
String
</div>
}
/>
</>
)
}
<VarItem
readonly
payload={{
variable: 'sys.user_id',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
String
</div>
}
/>
<VarItem
readonly
payload={{
variable: 'sys.app_id',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
String
</div>
}
/>
<VarItem
readonly
payload={{
variable: 'sys.workflow_id',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
String
</div>
}
/>
<VarItem
readonly
payload={{
variable: 'sys.workflow_run_id',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
String
</div>
}
/>
</div>
</>
</Field>
</div>
{isShowAddVarModal && (
<ConfigVarModal
isCreate
supportFile
isShow={isShowAddVarModal}
onClose={hideAddVarModal}
onConfirm={handleAddVarConfirm}
varKeys={inputs.variables.map(v => v.variable)}
/>
)}
<RemoveEffectVarConfirm
isShow={isShowRemoveVarConfirm}
onCancel={hideRemoveVarConfirm}
onConfirm={onRemoveVarConfirm}
/>
</div>
)
}
export default React.memo(Panel)
|