fix: viewer cant see users now

This commit is contained in:
2026-09-20 17:35:55 +02:00
parent 64e0eed95c
commit 58eb8ddb8e
3 changed files with 10 additions and 23 deletions
+10 -5
View File
@@ -19,11 +19,11 @@ import { authApi, api } from '@/lib/api/client';
import { toast } from '@/components/ui/toast'; import { toast } from '@/components/ui/toast';
const navItems = [ const navItems = [
{ href: '/dashboard', label: 'Overview', icon: LayoutDashboard }, { href: '/dashboard', label: 'Overview', icon: LayoutDashboard, neededRole: 'viewer' },
{ href: '/dashboard/tabs', label: 'Open Tabs', icon: ClipboardList }, { href: '/dashboard/tabs', label: 'Open Tabs', icon: ClipboardList, neededRole: 'viewer' },
{ href: '/dashboard/users', label: 'Users', icon: Monitor }, { href: '/dashboard/users', label: 'Users', icon: Monitor, neededRole: 'admin' },
{ href: '/dashboard/commands', label: 'Command History', icon: Terminal }, { href: '/dashboard/commands', label: 'Command History', icon: Terminal, neededRole: 'viewer' },
{ href: '/dashboard/settings', label: 'Settings', icon: Settings }, { href: '/dashboard/settings', label: 'Settings', icon: Settings, neededRole: 'viewer' },
]; ];
export default function DashboardLayout({ export default function DashboardLayout({
@@ -110,6 +110,11 @@ export default function DashboardLayout({
{navItems.map((item) => { {navItems.map((item) => {
const Icon = item.icon; const Icon = item.icon;
const active = pathname === item.href; const active = pathname === item.href;
if (item.neededRole === 'admin' && user?.role !== 'admin') {
return null;
}
return ( return (
<Link <Link
key={item.href} key={item.href}
@@ -107,23 +107,6 @@ export default function SettingsPage() {
</CardContent> </CardContent>
</Card> </Card>
<Card>
<CardHeader>
<CardTitle>API</CardTitle>
</CardHeader>
<CardContent className="space-y-2 text-sm">
<div className="flex justify-between">
<span className="text-muted-foreground">Base URL</span>
<span className="font-mono text-xs">{process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001/api/v1'}</span>
</div>
<div className="flex justify-between">
<span className="text-muted-foreground">Swagger</span>
<span className="font-mono text-xs">
{process.env.NEXT_PUBLIC_API_URL?.replace('/api/v1', '/api/docs') || 'http://localhost:3001/api/docs'}
</span>
</div>
</CardContent>
</Card>
</div> </div>
{regDialog && ( {regDialog && (
@@ -4,7 +4,6 @@ export function EmptyState({ title, description }: { title: string; description:
return ( return (
<Card> <Card>
<CardContent className="flex flex-col items-center justify-center py-12"> <CardContent className="flex flex-col items-center justify-center py-12">
<div className="text-4xl mb-4">📭</div>
<h3 className="text-lg font-semibold mb-1">{title}</h3> <h3 className="text-lg font-semibold mb-1">{title}</h3>
<p className="text-sm text-muted-foreground">{description}</p> <p className="text-sm text-muted-foreground">{description}</p>
</CardContent> </CardContent>