panel.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { type FC } from 'react'
  2. import React from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import useConfig from './use-config'
  5. import type { EndNodeType } from './types'
  6. import VarList from '@/app/components/workflow/nodes/_base/components/variable/var-list'
  7. import Field from '@/app/components/workflow/nodes/_base/components/field'
  8. import AddButton from '@/app/components/base/button/add-button'
  9. import { type NodePanelProps } from '@/app/components/workflow/types'
  10. const i18nPrefix = 'workflow.nodes.end'
  11. const Panel: FC<NodePanelProps<EndNodeType>> = ({
  12. id,
  13. data,
  14. }) => {
  15. const { t } = useTranslation()
  16. const {
  17. readOnly,
  18. inputs,
  19. handleVarListChange,
  20. handleAddVariable,
  21. } = useConfig(id, data)
  22. const outputs = inputs.outputs
  23. return (
  24. <div className='mt-2'>
  25. <div className='px-4 pb-4 space-y-4'>
  26. <Field
  27. title={t(`${i18nPrefix}.output.variable`)}
  28. operations={
  29. !readOnly ? <AddButton onClick={handleAddVariable} /> : undefined
  30. }
  31. >
  32. <VarList
  33. nodeId={id}
  34. readonly={readOnly}
  35. list={outputs}
  36. onChange={handleVarListChange}
  37. />
  38. </Field>
  39. </div>
  40. </div>
  41. )
  42. }
  43. export default React.memo(Panel)