fix(ui): учитывать права и состояние устройства при откате истории

This commit is contained in:
Denozordec committed 2026-10-13 19:45:39 +07:00
1 parent 5ce20e8892
commit c8f9c83f45
17 files changed
+388 -16

No files matched your search

+2
View File
@@ -1628,6 +1628,7 @@ function FiltersPage() {
}, [isLive, selectedServerId, apiFetch])
const restoreRevision = useCallback(async (id: string) => {
if (!can("mm:filters:write")) throw new Error("Нет прав на изменение конфигурации")
if (!isLive || !selectedServerId) throw new Error("Выберите устройство в режиме живых данных")
if (applyLock.current || applyBusy || historyRestoring) throw new Error("Дождитесь завершения текущей операции")
applyLock.current = true
@@ -2107,6 +2108,7 @@ function FiltersPage() {
revisions={revisions}
loading={historyLoading}
restoring={historyRestoring}
restoreDisabled={!can("mm:filters:write") || !isLive || !allServers.some(s => s.id === selectedServerId && s.enabled) || applyBusy || historyRestoring || movePending}
onRestore={restoreRevision}
/>
</>
+4
View File
@@ -1,5 +1,7 @@
"use client"
import { can } from "@/lib/auth"
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react"
import { useSearchParams } from "next/navigation"
import { PageHeader } from "@/components/page-header"
@@ -2040,6 +2042,7 @@ function FirewallPageInner() {
}, [isLive, historyServerId, apiFetch])
const restoreRevision = useCallback(async (id: string) => {
if (!can("mm:network:write")) throw new Error("Нет прав на изменение конфигурации")
if (!isLive || !historyServerId) throw new Error("Выберите устройство в режиме Live")
if (mutationLock.current) throw new Error("Дождитесь завершения текущей операции Firewall")
if (!readTrusted) throw new Error("Обновите актуальные данные Firewall перед восстановлением")
@@ -2837,6 +2840,7 @@ function FirewallPageInner() {
revisions={revisions}
loading={historyLoading}
restoring={historyRestoring}
restoreDisabled={!can("mm:network:write") || !isLive || !writeServer?.enabled || !readTrusted || failures.some(f => f.serverId === historyServerId) || dataLoading || busy || historyRestoring}
onRestore={restoreRevision}
/>
</>
+4
View File
@@ -1,5 +1,7 @@
"use client"
import { can } from "@/lib/auth"
import { Suspense, useCallback, useEffect, useRef, useMemo, useState } from "react"
import Link from "next/link"
import { useRouter, useSearchParams } from "next/navigation"
@@ -294,6 +296,7 @@ function GrePageContent({ selectedServerId, selectedTunnelId, allTunnelsHref, on
}, [isLive, historyServerId, apiFetch])
const restoreRevision = async (id: string) => {
if (!can("mm:network:write")) throw new Error("Нет прав на изменение конфигурации")
if (!historyServerId || !beginOperation(historyServerId)) throw new Error("Устройство не готово к восстановлению GRE")
setHistoryRestoring(true)
try {
@@ -934,6 +937,7 @@ function GrePageContent({ selectedServerId, selectedTunnelId, allTunnelsHref, on
revisions={revisions}
loading={historyLoading}
restoring={historyRestoring}
restoreDisabled={!can("mm:network:write") || !historyServerId || !canManage(historyServerId)}
onRestore={restoreRevision}
/>
+4
View File
@@ -1,5 +1,7 @@
"use client"
import { can } from "@/lib/auth"
import { z } from "zod"
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react"
import { useSearchParams } from "next/navigation"
@@ -295,6 +297,7 @@ function IpsecPage({ selectedServerId, setSelectedServerId, workspaceTab, setWor
}, [isLive, historyServerId, backendUrl])
const restoreRevision = async (id: string) => {
if (!can("mm:network:write")) throw new Error("Нет прав на изменение конфигурации")
if (!isLive || !historyServerId) return
beginOperation(historyServerId)
setHistoryRestoring(true)
@@ -969,6 +972,7 @@ function IpsecPage({ selectedServerId, setSelectedServerId, workspaceTab, setWor
revisions={revisions}
loading={historyLoading}
restoring={historyRestoring}
restoreDisabled={!can("mm:network:write") || !historyServerId || !canManage(historyServerId)}
onRestore={restoreRevision}
title="История конфигураций IPsec"
itemLabel="конфигурация"
+4
View File
@@ -1,5 +1,7 @@
"use client"
import { can } from "@/lib/auth"
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react"
import Link from "next/link"
import { useRouter, useSearchParams } from "next/navigation"
@@ -308,6 +310,7 @@ function WireGuardPageContent({ selectedServerId, selectedInterfaceId, allInterf
}, [isLive, historyServerId, backendUrl])
const restoreRevision = useCallback(async (id: string) => {
if (!can("mm:network:write")) throw new Error("Нет прав на изменение конфигурации")
if (!isLive || !historyServerId || restoreLock.current) return
restoreLock.current = true
setHistoryRestoring(true)
@@ -1022,6 +1025,7 @@ function WireGuardPageContent({ selectedServerId, selectedInterfaceId, allInterf
revisions={revisions}
loading={historyLoading}
restoring={historyRestoring}
restoreDisabled={!can("mm:network:write") || !isLive || !historyServerId || !displayServers.some(s => s.id === historyServerId && s.enabled) || loading || busy || deleteBusy || !!togglePending}
onRestore={restoreRevision}
/>
</>