A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat(app): open params sheet before launch when enricher declares params
dextmorgn56e1ab48cd87
diff --git a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx b/flowsint-app/src/components/sketches/graph/components/graph-main.tsxindex 9abef551..802cee6a 100644--- a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx+++ b/flowsint-app/src/components/sketches/graph/components/graph-main.tsx@@ -18,6 +18,11 @@ import { useLinkCreation } from '../hooks/use-link-creation'import { useQuickAdd } from '../hooks/use-quick-add'import { QuickAddOverlay } from './quick-add-overlay'import { usePermissions } from '@/hooks/use-can'+import { useLaunchEnricher } from '@/hooks/use-launch-enricher'+import {+ EnricherParamsSheet,+ type PendingEnricherLaunch+} from '@/components/sketches/enricher-params-sheet'type BaseContextMenuProps = {rawTop: number@@ -63,6 +68,10 @@ const GraphMain = () => {const [nodeMenu, setNodeMenu] = React.useState<NodeContextMenuProps | null>(null)const [edgeMenu, setEdgeMenu] = React.useState<EdgeContextMenuProps | null>(null)const [background, setBackgroundMenu] = React.useState<BackgroundContextMenuProps | null>(null)+ // Owned here rather than in the menus: a menu dismisses itself on any outside+ // mousedown, which would tear down a Sheet it rendered as soon as it is used.+ const [pendingLaunch, setPendingLaunch] = React.useState<PendingEnricherLaunch | null>(null)+ const { launchEnricher } = useLaunchEnricher(false)const {linkCreation,@@ -279,6 +288,15 @@ const GraphMain = () => {graphRef.current = ref}, [])+ const handleSubmitParams = useCallback(+ (params: Record<string, string>) => {+ if (!pendingLaunch) return+ launchEnricher(pendingLaunch.nodeIds, pendingLaunch.enricherName, sketchId, params)+ setPendingLaunch(null)+ },+ [pendingLaunch, launchEnricher, sketchId]+ )+return (<div ref={containerRef} className="relative h-full w-full bg-background"><GraphViewer@@ -308,11 +326,18 @@ const GraphMain = () => {onCancel={closeQuickAdd}/><PathPanel />- {nodeMenu && selectedNodes.length === 0 && <NodeContextMenu {...nodeMenu} />}+ {nodeMenu && selectedNodes.length === 0 && (+ <NodeContextMenu {...nodeMenu} onRequestParams={setPendingLaunch} />+ )}{edgeMenu && <EdgeContextMenu {...edgeMenu} />}{(background || (nodeMenu && selectedNodes.length > 0)) && (- <BackgroundContextMenu {...background} />+ <BackgroundContextMenu {...background} onRequestParams={setPendingLaunch} />)}+ <EnricherParamsSheet+ pending={pendingLaunch}+ onOpenChange={(open) => !open && setPendingLaunch(null)}+ onSubmit={handleSubmitParams}+ /></div>)}diff --git a/flowsint-app/src/components/sketches/graph/context-menu/background-context-menu.tsx b/flowsint-app/src/components/sketches/graph/context-menu/background-context-menu.tsxindex 208f4486..bbb925a5 100644--- a/flowsint-app/src/components/sketches/graph/context-menu/background-context-menu.tsx+++ b/flowsint-app/src/components/sketches/graph/context-menu/background-context-menu.tsx@@ -32,6 +32,7 @@ import { useConfirm } from '@/components/use-confirm-dialog'import { toast } from 'sonner'import { sketchService } from '@/api/sketch-service'import { usePermissions } from '@/hooks/use-can'+import type { PendingEnricherLaunch } from '@/components/sketches/enricher-params-sheet'interface GraphContextMenuProps {nodes: GraphNode[]@@ -46,6 +47,9 @@ interface GraphContextMenuProps {onEdit?: () => voidonDelete?: () => voidsetMenu: (menu: any | null) => void+ // The params sheet is owned by the parent: this menu dismisses itself on any+ // outside mousedown, and a Sheet portals outside its DOM subtree.+ onRequestParams?: (pending: PendingEnricherLaunch) => void[key: string]: any}@@ -63,6 +67,7 @@ export default function BackgroundContextMenu({onEdit: _onEdit,onDelete: _onDelete,setMenu,+ onRequestParams,...props}: GraphContextMenuProps) {const { id: sketchId } = useParams({ strict: false })@@ -119,9 +124,17 @@ export default function BackgroundContextMenu({setMenu(null)}- const handleEnricherClick = (e: React.MouseEvent, enricherName: string) => {+ const handleEnricherClick = (e: React.MouseEvent, enricher: Enricher) => {e.stopPropagation()- launchEnricher(selectedNodeIds, enricherName, sketchId)+ if (enricher.params_schema?.length) {+ onRequestParams?.({+ enricherName: enricher.name,+ paramsSchema: enricher.params_schema,+ nodeIds: selectedNodeIds+ })+ } else {+ launchEnricher(selectedNodeIds, enricher.name, sketchId)+ }setMenu(null)}@@ -259,7 +272,7 @@ export default function BackgroundContextMenu({<buttonkey={enricher.id}className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"- onClick={(e) => handleEnricherClick(e, enricher.name)}+ onClick={(e) => handleEnricherClick(e, enricher)}><Zap className="h-4 w-4 text-muted-foreground shrink-0" /><div className="flex-1 min-w-0">diff --git a/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx b/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsxindex 138f98c1..62651423 100644--- a/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx+++ b/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx@@ -26,6 +26,7 @@ import BaseContextMenu from '@/components/xyflow/context-menu'import { useGraphStore } from '@/stores/graph-store'import { CopyButton } from '@/components/copy'import { usePermissions } from '@/hooks/use-can'+import type { PendingEnricherLaunch } from '@/components/sketches/enricher-params-sheet'interface GraphContextMenuProps {node: GraphNode@@ -40,6 +41,9 @@ interface GraphContextMenuProps {onEdit?: () => voidonDelete?: () => voidsetMenu: (menu: any | null) => void+ // The params sheet is owned by the parent: this menu dismisses itself on any+ // outside mousedown, and a Sheet portals outside its DOM subtree.+ onRequestParams?: (pending: PendingEnricherLaunch) => void[key: string]: any}@@ -56,6 +60,7 @@ export default function ContextMenu({onEdit: _onEdit,onDelete: _onDelete,setMenu,+ onRequestParams,...props}: GraphContextMenuProps) {const { id: sketchId } = useParams({ strict: false })@@ -101,9 +106,17 @@ export default function ContextMenu({setMenu(null)}- const handleEnricherClick = (e: React.MouseEvent, enricherName: string) => {+ const handleEnricherClick = (e: React.MouseEvent, enricher: Enricher) => {e.stopPropagation()- launchEnricher([node.id], enricherName, sketchId)+ if (enricher.params_schema?.length) {+ onRequestParams?.({+ enricherName: enricher.name,+ paramsSchema: enricher.params_schema,+ nodeIds: [node.id]+ })+ } else {+ launchEnricher([node.id], enricher.name, sketchId)+ }setMenu(null)}@@ -202,7 +215,7 @@ export default function ContextMenu({<buttonkey={enricher.id}className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"- onClick={(e) => handleEnricherClick(e, enricher.name)}+ onClick={(e) => handleEnricherClick(e, enricher)}><Zap className="h-4 w-4 text-muted-foreground shrink-0" /><div className="flex-1 min-w-0">diff --git a/flowsint-app/src/components/sketches/launch-enricher.tsx b/flowsint-app/src/components/sketches/launch-enricher.tsxindex 9a22b318..d74fbc9e 100644--- a/flowsint-app/src/components/sketches/launch-enricher.tsx+++ b/flowsint-app/src/components/sketches/launch-enricher.tsx@@ -24,6 +24,10 @@ import { capitalizeFirstLetter } from '@/lib/utils'import { Skeleton } from '@/components/ui/skeleton'import { Search, FileCode2, Zap, PlusIcon, GitBranch, FileX, Sparkles } from 'lucide-react'import { Enricher, Flow } from '@/types'+import {+ EnricherParamsSheet,+ type PendingEnricherLaunch+} from '@/components/sketches/enricher-params-sheet'const LaunchEnricherOrFlowPanel = memo(({@@ -45,6 +49,7 @@ const LaunchEnricherOrFlowPanel = memo(const [activeTab, setActiveTab] = useState('enrichers')const [enrichersSearchQuery, setEnrichersSearchQuery] = useState('')const [flowsSearchQuery, setFlowsSearchQuery] = useState('')+ const [pendingLaunch, setPendingLaunch] = useState<PendingEnricherLaunch | null>(null)const { data: enrichers, isLoading: isLoadingEnrichers } = useQuery({queryKey: ['enrichers', type],@@ -86,8 +91,18 @@ const LaunchEnricherOrFlowPanel = memo(if (selectedEnricher) {// Check if it's an Enricher or Flow based on the active tabif (activeTab === 'enrichers') {- // For enrichers, use name- launchEnricher(values, (selectedEnricher as Enricher).name, sketch_id)+ const enricher = selectedEnricher as Enricher+ if (enricher.params_schema?.length) {+ // Hand over to the params sheet; it launches on submit.+ setPendingLaunch({+ enricherName: enricher.name,+ paramsSchema: enricher.params_schema,+ nodeIds: values+ })+ } else {+ // For enrichers, use name+ launchEnricher(values, enricher.name, sketch_id)+ }} else {// For flows, use idlaunchFlow(values, (selectedEnricher as Flow).id, sketch_id)@@ -104,6 +119,15 @@ const LaunchEnricherOrFlowPanel = memo(handleCloseModal])+ const handleSubmitParams = useCallback(+ (params: Record<string, string>) => {+ if (!pendingLaunch) return+ launchEnricher(pendingLaunch.nodeIds, pendingLaunch.enricherName, sketch_id, params)+ setPendingLaunch(null)+ },+ [pendingLaunch, launchEnricher, sketch_id]+ )+if (disabled) return <>{children}</>return (<div>@@ -395,6 +419,11 @@ const LaunchEnricherOrFlowPanel = memo(</SheetFooter></SheetContent></Sheet>+ <EnricherParamsSheet+ pending={pendingLaunch}+ onOpenChange={(open) => !open && setPendingLaunch(null)}+ onSubmit={handleSubmitParams}+ /></div>)}diff --git a/flowsint-app/src/hooks/use-launch-enricher.ts b/flowsint-app/src/hooks/use-launch-enricher.tsindex aa8e9dd1..6c2c3506 100644--- a/flowsint-app/src/hooks/use-launch-enricher.ts+++ b/flowsint-app/src/hooks/use-launch-enricher.ts@@ -13,7 +13,8 @@ export function useLaunchEnricher(askUser: boolean = false) {const launchEnricher = async (node_ids: string[],enricherName: string,- sketch_id: string | null | undefined+ sketch_id: string | null | undefined,+ params?: Record<string, string>) => {if (!sketch_id) return toast.error('Could not find the graph.')if (askUser) {@@ -23,7 +24,9 @@ export function useLaunchEnricher(askUser: boolean = false) {})if (!confirmed) return}- const body = JSON.stringify({ node_ids, sketch_id })+ // Omitted rather than sent as null when the enricher declares no params,+ // so callers that never had params keep sending the exact same payload.+ const body = JSON.stringify(params ? { node_ids, sketch_id, params } : { node_ids, sketch_id })const count = node_ids.lengthtoast.promise(enricherService.launch(enricherName, body), {loading: 'Loading...',