|
1 | | -import React, { memo } from 'react'; |
| 1 | +import React, { memo, useContext } from 'react'; |
2 | 2 | // import UndoRedo from '../header/undo-redo' |
3 | | -import ZoomInOut from './ZoomInOut'; |
4 | | -import UndoRedo from './UndoRedo'; |
5 | 3 | import Control from './Control'; |
| 4 | +import UndoRedo from './UndoRedo'; |
| 5 | +import ZoomInOut from './ZoomInOut'; |
6 | 6 |
|
7 | | -import './index.less'; |
8 | 7 | import { useTemporalStore } from '../hooks/useTemporalStore'; |
| 8 | +import { ConfigContext } from '../models/context'; |
| 9 | +import './index.less'; |
9 | 10 |
|
10 | 11 | export type OperatorProps = { |
11 | 12 | addNode: any; |
12 | 13 | xflowRef: any; |
13 | | -} |
| 14 | +}; |
14 | 15 |
|
15 | 16 | const Operator = ({ addNode, xflowRef }: OperatorProps) => { |
16 | 17 | const { undo, redo, pastStates, futureStates } = useTemporalStore(); |
| 18 | + const { globalConfig } = useContext(ConfigContext); |
| 19 | + const hideUndoRedoBtns = globalConfig?.controls?.hideUndoRedoBtns ?? false; |
| 20 | + |
17 | 21 | return ( |
18 | | - <div className='fai-reactflow-operator'> |
19 | | - <div className='operator-section'> |
| 22 | + <div className="fai-reactflow-operator"> |
| 23 | + <div className="operator-section"> |
20 | 24 | <ZoomInOut /> |
21 | | - <UndoRedo handleUndo={() => undo()} handleRedo={() => redo()} pastStates={pastStates} futureStates={futureStates} /> |
| 25 | + {!Boolean(hideUndoRedoBtns) && ( |
| 26 | + <UndoRedo |
| 27 | + handleUndo={() => undo()} |
| 28 | + handleRedo={() => redo()} |
| 29 | + pastStates={pastStates} |
| 30 | + futureStates={futureStates} |
| 31 | + /> |
| 32 | + )} |
22 | 33 | <Control addNode={addNode} xflowRef={xflowRef} /> |
23 | 34 | </div> |
24 | 35 | </div> |
25 | 36 | ); |
26 | | -} |
| 37 | +}; |
27 | 38 |
|
28 | | -export default memo(Operator) |
| 39 | +export default memo(Operator); |
0 commit comments