| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import type { FC } from 'react' | 
					
						
							|  |  |  | import React from 'react' | 
					
						
							|  |  |  | import { useTranslation } from 'react-i18next' | 
					
						
							|  |  |  | import useConfig from './use-config' | 
					
						
							|  |  |  | import type { AnswerNodeType } from './types' | 
					
						
							|  |  |  | import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor' | 
					
						
							|  |  |  | import type { NodePanelProps } from '@/app/components/workflow/types' | 
					
						
							|  |  |  | import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use-available-var-list' | 
					
						
							|  |  |  | const i18nPrefix = 'workflow.nodes.answer' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const Panel: FC<NodePanelProps<AnswerNodeType>> = ({ | 
					
						
							|  |  |  |   id, | 
					
						
							|  |  |  |   data, | 
					
						
							|  |  |  | }) => { | 
					
						
							|  |  |  |   const { t } = useTranslation() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const { | 
					
						
							|  |  |  |     readOnly, | 
					
						
							|  |  |  |     inputs, | 
					
						
							|  |  |  |     handleAnswerChange, | 
					
						
							|  |  |  |     filterVar, | 
					
						
							|  |  |  |   } = useConfig(id, data) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-27 21:57:08 +08:00
										 |  |  |   const { availableVars, availableNodesWithParent } = useAvailableVarList(id, { | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     onlyLeafNodeVar: false, | 
					
						
							| 
									
										
										
										
											2024-10-25 15:37:29 +08:00
										 |  |  |     hideChatVar: false, | 
					
						
							|  |  |  |     hideEnv: false, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     filterVar, | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |     <div className='mb-2 mt-2 space-y-4 px-4'> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       <Editor | 
					
						
							|  |  |  |         readOnly={readOnly} | 
					
						
							|  |  |  |         justVar | 
					
						
							|  |  |  |         title={t(`${i18nPrefix}.answer`)!} | 
					
						
							|  |  |  |         value={inputs.answer} | 
					
						
							|  |  |  |         onChange={handleAnswerChange} | 
					
						
							|  |  |  |         nodesOutputVars={availableVars} | 
					
						
							| 
									
										
										
										
											2024-05-27 21:57:08 +08:00
										 |  |  |         availableNodes={availableNodesWithParent} | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |         isSupportFileVar | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       /> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default React.memo(Panel) |