fix(web): UX/UI аудит — пагинация, a11y, settings и TruncatedText
Docker / build (push) Failing after 20s
Docker / build (push) Failing after 20s
Исправить обрезку Select в пагинации DataGrid, health-mode zero-results, подтверждение импорта бэкапа и унифицировать tooltip на обрезанном тексте. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
447d499a8d
commit
5c1c94bc57
28 files changed
+472
-219
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { useMemo, useState } from 'react'
|
||||
import {
|
||||
@@ -91,6 +91,7 @@ function buildSavePayload(r: ProviderAccountFormValues) {
|
||||
|
||||
function AccountsPage() {
|
||||
const { health } = Route.useSearch()
|
||||
const navigate = useNavigate()
|
||||
const queryClient = useQueryClient()
|
||||
const { data: snapshot, isLoading, isError, error, refetch } = useQuery(snapshotQueryOptions())
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -451,8 +452,16 @@ function AccountsPage() {
|
||||
}
|
||||
emptyAction={
|
||||
health || hasActiveAccountFilters(filters) ? (
|
||||
<Button variant="outline" onClick={() => setFilters(buildDefaultAccountFilters())}>
|
||||
Сбросить фильтры
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setFilters(buildDefaultAccountFilters())
|
||||
if (health) {
|
||||
void navigate({ to: '/accounts', search: {} })
|
||||
}
|
||||
}}
|
||||
>
|
||||
{health ? 'Выйти из режима и сбросить фильтры' : 'Сбросить фильтры'}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
|
||||
@@ -10,6 +10,21 @@ import { DataGridCard, columnDefFromDataGrid } from '@/components/data-grid-card
|
||||
import type { DataGridColumn } from '@/components/data-grid-types'
|
||||
import { Button } from '@cfdm/ui/components/button'
|
||||
import { Badge } from '@cfdm/ui/components/badge'
|
||||
import { TableSkeleton } from '@/components/skeletons'
|
||||
|
||||
const AUDIT_ENTITY_LABELS: Record<string, string> = {
|
||||
vps: 'VPS',
|
||||
payment: 'Платёж',
|
||||
providerAccount: 'Аккаунт',
|
||||
provider: 'Хостер',
|
||||
settings: 'Настройки',
|
||||
balanceLedger: 'Баланс',
|
||||
serverProject: 'Проект',
|
||||
}
|
||||
|
||||
function auditEntityLabel(entity: string): string {
|
||||
return AUDIT_ENTITY_LABELS[entity] ?? entity
|
||||
}
|
||||
|
||||
interface AuditRow {
|
||||
id: string
|
||||
@@ -51,7 +66,7 @@ function AuditPage() {
|
||||
{
|
||||
key: 'entity',
|
||||
header: 'Сущность',
|
||||
cell: (r) => <Badge variant="outline">{r.entity}</Badge>,
|
||||
cell: (r) => <Badge variant="outline">{auditEntityLabel(r.entity)}</Badge>,
|
||||
},
|
||||
{
|
||||
key: 'action',
|
||||
@@ -91,6 +106,7 @@ function AuditPage() {
|
||||
isError={isError}
|
||||
error={error}
|
||||
onRetry={() => refetch()}
|
||||
skeleton={<TableSkeleton />}
|
||||
empty={!data?.length}
|
||||
emptyTitle="Записей нет"
|
||||
emptyDescription="Изменения VPS появятся здесь после CRUD-операций"
|
||||
|
||||
@@ -238,7 +238,7 @@ function BalancePage() {
|
||||
rowId={(r) => r.id}
|
||||
pinLastColumn
|
||||
footerContent={
|
||||
<div className="flex justify-end gap-6 px-3 py-2 text-sm tabular-nums">
|
||||
<div className="flex flex-wrap justify-end gap-6 px-3 py-2 text-sm tabular-nums">
|
||||
<span>
|
||||
Приходы: <b className="text-foreground">{formatCurrency(totalCredit, baseCurrency)}</b>
|
||||
</span>
|
||||
|
||||
@@ -58,7 +58,7 @@ type InventoryIssue = { key: string; title: string; count: number; to: string; h
|
||||
function DashboardPage() {
|
||||
const navigate = useNavigate()
|
||||
const { data: snapshot, isLoading, isError, error, refetch } = useQuery(snapshotQueryOptions())
|
||||
const { data: stats } = useQuery(dashboardStatsQueryOptions())
|
||||
const { data: stats, isLoading: statsLoading } = useQuery(dashboardStatsQueryOptions())
|
||||
const settings = snapshot?.settings?.[0]
|
||||
const { data: rawRates } = useQuery(ratesQueryOptions(settings?.ratesUrl))
|
||||
const ratesData = normalizeRatesPayload(rawRates) ?? rawRates ?? null
|
||||
@@ -204,6 +204,9 @@ function DashboardPage() {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 md:gap-6">
|
||||
{statsLoading ? (
|
||||
<SectionCardsSkeleton count={6} />
|
||||
) : (
|
||||
<SectionCards
|
||||
items={[
|
||||
{
|
||||
@@ -269,6 +272,7 @@ function DashboardPage() {
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
{issues.length > 0 ? (
|
||||
<Alert variant="destructive">
|
||||
|
||||
@@ -26,16 +26,8 @@ import { ProjectEditSheet, projectFormDefaults } from '@/components/domain/proje
|
||||
import type { ProjectFormValues } from '@/lib/schemas'
|
||||
import { Button } from '@cfdm/ui/components/button'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@cfdm/ui/components/card'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@cfdm/ui/components/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirm-dialog'
|
||||
import { SectionCardsSkeleton, TableSkeleton } from '@/components/skeletons'
|
||||
import {
|
||||
formatCurrency,
|
||||
normalizeRatesPayload,
|
||||
@@ -72,7 +64,6 @@ function ProjectDetailPage() {
|
||||
const { data: rawRates } = useQuery(ratesQueryOptions(settings?.ratesUrl))
|
||||
const ratesData = normalizeRatesPayload(rawRates) ?? rawRates ?? null
|
||||
const [editOpen, setEditOpen] = useState(false)
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
const project = snapshot ? findProject(snapshot, projectId) : undefined
|
||||
const projectVps = useMemo(
|
||||
@@ -218,19 +209,31 @@ function ProjectDetailPage() {
|
||||
<PencilIcon data-icon="inline-start" />
|
||||
Изменить
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
if (projectVps.length > 0) {
|
||||
{projectVps.length > 0 ? (
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
toast.error(`Нельзя удалить: к проекту привязано ${projectVps.length} VPS`)
|
||||
return
|
||||
}
|
||||
setDeleteOpen(true)
|
||||
}}
|
||||
>
|
||||
<Trash2Icon data-icon="inline-start" />
|
||||
Удалить
|
||||
</Button>
|
||||
>
|
||||
<Trash2Icon data-icon="inline-start" />
|
||||
Удалить
|
||||
</Button>
|
||||
) : (
|
||||
<ConfirmDialog
|
||||
title="Удалить проект?"
|
||||
description={`«${project.name}» будет удалён без возможности восстановления.`}
|
||||
confirmLabel="Удалить"
|
||||
destructive
|
||||
onConfirm={() => delMut.mutate()}
|
||||
trigger={
|
||||
<Button variant="outline" disabled={delMut.isPending}>
|
||||
<Trash2Icon data-icon="inline-start" />
|
||||
Удалить
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
@@ -241,6 +244,12 @@ function ProjectDetailPage() {
|
||||
isError={isError}
|
||||
error={error}
|
||||
onRetry={() => refetch()}
|
||||
skeleton={
|
||||
<div className="flex flex-col gap-4">
|
||||
<SectionCardsSkeleton count={3} />
|
||||
<TableSkeleton />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{() =>
|
||||
!project ? (
|
||||
@@ -313,26 +322,6 @@ function ProjectDetailPage() {
|
||||
onSubmit={(values) => saveMut.mutate(values)}
|
||||
submitting={saveMut.isPending}
|
||||
/>
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Удалить проект?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
«{project.name}» будет удалён без возможности восстановления.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Отмена</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
variant="destructive"
|
||||
onClick={() => delMut.mutate()}
|
||||
disabled={delMut.isPending}
|
||||
>
|
||||
Удалить
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
import { Button } from '@cfdm/ui/components/button'
|
||||
import { Badge } from '@cfdm/ui/components/badge'
|
||||
import { EmptyState } from '@/components/empty-state'
|
||||
import { ProjectColorDot } from '@/components/project-color-dot'
|
||||
import { ProjectEditSheet, projectFormDefaults } from '@/components/domain/project-edit-sheet'
|
||||
import type { ProjectFormValues } from '@/lib/schemas'
|
||||
import { formatCurrency, normalizeRatesPayload } from '@/lib/format'
|
||||
@@ -133,9 +134,7 @@ function ProjectsPage() {
|
||||
icon: FolderKanbanIcon,
|
||||
cell: (row) => (
|
||||
<div className="flex items-center gap-2">
|
||||
{row.color ? (
|
||||
<span className="size-2.5 shrink-0 rounded-full" style={{ backgroundColor: row.color }} />
|
||||
) : null}
|
||||
<ProjectColorDot color={row.color} />
|
||||
<Button
|
||||
variant="link"
|
||||
className="h-auto p-0 font-medium"
|
||||
|
||||
@@ -9,6 +9,7 @@ import { PageHeader } from '@/components/page-header'
|
||||
import { QueryState } from '@/components/query-state'
|
||||
import { SectionCards } from '@/components/section-cards'
|
||||
import { SectionCardsSkeleton } from '@/components/skeletons'
|
||||
import { Skeleton } from '@cfdm/ui/components/skeleton'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@cfdm/ui/components/card'
|
||||
import { Badge } from '@cfdm/ui/components/badge'
|
||||
import { Button } from '@cfdm/ui/components/button'
|
||||
@@ -110,6 +111,7 @@ function RenewalsPage() {
|
||||
actions={
|
||||
<SelectField
|
||||
value={horizon}
|
||||
aria-label="Горизонт продлений"
|
||||
onValueChange={(v) => setHorizon((v ?? '30') as Horizon)}
|
||||
options={[
|
||||
{ value: '7', label: '7 дней' },
|
||||
@@ -127,7 +129,16 @@ function RenewalsPage() {
|
||||
isError={isError}
|
||||
error={error}
|
||||
onRetry={() => refetch()}
|
||||
skeleton={<SectionCardsSkeleton count={3} />}
|
||||
skeleton={
|
||||
<div className="flex flex-col gap-4">
|
||||
<SectionCardsSkeleton count={3} />
|
||||
<div className="flex flex-col gap-2">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-16 w-full rounded-lg" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
empty={items.length === 0}
|
||||
emptyTitle="Нет продлений в выбранном периоде"
|
||||
emptyDescription="Активные VPS с расчётной датой оплаты не найдены"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useQuery } from '@tanstack/react-query'
|
||||
import { CpuIcon, MemoryStickIcon, HardDriveIcon } from 'lucide-react'
|
||||
|
||||
import { snapshotQueryOptions } from '@/queries/snapshot'
|
||||
import { EmptyState } from '@/components/empty-state'
|
||||
import { AnalyticsPage } from '@/components/analytics-page'
|
||||
import { SectionCards } from '@/components/section-cards'
|
||||
import { Button } from '@cfdm/ui/components/button'
|
||||
@@ -102,7 +103,10 @@ function ResourcesPage() {
|
||||
<CardDescription>Только активные VPS</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ChartContainer config={RESOURCE_CONFIG} className="h-80 w-full">
|
||||
{chartData.length === 0 ? (
|
||||
<EmptyState title="Нет данных для графика" />
|
||||
) : (
|
||||
<ChartContainer config={RESOURCE_CONFIG} className="h-80 w-full" aria-label="Ресурсы по хостерам">
|
||||
<BarChart data={chartData} margin={{ top: 8, right: 8, bottom: 8, left: 8 }}>
|
||||
<CartesianGrid vertical={false} strokeDasharray="3 3" />
|
||||
<XAxis dataKey="name" tickLine={false} axisLine={false} tickMargin={8} />
|
||||
@@ -113,6 +117,7 @@ function ResourcesPage() {
|
||||
<Bar dataKey="disk" fill="var(--color-disk)" radius={4} />
|
||||
</BarChart>
|
||||
</ChartContainer>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useForm, Controller } from 'react-hook-form'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { toast } from 'sonner'
|
||||
import { DownloadIcon, UploadIcon } from 'lucide-react'
|
||||
import { useMemo } from 'react'
|
||||
import { useMemo, useCallback } from 'react'
|
||||
|
||||
import { snapshotQueryOptions } from '@/queries/snapshot'
|
||||
import { api, ApiError } from '@/lib/api-client'
|
||||
@@ -12,6 +12,17 @@ import { PageShell } from '@/components/page-shell'
|
||||
import { PageHeader } from '@/components/page-header'
|
||||
import { QueryState } from '@/components/query-state'
|
||||
import { SectionCardsSkeleton } from '@/components/skeletons'
|
||||
import { EmptyState } from '@/components/empty-state'
|
||||
import { ConfirmDialog } from '@/components/confirm-dialog'
|
||||
import { StatusBadge } from '@/components/status-badge'
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@cfdm/ui/components/table'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@cfdm/ui/components/card'
|
||||
import { FieldGroup } from '@cfdm/ui/components/field'
|
||||
import { Input } from '@cfdm/ui/components/input'
|
||||
@@ -32,6 +43,20 @@ export const Route = createFileRoute('/_auth/settings')({
|
||||
|
||||
const CURRENCIES = ['RUB', 'USD', 'EUR', 'UAH', 'KZT']
|
||||
|
||||
const NOTIFICATION_STATUS_MAP: Record<string, string> = {
|
||||
sent: 'ok',
|
||||
failed: 'error',
|
||||
}
|
||||
|
||||
const NOTIFICATION_STATUS_LABELS: Record<string, string> = {
|
||||
sent: 'Отправлено',
|
||||
failed: 'Ошибка',
|
||||
}
|
||||
|
||||
function notificationStatusLabel(status: string): string {
|
||||
return NOTIFICATION_STATUS_LABELS[status] ?? status
|
||||
}
|
||||
|
||||
function settingsToFormValues(s: Settings): SettingsFormValues {
|
||||
return {
|
||||
id: s.id,
|
||||
@@ -162,6 +187,50 @@ function SettingsPage() {
|
||||
queryFn: () => api.fetchNotificationLog(30),
|
||||
})
|
||||
|
||||
const importJsonMut = useMutation({
|
||||
mutationFn: (text: string) => api.importBackupJson(JSON.parse(text)),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: ['snapshot'] })
|
||||
toast.success('Импорт JSON выполнен')
|
||||
},
|
||||
onError: (e: unknown) => toast.error(e instanceof ApiError ? e.message : 'Ошибка импорта'),
|
||||
})
|
||||
|
||||
const importDbMut = useMutation({
|
||||
mutationFn: (buffer: ArrayBuffer) => api.importBackupDatabase(buffer),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: ['snapshot'] })
|
||||
toast.success('Импорт SQLite выполнен')
|
||||
},
|
||||
onError: (e: unknown) => toast.error(e instanceof ApiError ? e.message : 'Ошибка импорта'),
|
||||
})
|
||||
|
||||
const pickJsonFile = useCallback(() => {
|
||||
const input = document.createElement('input')
|
||||
input.type = 'file'
|
||||
input.accept = 'application/json,.json'
|
||||
input.onchange = async () => {
|
||||
const file = input.files?.[0]
|
||||
if (!file) return
|
||||
const text = await file.text()
|
||||
importJsonMut.mutate(text)
|
||||
}
|
||||
input.click()
|
||||
}, [importJsonMut])
|
||||
|
||||
const pickDbFile = useCallback(() => {
|
||||
const input = document.createElement('input')
|
||||
input.type = 'file'
|
||||
input.accept = '.db,application/octet-stream'
|
||||
input.onchange = async () => {
|
||||
const file = input.files?.[0]
|
||||
if (!file) return
|
||||
const buffer = await file.arrayBuffer()
|
||||
importDbMut.mutate(buffer)
|
||||
}
|
||||
input.click()
|
||||
}, [importDbMut])
|
||||
|
||||
const notificationRows = useMemo(
|
||||
() => notificationLog as NotificationLogRow[],
|
||||
[notificationLog],
|
||||
@@ -209,54 +278,40 @@ function SettingsPage() {
|
||||
<DownloadIcon data-icon="inline-start" />
|
||||
SQLite
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
const input = document.createElement('input')
|
||||
input.type = 'file'
|
||||
input.accept = 'application/json,.json'
|
||||
input.onchange = async () => {
|
||||
const file = input.files?.[0]
|
||||
if (!file) return
|
||||
try {
|
||||
const text = await file.text()
|
||||
await api.importBackupJson(JSON.parse(text))
|
||||
void queryClient.invalidateQueries({ queryKey: ['snapshot'] })
|
||||
toast.success('Импорт JSON выполнен')
|
||||
} catch (e) {
|
||||
toast.error(e instanceof ApiError ? e.message : 'Ошибка импорта')
|
||||
}
|
||||
}
|
||||
input.click()
|
||||
}}
|
||||
>
|
||||
<UploadIcon data-icon="inline-start" />
|
||||
Импорт JSON
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
const input = document.createElement('input')
|
||||
input.type = 'file'
|
||||
input.accept = '.db,application/octet-stream'
|
||||
input.onchange = async () => {
|
||||
const file = input.files?.[0]
|
||||
if (!file) return
|
||||
try {
|
||||
const buffer = await file.arrayBuffer()
|
||||
await api.importBackupDatabase(buffer)
|
||||
void queryClient.invalidateQueries({ queryKey: ['snapshot'] })
|
||||
toast.success('Импорт SQLite выполнен')
|
||||
} catch (e) {
|
||||
toast.error(e instanceof ApiError ? e.message : 'Ошибка импорта')
|
||||
}
|
||||
}
|
||||
input.click()
|
||||
}}
|
||||
>
|
||||
<UploadIcon data-icon="inline-start" />
|
||||
Импорт SQLite
|
||||
</Button>
|
||||
<ConfirmDialog
|
||||
title="Импортировать JSON?"
|
||||
description="Текущие данные будут перезаписаны содержимым файла резервной копии."
|
||||
confirmLabel="Выбрать файл"
|
||||
destructive
|
||||
onConfirm={pickJsonFile}
|
||||
trigger={
|
||||
<LoadingButton
|
||||
type="button"
|
||||
variant="outline"
|
||||
loading={importJsonMut.isPending}
|
||||
>
|
||||
<UploadIcon data-icon="inline-start" />
|
||||
Импорт JSON
|
||||
</LoadingButton>
|
||||
}
|
||||
/>
|
||||
<ConfirmDialog
|
||||
title="Импортировать SQLite?"
|
||||
description="Текущая база данных будет полностью заменена загруженным файлом .db."
|
||||
confirmLabel="Выбрать файл"
|
||||
destructive
|
||||
onConfirm={pickDbFile}
|
||||
trigger={
|
||||
<LoadingButton
|
||||
type="button"
|
||||
variant="outline"
|
||||
loading={importDbMut.isPending}
|
||||
>
|
||||
<UploadIcon data-icon="inline-start" />
|
||||
Импорт SQLite
|
||||
</LoadingButton>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -273,7 +328,7 @@ function SettingsPage() {
|
||||
isError={isError}
|
||||
error={error}
|
||||
onRetry={() => refetch()}
|
||||
skeleton={<SectionCardsSkeleton count={1} />}
|
||||
skeleton={<SectionCardsSkeleton count={3} />}
|
||||
>
|
||||
{() => (
|
||||
<form
|
||||
@@ -478,42 +533,45 @@ function SettingsPage() {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{notificationRows.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground">Записей пока нет</p>
|
||||
<EmptyState title="Записей пока нет" />
|
||||
) : (
|
||||
<div className="overflow-x-auto rounded-md border">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b bg-muted/50 text-left">
|
||||
<th className="px-3 py-2 font-medium">Время</th>
|
||||
<th className="px-3 py-2 font-medium">Событие</th>
|
||||
<th className="px-3 py-2 font-medium">Канал</th>
|
||||
<th className="px-3 py-2 font-medium">Статус</th>
|
||||
<th className="px-3 py-2 font-medium">Ошибка</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{notificationRows.map((row) => {
|
||||
const errorText =
|
||||
row.status === 'failed' && row.payload?.error != null
|
||||
? String(row.payload.error)
|
||||
: ''
|
||||
return (
|
||||
<tr key={row.id} className="border-b last:border-0">
|
||||
<td className="px-3 py-2 whitespace-nowrap text-muted-foreground">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Время</TableHead>
|
||||
<TableHead>Событие</TableHead>
|
||||
<TableHead>Канал</TableHead>
|
||||
<TableHead>Статус</TableHead>
|
||||
<TableHead>Ошибка</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{notificationRows.map((row) => {
|
||||
const errorText =
|
||||
row.status === 'failed' && row.payload?.error != null
|
||||
? String(row.payload.error)
|
||||
: ''
|
||||
return (
|
||||
<TableRow key={row.id}>
|
||||
<TableCell className="whitespace-nowrap text-muted-foreground">
|
||||
{new Date(row.createdAt).toLocaleString('ru-RU')}
|
||||
</td>
|
||||
<td className="px-3 py-2">{row.event}</td>
|
||||
<td className="px-3 py-2">{row.channel}</td>
|
||||
<td className="px-3 py-2">{row.status}</td>
|
||||
<td className="max-w-xs px-3 py-2 text-xs text-destructive break-words">
|
||||
</TableCell>
|
||||
<TableCell>{row.event}</TableCell>
|
||||
<TableCell>{row.channel}</TableCell>
|
||||
<TableCell>
|
||||
<StatusBadge
|
||||
status={NOTIFICATION_STATUS_MAP[row.status] ?? row.status}
|
||||
label={notificationStatusLabel(row.status)}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell className="max-w-xs break-words text-xs text-destructive">
|
||||
{errorText || '—'}
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -340,9 +340,13 @@ function TariffsPage() {
|
||||
<AlertDescription className="flex flex-col gap-1">
|
||||
{tariffDiffs.slice(0, 5).map((d) => (
|
||||
<span key={d.vpsId}>
|
||||
<Link to="/vps/$vpsId" params={{ vpsId: d.vpsId }} className="underline">
|
||||
<Button
|
||||
variant="link"
|
||||
className="h-auto p-0"
|
||||
render={<Link to="/vps/$vpsId" params={{ vpsId: d.vpsId }} />}
|
||||
>
|
||||
{d.vpsLabel}
|
||||
</Link>
|
||||
</Button>
|
||||
{' '}({d.tariffName}): {d.issues.join('; ')}
|
||||
</span>
|
||||
))}
|
||||
@@ -372,9 +376,13 @@ function TariffsPage() {
|
||||
<AlertDescription className="flex flex-col gap-1">
|
||||
{tariffDiffs.slice(0, 5).map((d) => (
|
||||
<span key={d.vpsId}>
|
||||
<Link to="/vps/$vpsId" params={{ vpsId: d.vpsId }} className="underline">
|
||||
<Button
|
||||
variant="link"
|
||||
className="h-auto p-0"
|
||||
render={<Link to="/vps/$vpsId" params={{ vpsId: d.vpsId }} />}
|
||||
>
|
||||
{d.vpsLabel}
|
||||
</Link>
|
||||
</Button>
|
||||
{' '}({d.tariffName}): {d.issues.join('; ')}
|
||||
</span>
|
||||
))}
|
||||
|
||||
@@ -14,6 +14,8 @@ import { snapshotQueryOptions, ratesQueryOptions } from '@/queries/snapshot'
|
||||
import { PageShell } from '@/components/page-shell'
|
||||
import { PageHeader } from '@/components/page-header'
|
||||
import { QueryState } from '@/components/query-state'
|
||||
import { StatusBadge } from '@/components/status-badge'
|
||||
import { Skeleton } from '@cfdm/ui/components/skeleton'
|
||||
import { Button } from '@cfdm/ui/components/button'
|
||||
import { Badge } from '@cfdm/ui/components/badge'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@cfdm/ui/components/card'
|
||||
@@ -116,9 +118,11 @@ function VpsDetailPage() {
|
||||
title={vps ? (vps.ip || vps.dns || 'VPS') : 'VPS'}
|
||||
description={account ? accountSelectLabel(account, providerById) : undefined}
|
||||
actions={
|
||||
<Button variant="outline" render={<Link to="/vps" search={{ edit: vpsId }} />}>
|
||||
Редактировать
|
||||
</Button>
|
||||
vps ? (
|
||||
<Button variant="outline" render={<Link to="/vps" search={{ edit: vpsId }} />}>
|
||||
Редактировать
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -133,6 +137,15 @@ function VpsDetailPage() {
|
||||
isError={isError}
|
||||
error={error}
|
||||
onRetry={() => refetch()}
|
||||
skeleton={
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-9 w-48" />
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<Skeleton className="h-40 w-full" />
|
||||
<Skeleton className="h-40 w-full" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
empty={!isLoading && !vps}
|
||||
emptyTitle="VPS не найден"
|
||||
emptyDescription="Запись могла быть удалена"
|
||||
@@ -151,9 +164,7 @@ function VpsDetailPage() {
|
||||
|
||||
<TabsContent value="overview" className="flex flex-col gap-4">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Badge variant={row.status === 'active' ? 'default' : 'secondary'}>
|
||||
{vpsStatusLabel(row.status)}
|
||||
</Badge>
|
||||
<StatusBadge status={row.status} label={vpsStatusLabel(row.status)} />
|
||||
{row.project ? <Badge variant="outline">{row.project}</Badge> : null}
|
||||
{row.environment ? <Badge variant="outline">{row.environment}</Badge> : null}
|
||||
</div>
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
} from '@/components/vps-filters'
|
||||
import { VpsFiltersToolbar } from '@/components/vps-filters-toolbar'
|
||||
import { HealthModeBanner } from '@/components/health-mode-banner'
|
||||
import { ProjectColorDot } from '@/components/project-color-dot'
|
||||
import { VpsBulkToolbar } from '@/components/domain/vps-bulk-toolbar'
|
||||
|
||||
import type { Vps } from '@/types/entities'
|
||||
@@ -189,7 +190,7 @@ function VpsPage() {
|
||||
value: name,
|
||||
label: name,
|
||||
leading: color ? (
|
||||
<span className="size-2.5 shrink-0 rounded-full ring-1 ring-foreground/10" style={{ backgroundColor: color }} />
|
||||
<ProjectColorDot color={color} className="ring-1 ring-foreground/10" />
|
||||
) : undefined,
|
||||
}
|
||||
})
|
||||
@@ -531,11 +532,20 @@ function VpsPage() {
|
||||
>
|
||||
{(snap) => {
|
||||
const filtersActive = hasActiveVpsFilters(filters)
|
||||
const zeroResults = snap.vps.length > 0 && filteredVps.length === 0 && filtersActive
|
||||
const zeroResults =
|
||||
snap.vps.length > 0 && filteredVps.length === 0 && (filtersActive || Boolean(health))
|
||||
|
||||
const resetFilters = () => {
|
||||
setFilters(buildDefaultVpsFilters())
|
||||
if (health) {
|
||||
void navigate({ to: '/vps', search: {} })
|
||||
}
|
||||
}
|
||||
|
||||
if (zeroResults) {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
{health ? <HealthModeBanner health={health} exitTo="/vps" /> : null}
|
||||
<VpsFiltersToolbar
|
||||
filters={filters}
|
||||
onChange={setFilters}
|
||||
@@ -555,8 +565,8 @@ function VpsPage() {
|
||||
title="Ничего не найдено"
|
||||
description="По текущим фильтрам VPS не найдены"
|
||||
action={
|
||||
<Button variant="outline" onClick={() => setFilters(buildDefaultVpsFilters())}>
|
||||
Сбросить фильтры
|
||||
<Button variant="outline" onClick={resetFilters}>
|
||||
{health ? 'Выйти из режима и сбросить фильтры' : 'Сбросить фильтры'}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user