Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
b718e66b
Commit
b718e66b
authored
Mar 13, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: drag stop & click
parent
a55a7603
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
16 deletions
+12
-16
use-nodes-interactions.ts
web/app/components/workflow/hooks/use-nodes-interactions.ts
+12
-12
store.ts
web/app/components/workflow/store.ts
+0
-4
No files found.
web/app/components/workflow/hooks/use-nodes-interactions.ts
View file @
b718e66b
import
{
useCallback
}
from
'react'
import
{
useCallback
,
useRef
}
from
'react'
import
produce
from
'immer'
import
produce
from
'immer'
import
type
{
import
type
{
NodeDragHandler
,
NodeDragHandler
,
...
@@ -29,17 +29,17 @@ export const useNodesInteractions = () => {
...
@@ -29,17 +29,17 @@ export const useNodesInteractions = () => {
const
store
=
useStoreApi
()
const
store
=
useStoreApi
()
const
nodesInitialData
=
useNodesInitialData
()
const
nodesInitialData
=
useNodesInitialData
()
const
{
handleSyncWorkflowDraft
}
=
useNodesSyncDraft
()
const
{
handleSyncWorkflowDraft
}
=
useNodesSyncDraft
()
const
dragNodeStartPosition
=
useRef
({
x
:
0
,
y
:
0
}
as
{
x
:
number
;
y
:
number
})
const
handleNodeDragStart
=
useCallback
<
NodeDragHandler
>
(()
=>
{
const
handleNodeDragStart
=
useCallback
<
NodeDragHandler
>
((
_
,
node
)
=>
{
const
{
const
{
runningStatus
,
runningStatus
,
setIsDragging
,
}
=
useStore
.
getState
()
}
=
useStore
.
getState
()
if
(
runningStatus
)
if
(
runningStatus
)
return
return
setIsDragging
(
true
)
dragNodeStartPosition
.
current
=
{
x
:
node
.
position
.
x
,
y
:
node
.
position
.
y
}
},
[])
},
[])
const
handleNodeDrag
=
useCallback
<
NodeDragHandler
>
((
e
,
node
:
Node
)
=>
{
const
handleNodeDrag
=
useCallback
<
NodeDragHandler
>
((
e
,
node
:
Node
)
=>
{
...
@@ -147,10 +147,9 @@ export const useNodesInteractions = () => {
...
@@ -147,10 +147,9 @@ export const useNodesInteractions = () => {
setNodes
(
newNodes
)
setNodes
(
newNodes
)
},
[
store
])
},
[
store
])
const
handleNodeDragStop
=
useCallback
<
NodeDragHandler
>
(()
=>
{
const
handleNodeDragStop
=
useCallback
<
NodeDragHandler
>
((
_
,
node
)
=>
{
const
{
const
{
runningStatus
,
runningStatus
,
setIsDragging
,
setHelpLineHorizontal
,
setHelpLineHorizontal
,
setHelpLineVertical
,
setHelpLineVertical
,
}
=
useStore
.
getState
()
}
=
useStore
.
getState
()
...
@@ -158,10 +157,12 @@ export const useNodesInteractions = () => {
...
@@ -158,10 +157,12 @@ export const useNodesInteractions = () => {
if
(
runningStatus
)
if
(
runningStatus
)
return
return
setIsDragging
(
false
)
const
{
x
,
y
}
=
dragNodeStartPosition
.
current
setHelpLineHorizontal
()
if
(
!
(
x
===
node
.
position
.
x
&&
y
===
node
.
position
.
y
))
{
setHelpLineVertical
()
setHelpLineHorizontal
()
handleSyncWorkflowDraft
()
setHelpLineVertical
()
handleSyncWorkflowDraft
()
}
},
[
handleSyncWorkflowDraft
])
},
[
handleSyncWorkflowDraft
])
const
handleNodeEnter
=
useCallback
<
NodeMouseHandler
>
((
_
,
node
)
=>
{
const
handleNodeEnter
=
useCallback
<
NodeMouseHandler
>
((
_
,
node
)
=>
{
...
@@ -236,10 +237,9 @@ export const useNodesInteractions = () => {
...
@@ -236,10 +237,9 @@ export const useNodesInteractions = () => {
const
handleNodeClick
=
useCallback
<
NodeMouseHandler
>
((
_
,
node
)
=>
{
const
handleNodeClick
=
useCallback
<
NodeMouseHandler
>
((
_
,
node
)
=>
{
const
{
const
{
runningStatus
,
runningStatus
,
isDragging
,
}
=
useStore
.
getState
()
}
=
useStore
.
getState
()
if
(
runningStatus
||
isDragging
)
if
(
runningStatus
)
return
return
handleNodeSelect
(
node
.
id
)
handleNodeSelect
(
node
.
id
)
...
...
web/app/components/workflow/store.ts
View file @
b718e66b
...
@@ -18,7 +18,6 @@ type State = {
...
@@ -18,7 +18,6 @@ type State = {
workflowRunId
:
string
workflowRunId
:
string
showRunHistory
:
boolean
showRunHistory
:
boolean
showFeaturesPanel
:
boolean
showFeaturesPanel
:
boolean
isDragging
:
boolean
helpLineHorizontal
?:
HelpLineHorizontalPosition
helpLineHorizontal
?:
HelpLineHorizontalPosition
helpLineVertical
?:
HelpLineVerticalPosition
helpLineVertical
?:
HelpLineVerticalPosition
toolsets
:
CollectionWithExpanded
[]
toolsets
:
CollectionWithExpanded
[]
...
@@ -37,7 +36,6 @@ type Action = {
...
@@ -37,7 +36,6 @@ type Action = {
setWorkflowRunId
:
(
workflowRunId
:
string
)
=>
void
setWorkflowRunId
:
(
workflowRunId
:
string
)
=>
void
setShowRunHistory
:
(
showRunHistory
:
boolean
)
=>
void
setShowRunHistory
:
(
showRunHistory
:
boolean
)
=>
void
setShowFeaturesPanel
:
(
showFeaturesPanel
:
boolean
)
=>
void
setShowFeaturesPanel
:
(
showFeaturesPanel
:
boolean
)
=>
void
setIsDragging
:
(
isDragging
:
boolean
)
=>
void
setHelpLineHorizontal
:
(
helpLineHorizontal
?:
HelpLineHorizontalPosition
)
=>
void
setHelpLineHorizontal
:
(
helpLineHorizontal
?:
HelpLineHorizontalPosition
)
=>
void
setHelpLineVertical
:
(
helpLineVertical
?:
HelpLineVerticalPosition
)
=>
void
setHelpLineVertical
:
(
helpLineVertical
?:
HelpLineVerticalPosition
)
=>
void
setToolsets
:
(
toolsets
:
CollectionWithExpanded
[])
=>
void
setToolsets
:
(
toolsets
:
CollectionWithExpanded
[])
=>
void
...
@@ -62,8 +60,6 @@ export const useStore = create<State & Action>(set => ({
...
@@ -62,8 +60,6 @@ export const useStore = create<State & Action>(set => ({
setShowRunHistory
:
showRunHistory
=>
set
(()
=>
({
showRunHistory
})),
setShowRunHistory
:
showRunHistory
=>
set
(()
=>
({
showRunHistory
})),
showFeaturesPanel
:
false
,
showFeaturesPanel
:
false
,
setShowFeaturesPanel
:
showFeaturesPanel
=>
set
(()
=>
({
showFeaturesPanel
})),
setShowFeaturesPanel
:
showFeaturesPanel
=>
set
(()
=>
({
showFeaturesPanel
})),
isDragging
:
false
,
setIsDragging
:
isDragging
=>
set
(()
=>
({
isDragging
})),
helpLineHorizontal
:
undefined
,
helpLineHorizontal
:
undefined
,
setHelpLineHorizontal
:
helpLineHorizontal
=>
set
(()
=>
({
helpLineHorizontal
})),
setHelpLineHorizontal
:
helpLineHorizontal
=>
set
(()
=>
({
helpLineHorizontal
})),
helpLineVertical
:
undefined
,
helpLineVertical
:
undefined
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment