-
Notifications
You must be signed in to change notification settings - Fork 12
feat(entities-plugins): add branch node support for datakit flow editor #2544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… layout calculations
…e branch change handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces branch node support for the Datakit flow editor, enabling conditional execution through "then/else" logic. The implementation adds comprehensive schema definitions, UI components, state management, and visual elements for branch nodes.
- Adds branch node schema with
then
/else
fields and visual components for the flow editor - Implements branch group management with membership validation and cycle detection
- Creates specialized form components and layout composables for branch node interaction
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
packages/entities/entities-plugins/src/locales/en.json | Updates localization strings for branch nodes and conflict resolution |
packages/entities/entities-plugins/src/components/free-form/Datakit/types.ts | Extends type definitions with branch-related interfaces and group management types |
packages/entities/entities-plugins/src/components/free-form/Datakit/schema/strict.ts | Adds BranchNode schema and branch name enum definitions |
packages/entities/entities-plugins/src/components/free-form/Datakit/schema/compat.ts | Implements compatible branch node schema with loose validation |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/store.ts | Integrates branch group management into the main editor store |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/init.ts | Handles initialization of branch groups from configuration data |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/history.ts | Exports TaggedHistory type for branch group manager |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/helpers.ts | Adds utility functions for branch group management and ID generation |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/flow.ts | Integrates branch layout composable and updates flow rendering logic |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/branch-group-manager.ts | Creates comprehensive branch group management system |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/node.ts | Updates node metadata to use centralized visual system |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/node-visual.ts | Centralizes visual styling definitions for all node types |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/NodePropertiesPanel.vue | Registers branch form component in the properties panel |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/NodePanelItem.vue | Updates panel item to use centralized visual styling |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/NodeBadge.vue | Refactors badge component to use centralized visual system |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/GroupNode.vue | Creates new group node component for branch visualization |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/FlowNode.vue | Adds branch handle rendering support to flow nodes |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node-forms/NodeFormCall.vue | Removes trailing whitespace |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node-forms/NodeFormBranch.vue | Creates specialized form component for branch node configuration |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node-forms/InputsField.vue | Conditionally renders input field sections |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/composables/useBranchNodeForm.ts | Implements branch-specific form logic with conflict resolution |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/composables/useBranchLayout.ts | Creates comprehensive branch layout management system |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/FlowEditor.vue | Updates editor to handle new UI data structure |
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/FlowCanvas.vue | Registers group node component and handles group node interactions |
packages/entities/entities-plugins/src/components/free-form/Datakit/constants.ts | Adds constants for branch group layout and z-index management |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...ies/entities-plugins/src/components/free-form/Datakit/flow-editor/node-forms/InputsField.vue
Show resolved
Hide resolved
...ies/entities-plugins/src/components/free-form/Datakit/flow-editor/node-forms/InputsField.vue
Show resolved
Hide resolved
...ages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/helpers.ts
Outdated
Show resolved
Hide resolved
...s/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/node-visual.ts
Show resolved
Hide resolved
...tities-plugins/src/components/free-form/Datakit/flow-editor/composables/useBranchNodeForm.ts
Outdated
Show resolved
Hide resolved
...tities-plugins/src/components/free-form/Datakit/flow-editor/composables/useBranchNodeForm.ts
Show resolved
Hide resolved
...tities-plugins/src/components/free-form/Datakit/flow-editor/composables/useBranchNodeForm.ts
Outdated
Show resolved
Hide resolved
...ies/entities-plugins/src/components/free-form/Datakit/flow-editor/composables/useNodeForm.ts
Outdated
Show resolved
Hide resolved
q: Should we guard this change by M2 FF? |
…to prevent unnecessary updates
…and remove unused constants
3921c13
to
7f9b4ff
Compare
Preview components from this PR in consuming applicationIn consuming application project install preview versions of shared packages generated by this PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the PR generally looks good for this new node type.
export interface NodeDimensions { | ||
width: number | ||
height: number | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Because we are already using XYPosition
from @vue-flow/core
, maybe we can also try importing Dimensions
from there.
// @vue-flow/core
export interface Dimensions {
width: number
height: number
}
Summary
KM-1668
Schema & types
schema/strict.ts
,schema/compat.ts
,types.ts
BranchName
enum, and branch key constants allow configs to expressthen/else
targets.DatakitUIData
now carriesgroups
, with supportingGroupId
,GroupInstance
, and helper types used downstream.Editor state
store/branch-group-manager.ts
,store/store.ts
,store/flow.ts
createBranchGroupManager
encapsulates branch membership validation, conflict resolution, cycle checks, and history commitments.groupPositions
, and serializes/deserializesDatakitUIData.groups
.useBranchLayout
) to emit group nodes and edges, while node removal/rename hooks clean up memberships.Branch layout
composables/useBranchLayout.ts
,FlowCanvas.vue
,node/GroupNode.vue
,FlowNode.vue
useBranchLayout
projects store state into Vue Flow: computes group nodes, branch edges, z-index, and responds to drag interactions.FlowCanvas
registers the newGroupNode
typeFlowNode
renders read-only branch handlesBranch form
node-forms/NodeFormBranch.vue
,composables/useBranchNodeForm.ts
useBranchNodeForm
(branched from generic node form) handles multiselect defaults, membership updates, conflict prompts, and toast errorsNodeFormBranch
delegates to the composable, usingEnumField
forthen/else
selectionsVisual
node/node-visual.ts
,node/NodeBadge.vue
,node/NodePanelItem.vue