Download web/src/components/shell/IconRail.tsx from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 4.1 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/shell/IconRail.tsx
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/components/shell/IconRail.tsx
-
curl -L -o IconRail.tsx https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/shell/IconRail.tsx
4.1 kB
| import './rail.css'; | |
| import { Tooltip } from '@mantine/core'; | |
| import { IconAlertTriangle, IconHandStop } from '@/components/icons'; | |
| import { NavLink as RouterLink, useLocation } from 'react-router-dom'; | |
| import { useBrand, useHealth, useKill, useRuns } from '../../api/hooks'; | |
| import { useAuth } from '../../auth/AuthContext'; | |
| import { useWaitsOnMe } from '../../domain/waiting'; | |
| import { AccountMenu, AGENT_STUDIO, AI_MONITORING, INTEGRATIONS, LIBRARY, MAIN, SETTINGS, SETUP, type NavItem } from './AppSidebar'; | |
| import { envKind, useChosenEnv } from './EnvSwitcher'; | |
| /** The name under each icon: short, and always part of the page's full name (so what is read out matches what is shown). */ | |
| const SHORT: Record<string, string> = { '/runs': 'Runs', '/pods': 'Pods', '/agent-studio': 'Studio' }; | |
| function RailLink({ item, badge }: { item: NavItem; badge?: number }) { | |
| const loc = useLocation(); | |
| const active = item.match ? item.match(loc.pathname) : loc.pathname === item.to || loc.pathname.startsWith(`${item.to}/`); | |
| // the shown short name is always part of the name read out (Test environments: "Pods") | |
| const full = SHORT[item.to] && !item.label.toLowerCase().includes(SHORT[item.to].toLowerCase()) ? `${item.label} (${SHORT[item.to]})` : item.label; | |
| const name = badge ? `${full}, ${badge} waiting for you` : full; | |
| return ( | |
| <Tooltip label={item.label} position="right" withArrow openDelay={400}> | |
| <RouterLink to={item.to} className="pw-rail-item" data-active={active} aria-current={active ? 'page' : undefined} aria-label={name}> | |
| {item.icon} | |
| <span className="pw-rail-label" aria-hidden>{SHORT[item.to] ?? item.label}</span> | |
| {!!badge && <span className="pw-rail-badge" aria-hidden>{badge > 9 ? '9+' : badge}</span>} | |
| </RouterLink> | |
| </Tooltip> | |
| ); | |
| } | |
| /** The app's navigation on a desktop: the toolbar (an icon and a short name per page, the full name on hover and to | |
| * screen readers), the runs waiting for you as a badge on Test runs, the emergency stop and a silent practice app as | |
| * warnings, the account at the bottom. The environment switcher is the project switcher in the top bar. */ | |
| export function IconRail() { | |
| const { can } = useAuth(); | |
| const brand = useBrand(); | |
| const runs = useRuns(40, 0); | |
| const mine = useWaitsOnMe(); | |
| const kill = useKill(); | |
| const health = useHealth(); | |
| const env = useChosenEnv().pod; | |
| const waiting = (runs.data?.items ?? []).filter(mine).length; | |
| const name = brand.data?.product_name ?? 'Astra'; | |
| const items: NavItem[] = [...MAIN, ...LIBRARY, ...SETUP, ...(can('admin') ? [AGENT_STUDIO, AI_MONITORING, INTEGRATIONS, SETTINGS] : [])]; | |
| return ( | |
| <div className="pw-rail"> | |
| <RouterLink to="/" className="pw-rail-brand" aria-label={`${name} home`} data-testid="brand"> | |
| <img className="astra-logo" src="/astra-logo.png" alt="" height={26} /> | |
| </RouterLink> | |
| <nav className="pw-rail-nav" aria-label="Pages"> | |
| {items.map((it, i) => ( | |
| <span key={it.to} className="pw-rail-slot" data-gap={i === MAIN.length || i === MAIN.length + LIBRARY.length || undefined}> | |
| <RailLink item={it} badge={it.to === '/runs' ? waiting : undefined} /> | |
| </span> | |
| ))} | |
| </nav> | |
| <div className="pw-rail-foot"> | |
| {kill.data?.engaged && ( | |
| <Tooltip label="Emergency stop is on" position="right" withArrow> | |
| <span className="pw-rail-warn" data-tone="red" role="status" data-testid="kill-indicator" aria-label="Emergency stop is on"><IconHandStop size={18} aria-hidden /></span> | |
| </Tooltip> | |
| )} | |
| {health.data && !health.data.mock_up && envKind(env?.kind) === 'mock' && !!env && ( | |
| <Tooltip label="The practice app is not answering" position="right" withArrow> | |
| <span className="pw-rail-warn" data-tone="orange" role="status" aria-label="practice app down"><IconAlertTriangle size={18} aria-hidden /></span> | |
| </Tooltip> | |
| )} | |
| <AccountMenu compact /> | |
| </div> | |
| </div> | |
| ); | |
| } | |