fix(evolution): разделить состояния настроек и каталога и защитить контекст
This commit is contained in:
1 parent
554dba55ec
commit
9db1471b2c
11 files changed
+158
-202
No files matched your search
@@ -0,0 +1,22 @@
|
||||
"use client"
|
||||
import {useEvoBGP} from "@/lib/evobgp-context"
|
||||
import {useDataSource} from "@/lib/data-source"
|
||||
import {can} from "@/lib/auth"
|
||||
import {Alert,AlertDescription,AlertTitle} from "@/components/reui/alert"
|
||||
import {Badge} from "@/components/reui/badge"
|
||||
import {Button} from "@/components/ui/button"
|
||||
import {AlertCircleIcon} from "lucide-react"
|
||||
const date=(value:string|null)=>value?new Date(value).toLocaleString("ru-RU"):"—"
|
||||
export function EvoBgpDataStatus(){
|
||||
const evo=useEvoBGP(),{mode,backendStatus}=useDataSource()
|
||||
return <div className="flex flex-col gap-3">
|
||||
<div className="flex flex-wrap items-center gap-2"><Badge variant="secondary">Интеграция: {evo.settingsLoaded?evo.enabled?"включена":"выключена":"—"}</Badge><Badge variant="secondary">Ключ: {evo.settingsLoaded?evo.secretConfigured?"сохранён":"не сохранён":"—"}</Badge></div>
|
||||
<p role="status" className="text-xs text-muted-foreground">{evo.settingsLoaded?"Настройки EvoBGP получены: "+date(evo.settingsReceivedAt):evo.settingsLoading?"Загрузка настроек EvoBGP…":"Настройки EvoBGP не получены"}</p>
|
||||
{evo.settingsLoaded&&evo.settingsLoading?<p role="status" className="text-xs text-muted-foreground">Обновление настроек EvoBGP…</p>:null}
|
||||
{evo.settingsError?<Alert variant="warning"><AlertCircleIcon aria-hidden="true"/><AlertTitle>{evo.settingsLoaded?"Настройки EvoBGP не обновлены":"Настройки EvoBGP неизвестны"}</AlertTitle><AlertDescription>{evo.settingsError}</AlertDescription></Alert>:null}
|
||||
<p role="status" className="text-xs text-muted-foreground">{evo.snapshot?"Каталог EvoBGP получен: "+date(evo.catalogReceivedAt):evo.loading?"Загрузка каталога EvoBGP…":evo.settingsLoaded&&!evo.enabled?"Каталог EvoBGP отключён в сохранённых настройках":"Каталог EvoBGP не получен"}</p>
|
||||
{evo.snapshot&&evo.loading?<p role="status" className="text-xs text-muted-foreground">Обновление каталога EvoBGP…</p>:null}
|
||||
{evo.catalogError?<Alert variant="warning"><AlertCircleIcon aria-hidden="true"/><AlertTitle>{evo.snapshot?"Каталог EvoBGP не обновлён; показаны последние данные":"Каталог EvoBGP неизвестен"}</AlertTitle><AlertDescription>{evo.catalogError}</AlertDescription></Alert>:null}
|
||||
<Button size="sm" variant="outline" disabled={mode!=="live"||backendStatus!==true||!can("mm:settings:admin")||evo.settingsLoading||evo.operationBusy} onClick={()=>{void evo.loadSettings()}}>Обновить настройки EvoBGP</Button>
|
||||
</div>
|
||||
}
|
||||
Reference in new issue
Block a user