A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat(app): RBAC permission gating, share dialog, profile page and user display
dextmorgnf5e6fb79ae11
diff --git a/flowsint-app/src/api/auth-service.ts b/flowsint-app/src/api/auth-service.tsindex d4b5a01d..488816e7 100644--- a/flowsint-app/src/api/auth-service.ts+++ b/flowsint-app/src/api/auth-service.ts@@ -49,6 +49,17 @@ export const authService = {},getCurrentUser: async () => {- return fetchWithAuth('/api/users/me')+ return fetchWithAuth('/api/auth/me')+ },++ updateProfile: async (data: { first_name?: string; last_name?: string; avatar_url?: string }) => {+ return fetchWithAuth('/api/auth/me', {+ method: 'PUT',+ body: JSON.stringify(data)+ })+ },++ searchUsers: async (query: string) => {+ return fetchWithAuth(`/api/auth/users/search?q=${encodeURIComponent(query)}`)}}diff --git a/flowsint-app/src/api/investigation-service.ts b/flowsint-app/src/api/investigation-service.tsindex a5fd1f70..3fdb1ef7 100644--- a/flowsint-app/src/api/investigation-service.ts+++ b/flowsint-app/src/api/investigation-service.ts@@ -21,5 +21,29 @@ export const investigationService = {return fetchWithAuth(`/api/investigations/${investigationId}`, {method: 'DELETE'})+ },++ // Collaborator management+ getCollaborators: async (investigationId: string): Promise<any> => {+ return fetchWithAuth(`/api/investigations/${investigationId}/collaborators`, {+ method: 'GET'+ })+ },+ addCollaborator: async (investigationId: string, body: { email: string; role: string }): Promise<any> => {+ return fetchWithAuth(`/api/investigations/${investigationId}/collaborators`, {+ method: 'POST',+ body: JSON.stringify(body)+ })+ },+ updateCollaboratorRole: async (investigationId: string, userId: string, body: { role: string }): Promise<any> => {+ return fetchWithAuth(`/api/investigations/${investigationId}/collaborators/${userId}`, {+ method: 'PUT',+ body: JSON.stringify(body)+ })+ },+ removeCollaborator: async (investigationId: string, userId: string): Promise<any> => {+ return fetchWithAuth(`/api/investigations/${investigationId}/collaborators/${userId}`, {+ method: 'DELETE'+ })}}diff --git a/flowsint-app/src/api/query-keys.ts b/flowsint-app/src/api/query-keys.tsindex a4cf102c..61ed36b3 100644--- a/flowsint-app/src/api/query-keys.ts+++ b/flowsint-app/src/api/query-keys.ts@@ -13,6 +13,7 @@ export const queryKeys = {sketches: (investigationId: string) => [investigationId, 'sketches'],analyses: (investigationId: string) => [investigationId, 'analyses'],flows: (investigationId: string) => [investigationId, 'flows'],+ collaborators: (investigationId: string) => ['investigations', investigationId, 'collaborators'],dashboard: ['investigations', 'dashboard'],selector: (investigationId: string) => ['dashboard', 'selector', investigationId]},diff --git a/flowsint-app/src/components/analyses/analysis-editor.tsx b/flowsint-app/src/components/analyses/analysis-editor.tsxindex aef3d787..c57be4d7 100644--- a/flowsint-app/src/components/analyses/analysis-editor.tsx+++ b/flowsint-app/src/components/analyses/analysis-editor.tsx@@ -19,6 +19,7 @@ import { useConfirm } from '../use-confirm-dialog'import { Editor } from '@tiptap/core'import { Link, useParams } from '@tanstack/react-router'import { useLayoutStore } from '@/stores/layout-store'+import { usePermissions } from '@/hooks/use-can'import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'import {DropdownMenu,@@ -78,6 +79,7 @@ export const AnalysisEditor = ({showToolbar = false}: AnalysisEditorProps) => {const { confirm } = useConfirm()+ const { canEdit } = usePermissions()const toggleAnalysis = useLayoutStore((s) => s.toggleAnalysis)const { investigationId: routeInvestigationId, type } = useParams({ strict: false }) as {investigationId: string@@ -318,7 +320,7 @@ export const AnalysisEditor = ({{/* Title section */}<div className="flex items-center gap-2 flex-1 min-w-0">- {isEditingTitle ? (+ {canEdit && isEditingTitle ? (<inputclassName="text-md font-medium bg-transparent outline-none border-none p-0 m-0 w-full"value={titleValue}@@ -340,8 +342,8 @@ export const AnalysisEditor = ({/>) : (<span- className={`text-md font-medium truncate min-w-0 flex-1 ${'cursor-pointer hover:text-primary'}`}- onClick={() => setIsEditingTitle(true)}+ className={`text-md font-medium truncate min-w-0 flex-1 ${canEdit ? 'cursor-pointer hover:text-primary' : ''}`}+ onClick={canEdit ? () => setIsEditingTitle(true) : undefined}>{titleValue || 'Untitled Analysis'}</span>@@ -350,7 +352,7 @@ export const AnalysisEditor = ({</div>{/* Action buttons */}- {showActions && (+ {showActions && canEdit && (<div className="flex items-center gap-1"><SaveStatusBadge status={saveStatus} /><DropdownMenu>@@ -426,29 +428,32 @@ export const AnalysisEditor = ({}return content || ''})()}- onChange={handleEditorChange}+ onChange={canEdit ? handleEditorChange : undefined}className="w-full h-full"editorContentClassName="p-5 min-h-[300px]"output="json"- placeholder={'Enter your analysis...'}- autofocus={true}- showToolbar={showToolbar}+ placeholder={canEdit ? 'Enter your analysis...' : ''}+ autofocus={canEdit}+ showToolbar={canEdit && showToolbar}editorClassName="focus:outline-hidden"onEditorReady={setEditor}+ editable={canEdit}/></div>) : (<div className="flex flex-col items-center justify-center h-full text-muted-foreground space-y-3"><div>No analysis selected.</div>- <Button- className="shadow-none"- variant="outline"- onClick={() => createMutation.mutate()}- disabled={createMutation.isPending}- >- <PlusIcon className="w-4 h-4 mr-2" strokeWidth={1.5} />- Create your first analysis- </Button>+ {canEdit && (+ <Button+ className="shadow-none"+ variant="outline"+ onClick={() => createMutation.mutate()}+ disabled={createMutation.isPending}+ >+ <PlusIcon className="w-4 h-4 mr-2" strokeWidth={1.5} />+ Create your first analysis+ </Button>+ )}</div>)}</div>diff --git a/flowsint-app/src/components/dashboard/investigation/analyses-section.tsx b/flowsint-app/src/components/dashboard/investigation/analyses-section.tsxindex 616cd99a..91fe32c9 100644--- a/flowsint-app/src/components/dashboard/investigation/analyses-section.tsx+++ b/flowsint-app/src/components/dashboard/investigation/analyses-section.tsx@@ -8,19 +8,22 @@ import { Link } from "@tanstack/react-router"interface AnalysesSectionProps {analyses: Analysis[]+ canCreate?: boolean}-export function AnalysesSection({ analyses }: AnalysesSectionProps) {+export function AnalysesSection({ analyses, canCreate = true }: AnalysesSectionProps) {return (<section><div className="flex items-center justify-between mb-4"><h2 className="text-sm font-medium text-foreground">Analyses</h2>- <NewAnalysis>- <Button variant="ghost" size="sm" className="h-7 text-xs text-muted-foreground hover:text-foreground gap-1">- <Plus className="w-3.5 h-3.5" />- New- </Button>- </NewAnalysis>+ {canCreate && (+ <NewAnalysis>+ <Button variant="ghost" size="sm" className="h-7 text-xs text-muted-foreground hover:text-foreground gap-1">+ <Plus className="w-3.5 h-3.5" />+ New+ </Button>+ </NewAnalysis>+ )}</div>{analyses.length === 0 ?diff --git a/flowsint-app/src/components/dashboard/investigation/case-header.tsx b/flowsint-app/src/components/dashboard/investigation/case-header.tsxindex 2a580653..7f6e0f73 100644--- a/flowsint-app/src/components/dashboard/investigation/case-header.tsx+++ b/flowsint-app/src/components/dashboard/investigation/case-header.tsx@@ -7,17 +7,20 @@ import {DropdownMenuTrigger,} from "@/components/ui/dropdown-menu"import { MoreHorizontal, Star, Share, Trash2, Clock } from "lucide-react"-import { Investigation } from "@/types"+import { Investigation, Collaborator } from "@/types"import { formatDistanceToNow } from "date-fns"import { useState } from "react"import { cn } from "@/lib/utils"import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"-import { useQueryClient } from "@tanstack/react-query"+import { useQuery, useQueryClient } from "@tanstack/react-query"import { investigationService } from "@/api/investigation-service"import { useConfirm } from "@/components/use-confirm-dialog"import { queryKeys } from "@/api/query-keys"import { toast } from "sonner"import { Link, useRouter } from "@tanstack/react-router"+import { usePermissions } from "@/hooks/use-can"+import { ShareDialog } from "./share-dialog"+import { getInitials } from "@/lib/user-display"type CaseOverviewPageProps = {investigation: Investigation@@ -28,10 +31,16 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {addSuffix: true})const router = useRouter()+ const { canDelete, canManage } = usePermissions()const { confirm } = useConfirm()const queryClient = useQueryClient()+ const { data: collaborators = [] } = useQuery<Collaborator[]>({+ queryKey: queryKeys.investigations.collaborators(investigation.id),+ queryFn: () => investigationService.getCollaborators(investigation.id),+ })+const handleDeleteInvestigation = async () => {const confirmed = await confirm({title: 'Delete Investigation',@@ -41,13 +50,9 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {if (confirmed) {const deletePromise = () =>investigationService.delete(investigation.id).then(() => {- ''- // Invalidate the investigations listqueryClient.invalidateQueries({queryKey: queryKeys.investigations.list})-- // Also remove related data from cachequeryClient.removeQueries({queryKey: queryKeys.investigations.detail(investigation.id)})@@ -73,7 +78,7 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {return (<div className="space-y-6 pb-6 border-b border-border">- {/* Breadcrumb - subtle */}+ {/* Breadcrumb */}<div className="flex items-center gap-1.5 text-sm text-muted-foreground"><Link to={"/dashboard"} className="hover:text-foreground cursor-pointer transition-colors">Cases</Link><span>/</span>@@ -88,7 +93,7 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {<FavoriteButton /></div>- {/* Inline properties - Notion style */}+ {/* Inline properties */}<div className="flex items-center gap-4 text-sm"><PropertyPill label="Status" value={investigation.status} valueClass="text-success" /><PropertyPill label="Priority" value="Medium" valueClass="text-primary" />@@ -96,51 +101,51 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {</div></div>- {/* Actions - minimal */}+ {/* Actions */}<div className="flex items-center gap-1">- {/* <Button variant="ghost" size="sm" className="text-muted-foreground h-8 px-2">- <Share className="w-4 h-4" />- </Button> */}- <DropdownMenu>- <DropdownMenuTrigger asChild>+ {canManage && (+ <ShareDialog investigationId={investigation.id}><Button variant="ghost" size="sm" className="text-muted-foreground h-8 px-2">- <MoreHorizontal className="w-4 h-4" />+ <Share className="w-4 h-4" /></Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end" className="w-48">- {/* <DropdownMenuItem>Export as PDF</DropdownMenuItem>- <DropdownMenuItem>Duplicate</DropdownMenuItem> */}- {/* <DropdownMenuSeparator /> */}- <DropdownMenuItem onClick={handleDeleteInvestigation} className="text-destructive">- <Trash2 className="w-4 h-4 mr-2" />- Delete- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>+ </ShareDialog>+ )}+ {canDelete && (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="ghost" size="sm" className="text-muted-foreground h-8 px-2">+ <MoreHorizontal className="w-4 h-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-48">+ <DropdownMenuItem onClick={handleDeleteInvestigation} className="text-destructive">+ <Trash2 className="w-4 h-4 mr-2" />+ Delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}</div></div>- {/* Tags row */}- {/* <div className="flex items-center gap-2 flex-wrap">- <Tag>APT</Tag>- <Tag>Nation-State</Tag>- <Tag>Supply Chain</Tag>- <Tag>SolarWinds</Tag>- <button className="text-xs text-muted-foreground hover:text-foreground transition-colors">+ Add tag</button>- </div> */}-{/* Team */}<div className="flex items-center gap-2"><div className="flex -space-x-1.5">- <Avatar className="h-5 w-5">- <AvatarImage src="https://cherry.img.pmdstatic.net/fit/https.3A.2F.2Fimg.2Egamesider.2Ecom.2Fs3.2Ffrgsg.2F1280.2Fthe-last-of-us.2Fdefault_2023-11-27_291826c8-5b2b-4928-a167-259dd0b18a7c.2Ejpeg/1200x675/quality/80/the-last-of-us-saison-2-mauvaise-nouvelle-pedro-pascal.jpg" />- <AvatarFallback>U</AvatarFallback>- </Avatar>- {/* <Avatar initials="SK" />- <Avatar initials="MR" /> */}+ {collaborators.map((collab) => (+ <Avatar key={collab.id} className="h-5 w-5 border border-background">+ {collab.user?.avatar_url && <AvatarImage src={collab.user.avatar_url} />}+ <AvatarFallback className="text-[10px]">{getInitials(collab.user)}</AvatarFallback>+ </Avatar>+ ))}</div>- <span className="text-sm text-muted-foreground">1 investigator</span>- {/* <button disabled className="text-xs text-muted-foreground hover:text-foreground transition-colors ml-1">+ Invite</button> */}+ <span className="text-sm text-muted-foreground">+ {collaborators.length} investigator{collaborators.length !== 1 ? 's' : ''}+ </span>+ {canManage && (+ <ShareDialog investigationId={investigation.id}>+ <button className="text-xs text-muted-foreground hover:text-foreground transition-colors ml-1">+ Invite</button>+ </ShareDialog>+ )}</div></div>)diff --git a/flowsint-app/src/components/dashboard/investigation/case-overview-page.tsx b/flowsint-app/src/components/dashboard/investigation/case-overview-page.tsxindex 373d7609..6970649b 100644--- a/flowsint-app/src/components/dashboard/investigation/case-overview-page.tsx+++ b/flowsint-app/src/components/dashboard/investigation/case-overview-page.tsx@@ -1,36 +1,24 @@import { CaseHeader } from "./case-header"-// import { MetricsGrid } from "./metrics-grid"-// import { ActivityTimeline } from "./activity-timeline"import { SketchesSection } from "./sketches-section"import { AnalysesSection } from "./analyses-section"-// import { EvidenceSection } from "./evidence-section"-// import { TasksSection } from "./tasks-section"import { Investigation } from "@/types"+import { usePermissions } from "@/hooks/use-can"type CaseOverviewPageProps = {investigation: Investigation}export function CaseOverviewPage({ investigation }: CaseOverviewPageProps) {+ const { canCreate } = usePermissions()return (<main className="flex-1 h-full overflow-auto"><div className="max-w-7xl mx-auto px-8 py-8"><CaseHeader investigation={investigation} />- {/* <MetricsGrid investigation={investigation} /> */}<div className="space-y-8">- <SketchesSection sketches={investigation.sketches} />- <AnalysesSection analyses={investigation.analyses} />-- {/* Two column for smaller sections */}- {/* <div className="grid grid-cols-1 lg:grid-cols-2 gap-8">- <EvidenceSection />- <div className="space-y-8">- <TasksSection />- <ActivityTimeline />- </div>- </div> */}+ <SketchesSection sketches={investigation.sketches} canCreate={canCreate} />+ <AnalysesSection analyses={investigation.analyses} canCreate={canCreate} /></div></div></main>diff --git a/flowsint-app/src/components/dashboard/investigation/share-dialog.tsx b/flowsint-app/src/components/dashboard/investigation/share-dialog.tsxnew file mode 100644index 00000000..4aca5e3b--- /dev/null+++ b/flowsint-app/src/components/dashboard/investigation/share-dialog.tsx@@ -0,0 +1,268 @@+import { useState, useCallback, useRef, useEffect } from 'react'+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'+import { investigationService } from '@/api/investigation-service'+import { authService } from '@/api/auth-service'+import { queryKeys } from '@/api/query-keys'+import { toast } from 'sonner'+import type { Collaborator, InvestigationRole, Profile } from '@/types'+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+ DialogTrigger,+} from '@/components/ui/dialog'+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@/components/ui/select'+import { Button } from '@/components/ui/button'+import { Input } from '@/components/ui/input'+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'+import { X, UserPlus, Crown, Shield, Pencil, Eye } from 'lucide-react'+import { getDisplayName, getInitials } from '@/lib/user-display'++const ROLE_OPTIONS: { value: InvestigationRole; label: string; icon: typeof Eye }[] = [+ { value: 'admin', label: 'Admin', icon: Shield },+ { value: 'editor', label: 'Editor', icon: Pencil },+ { value: 'viewer', label: 'Viewer', icon: Eye },+]++function getRoleFromCollaborator(collab: Collaborator): InvestigationRole {+ return (collab.roles[0] ?? 'viewer') as InvestigationRole+}++interface ShareDialogProps {+ investigationId: string+ children: React.ReactNode+}++export function ShareDialog({ investigationId, children }: ShareDialogProps) {+ const [open, setOpen] = useState(false)+ const [query, setQuery] = useState('')+ const [selectedEmail, setSelectedEmail] = useState('')+ const [role, setRole] = useState<string>('editor')+ const [suggestions, setSuggestions] = useState<Profile[]>([])+ const [showSuggestions, setShowSuggestions] = useState(false)+ const debounceRef = useRef<NodeJS.Timeout | null>(null)+ const queryClient = useQueryClient()++ const { data: collaborators = [], isLoading } = useQuery<Collaborator[]>({+ queryKey: queryKeys.investigations.collaborators(investigationId),+ queryFn: () => investigationService.getCollaborators(investigationId),+ enabled: open,+ })++ // Debounced user search+ const handleQueryChange = useCallback((value: string) => {+ setQuery(value)+ setSelectedEmail(value)+ if (debounceRef.current) clearTimeout(debounceRef.current)+ if (value.length < 2) {+ setSuggestions([])+ setShowSuggestions(false)+ return+ }+ debounceRef.current = setTimeout(async () => {+ try {+ const results = await authService.searchUsers(value)+ setSuggestions(results)+ setShowSuggestions(results.length > 0)+ } catch {+ setSuggestions([])+ setShowSuggestions(false)+ }+ }, 300)+ }, [])++ useEffect(() => {+ return () => { if (debounceRef.current) clearTimeout(debounceRef.current) }+ }, [])++ const handleSelectUser = (user: Profile) => {+ setSelectedEmail(user.email ?? '')+ setQuery(getDisplayName(user))+ setShowSuggestions(false)+ setSuggestions([])+ }++ const addMutation = useMutation({+ mutationFn: (body: { email: string; role: string }) =>+ investigationService.addCollaborator(investigationId, body),+ onSuccess: () => {+ queryClient.invalidateQueries({+ queryKey: queryKeys.investigations.collaborators(investigationId),+ })+ setQuery('')+ setSelectedEmail('')+ toast.success('Collaborator added')+ },+ onError: (error: any) => {+ const message = error?.message || 'Failed to add collaborator'+ toast.error(message)+ },+ })++ const updateMutation = useMutation({+ mutationFn: ({ userId, role }: { userId: string; role: string }) =>+ investigationService.updateCollaboratorRole(investigationId, userId, { role }),+ onSuccess: () => {+ queryClient.invalidateQueries({+ queryKey: queryKeys.investigations.collaborators(investigationId),+ })+ toast.success('Role updated')+ },+ onError: () => toast.error('Failed to update role'),+ })++ const removeMutation = useMutation({+ mutationFn: (userId: string) =>+ investigationService.removeCollaborator(investigationId, userId),+ onSuccess: () => {+ queryClient.invalidateQueries({+ queryKey: queryKeys.investigations.collaborators(investigationId),+ })+ toast.success('Collaborator removed')+ },+ onError: () => toast.error('Failed to remove collaborator'),+ })++ const handleInvite = () => {+ if (!selectedEmail.trim()) return+ addMutation.mutate({ email: selectedEmail.trim(), role })+ }++ return (+ <Dialog open={open} onOpenChange={setOpen}>+ <DialogTrigger asChild>{children}</DialogTrigger>+ <DialogContent className="sm:max-w-md">+ <DialogHeader>+ <DialogTitle>Share investigation</DialogTitle>+ </DialogHeader>++ {/* Invite form */}+ <div className="flex items-center gap-2">+ <div className="relative flex-1">+ <Input+ placeholder="Search by email..."+ value={query}+ onChange={(e) => handleQueryChange(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Enter') { handleInvite(); setShowSuggestions(false) }+ if (e.key === 'Escape') setShowSuggestions(false)+ }}+ onFocus={() => suggestions.length > 0 && setShowSuggestions(true)}+ />+ {showSuggestions && suggestions.length > 0 && (+ <div className="absolute z-50 top-full mt-1 w-full rounded-md border bg-popover shadow-md overflow-hidden">+ {suggestions.map((user) => (+ <button+ key={user.id}+ className="w-full flex items-center gap-2.5 px-3 py-2 text-sm hover:bg-accent text-left transition-colors"+ onMouseDown={(e) => { e.preventDefault(); handleSelectUser(user) }}+ >+ <Avatar className="h-6 w-6 shrink-0">+ {user.avatar_url && <AvatarImage src={user.avatar_url} />}+ <AvatarFallback className="text-[10px]">{getInitials(user)}</AvatarFallback>+ </Avatar>+ <div className="flex-1 min-w-0">+ <p className="truncate text-sm">{getDisplayName(user)}</p>+ {user.email && <p className="truncate text-xs text-muted-foreground">{user.email}</p>}+ </div>+ </button>+ ))}+ </div>+ )}+ </div>+ <Select value={role} onValueChange={setRole}>+ <SelectTrigger className="w-28">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {ROLE_OPTIONS.map((opt) => (+ <SelectItem key={opt.value} value={opt.value}>+ {opt.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <Button+ size="sm"+ onClick={handleInvite}+ disabled={!selectedEmail.trim() || addMutation.isPending}+ >+ <UserPlus className="w-4 h-4" />+ </Button>+ </div>++ {/* Collaborators list */}+ <div className="mt-2 space-y-1 max-h-64 overflow-y-auto">+ {isLoading ? (+ <div className="py-4 text-center text-sm text-muted-foreground">Loading...</div>+ ) : collaborators.length === 0 ? (+ <div className="py-4 text-center text-sm text-muted-foreground">No collaborators yet</div>+ ) : (+ collaborators.map((collab) => {+ const isOwner = getRoleFromCollaborator(collab) === 'owner'+ return (+ <div+ key={collab.id}+ className="flex items-center gap-3 py-2 px-1 rounded-md hover:bg-muted/50 transition-colors"+ >+ <Avatar className="h-7 w-7">+ {collab.user?.avatar_url && <AvatarImage src={collab.user.avatar_url} />}+ <AvatarFallback className="text-xs">+ {getInitials(collab.user)}+ </AvatarFallback>+ </Avatar>+ <div className="flex-1 min-w-0">+ <p className="text-sm font-medium truncate">+ {getDisplayName(collab.user)}+ </p>+ </div>+ {isOwner ? (+ <div className="flex items-center gap-1 text-xs text-muted-foreground px-2">+ <Crown className="w-3 h-3" />+ Owner+ </div>+ ) : (+ <>+ <Select+ value={getRoleFromCollaborator(collab)}+ onValueChange={(newRole) =>+ updateMutation.mutate({ userId: collab.user_id, role: newRole })+ }+ >+ <SelectTrigger className="w-24 h-7 text-xs">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {ROLE_OPTIONS.map((opt) => (+ <SelectItem key={opt.value} value={opt.value}>+ {opt.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <Button+ variant="ghost"+ size="icon"+ className="h-7 w-7 text-muted-foreground hover:text-destructive"+ onClick={() => removeMutation.mutate(collab.user_id)}+ >+ <X className="w-3.5 h-3.5" />+ </Button>+ </>+ )}+ </div>+ )+ })+ )}+ </div>+ </DialogContent>+ </Dialog>+ )+}diff --git a/flowsint-app/src/components/dashboard/investigation/sketches-section.tsx b/flowsint-app/src/components/dashboard/investigation/sketches-section.tsxindex 6c521a5a..ec8bab95 100644--- a/flowsint-app/src/components/dashboard/investigation/sketches-section.tsx+++ b/flowsint-app/src/components/dashboard/investigation/sketches-section.tsx@@ -9,16 +9,17 @@ import NewSketch from "@/components/sketches/new-sketch"interface SketchesSectionProps {sketches: Sketch[]+ canCreate?: boolean}-export function SketchesSection({ sketches }: SketchesSectionProps) {+export function SketchesSection({ sketches, canCreate = true }: SketchesSectionProps) {const isEmpty = sketches.length === 0return (<section className="my-4"><div className="flex items-center justify-between mb-4"><h2 className="text-sm font-medium text-foreground">Sketches</h2>- {!isEmpty && (+ {!isEmpty && canCreate && (<NewSketch><Button variant="ghost" size="sm" className="h-7 text-xs text-muted-foreground hover:text-foreground gap-1"><Plus className="w-3.5 h-3.5" />@@ -29,7 +30,7 @@ export function SketchesSection({ sketches }: SketchesSectionProps) {</div>{isEmpty ? (- <EmptySketches onAction={() => console.log("Create sketch")} />+ canCreate ? <EmptySketches onAction={() => console.log("Create sketch")} /> : <div className="text-sm text-muted-foreground py-4">No sketches yet.</div>) : (<div className="grid grid-cols-2 md:grid-cols-4 gap-3">{sketches.map((sketch) => (diff --git a/flowsint-app/src/components/layout/top-navbar.tsx b/flowsint-app/src/components/layout/top-navbar.tsxindex b00110b3..63db5b20 100644--- a/flowsint-app/src/components/layout/top-navbar.tsx+++ b/flowsint-app/src/components/layout/top-navbar.tsx@@ -26,6 +26,7 @@ import { useConfirm } from '../use-confirm-dialog'import { sketchService } from '@/api/sketch-service'import { toast } from 'sonner'import { useKeyboardShortcut } from '@/hooks/use-keyboard-shortcut'+import { usePermissions } from '@/hooks/use-can'export const TopNavbar = memo(() => {const { investigationId, id, type } = useParams({ strict: false })@@ -85,6 +86,7 @@ export function InvestigationMenu({investigationId?: stringsketchId: string}) {+ const { canEdit } = usePermissions()const toggleSettingsModal = useGraphSettingsStore((s) => s.toggleSettingsModal)const toggleKeyboardShortcutsModal = useGraphSettingsStore((s) => s.toggleKeyboardShortcutsModal)const setImportModalOpen = useGraphSettingsStore((s) => s.setImportModalOpen)@@ -175,15 +177,18 @@ export function InvestigationMenu({</a></DropdownMenuItem><DropdownMenuItem disabled>API</DropdownMenuItem>- <DropdownMenuSeparator />- <DropdownMenuItem onClick={() => setImportModalOpen(true)}>- <Upload /> Import entities- </DropdownMenuItem>- <DropdownMenuSeparator />- <DropdownMenuItem onClick={handleDelete} variant="destructive">- Delete sketch- {/* <DropdownMenuShortcut>⇧⌘Q</DropdownMenuShortcut> */}- </DropdownMenuItem>+ {canEdit && (+ <>+ <DropdownMenuSeparator />+ <DropdownMenuItem onClick={() => setImportModalOpen(true)}>+ <Upload /> Import entities+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem onClick={handleDelete} variant="destructive">+ Delete sketch+ </DropdownMenuItem>+ </>+ )}</DropdownMenuContent><ImportSheet sketchId={sketchId} /></DropdownMenu>diff --git a/flowsint-app/src/components/nav-user.tsx b/flowsint-app/src/components/nav-user.tsxindex 1f0f6198..89aa048f 100644--- a/flowsint-app/src/components/nav-user.tsx+++ b/flowsint-app/src/components/nav-user.tsx@@ -1,4 +1,4 @@-import { LogOut } from 'lucide-react'+import { LogOut, UserIcon } from 'lucide-react'import {DropdownMenu,DropdownMenuContent,@@ -11,11 +11,17 @@ import { Button } from './ui/button'import { ModeToggle } from './mode-toggle'import { authService } from '@/api/auth-service'import { useCallback } from 'react'-import { useNavigate } from '@tanstack/react-router'-import { Avatar, AvatarImage, AvatarFallback } from './ui/avatar'+import { Link, useNavigate } from '@tanstack/react-router'+import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar'+import { useAuthStore } from '@/stores/auth-store'+import { getDisplayName, getInitials } from '@/lib/user-display'export function NavUser() {const navigate = useNavigate()+ const user = useAuthStore((s) => s.user)+ const displayName = getDisplayName(user)+ const initials = getInitials(user)+const logout = useCallback(() => {authService.logout()navigate({ to: '/login' })@@ -27,8 +33,8 @@ export function NavUser() {<div className="h-auto flex items-center justify-center"><Button size="lg" className="p-0 h-auto rounded-full cursor-pointer"><Avatar>- <AvatarImage src="https://cherry.img.pmdstatic.net/fit/https.3A.2F.2Fimg.2Egamesider.2Ecom.2Fs3.2Ffrgsg.2F1280.2Fthe-last-of-us.2Fdefault_2023-11-27_291826c8-5b2b-4928-a167-259dd0b18a7c.2Ejpeg/1200x675/quality/80/the-last-of-us-saison-2-mauvaise-nouvelle-pedro-pascal.jpg" />- <AvatarFallback>U</AvatarFallback>+ {user?.avatar_url && <AvatarImage src={user.avatar_url} />}+ <AvatarFallback>{initials}</AvatarFallback></Avatar></Button></div>@@ -41,10 +47,13 @@ export function NavUser() {<DropdownMenuLabel className="p-0 font-normal"><div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm"><Avatar>- <AvatarImage src="https://cherry.img.pmdstatic.net/fit/https.3A.2F.2Fimg.2Egamesider.2Ecom.2Fs3.2Ffrgsg.2F1280.2Fthe-last-of-us.2Fdefault_2023-11-27_291826c8-5b2b-4928-a167-259dd0b18a7c.2Ejpeg/1200x675/quality/80/the-last-of-us-saison-2-mauvaise-nouvelle-pedro-pascal.jpg" />- <AvatarFallback>U</AvatarFallback>+ {user?.avatar_url && <AvatarImage src={user.avatar_url} />}+ <AvatarFallback>{initials}</AvatarFallback></Avatar>- <div className="grid flex-1 text-left text-sm leading-tight"></div>+ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-medium">{displayName}</span>+ {user?.email && <span className="truncate text-xs text-muted-foreground">{user.email}</span>}+ </div></div></DropdownMenuLabel><DropdownMenuLabel className="text-xs font-light opacity-60">Preferences</DropdownMenuLabel>@@ -53,6 +62,12 @@ export function NavUser() {<ModeToggle /></div><DropdownMenuSeparator />+ <DropdownMenuItem asChild>+ <Link to="/dashboard/profile">+ <UserIcon />+ Profile+ </Link>+ </DropdownMenuItem><DropdownMenuItem onClick={logout}><LogOut />Log outdiff --git a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/details-panel.tsxindex ac5035d7..a03e73a8 100644--- a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx+++ b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx@@ -23,6 +23,7 @@ import {import LaunchFlow from '../launch-enricher'import NodeActions from '../graph/node/actions/node-actions'import { useParams } from '@tanstack/react-router'+import { usePermissions } from '@/hooks/use-can'import { useGraphStore } from '@/stores/graph-store'import { useIcon } from '@/hooks/use-icon'import { useActionItems } from '@/hooks/use-action-items'@@ -265,6 +266,7 @@ StatusCodeBadge.displayName = 'StatusCodeBadge'const DetailsPanel = memo(() => {const { id: sketchId } = useParams({ strict: false })+ const { canEdit } = usePermissions()const nodesLength = useGraphStore((s) => s.nodesLength)const node = useGraphStore((s) => s.getCurrentNode())const updateNode = useGraphStore((s) => s.updateNode)@@ -493,13 +495,21 @@ const DetailsPanel = memo(() => {{/* Hero */}<div className="px-6 pt-5 pb-4 space-y-3 shrink-0"><div className="flex items-start gap-3">- <button- onClick={() => setOpenIconPicker(true)}- className="shrink-0 mt-1.5 hover:opacity-70 transition-opacity"- >- <IconComponent size={24} />- </button>- <TitleInput value={formData.nodeLabel} onChange={handleLabelCommit} />+ {canEdit ? (+ <button+ onClick={() => setOpenIconPicker(true)}+ className="shrink-0 mt-1.5 hover:opacity-70 transition-opacity"+ >+ <IconComponent size={24} />+ </button>+ ) : (+ <div className="shrink-0 mt-1.5"><IconComponent size={24} /></div>+ )}+ {canEdit ? (+ <TitleInput value={formData.nodeLabel} onChange={handleLabelCommit} />+ ) : (+ <span className="min-w-0 flex-1 text-2xl font-bold truncate">{formData.nodeLabel}</span>+ )}<div className="shrink-0 mt-0.5"><NodeActions node={node} /></div>@@ -510,14 +520,16 @@ const DetailsPanel = memo(() => {</div>{/* Enrich CTA */}- <div className="px-6 pb-4 shrink-0">- <LaunchFlow values={[node.id]} type={node.nodeType}>- <Button className="rounded-full h-8 gap-1.5 px-4 text-sm" size="sm">- <Rocket className="size-3.5" strokeWidth={1.7} />- Enrich- </Button>- </LaunchFlow>- </div>+ {canEdit && (+ <div className="px-6 pb-4 shrink-0">+ <LaunchFlow values={[node.id]} type={node.nodeType}>+ <Button className="rounded-full h-8 gap-1.5 px-4 text-sm" size="sm">+ <Rocket className="size-3.5" strokeWidth={1.7} />+ Enrich+ </Button>+ </LaunchFlow>+ </div>+ )}{/* Tabs */}<Tabs defaultValue="properties" className="flex-1 min-h-0 flex flex-col overflow-hidden gap-0">@@ -541,12 +553,14 @@ const DetailsPanel = memo(() => {>Relations</TabsTrigger>- <TabsTrigger- value="appearance"- className="flex-1 rounded-none border-0 border-b-2 border-transparent data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none text-xs h-full"- >- Style- </TabsTrigger>+ {canEdit && (+ <TabsTrigger+ value="appearance"+ className="flex-1 rounded-none border-0 border-b-2 border-transparent data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none text-xs h-full"+ >+ Style+ </TabsTrigger>+ )}</TabsList></div>@@ -561,11 +575,15 @@ const DetailsPanel = memo(() => {copyValue={copyField(value)}>{typeof value === 'boolean' ? (- <Switch- checked={value}- onCheckedChange={(checked) => handlePropertyBlur(key, checked)}- className="scale-75"- />+ canEdit ? (+ <Switch+ checked={value}+ onCheckedChange={(checked) => handlePropertyBlur(key, checked)}+ className="scale-75"+ />+ ) : (+ <span className="text-muted-foreground">{value ? 'Yes' : 'No'}</span>+ )) : typeof value === 'number' ? (<StatusCodeBadge statusCode={value} />) : typeof value === 'string' && value.startsWith('https://') ? (@@ -581,17 +599,23 @@ const DetailsPanel = memo(() => {) : value && typeof value === 'object' && value.constructor === Object ? (<PopoverProperty label={key} property={value as object} />) : getNodePropertyType(key) === 'list' ? (- <TagsInput- value={value || []}- onChange={(tags) => handlePropertyBlur(key, tags)}- orientation='vertical'- placeholder={value?.length === 0 ? "Empty" : `Enter ${key.toLowerCase()}`}- />- ) : (+ canEdit ? (+ <TagsInput+ value={value || []}+ onChange={(tags) => handlePropertyBlur(key, tags)}+ orientation='vertical'+ placeholder={value?.length === 0 ? "Empty" : `Enter ${key.toLowerCase()}`}+ />+ ) : (+ <span className="text-muted-foreground truncate">{Array.isArray(value) ? value.join(', ') : formatValue(value)}</span>+ )+ ) : canEdit ? (<PropertyInputvalue={String(value || '')}onBlur={(val) => handlePropertyBlur(key, val)}/>+ ) : (+ <span className="text-muted-foreground truncate">{formatValue(value)}</span>)}</PropertyRow>))@@ -604,12 +628,13 @@ const DetailsPanel = memo(() => {<div className="min-h-[120px]"><MinimalTiptapEditorvalue={formData.notes}- onChange={handleNotesChange}+ onChange={canEdit ? handleNotesChange : undefined}output="html"- placeholder="Write something..."+ placeholder={canEdit ? "Write something..." : ""}showToolbar={false}editorContentClassName="px-6 py-3 !max-w-none prose-sm"immediatelyRender={false}+ editable={canEdit}/></div></CollapsibleSection>diff --git a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx b/flowsint-app/src/components/sketches/graph/components/graph-main.tsxindex ae9d8d3f..52007d69 100644--- a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx+++ b/flowsint-app/src/components/sketches/graph/components/graph-main.tsx@@ -10,6 +10,7 @@ import { type GraphNode, GraphEdge } from '@/types'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'type BaseContextMenuProps = {rawTop: number@@ -39,6 +40,7 @@ type BackgroundContextMenuProps = BaseContextMenuProps & {const GraphMain = () => {const { id: sketchId } = useParams({ strict: false })+ const { canEdit, canCreate } = usePermissions()const filteredNodes = useGraphStore((s) => s.filteredNodes)const filteredEdges = useGraphStore((s) => s.filteredEdges)const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)@@ -89,7 +91,7 @@ const GraphMain = () => {const now = Date.now()if (event && now - lastBgClickRef.current < 400) {lastBgClickRef.current = 0- if (graphRef.current && containerRef.current) {+ if (canCreate && graphRef.current && containerRef.current) {const rect = containerRef.current.getBoundingClientRect()const sx = event.clientX - rect.leftconst sy = event.clientY - rect.top@@ -232,14 +234,14 @@ const GraphMain = () => {)const linkCreationProp = useMemo(- () => ({+ () => canCreate ? ({shiftHeld,sourceNode: linkCreation.sourceNode,onStartLinking: startLinking,onCompleteLinking: handleCompleteLinking,onCancel: cancelLinkCreation- }),- [shiftHeld, linkCreation.sourceNode, startLinking, handleCompleteLinking, cancelLinkCreation]+ }) : undefined,+ [canCreate, shiftHeld, linkCreation.sourceNode, startLinking, handleCompleteLinking, cancelLinkCreation])const handleGraphRef = useCallback((ref: any) => {@@ -259,7 +261,7 @@ const GraphMain = () => {showLabels={true}showIcons={true}onGraphRef={handleGraphRef}- enableNodeDrag={!shiftHeld}+ enableNodeDrag={canEdit && !shiftHeld}allowLassosketchId={sketchId}linkCreation={linkCreationProp}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 9ac1d9f7..7226269e 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@@ -30,6 +30,7 @@ import { useGraphSettingsStore } from '@/stores/graph-settings-store'import { useConfirm } from '@/components/use-confirm-dialog'import { toast } from 'sonner'import { sketchService } from '@/api/sketch-service'+import { usePermissions } from '@/hooks/use-can'interface GraphContextMenuProps {nodes: GraphNode[]@@ -61,6 +62,7 @@ export default function BackgroundContextMenu({...props}: GraphContextMenuProps) {const { id: sketchId } = useParams({ strict: false })+ const { canEdit } = usePermissions()const [activeTab, setActiveTab] = useState('enrichers')const [enrichersSearchQuery, setEnrichersSearchQuery] = useState('')const [flowsSearchQuery, setFlowsSearchQuery] = useState('')@@ -167,26 +169,28 @@ export default function BackgroundContextMenu({{isSameType && <span className="block">- {sharedType}</span>}</div><div className="grow" />- <div>- <Tooltip>- <TooltipTrigger asChild>- <div>- <Button- variant="ghost"- size="sm"- className="h-6 p-0 hover:bg-muted opacity-70 hover:opacity-100 text-destructive hover:text-destructive"- onClick={handleDeleteNodes}- >- <Trash2 className="h-3 w-3" strokeWidth={1.5} /> Delete{' '}- {selectedNodeIds.length}- </Button>- </div>- </TooltipTrigger>- <TooltipContent>- <p>Delete {selectedNodeIds.length} node(s)</p>- </TooltipContent>- </Tooltip>- </div>+ {canEdit && (+ <div>+ <Tooltip>+ <TooltipTrigger asChild>+ <div>+ <Button+ variant="ghost"+ size="sm"+ className="h-6 p-0 hover:bg-muted opacity-70 hover:opacity-100 text-destructive hover:text-destructive"+ onClick={handleDeleteNodes}+ >+ <Trash2 className="h-3 w-3" strokeWidth={1.5} /> Delete{' '}+ {selectedNodeIds.length}+ </Button>+ </div>+ </TooltipTrigger>+ <TooltipContent>+ <p>Delete {selectedNodeIds.length} node(s)</p>+ </TooltipContent>+ </Tooltip>+ </div>+ )}</div>{/* Tabs */}@@ -377,6 +381,7 @@ export default function BackgroundContextMenu({}const DefaultBackgroundMenu = memo(() => {+ const { canCreate } = usePermissions()const setOpenMainDialog = useGraphStore((state) => state.setOpenMainDialog)const setImportModalOpen = useGraphSettingsStore((s) => s.setImportModalOpen)@@ -388,6 +393,14 @@ const DefaultBackgroundMenu = memo(() => {setImportModalOpen(true)}, [setImportModalOpen])+ if (!canCreate) {+ return (+ <div className="flex-1 grow text-sm overflow-hidden min-h-0 p-3">+ <p className="text-muted-foreground text-xs">View only</p>+ </div>+ )+ }+return (<div className="flex-1 grow text-sm overflow-hidden min-h-0"><buttondiff --git a/flowsint-app/src/components/sketches/graph/context-menu/edge-context-menu.tsx b/flowsint-app/src/components/sketches/graph/context-menu/edge-context-menu.tsxindex cc0b2146..f79ca9ed 100644--- a/flowsint-app/src/components/sketches/graph/context-menu/edge-context-menu.tsx+++ b/flowsint-app/src/components/sketches/graph/context-menu/edge-context-menu.tsx@@ -10,6 +10,7 @@ import { useGraphStore } from '@/stores/graph-store'import { useConfirm } from '@/components/use-confirm-dialog'import { toast } from 'sonner'import { Input } from '@/components/ui/input'+import { usePermissions } from '@/hooks/use-can'interface EdgeContextMenuProps {edge?: GraphEdge@@ -44,6 +45,7 @@ export default function EdgeContextMenu({...props}: EdgeContextMenuProps) {const { id: sketchId } = useParams({ strict: false })+ const { canEdit } = usePermissions()const removeEdges = useGraphStore((s) => s.removeEdges)const updateEdge = useGraphStore((s) => s.updateEdge)const clearSelectedEdges = useGraphStore((s) => s.clearSelectedEdges)@@ -173,8 +175,9 @@ export default function EdgeContextMenu({e.stopPropagation()if (onSubmitNew) e.currentTarget.select()}}- onBlur={handleBlur}- onKeyDown={handleKeyDown}+ onBlur={canEdit ? handleBlur : undefined}+ onKeyDown={canEdit ? handleKeyDown : undefined}+ readOnly={!canEdit}autoFocus/></div>@@ -184,9 +187,11 @@ export default function EdgeContextMenu({{!isMultiSelect && edge && (<CopyButton size="icon" content={edge.label} className="h-7 w-7" />)}- <Button onClick={handleDelete} size="icon" variant="ghost" className="h-7 w-7">- <Trash2 className="h-3.5! w-3.5! opacity-50" />- </Button>+ {canEdit && (+ <Button onClick={handleDelete} size="icon" variant="ghost" className="h-7 w-7">+ <Trash2 className="h-3.5! w-3.5! opacity-50" />+ </Button>+ )}</div></div></BaseContextMenu>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 fe4ac94a..cb01efa3 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@@ -1,4 +1,4 @@-import React, { memo, useCallback, useMemo, useState } from 'react'+import React, { memo, useCallback, useState } from 'react'import { enricherService } from '@/api/enricher-service'import { flowService } from '@/api/flow-service'import { useQuery } from '@tanstack/react-query'@@ -25,6 +25,7 @@ import NodeActions from '../node/actions/node-actions'import BaseContextMenu from '@/components/xyflow/context-menu'import { useGraphStore } from '@/stores/graph-store'import { CopyButton } from '@/components/copy'+import { usePermissions } from '@/hooks/use-can'interface GraphContextMenuProps {node: GraphNode@@ -56,6 +57,7 @@ export default function ContextMenu({...props}: GraphContextMenuProps) {const { id: sketchId } = useParams({ strict: false })+ const { canEdit } = usePermissions()const [activeTab, setActiveTab] = useState('enrichers')const [enrichersSearchQuery, setEnrichersSearchQuery] = useState('')const [flowsSearchQuery, setFlowsSearchQuery] = useState('')@@ -133,24 +135,26 @@ export default function ContextMenu({</div></div>- {/* Tabs */}- <div className="px-3 py-2 border-b border-border shrink-0">- <Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">- <TabsList className="w-full h-9">- <TabsTrigger value="enrichers" className="flex-1" onClick={(e) => e.stopPropagation()}>- <Zap className="h-3 w-3 mr-1" />- Enrichers- </TabsTrigger>- <TabsTrigger value="flows" className="flex-1" onClick={(e) => e.stopPropagation()}>- <FileCode2 className="h-3 w-3 mr-1" />- Flows- </TabsTrigger>- </TabsList>- </Tabs>- </div>+ {/* Tabs - editor+ only */}+ {canEdit && (+ <div className="px-3 py-2 border-b border-border shrink-0">+ <Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">+ <TabsList className="w-full h-9">+ <TabsTrigger value="enrichers" className="flex-1" onClick={(e) => e.stopPropagation()}>+ <Zap className="h-3 w-3 mr-1" />+ Enrichers+ </TabsTrigger>+ <TabsTrigger value="flows" className="flex-1" onClick={(e) => e.stopPropagation()}>+ <FileCode2 className="h-3 w-3 mr-1" />+ Flows+ </TabsTrigger>+ </TabsList>+ </Tabs>+ </div>+ )}{/* Tab Content */}- <Tabs value={activeTab} className="flex-1 flex flex-col min-h-0">+ {canEdit && <Tabs value={activeTab} className="flex-1 flex flex-col min-h-0">{/* Enrichers Tab */}<TabsContent value="enrichers" className="flex-1 flex flex-col min-h-0 mt-0">{/* Enrichers Search */}@@ -302,7 +306,7 @@ export default function ContextMenu({)}</div></TabsContent>- </Tabs>+ </Tabs>}</BaseContextMenu>)}diff --git a/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsx b/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsxindex 68499df9..153ad777 100644--- a/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsx+++ b/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsx@@ -20,6 +20,7 @@ import { useLayoutStore } from '@/stores/layout-store'import { GraphNode } from '@/types'import { useGraphSettingsStore } from '@/stores/graph-settings-store'import { cn } from '@/lib/utils'+import { usePermissions } from '@/hooks/use-can'const flagColors = {red: 'text-red-400 fill-red-200',@@ -34,6 +35,7 @@ type FlagColor = keyof typeof flagColorsconst NodeActions = memo(({ node, setMenu }: { node: GraphNode; setMenu?: (menu: any | null) => void }) => {const { id: sketchId } = useParams({ strict: false })+ const { canEdit } = usePermissions()const { confirm } = useConfirm()const setOpenMainDialog = useGraphStore((state) => state.setOpenMainDialog)const setRelatedNodeToAdd = useGraphStore((state) => state.setRelatedNodeToAdd)@@ -106,6 +108,8 @@ const NodeActions = memo([node.id, flagValue, updateNode, sketchId])+ if (!canEdit) return null+return (<DropdownMenu><DropdownMenuTrigger asChild>diff --git a/flowsint-app/src/components/sketches/graph/panels/selected-items-panel.tsx b/flowsint-app/src/components/sketches/graph/panels/selected-items-panel.tsxindex 5c322b33..7189bac5 100644--- a/flowsint-app/src/components/sketches/graph/panels/selected-items-panel.tsx+++ b/flowsint-app/src/components/sketches/graph/panels/selected-items-panel.tsx@@ -15,6 +15,8 @@ import LaunchFlow from '../../launch-enricher'import { TypeBadge } from '@/components/type-badge'import { useParams } from '@tanstack/react-router'import { useGraphSettingsStore } from '@/stores/graph-settings-store'+import { usePermissions } from '@/hooks/use-can'+const SelectedItemsPanel = () => {const selectedNodes = useGraphStore((s) => s.selectedNodes)@@ -76,6 +78,7 @@ export const SelectedList = () => {const ActionBar = () => {const { id: sketchId } = useParams({ strict: false })+ const { canEdit } = usePermissions()const { confirm } = useConfirm()const selectedNodes = useGraphStore((s) => s.selectedNodes)const removeNodes = useGraphStore((s) => s.removeNodes)@@ -129,7 +132,7 @@ const ActionBar = () => {return (<div className="flex items-center gap-1"><TooltipProvider>- {Boolean(settings?.general?.showFlow?.value) &&+ {canEdit && Boolean(settings?.general?.showFlow?.value) &&<Tooltip><TooltipTrigger asChild><div>@@ -147,47 +150,51 @@ const ActionBar = () => {<p>Ask AI</p></TooltipContent></Tooltip>}- <Tooltip>- <TooltipTrigger asChild>- <div>- <Button- variant="ghost"- size="sm"- disabled={selectedNodes.length === 0}- className="h-6 w-6 p-0 relative text-destructive hover:text-destructive"- onClick={handleDeleteNodes}- >- <Trash2 className="h-3 w-3" strokeWidth={1.5} />- {selectedNodes.length > 0 && (- <span className="absolute -top-2 -right-2 z-50 bg-primary text-white text-[10px] rounded-full w-auto min-w-4.5 h-4.5 p-1 flex items-center justify-center">- {selectedNodes.length}- </span>- )}- </Button>- </div>- </TooltipTrigger>- <TooltipContent>- <p>Delete {selectedNodes.length} nodes</p>- </TooltipContent>- </Tooltip>- <Tooltip>- <TooltipTrigger asChild>- <div className="ml-2">- <LaunchFlow disabled={!shareSameType} values={values} type={type}>- <Button disabled={!shareSameType} size={'sm'} className="rounded-full h-7">- <Rocket className="h-3 w-3" strokeWidth={2} />({selectedNodes.length})+ {canEdit && (+ <Tooltip>+ <TooltipTrigger asChild>+ <div>+ <Button+ variant="ghost"+ size="sm"+ disabled={selectedNodes.length === 0}+ className="h-6 w-6 p-0 relative text-destructive hover:text-destructive"+ onClick={handleDeleteNodes}+ >+ <Trash2 className="h-3 w-3" strokeWidth={1.5} />+ {selectedNodes.length > 0 && (+ <span className="absolute -top-2 -right-2 z-50 bg-primary text-white text-[10px] rounded-full w-auto min-w-4.5 h-4.5 p-1 flex items-center justify-center">+ {selectedNodes.length}+ </span>+ )}</Button>- </LaunchFlow>- </div>- </TooltipTrigger>- <TooltipContent>- {!shareSameType ? (- <p>All selected items are not the same type</p>- ) : (- <p>Launch enricher</p>- )}- </TooltipContent>- </Tooltip>+ </div>+ </TooltipTrigger>+ <TooltipContent>+ <p>Delete {selectedNodes.length} nodes</p>+ </TooltipContent>+ </Tooltip>+ )}+ {canEdit && (+ <Tooltip>+ <TooltipTrigger asChild>+ <div className="ml-2">+ <LaunchFlow disabled={!shareSameType} values={values} type={type}>+ <Button disabled={!shareSameType} size={'sm'} className="rounded-full h-7">+ <Rocket className="h-3 w-3" strokeWidth={2} />({selectedNodes.length})+ </Button>+ </LaunchFlow>+ </div>+ </TooltipTrigger>+ <TooltipContent>+ {!shareSameType ? (+ <p>All selected items are not the same type</p>+ ) : (+ <p>Launch enricher</p>+ )}+ </TooltipContent>+ </Tooltip>+ )}<Tooltip><TooltipTrigger asChild><div>diff --git a/flowsint-app/src/components/sketches/index.tsx b/flowsint-app/src/components/sketches/index.tsxindex a884aac6..65366d88 100644--- a/flowsint-app/src/components/sketches/index.tsx+++ b/flowsint-app/src/components/sketches/index.tsx@@ -19,6 +19,7 @@ import Settings, { KeyboardShortcuts } from './settings/settings'import { type GraphNode, type GraphEdge } from '@/types'import { MergeDialog } from './graph/actions/merge-nodes'import { useGraphRefresh } from '@/hooks/use-graph-refresh'+import { usePermissions } from '@/hooks/use-can'const RelationshipsTable = lazy(() => import('@/components/table/relationships-view'))// Separate component for the drag overlay@@ -43,6 +44,7 @@ interface GraphPanelProps {}const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {+ const { canCreate } = usePermissions()const handleOpenFormModal = useGraphStore((s) => s.handleOpenFormModal)const view = useGraphControls((s) => s.view)const updateGraphData = useGraphStore((s) => s.updateGraphData)@@ -120,10 +122,10 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {return (<div- onDragOver={handleDragOver}- onDragEnter={handleDragEnter}- onDragLeave={handleDragLeave}- onDrop={handleDrop}+ onDragOver={canCreate ? handleDragOver : undefined}+ onDragEnter={canCreate ? handleDragEnter : undefined}+ onDragLeave={canCreate ? handleDragLeave : undefined}+ onDrop={canCreate ? handleDrop : undefined}className="h-full w-full flex flex-col relative outline-2 outline-transparent bg-background"><Toolbar isLoading={isLoading} />diff --git a/flowsint-app/src/components/sketches/settings/settings.tsx b/flowsint-app/src/components/sketches/settings/settings.tsxindex 51ebb568..c2aab2a1 100644--- a/flowsint-app/src/components/sketches/settings/settings.tsx+++ b/flowsint-app/src/components/sketches/settings/settings.tsx@@ -34,6 +34,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'import { useNodesDisplaySettings, ITEM_TYPES, ItemType } from '@/stores/node-display-settings'import IconPicker, { NodeIconTrigger } from '@/components/shared/icon-picker'import { ColorPicker } from '@/components/shared/color-picker'+import { usePermissions } from '@/hooks/use-can'// SettingItem Componentsinterface SettingItemProps {@@ -421,6 +422,7 @@ function DynamicSection({ categoryId, category, title, description }: DynamicSec}export default function GlobalSettings() {+ const { canEdit } = usePermissions()const settingsModalOpen = useGraphSettingsStore((s) => s.settingsModalOpen)const setSettingsModalOpen = useGraphSettingsStore((s) => s.setSettingsModalOpen)const settings = useGraphSettingsStore((s) => s.settings)@@ -567,7 +569,7 @@ export default function GlobalSettings() {label="Title"description="The name of your sketch"value={formData.title}- onValueChange={(value) => handleInputChange('title', value)}+ onValueChange={canEdit ? (value) => handleInputChange('title', value) : () => {}}placeholder="Enter sketch title"/>@@ -575,7 +577,7 @@ export default function GlobalSettings() {label="Description"description="A brief description of what this sketch represents"value={formData.description}- onValueChange={(value) => handleInputChange('description', value)}+ onValueChange={canEdit ? (value) => handleInputChange('description', value) : () => {}}placeholder="Enter sketch description"rows={4}/>@@ -584,7 +586,7 @@ export default function GlobalSettings() {label="Status"description="The current status of this sketch"value={formData.status}- onValueChange={(value) => handleInputChange('status', value)}+ onValueChange={canEdit ? (value) => handleInputChange('status', value) : () => {}}options={[{ value: 'active', label: 'Active' },{ value: 'inactive', label: 'Inactive' },@@ -594,21 +596,23 @@ export default function GlobalSettings() {/></div>- <div className="flex gap-3 pt-6">- <SheetClose asChild>- <Button variant="outline" type="button" className="flex-1 shadow-none">- Cancel+ {canEdit && (+ <div className="flex gap-3 pt-6">+ <SheetClose asChild>+ <Button variant="outline" type="button" className="flex-1 shadow-none">+ Cancel+ </Button>+ </SheetClose>+ <Button+ type="submit"+ disabled={updateMutation.isPending}+ onClick={handleSubmit}+ className="flex-1 shadow-none"+ >+ {updateMutation.isPending ? 'Saving...' : 'Save changes'}</Button>- </SheetClose>- <Button- type="submit"- disabled={updateMutation.isPending}- onClick={handleSubmit}- className="flex-1 shadow-none"- >- {updateMutation.isPending ? 'Saving...' : 'Save changes'}- </Button>- </div>+ </div>+ )}</div>)}diff --git a/flowsint-app/src/hooks/use-can.ts b/flowsint-app/src/hooks/use-can.tsnew file mode 100644index 00000000..dfb82ddb--- /dev/null+++ b/flowsint-app/src/hooks/use-can.ts@@ -0,0 +1,77 @@+import { useMemo } from 'react'+import { useLoaderData } from '@tanstack/react-router'+import type { InvestigationRole } from '@/types'++type Action =+ | 'read'+ | 'create'+ | 'update'+ | 'delete'+ | 'manage'++export type Permissions = {+ can: (action: Action) => boolean+ canEdit: boolean+ canCreate: boolean+ canDelete: boolean+ canManage: boolean+ isViewer: boolean+ isOwner: boolean+ role: InvestigationRole | null+}++const ROLE_LEVEL: Record<InvestigationRole, number> = {+ owner: 4,+ admin: 3,+ editor: 2,+ viewer: 1+}++function canRolePerform(role: InvestigationRole | null, action: Action): boolean {+ if (!role) return false+ const level = ROLE_LEVEL[role]+ switch (action) {+ case 'read':+ return level >= 1+ case 'create':+ case 'update':+ return level >= 2+ case 'manage':+ return level >= 3+ case 'delete':+ return level >= 4+ default:+ return false+ }+}++export function useCan(role: InvestigationRole | null | undefined): Permissions {+ return useMemo(() => {+ const r = role ?? null+ const can = (action: Action) => canRolePerform(r, action)+ return {+ can,+ canEdit: can('update'),+ canCreate: can('create'),+ canDelete: can('delete'),+ canManage: can('manage'),+ isViewer: r === 'viewer',+ isOwner: r === 'owner',+ role: r+ }+ }, [role])+}++/**+ * Read permissions from the $investigationId layout route loader data.+ * Works anywhere rendered under that route — including components in+ * RootLayout like DetailsPanel, since the route is active when they render.+ */+export function usePermissions(): Permissions {+ const role = useLoaderData({+ from: '/_auth/dashboard/investigations/$investigationId',+ select: (d: any) => d?.investigation?.current_user_role ?? null,+ strict: false,+ }) as InvestigationRole | null | undefined+ return useCan(role)+}diff --git a/flowsint-app/src/lib/user-display.ts b/flowsint-app/src/lib/user-display.tsnew file mode 100644index 00000000..96c6e933--- /dev/null+++ b/flowsint-app/src/lib/user-display.ts@@ -0,0 +1,30 @@+import type { Profile } from '@/types'+import type { User } from '@/stores/auth-store'++type UserLike = Partial<Profile> & Partial<User> | null | undefined++/**+ * Returns the best display name available:+ * username > "first last" > email > "Unknown"+ */+export function getDisplayName(user: UserLike): string {+ if (!user) return 'Unknown'+ if ('username' in user && user.username) return user.username+ const fullName = [user.first_name, user.last_name].filter(Boolean).join(' ')+ if (fullName) return fullName+ if (user.email) return user.email+ return 'Unknown'+}++/**+ * Returns 1-2 letter initials from the best available name source.+ */+export function getInitials(user: UserLike): string {+ if (!user) return '?'+ if ('username' in user && user.username) return user.username[0].toUpperCase()+ const first = user.first_name?.[0] ?? ''+ const last = user.last_name?.[0] ?? ''+ if (first || last) return (first + last).toUpperCase()+ if (user.email) return user.email[0].toUpperCase()+ return '?'+}diff --git a/flowsint-app/src/routeTree.gen.ts b/flowsint-app/src/routeTree.gen.tsindex 8b1fa422..26f8cd99 100644--- a/flowsint-app/src/routeTree.gen.ts+++ b/flowsint-app/src/routeTree.gen.ts@@ -18,9 +18,11 @@ import { Route as AuthDashboardRouteImport } from './routes/_auth.dashboard'import { Route as AuthDashboardIndexRouteImport } from './routes/_auth.dashboard.index'import { Route as AuthDashboardVaultRouteImport } from './routes/_auth.dashboard.vault'import { Route as AuthDashboardToolsRouteImport } from './routes/_auth.dashboard.tools'+import { Route as AuthDashboardProfileRouteImport } from './routes/_auth.dashboard.profile'import { Route as AuthDashboardFlowsIndexRouteImport } from './routes/_auth.dashboard.flows.index'import { Route as AuthDashboardEnrichersIndexRouteImport } from './routes/_auth.dashboard.enrichers.index'import { Route as AuthDashboardCustomTypesIndexRouteImport } from './routes/_auth.dashboard.custom-types.index'+import { Route as AuthDashboardInvestigationsInvestigationIdRouteImport } from './routes/_auth.dashboard.investigations.$investigationId'import { Route as AuthDashboardFlowsFlowIdRouteImport } from './routes/_auth.dashboard.flows.$flowId'import { Route as AuthDashboardEnrichersNewRouteImport } from './routes/_auth.dashboard.enrichers.new'import { Route as AuthDashboardEnrichersEnricherIdRouteImport } from './routes/_auth.dashboard.enrichers.$enricherId'@@ -72,6 +74,11 @@ const AuthDashboardToolsRoute = AuthDashboardToolsRouteImport.update({path: '/tools',getParentRoute: () => AuthDashboardRoute,} as any)+const AuthDashboardProfileRoute = AuthDashboardProfileRouteImport.update({+ id: '/profile',+ path: '/profile',+ getParentRoute: () => AuthDashboardRoute,+} as any)const AuthDashboardFlowsIndexRoute = AuthDashboardFlowsIndexRouteImport.update({id: '/flows/',path: '/flows/',@@ -89,6 +96,12 @@ const AuthDashboardCustomTypesIndexRoute =path: '/custom-types/',getParentRoute: () => AuthDashboardRoute,} as any)+const AuthDashboardInvestigationsInvestigationIdRoute =+ AuthDashboardInvestigationsInvestigationIdRouteImport.update({+ id: '/investigations/$investigationId',+ path: '/investigations/$investigationId',+ getParentRoute: () => AuthDashboardRoute,+ } as any)const AuthDashboardFlowsFlowIdRoute =AuthDashboardFlowsFlowIdRouteImport.update({id: '/flows/$flowId',@@ -115,15 +128,15 @@ const AuthDashboardCustomTypesTypeIdRoute =} as any)const AuthDashboardInvestigationsInvestigationIdIndexRoute =AuthDashboardInvestigationsInvestigationIdIndexRouteImport.update({- id: '/investigations/$investigationId/',- path: '/investigations/$investigationId/',- getParentRoute: () => AuthDashboardRoute,+ id: '/',+ path: '/',+ getParentRoute: () => AuthDashboardInvestigationsInvestigationIdRoute,} as any)const AuthDashboardInvestigationsInvestigationIdTypeIdRoute =AuthDashboardInvestigationsInvestigationIdTypeIdRouteImport.update({- id: '/investigations/$investigationId/$type/$id',- path: '/investigations/$investigationId/$type/$id',- getParentRoute: () => AuthDashboardRoute,+ id: '/$type/$id',+ path: '/$type/$id',+ getParentRoute: () => AuthDashboardInvestigationsInvestigationIdRoute,} as any)export interface FileRoutesByFullPath {@@ -132,6 +145,7 @@ export interface FileRoutesByFullPath {'/middleware': typeof MiddlewareRoute'/register': typeof RegisterRoute'/dashboard': typeof AuthDashboardRouteWithChildren+ '/dashboard/profile': typeof AuthDashboardProfileRoute'/dashboard/tools': typeof AuthDashboardToolsRoute'/dashboard/vault': typeof AuthDashboardVaultRoute'/dashboard/': typeof AuthDashboardIndexRoute@@ -139,10 +153,11 @@ export interface FileRoutesByFullPath {'/dashboard/enrichers/$enricherId': typeof AuthDashboardEnrichersEnricherIdRoute'/dashboard/enrichers/new': typeof AuthDashboardEnrichersNewRoute'/dashboard/flows/$flowId': typeof AuthDashboardFlowsFlowIdRoute+ '/dashboard/investigations/$investigationId': typeof AuthDashboardInvestigationsInvestigationIdRouteWithChildren'/dashboard/custom-types': typeof AuthDashboardCustomTypesIndexRoute'/dashboard/enrichers': typeof AuthDashboardEnrichersIndexRoute'/dashboard/flows': typeof AuthDashboardFlowsIndexRoute- '/dashboard/investigations/$investigationId': typeof AuthDashboardInvestigationsInvestigationIdIndexRoute+ '/dashboard/investigations/$investigationId/': typeof AuthDashboardInvestigationsInvestigationIdIndexRoute'/dashboard/investigations/$investigationId/$type/$id': typeof AuthDashboardInvestigationsInvestigationIdTypeIdRoute}export interface FileRoutesByTo {@@ -150,6 +165,7 @@ export interface FileRoutesByTo {'/login': typeof LoginRoute'/middleware': typeof MiddlewareRoute'/register': typeof RegisterRoute+ '/dashboard/profile': typeof AuthDashboardProfileRoute'/dashboard/tools': typeof AuthDashboardToolsRoute'/dashboard/vault': typeof AuthDashboardVaultRoute'/dashboard': typeof AuthDashboardIndexRoute@@ -171,6 +187,7 @@ export interface FileRoutesById {'/middleware': typeof MiddlewareRoute'/register': typeof RegisterRoute'/_auth/dashboard': typeof AuthDashboardRouteWithChildren+ '/_auth/dashboard/profile': typeof AuthDashboardProfileRoute'/_auth/dashboard/tools': typeof AuthDashboardToolsRoute'/_auth/dashboard/vault': typeof AuthDashboardVaultRoute'/_auth/dashboard/': typeof AuthDashboardIndexRoute@@ -178,6 +195,7 @@ export interface FileRoutesById {'/_auth/dashboard/enrichers/$enricherId': typeof AuthDashboardEnrichersEnricherIdRoute'/_auth/dashboard/enrichers/new': typeof AuthDashboardEnrichersNewRoute'/_auth/dashboard/flows/$flowId': typeof AuthDashboardFlowsFlowIdRoute+ '/_auth/dashboard/investigations/$investigationId': typeof AuthDashboardInvestigationsInvestigationIdRouteWithChildren'/_auth/dashboard/custom-types/': typeof AuthDashboardCustomTypesIndexRoute'/_auth/dashboard/enrichers/': typeof AuthDashboardEnrichersIndexRoute'/_auth/dashboard/flows/': typeof AuthDashboardFlowsIndexRoute@@ -192,6 +210,7 @@ export interface FileRouteTypes {| '/middleware'| '/register'| '/dashboard'+ | '/dashboard/profile'| '/dashboard/tools'| '/dashboard/vault'| '/dashboard/'@@ -199,10 +218,11 @@ export interface FileRouteTypes {| '/dashboard/enrichers/$enricherId'| '/dashboard/enrichers/new'| '/dashboard/flows/$flowId'+ | '/dashboard/investigations/$investigationId'| '/dashboard/custom-types'| '/dashboard/enrichers'| '/dashboard/flows'- | '/dashboard/investigations/$investigationId'+ | '/dashboard/investigations/$investigationId/'| '/dashboard/investigations/$investigationId/$type/$id'fileRoutesByTo: FileRoutesByToto:@@ -210,6 +230,7 @@ export interface FileRouteTypes {| '/login'| '/middleware'| '/register'+ | '/dashboard/profile'| '/dashboard/tools'| '/dashboard/vault'| '/dashboard'@@ -230,6 +251,7 @@ export interface FileRouteTypes {| '/middleware'| '/register'| '/_auth/dashboard'+ | '/_auth/dashboard/profile'| '/_auth/dashboard/tools'| '/_auth/dashboard/vault'| '/_auth/dashboard/'@@ -237,6 +259,7 @@ export interface FileRouteTypes {| '/_auth/dashboard/enrichers/$enricherId'| '/_auth/dashboard/enrichers/new'| '/_auth/dashboard/flows/$flowId'+ | '/_auth/dashboard/investigations/$investigationId'| '/_auth/dashboard/custom-types/'| '/_auth/dashboard/enrichers/'| '/_auth/dashboard/flows/'@@ -317,6 +340,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthDashboardToolsRouteImportparentRoute: typeof AuthDashboardRoute}+ '/_auth/dashboard/profile': {+ id: '/_auth/dashboard/profile'+ path: '/profile'+ fullPath: '/dashboard/profile'+ preLoaderRoute: typeof AuthDashboardProfileRouteImport+ parentRoute: typeof AuthDashboardRoute+ }'/_auth/dashboard/flows/': {id: '/_auth/dashboard/flows/'path: '/flows'@@ -338,6 +368,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthDashboardCustomTypesIndexRouteImportparentRoute: typeof AuthDashboardRoute}+ '/_auth/dashboard/investigations/$investigationId': {+ id: '/_auth/dashboard/investigations/$investigationId'+ path: '/investigations/$investigationId'+ fullPath: '/dashboard/investigations/$investigationId'+ preLoaderRoute: typeof AuthDashboardInvestigationsInvestigationIdRouteImport+ parentRoute: typeof AuthDashboardRoute+ }'/_auth/dashboard/flows/$flowId': {id: '/_auth/dashboard/flows/$flowId'path: '/flows/$flowId'@@ -368,22 +405,41 @@ declare module '@tanstack/react-router' {}'/_auth/dashboard/investigations/$investigationId/': {id: '/_auth/dashboard/investigations/$investigationId/'- path: '/investigations/$investigationId'- fullPath: '/dashboard/investigations/$investigationId'+ path: '/'+ fullPath: '/dashboard/investigations/$investigationId/'preLoaderRoute: typeof AuthDashboardInvestigationsInvestigationIdIndexRouteImport- parentRoute: typeof AuthDashboardRoute+ parentRoute: typeof AuthDashboardInvestigationsInvestigationIdRoute}'/_auth/dashboard/investigations/$investigationId/$type/$id': {id: '/_auth/dashboard/investigations/$investigationId/$type/$id'- path: '/investigations/$investigationId/$type/$id'+ path: '/$type/$id'fullPath: '/dashboard/investigations/$investigationId/$type/$id'preLoaderRoute: typeof AuthDashboardInvestigationsInvestigationIdTypeIdRouteImport- parentRoute: typeof AuthDashboardRoute+ parentRoute: typeof AuthDashboardInvestigationsInvestigationIdRoute}}}+interface AuthDashboardInvestigationsInvestigationIdRouteChildren {+ AuthDashboardInvestigationsInvestigationIdIndexRoute: typeof AuthDashboardInvestigationsInvestigationIdIndexRoute+ AuthDashboardInvestigationsInvestigationIdTypeIdRoute: typeof AuthDashboardInvestigationsInvestigationIdTypeIdRoute+}++const AuthDashboardInvestigationsInvestigationIdRouteChildren: AuthDashboardInvestigationsInvestigationIdRouteChildren =+ {+ AuthDashboardInvestigationsInvestigationIdIndexRoute:+ AuthDashboardInvestigationsInvestigationIdIndexRoute,+ AuthDashboardInvestigationsInvestigationIdTypeIdRoute:+ AuthDashboardInvestigationsInvestigationIdTypeIdRoute,+ }++const AuthDashboardInvestigationsInvestigationIdRouteWithChildren =+ AuthDashboardInvestigationsInvestigationIdRoute._addFileChildren(+ AuthDashboardInvestigationsInvestigationIdRouteChildren,+ )+interface AuthDashboardRouteChildren {+ AuthDashboardProfileRoute: typeof AuthDashboardProfileRouteAuthDashboardToolsRoute: typeof AuthDashboardToolsRouteAuthDashboardVaultRoute: typeof AuthDashboardVaultRouteAuthDashboardIndexRoute: typeof AuthDashboardIndexRoute@@ -391,14 +447,14 @@ interface AuthDashboardRouteChildren {AuthDashboardEnrichersEnricherIdRoute: typeof AuthDashboardEnrichersEnricherIdRouteAuthDashboardEnrichersNewRoute: typeof AuthDashboardEnrichersNewRouteAuthDashboardFlowsFlowIdRoute: typeof AuthDashboardFlowsFlowIdRoute+ AuthDashboardInvestigationsInvestigationIdRoute: typeof AuthDashboardInvestigationsInvestigationIdRouteWithChildrenAuthDashboardCustomTypesIndexRoute: typeof AuthDashboardCustomTypesIndexRouteAuthDashboardEnrichersIndexRoute: typeof AuthDashboardEnrichersIndexRouteAuthDashboardFlowsIndexRoute: typeof AuthDashboardFlowsIndexRoute- AuthDashboardInvestigationsInvestigationIdIndexRoute: typeof AuthDashboardInvestigationsInvestigationIdIndexRoute- AuthDashboardInvestigationsInvestigationIdTypeIdRoute: typeof AuthDashboardInvestigationsInvestigationIdTypeIdRoute}const AuthDashboardRouteChildren: AuthDashboardRouteChildren = {+ AuthDashboardProfileRoute: AuthDashboardProfileRoute,AuthDashboardToolsRoute: AuthDashboardToolsRoute,AuthDashboardVaultRoute: AuthDashboardVaultRoute,AuthDashboardIndexRoute: AuthDashboardIndexRoute,@@ -406,13 +462,11 @@ const AuthDashboardRouteChildren: AuthDashboardRouteChildren = {AuthDashboardEnrichersEnricherIdRoute: AuthDashboardEnrichersEnricherIdRoute,AuthDashboardEnrichersNewRoute: AuthDashboardEnrichersNewRoute,AuthDashboardFlowsFlowIdRoute: AuthDashboardFlowsFlowIdRoute,+ AuthDashboardInvestigationsInvestigationIdRoute:+ AuthDashboardInvestigationsInvestigationIdRouteWithChildren,AuthDashboardCustomTypesIndexRoute: AuthDashboardCustomTypesIndexRoute,AuthDashboardEnrichersIndexRoute: AuthDashboardEnrichersIndexRoute,AuthDashboardFlowsIndexRoute: AuthDashboardFlowsIndexRoute,- AuthDashboardInvestigationsInvestigationIdIndexRoute:- AuthDashboardInvestigationsInvestigationIdIndexRoute,- AuthDashboardInvestigationsInvestigationIdTypeIdRoute:- AuthDashboardInvestigationsInvestigationIdTypeIdRoute,}const AuthDashboardRouteWithChildren = AuthDashboardRoute._addFileChildren(diff --git a/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.index.tsx b/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.index.tsxindex 164708ce..7527709c 100644--- a/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.index.tsx+++ b/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.index.tsx@@ -1,63 +1,17 @@-import { createFileRoute, useNavigate } from '@tanstack/react-router'-import { investigationService } from '@/api/investigation-service'+import { createFileRoute, useLoaderData, useNavigate } from '@tanstack/react-router'import { analysisService } from '@/api/analysis-service'import { useMutation, useQueryClient } from '@tanstack/react-query'import { toast } from 'sonner'import { CaseOverviewPage } from "@/components/dashboard/investigation/case-overview-page"--function InvestigationSkeleton() {- return (- <div className="h-full w-full bg-background overflow-y-auto">- <div className="max-w-7xl mx-auto p-8 space-y-8">- {/* Header Skeleton */}- <div className="space-y-4">- <div className="w-64 h-8 bg-muted rounded animate-pulse" />- <div className="w-96 h-4 bg-muted rounded animate-pulse" />- <div className="flex items-center gap-4">- <div className="w-20 h-6 bg-muted rounded animate-pulse" />- <div className="w-24 h-6 bg-muted rounded animate-pulse" />- <div className="w-32 h-6 bg-muted rounded animate-pulse" />- </div>- </div>-- {/* Stats Cards Skeleton */}- <div className="grid grid-cols-1 md:grid-cols-3 gap-6">- {Array.from({ length: 3 }).map((_, i) => (- <div key={i} className="h-24 bg-muted rounded-lg animate-pulse" />- ))}- </div>-- {/* Content Skeleton */}- <div className="grid grid-cols-1 lg:grid-cols-2 gap-8">- {Array.from({ length: 2 }).map((_, i) => (- <div key={i} className="space-y-4">- <div className="w-48 h-6 bg-muted rounded animate-pulse" />- <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">- {Array.from({ length: 4 }).map((_, j) => (- <div key={j} className="h-32 bg-muted rounded-lg animate-pulse" />- ))}- </div>- </div>- ))}- </div>- </div>- </div>- )-}-export const Route = createFileRoute('/_auth/dashboard/investigations/$investigationId/')({- loader: async ({ params: { investigationId } }) => {- return {- investigation: await investigationService.getById(investigationId)- }- },component: InvestigationPage,- pendingComponent: InvestigationSkeleton})function InvestigationPage() {- const { investigation } = Route.useLoaderData()+ const { investigation } = useLoaderData({+ from: '/_auth/dashboard/investigations/$investigationId'+ })const navigate = useNavigate()const queryClient = useQueryClient()@@ -73,7 +27,6 @@ function InvestigationPage() {onSuccess: async (data) => {queryClient.invalidateQueries({ queryKey: ['analyses', 'investigation', investigation.id] })toast.success('New analysis created')- // Navigate to the New analysis pagenavigate({to: '/dashboard/investigations/$investigationId/$type/$id',params: {diff --git a/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.tsx b/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.tsxnew file mode 100644index 00000000..e3b78aa6--- /dev/null+++ b/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.tsx@@ -0,0 +1,34 @@+import { createFileRoute, Outlet } from '@tanstack/react-router'+import { investigationService } from '@/api/investigation-service'++function InvestigationSkeleton() {+ return (+ <div className="h-full w-full bg-background overflow-y-auto">+ <div className="max-w-7xl mx-auto p-8 space-y-8">+ <div className="space-y-4">+ <div className="w-64 h-8 bg-muted rounded animate-pulse" />+ <div className="w-96 h-4 bg-muted rounded animate-pulse" />+ <div className="flex items-center gap-4">+ <div className="w-20 h-6 bg-muted rounded animate-pulse" />+ <div className="w-24 h-6 bg-muted rounded animate-pulse" />+ <div className="w-32 h-6 bg-muted rounded animate-pulse" />+ </div>+ </div>+ <div className="grid grid-cols-1 md:grid-cols-3 gap-6">+ {Array.from({ length: 3 }).map((_, i) => (+ <div key={i} className="h-24 bg-muted rounded-lg animate-pulse" />+ ))}+ </div>+ </div>+ </div>+ )+}++export const Route = createFileRoute('/_auth/dashboard/investigations/$investigationId')({+ loader: async ({ params: { investigationId } }) => {+ const investigation = await investigationService.getById(investigationId)+ return { investigation }+ },+ component: () => <Outlet />,+ pendingComponent: InvestigationSkeleton+})diff --git a/flowsint-app/src/routes/_auth.dashboard.profile.tsx b/flowsint-app/src/routes/_auth.dashboard.profile.tsxnew file mode 100644index 00000000..898b7e9a--- /dev/null+++ b/flowsint-app/src/routes/_auth.dashboard.profile.tsx@@ -0,0 +1,151 @@+import { createFileRoute } from '@tanstack/react-router'+import { useState, useEffect } from 'react'+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'+import { authService } from '@/api/auth-service'+import { Button } from '@/components/ui/button'+import { Input } from '@/components/ui/input'+import { Label } from '@/components/ui/label'+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'+import { toast } from 'sonner'+import { useAuthStore } from '@/stores/auth-store'+import { getDisplayName, getInitials } from '@/lib/user-display'+import { SESSION_QUERY_KEY } from '@/hooks/use-auth'++export const Route = createFileRoute('/_auth/dashboard/profile')({+ component: ProfilePage,+})++function ProfilePage() {+ const authUser = useAuthStore((s) => s.user)+ const setAuth = useAuthStore((s) => s.setAuth)+ const token = useAuthStore((s) => s.token)++ const { data: profile, isLoading } = useQuery({+ queryKey: ['profile', 'me'],+ queryFn: authService.getCurrentUser,+ })++ const [form, setForm] = useState({+ first_name: '',+ last_name: '',+ avatar_url: '',+ })++ useEffect(() => {+ if (profile) {+ setForm({+ first_name: profile.first_name ?? '',+ last_name: profile.last_name ?? '',+ avatar_url: profile.avatar_url ?? '',+ })+ }+ }, [profile])++ const queryClient = useQueryClient()++ const updateMutation = useMutation({+ mutationFn: authService.updateProfile,+ onSuccess: (data) => {+ queryClient.invalidateQueries({ queryKey: ['profile', 'me'] })+ queryClient.invalidateQueries({ queryKey: SESSION_QUERY_KEY })+ if (token && authUser) {+ setAuth(token, {+ ...authUser,+ first_name: data.first_name ?? undefined,+ last_name: data.last_name ?? undefined,+ avatar_url: data.avatar_url ?? undefined,+ username: [data.first_name, data.last_name].filter(Boolean).join(' ') || authUser.email,+ })+ }+ toast.success('Profile updated')+ },+ onError: () => toast.error('Failed to update profile'),+ })++ const handleSubmit = (e: React.FormEvent) => {+ e.preventDefault()+ updateMutation.mutate(form)+ }++ const handleChange = (field: string, value: string) => {+ setForm((prev) => ({ ...prev, [field]: value }))+ }++ if (isLoading) {+ return (+ <div className="flex-1 h-full flex items-center justify-center">+ <div className="w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin" />+ </div>+ )+ }++ const displayName = getDisplayName(profile)+ const initials = getInitials(profile)++ return (+ <main className="flex-1 h-full overflow-auto">+ <div className="max-w-xl mx-auto px-8 py-12 space-y-8">+ <div>+ <h1 className="text-2xl font-semibold tracking-tight">Profile</h1>+ <p className="text-sm text-muted-foreground mt-1">Manage your account information.</p>+ </div>++ {/* Avatar preview */}+ <div className="flex items-center gap-4">+ <Avatar className="h-16 w-16">+ {form.avatar_url && <AvatarImage src={form.avatar_url} />}+ <AvatarFallback className="text-lg">{initials}</AvatarFallback>+ </Avatar>+ <div>+ <p className="font-medium">{displayName}</p>+ <p className="text-sm text-muted-foreground">{profile?.email}</p>+ </div>+ </div>++ <form onSubmit={handleSubmit} className="space-y-5">+ <div className="grid grid-cols-2 gap-4">+ <div className="space-y-2">+ <Label htmlFor="first_name">First name</Label>+ <Input+ id="first_name"+ value={form.first_name}+ onChange={(e) => handleChange('first_name', e.target.value)}+ placeholder="John"+ />+ </div>+ <div className="space-y-2">+ <Label htmlFor="last_name">Last name</Label>+ <Input+ id="last_name"+ value={form.last_name}+ onChange={(e) => handleChange('last_name', e.target.value)}+ placeholder="Doe"+ />+ </div>+ </div>++ <div className="space-y-2">+ <Label htmlFor="avatar_url">Avatar URL</Label>+ <Input+ id="avatar_url"+ value={form.avatar_url}+ onChange={(e) => handleChange('avatar_url', e.target.value)}+ placeholder="https://..."+ />+ </div>++ <div className="space-y-2">+ <Label>Email</Label>+ <Input value={profile?.email ?? ''} disabled className="opacity-60" />+ </div>++ <div className="pt-2">+ <Button type="submit" disabled={updateMutation.isPending}>+ {updateMutation.isPending ? 'Saving...' : 'Save changes'}+ </Button>+ </div>+ </form>+ </div>+ </main>+ )+}diff --git a/flowsint-app/src/stores/auth-store.ts b/flowsint-app/src/stores/auth-store.tsindex f13ed3c3..4c3e1877 100644--- a/flowsint-app/src/stores/auth-store.ts+++ b/flowsint-app/src/stores/auth-store.ts@@ -6,6 +6,9 @@ export interface User {id: stringusername: stringemail: string+ first_name?: string+ last_name?: string+ avatar_url?: string}interface AuthState {diff --git a/flowsint-app/src/types/investigation.ts b/flowsint-app/src/types/investigation.tsindex 09c7f9b9..ccdf2828 100644--- a/flowsint-app/src/types/investigation.ts+++ b/flowsint-app/src/types/investigation.ts@@ -2,6 +2,8 @@ import { type Sketch } from './sketch'import { type Profile } from './profile'import { type Analysis } from './analysis'+export type InvestigationRole = 'owner' | 'admin' | 'editor' | 'viewer'+export interface Investigation {id: stringname: string@@ -13,4 +15,12 @@ export interface Investigation {owner: Profileowner_id: stringstatus: string+ current_user_role: InvestigationRole | null+}++export interface Collaborator {+ id: string+ user_id: string+ roles: string[]+ user: Profile | null}diff --git a/flowsint-app/src/types/profile.ts b/flowsint-app/src/types/profile.tsindex 41b8118e..12e9898f 100644--- a/flowsint-app/src/types/profile.ts+++ b/flowsint-app/src/types/profile.ts@@ -4,4 +4,5 @@ export interface Profile {last_name: stringid: stringavatar_url?: string+ email?: string}