From d2d613bd4ea4617b013ccc574c14aa3b3b4fa6fc Mon Sep 17 00:00:00 2001 From: eepsita12 Date: Sat, 23 May 2026 19:21:14 +0530 Subject: [PATCH] WIP: select all context menu feature --- package.json | 3 +- .../controls/ExportControl/transformToCsv.ts | 6 +- .../src/modules/GraphViewer/GraphViewer.tsx | 169 ++++++++++-------- .../internalComponents/ContextMenu.tsx | 64 +++++++ 4 files changed, 161 insertions(+), 81 deletions(-) diff --git a/package.json b/package.json index 21034d690..7a573e64e 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,7 @@ "check:lint": "eslint --concurrency=auto", "format": "prettier --write .", "check:format": "prettier --check .", - "test": "vitest run", - "test:watch": "vitest", + "test": "vitest run", "test:watch": "vitest", "coverage": "vitest run --coverage", "check:types": "pnpm -r --include-workspace-root --parallel --stream run typecheck", "typecheck": "tsc --noEmit", diff --git a/packages/graph-explorer/src/components/Tabular/controls/ExportControl/transformToCsv.ts b/packages/graph-explorer/src/components/Tabular/controls/ExportControl/transformToCsv.ts index 2eba9c9c2..e61a5a49f 100644 --- a/packages/graph-explorer/src/components/Tabular/controls/ExportControl/transformToCsv.ts +++ b/packages/graph-explorer/src/components/Tabular/controls/ExportControl/transformToCsv.ts @@ -1,7 +1,5 @@ import { unparse } from "papaparse"; - import type { TabularColumnInstance } from "@/components/Tabular/helpers/tableInstanceToTabularInstance"; - import { LABELS } from "@/utils/constants"; export function transformToCsv( @@ -37,7 +35,9 @@ export function transformToCsv( }), ); - const headers = columns.map(col => col.definition?.label || col.instance.id); + const headers = columns.map( + col => col.definition?.label || col.instance.id, + ); return unparse([headers, ...csvRows], { header: false }); } diff --git a/packages/graph-explorer/src/modules/GraphViewer/GraphViewer.tsx b/packages/graph-explorer/src/modules/GraphViewer/GraphViewer.tsx index f5978abf7..600bfdeb1 100644 --- a/packages/graph-explorer/src/modules/GraphViewer/GraphViewer.tsx +++ b/packages/graph-explorer/src/modules/GraphViewer/GraphViewer.tsx @@ -154,83 +154,100 @@ function GraphViewerContent({ const isEmpty = !nodes.length && !edges.length; return ( -
- - - Graph View - - - - -
- - - - - - - - - - - - - - {isContextOpen && - renderContextLayer( -
- -
, - )} +
+ {}} + affectedNodesIds={[]} + affectedEdgesIds={[]} + /> +
+); - - - - -
- setLegendOpen(false)} /> -
-
-
- -
- ); + + // return ( + //
+ // + // + // Graph View + // + // + // + // + //
+ // + // + // + // + // + // + // + // + // + // + // + // + // + // {/* {isContextOpen && + // renderContextLayer( + //
+ // + //
, + // )} */} + // {}} + // affectedNodesIds={[]} + // affectedEdgesIds={[]} + // /> + + + // + // + // + // + //
+ // setLegendOpen(false)} /> + //
+ //
+ //
+ // + //
+ // ); } function Legend({ diff --git a/packages/graph-explorer/src/modules/GraphViewer/internalComponents/ContextMenu.tsx b/packages/graph-explorer/src/modules/GraphViewer/internalComponents/ContextMenu.tsx index c37d28246..2c8ca0b6a 100644 --- a/packages/graph-explorer/src/modules/GraphViewer/internalComponents/ContextMenu.tsx +++ b/packages/graph-explorer/src/modules/GraphViewer/internalComponents/ContextMenu.tsx @@ -46,6 +46,9 @@ import { cn } from "@/utils"; import { useGraphSelection } from "../useGraphSelection"; +import { useRenderedVertices, useRenderedEdges } from "@/core"; +import { getVertexIdFromRenderedVertexId, getEdgeIdFromRenderedEdgeId } from "@/core"; + type ContextMenuProps = { affectedNodesIds: VertexId[]; affectedEdgesIds: EdgeId[]; @@ -290,6 +293,9 @@ function MultipleEntitiesMenu({ } function NoTargetMenu() { + const vertices = useRenderedVertices(); + const edges = useRenderedEdges(); + const { onFitAllToCanvas, onCenterGraph, @@ -297,7 +303,41 @@ function NoTargetMenu() { onZoomIn, onZoomOut, } = useGraphGlobalActions(); + const clearGraph = useClearGraph(); + const { replaceGraphSelection } = useGraphSelection(); + + // 🔹 Select all nodes + const handleSelectAllNodes = () => { + replaceGraphSelection({ + vertices: vertices.map(v => + getVertexIdFromRenderedVertexId(v.data.id), + ), + edges: [], + }); + }; + + // 🔹 Select all edges + const handleSelectAllEdges = () => { + replaceGraphSelection({ + vertices: [], + edges: edges.map(e => + getEdgeIdFromRenderedEdgeId(e.data.id), + ), + }); + }; + + // 🔹 Select all nodes + edges + const handleSelectAll = () => { + replaceGraphSelection({ + vertices: vertices.map(v => + getVertexIdFromRenderedVertexId(v.data.id), + ), + edges: edges.map(e => + getEdgeIdFromRenderedEdgeId(e.data.id), + ), + }); + }; return ( @@ -305,24 +345,48 @@ function NoTargetMenu() { Fit to frame + Center + Download screenshot + + Zoom in + Zoom out + + + + + Select all nodes + + + + + Select all edges + + + + + Select all + + + + Clear canvas