Commit 19b9efe3 authored by Michael Vrána's avatar Michael Vrána

Clear algorithm canvas

parent 30f9a8e8
Pipeline #80134 passed with stages
in 4 minutes and 45 seconds
......@@ -22,7 +22,7 @@ import ElementButton from '../../Toolbar/ElementButton'
import { Actions } from '../../../reducers'
const { toggleGrid, setCursorMode, zoom } = algorithmCanvasActions
const { importGraph } = algorithmDataActions
const { importGraph, clear } = algorithmDataActions
const { undoAlgorithm, redoAlgorithm } = Actions
const useStyles = makeStyles((theme) => ({
......@@ -124,6 +124,7 @@ export const AlgorithmCanvasToolbar = () => {
const handleUndo = useCallback(() => dispatch(undoAlgorithm()), [dispatch])
const handleRedo = useCallback(() => dispatch(redoAlgorithm()), [dispatch])
const handleClear = useCallback(() => dispatch(clear()), [dispatch])
return (
<div className={classes.root}>
......@@ -141,12 +142,17 @@ export const AlgorithmCanvasToolbar = () => {
Icon={UndoIcon}
label="Undo"
onAction={handleUndo}
></ElementButton>
/>
<ElementButton
Icon={RedoIcon}
label="Redo"
onAction={handleRedo}
></ElementButton>
/>
<ElementButton
Icon={CloseIcon}
label="Clear canvas"
onAction={handleClear}
/>
</Paper>
<AlgorithmImportExportToolbar
onExport={handleExport}
......
......@@ -46,7 +46,9 @@ export const algorithmDataActions = {
deleteEdge: (id: string) => createAction('deleteEdge', id),
importGraph: (data: Omit<AlgorithmGraph, 'outputValues'>) =>
createAction('importGraph', data)
createAction('importGraph', data),
clear: () => createAction('clear')
}
export type AlgorithmDataActions = ActionsUnion<typeof algorithmDataActions>
......@@ -330,6 +332,9 @@ export const algorithmReducer = (
incompatibleEdges
}
}
case 'clear' : {
return initialAlgorithmState
}
default: {
return state
}
......
......@@ -118,7 +118,8 @@ const reducer = combineReducers<ReduxState>({
'addEdge',
'positionNode',
'deleteNode',
'deleteEdge'
'deleteEdge',
'clear'
].includes(action.type)
}),
stateUI: stateUIReducer,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment