Skip to content

Commit

Permalink
Support enabling nodes (#2800)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Apr 18, 2024
1 parent 5b0d59e commit 78f5d90
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/renderer/hooks/useNodesMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChevronRightIcon, CloseIcon, CopyIcon, DeleteIcon } from '@chakra-ui/icons';
import { HStack, MenuDivider, MenuItem, MenuList, Spacer, Text } from '@chakra-ui/react';
import { useRef } from 'react';
import { MdPlayArrow, MdPlayDisabled } from 'react-icons/md';
import { Node, useReactFlow } from 'reactflow';
import { useContext } from 'use-context-selector';
import { EdgeData, NodeData } from '../../common/common-types';
Expand All @@ -11,7 +12,7 @@ import { UseContextMenu, useContextMenu } from './useContextMenu';
import './useNodeMenu.scss';

export const useNodesMenu = (nodes: Node<NodeData>[]): UseContextMenu => {
const { removeNodesById, resetInputs, resetConnections, duplicateNodes } =
const { removeNodesById, resetInputs, resetConnections, duplicateNodes, setNodeDisabled } =
useContext(GlobalContext);

const nodeIds = nodes.map((n) => n.id);
Expand Down Expand Up @@ -88,6 +89,29 @@ export const useNodesMenu = (nodes: Node<NodeData>[]): UseContextMenu => {
</MenuList>
</div>
<MenuDivider />
<MenuItem
icon={<MdPlayArrow />}
isDisabled={nodes.every((n) => !n.data.isDisabled)}
onClick={() => {
for (const id of nodeIds) {
setNodeDisabled(id, false);
}
}}
>
Enable All
</MenuItem>
<MenuItem
icon={<MdPlayDisabled />}
isDisabled={nodes.every((n) => n.data.isDisabled)}
onClick={() => {
for (const id of nodeIds) {
setNodeDisabled(id, true);
}
}}
>
Disable All
</MenuItem>
<MenuDivider />
<MenuItem
icon={<DeleteIcon />}
onClick={() => {
Expand Down

0 comments on commit 78f5d90

Please sign in to comment.