Skip to content

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

feat(app): added 'tags-input'. Changed the text input for aliases to tags-input in the details panel

bjst0neae81c216b0a0
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 46a3d1be..5e4ba358 100644
--- a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx
+++ b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx
@@ -33,6 +33,7 @@ import { Circle, Square, Triangle, Hexagon } from 'lucide-react'
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
import { Slider } from '@/components/ui/slider'
import { Button } from '@/components/ui/button'
+import { TagsInput } from '@/components/ui/tags-input'
// Types
type FormData = {
@@ -259,7 +260,7 @@ const DetailsPanel = memo(() => {
setHasChanges(true)
}, [])
- const handlePropertyChange = useCallback((key: string, value: string | boolean) => {
+ const handlePropertyChange = useCallback((key: string, value: string | string[] | boolean) => {
setFormData((prev) => ({
...prev,
nodeProperties: { ...prev.nodeProperties, [key]: value }
@@ -384,6 +385,12 @@ const DetailsPanel = memo(() => {
</a>
) : value && value.constructor === Object ? (
<PopoverProperty label={key} property={value} />
+ ) : key === 'aliases' ? (
+ <TagsInput
+ value={value || []}
+ onChange={(tags) => handlePropertyChange(key, tags)}
+ orientation='vertical'
+ />
) : (
<input
type="text"
diff --git a/flowsint-app/src/components/ui/tags-input.tsx b/flowsint-app/src/components/ui/tags-input.tsx
new file mode 100644
index 00000000..8a3b5cb3
--- /dev/null
+++ b/flowsint-app/src/components/ui/tags-input.tsx
@@ -0,0 +1,92 @@
+// src/components/ui/tags-input.tsx
+import * as React from 'react';
+import { X } from 'lucide-react';
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { cn } from '@/lib/utils';
+
+interface TagsInputProps extends React.HTMLAttributes<HTMLDivElement> {
+ value: string[];
+ onChange: (tags: string[]) => void;
+ placeholder?: string;
+ disabled?: boolean;
+ orientation: 'vertical' | 'horizontal';
+}
+
+function TagsInput({
+ value,
+ onChange,
+ placeholder = "Input new tag...",
+ disabled = false,
+ orientation = 'vertical',
+ className,
+ ...props
+}: TagsInputProps) {
+ const [inputValue, setInputValue] = React.useState("");
+
+ const addTag = () => {
+ const trimmed = inputValue.trim();
+ if (trimmed && !value.includes(trimmed)) {
+ onChange([...value, trimmed]);
+ }
+ setInputValue("");
+ };
+
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
+ if (e.key === "Enter" || e.key === ",") {
+ e.preventDefault();
+ addTag();
+ }
+ };
+
+ const removeTag = (tagToRemove: string) => {
+ onChange(value.filter((tag) => tag !== tagToRemove));
+ };
+
+ return (
+ <div
+ className={cn(
+ "flex items-center gap-2 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
+ orientation === 'horizontal'
+ ? "flex-wrap items-center gap-2"
+ : "flex-col items-end gap-2",
+ disabled && "cursor-not-allowed opacity-50",
+ className
+ )}
+ {...props}
+ >
+ {value.map((tag) => (
+ <Badge key={tag} variant="secondary" className="gap-1">
+ {tag}
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-4 w-4 p-0 hover:bg-transparent"
+ onClick={() => removeTag(tag)}
+ disabled={disabled}
+ >
+ <X className="h-3 w-3" />
+ <span className="sr-only">Delete tag {tag}</span>
+ </Button>
+ </Badge>
+ ))}
+ <Input
+ type="text"
+ value={inputValue}
+ onChange={(e) => setInputValue(e.target.value)}
+ onKeyDown={handleKeyDown}
+ onBlur={addTag}
+ placeholder={placeholder}
+ disabled={disabled}
+ className={cn(
+ "flex-1 border-0 bg-transparent p-0 text-sm outline-none focus-visible:ring-0 focus-visible:ring-offset-0",
+ "text-center"
+ )}
+ />
+ </div>
+ );
+}
+
+export { TagsInput }
\ No newline at end of file