email-node.tsx


Overview

The email-node.tsx file defines a React functional component for rendering an interactive "Email Node" UI element within a flowchart or workflow editor interface. This component visually represents an email action node, displaying email configuration information such as SMTP server details and sender address. It supports interactive connection points ("handles") for linking this node with others in the flow, and allows users to toggle the visibility of additional details including an example JSON input schema.

This file is designed to be used with the @xyflow/react library, which provides node and handle components for building flow-based editors, and integrates UI components from antd along with CSS modules for styling. The component is memoized with React's memo for performance optimization.


Component: InnerEmailNode

Description

InnerEmailNode is the main React functional component in this file. It renders the node UI for an email action in a flow editor. It shows basic SMTP configuration details, and when clicked, expands to show an example JSON input format that this node expects. The component supports selectable styling and connection handles on its left and right edges for linking nodes.


Props

InnerEmailNode receives props typed as NodeProps from @xyflow/react and a custom interface IEmailNode. The main props used are:

Prop

Type

Description

Default

id

string

Unique identifier for the node instance.

Required

data

IEmailNode

Data object containing node-specific information (name, label, form).

Required

isConnectable

boolean

Flag indicating if the node's handles should allow connections.

true

selected

boolean

Indicates if the node is currently selected in the UI.

false


Internal State

State

Type

Description

showDetails

boolean

Controls whether the detailed JSON input example is shown.


JSX Structure


Usage Example

import { EmailNode } from './email-node';

const exampleNodeData = {
  name: "Send Email",
  label: "Email Action",
  form: {
    smtp_server: "smtp.example.com",
    smtp_port: 587,
    email: "[email protected]"
  }
};

<EmailNode
  id="node-123"
  data={exampleNodeData}
  isConnectable={true}
  selected={false}
/>

Return Value

The component returns a JSX element representing the styled email node UI.


Implementation Details


Exported Components

Export Name

Description

InnerEmailNode

The email node React component.

EmailNode

Memoized version of InnerEmailNode for performance.


Interaction with Other Parts of the System

This component would be used as part of a larger flowchart or workflow editor interface, where users create and connect nodes to define automated email actions.


Mermaid Diagram

classDiagram
    class InnerEmailNode {
        +id: string
        +data: IEmailNode
        +isConnectable: boolean
        +selected: boolean
        +showDetails: boolean (state)
        +() : JSX.Element
    }
    class EmailNode {
        +InnerEmailNode: React.MemoExoticComponent
    }
    InnerEmailNode <|-- EmailNode
    InnerEmailNode : +setShowDetails(boolean)
    InnerEmailNode : +Handle (left & right)
    InnerEmailNode : +NodeHeader(id, name, label)
    InnerEmailNode : +Flex (container for layout)

Summary

email-node.tsx provides a reusable, styled React component to visually represent an email action node in a flow editor interface. It efficiently handles user interaction to show/hide detailed configuration data and supports connections to other nodes through interactive handles. Memoization and modular design make it performant and easy to maintain or extend.