From c770b752ed705ef7d0cfec0946e058ffd5c3d7ef Mon Sep 17 00:00:00 2001 From: dextmorgn Date: Sun, 10 Aug 2025 19:49:07 +0200 Subject: [PATCH] feat: toggle details on currentNode --- flowsint-api/app/api/routes/types.py | 1 + flowsint-api/app/models/base.py | 4 - flowsint-api/app/models/models.py | 8 +- .../src/renderer/public/icons/asn.svg | 15 +-- .../src/renderer/public/icons/file-code-2.svg | 1 + .../src/renderer/public/icons/file-digit.svg | 1 + .../src/renderer/public/icons/file.svg | 2 +- .../src/components/chat/floating-chat.tsx | 18 +-- .../{new-actions.tsx => add-item-dialog.tsx} | 7 +- .../{ => details-panel}/details-panel.tsx | 37 ++++-- .../graphs/{ => details-panel}/neighbors.tsx | 7 +- .../{ => details-panel}/node-editor-modal.tsx | 4 +- .../graphs/details-panel/relationships.tsx | 94 ++++++++++++++ .../src/components/graphs/empty-state.tsx | 4 +- .../src/components/graphs/graph-panel.tsx | 15 ++- .../src/components/graphs/graph-viewer.tsx | 8 +- .../src/components/graphs/items-panel.tsx | 6 +- .../src/components/graphs/nodes-panel.tsx | 2 - .../src/components/graphs/toolbar.tsx | 116 +++--------------- .../graphs/use-force-graph-controls.ts | 55 --------- .../src/components/layout/root.layout.tsx | 25 ++-- .../src/components/table/nodes-view.tsx | 8 +- .../components/table/relationships-view.tsx | 15 +-- .../components/transforms/context-menu.tsx | 8 ++ .../src/components/transforms/editor.tsx | 5 +- .../renderer/src/components/type-badge.tsx | 5 +- .../src/renderer/src/lib/action-items.ts | 1 + ...estigations.$investigationId.$type.$id.tsx | 7 ++ .../src/renderer/src/stores/graph-store.ts | 18 ++- .../src/renderer/src/stores/layout-store.ts | 8 +- flowsint-app/src/renderer/src/types/graph.ts | 9 +- flowsint-app/src/renderer/src/types/index.ts | 1 - flowsint-app/src/renderer/src/types/table.ts | 26 ++-- flowsint-app/src/renderer/src/types/tabs.d.ts | 6 - flowsint-app/src/renderer/src/types/tabs.ts | 35 ------ 35 files changed, 265 insertions(+), 317 deletions(-) delete mode 100644 flowsint-api/app/models/base.py create mode 100644 flowsint-app/src/renderer/public/icons/file-code-2.svg create mode 100644 flowsint-app/src/renderer/public/icons/file-digit.svg rename flowsint-app/src/renderer/src/components/graphs/{new-actions.tsx => add-item-dialog.tsx} (97%) rename flowsint-app/src/renderer/src/components/graphs/{ => details-panel}/details-panel.tsx (79%) rename flowsint-app/src/renderer/src/components/graphs/{ => details-panel}/neighbors.tsx (75%) rename flowsint-app/src/renderer/src/components/graphs/{ => details-panel}/node-editor-modal.tsx (99%) create mode 100644 flowsint-app/src/renderer/src/components/graphs/details-panel/relationships.tsx delete mode 100644 flowsint-app/src/renderer/src/components/graphs/use-force-graph-controls.ts delete mode 100644 flowsint-app/src/renderer/src/types/tabs.d.ts delete mode 100644 flowsint-app/src/renderer/src/types/tabs.ts diff --git a/flowsint-api/app/api/routes/types.py b/flowsint-api/app/api/routes/types.py index eb0c818e..8911461d 100644 --- a/flowsint-api/app/api/routes/types.py +++ b/flowsint-api/app/api/routes/types.py @@ -199,6 +199,7 @@ def extract_input_schema(model: Type[BaseModel], label_key:str, icon: Optional[s "label_key": label_key, "icon": icon or type_name.lower(), "label": type_name, + "description": details.get("description",""), "fields": [resolve_field(prop, details=info, schema=schema) for prop, info in details.get("properties", {}).items() ] diff --git a/flowsint-api/app/models/base.py b/flowsint-api/app/models/base.py deleted file mode 100644 index f75ec448..00000000 --- a/flowsint-api/app/models/base.py +++ /dev/null @@ -1,4 +0,0 @@ -from sqlalchemy.orm import DeclarativeBase - -class Base(DeclarativeBase): - pass diff --git a/flowsint-api/app/models/models.py b/flowsint-api/app/models/models.py index 29ec5c40..7e5073f2 100644 --- a/flowsint-api/app/models/models.py +++ b/flowsint-api/app/models/models.py @@ -1,16 +1,16 @@ import uuid from datetime import datetime - from sqlalchemy import ( String, Text, DateTime, ForeignKey, Index, func, JSON, Column, Enum as SQLEnum ) from sqlalchemy.dialects.postgresql import UUID as PGUUID, ARRAY, JSONB -from sqlalchemy.orm import Mapped, mapped_column, relationship - -from .base import Base +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship from app.core.enums import EventLevel +class Base(DeclarativeBase): + pass + class Feedback(Base): __tablename__ = "feedbacks" diff --git a/flowsint-app/src/renderer/public/icons/asn.svg b/flowsint-app/src/renderer/public/icons/asn.svg index 7e46094f..fa90915e 100644 --- a/flowsint-app/src/renderer/public/icons/asn.svg +++ b/flowsint-app/src/renderer/public/icons/asn.svg @@ -1,14 +1 @@ - - - - - - - - - - - - - ASN - \ No newline at end of file + \ No newline at end of file diff --git a/flowsint-app/src/renderer/public/icons/file-code-2.svg b/flowsint-app/src/renderer/public/icons/file-code-2.svg new file mode 100644 index 00000000..2967bea2 --- /dev/null +++ b/flowsint-app/src/renderer/public/icons/file-code-2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/flowsint-app/src/renderer/public/icons/file-digit.svg b/flowsint-app/src/renderer/public/icons/file-digit.svg new file mode 100644 index 00000000..fa90915e --- /dev/null +++ b/flowsint-app/src/renderer/public/icons/file-digit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/flowsint-app/src/renderer/public/icons/file.svg b/flowsint-app/src/renderer/public/icons/file.svg index 25ca07ad..a01842a9 100644 --- a/flowsint-app/src/renderer/public/icons/file.svg +++ b/flowsint-app/src/renderer/public/icons/file.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/flowsint-app/src/renderer/src/components/chat/floating-chat.tsx b/flowsint-app/src/renderer/src/components/chat/floating-chat.tsx index aa445087..ed733585 100644 --- a/flowsint-app/src/renderer/src/components/chat/floating-chat.tsx +++ b/flowsint-app/src/renderer/src/components/chat/floating-chat.tsx @@ -228,32 +228,32 @@ function FloatingChat() { */}

- Start your conversation + Start your conversation with Flo

Ask me anything about your investigation. Here are some examples:

-
-

Analysis & Insights:

-
    +
    +

    Analysis & Insights

    +
    • • "Analyze the connections between these entities"
    • • "What patterns do you see in this data?"
    • • "Summarize the key findings from this investigation"
    -
    + {/*

    Data Exploration:

    • • "Find all IP addresses related to this domain"
    • • "Show me all crypto wallets connected to this address"
    • • "What social media accounts are linked to this email?"
    -
    -
    -

    Investigation Help:

    -
      +
    */} +
    +

    Investigation Help

    +
    • • "Suggest next steps for this investigation"
    • • "What should I look for next?"
    • • "Help me organize this investigation"
    • diff --git a/flowsint-app/src/renderer/src/components/graphs/new-actions.tsx b/flowsint-app/src/renderer/src/components/graphs/add-item-dialog.tsx similarity index 97% rename from flowsint-app/src/renderer/src/components/graphs/new-actions.tsx rename to flowsint-app/src/renderer/src/components/graphs/add-item-dialog.tsx index 59a17ae8..e487b54d 100644 --- a/flowsint-app/src/renderer/src/components/graphs/new-actions.tsx +++ b/flowsint-app/src/renderer/src/components/graphs/add-item-dialog.tsx @@ -16,7 +16,7 @@ import { useIcon } from "@/hooks/use-icon" import { useLayoutStore } from "@/stores/layout-store" import { useActionItems } from "@/hooks/use-action-items" -export default function ActionDialog() { +export default function AddItemDialog() { const handleOpenFormModal = useGraphStore(state => state.handleOpenFormModal) const currentNodeType = useGraphStore(state => state.currentNodeType) const setCurrentNode = useGraphStore(state => state.setCurrentNode) @@ -216,7 +216,7 @@ export default function ActionDialog() { <>Add {currentNodeType.label.toLowerCase()} )} - Fill the required data. + {currentNodeType?.description} {currentNodeType && (
      {item.label}
      - {!item.children &&
      {item.fields.length} fields
      } + {!item.children &&
      {item.description}
      } + {!item.children && {item.fields.length} fields} {item.disabled && ( Soon diff --git a/flowsint-app/src/renderer/src/components/graphs/details-panel.tsx b/flowsint-app/src/renderer/src/components/graphs/details-panel/details-panel.tsx similarity index 79% rename from flowsint-app/src/renderer/src/components/graphs/details-panel.tsx rename to flowsint-app/src/renderer/src/components/graphs/details-panel/details-panel.tsx index 7e0ae785..38492352 100644 --- a/flowsint-app/src/renderer/src/components/graphs/details-panel.tsx +++ b/flowsint-app/src/renderer/src/components/graphs/details-panel/details-panel.tsx @@ -2,14 +2,16 @@ import { memo } from "react" import { cn } from "@/lib/utils" import { CopyButton } from "@/components/copy" import { Check, Rocket, X, MousePointer } from "lucide-react" -import LaunchTransform from "./launch-transform" -import NodeActions from "./node-actions" +import LaunchTransform from "../launch-transform" +import NodeActions from "../node-actions" import { GraphNode } from "@/stores/graph-store" -import { Button } from "../ui/button" -import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip" +import { Button } from "../../ui/button" +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../ui/tooltip" import { useIcon } from "@/hooks/use-icon" import { useParams } from "@tanstack/react-router" import NeighborsGraph from "./neighbors" +import Relationships from "./relationships" +import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "../../ui/resizable" export default function DetailsPanel({ node }: { node: GraphNode | null }) { const { id: sketchId } = useParams({ strict: false }) @@ -30,9 +32,9 @@ export default function DetailsPanel({ node }: { node: GraphNode | null }) { } return ( -
      +
      -
      +

      {node.data?.label}

      @@ -67,9 +69,24 @@ export default function DetailsPanel({ node }: { node: GraphNode | null }) { />
      )} - -
      - +
      + + +
      + +
      +
      + + +
      + +
      +
      + + + + +
      ) @@ -133,7 +150,7 @@ const ItemHero = ({ node }: { node: GraphNode }) => {

      {node.data.label}

      {node.data.type}

      - +
      ) } \ No newline at end of file diff --git a/flowsint-app/src/renderer/src/components/graphs/neighbors.tsx b/flowsint-app/src/renderer/src/components/graphs/details-panel/neighbors.tsx similarity index 75% rename from flowsint-app/src/renderer/src/components/graphs/neighbors.tsx rename to flowsint-app/src/renderer/src/components/graphs/details-panel/neighbors.tsx index 05118220..b08e907d 100644 --- a/flowsint-app/src/renderer/src/components/graphs/neighbors.tsx +++ b/flowsint-app/src/renderer/src/components/graphs/details-panel/neighbors.tsx @@ -1,6 +1,6 @@ import { sketchService } from "@/api/sketch-service"; import { useQuery } from "@tanstack/react-query"; -import ForceGraphViewer from "./graph-viewer"; +import ForceGraphViewer from "../graph-viewer"; const NeighborsGraph = ({ sketchId, nodeId }: { sketchId: string, nodeId: string }) => { @@ -12,7 +12,10 @@ const NeighborsGraph = ({ sketchId, nodeId }: { sketchId: string, nodeId: string
      {isLoading ?
      Loading...
      : <> -
      {neighborsData.nds.length - 1} neighbor(s)
      +
      + {neighborsData.nds.length - 1} + neighbor(s) +
      { + const relationships: Relation[] = [] + edges.forEach((edge) => { + const target = nodes.find((n) => (n.id === edge.target)) + if (!target) return + relationships.push({ target, edge: { label: String(edge.caption || 'RELATED_TO') } }) + }) + return relationships +} + +const Relationships = ({ sketchId, nodeId }: { sketchId: string, nodeId: string }) => { + const { data: neighborsData, isLoading } = useQuery({ + queryKey: ['neighbors', sketchId, nodeId], + queryFn: () => sketchService.getNodeNeighbors(sketchId, nodeId), + }); + + const parentRef = useRef(null); + const relationships = getInlineRelationships(neighborsData?.nds || [], neighborsData?.rls || []); + + const rowVirtualizer = useVirtualizer({ + count: relationships.length, + getScrollElement: () => parentRef.current, + estimateSize: () => 40, // Estimate height of each relationship item + overscan: 5, + }); + + if (isLoading) return
      + + return ( +
      +
      + {rowVirtualizer.getVirtualItems().map((virtualRow) => { + const rel = relationships[virtualRow.index]; + return ( +
      + + {rel.edge.label} + + + +
      + ); + })} +
      +
      + ) +} + +export default Relationships + + +const RelationshipItem = memo(({ node }: { node: GraphNode }) => { + const setCurrentNode = useGraphStore(s => s.setCurrentNode) + const handleClick = useCallback(() => { + setCurrentNode(node) + }, [setCurrentNode]) + return ( + + ) +}) \ No newline at end of file diff --git a/flowsint-app/src/renderer/src/components/graphs/empty-state.tsx b/flowsint-app/src/renderer/src/components/graphs/empty-state.tsx index 200101db..cd415525 100644 --- a/flowsint-app/src/renderer/src/components/graphs/empty-state.tsx +++ b/flowsint-app/src/renderer/src/components/graphs/empty-state.tsx @@ -6,7 +6,7 @@ import { useGraphStore } from '@/stores/graph-store' const EmptyState = memo(() => { const setOpenMainDialog = useGraphStore(state => state.setOpenMainDialog) - const handleOpenNewActionDialog = useCallback(() => { + const handleOpenNewAddItemDialog = useCallback(() => { setOpenMainDialog(true) }, [setOpenMainDialog]) @@ -74,7 +74,7 @@ const EmptyState = memo(() => { {/* Call to action */}
      -
      diff --git a/flowsint-app/src/renderer/src/components/graphs/nodes-panel.tsx b/flowsint-app/src/renderer/src/components/graphs/nodes-panel.tsx index 9c7c7119..57857767 100644 --- a/flowsint-app/src/renderer/src/components/graphs/nodes-panel.tsx +++ b/flowsint-app/src/renderer/src/components/graphs/nodes-panel.tsx @@ -20,10 +20,8 @@ import { import type { GraphNode } from "@/stores/graph-store" import { Checkbox } from "@/components/ui/checkbox" -// Hauteur fixe pour chaque item (en pixels) const ITEM_HEIGHT = 40 -// Function to extract all leaf-level node types from actionItems const getAllNodeTypes = (actionItems: any[]) => { const types: string[] = [] actionItems.forEach(item => { diff --git a/flowsint-app/src/renderer/src/components/graphs/toolbar.tsx b/flowsint-app/src/renderer/src/components/graphs/toolbar.tsx index 1d1b659e..f4dd40c6 100644 --- a/flowsint-app/src/renderer/src/components/graphs/toolbar.tsx +++ b/flowsint-app/src/renderer/src/components/graphs/toolbar.tsx @@ -1,19 +1,13 @@ import { Button } from "@/components/ui/button" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" -import { useConfirm } from "@/components/use-confirm-dialog" import { useGraphControls } from "@/stores/graph-controls-store" -import { useGraphStore } from "@/stores/graph-store" import { Maximize, Minus, - Trash, ZoomIn, RotateCw, - GitPullRequestCreate, - // GitFork, Waypoints, - Table, MapPin, List, SlidersHorizontal, @@ -21,11 +15,8 @@ import { ArrowRightLeft } from "lucide-react" import { memo, useCallback } from "react" -import { sketchService } from "@/api/sketch-service" -import { useParams } from "@tanstack/react-router" import { toast } from "sonner" import { cn } from "@/lib/utils" -// import { useKeyboardShortcut } from "@/hooks/use-keyboard-shortcut" import ForceControls from './force-controls' const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0 @@ -65,20 +56,13 @@ const ToolbarButton = memo(function ToolbarButton({ ) }) export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean }) { - const { id: sketchId } = useParams({ from: "/_auth/dashboard/investigations/$investigationId/$type/$id" }) - const selectedNodes = useGraphStore((state) => state.selectedNodes || []) const view = useGraphControls(s => s.view) - const setOpenAddRelationDialog = useGraphStore((state) => state.setOpenAddRelationDialog) const setView = useGraphControls((s) => s.setView) - const removeNodes = useGraphStore((state) => state.removeNodes) const zoomToFit = useGraphControls((s) => s.zoomToFit); const zoomIn = useGraphControls((s) => s.zoomIn); const zoomOut = useGraphControls((s) => s.zoomOut); const onLayout = useGraphControls((s) => s.onLayout); - const { confirm } = useConfirm() const refetchGraph = useGraphControls((s) => s.refetchGraph) - const clearSelectedNodes = useGraphStore((s) => s.clearSelectedNodes) - // const nodesLength = useGraphStore((s) => s.getNodesLength()) const handleRefresh = useCallback(() => { try { @@ -89,32 +73,6 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean } }, [refetchGraph, onLayout]); - const handleOpenRelationshipDialog = useCallback(() => { - setOpenAddRelationDialog(true) - }, []) - - const handleDeleteNodes = useCallback(async () => { - if (!selectedNodes.length) return - if (!await confirm({ title: `You are about to delete ${selectedNodes.length} node(s).`, message: "The action is irreversible." })) return - - toast.promise( - (async () => { - removeNodes(selectedNodes.map((n) => n.id)) - clearSelectedNodes() - return sketchService.deleteNodes(sketchId, JSON.stringify({ nodeIds: selectedNodes.map((n) => n.id) })) - })(), - { - loading: `Deleting ${selectedNodes.length} node(s)...`, - success: 'Nodes deleted successfully.', - error: 'Failed to delete nodes.' - } - ) - }, [selectedNodes, confirm, removeNodes, clearSelectedNodes, sketchId]) - const isMoreThanZero = selectedNodes.length > 0 - const isTwo = selectedNodes.length == 2 - // const isGraphOnly = nodesLength > 500 - // const isCosmoOnly = nodesLength > 3000 - const handleForceLayout = useCallback(() => { setView("force") }, [setView]) @@ -136,60 +94,28 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean onLayout && onLayout("dagre-tb") }, [onLayout, setView]) - // const handleDagreLayoutLR = useCallback(() => { - // setView("hierarchy") - // onLayout && onLayout("dagre-lr") - // }, [onLayout, setView]) - - // const { isMac } = useKeyboardShortcut({ - // key: "y", - // ctrlOrCmd: true, - // callback: handleDagreLayoutTB - // }) - return (
      - {/* } - tooltip="Create relation" - disabled={!isTwo} + < ToolbarButton + icon={} + tooltip="Zoom In" + onClick={zoomIn} + disabled={["table", "relationships"].includes(view)} /> } - tooltip="Delete" - disabled={!isMoreThanZero} - badge={isMoreThanZero ? selectedNodes.length : null} - /> */} - {/* } tooltip="Filter" /> */} - <> - < ToolbarButton - icon={} - tooltip="Zoom In" - onClick={zoomIn} - disabled={["table", "relationships"].includes(view)} - /> - } - tooltip="Zoom Out" - onClick={zoomOut} - disabled={["table", "relationships"].includes(view)} - /> - } - tooltip="Fit to View" - onClick={zoomToFit} - disabled={["table", "relationships"].includes(view)} - /> - - {/* } - tooltip={isGraphOnly ? "Graph is too large to render in hierarchy layout" : `Hierarchy (${isMac ? '⌘' : 'ctrl'}+Y)`} - onClick={handleDagreLayoutLR} - disabled={isGraphOnly} - /> */} + icon={} + tooltip="Zoom Out" + onClick={zoomOut} + disabled={["table", "relationships"].includes(view)} + /> + } + tooltip="Fit to View" + onClick={zoomToFit} + disabled={["table", "relationships"].includes(view)} + /> + } tooltip={`Hierarchy (${isMac ? '⌘' : 'ctrl'}+Y)`} @@ -199,7 +125,6 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean icon={} tooltip={"Graph view"} onClick={handleForceLayout} - // disabled={isCosmoOnly} /> } @@ -216,13 +141,6 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean tooltip={"Map view"} onClick={handleMapLayout} /> - {/* } - tooltip={"3D Graph"} - onClick={handleForce3DLayout} - disabled={isCosmoOnly} - /> */} - {/* } tooltip="Settings" /> */} void; -// zoomOut: () => void; -// zoomToFit: () => void; -// resetZoom: () => void; -// } - -// export const useForceGraphControls = () => { -// const graphRef = useRef(); - -// const setGraphRef = useCallback((ref: any) => { -// graphRef.current = ref; -// }, []); - -// const zoomIn = useCallback(() => { -// if (graphRef.current) { -// const zoom = graphRef.current.zoom(); -// graphRef.current.zoom(zoom * 1.5); -// } -// }, []); - -// const zoomOut = useCallback(() => { -// if (graphRef.current) { -// const zoom = graphRef.current.zoom(); -// graphRef.current.zoom(zoom * 0.75); -// } -// }, []); - -// const zoomToFit = useCallback(() => { -// if (graphRef.current) { -// graphRef.current.zoomToFit(400); -// } -// }, []); - -// const resetZoom = useCallback(() => { -// if (graphRef.current) { -// graphRef.current.zoom(1); -// graphRef.current.centerAt(0, 0); -// } -// }, []); - -// const controls: ForceGraphControls = { -// zoomIn, -// zoomOut, -// zoomToFit, -// resetZoom, -// }; - -// return { -// controls, -// setGraphRef, -// }; -// }; \ No newline at end of file diff --git a/flowsint-app/src/renderer/src/components/layout/root.layout.tsx b/flowsint-app/src/renderer/src/components/layout/root.layout.tsx index d7924d61..60c20d6f 100644 --- a/flowsint-app/src/renderer/src/components/layout/root.layout.tsx +++ b/flowsint-app/src/renderer/src/components/layout/root.layout.tsx @@ -1,4 +1,4 @@ -import { type ReactNode } from "react" +import { useEffect, type ReactNode } from "react" import { Sidebar } from "./sidebar" import { TopNavbar } from "./top-navbar" import { StatusBar } from "./status-bar" @@ -10,7 +10,7 @@ import { useLayoutStore } from "@/stores/layout-store" // import NotesPanel from "../analyses/notes-panel" import { useKeyboardShortcut } from "@/hooks/use-keyboard-shortcut" import { useParams } from "@tanstack/react-router" -import DetailsPanel from "../graphs/details-panel" +import DetailsPanel from "../graphs/details-panel/details-panel" import { useGraphStore } from "@/stores/graph-store" interface LayoutProps { @@ -27,11 +27,18 @@ export default function RootLayout({ children }: LayoutProps) { const togglePanel = useLayoutStore(s => s.togglePanel) const closePanel = useLayoutStore(s => s.closePanel) const openPanel = useLayoutStore(s => s.openPanel) - const toggleAnalysis = useLayoutStore(s => s.toggleAnalysis) - const closeAnalysis = useLayoutStore(s => s.closeAnalysis) - const openAnalysis = useLayoutStore(s => s.openAnalysis) + const closeDetails = useLayoutStore(s => s.closeDetails) + const openDetails = useLayoutStore(s => s.openDetails) const currentNode = useGraphStore((s) => s.currentNode) - const { investigationId, id } = useParams({ strict: false }) + const { id } = useParams({ strict: false }) + + useEffect(() => { + if (!currentNode) { + closeDetails() + return + } + openDetails() + }, [currentNode]) // Set up keyboard shortcut for chat panel @@ -102,7 +109,7 @@ export default function RootLayout({ children }: LayoutProps) { {children} - {isOpenDetails && id && ( + {isOpenDetails && id && currentNode && ( <> diff --git a/flowsint-app/src/renderer/src/components/table/nodes-view.tsx b/flowsint-app/src/renderer/src/components/table/nodes-view.tsx index 55261956..73d93f84 100644 --- a/flowsint-app/src/renderer/src/components/table/nodes-view.tsx +++ b/flowsint-app/src/renderer/src/components/table/nodes-view.tsx @@ -69,12 +69,14 @@ export default function NodesTable({ nodes }: NodesTableProps) { const [selectedType, setSelectedType] = useState("all"); const parentRef = useRef(null); const setCurrentNode = useGraphStore(s => s.setCurrentNode) - const setOpenNodeEditorModal = useGraphStore(s => s.setOpenNodeEditorModal) + // const setOpenNodeEditorModal = useGraphStore(s => s.setOpenNodeEditorModal) const onNodeClick = useCallback((node: GraphNode) => { setCurrentNode(node) - setOpenNodeEditorModal(true) - }, [setCurrentNode, setOpenNodeEditorModal]) + // setOpenNodeEditorModal(true) + }, [setCurrentNode, + // setOpenNodeEditorModal + ]) // Filter nodes based on search and type diff --git a/flowsint-app/src/renderer/src/components/table/relationships-view.tsx b/flowsint-app/src/renderer/src/components/table/relationships-view.tsx index 779b9fd7..194b03ec 100644 --- a/flowsint-app/src/renderer/src/components/table/relationships-view.tsx +++ b/flowsint-app/src/renderer/src/components/table/relationships-view.tsx @@ -18,12 +18,7 @@ import { SelectValue, } from "@/components/ui/select"; import { CopyButton } from "../copy"; - -export type RelationshipType = { - source: GraphNode - target: GraphNode - edge: { label: string } -} +import { RelationshipType } from "@/types"; const ITEM_HEIGHT = 67; // Balanced spacing between items (55px card + 12px padding) @@ -104,12 +99,14 @@ export default function RelationshipsTable() { const [selectedType, setSelectedType] = useState("all"); const parentRef = useRef(null); const setCurrentNode = useGraphStore(s => s.setCurrentNode) - const setOpenNodeEditorModal = useGraphStore(s => s.setOpenNodeEditorModal) + // const setOpenNodeEditorModal = useGraphStore(s => s.setOpenNodeEditorModal) const onNodeClick = useCallback((node: GraphNode) => { setCurrentNode(node) - setOpenNodeEditorModal(true) - }, [setCurrentNode, setOpenNodeEditorModal]) + // setOpenNodeEditorModal(true) + }, [setCurrentNode, + // setOpenNodeEditorModal + ]) // Filter relationships based on search and type diff --git a/flowsint-app/src/renderer/src/components/transforms/context-menu.tsx b/flowsint-app/src/renderer/src/components/transforms/context-menu.tsx index a5ce270f..95a288be 100644 --- a/flowsint-app/src/renderer/src/components/transforms/context-menu.tsx +++ b/flowsint-app/src/renderer/src/components/transforms/context-menu.tsx @@ -35,11 +35,18 @@ export default function ContextMenu({ }: GraphContextMenuProps) { const setOpenParamsDialog = useTransformStore(s => s.setOpenParamsDialog) + const deleteNode = useTransformStore(s => s.deleteNode) + const handleOpenParamsModal = useCallback(() => { setOpenParamsDialog(true, node as TransformNode) setMenu(null) }, [setOpenParamsDialog, node, setMenu]) + const handleDeleteTransform = useCallback(() => { + deleteNode(node.id as string) + setMenu(null) + }, [deleteNode, node.id, setMenu]) + return ( Edit
      } -
      diff --git a/flowsint-app/src/renderer/src/components/type-badge.tsx b/flowsint-app/src/renderer/src/components/type-badge.tsx index 379a5e16..0749ac49 100644 --- a/flowsint-app/src/renderer/src/components/type-badge.tsx +++ b/flowsint-app/src/renderer/src/components/type-badge.tsx @@ -6,9 +6,10 @@ import { memo } from "react" type TypeBadgeProps = { type: string className?: string + children?: React.ReactNode } -function TypeBadgeComponent({ type, className }: TypeBadgeProps) { +function TypeBadgeComponent({ type, children, className }: TypeBadgeProps) { const colors = useNodesDisplaySettings(s => s.colors) const color = colors[type as keyof typeof colors] || "bg-gray-100 text-gray-800 hover:bg-gray-100/80 dark:bg-gray-800/50 dark:text-gray-300 dark:hover:bg-gray-800/60" return ( @@ -17,7 +18,7 @@ function TypeBadgeComponent({ type, className }: TypeBadgeProps) { style={{ backgroundColor: hexToRgba(color, .5) }} className={cn("font-medium border-transparent", className)} > - {type} + {children ?? type} ) } diff --git a/flowsint-app/src/renderer/src/lib/action-items.ts b/flowsint-app/src/renderer/src/lib/action-items.ts index 712fef29..1f585405 100644 --- a/flowsint-app/src/renderer/src/lib/action-items.ts +++ b/flowsint-app/src/renderer/src/lib/action-items.ts @@ -27,6 +27,7 @@ export interface ActionItem { disabled?: boolean comingSoon?: boolean children?: ActionItem[] + description: string } export function findActionItemByKey(key: string, actionItems: ActionItem[] | undefined): ActionItem | undefined { diff --git a/flowsint-app/src/renderer/src/routes/_auth.dashboard.investigations.$investigationId.$type.$id.tsx b/flowsint-app/src/renderer/src/routes/_auth.dashboard.investigations.$investigationId.$type.$id.tsx index 64119498..b6d37bc7 100644 --- a/flowsint-app/src/renderer/src/routes/_auth.dashboard.investigations.$investigationId.$type.$id.tsx +++ b/flowsint-app/src/renderer/src/routes/_auth.dashboard.investigations.$investigationId.$type.$id.tsx @@ -6,6 +6,7 @@ import Loader from '@/components/loader' import { analysisService } from '@/api/analysis-service' import { AnalysisPage } from '@/components/analyses/analysis-page' import { useGraphControls } from '@/stores/graph-controls-store' +import { useGraphStore } from '@/stores/graph-store' import { useEffect } from 'react' const services = { @@ -15,6 +16,7 @@ const services = { const GraphPageContent = () => { const setActions = useGraphControls((s) => s.setActions) + const reset = useGraphStore((s) => s.reset) const { params: { type, id, investigationId }, sketch } = useLoaderData({ from: '/_auth/dashboard/investigations/$investigationId/$type/$id', }) @@ -28,6 +30,11 @@ const GraphPageContent = () => { initialData: sketch }) + // Reset graph store when sketchId changes or is null + useEffect(() => { + reset() + }, [id, reset]) + useEffect(() => { setActions({ refetchGraph: refetch }) }, [refetch, setActions, id]) diff --git a/flowsint-app/src/renderer/src/stores/graph-store.ts b/flowsint-app/src/renderer/src/stores/graph-store.ts index 6e8731f3..36edf3ae 100644 --- a/flowsint-app/src/renderer/src/stores/graph-store.ts +++ b/flowsint-app/src/renderer/src/stores/graph-store.ts @@ -18,7 +18,7 @@ export type GraphNode = Node & { x?: number; y?: number; } -export type GraphEdge = Edge +export type GraphEdge = Edge & { caption?: string } interface GraphState { // === Graph === @@ -36,6 +36,7 @@ interface GraphState { onNodesChange: OnNodesChange onEdgesChange: OnEdgesChange onConnect: OnConnect + reset: () => void // === Selection & Current === currentNode: GraphNode | null @@ -167,6 +168,21 @@ export const useGraphStore = create()((set, get) => ({ edges: [...get().edges, edge], }) }, + reset: () => { + set({ + // nodes: [], + // edges: [], + currentNode: null, + selectedNodes: [], + relatedNodeToAdd: null, + openMainDialog: false, + openFormDialog: false, + openAddRelationDialog: false, + openNodeEditorModal: false, + currentNodeType: null, + filters: {}, + }) + }, // === Selection & Current === currentNode: null, diff --git a/flowsint-app/src/renderer/src/stores/layout-store.ts b/flowsint-app/src/renderer/src/stores/layout-store.ts index b12a3e67..df90967d 100644 --- a/flowsint-app/src/renderer/src/stores/layout-store.ts +++ b/flowsint-app/src/renderer/src/stores/layout-store.ts @@ -18,8 +18,8 @@ interface LayoutStore { openPanel: () => void closeChat: () => void openChat: () => void - openAnalysis: () => void - closeAnalysis: () => void + openDetails: () => void + closeDetails: () => void setChatDimensions: (width: number, height: number) => void activeTab: string activeTransformTab: string @@ -48,8 +48,8 @@ export const useLayoutStore = create()( openPanel: () => set({ isOpenPanel: true }), closeChat: () => set({ isOpenChat: false }), openChat: () => set({ isOpenChat: true }), - closeAnalysis: () => set({ isOpenAnalysis: false }), - openAnalysis: () => set({ isOpenAnalysis: true }), + closeDetails: () => set({ isOpenAnalysis: false }), + openDetails: () => set({ isOpenAnalysis: true }), setChatDimensions: (width: number, height: number) => set({ chatWidth: width, chatHeight: height }), setActiveTab: (tab: string) => set({ activeTab: tab }), setActiveTransformTab: (tab: string) => set({ activeTransformTab: tab }), diff --git a/flowsint-app/src/renderer/src/types/graph.ts b/flowsint-app/src/renderer/src/types/graph.ts index 10a598c7..a7435a42 100644 --- a/flowsint-app/src/renderer/src/types/graph.ts +++ b/flowsint-app/src/renderer/src/types/graph.ts @@ -11,12 +11,13 @@ export type NodeData = { }; export type EdgeData = { - from: string, - to: string, - date: string, + from: string; + to: string; + date: string; id: string; label: string; - type: string, + caption?: string; + type: string; confidence_level?: number | string }; diff --git a/flowsint-app/src/renderer/src/types/index.ts b/flowsint-app/src/renderer/src/types/index.ts index 24126bce..23d99f7f 100644 --- a/flowsint-app/src/renderer/src/types/index.ts +++ b/flowsint-app/src/renderer/src/types/index.ts @@ -9,4 +9,3 @@ export * from "./sketch"; export * from "./table"; export * from "./tool"; export * from "./transform"; -export * from "./tabs"; diff --git a/flowsint-app/src/renderer/src/types/table.ts b/flowsint-app/src/renderer/src/types/table.ts index ebe23639..5eb2a88c 100644 --- a/flowsint-app/src/renderer/src/types/table.ts +++ b/flowsint-app/src/renderer/src/types/table.ts @@ -1,3 +1,5 @@ +import { GraphNode } from "@/stores/graph-store" + export type Row = { id: string label: string @@ -5,22 +7,8 @@ export type Row = { created_at: string } -export const rows: Row[] = [ - { - id: "728ed52f", - label: "https://alliage.io", - type: "wesbite", - created_at: "2021-01-01" - }, - { - id: "728ed52E", - label: "alliage.io", - type: "domain", - created_at: "2021-01-01" - }, { - id: "722ed52E", - label: "12.32.43.12", - type: "ip", - created_at: "2021-01-01" - }, -] \ No newline at end of file +export type RelationshipType = { + source: GraphNode + target: GraphNode + edge: { label: string } +} \ No newline at end of file diff --git a/flowsint-app/src/renderer/src/types/tabs.d.ts b/flowsint-app/src/renderer/src/types/tabs.d.ts deleted file mode 100644 index d9feb5f7..00000000 --- a/flowsint-app/src/renderer/src/types/tabs.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type TabInfo = { - id: string - name: string - mode?: string | null - } - \ No newline at end of file diff --git a/flowsint-app/src/renderer/src/types/tabs.ts b/flowsint-app/src/renderer/src/types/tabs.ts deleted file mode 100644 index 14a6b9e9..00000000 --- a/flowsint-app/src/renderer/src/types/tabs.ts +++ /dev/null @@ -1,35 +0,0 @@ -export interface TabInfo { - id: string - title: string - type: "graph" | "wall" - investigationId: string - data?: any - isDirty?: boolean - isLoading?: boolean -} - -export interface TabsState { - items: TabInfo[] - selectedTabId: string | null - selectedTabIndex: number -} - -export interface TabsSlice { - tabs: TabsState & { - initialize: () => Promise - setSelectedTab: (tab: TabInfo) => void - remove: (tab: TabInfo) => void - add: (params: { - id: string - type: "graph" | "wall" - investigationId: string - data?: any - title?: string - isLoading?: boolean - }) => Promise - reorder: (tabs: TabInfo[]) => void - updateTabData: (id: string, data: any) => void - markTabDirty: (id: string, isDirty?: boolean) => void - clearTabs: () => void - } -} \ No newline at end of file