Merge branch 'fix/sweep-raw-axios-error-displays' into 'main'

fix(ui): replace raw AxiosError dumps with QueryErrorState across routes

See merge request 2-6/2-6-4/terravault/ordinis!194
This commit is contained in:
Александр Зимин
2026-05-14 20:42:45 +00:00
5 changed files with 34 additions and 39 deletions
@@ -1,6 +1,6 @@
import { useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Alert, Badge, Button, LoadingBlock, Modal, TextInput } from '@/ui'
import { Alert, Badge, Button, LoadingBlock, Modal, QueryErrorState, TextInput } from '@/ui'
import { WarningIcon, XCircleIcon } from '@phosphor-icons/react'
import { useCascadePreview } from '@/api/queries'
import { useCascadeCloseRecord } from '@/api/mutations'
@@ -116,9 +116,7 @@ export const CascadeConfirmDialog = ({
{preview.isLoading && <LoadingBlock size="md" label={t('loading')} />}
{preview.error && (
<Alert variant="error" title={t('error.failed')}>
{String(preview.error)}
</Alert>
<QueryErrorState error={preview.error} onRetry={() => preview.refetch()} />
)}
{plan && (
@@ -261,9 +259,9 @@ export const CascadeConfirmDialog = ({
)}
{cascadeMut.error && (
<Alert variant="error" title={t('error.failed')}>
{String(cascadeMut.error)}
</Alert>
/* Mutation error — no retry button (user triggers via Confirm
again). QueryErrorState classifies 4xx/5xx code/message. */
<QueryErrorState error={cascadeMut.error} />
)}
</>
)}
@@ -967,9 +967,10 @@ function DictionaryDetail() {
{recordsResult.isLoading && <LoadingBlock size="md" label={t('loading')} />}
{recordsResult.error && (
<Alert variant="error" title={t('error.failed')}>
{String(recordsResult.error)}
</Alert>
<QueryErrorState
error={recordsResult.error}
onRetry={() => recordsResult.refetch()}
/>
)}
{recordsResult.data && recordsResult.data.length === 0 && (
@@ -1279,9 +1280,10 @@ function DictionaryDetail() {
)}
{detailQuery.data && edit.kind === 'edit' && rawRecordQuery.error && (
<Alert variant="error" title={t('error.failed')}>
{String(rawRecordQuery.error)}
</Alert>
<QueryErrorState
error={rawRecordQuery.error}
onRetry={() => rawRecordQuery.refetch()}
/>
)}
{detailQuery.data && edit.kind === 'edit' && rawRecordQuery.data && (
@@ -2086,7 +2088,8 @@ function highlightJson(json: string): string {
*/
function EventsTabContent({ dictName }: { dictName: string }) {
const { t } = useTranslation()
const { data, isLoading, error } = useAudit({ dictionaryName: dictName, size: 50 })
const auditQ = useAudit({ dictionaryName: dictName, size: 50 })
const { data, isLoading, error } = auditQ
// Filter chips per prototype: все / edit / publish / review / webhook / export.
// Backend audit actions: CREATE / UPDATE / CLOSE / EXPORT etc. — map to display
// groups for chip filter.
@@ -2094,11 +2097,7 @@ function EventsTabContent({ dictName }: { dictName: string }) {
if (isLoading) return <LoadingBlock size="md" label={t('loading')} />
if (error)
return (
<Alert variant="error" title={t('error.failed')}>
{String(error)}
</Alert>
)
return <QueryErrorState error={error} onRetry={() => auditQ.refetch()} />
const rows = data?.content ?? []
if (rows.length === 0)
return (
@@ -2298,7 +2297,8 @@ function EventsTabContent({ dictName }: { dictName: string }) {
function HistoryTabContent({ detail }: { detail?: import('@/api/client').DictionaryDetail }) {
const { t } = useTranslation()
const [diffEntryId, setDiffEntryId] = useState<number | undefined>(undefined)
const { data, isLoading, error } = useChangelog(detail?.name)
const changelogQ = useChangelog(detail?.name)
const { data, isLoading, error } = changelogQ
if (!detail) return null
@@ -2306,9 +2306,7 @@ function HistoryTabContent({ detail }: { detail?: import('@/api/client').Diction
<div className="space-y-3">
{isLoading && <LoadingBlock size="md" label={t('loading')} />}
{error && (
<Alert variant="error" title={t('error.failed')}>
{String(error)}
</Alert>
<QueryErrorState error={error} onRetry={() => changelogQ.refetch()} />
)}
{data && data.entries.length === 0 && (
<EmptyState
+10 -7
View File
@@ -2,13 +2,13 @@ import { useState } from 'react'
import { Link, createFileRoute } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import {
Alert,
Badge,
Button,
EmptyState,
LoadingBlock,
PageHeader,
Panel,
QueryErrorState,
Table,
TableBody,
TableCell,
@@ -92,15 +92,18 @@ function MyDraftsPage() {
<LoadingBlock size="md" label={t('loading')} />
)}
{/* QueryErrorState classifies status code (502 → "Сервис временно
недоступен", timeout → "Запрос превысил время ожидания", etc.) и
показывает retry button. Раньше тут был <Alert>{String(error)}</Alert>
который дампил raw AxiosError юзеру — анти-паттерн UX. */}
{drafts.error && (
<Alert variant="error" title={t('error.failed')}>
{String(drafts.error)}
</Alert>
<QueryErrorState error={drafts.error} onRetry={() => drafts.refetch()} />
)}
{schemaDrafts.error && (
<Alert variant="error" title={t('error.failed')}>
{String(schemaDrafts.error)}
</Alert>
<QueryErrorState
error={schemaDrafts.error}
onRetry={() => schemaDrafts.refetch()}
/>
)}
{bothEmpty && <EmptyState title={t('myDrafts.empty')} />}
+1 -3
View File
@@ -715,9 +715,7 @@ function ReviewDrawer({ draftId, onClose }: DrawerProps) {
<div className="space-y-4">
{draftQ.isLoading && <LoadingBlock size="md" label={t('loading')} />}
{draftQ.error && (
<Alert variant="error" title={t('error.failed')}>
{String(draftQ.error)}
</Alert>
<QueryErrorState error={draftQ.error} onRetry={() => draftQ.refetch()} />
)}
{draft && (
@@ -12,6 +12,7 @@ import {
MultiSelect,
PageHeader,
Panel,
QueryErrorState,
Table,
TableBody,
TableCell,
@@ -79,7 +80,8 @@ const EVENT_TYPE_OPTIONS: SelectOption[] = [
function WebhooksPage() {
const { t } = useTranslation()
const { data, isLoading, error } = useWebhookSubscriptions()
const subsQ = useWebhookSubscriptions()
const { data, isLoading, error } = subsQ
const [createOpen, setCreateOpen] = useState(false)
const [revealedSecret, setRevealedSecret] = useState<{
name: string
@@ -94,11 +96,7 @@ function WebhooksPage() {
if (isLoading) return <LoadingBlock size="md" label={t('loading')} />
if (error) {
return (
<Alert variant="error" title={t('error.failed')}>
{String(error)}
</Alert>
)
return <QueryErrorState error={error} onRetry={() => subsQ.refetch()} />
}
return (