diff --git a/assets/icons/lock.svg b/assets/icons/lock.svg new file mode 100644 index 00000000..72c66dc7 --- /dev/null +++ b/assets/icons/lock.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/unlock.svg b/assets/icons/unlock.svg new file mode 100644 index 00000000..22ed8018 --- /dev/null +++ b/assets/icons/unlock.svg @@ -0,0 +1 @@ + diff --git a/cypress/integration/flow/empty.spec.js b/cypress/integration/flow/empty.spec.js index 54f514a0..8fffb924 100644 --- a/cypress/integration/flow/empty.spec.js +++ b/cypress/integration/flow/empty.spec.js @@ -32,6 +32,14 @@ describe('Empty Flow Rendering', () => { cy.get('.react-flow__controls-fitview').click(); }); + it('uses lock view control', () => { + cy.get('.react-flow__controls-unlocked').click(); + cy.get('.react-flow__controls-unlocked').should('not.exist'); + + cy.get('.react-flow__controls-locked').click(); + cy.get('.react-flow__controls-locked').should('not.exist'); + }) + it('renders an empty mini map', () => { cy.get('.react-flow__minimap'); cy.get('.react-flow__minimap-node').should('not.exist'); diff --git a/src/plugins/Controls/index.tsx b/src/plugins/Controls/index.tsx index e2c38712..79519e43 100644 --- a/src/plugins/Controls/index.tsx +++ b/src/plugins/Controls/index.tsx @@ -2,9 +2,13 @@ import React, { CSSProperties } from 'react'; import classnames from 'classnames'; import { fitView, zoomIn, zoomOut } from '../../utils/graph'; +import { useStoreState, useStoreActions } from '../../store/hooks'; + import PlusIcon from '../../../assets/icons/plus.svg'; import MinusIcon from '../../../assets/icons/minus.svg'; import FitviewIcon from '../../../assets/icons/fitview.svg'; +import LockIcon from '../../../assets/icons/lock.svg'; +import UnlockIcon from '../../../assets/icons/unlock.svg'; const baseStyle: CSSProperties = { position: 'absolute', @@ -18,6 +22,9 @@ interface ControlProps extends React.HTMLAttributes {} export default ({ style, className }: ControlProps) => { const mapClasses: string = classnames('react-flow__controls', className); + const setInteractive = useStoreActions(actions => actions.setInteractive); + const { isInteractive } = useStoreState(({ isInteractive }) => ({ isInteractive })); + return (
{ >
+
setInteractive(!isInteractive)} + > + { isInteractive ? : } +
); };