fix(history): подсказка и Button-стайл когда у записи 1 версия

This commit is contained in:
Александр Зимин
2026-05-12 08:57:44 +00:00
parent bdf16daee8
commit 7192aed71c
2 changed files with 22 additions and 4 deletions
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Alert, Badge, Button, Drawer, LoadingBlock } from '@/ui'
import { ArrowsLeftRightIcon, ArrowCounterClockwiseIcon } from '@phosphor-icons/react'
import { ArrowsLeftRightIcon, ArrowCounterClockwiseIcon, BracketsCurlyIcon, InfoIcon } from '@phosphor-icons/react'
import { useRecordHistory } from '@/api/queries'
import { RecordDependentsPanel } from '@/components/lineage/RecordDependentsPanel'
@@ -120,18 +120,23 @@ export const RecordHistoryDrawer = ({
* с самим собой). Revert тоже только для старых (на текущей
* uno-op). Wrap чтобы планшетный portrait делал stack. */}
<div className="mt-2 flex flex-wrap items-center gap-2">
<button
{/* JSON toggle: подаём как Button ghost вместо текстовой
* ссылки — иначе в single-version case строка выглядит
* как «нет действий вообще». */}
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => setExpanded((prev) => {
const next = new Set(prev)
if (next.has(rec.id)) next.delete(rec.id)
else next.add(rec.id)
return next
})}
className="text-cell text-accent hover:underline"
leftIcon={<BracketsCurlyIcon weight="regular" size={14} />}
>
{expanded.has(rec.id) ? t('history.hideData') : t('history.viewData')}
</button>
</Button>
{!isLatest && onCompare && (
<Button
type="button"
@@ -155,6 +160,17 @@ export const RecordHistoryDrawer = ({
</Button>
)}
</div>
{/* Single-version hint: объясняем, почему Compare/Revert
* отсутствуют. Раньше пользователь видел только JSON-ссылку
* и спрашивал «где кнопки?». Показываем только когда есть
* вообще что показать (canMutate с обоими callback'ами),
* иначе read-only viewer и подсказка не нужна. */}
{isLatest && data.length === 1 && (onCompare || onRevert) && (
<div className="mt-2 flex items-start gap-1.5 text-cell text-mute">
<InfoIcon weight="regular" size={14} className="mt-[2px] shrink-0" />
<span>{t('history.singleVersionHint')}</span>
</div>
)}
{expanded.has(rec.id) && (
<pre className="text-mono mt-2 bg-line/30 rounded p-2 overflow-x-auto text-cell">
{JSON.stringify(rec.data, null, 2)}