mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-06 08:58:05 +00:00
928a3a8343
* feat(mobile): masthead-led dashboard and 5-tab bottom nav on phones On phones (below the md breakpoint) the dashboard now renders a bespoke, masthead-led layout instead of the reflowed desktop workspace: - A status masthead leads with the overall system-health verdict, the node, and a live summary (stack counts, last sync, a "metrics stale" marker when polling stops). - A CPU hero card with a sparkline, then a memory / disk / network strip with threshold-colored bars, then a tappable stack-health list. - The bottom tab bar gains a Home tab (Home / Stacks / Fleet / Sched / Settings); the global top bar is dropped on this screen, with notifications and a "more" menu rehomed into the masthead. The health-verdict logic is extracted into a shared helper so the phone masthead and the desktop health bar read from one source, with unit tests. All changes are scoped below the md breakpoint or rendered only on the mobile shell; desktop layout is unchanged (verified against the desktop snapshot gate). * feat(mobile): bespoke fleet glance and node detail on phones On phones (below the md breakpoint) the Fleet view now renders a bespoke, masthead-led layout instead of the reflowed desktop workspace: - A fleet masthead leads with the overall fleet-health verdict and a running / cpu / mem summary band, then a list of node cards. The local node is marked with a cyan rail and a "you are here" tag; offline nodes are dimmed. - Tapping a node opens a full-screen node detail: state pill, resource bars (cpu / mem / disk), the stacks running on that node, and an Inspect action that switches to the node. Operators with the right permissions also get a Drain (cordon) action. - The screen polls the fleet overview every 30 seconds; the global top bar is dropped here, with notifications and a "more" menu in the masthead. All changes are scoped below the md breakpoint or rendered only on the mobile shell; desktop layout is unchanged. * feat(mobile): bespoke schedules and settings screens on phones On phones (below the md breakpoint) Schedules and Settings now render bespoke, masthead-led layouts instead of the reflowed desktop workspace: - Schedules: a "next up" glance leading with the next run time and countdown, then upcoming runs grouped by day with a per-action status dot and target. It is read-only on mobile; creating and editing schedules stays on desktop. - Settings: a grouped-card list of every reachable section; tapping one opens it full-screen with a back affordance and a section masthead. The section content itself is the same as on desktop. The settings section switch, lazy-loaded section chunks, and tier gating are moved into a shared component so the desktop and mobile screens render the same section content from one place. The global top bar is dropped on both screens, with notifications and a "more" menu in the masthead. All changes are scoped below the md breakpoint or rendered only on the mobile shell; desktop layout is unchanged. * fix(mobile): show notifications and more-menu on the stack detail header The full-screen stack detail on phones drops the global top bar, but its header was missing the notifications bell and the "more" navigation menu that the other mobile screens carry in their masthead, leaving no way to reach notifications or other destinations while viewing a stack. Render the same header-actions cluster in the detail header (and the loading placeholder), next to the back affordance. Desktop is unaffected.
113 lines
3.9 KiB
TypeScript
113 lines
3.9 KiB
TypeScript
import { Home, Layers, Radar, Clock, Settings as SettingsIcon } from 'lucide-react';
|
|
import type { LucideIcon } from 'lucide-react';
|
|
import { cn } from '@/lib/utils';
|
|
import type { NavItem, ActiveView } from './EditorLayout/hooks/useViewNavigationState';
|
|
import type { MobileView } from './EditorLayout/mobile-surface';
|
|
|
|
type TabId = 'home' | 'stacks' | 'fleet' | 'schedules' | 'settings';
|
|
|
|
interface MobileTabBarProps {
|
|
/** The already-gated nav items (admin / remote / paid filtering applied). */
|
|
navItems: NavItem[];
|
|
activeView: ActiveView;
|
|
/** Which top-level mobile surface is showing when no stack detail is open. */
|
|
mobileView: MobileView;
|
|
/** True while a stack detail is open (keeps the Stacks tab marked current). */
|
|
detailOpen: boolean;
|
|
onHome: () => void;
|
|
onStacks: () => void;
|
|
onNavigate: (view: ActiveView) => void;
|
|
onSettings: () => void;
|
|
}
|
|
|
|
interface Tab {
|
|
id: TabId;
|
|
label: string;
|
|
icon: LucideIcon;
|
|
view?: ActiveView;
|
|
}
|
|
|
|
/**
|
|
* Bottom tab bar for the mobile shell (hidden at md+). Five primary
|
|
* destinations: Home (dashboard), Stacks (the list), Fleet, Sched, Settings.
|
|
* Fleet and Sched only appear when present in the gated `navItems`, so the bar
|
|
* never exposes a flow the desktop nav would hide (admin-only schedules,
|
|
* hub-only views on a remote node). Everything else stays reachable through the
|
|
* masthead "more" menu on bespoke screens, or the TopBar nav sheet elsewhere.
|
|
*/
|
|
export function MobileTabBar({
|
|
navItems,
|
|
activeView,
|
|
mobileView,
|
|
detailOpen,
|
|
onHome,
|
|
onStacks,
|
|
onNavigate,
|
|
onSettings,
|
|
}: MobileTabBarProps) {
|
|
const has = (value: ActiveView) => navItems.some(i => i.value === value);
|
|
|
|
const tabs: Tab[] = [
|
|
{ id: 'home', label: 'Home', icon: Home },
|
|
{ id: 'stacks', label: 'Stacks', icon: Layers },
|
|
...(has('fleet') ? [{ id: 'fleet' as const, label: 'Fleet', icon: Radar, view: 'fleet' as const }] : []),
|
|
...(has('scheduled-ops')
|
|
? [{ id: 'schedules' as const, label: 'Sched', icon: Clock, view: 'scheduled-ops' as const }]
|
|
: []),
|
|
{ id: 'settings', label: 'Settings', icon: SettingsIcon },
|
|
];
|
|
|
|
const currentTab = (): TabId | null => {
|
|
if (detailOpen || mobileView === 'list') return 'stacks';
|
|
if (activeView === 'dashboard') return 'home';
|
|
if (activeView === 'fleet') return 'fleet';
|
|
if (activeView === 'scheduled-ops') return 'schedules';
|
|
if (activeView === 'settings') return 'settings';
|
|
return null;
|
|
};
|
|
const current = currentTab();
|
|
|
|
const select = (tab: Tab) => {
|
|
if (tab.id === 'home') onHome();
|
|
else if (tab.id === 'stacks') onStacks();
|
|
else if (tab.id === 'settings') onSettings();
|
|
else if (tab.view) onNavigate(tab.view);
|
|
};
|
|
|
|
return (
|
|
<nav
|
|
aria-label="Primary mobile"
|
|
className={cn(
|
|
'md:hidden flex shrink-0 items-stretch',
|
|
'border-t border-hairline',
|
|
'bg-[color-mix(in_oklch,var(--card)_70%,transparent)] backdrop-blur-md backdrop-saturate-150',
|
|
'pb-[max(8px,env(safe-area-inset-bottom))]',
|
|
)}
|
|
>
|
|
{tabs.map(tab => {
|
|
const on = current === tab.id;
|
|
const Icon = tab.icon;
|
|
return (
|
|
<button
|
|
key={tab.id}
|
|
type="button"
|
|
onClick={() => select(tab)}
|
|
aria-current={on ? 'page' : undefined}
|
|
aria-label={tab.label}
|
|
className={cn(
|
|
'flex flex-1 min-h-14 flex-col items-center justify-center gap-1 pt-2',
|
|
'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/50',
|
|
on ? 'text-brand' : 'text-stat-icon hover:text-foreground',
|
|
)}
|
|
>
|
|
<Icon className="h-5 w-5" strokeWidth={1.6} />
|
|
<span className={cn('font-mono text-[9px] uppercase tracking-[0.08em]', on && 'font-medium')}>
|
|
{tab.label}
|
|
</span>
|
|
</button>
|
|
);
|
|
})}
|
|
</nav>
|
|
);
|
|
}
|