Add ContextProvider, Context and Hook #16#57
Add ContextProvider, Context and Hook #16#57ricardozanini merged 8 commits intoserverlessworkflow:mainfrom
Conversation
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR implements context-based state management for the Diagram Editor component by introducing a context provider pattern with a custom React hook. The implementation allows the editor to manage and access shared state (read-only mode and locale settings) throughout the component tree.
Changes:
- Created
DiagramEditorContextwith context definition and customuseDiagramEditorContexthook for accessing state - Implemented
DiagramContextProvidercomponent that initializes and synchronizes state with props, providing state update functions through context - Integrated the context provider into
DiagramEditorcomponent to wrap the diagram rendering - Added comprehensive unit tests covering context consumption, prop change reactivity, and render optimization
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/store/diagramEditorContext.ts |
Defines context type with state and update functions; exports hook for consuming context |
src/store/DiagramEditorContextProvider.tsx |
Implements provider component that manages state initialization and synchronization with parent props |
src/diagram-editor/DiagramEditor.tsx |
Integrates context provider to wrap diagram component and pass editor props through context |
tests/store/DiagramEditorContextProvider.test.tsx |
Comprehensive test suite verifying context consumption, prop reactivity, and re-render behavior |
src/react-flow/diagram/Diagram.tsx |
Minor whitespace cleanup (blank line removal) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/serverless-workflow-diagram-editor/src/store/diagramEditorContext.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContext.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Outdated
Show resolved
Hide resolved
|
Thanks for PR @handreyrc, just a couple of small comments |
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/serverless-workflow-diagram-editor/src/diagram-editor/DiagramEditor.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
There was a problem hiding this comment.
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Show resolved
Hide resolved
lornakelly
left a comment
There was a problem hiding this comment.
Thanks for the work Handrey, LGTM
fantonangeli
left a comment
There was a problem hiding this comment.
@handreyrc Thanks a lot for this PR I wrote a few suggestions.
Please check if they make sense
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Show resolved
Hide resolved
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
|
I think weare good to merge this PR if you approve it as well. Thanks! |
Closes #16
Summary
This PR sets up state management for the Diagram Editor component.
Changes