Merge branch 'fix/history-drawer-single-version-hint' into 'main'
fix(history): подсказка и Button-стайл когда у записи 1 версия See merge request 2-6/2-6-4/terravault/ordinis!122
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Alert, Badge, Button, Drawer, LoadingBlock } from '@/ui'
|
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 { useRecordHistory } from '@/api/queries'
|
||||||
import { RecordDependentsPanel } from '@/components/lineage/RecordDependentsPanel'
|
import { RecordDependentsPanel } from '@/components/lineage/RecordDependentsPanel'
|
||||||
|
|
||||||
@@ -120,18 +120,23 @@ export const RecordHistoryDrawer = ({
|
|||||||
* с самим собой). Revert тоже только для старых (на текущей
|
* с самим собой). Revert тоже только для старых (на текущей
|
||||||
* uno-op). Wrap чтобы планшетный portrait делал stack. */}
|
* uno-op). Wrap чтобы планшетный portrait делал stack. */}
|
||||||
<div className="mt-2 flex flex-wrap items-center gap-2">
|
<div className="mt-2 flex flex-wrap items-center gap-2">
|
||||||
<button
|
{/* JSON toggle: подаём как Button ghost вместо текстовой
|
||||||
|
* ссылки — иначе в single-version case строка выглядит
|
||||||
|
* как «нет действий вообще». */}
|
||||||
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
onClick={() => setExpanded((prev) => {
|
onClick={() => setExpanded((prev) => {
|
||||||
const next = new Set(prev)
|
const next = new Set(prev)
|
||||||
if (next.has(rec.id)) next.delete(rec.id)
|
if (next.has(rec.id)) next.delete(rec.id)
|
||||||
else next.add(rec.id)
|
else next.add(rec.id)
|
||||||
return next
|
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')}
|
{expanded.has(rec.id) ? t('history.hideData') : t('history.viewData')}
|
||||||
</button>
|
</Button>
|
||||||
{!isLatest && onCompare && (
|
{!isLatest && onCompare && (
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -155,6 +160,17 @@ export const RecordHistoryDrawer = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</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) && (
|
{expanded.has(rec.id) && (
|
||||||
<pre className="text-mono mt-2 bg-line/30 rounded p-2 overflow-x-auto text-cell">
|
<pre className="text-mono mt-2 bg-line/30 rounded p-2 overflow-x-auto text-cell">
|
||||||
{JSON.stringify(rec.data, null, 2)}
|
{JSON.stringify(rec.data, null, 2)}
|
||||||
|
|||||||
@@ -397,6 +397,7 @@ i18n
|
|||||||
'history.compare': 'Сравнить с текущим',
|
'history.compare': 'Сравнить с текущим',
|
||||||
'history.revert': 'Откатить к v{{v}}',
|
'history.revert': 'Откатить к v{{v}}',
|
||||||
'history.revertConfirm': 'Откатить к v{{v}}? Создастся новая активная версия.',
|
'history.revertConfirm': 'Откатить к v{{v}}? Создастся новая активная версия.',
|
||||||
|
'history.singleVersionHint': 'Это единственная версия. Кнопки «Сравнить» и «Откатить» появятся, когда у записи будет более одной версии.',
|
||||||
// === Lineage (dict-relationships-v2 Phase 1) ===
|
// === Lineage (dict-relationships-v2 Phase 1) ===
|
||||||
'lineage.usedBy.title': 'На этот словарь ссылаются',
|
'lineage.usedBy.title': 'На этот словарь ссылаются',
|
||||||
'lineage.usedBy.count_one': '{{count}} связь',
|
'lineage.usedBy.count_one': '{{count}} связь',
|
||||||
@@ -911,6 +912,7 @@ i18n
|
|||||||
'history.compare': 'Compare with current',
|
'history.compare': 'Compare with current',
|
||||||
'history.revert': 'Revert to v{{v}}',
|
'history.revert': 'Revert to v{{v}}',
|
||||||
'history.revertConfirm': 'Revert to v{{v}}? A new active version will be created.',
|
'history.revertConfirm': 'Revert to v{{v}}? A new active version will be created.',
|
||||||
|
'history.singleVersionHint': 'This is the only version. Compare and Revert actions will appear once the record has more than one version.',
|
||||||
// === Lineage (dict-relationships-v2 Phase 1) ===
|
// === Lineage (dict-relationships-v2 Phase 1) ===
|
||||||
'lineage.usedBy.title': 'Used by',
|
'lineage.usedBy.title': 'Used by',
|
||||||
'lineage.usedBy.count_one': '{{count}} reference',
|
'lineage.usedBy.count_one': '{{count}} reference',
|
||||||
|
|||||||
Reference in New Issue
Block a user