| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  | import type { FC } from 'react' | 
					
						
							|  |  |  | import React from 'react' | 
					
						
							|  |  |  | import { useTranslation } from 'react-i18next' | 
					
						
							| 
									
										
										
										
											2024-12-03 13:56:40 +08:00
										 |  |  | import { | 
					
						
							|  |  |  |   RiAddLine, | 
					
						
							|  |  |  | } from '@remixicon/react' | 
					
						
							|  |  |  | import VarList from './components/var-list' | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  | import useConfig from './use-config' | 
					
						
							|  |  |  | import type { AssignerNodeType } from './types' | 
					
						
							| 
									
										
										
										
											2025-02-17 17:05:13 +08:00
										 |  |  | import type { NodePanelProps } from '@/app/components/workflow/types' | 
					
						
							| 
									
										
										
										
											2024-12-03 13:56:40 +08:00
										 |  |  | import { useHandleAddOperationItem } from './hooks' | 
					
						
							|  |  |  | import ActionButton from '@/app/components/base/action-button' | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | const i18nPrefix = 'workflow.nodes.assigner' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const Panel: FC<NodePanelProps<AssignerNodeType>> = ({ | 
					
						
							|  |  |  |   id, | 
					
						
							|  |  |  |   data, | 
					
						
							|  |  |  | }) => { | 
					
						
							|  |  |  |   const { t } = useTranslation() | 
					
						
							| 
									
										
										
										
											2024-12-03 13:56:40 +08:00
										 |  |  |   const handleAddOperationItem = useHandleAddOperationItem() | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  |   const { | 
					
						
							|  |  |  |     readOnly, | 
					
						
							|  |  |  |     inputs, | 
					
						
							| 
									
										
										
										
											2024-12-03 13:56:40 +08:00
										 |  |  |     handleOperationListChanges, | 
					
						
							|  |  |  |     getAssignedVarType, | 
					
						
							|  |  |  |     getToAssignedVarType, | 
					
						
							|  |  |  |     writeModeTypesNum, | 
					
						
							|  |  |  |     writeModeTypesArr, | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  |     writeModeTypes, | 
					
						
							|  |  |  |     filterAssignedVar, | 
					
						
							|  |  |  |     filterToAssignedVar, | 
					
						
							|  |  |  |   } = useConfig(id, data) | 
					
						
							| 
									
										
										
										
											2024-12-03 13:56:40 +08:00
										 |  |  |   const handleAddOperation = () => { | 
					
						
							|  |  |  |     const newList = handleAddOperationItem(inputs.items || []) | 
					
						
							|  |  |  |     handleOperationListChanges(newList) | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |     <div className='flex flex-col items-start self-stretch py-2'> | 
					
						
							|  |  |  |       <div className='flex w-full flex-col items-start justify-center gap-1 self-stretch px-4 py-2'> | 
					
						
							| 
									
										
										
										
											2024-12-03 13:56:40 +08:00
										 |  |  |         <div className='flex items-start gap-2 self-stretch'> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |           <div className='system-sm-semibold-uppercase flex grow flex-col items-start justify-center text-text-secondary'>{t(`${i18nPrefix}.variables`)}</div> | 
					
						
							| 
									
										
										
										
											2024-12-03 13:56:40 +08:00
										 |  |  |           <ActionButton onClick={handleAddOperation}> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |             <RiAddLine className='h-4 w-4 shrink-0 text-text-tertiary' /> | 
					
						
							| 
									
										
										
										
											2024-12-03 13:56:40 +08:00
										 |  |  |           </ActionButton> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |         <VarList | 
					
						
							|  |  |  |           readonly={readOnly} | 
					
						
							|  |  |  |           nodeId={id} | 
					
						
							|  |  |  |           list={inputs.items || []} | 
					
						
							|  |  |  |           onChange={(newList) => { | 
					
						
							|  |  |  |             handleOperationListChanges(newList) | 
					
						
							|  |  |  |           }} | 
					
						
							|  |  |  |           filterVar={filterAssignedVar} | 
					
						
							|  |  |  |           filterToAssignedVar={filterToAssignedVar} | 
					
						
							|  |  |  |           getAssignedVarType={getAssignedVarType} | 
					
						
							|  |  |  |           writeModeTypes={writeModeTypes} | 
					
						
							|  |  |  |           writeModeTypesArr={writeModeTypesArr} | 
					
						
							|  |  |  |           writeModeTypesNum={writeModeTypesNum} | 
					
						
							|  |  |  |           getToAssignedVarType={getToAssignedVarType} | 
					
						
							|  |  |  |         /> | 
					
						
							| 
									
										
										
										
											2024-08-13 14:44:10 +08:00
										 |  |  |       </div> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default React.memo(Panel) |