-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangqi
committed
Jan 6, 2024
1 parent
3c29e15
commit b6a4da0
Showing
4 changed files
with
160 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
scaleph-ui-react2/src/pages/Project/Workspace/Artifact/DI/DiJobFlow/Dag/menubar/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from 'react'; | ||
import {Button, Space, Tooltip} from 'antd'; | ||
import {CalculatorOutlined, EyeOutlined, SaveOutlined} from '@ant-design/icons'; | ||
import {useIntl} from "@umijs/max"; | ||
import type {Edge} from '@antv/xflow'; | ||
import {useGraphEvent, useGraphInstance, useGraphStore,} from '@antv/xflow'; | ||
import {Menubar} from "@antv/x6-react-components"; | ||
|
||
const CustomMenubar: React.FC = () => { | ||
const intl = useIntl(); | ||
const graph = useGraphInstance(); | ||
const nodes = useGraphStore((state) => state.nodes); | ||
const updateEdge = useGraphStore((state) => state.updateEdge); | ||
const removeNodes = useGraphStore((state) => state.removeNodes); | ||
|
||
useGraphEvent('node:change:data', ({node}) => { | ||
if (graph) { | ||
const edges = graph.getIncomingEdges(node); | ||
const {status} = node.data; | ||
edges?.forEach((edge: Edge) => { | ||
if (status === 'running') { | ||
updateEdge(edge.id, { | ||
animated: true, | ||
}); | ||
} else { | ||
updateEdge(edge.id, { | ||
animated: false, | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
const onPreview = () => { | ||
console.log('onPreview', graph) | ||
}; | ||
|
||
const onDebug = () => { | ||
console.log('onDebug', graph) | ||
}; | ||
|
||
const onSave = () => { | ||
console.log('onSave', graph) | ||
}; | ||
|
||
return ( | ||
<Menubar extra={<Space> | ||
<Tooltip title={intl.formatMessage({id: 'pages.project.di.flow.dag.debug'})}> | ||
<Button | ||
size="small" | ||
icon={<CalculatorOutlined/>} | ||
onClick={onDebug} | ||
/> | ||
</Tooltip> | ||
<Tooltip title={intl.formatMessage({id: 'pages.project.di.flow.dag.preview'})}> | ||
<Button | ||
size="small" | ||
icon={<EyeOutlined/>} | ||
onClick={onPreview} | ||
/> | ||
</Tooltip> | ||
<Tooltip title={intl.formatMessage({id: 'pages.project.di.flow.dag.save'})}> | ||
<Button | ||
size="small" | ||
icon={<SaveOutlined/>} | ||
onClick={onSave} | ||
/> | ||
</Tooltip> | ||
|
||
</Space>}/> | ||
); | ||
}; | ||
|
||
export {CustomMenubar}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters