Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
198d3e41
Commit
198d3e41
authored
3 weeks ago
by
ali asaria
Browse files
Options
Downloads
Patches
Plain Diff
auto zoom to the number of nodes that are on the canvas
parent
40a63dca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/renderer/components/Experiment/Workflows/WorkflowCanvas.tsx
+37
-3
37 additions, 3 deletions
...nderer/components/Experiment/Workflows/WorkflowCanvas.tsx
with
37 additions
and
3 deletions
src/renderer/components/Experiment/Workflows/WorkflowCanvas.tsx
+
37
−
3
View file @
198d3e41
import
{
Background
,
ControlButton
,
Controls
,
ReactFlow
}
from
'
@xyflow/react
'
;
import
{
Background
,
ControlButton
,
Controls
,
ReactFlow
,
ReactFlowProvider
,
useReactFlow
,
}
from
'
@xyflow/react
'
;
import
{
PlusCircleIcon
}
from
'
lucide-react
'
;
import
{
PlusCircleIcon
}
from
'
lucide-react
'
;
import
React
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
function
generateNodes
(
workflow
:
any
)
{
function
generateNodes
(
workflow
:
any
)
{
let
out
:
any
[]
=
[];
let
out
:
any
[]
=
[];
...
@@ -47,12 +54,31 @@ function generateEdges(workflow: any) {
...
@@ -47,12 +54,31 @@ function generateEdges(workflow: any) {
return
out
;
return
out
;
}
}
export
default
function
WorkflowCanvas
({
selectedWorkflow
})
{
const
Flow
=
({
selectedWorkflow
})
=>
{
const
reactFlowInstance
=
useReactFlow
();
// Use fitView after the component mounts
useEffect
(()
=>
{
// Wait a moment to ensure the flow is rendered before fitting
const
timer
=
setTimeout
(()
=>
{
reactFlowInstance
.
fitView
({
includeHiddenNodes
:
false
,
// Don't include hidden nodes
minZoom
:
0.5
,
// Set minimum zoom level
maxZoom
:
10
,
// Set maximum zoom level
});
},
100
);
return
()
=>
clearTimeout
(
timer
);
},
[
reactFlowInstance
,
selectedWorkflow
]);
return
(
return
(
<
ReactFlow
<
ReactFlow
nodes
=
{
generateNodes
(
selectedWorkflow
)
}
nodes
=
{
generateNodes
(
selectedWorkflow
)
}
edges
=
{
generateEdges
(
selectedWorkflow
)
}
edges
=
{
generateEdges
(
selectedWorkflow
)
}
fitView
fitView
zoomOnScroll
=
{
false
}
zoomOnPinch
=
{
false
}
zoomOnDoubleClick
=
{
false
}
panOnScroll
=
{
false
}
style
=
{
{
backgroundColor
:
'
#F7F9FB
'
}
}
style
=
{
{
backgroundColor
:
'
#F7F9FB
'
}
}
>
>
<
Background
color
=
"#96ADE9"
/>
<
Background
color
=
"#96ADE9"
/>
...
@@ -72,4 +98,12 @@ export default function WorkflowCanvas({ selectedWorkflow }) {
...
@@ -72,4 +98,12 @@ export default function WorkflowCanvas({ selectedWorkflow }) {
/>
/>
</
ReactFlow
>
</
ReactFlow
>
);
);
};
export
default
function
WorkflowCanvas
({
selectedWorkflow
})
{
return
(
<
ReactFlowProvider
>
<
Flow
selectedWorkflow
=
{
selectedWorkflow
}
/>
</
ReactFlowProvider
>
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment