Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

fix(app): render select params as a dropdown, drop dead settings, fix enricher list react key

dextmorgnc5c4535d0948
diff --git a/flowsint-app/src/components/flows/params-dialog.tsx b/flowsint-app/src/components/flows/params-dialog.tsx
index 170f768d..1e8b889a 100644
--- a/flowsint-app/src/components/flows/params-dialog.tsx
+++ b/flowsint-app/src/components/flows/params-dialog.tsx
@@ -5,6 +5,7 @@ import { useCallback, useState } from 'react'
import { EnricherParamSchemaItem } from '@/types'
import { Label } from '../ui/label'
import { Input } from '../ui/input'
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
import KeySelector from '../keys/key-select'
import { type Key } from '@/types/key'
import { useQuery } from '@tanstack/react-query'
@@ -19,24 +20,15 @@ const ParamsDialog = () => {
const selectedNode = useFlowStore((s) => s.selectedNode)
const updateNode = useFlowStore((s) => s.updateNode)
const [params, setParams] = useState<Record<string, string>>({})
- const [settings, setSettings] = useState<Record<string, string>>({
- duration: '30',
- retry: '3',
- timeout: '60',
- priority: 'medium'
- })
- // Initialize params and settings when selectedNode changes — adjusted
- // during render rather than in an effect.
+ // Initialize params when selectedNode changes — adjusted during render
+ // rather than in an effect.
const [prevSelectedNode, setPrevSelectedNode] = useState(selectedNode)
if (selectedNode !== prevSelectedNode) {
setPrevSelectedNode(selectedNode)
if (selectedNode?.data.params) {
setParams(selectedNode.data.params)
}
- if (selectedNode?.data.settings) {
- setSettings((prev) => ({ ...prev, ...selectedNode.data.settings }))
- }
}
// Fetch keys to convert between IDs and Key objects
@@ -51,13 +43,53 @@ const ParamsDialog = () => {
...selectedNode,
data: {
...selectedNode.data,
- params,
- settings
+ params
}
}
updateNode(updatedNode)
setOpenParamsDialog(false)
- }, [selectedNode, updateNode, params, settings, setOpenParamsDialog])
+ }, [selectedNode, updateNode, params, setOpenParamsDialog])
+
+ const renderField = (param: EnricherParamSchemaItem) => {
+ if (param.type === 'vaultSecret') {
+ return (
+ <KeySelector
+ onChange={(key) => setParams({ ...params, [param.name]: key.id })}
+ value={keys.find((key) => key.id === params[param.name])}
+ />
+ )
+ }
+
+ if (param.type === 'select' && param.options?.length) {
+ return (
+ <Select
+ value={params[param.name] || ''}
+ onValueChange={(value) => setParams({ ...params, [param.name]: value })}
+ >
+ <SelectTrigger id={param.name} className="w-full">
+ <SelectValue placeholder={`Select ${param.name}`} />
+ </SelectTrigger>
+ <SelectContent>
+ {param.options.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )
+ }
+
+ return (
+ <Input
+ id={param.name}
+ type={param.type}
+ placeholder={param.default ?? param.name}
+ value={params[param.name] || ''}
+ onChange={(e) => setParams({ ...params, [param.name]: e.target.value })}
+ />
+ )
+ }
if (!selectedNode) return
@@ -90,20 +122,7 @@ const ParamsDialog = () => {
</Label>
<p className="text-sm opacity-60">{param.description}</p>
</div>
- {param.type === 'vaultSecret' ? (
- <KeySelector
- onChange={(key) => setParams({ ...params, [param.name]: key.id })}
- value={keys.find((key) => key.id === params[param.name])}
- />
- ) : (
- <Input
- id={param.name}
- type={param.type}
- placeholder={param.default ?? param.name}
- value={params[param.name] || ''}
- onChange={(e) => setParams({ ...params, [param.name]: e.target.value })}
- />
- )}
+ {renderField(param)}
</div>
))}
</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.tsx
index bbb925a5..92e6892c 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
@@ -270,7 +270,7 @@ export default function BackgroundContextMenu({
<div className="p-1">
{filteredEnrichers.map((enricher: Enricher) => (
<button
- key={enricher.id}
+ key={enricher.name}
className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"
onClick={(e) => handleEnricherClick(e, enricher)}
>
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.tsx
index 62651423..62cb2ffe 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
@@ -213,7 +213,7 @@ export default function ContextMenu({
<div className="p-1">
{filteredEnrichers.map((enricher: Enricher) => (
<button
- key={enricher.id}
+ key={enricher.name}
className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"
onClick={(e) => handleEnricherClick(e, enricher)}
>
diff --git a/flowsint-app/src/types/enricher.ts b/flowsint-app/src/types/enricher.ts
index 3ad66b11..56d37b65 100644
--- a/flowsint-app/src/types/enricher.ts
+++ b/flowsint-app/src/types/enricher.ts
@@ -31,7 +31,6 @@ export interface Enricher {
required_params: boolean
params: Record<string, string>
params_schema: EnricherParamSchemaItem[]
- settings?: Record<string, string>
icon: string | null
wobblyType?: boolean
}