feat: add view mode state and toggle to runtime dashboard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-16 13:37:16 +02:00
parent 5c94881608
commit d0c2fd1ac3

View File

@@ -1,6 +1,6 @@
import { useState, useMemo, useCallback } from 'react';
import { useParams, useNavigate } from 'react-router';
import { ExternalLink, RefreshCw, Pencil } from 'lucide-react';
import { ExternalLink, RefreshCw, Pencil, LayoutGrid, List, ChevronRight, ChevronDown } from 'lucide-react';
import {
StatCard, StatusDot, Badge, MonoText,
GroupCard, DataTable, EventFeed,
@@ -114,6 +114,27 @@ export default function AgentHealth() {
const catalogEntry = catalogApps?.find((a) => a.slug === appId);
const [confirmDismissOpen, setConfirmDismissOpen] = useState(false);
const [viewMode, setViewMode] = useState<'compact' | 'expanded'>(() => {
const saved = localStorage.getItem('cameleer:runtime:viewMode');
return saved === 'expanded' ? 'expanded' : 'compact';
});
const [expandedApps, setExpandedApps] = useState<Set<string>>(new Set());
const toggleViewMode = useCallback((mode: 'compact' | 'expanded') => {
setViewMode(mode);
setExpandedApps(new Set());
localStorage.setItem('cameleer:runtime:viewMode', mode);
}, []);
const toggleAppExpanded = useCallback((appId: string) => {
setExpandedApps((prev) => {
const next = new Set(prev);
if (next.has(appId)) next.delete(appId);
else next.add(appId);
return next;
});
}, []);
const [configEditing, setConfigEditing] = useState(false);
const [configDraft, setConfigDraft] = useState<Record<string, string | boolean>>({});
@@ -399,6 +420,22 @@ export default function AgentHealth() {
accent={deadCount > 0 ? 'error' : 'success'}
detail={deadCount > 0 ? 'requires attention' : 'all healthy'}
/>
<div className={styles.viewToggle}>
<button
className={`${styles.viewToggleBtn} ${viewMode === 'compact' ? styles.viewToggleBtnActive : ''}`}
onClick={() => toggleViewMode('compact')}
title="Compact view"
>
<LayoutGrid size={14} />
</button>
<button
className={`${styles.viewToggleBtn} ${viewMode === 'expanded' ? styles.viewToggleBtnActive : ''}`}
onClick={() => toggleViewMode('expanded')}
title="Expanded view"
>
<List size={14} />
</button>
</div>
</div>
{/* Application config bar */}