Skip to content

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

feat(app): move toast to center

dextmorgne76b1ecb2ec1
diff --git a/flowsint-app/src/components/sketches/add-item-dialog.tsx b/flowsint-app/src/components/sketches/add-item-dialog.tsx
index 5aff9577..c92a21c2 100644
--- a/flowsint-app/src/components/sketches/add-item-dialog.tsx
+++ b/flowsint-app/src/components/sketches/add-item-dialog.tsx
@@ -30,6 +30,8 @@ export default function AddItemDialog() {
const setOpenMainDialog = useGraphStore((state) => state.setOpenMainDialog)
const openFormDialog = useGraphStore((state) => state.openFormDialog)
const setOpenFormDialog = useGraphStore((state) => state.setOpenFormDialog)
+ const regenerateLayout = useGraphControls((s) => s.regenerateLayout)
+ const currentLayoutType = useGraphControls((s) => s.currentLayoutType)
const addNode = useGraphStore((state) => state.addNode)
const addEdge = useGraphStore((state) => state.addEdge)
const replaceNode = useGraphStore((state) => state.replaceNode)
@@ -134,9 +136,15 @@ export default function AddItemDialog() {
setOpenMainDialog(false)
setOpenFormDialog(false)
// Show optimistic success message
- toast.success(
- relatedNodeToAdd ? `New relation added to ${relatedNodeToAdd.data.label}.` : 'New node added.'
- )
+ toast(`New ${type.toLowerCase()} added to sketch.`, {
+ description: relatedNodeToAdd
+ ? `A new ${type.toLowerCase()} "${label}" was added to relation ${relatedNodeToAdd.data.label}.`
+ : `A new ${type.toLowerCase()} "${label}" was added.`,
+ action: {
+ label: 'Beautify layout',
+ onClick: () => regenerateLayout(currentLayoutType)
+ }
+ })
// Make API calls in the background
try {
// Create the node via API to get the real database ID
diff --git a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx
index 0fa500c2..b22d3c03 100644
--- a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx
+++ b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx
@@ -1,7 +1,7 @@
-import { memo } from 'react'
+import { memo, useCallback } from 'react'
import { cn } from '@/lib/utils'
import { CopyButton } from '@/components/copy'
-import { Check, Rocket, X, MousePointer } from 'lucide-react'
+import { Check, Rocket, X, MousePointer, Link2 } from 'lucide-react'
import LaunchFlow from '../launch-enricher'
import NodeActions from '../graph/actions/node-actions'
import { Button } from '../../ui/button'
@@ -14,14 +14,21 @@ import { GraphNode } from '@/types'
import { useGraphStore } from '@/stores/graph-store'
import { Badge } from '@/components/ui/badge'
import DOMPurify from 'dompurify'
+import { useIcon } from '@/hooks/use-icon'
const DetailsPanel = memo(({ node }: { node: GraphNode | null }) => {
const { id: sketchId } = useParams({ strict: false })
const nodes = useGraphStore((s) => s.nodes)
+ const NodeIcon = useIcon(node?.data?.type || 'default')
+ const setCurrentNode = useGraphStore((s) => s.setCurrentNode)
node = nodes.find((n) => n.id === node?.id) || null
+
+ const handleClose = useCallback(() => {
+ setCurrentNode(null)
+ }, [])
if (!node) {
return (
- <div className="flex p-12 flex-col items-center justify-center h-full text-center p-8">
+ <div className="flex flex-col items-center justify-center h-full text-center p-8">
<div className="w-16 h-16 bg-muted rounded-full flex items-center justify-center mb-4">
<MousePointer className="h-8 w-8 text-muted-foreground" />
</div>
@@ -35,9 +42,15 @@ const DetailsPanel = memo(({ node }: { node: GraphNode | null }) => {
return (
<div className="flex flex-col h-full overflow-hidden bg-card">
- {/* <ItemHero node={node} /> */}
- <div className="flex items-center bg-card h-10 sticky w-full top-0 border-b justify-start px-4 gap-2 z-1">
- <p className="text-sm font-semibold truncate">{node.data?.label}</p>
+ <div className="flex items-center sticky w-full top-0 border-b justify-start pr-4 pl-2 py-2 h-10 gap-2 bg-card/90 backdrop-blur-md ">
+ <Button
+ onClick={handleClose}
+ size={'icon'}
+ variant={'ghost'}
+ className="h-7 w-7 hover:bg-accent rounded-full"
+ >
+ <X />
+ </Button>
<div className="grow" />
<div className="flex items-center">
<TooltipProvider>
@@ -63,6 +76,27 @@ const DetailsPanel = memo(({ node }: { node: GraphNode | null }) => {
<NodeActions node={node} />
</div>
</div>
+ <div className="px-4 pt-4 pb-4 border-b">
+ <div className="flex items-start gap-3">
+ {/* Icon */}
+ <div className="shrink-0">
+ <NodeIcon size={38} />
+ </div>
+
+ {/* Content */}
+ <div className="flex-1 min-w-0 space-y-2">
+ <div className="flex items-center gap-2 flex-wrap">
+ <h2 className="text-xl font-bold truncate">{node.data?.label}</h2>
+ <CopyButton className="h-4 w-4" content={node.data.label} />
+ </div>
+ {node.data?.type && (
+ <Badge variant="secondary" className="text-xs">
+ {node.data.type}
+ </Badge>
+ )}
+ </div>
+ </div>
+ </div>
<div className="flex-1 min-h-0">
<ResizablePanelGroup direction="vertical" className="h-full">
<ResizablePanel defaultSize={30} minSize={20}>
@@ -115,7 +149,10 @@ function KeyValueDisplay({ data, className }: KeyValueDisplayProps) {
{data &&
Object.entries(data)
.filter(
- ([key]) => !['id', 'sketch_id', 'caption', 'size', 'color', 'description', 'x', 'y'].includes(key)
+ ([key]) =>
+ !['id', 'sketch_id', 'caption', 'size', 'color', 'description', 'x', 'y'].includes(
+ key
+ )
)
.map(([key, value], index) => {
let val: string | null = null
@@ -123,8 +160,7 @@ function KeyValueDisplay({ data, className }: KeyValueDisplayProps) {
if (typeof value === 'number') {
val = value.toString()
display = <StatusCodeBadge statusCode={value} />
- }
- else if (typeof value === 'boolean') {
+ } else if (typeof value === 'boolean') {
val = value.toString()
display = value ? (
<Check className="h-4 w-4 text-green-600" />
@@ -132,7 +168,7 @@ function KeyValueDisplay({ data, className }: KeyValueDisplayProps) {
<X className="h-4 w-4 text-red-600" />
)
} else if (typeof value === 'object') {
- val = value?.["label"] ?? "N/A"
+ val = value?.['label'] ?? 'N/A'
display = val
} else if (Array.isArray(value)) {
val = `${value.length} items`
@@ -190,7 +226,7 @@ export function StatusCodeBadge({ statusCode }: StatusCodeBadgeProps) {
2: 'bg-green-100 text-green-800 border-green-300',
3: 'bg-purple-100 text-purple-800 border-purple-300',
4: 'bg-orange-100 text-orange-800 border-orange-300',
- 5: 'bg-red-100 text-red-800 border-red-300',
+ 5: 'bg-red-100 text-red-800 border-red-300'
}
const labels = {
@@ -198,16 +234,19 @@ export function StatusCodeBadge({ statusCode }: StatusCodeBadgeProps) {
2: 'Success',
3: 'Redirect',
4: 'Client Error',
- 5: 'Server Error',
+ 5: 'Server Error'
}
return (
<Badge
variant="outline"
- className={cn("text-xs", variants[category as keyof typeof variants] || 'bg-gray-100 text-gray-800')}
+ className={cn(
+ 'text-xs',
+ variants[category as keyof typeof variants] || 'bg-gray-100 text-gray-800'
+ )}
>
{statusCode}
{/* {labels[category as keyof typeof labels]} */}
</Badge>
)
-}
\ No newline at end of file
+}
diff --git a/flowsint-app/src/components/sketches/import-preview.tsx b/flowsint-app/src/components/sketches/import-preview.tsx
index e19777e2..bc846b39 100644
--- a/flowsint-app/src/components/sketches/import-preview.tsx
+++ b/flowsint-app/src/components/sketches/import-preview.tsx
@@ -355,7 +355,9 @@ export function ImportPreview({
}: ImportPreviewProps) {
const { actionItems, isLoading: isLoadingActionItems } = useActionItems()
const refetchGraph = useGraphControls((s) => s.refetchGraph)
- console.log(analysisResult)
+ const regenerateLayout = useGraphControls((s) => s.regenerateLayout)
+ const currentLayoutType = useGraphControls((s) => s.currentLayoutType)
+
const fieldsByType = useMemo(() => {
if (!actionItems) return {}
const fields: Record<string, string[]> = {}
@@ -407,7 +409,7 @@ export function ImportPreview({
entity_type: entity.detected_type,
include: true,
label: entity.obj.label,
- node_id: entity.node_id,
+ node_id: entity?.node_id?.toString(),
data
})
})
@@ -546,7 +548,14 @@ export function ImportPreview({
setTimeout(onSuccess, 2000)
refetchGraph()
setIsImporting(false)
- toast.success('Import successful!')
+ toast(`Import successful !`, {
+ duration: 6000,
+ description: `${result.nodes_created} entities were imported. You can now display them with the layout commands.`,
+ action: {
+ label: 'Beautify layout',
+ onClick: () => regenerateLayout(currentLayoutType)
+ }
+ })
}
} catch (error) {
setIsImporting(false)
@@ -649,7 +658,7 @@ export function ImportPreview({
className="flex-1 flex flex-col overflow-hidden"
>
<div className="px-4 pt-4">
- <TabsList className="w-full justify-start">
+ <TabsList className="w-full justify-start overflow-x-auto">
{typeNames.map((name) => (
<TabsTrigger key={name} value={name} className="flex-1">
{name} ({mappingsByType[name]?.length || 0})
diff --git a/flowsint-app/src/routes/__root.tsx b/flowsint-app/src/routes/__root.tsx
index 0b9def67..6bec186b 100644
--- a/flowsint-app/src/routes/__root.tsx
+++ b/flowsint-app/src/routes/__root.tsx
@@ -14,7 +14,7 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
const { theme } = useTheme()
return (
<TutorialProvider>
- <Toaster theme={theme} position="top-right" richColors />
+ <Toaster offset={{ top: '90px' }} theme={theme} position="top-center" />
<Outlet />
</TutorialProvider>
)
diff --git a/flowsint-app/src/stores/graph-controls-store.ts b/flowsint-app/src/stores/graph-controls-store.ts
index d7d28265..29e08006 100644
--- a/flowsint-app/src/stores/graph-controls-store.ts
+++ b/flowsint-app/src/stores/graph-controls-store.ts
@@ -34,21 +34,21 @@ export const useGraphControls = create<GraphControlsStore>()(
isSelectorModeActive: false,
selectionMode: 'lasso',
currentLayoutType: 'force',
- zoomToFit: () => { },
- zoomIn: () => { },
- zoomOut: () => { },
- zoomToSelection: () => { },
- centerOnNode: () => { },
- onLayout: () => { },
+ zoomToFit: () => {},
+ zoomIn: () => {},
+ zoomOut: () => {},
+ zoomToSelection: () => {},
+ centerOnNode: () => {},
+ onLayout: () => {},
setActions: (actions) => set(actions),
- refetchGraph: (onSuccess) => { },
- regenerateLayout: () => { },
+ refetchGraph: (onSuccess) => {},
+ regenerateLayout: () => {},
getViewportCenter: () => null,
setCurrentLayoutType: (layoutType) => set({ currentLayoutType: layoutType }),
setView: (view) => set({ view }),
setIsSelectorModeActive: (active) => set({ isSelectorModeActive: active }),
setSelectionMode: (mode) => set({ selectionMode: mode }),
- exportToPNG: async () => { }
+ exportToPNG: async () => {}
}),
{
name: 'graph-controls-storage',
diff --git a/flowsint-app/src/stores/graph-settings-store.ts b/flowsint-app/src/stores/graph-settings-store.ts
index 6e64e442..8b4fd323 100644
--- a/flowsint-app/src/stores/graph-settings-store.ts
+++ b/flowsint-app/src/stores/graph-settings-store.ts
@@ -56,7 +56,7 @@ const DEFAULT_SETTINGS = {
name: 'Node Weight Multiplier',
type: 'number',
value: 1.5,
- min: 1.0,
+ min: 0.1,
max: 8.0,
step: 0.01,
description: 'Defines how a node size varies depending on the weight (number of relations).'