CI / changes (push) Successful in 17s
CI / commitlint (push) Has been skipped
CI / openapi (push) Successful in 26s
CI / web (push) Successful in 46s
CI / go (push) Successful in 1m1s
CI / bird2 (push) Successful in 17s
CI / release (push) Failing after 2m22s
Web UI полностью переведён с SvelteKit на новый стек: React 19, TanStack Router/Query/Table/Virtual, shadcn/ui (base-nova) и ReUI enterprise-компоненты (data-grid, filters, autocomplete). Новый код разложен по слоям: packages/ui (shadcn-примитивы), apps/web (роуты, shared-обёртки, ReUI-адаптации). BREAKING CHANGE: меняется структура и инструментинг фронтенда. - apps/web/ — новый Vite + React-проект (@evobgp/web), file-based роуты TanStack Router; экраны dashboard, modules, monitoring, network, operations, schedule, settings, tenant-settings, access, directories. - packages/ui/ — shadcn/ui-примитивы (@evobgp/ui) с общими стилями globals.css и cn-утилитой; CLI shadcn запускается из apps/web. - apps/web/src/components/reui/ — enterprise-паттерны ReUI. - pnpm workspace (pnpm-workspace.yaml, pnpm-lock.yaml, tsconfig.base.json) заменяет npm-проект в web/. - web/ переименован в web-legacy-svelte/ (архив-референс для миграции); импорты оттуда запрещены правилом WEB-22. - CI (.gitea/workflows/ci.yaml): job web переведён на Node 22 + pnpm 10 (typecheck/lint/build через pnpm --filter @evobgp/web); пути триггеров обновлены под apps/web|packages/ui. - deploy/docker/evobgp-web/Dockerfile: сборка из корня репозитория, pnpm install --frozen-lockfile, выход dist из apps/web/dist. - .cursor/rules/web-shadcn.mdc, context7-stack.mdc, engineering.mdc, AGENTS.md — обновлены под React-стек (WEB-01..WEB-22, DOC-SYNC-06/07). Проверки WEB-19 локально: typecheck, lint, build — exit 0. Co-authored-by: Cursor <[email protected]>
110 lines
4.0 KiB
TypeScript
110 lines
4.0 KiB
TypeScript
import type { ReactElement, ReactNode } from 'react'
|
|
import { Card, CardContent } from '@evobgp/ui/components/card'
|
|
import { cn } from '@evobgp/ui/lib/utils'
|
|
import { TruncatedText } from '@/components/truncated-text'
|
|
|
|
export interface SectionCardItem {
|
|
label: ReactNode
|
|
value: string | number | ReactElement
|
|
hint?: ReactNode
|
|
icon?: ReactNode
|
|
badge?: ReactNode
|
|
variant?: 'default' | 'warning' | 'destructive'
|
|
active?: boolean
|
|
onClick?: () => void
|
|
}
|
|
|
|
const VARIANT_CLASS: Record<NonNullable<SectionCardItem['variant']>, string> = {
|
|
default: '',
|
|
warning: 'border-warning/50',
|
|
destructive: 'border-destructive/50',
|
|
}
|
|
|
|
function sectionGridClass(count: number): string {
|
|
if (count <= 1) return 'grid-cols-1'
|
|
if (count === 2) return 'sm:grid-cols-2'
|
|
if (count === 3) return 'sm:grid-cols-2 lg:grid-cols-3'
|
|
if (count === 4) return 'sm:grid-cols-2 lg:grid-cols-4'
|
|
if (count === 5) return 'sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5'
|
|
if (count === 6) return 'sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6'
|
|
return 'sm:grid-cols-2 lg:grid-cols-3'
|
|
}
|
|
|
|
const VALUE_VARIANT_CLASS: Record<NonNullable<SectionCardItem['variant']>, string> = {
|
|
default: '',
|
|
warning: 'text-warning-foreground',
|
|
destructive: 'text-destructive',
|
|
}
|
|
|
|
export function SectionCards({ items, className }: { items: SectionCardItem[]; className?: string }) {
|
|
return (
|
|
<div className={cn('grid gap-3', sectionGridClass(items.length), className)}>
|
|
{items.map((item, idx) => {
|
|
const clickable = Boolean(item.onClick)
|
|
const content = (
|
|
<CardContent className="flex items-start gap-2.5 px-3 py-2.5">
|
|
{item.icon ? (
|
|
<span className="flex size-7 shrink-0 items-center justify-center rounded-md bg-muted/60 text-muted-foreground">
|
|
{item.icon}
|
|
</span>
|
|
) : null}
|
|
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
<div className="flex items-center justify-between gap-2">
|
|
{typeof item.label === 'string' ? (
|
|
<TruncatedText className="text-xs text-muted-foreground">{item.label}</TruncatedText>
|
|
) : (
|
|
<span className="truncate text-xs text-muted-foreground">{item.label}</span>
|
|
)}
|
|
{item.badge ? <span className="shrink-0">{item.badge}</span> : null}
|
|
</div>
|
|
<div className="flex min-w-0 items-baseline gap-1.5">
|
|
<span
|
|
className={cn(
|
|
'flex items-center gap-1 text-lg font-semibold tabular-nums',
|
|
VALUE_VARIANT_CLASS[item.variant ?? 'default'],
|
|
)}
|
|
>
|
|
{item.value}
|
|
</span>
|
|
{item.hint ? (
|
|
typeof item.hint === 'string' ? (
|
|
<TruncatedText className="text-xs text-muted-foreground">· {item.hint}</TruncatedText>
|
|
) : (
|
|
<span className="truncate text-xs text-muted-foreground">· {item.hint}</span>
|
|
)
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
</CardContent>
|
|
)
|
|
return (
|
|
<Card
|
|
key={typeof item.label === 'string' ? item.label : idx}
|
|
className={cn(
|
|
'gap-0',
|
|
VARIANT_CLASS[item.variant ?? 'default'],
|
|
item.active && 'border-primary ring-1 ring-primary/30',
|
|
clickable && 'cursor-pointer transition-colors hover:bg-muted/40',
|
|
)}
|
|
onClick={item.onClick}
|
|
role={clickable ? 'button' : undefined}
|
|
tabIndex={clickable ? 0 : undefined}
|
|
onKeyDown={
|
|
clickable
|
|
? (e) => {
|
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
e.preventDefault()
|
|
item.onClick?.()
|
|
}
|
|
}
|
|
: undefined
|
|
}
|
|
>
|
|
{content}
|
|
</Card>
|
|
)
|
|
})}
|
|
</div>
|
|
)
|
|
}
|