Skip to content

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

feat(app): RBAC permission gating, UserAvatar component, share dialog redesign and responsive grids

dextmorgn47b0c05115e7
diff --git a/flowsint-app/src/components/analyses/analyses-list.tsx b/flowsint-app/src/components/analyses/analyses-list.tsx
index 546f4be3..164baff8 100644
--- a/flowsint-app/src/components/analyses/analyses-list.tsx
+++ b/flowsint-app/src/components/analyses/analyses-list.tsx
@@ -13,6 +13,7 @@ import { toast } from 'sonner'
import { formatDistanceToNow } from 'date-fns'
import { queryKeys } from '@/api/query-keys'
import ErrorState from '../shared/error-state'
+import { usePermissions } from '@/hooks/use-can'
const AnalysisItem = ({ analysis, active }: { analysis: Analysis; active: boolean }) => {
return (
@@ -46,6 +47,7 @@ const AnalysisItem = ({ analysis, active }: { analysis: Analysis; active: boolea
}
const AnalysisList = () => {
+ const { canEdit } = usePermissions()
const { investigationId, id, type } = useParams({ strict: false })
const queryClient = useQueryClient()
const navigate = useNavigate()
@@ -112,16 +114,18 @@ const AnalysisList = () => {
return (
<div className="w-full h-full bg-card flex flex-col overflow-hidden">
<div className="p-2 flex items-center h-11 gap-2 border-b shrink-0">
- <Button
- variant="ghost"
- size="icon"
- className="h-7 w-7"
- onClick={() => createMutation.mutate()}
- disabled={createMutation.isPending}
- title="Create New analysis"
- >
- <PlusIcon className="h-4 w-4" />
- </Button>
+ {canEdit && (
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-7 w-7"
+ onClick={() => createMutation.mutate()}
+ disabled={createMutation.isPending}
+ title="Create New analysis"
+ >
+ <PlusIcon className="h-4 w-4" />
+ </Button>
+ )}
<Input
type="search"
className="!border border-border h-7"
diff --git a/flowsint-app/src/components/dashboard/empty-states.tsx b/flowsint-app/src/components/dashboard/empty-states.tsx
index eba8ffea..3e37c9d2 100644
--- a/flowsint-app/src/components/dashboard/empty-states.tsx
+++ b/flowsint-app/src/components/dashboard/empty-states.tsx
@@ -5,6 +5,7 @@ import NewAnalysis from "../analyses/new-analysis"
interface EmptyStateProps {
onAction?: () => void
+ canCreate?: boolean
}
export function EmptyInvestigations({ onAction }: EmptyStateProps) {
@@ -70,7 +71,7 @@ export function EmptySketches({ onAction }: EmptyStateProps) {
)
}
-export function EmptyAnalyses({ onAction }: EmptyStateProps) {
+export function EmptyAnalyses({ onAction, canCreate = true }: EmptyStateProps) {
return (
<div className="flex flex-col items-center justify-center py-10 px-4">
{/* Minimal document illustration */}
@@ -93,12 +94,14 @@ export function EmptyAnalyses({ onAction }: EmptyStateProps) {
<p className="text-xs text-muted-foreground text-center max-w-[200px] mb-4">
Document findings, patterns, and conclusions from your investigation
</p>
- <NewAnalysis>
- <Button onClick={onAction} variant="ghost" size="sm" className="h-7 text-xs gap-1.5">
- <Plus className="w-3.5 h-3.5" />
- Write analysis
- </Button>
- </NewAnalysis>
+ {canCreate && (
+ <NewAnalysis>
+ <Button onClick={onAction} variant="ghost" size="sm" className="h-7 text-xs gap-1.5">
+ <Plus className="w-3.5 h-3.5" />
+ Write analysis
+ </Button>
+ </NewAnalysis>
+ )}
</div>
)
}
diff --git a/flowsint-app/src/components/dashboard/investigation/analyses-section.tsx b/flowsint-app/src/components/dashboard/investigation/analyses-section.tsx
index 91fe32c9..7522f210 100644
--- a/flowsint-app/src/components/dashboard/investigation/analyses-section.tsx
+++ b/flowsint-app/src/components/dashboard/investigation/analyses-section.tsx
@@ -28,7 +28,7 @@ export function AnalysesSection({ analyses, canCreate = true }: AnalysesSectionP
{analyses.length === 0 ?
<div className="border border-dashed rounded-md">
- <EmptyAnalyses />
+ <EmptyAnalyses canCreate={canCreate} />
</div> :
<div className="space-y-1">
{analyses.map((analysis) => (
diff --git a/flowsint-app/src/components/dashboard/investigation/case-header.tsx b/flowsint-app/src/components/dashboard/investigation/case-header.tsx
index 7f6e0f73..7ae078c1 100644
--- a/flowsint-app/src/components/dashboard/investigation/case-header.tsx
+++ b/flowsint-app/src/components/dashboard/investigation/case-header.tsx
@@ -1,26 +1,34 @@
-import type React from "react"
-import { Button } from "@/components/ui/button"
+import type React from 'react'
+import { Badge } from '@/components/ui/badge'
+import { Button } from '@/components/ui/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu"
-import { MoreHorizontal, Star, Share, Trash2, Clock } from "lucide-react"
-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 { 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"
+ DropdownMenuTrigger
+} from '@/components/ui/dropdown-menu'
+import { MoreHorizontal, Star, Share, Trash2, Clock, Crown, Shield, Pencil, Eye } from 'lucide-react'
+import { Investigation, Collaborator } from '@/types'
+import { formatDistanceToNow } from 'date-fns'
+import { useState } from 'react'
+import { cn } from '@/lib/utils'
+import { AvatarGroup } from '@/components/ui/avatar'
+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 type { InvestigationRole } from '@/types'
+import { ShareDialog } from './share-dialog'
+
+const ROLE_CONFIG: Record<InvestigationRole, { label: string; icon: typeof Eye; className: string }> = {
+ owner: { label: 'Owner', icon: Crown, className: 'bg-amber-500/15 text-amber-700 border-amber-500/30 dark:text-amber-400' },
+ admin: { label: 'Admin', icon: Shield, className: 'bg-purple-500/15 text-purple-700 border-purple-500/30 dark:text-purple-400' },
+ editor: { label: 'Editor', icon: Pencil, className: 'bg-blue-500/15 text-blue-700 border-blue-500/30 dark:text-blue-400' },
+ viewer: { label: 'Viewer', icon: Eye, className: 'bg-zinc-500/15 text-zinc-700 border-zinc-500/30 dark:text-zinc-400' },
+}
type CaseOverviewPageProps = {
investigation: Investigation
@@ -31,14 +39,14 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {
addSuffix: true
})
const router = useRouter()
- const { canDelete, canManage } = usePermissions()
+ const { canDelete, canManage, role } = usePermissions()
const { confirm } = useConfirm()
const queryClient = useQueryClient()
const { data: collaborators = [] } = useQuery<Collaborator[]>({
queryKey: queryKeys.investigations.collaborators(investigation.id),
- queryFn: () => investigationService.getCollaborators(investigation.id),
+ queryFn: () => investigationService.getCollaborators(investigation.id)
})
const handleDeleteInvestigation = async () => {
@@ -65,7 +73,7 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {
queryClient.removeQueries({
queryKey: queryKeys.investigations.flows(investigation.id)
})
- router.navigate({ to: "/dashboard" })
+ router.navigate({ to: '/dashboard' })
})
toast.promise(deletePromise, {
@@ -80,7 +88,9 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {
<div className="space-y-6 pb-6 border-b border-border">
{/* 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>
+ <Link to={'/dashboard'} className="hover:text-foreground cursor-pointer transition-colors">
+ Cases
+ </Link>
<span>/</span>
<span className="text-foreground">{investigation.name}</span>
</div>
@@ -89,15 +99,33 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {
<div className="flex items-start justify-between gap-4">
<div className="space-y-2 flex-1">
<div className="flex items-center gap-3">
- <h1 className="text-2xl font-semibold text-foreground tracking-tight">{investigation.name}</h1>
+ <h1 className="text-2xl font-semibold text-foreground tracking-tight">
+ {investigation.name}
+ </h1>
<FavoriteButton />
</div>
+ {/* Role badge */}
+ {role && (() => {
+ const config = ROLE_CONFIG[role]
+ const Icon = config.icon
+ return (
+ <Badge className={cn('gap-1 text-xs font-medium shadow-none', config.className)}>
+ <Icon className="w-3 h-3" />
+ {config.label}
+ </Badge>
+ )
+ })()}
+
{/* 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" />
- <PropertyPill label="Updated" value={lastUpdated} icon={<Clock className="w-3 h-3" />} />
+ <PropertyPill
+ label="Updated"
+ value={lastUpdated}
+ icon={<Clock className="w-3 h-3" />}
+ />
</div>
</div>
@@ -130,20 +158,15 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {
{/* Team */}
<div className="flex items-center gap-2">
- <div className="flex -space-x-1.5">
- {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>
+ <AvatarGroup users={collaborators.map((c) => c.user)} size="md" />
<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>
+ <button className="text-xs text-muted-foreground hover:text-foreground transition-colors ml-1">
+ + Invite
+ </button>
</ShareDialog>
)}
</div>
@@ -154,8 +177,8 @@ export function CaseHeader({ investigation }: CaseOverviewPageProps) {
function PropertyPill({
label,
value,
- valueClass = "text-foreground",
- icon,
+ valueClass = 'text-foreground',
+ icon
}: {
label: string
value: string
@@ -177,12 +200,14 @@ function PropertyPill({
// return <span className="px-2 py-0.5 rounded bg-secondary text-xs text-secondary-foreground">{children}</span>
// }
-
const FavoriteButton = () => {
const [fav, setFav] = useState<boolean>(false)
return (
- <button onClick={() => setFav(!fav)} className={cn("text-muted-foreground hover:text-warning transition-colors")}>
- <Star className={cn("w-4 h-4", fav && "text-warning fill-warning")} />
+ <button
+ onClick={() => setFav(!fav)}
+ className={cn('text-muted-foreground hover:text-warning transition-colors')}
+ >
+ <Star className={cn('w-4 h-4', fav && 'text-warning fill-warning')} />
</button>
)
-}
\ No newline at end of file
+}
diff --git a/flowsint-app/src/components/dashboard/investigation/investigations-list.tsx b/flowsint-app/src/components/dashboard/investigation/investigations-list.tsx
index caa07d40..f068cbe5 100644
--- a/flowsint-app/src/components/dashboard/investigation/investigations-list.tsx
+++ b/flowsint-app/src/components/dashboard/investigation/investigations-list.tsx
@@ -126,7 +126,8 @@ export function InvestigationsList({
</table>
</div>
) : (
- <div className="grid grid-cols-3 gap-3">
+ <div style={{ containerType: 'inline-size' }}>
+ <div className="grid grid-cols-1 cq-sm:grid-cols-2 cq-md:grid-cols-3 gap-3">
{filteredInvestigations.length === 0 && <div>No investigation found.</div>}
{filteredInvestigations.map((inv) => (
<Link
@@ -168,6 +169,7 @@ export function InvestigationsList({
</Link>
))}
</div>
+ </div>
)}
</div>
)
diff --git a/flowsint-app/src/components/dashboard/investigation/metrics-grid.tsx b/flowsint-app/src/components/dashboard/investigation/metrics-grid.tsx
index 1570d781..fbe2580b 100644
--- a/flowsint-app/src/components/dashboard/investigation/metrics-grid.tsx
+++ b/flowsint-app/src/components/dashboard/investigation/metrics-grid.tsx
@@ -1,7 +1,6 @@
-import { Network, FileText, Users, Shield, Paperclip, CheckCircle } from "lucide-react"
+import { Network, FileText, Users, Shield } from "lucide-react"
import { Investigation } from "@/types"
import { useMemo } from "react"
-import { cn } from "@/lib/utils"
type CaseOverviewPageProps = {
investigation: Investigation
@@ -19,7 +18,8 @@ export function MetricsGrid({ investigation }: CaseOverviewPageProps) {
], [sketchCount, analysisCount])
return (
- <div className={cn("grid border grid-cols-3 gap-px bg-border rounded-lg overflow-hidden my-6", `md:grid-cols-${metrics.length}`)} >
+ <div className="my-6" style={{ containerType: 'inline-size' }}>
+ <div className="grid border grid-cols-2 cq-sm:grid-cols-4 gap-px bg-border rounded-lg overflow-hidden">
{
metrics.map((metric) => (
<div
@@ -32,6 +32,7 @@ export function MetricsGrid({ investigation }: CaseOverviewPageProps) {
</div>
))
}
- </ div>
+ </div>
+ </div>
)
}
diff --git a/flowsint-app/src/components/dashboard/investigation/share-dialog.tsx b/flowsint-app/src/components/dashboard/investigation/share-dialog.tsx
index 4aca5e3b..f68a586a 100644
--- a/flowsint-app/src/components/dashboard/investigation/share-dialog.tsx
+++ b/flowsint-app/src/components/dashboard/investigation/share-dialog.tsx
@@ -8,33 +8,113 @@ import type { Collaborator, InvestigationRole, Profile } from '@/types'
import {
Dialog,
DialogContent,
+ DialogDescription,
DialogHeader,
DialogTitle,
- DialogTrigger,
+ DialogTrigger
} from '@/components/ui/dialog'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
- SelectValue,
+ SelectValue
} from '@/components/ui/select'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger
+} from '@/components/ui/dropdown-menu'
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'
+import { UserAvatar } from '@/components/ui/avatar'
+import { Badge } from '@/components/ui/badge'
+import { Separator } from '@/components/ui/separator'
+import { Skeleton } from '@/components/ui/skeleton'
+import { X, UserPlus, Crown, Shield, Pencil, Eye, Users, Check } from 'lucide-react'
+import { getDisplayName } from '@/lib/user-display'
+import { cn } from '@/lib/utils'
-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 },
+const ROLE_OPTIONS: {
+ value: InvestigationRole
+ label: string
+ icon: typeof Eye
+ className: string
+}[] = [
+ {
+ value: 'admin',
+ label: 'Admin',
+ icon: Shield,
+ className: 'bg-purple-500/15 text-purple-700 border-purple-500/30 dark:text-purple-400'
+ },
+ {
+ value: 'editor',
+ label: 'Editor',
+ icon: Pencil,
+ className: 'bg-blue-500/15 text-blue-700 border-blue-500/30 dark:text-blue-400'
+ },
+ {
+ value: 'viewer',
+ label: 'Viewer',
+ icon: Eye,
+ className: 'bg-zinc-500/15 text-zinc-700 border-zinc-500/30 dark:text-zinc-400'
+ }
]
+const ROLE_BADGE: Record<
+ InvestigationRole,
+ { label: string; icon: typeof Eye; className: string }
+> = {
+ owner: {
+ label: 'Owner',
+ icon: Crown,
+ className: 'bg-amber-500/15 text-amber-700 border-amber-500/30 dark:text-amber-400'
+ },
+ admin: {
+ label: 'Admin',
+ icon: Shield,
+ className: 'bg-purple-500/15 text-purple-700 border-purple-500/30 dark:text-purple-400'
+ },
+ editor: {
+ label: 'Editor',
+ icon: Pencil,
+ className: 'bg-blue-500/15 text-blue-700 border-blue-500/30 dark:text-blue-400'
+ },
+ viewer: {
+ label: 'Viewer',
+ icon: Eye,
+ className: 'bg-zinc-500/15 text-zinc-700 border-zinc-500/30 dark:text-zinc-400'
+ }
+}
+
function getRoleFromCollaborator(collab: Collaborator): InvestigationRole {
return (collab.roles[0] ?? 'viewer') as InvestigationRole
}
+const RoleBadge = ({
+ role,
+ className,
+ ...props
+}: { role: InvestigationRole; className?: string } & React.ComponentProps<'div'>) => {
+ const config = ROLE_BADGE[role]
+ const Icon = config.icon
+ return (
+ <Badge
+ variant="outline"
+ className={cn(
+ 'gap-1 text-[11px] font-medium shadow-none px-1.5 py-0 cursor-default',
+ config.className,
+ className
+ )}
+ {...props}
+ >
+ <Icon className="w-3 h-3" />
+ {config.label}
+ </Badge>
+ )
+}
+
interface ShareDialogProps {
investigationId: string
children: React.ReactNode
@@ -53,10 +133,9 @@ export function ShareDialog({ investigationId, children }: ShareDialogProps) {
const { data: collaborators = [], isLoading } = useQuery<Collaborator[]>({
queryKey: queryKeys.investigations.collaborators(investigationId),
queryFn: () => investigationService.getCollaborators(investigationId),
- enabled: open,
+ enabled: open
})
- // Debounced user search
const handleQueryChange = useCallback((value: string) => {
setQuery(value)
setSelectedEmail(value)
@@ -79,7 +158,9 @@ export function ShareDialog({ investigationId, children }: ShareDialogProps) {
}, [])
useEffect(() => {
- return () => { if (debounceRef.current) clearTimeout(debounceRef.current) }
+ return () => {
+ if (debounceRef.current) clearTimeout(debounceRef.current)
+ }
}, [])
const handleSelectUser = (user: Profile) => {
@@ -94,7 +175,7 @@ export function ShareDialog({ investigationId, children }: ShareDialogProps) {
investigationService.addCollaborator(investigationId, body),
onSuccess: () => {
queryClient.invalidateQueries({
- queryKey: queryKeys.investigations.collaborators(investigationId),
+ queryKey: queryKeys.investigations.collaborators(investigationId)
})
setQuery('')
setSelectedEmail('')
@@ -103,7 +184,7 @@ export function ShareDialog({ investigationId, children }: ShareDialogProps) {
onError: (error: any) => {
const message = error?.message || 'Failed to add collaborator'
toast.error(message)
- },
+ }
})
const updateMutation = useMutation({
@@ -111,11 +192,11 @@ export function ShareDialog({ investigationId, children }: ShareDialogProps) {
investigationService.updateCollaboratorRole(investigationId, userId, { role }),
onSuccess: () => {
queryClient.invalidateQueries({
- queryKey: queryKeys.investigations.collaborators(investigationId),
+ queryKey: queryKeys.investigations.collaborators(investigationId)
})
toast.success('Role updated')
},
- onError: () => toast.error('Failed to update role'),
+ onError: () => toast.error('Failed to update role')
})
const removeMutation = useMutation({
@@ -123,11 +204,11 @@ export function ShareDialog({ investigationId, children }: ShareDialogProps) {
investigationService.removeCollaborator(investigationId, userId),
onSuccess: () => {
queryClient.invalidateQueries({
- queryKey: queryKeys.investigations.collaborators(investigationId),
+ queryKey: queryKeys.investigations.collaborators(investigationId)
})
toast.success('Collaborator removed')
},
- onError: () => toast.error('Failed to remove collaborator'),
+ onError: () => toast.error('Failed to remove collaborator')
})
const handleInvite = () => {
@@ -138,130 +219,186 @@ export function ShareDialog({ investigationId, children }: ShareDialogProps) {
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>{children}</DialogTrigger>
- <DialogContent className="sm:max-w-md">
- <DialogHeader>
- <DialogTitle>Share investigation</DialogTitle>
+ <DialogContent className="sm:max-w-xl gap-0 p-0 overflow-hidden">
+ <DialogHeader className="px-5 pt-5 pb-4">
+ <DialogTitle className="text-base">Share investigation</DialogTitle>
+ <DialogDescription className="text-sm text-muted-foreground">
+ Invite collaborators and manage access.
+ </DialogDescription>
</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 className="px-5 pb-4">
+ <div className="flex items-center gap-2">
+ <div className="relative flex-1">
+ <Input
+ placeholder="Search by name or 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)}
+ className="h-9"
+ />
+ {showSuggestions && suggestions.length > 0 && (
+ <div className="absolute z-50 top-full mt-1 w-full rounded-md border bg-popover shadow-lg 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)
+ }}
+ >
+ <UserAvatar user={user} size="sm" />
+ <div className="flex-1 min-w-0">
+ <p className="truncate text-sm font-medium">{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-[100px] h-9">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {ROLE_OPTIONS.map((opt) => {
+ const Icon = opt.icon
+ return (
+ <SelectItem key={opt.value} value={opt.value}>
+ <span className="flex items-center gap-1.5">
+ <Icon className="w-3.5 h-3.5 opacity-60" />
+ {opt.label}
+ </span>
+ </SelectItem>
+ )
+ })}
+ </SelectContent>
+ </Select>
+ <Button
+ size="sm"
+ className="h-9 px-3"
+ onClick={handleInvite}
+ disabled={!selectedEmail.trim() || addMutation.isPending}
+ >
+ <UserPlus className="w-4 h-4 mr-1.5" />
+ Invite
+ </Button>
</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>
+ <Separator />
+
{/* Collaborators list */}
- <div className="mt-2 space-y-1 max-h-64 overflow-y-auto">
+ <div className="max-h-72 overflow-y-auto">
{isLoading ? (
- <div className="py-4 text-center text-sm text-muted-foreground">Loading...</div>
+ <div className="p-5 space-y-3">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div key={i} className="flex items-center gap-3">
+ <Skeleton className="h-8 w-8 rounded-full" />
+ <div className="flex-1 space-y-1.5">
+ <Skeleton className="h-3.5 w-28" />
+ <Skeleton className="h-3 w-36" />
+ </div>
+ <Skeleton className="h-5 w-14 rounded-full" />
+ </div>
+ ))}
+ </div>
) : collaborators.length === 0 ? (
- <div className="py-4 text-center text-sm text-muted-foreground">No collaborators yet</div>
+ <div className="py-10 flex flex-col items-center gap-2 text-center">
+ <Users className="w-8 h-8 text-muted-foreground/30" />
+ <p className="text-sm text-muted-foreground">No collaborators yet</p>
+ </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 className="p-2">
+ {collaborators.map((collab) => {
+ const collabRole = getRoleFromCollaborator(collab)
+ const isOwner = collabRole === 'owner'
+ return (
+ <div
+ key={collab.id}
+ className="flex items-center gap-3 px-3 py-2.5 rounded-md hover:bg-muted/50 transition-colors group"
+ >
+ <UserAvatar user={collab.user} size="md" />
+ <div className="flex-1 min-w-0">
+ <p className="text-sm font-medium truncate">{getDisplayName(collab.user)}</p>
+ {collab.user?.email && (
+ <p className="text-xs text-muted-foreground truncate">
+ {collab.user.email}
+ </p>
+ )}
</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>
- )
- })
+ {isOwner ? (
+ <RoleBadge role="owner" />
+ ) : (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button>
+ <RoleBadge role={collabRole} className="cursor-pointer hover:opacity-80 transition-opacity" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="min-w-[140px]">
+ {ROLE_OPTIONS.map((opt) => {
+ const Icon = opt.icon
+ const isActive = opt.value === collabRole
+ return (
+ <DropdownMenuItem
+ key={opt.value}
+ onClick={() => updateMutation.mutate({ userId: collab.user_id, role: opt.value })}
+ className="flex items-center gap-2"
+ >
+ <Icon className="w-3.5 h-3.5 opacity-60" />
+ {opt.label}
+ {isActive && <Check className="w-3.5 h-3.5 ml-auto" />}
+ </DropdownMenuItem>
+ )
+ })}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ <Button
+ variant="ghost"
+ size="icon"
+ className={cn(
+ 'h-7 w-7 shrink-0',
+ isOwner
+ ? 'invisible'
+ : 'text-muted-foreground/50 hover:text-destructive opacity-0 group-hover:opacity-100 transition-opacity'
+ )}
+ onClick={() => !isOwner && removeMutation.mutate(collab.user_id)}
+ disabled={isOwner}
+ >
+ <X className="w-3.5 h-3.5" />
+ </Button>
+ </div>
+ )
+ })}
+ </div>
)}
</div>
+
+ {/* Footer */}
+ {collaborators.length > 0 && (
+ <>
+ <Separator />
+ <div className="px-5 py-3">
+ <p className="text-xs text-muted-foreground">
+ {collaborators.length} member{collaborators.length !== 1 ? 's' : ''} have access
+ </p>
+ </div>
+ </>
+ )}
</DialogContent>
</Dialog>
)
diff --git a/flowsint-app/src/components/dashboard/investigation/sketches-section.tsx b/flowsint-app/src/components/dashboard/investigation/sketches-section.tsx
index ec8bab95..bf414d93 100644
--- a/flowsint-app/src/components/dashboard/investigation/sketches-section.tsx
+++ b/flowsint-app/src/components/dashboard/investigation/sketches-section.tsx
@@ -32,7 +32,8 @@ export function SketchesSection({ sketches, canCreate = true }: SketchesSectionP
{isEmpty ? (
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">
+ <div style={{ containerType: 'inline-size' }}>
+ <div className="grid grid-cols-1 cq-sm:grid-cols-2 cq-md:grid-cols-3 cq-lg:grid-cols-4 gap-3">
{sketches.map((sketch) => (
<Link
to="/dashboard/investigations/$investigationId/$type/$id"
@@ -75,6 +76,7 @@ export function SketchesSection({ sketches, canCreate = true }: SketchesSectionP
</Link>
))}
</div>
+ </div>
)
}
</section >
diff --git a/flowsint-app/src/components/dashboard/overview/dashboard-stats.tsx b/flowsint-app/src/components/dashboard/overview/dashboard-stats.tsx
index ef8c658e..b72b5343 100644
--- a/flowsint-app/src/components/dashboard/overview/dashboard-stats.tsx
+++ b/flowsint-app/src/components/dashboard/overview/dashboard-stats.tsx
@@ -16,7 +16,8 @@ export function DashboardStats({ casesCount, activeCasesCount }: DashboardStatsP
], [casesCount, activeCasesCount])
return (
- <div className="grid grid-cols-4 gap-4 mt-8">
+ <div className="mt-8" style={{ containerType: 'inline-size' }}>
+ <div className="grid grid-cols-1 cq-sm:grid-cols-2 cq-lg:grid-cols-4 gap-4">
{stats.map((stat) => (
<div key={stat.label} className="px-4 py-3 border border-border rounded-lg bg-card/30">
<div className="flex items-center gap-3">
@@ -31,5 +32,6 @@ export function DashboardStats({ casesCount, activeCasesCount }: DashboardStatsP
</div>
))}
</div>
+ </div>
)
}
diff --git a/flowsint-app/src/components/layout/top-navbar.tsx b/flowsint-app/src/components/layout/top-navbar.tsx
index 63db5b20..aa38cb8b 100644
--- a/flowsint-app/src/components/layout/top-navbar.tsx
+++ b/flowsint-app/src/components/layout/top-navbar.tsx
@@ -3,10 +3,15 @@ import { Link, useNavigate, useParams } from '@tanstack/react-router'
import InvestigationSelector from './investigation-selector'
import SketchSelector from './sketch-selector'
import { memo, useCallback } from 'react'
+import { useQuery } from '@tanstack/react-query'
import { Switch } from '../ui/switch'
import { Label } from '../ui/label'
import { useLayoutStore } from '@/stores/layout-store'
import { Button } from '@/components/ui/button'
+import { AvatarGroup } from '@/components/ui/avatar'
+import { investigationService } from '@/api/investigation-service'
+import { queryKeys } from '@/api/query-keys'
+import type { Collaborator } from '@/types'
import { ImportSheet } from '../sketches/import-sheet'
import {
DropdownMenu,
@@ -22,6 +27,7 @@ import { Settings2, Upload } from 'lucide-react'
import { isMac } from '@/lib/utils'
import { useGraphSettingsStore } from '@/stores/graph-settings-store'
import { useMutation } from '@tanstack/react-query'
+import { Separator } from '../ui/separator'
import { useConfirm } from '../use-confirm-dialog'
import { sketchService } from '@/api/sketch-service'
import { toast } from 'sonner'
@@ -33,6 +39,12 @@ export const TopNavbar = memo(() => {
const toggleAnalysis = useLayoutStore((s) => s.toggleAnalysis)
const isOpenAnalysis = useLayoutStore((s) => s.isOpenAnalysis)
+ const { data: collaborators = [] } = useQuery<Collaborator[]>({
+ queryKey: queryKeys.investigations.collaborators(investigationId!),
+ queryFn: () => investigationService.getCollaborators(investigationId!),
+ enabled: !!investigationId
+ })
+
const handleToggleAnalysis = useCallback(() => toggleAnalysis(), [toggleAnalysis])
return (
@@ -60,7 +72,13 @@ export const TopNavbar = memo(() => {
<Command />
</div>
</div>
- <div className="flex items-center gap-4">
+ <div className="flex items-center gap-3">
+ {investigationId && collaborators.length > 0 && (
+ <>
+ <AvatarGroup users={collaborators.map((c) => c.user)} size="sm" max={5} />
+ <Separator orientation="vertical" className="h-5" />
+ </>
+ )}
<div className="flex items-center space-x-2">
{type === 'graph' && (
<>
@@ -190,7 +208,7 @@ export function InvestigationMenu({
</>
)}
</DropdownMenuContent>
- <ImportSheet sketchId={sketchId} />
+ {canEdit && <ImportSheet sketchId={sketchId} />}
</DropdownMenu>
)
}
diff --git a/flowsint-app/src/components/nav-user.tsx b/flowsint-app/src/components/nav-user.tsx
index 89aa048f..dd6bb756 100644
--- a/flowsint-app/src/components/nav-user.tsx
+++ b/flowsint-app/src/components/nav-user.tsx
@@ -12,15 +12,14 @@ import { ModeToggle } from './mode-toggle'
import { authService } from '@/api/auth-service'
import { useCallback } from 'react'
import { Link, useNavigate } from '@tanstack/react-router'
-import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar'
+import { UserAvatar } from './ui/avatar'
import { useAuthStore } from '@/stores/auth-store'
-import { getDisplayName, getInitials } from '@/lib/user-display'
+import { getDisplayName } 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()
@@ -32,10 +31,7 @@ export function NavUser() {
<DropdownMenuTrigger asChild>
<div className="h-auto flex items-center justify-center">
<Button size="lg" className="p-0 h-auto rounded-full cursor-pointer">
- <Avatar>
- {user?.avatar_url && <AvatarImage src={user.avatar_url} />}
- <AvatarFallback>{initials}</AvatarFallback>
- </Avatar>
+ <UserAvatar user={user} />
</Button>
</div>
</DropdownMenuTrigger>
@@ -46,10 +42,7 @@ 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>
- {user?.avatar_url && <AvatarImage src={user.avatar_url} />}
- <AvatarFallback>{initials}</AvatarFallback>
- </Avatar>
+ <UserAvatar user={user} />
<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>}
diff --git a/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx
index 96506631..9f401678 100644
--- a/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx
+++ b/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx
@@ -6,6 +6,7 @@ import { useParams } from '@tanstack/react-router'
import { toast } from 'sonner'
import { useIcon } from '@/hooks/use-icon'
import { useConfirm } from '@/components/use-confirm-dialog'
+import { usePermissions } from '@/hooks/use-can'
import { sketchService } from '@/api/sketch-service'
import { CopyButton } from '@/components/copy'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
@@ -14,6 +15,7 @@ import { Badge } from '@/components/ui/badge'
import { Input } from '@/components/ui/input'
const EdgeDetailsPanel = memo(() => {
+ const { canEdit } = usePermissions()
const { id: sketchId } = useParams({ strict: false })
const nodes = useGraphStore((s) => s.nodes)
const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)
@@ -146,29 +148,32 @@ const EdgeDetailsPanel = memo(() => {
defaultValue={edge.label || 'Relationship'}
onChange={handleInputChange}
onFocus={(e) => e.stopPropagation()}
- onBlur={handleBlur}
- onKeyDown={handleKeyDown}
+ onBlur={canEdit ? handleBlur : undefined}
+ onKeyDown={canEdit ? handleKeyDown : undefined}
+ readOnly={!canEdit}
/>
<div className="grow" />
- <div className="flex items-center">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="sm"
- onClick={handleDelete}
- className="h-6 w-6 p-0 hover:bg-muted opacity-70 hover:opacity-100 text-destructive hover:text-destructive"
- >
- <Trash2 className="h-3 w-3" strokeWidth={2} />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Delete relationship</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
+ {canEdit && (
+ <div className="flex items-center">
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={handleDelete}
+ className="h-6 w-6 p-0 hover:bg-muted opacity-70 hover:opacity-100 text-destructive hover:text-destructive"
+ >
+ <Trash2 className="h-3 w-3" strokeWidth={2} />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>Delete relationship</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </div>
+ )}
</div>
{/* Content */}
diff --git a/flowsint-app/src/components/sketches/graph/panels/graph-navigation.tsx b/flowsint-app/src/components/sketches/graph/panels/graph-navigation.tsx
index 5bfba032..497c39ba 100644
--- a/flowsint-app/src/components/sketches/graph/panels/graph-navigation.tsx
+++ b/flowsint-app/src/components/sketches/graph/panels/graph-navigation.tsx
@@ -6,8 +6,10 @@ import { ItemsPanel } from './items-panel'
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable'
import { useLayoutStore } from '@/stores/layout-store'
import SelectedItemsPanel from './selected-items-panel'
+import { usePermissions } from '@/hooks/use-can'
const GraphNavigation = () => {
+ const { canEdit } = usePermissions()
const nodes = useGraphStore((s) => s.nodes)
const activeTab = useLayoutStore((s) => s.activeTab)
const setActiveTab = useLayoutStore((s) => s.setActiveTab)
@@ -25,9 +27,11 @@ const GraphNavigation = () => {
<TabsTrigger value="entities">
<Users className="h-3 w-3 opacity-60" /> Entities
</TabsTrigger>
- <TabsTrigger value="items">
- <UserPlus className="h-3 w-3 opacity-60" /> Add
- </TabsTrigger>
+ {canEdit && (
+ <TabsTrigger value="items">
+ <UserPlus className="h-3 w-3 opacity-60" /> Add
+ </TabsTrigger>
+ )}
</TabsList>
<TabsContent
value="entities"
@@ -61,9 +65,11 @@ const GraphNavigation = () => {
</ResizablePanel>
</ResizablePanelGroup>
</TabsContent>
- <TabsContent value="items" className="my-0 grow h-full overflow-hidden min-h-0">
- <ItemsPanel />
- </TabsContent>
+ {canEdit && (
+ <TabsContent value="items" className="my-0 grow h-full overflow-hidden min-h-0">
+ <ItemsPanel />
+ </TabsContent>
+ )}
</Tabs>
</div>
)
diff --git a/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx b/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx
index a7b04293..8b675c68 100644
--- a/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx
+++ b/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx
@@ -20,6 +20,7 @@ import {
} from '@/components/ui/dropdown-menu'
import { GraphNode } from '@/types'
import { Checkbox } from '@/components/ui/checkbox'
+import { usePermissions } from '@/hooks/use-can'
const ITEM_HEIGHT = 40
// Mémoiser le composant NodeRenderer
@@ -31,7 +32,8 @@ const NodeRenderer = memo(
isNodeChecked,
isCurrent,
centerOnNode,
- autoZoomOnCurrentNode
+ autoZoomOnCurrentNode,
+ canEdit
}: {
node: GraphNode
setCurrentNodeId: (nodeId: string | null) => void
@@ -40,6 +42,7 @@ const NodeRenderer = memo(
isCurrent: (nodeId: string) => boolean
centerOnNode: (x: number, y: number) => void
autoZoomOnCurrentNode: boolean
+ canEdit: boolean
}) => {
const handleClick = useCallback(() => {
setCurrentNodeId(node.id)
@@ -65,13 +68,15 @@ const NodeRenderer = memo(
isCurrent(node.id) && 'bg-muted/70'
)}
>
- <div className="pl-2">
- <Checkbox
- checked={isNodeChecked(node.id)}
- onCheckedChange={handleCheckboxChange}
- className="mr-1 border-border"
- />
- </div>
+ {canEdit && (
+ <div className="pl-2">
+ <Checkbox
+ checked={isNodeChecked(node.id)}
+ onCheckedChange={handleCheckboxChange}
+ className="mr-1 border-border"
+ />
+ </div>
+ )}
<button
className={cn(
'flex-1 flex truncate mt-0 text-sm font-medium overflow-hidden duration-0 items-center justify-start p-4 !py-5 rounded-none text-left h-full'
@@ -95,7 +100,8 @@ const VirtualizedItem = memo(
isNodeChecked,
isCurrent,
centerOnNode,
- autoZoomOnCurrentNode
+ autoZoomOnCurrentNode,
+ canEdit
}: {
index: number
node: GraphNode
@@ -105,6 +111,7 @@ const VirtualizedItem = memo(
isCurrent: (nodeId: string) => boolean
centerOnNode: (x: number, y: number) => void
autoZoomOnCurrentNode: boolean
+ canEdit: boolean
}) => {
return (
<NodeRenderer
@@ -115,12 +122,14 @@ const VirtualizedItem = memo(
isNodeChecked={isNodeChecked}
centerOnNode={centerOnNode}
autoZoomOnCurrentNode={autoZoomOnCurrentNode}
+ canEdit={canEdit}
/>
)
}
)
const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?: boolean }) => {
+ const { canEdit } = usePermissions()
const currentNodeId = useGraphStore((state) => state.currentNodeId)
const setCurrentNodeId = useGraphStore((state) => state.setCurrentNodeId)
const setSelectedNodes = useGraphStore((state) => state.setSelectedNodes)
@@ -231,9 +240,11 @@ const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?:
{/* Header fixe */}
<div className="sticky border-b top-0 p-2 bg-card z-10 shrink-0">
<div className="flex items-center gap-2">
- <div>
- <Checkbox onCheckedChange={handleCheckAll} className="mr-1" />
- </div>
+ {canEdit && (
+ <div>
+ <Checkbox onCheckedChange={handleCheckAll} className="mr-1" />
+ </div>
+ )}
<Badge className="h-7" variant={'outline'}>
<span className="font-semibold">
{filters?.length || searchQuery
@@ -369,6 +380,7 @@ const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?:
isNodeChecked={isNodeChecked}
centerOnNode={centerOnNode}
autoZoomOnCurrentNode={autoZoomOnCurrentNode}
+ canEdit={canEdit}
/>
</div>
)
diff --git a/flowsint-app/src/components/sketches/toolbar.tsx b/flowsint-app/src/components/sketches/toolbar.tsx
index 375971e4..bfea3c94 100644
--- a/flowsint-app/src/components/sketches/toolbar.tsx
+++ b/flowsint-app/src/components/sketches/toolbar.tsx
@@ -27,6 +27,7 @@ import { Separator } from '../ui/separator'
import { ViewToggle } from './view-toggle'
import { NetworkIcon } from '../icons/network'
import { useKeyboard } from '@/hooks/use-keyboard'
+import { usePermissions } from '@/hooks/use-can'
import {
DropdownMenu,
DropdownMenuContent,
@@ -105,6 +106,7 @@ const FloatingBar = ({
export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean }) {
const { confirm } = useConfirm()
+ const { canEdit } = usePermissions()
const { id: sketchId } = useParams({ strict: false })
const view = useGraphControls((s) => s.view)
const setView = useGraphControls((s) => s.setView)
@@ -328,14 +330,14 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
icon={<GitPullRequestArrow className="h-4 w-4 opacity-70" />}
tooltip="Connect"
onClick={handleOpenAddRelationDialog}
- disabled={!areExactlyTwoSelected}
+ disabled={!canEdit || !areExactlyTwoSelected}
badge={areExactlyTwoSelected ? 2 : null}
/>
<ToolbarButton
icon={<Merge className="h-4 w-4 opacity-70" />}
tooltip="Merge"
onClick={handleOpenMergeDialog}
- disabled={!areMergeable}
+ disabled={!canEdit || !areMergeable}
badge={areMergeable ? selectedNodes.length : null}
/>
<PathFinder />
@@ -344,13 +346,13 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
icon={<NetworkIcon className="h-4 w-4 opacity-70" />}
tooltip="Force layout"
onClick={handleApplyForceLayout}
- disabled={isLoading || view !== 'graph'}
+ disabled={!canEdit || isLoading || view !== 'graph'}
/>
<ToolbarButton
icon={<GitFork strokeWidth={1.4} className="h-4 w-4 opacity-70 rotate-180" />}
tooltip="Hierarchy layout"
onClick={handleApplyHierarchyLayout}
- disabled={isLoading || view !== 'graph'}
+ disabled={!canEdit || isLoading || view !== 'graph'}
/>
</FloatingBar>
)}
diff --git a/flowsint-app/src/components/table/nodes-view.tsx b/flowsint-app/src/components/table/nodes-view.tsx
index e672faf2..700aa195 100644
--- a/flowsint-app/src/components/table/nodes-view.tsx
+++ b/flowsint-app/src/components/table/nodes-view.tsx
@@ -16,6 +16,7 @@ import { Checkbox } from '@/components/ui/checkbox'
import { CopyButton } from '../copy'
import { GraphNode } from '@/types'
import { formatDistanceToNow } from 'date-fns'
+import { usePermissions } from '@/hooks/use-can'
export type RelationshipType = {
source: GraphNode
@@ -31,13 +32,15 @@ interface NodeItemProps {
onNodeClick: (node: GraphNode) => void
isSelected: boolean
onSelectionChange: (node: GraphNode, checked: boolean) => void
+ canEdit: boolean
}
const NodeItem = memo(function NodeItem({
node,
onNodeClick,
isSelected,
- onSelectionChange
+ onSelectionChange,
+ canEdit
}: NodeItemProps) {
const SourceIcon = useIcon(node.nodeType, {
nodeColor: node.nodeColor,
@@ -77,13 +80,15 @@ const NodeItem = memo(function NodeItem({
<div
className="grid items-center h-14 gap-3 text-sm border-b last:border-b-0"
style={{
- gridTemplateColumns: '24px 32px auto 1fr 140px 160px 32px'
+ gridTemplateColumns: canEdit ? '24px 32px auto 1fr 140px 160px 32px' : '32px auto 1fr 140px 160px 32px'
}}
>
{/* Checkbox */}
- <div className="flex items-center">
- <Checkbox checked={isSelected} onCheckedChange={handleCheckboxChange} />
- </div>
+ {canEdit && (
+ <div className="flex items-center">
+ <Checkbox checked={isSelected} onCheckedChange={handleCheckboxChange} />
+ </div>
+ )}
{/* Icon */}
<div className="flex items-center justify-center">
@@ -139,6 +144,7 @@ type NodesTableProps = {
nodes: GraphNode[]
}
export default function NodesTable({ nodes }: NodesTableProps) {
+ const { canEdit } = usePermissions()
const [searchQuery, setSearchQuery] = useState('')
const [selectedType, setSelectedType] = useState<string>('all')
const parentRef = useRef<HTMLDivElement>(null)
@@ -284,19 +290,21 @@ export default function NodesTable({ nodes }: NodesTableProps) {
{/* Table Header */}
<div
className="grid items-center h-11 px-4 bg-muted/50 p-2 rounded-t-md border text-sm font-medium text-muted-foreground"
- style={{ gridTemplateColumns: '24px 32px auto 1fr 140px 160px 32px' }}
+ style={{ gridTemplateColumns: canEdit ? '24px 32px auto 1fr 140px 160px 32px' : '32px auto 1fr 140px 160px 32px' }}
>
- <div className="flex items-center">
- <Checkbox
- checked={isAllSelected}
- ref={(el) => {
- if (el && 'indeterminate' in el) {
- ;(el as HTMLInputElement).indeterminate = isIndeterminate
- }
- }}
- onCheckedChange={handleSelectAll}
- />
- </div>
+ {canEdit && (
+ <div className="flex items-center">
+ <Checkbox
+ checked={isAllSelected}
+ ref={(el) => {
+ if (el && 'indeterminate' in el) {
+ ;(el as HTMLInputElement).indeterminate = isIndeterminate
+ }
+ }}
+ onCheckedChange={handleSelectAll}
+ />
+ </div>
+ )}
<div></div> {/* Icon */}
<div className="text-left">Label</div>
<div>Data</div>
@@ -336,6 +344,7 @@ export default function NodesTable({ nodes }: NodesTableProps) {
onNodeClick={onNodeClick}
isSelected={isNodeSelected(node.id)}
onSelectionChange={handleNodeSelectionChange}
+ canEdit={canEdit}
/>
</div>
)
diff --git a/flowsint-app/src/components/table/relationships-view.tsx b/flowsint-app/src/components/table/relationships-view.tsx
index 8493d1ce..c136afa7 100644
--- a/flowsint-app/src/components/table/relationships-view.tsx
+++ b/flowsint-app/src/components/table/relationships-view.tsx
@@ -24,6 +24,7 @@ import { Checkbox } from '@/components/ui/checkbox'
import { Button } from '@/components/ui/button'
import { useConfirm } from '@/components/use-confirm-dialog'
import { toast } from 'sonner'
+import { usePermissions } from '@/hooks/use-can'
const ITEM_HEIGHT = 67 // Balanced spacing between items (55px card + 12px padding)
@@ -34,6 +35,7 @@ interface RelationshipItemProps {
onNodeClick: (node: GraphNode) => void
isSelected: boolean
onSelectionChange: (edge: GraphEdge, checked: boolean) => void
+ canEdit: boolean
}
function RelationshipItem({
@@ -41,7 +43,8 @@ function RelationshipItem({
style,
onNodeClick,
isSelected,
- onSelectionChange
+ onSelectionChange,
+ canEdit
}: RelationshipItemProps) {
const SourceIcon = useIcon(relationship.source.nodeType, {
nodeColor: relationship.source.nodeColor,
@@ -73,9 +76,11 @@ function RelationshipItem({
<Card className="h-[55px] p-0 rounded-md">
<CardContent className="p-3 h-[55px] flex items-center gap-3 min-w-0">
{/* Checkbox */}
- <div className="flex items-center shrink-0">
- <Checkbox checked={isSelected} onCheckedChange={handleCheckboxChange} />
- </div>
+ {canEdit && (
+ <div className="flex items-center shrink-0">
+ <Checkbox checked={isSelected} onCheckedChange={handleCheckboxChange} />
+ </div>
+ )}
{/* Source Node */}
<div className="flex items-center gap-2 flex-1 min-w-0 max-w-[35%]">
@@ -143,6 +148,7 @@ export default function RelationshipsTable() {
queryFn: () => sketchService.getGraphDataById(sketchId as string, true)
})
+ const { canEdit } = usePermissions()
const [searchQuery, setSearchQuery] = useState('')
const [selectedType, setSelectedType] = useState<string>('all')
const parentRef = useRef<HTMLDivElement>(null)
@@ -389,7 +395,7 @@ export default function RelationshipsTable() {
</div>
{/* Selection Controls */}
- {filteredRelationships.length > 0 && (
+ {canEdit && filteredRelationships.length > 0 && (
<div className="flex items-center gap-4 mb-2">
<div className="flex items-center gap-2">
<Checkbox
@@ -434,6 +440,7 @@ export default function RelationshipsTable() {
onNodeClick={onNodeClick}
isSelected={isEdgeSelected(relationship.edge.id)}
onSelectionChange={handleEdgeSelectionChange}
+ canEdit={canEdit}
style={{
position: 'absolute',
top: 0,
diff --git a/flowsint-app/src/components/ui/avatar.tsx b/flowsint-app/src/components/ui/avatar.tsx
index 1dda4c79..d9dedf34 100644
--- a/flowsint-app/src/components/ui/avatar.tsx
+++ b/flowsint-app/src/components/ui/avatar.tsx
@@ -1,7 +1,24 @@
import * as React from 'react'
import * as AvatarPrimitive from '@radix-ui/react-avatar'
-
import { cn } from '@/lib/utils'
+import { getDisplayName, getInitials } from '@/lib/user-display'
+import type { Profile } from '@/types'
+import type { User } from '@/stores/auth-store'
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
+
+type UserLike = (Partial<Profile> & Partial<User>) | null | undefined
+
+const SIZES = {
+ xs: { root: 'size-5', text: 'text-[10px]' },
+ sm: { root: 'size-6', text: 'text-[10px]' },
+ md: { root: 'size-7', text: 'text-xs' },
+ lg: { root: 'size-8', text: 'text-sm' },
+ xl: { root: 'size-10', text: 'text-base' },
+} as const
+
+type AvatarSize = keyof typeof SIZES
+
+// --- Primitives (re-exported for non-user edge cases like tool-card) ---
function Avatar({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Root>) {
return (
@@ -35,4 +52,66 @@ function AvatarFallback({
/>
)
}
-export { Avatar, AvatarImage, AvatarFallback }
+
+// --- Domain components ---
+
+interface UserAvatarProps {
+ user: UserLike
+ size?: AvatarSize
+ className?: string
+}
+
+function UserAvatar({ user, size = 'lg', className }: UserAvatarProps) {
+ const s = SIZES[size]
+ return (
+ <Avatar className={cn(s.root, className)}>
+ {user?.avatar_url && <AvatarImage src={user.avatar_url} alt={getDisplayName(user)} />}
+ <AvatarFallback className={s.text}>{getInitials(user)}</AvatarFallback>
+ </Avatar>
+ )
+}
+
+interface AvatarGroupProps {
+ users: UserLike[]
+ size?: AvatarSize
+ max?: number
+ className?: string
+}
+
+function AvatarGroup({ users, size = 'sm', max, className }: AvatarGroupProps) {
+ const visible = max != null ? users.slice(0, max) : users
+ const overflow = max != null ? users.length - max : 0
+ const s = SIZES[size]
+
+ return (
+ <div className={cn('flex -space-x-1.5', className)}>
+ {visible.map((user, i) => (
+ <Tooltip key={user?.id ?? i}>
+ <TooltipTrigger asChild>
+ <div>
+ <UserAvatar
+ user={user}
+ size={size}
+ className="border border-background"
+ />
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>{getDisplayName(user)}</TooltipContent>
+ </Tooltip>
+ ))}
+ {overflow > 0 && (
+ <div
+ className={cn(
+ s.root,
+ s.text,
+ 'relative flex shrink-0 items-center justify-center rounded-full border border-background bg-muted font-medium text-muted-foreground'
+ )}
+ >
+ +{overflow}
+ </div>
+ )}
+ </div>
+ )
+}
+
+export { Avatar, AvatarImage, AvatarFallback, UserAvatar, AvatarGroup }
diff --git a/flowsint-app/src/routes/_auth.dashboard.custom-types.index.tsx b/flowsint-app/src/routes/_auth.dashboard.custom-types.index.tsx
index 578725a3..345dd164 100644
--- a/flowsint-app/src/routes/_auth.dashboard.custom-types.index.tsx
+++ b/flowsint-app/src/routes/_auth.dashboard.custom-types.index.tsx
@@ -168,7 +168,8 @@ function CustomTypesList({ types, onDelete, navigate }: CustomTypesListProps) {
}
return (
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
+ <div style={{ containerType: 'inline-size' }}>
+ <div className="grid grid-cols-1 cq-sm:grid-cols-2 cq-md:grid-cols-3 gap-4">
{types.map((customType) => (
<Card key={customType.id} className="hover:border-primary/50 transition-colors">
<CardHeader>
@@ -211,5 +212,6 @@ function CustomTypesList({ types, onDelete, navigate }: CustomTypesListProps) {
</Card>
))}
</div>
+ </div>
)
}
diff --git a/flowsint-app/src/routes/_auth.dashboard.profile.tsx b/flowsint-app/src/routes/_auth.dashboard.profile.tsx
index 898b7e9a..ba7943d4 100644
--- a/flowsint-app/src/routes/_auth.dashboard.profile.tsx
+++ b/flowsint-app/src/routes/_auth.dashboard.profile.tsx
@@ -5,10 +5,10 @@ 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 { UserAvatar } from '@/components/ui/avatar'
import { toast } from 'sonner'
import { useAuthStore } from '@/stores/auth-store'
-import { getDisplayName, getInitials } from '@/lib/user-display'
+import { getDisplayName } from '@/lib/user-display'
import { SESSION_QUERY_KEY } from '@/hooks/use-auth'
export const Route = createFileRoute('/_auth/dashboard/profile')({
@@ -80,7 +80,6 @@ function ProfilePage() {
}
const displayName = getDisplayName(profile)
- const initials = getInitials(profile)
return (
<main className="flex-1 h-full overflow-auto">
@@ -92,10 +91,11 @@ function ProfilePage() {
{/* 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>
+ <UserAvatar
+ user={{ ...profile, avatar_url: form.avatar_url || undefined }}
+ size="xl"
+ className="size-16 text-lg"
+ />
<div>
<p className="font-medium">{displayName}</p>
<p className="text-sm text-muted-foreground">{profile?.email}</p>
diff --git a/flowsint-app/src/styles.css b/flowsint-app/src/styles.css
index d80d558e..b940d787 100644
--- a/flowsint-app/src/styles.css
+++ b/flowsint-app/src/styles.css
@@ -9,24 +9,48 @@
.cq-sm\:grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
+ .cq-sm\:grid-cols-3 {
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ }
+ .cq-sm\:grid-cols-4 {
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ }
}
@container (min-width: 768px) {
+ .cq-md\:grid-cols-2 {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
.cq-md\:grid-cols-3 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
+ .cq-md\:grid-cols-4 {
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ }
}
@container (min-width: 1024px) {
+ .cq-lg\:grid-cols-3 {
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ }
.cq-lg\:grid-cols-4 {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
+ .cq-lg\:grid-cols-5 {
+ grid-template-columns: repeat(5, minmax(0, 1fr));
+ }
}
@container (min-width: 1280px) {
+ .cq-xl\:grid-cols-4 {
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ }
.cq-xl\:grid-cols-5 {
grid-template-columns: repeat(5, minmax(0, 1fr));
}
+ .cq-xl\:grid-cols-6 {
+ grid-template-columns: repeat(6, minmax(0, 1fr));
+ }
}
/* Electron title bar draggable region */