fix: hoist DetailPanel into AppShell detail slot for proper slide-in
DetailPanel is a flex sibling that slides in from the right — it must be rendered at the AppShell level via the detail prop, not inside the page content. Add DetailPanelContext so pages can push their panel content up to LayoutShell, which passes it to AppShell.detail. Applied to Dashboard (exchange detail) and AgentHealth (instance detail). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
23
ui/src/components/DetailPanelContext.tsx
Normal file
23
ui/src/components/DetailPanelContext.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { createContext, useContext, useState, type ReactNode } from 'react';
|
||||
|
||||
interface DetailPanelContextValue {
|
||||
detail: ReactNode;
|
||||
setDetail: (node: ReactNode) => void;
|
||||
}
|
||||
|
||||
const DetailPanelContext = createContext<DetailPanelContextValue | null>(null);
|
||||
|
||||
export function DetailPanelProvider({ children }: { children: ReactNode }) {
|
||||
const [detail, setDetail] = useState<ReactNode>(null);
|
||||
return (
|
||||
<DetailPanelContext.Provider value={{ detail, setDetail }}>
|
||||
{children}
|
||||
</DetailPanelContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useDetailPanelSlot(): DetailPanelContextValue {
|
||||
const ctx = useContext(DetailPanelContext);
|
||||
if (!ctx) throw new Error('useDetailPanelSlot must be used within DetailPanelProvider');
|
||||
return ctx;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { useRouteCatalog } from '../api/queries/catalog';
|
||||
import { useAgents } from '../api/queries/agents';
|
||||
import { useAuthStore } from '../auth/auth-store';
|
||||
import { useMemo, useCallback } from 'react';
|
||||
import { DetailPanelProvider, useDetailPanelSlot } from './DetailPanelContext';
|
||||
|
||||
function healthToColor(health: string): string {
|
||||
switch (health) {
|
||||
@@ -68,6 +69,7 @@ function LayoutContent() {
|
||||
const { data: agents } = useAgents();
|
||||
const { username, logout } = useAuthStore();
|
||||
const { open: paletteOpen, setOpen: setPaletteOpen } = useCommandPalette();
|
||||
const { detail } = useDetailPanelSlot();
|
||||
|
||||
const sidebarApps: SidebarApp[] = useMemo(() => {
|
||||
if (!catalog) return [];
|
||||
@@ -122,6 +124,7 @@ function LayoutContent() {
|
||||
apps={sidebarApps}
|
||||
/>
|
||||
}
|
||||
detail={detail}
|
||||
>
|
||||
<TopBar
|
||||
breadcrumb={breadcrumb}
|
||||
@@ -146,7 +149,9 @@ export function LayoutShell() {
|
||||
<ToastProvider>
|
||||
<CommandPaletteProvider>
|
||||
<GlobalFilterProvider>
|
||||
<LayoutContent />
|
||||
<DetailPanelProvider>
|
||||
<LayoutContent />
|
||||
</DetailPanelProvider>
|
||||
</GlobalFilterProvider>
|
||||
</CommandPaletteProvider>
|
||||
</ToastProvider>
|
||||
|
||||
Reference in New Issue
Block a user