Skip to content

Set up React Flow and add a base Diagram component #10#47

Open
handreyrc wants to merge 2 commits intoserverlessworkflow:mainfrom
handreyrc:add-react-flow
Open

Set up React Flow and add a base Diagram component #10#47
handreyrc wants to merge 2 commits intoserverlessworkflow:mainfrom
handreyrc:add-react-flow

Conversation

@handreyrc
Copy link
Contributor

@handreyrc handreyrc commented Mar 25, 2026

Closes #10

Summary

This PR sets up react flow lib and introduces the Diagram component allowing to render, visualize and interact with a hardcoded sample workflow.

Changes

  • Added reacflow lib to the catalog.
  • Added Diagram component to contain and consume the react flow lib.
  • Upated DiagramEditor component to load the Diagram component.
  • Updated storybook to showcase the DiagramEditor component rendering a sample workflow.
  • Updated test setings and tests to work with react flow.
image

Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copilot AI review requested due to automatic review settings March 25, 2026 23:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Sets up React Flow (@xyflow/react) in the diagram editor package and introduces a baseline Diagram component so the editor can render and interact with a simple hardcoded node/edge workflow (as a wiring/smoke test for the diagram layer).

Changes:

  • Added @xyflow/react to the workspace catalog and the serverless-workflow-diagram-editor package dependencies.
  • Introduced src/react-flow/diagram/Diagram (with CSS) and updated DiagramEditor to render it.
  • Updated Storybook + Vitest setup/tests to accommodate React Flow rendering requirements (e.g., DOM mocks).

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds @xyflow/react to the central pnpm catalog.
pnpm-lock.yaml Locks @xyflow/react and its transitive deps; includes incidental lock updates.
packages/serverless-workflow-diagram-editor/package.json Adds @xyflow/react as a runtime dependency via catalog:.
packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.tsx New baseline React Flow diagram rendering + interactions.
packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.css Adds diagram container/background styling used by React Flow.
packages/serverless-workflow-diagram-editor/src/diagram-editor/DiagramEditor.tsx Replaces placeholder UI with Diagram embedding + (placeholder) imperative API.
packages/serverless-workflow-diagram-editor/stories/DiagramEditor.tsx Ensures Storybook story provides height for React Flow to render.
packages/serverless-workflow-diagram-editor/stories/DiagramEditor.stories.ts Updates story args to match the new DiagramEditor props.
packages/serverless-workflow-diagram-editor/tests/setupTests.ts Adds global DOM mocks (ResizeObserver/DOMMatrix/PointerEvent) for React Flow tests.
packages/serverless-workflow-diagram-editor/tests/react-flow/diagram/Diagram.test.tsx Adds a basic render smoke test for diagram node labels.
packages/serverless-workflow-diagram-editor/tests/diagram-editor/DiagramEditor.test.tsx Updates editor test to assert the diagram container renders.
packages/serverless-workflow-diagram-editor/tests/diagram-editor/DiagramEditor.story.test.tsx Updates story test to assert the diagram container renders.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: handreyrc <handrey.cunha@gmail.com>
(changes) => setEdges((edgesSnapshot) => RF.applyEdgeChanges(changes, edgesSnapshot)),
[],
);
const onConnect = React.useCallback<RF.OnConnect>(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this for MVP as it will be readonly?

args: {
isReadOnly: true,
content: "Sample Content",
locale: "EN",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should lowercase en here as thats the i18next standard

test("Render DiagramEditor Component", async () => {
const content = "Sample Content";
test("Renders react flow Diagram component", async () => {
const locale = "EN";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before if we can change to lowercase

Copy link
Member

@fantonangeli fantonangeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @handreyrc for your PR. I only have a few comments, but this PR already looks great


export const DiagramEditor = (props: DiagramEditorProps) => {
//TODO: Implement the actual component this is just a placeholder
export const DiagramEditor = ({ isReadOnly, locale, ref }: DiagramEditorProps) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because oxlint was only showing a warning but nothing was clearly shown in CI with an error, I would also change the root settings in line /.oxlintrc.json:6 to the following, so also arguments are ignored when they start with "_":

    "typescript/no-unused-vars": ["error", {"argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
Suggested change
export const DiagramEditor = ({ isReadOnly, locale, ref }: DiagramEditorProps) => {
// oxlint-disable-next-line no-unused-vars remove this after the real implementation
export const DiagramEditor = ({ isReadOnly, locale, ref }: DiagramEditorProps) => {

<SWDiagramEditor content={props.content} isReadOnly={props.isReadOnly} />
</>
<div style={{ height: "100vh" }}>
<SWDiagramEditor isReadOnly={props.isReadOnly} locale={props.locale} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename this with SWF and the import alias

Suggested change
<SWDiagramEditor isReadOnly={props.isReadOnly} locale={props.locale} />
<SWFDiagramEditor isReadOnly={props.isReadOnly} locale={props.locale} />

edges={edges}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onConnect={onConnect}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, I would implement something like this, to have disable the nodes connections when is read-only

Suggested change
onConnect={onConnect}
onConnect={isReadOnly ? undefined : onConnect}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set up React Flow and add a base Diagram component

4 participants