You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

invoke-node.tsx 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { useTheme } from '@/components/theme-provider';
  2. import { IInvokeNode } from '@/interfaces/database/flow';
  3. import { Handle, NodeProps, Position } from '@xyflow/react';
  4. import { Flex } from 'antd';
  5. import classNames from 'classnames';
  6. import { get } from 'lodash';
  7. import { memo } from 'react';
  8. import { useTranslation } from 'react-i18next';
  9. import { LeftHandleStyle, RightHandleStyle } from './handle-icon';
  10. import styles from './index.less';
  11. import NodeHeader from './node-header';
  12. function InnerInvokeNode({
  13. id,
  14. data,
  15. isConnectable = true,
  16. selected,
  17. }: NodeProps<IInvokeNode>) {
  18. const { t } = useTranslation();
  19. const { theme } = useTheme();
  20. const url = get(data, 'form.url');
  21. return (
  22. <section
  23. className={classNames(
  24. styles.ragNode,
  25. theme === 'dark' ? styles.dark : '',
  26. {
  27. [styles.selectedNode]: selected,
  28. },
  29. )}
  30. >
  31. <Handle
  32. id="c"
  33. type="source"
  34. position={Position.Left}
  35. isConnectable={isConnectable}
  36. className={styles.handle}
  37. style={LeftHandleStyle}
  38. ></Handle>
  39. <Handle
  40. type="source"
  41. position={Position.Right}
  42. isConnectable={isConnectable}
  43. className={styles.handle}
  44. id="b"
  45. style={RightHandleStyle}
  46. ></Handle>
  47. <NodeHeader
  48. id={id}
  49. name={data.name}
  50. label={data.label}
  51. className={styles.nodeHeader}
  52. ></NodeHeader>
  53. <Flex vertical>
  54. <div>{t('flow.url')}</div>
  55. <div className={styles.nodeText}>{url}</div>
  56. </Flex>
  57. </section>
  58. );
  59. }
  60. export const InvokeNode = memo(InnerInvokeNode);