fix(backups): разделить загрузку каталогов и права действий

This commit is contained in:
Denozordec committed 2026-10-01 15:06:52 +07:00
1 parent b460997cbf
commit 3dcc7c9ea6
11 files changed
+259 -91

No files matched your search

+9 -1
View File
@@ -28,6 +28,9 @@ export function BackupsHistory({
onRestore,
onDelete,
onCreate,
canCreate = true,
canWrite = true,
canDownload = true,
}: {
backups: Backup[]
kindFilter: KindFilter
@@ -39,6 +42,9 @@ export function BackupsHistory({
onDownload: (id: string, filename: string) => void
onRestore: (backup: Backup) => void
onDelete: (backup: Backup) => void
canCreate?: boolean
canWrite?: boolean
canDownload?: boolean
onCreate: () => void
}) {
const autoCount = backups.filter((b) => b.kind === "auto").length
@@ -76,6 +82,8 @@ export function BackupsHistory({
onDownload={onDownload}
onRestore={onRestore}
onDelete={onDelete}
canWrite={canWrite}
canDownload={canDownload}
emptyTitle={isEmptyAll ? "Нет бэкапов" : "Ничего не найдено"}
emptyDescription={
isEmptyAll
@@ -83,7 +91,7 @@ export function BackupsHistory({
: "Измените фильтры или поисковый запрос"
}
emptyAction={
isEmptyAll ? (
isEmptyAll && canCreate ? (
<Button type="button" size="sm" onClick={onCreate}>
<PlusIcon className="size-4" />
Новый бэкап
+8 -1
View File
@@ -32,6 +32,8 @@ interface BackupsDataGridProps {
onDownload: (id: string, filename: string) => void
onRestore: (backup: Backup) => void
onDelete: (backup: Backup) => void
canWrite?: boolean
canDownload?: boolean
emptyAction?: ReactNode
emptyTitle?: string
emptyDescription?: string
@@ -48,6 +50,8 @@ function BackupsDataGrid({
onDownload,
onRestore,
onDelete,
canWrite = true,
canDownload = true,
emptyAction,
emptyTitle = "Нет бэкапов",
emptyDescription = "Создайте первый бэкап вручную или настройте расписание",
@@ -191,6 +195,7 @@ function BackupsDataGrid({
className="size-7"
title="Скачать"
aria-label={`Скачать ${b.filename}`}
disabled={!canDownload}
onClick={() => onDownload(b.id, b.filename)}
>
<DownloadIcon className="size-3.5" />
@@ -202,6 +207,7 @@ function BackupsDataGrid({
className="size-7"
title="Восстановить"
aria-label={`Восстановить ${b.filename}`}
disabled={!canWrite || !b.serverId}
onClick={() => onRestore(b)}
>
<RefreshCwIcon className="size-3.5" />
@@ -213,6 +219,7 @@ function BackupsDataGrid({
className="size-7 text-destructive hover:text-destructive"
title="Удалить"
aria-label={`Удалить ${b.filename}`}
disabled={!canWrite}
onClick={() => onDelete(b)}
>
<Trash2Icon className="size-3.5" />
@@ -228,7 +235,7 @@ function BackupsDataGrid({
},
},
],
[onDelete, onDownload, onRestore],
[onDelete, onDownload, onRestore, canWrite, canDownload],
)
const table = useTable({