diff --git a/src/components/DependencyGraph.tsx b/src/components/DependencyGraph.tsx index afc50a65..6ca77669 100644 --- a/src/components/DependencyGraph.tsx +++ b/src/components/DependencyGraph.tsx @@ -59,6 +59,7 @@ import { DropdownMenuTrigger, } from "./ui/dropdown-menu"; import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover"; +import { Move } from "lucide-react"; // Types for the context menu type MenuType = "edge" | "node" | null; @@ -181,13 +182,21 @@ const DependencyGraph: FunctionComponent<{ childrenLimitMap, previousNodesRef.current, handleExpansionToggle, + enableContextMenu, ); previousNodesRef.current = nodes; // get the root node - we use it for the initial position of the viewport const rootNode = nodes.find((n) => n.data.label === graph.name)!; return [nodes, edges, rootNode]; - }, [graph, vulns, expandedNodes, childrenLimitMap, handleExpansionToggle]); + }, [ + graph, + vulns, + expandedNodes, + childrenLimitMap, + handleExpansionToggle, + enableContextMenu, + ]); const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges); @@ -757,6 +766,17 @@ const DependencyGraph: FunctionComponent<{ )} +
+ + + You can interact with this graph + +
+ {/* Todo: Find a better way to disable edge cursor pointer when context menu + is disabled. This is a bit hacky but works for now. Issue 1708 */} + {!enableContextMenu && ( + + )} void; }; id: string; @@ -98,7 +99,10 @@ export const DependencyGraphNode: FunctionComponent< width: props.data.nodeWidth, }} className={classNames( - "relative border-2 rounded-lg p-3 text-xs text-card-foreground bg-card transition-all cursor-pointer active:cursor-grabbing", + "relative border-2 rounded-lg p-3 text-xs text-card-foreground bg-card transition-all", + props.data.enableContextMenu + ? "cursor-pointer active:cursor-grabbing" + : "cursor-grab active:cursor-grabbing", props.data.vuln ? props.data.vuln.every((v) => v.state === "falsePositive") ? "border-gray-500/50 shadow-md" diff --git a/src/components/SeverityCard.tsx b/src/components/SeverityCard.tsx index d7735dbd..e7fa2707 100644 --- a/src/components/SeverityCard.tsx +++ b/src/components/SeverityCard.tsx @@ -89,7 +89,7 @@ const SeverityCard: FunctionComponent = ({ `/${activeOrg.slug}/projects/${project.slug}/assets/${asset?.slug}/refs/${activeAssetVersion?.slug}/dependency-risks?` + new URLSearchParams({ ...applySQLFilter(variant), - ...(artifactName && {artifact: artifactName}), + ...(artifactName && { artifact: artifactName }), }) } className="text-xs !text-muted-foreground" diff --git a/src/utils/dependencyGraphHelpers.ts b/src/utils/dependencyGraphHelpers.ts index a397376e..3aca09c6 100644 --- a/src/utils/dependencyGraphHelpers.ts +++ b/src/utils/dependencyGraphHelpers.ts @@ -219,6 +219,7 @@ export const getLayoutedElements = ( childrenLimitMap: Map, previousNodes: Array = [], onExpansionToggle?: (nodeId: string) => void, + enableContextMenu?: boolean, ): [ Array<{ id: string; @@ -332,6 +333,7 @@ export const getLayoutedElements = ( hasMore: childCount > shownCount, isLoadMoreNode, parentId, + enableContextMenu, remainingCount: parentId ? (childCountMap.get(parentId) || 0) - (childrenLimitMap.get(parentId) || INITIAL_CHILDREN_TO_SHOW)