fix(system): keep network configuration in worker settings
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import {useEffect, useRef, useState} from "react";
|
||||
import {Button, Description, Icon, SettingsCard, StatusBadge} from "@nodedc/ui-react";
|
||||
import {useRef, useState} from "react";
|
||||
import {Button, Description, Icon, StatusBadge} from "@nodedc/ui-react";
|
||||
import {fleetRequest} from "../../core/fleet/useFleet";
|
||||
import {connectionRequest, type ConnectionCatalog} from "../../core/system/workerConnections";
|
||||
|
||||
export function ImportNetworkProfile({onImported, disabled = false}: {onImported: () => Promise<unknown>; disabled?: boolean}) {
|
||||
const input = useRef<HTMLInputElement>(null);
|
||||
@@ -26,28 +25,3 @@ export function ImportNetworkProfile({onImported, disabled = false}: {onImported
|
||||
{error && <p role="alert"><StatusBadge tone="warning">{error}</StatusBadge></p>}
|
||||
</>;
|
||||
}
|
||||
|
||||
export function SharedNetworkProfiles() {
|
||||
const [catalog, setCatalog] = useState<ConnectionCatalog | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
async function refresh(signal?: AbortSignal) {
|
||||
const value = await connectionRequest<ConnectionCatalog>("", undefined, signal);
|
||||
if (!signal?.aborted) {setCatalog(value); setError(null);}
|
||||
}
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
void refresh(controller.signal).catch(e => {if (!controller.signal.aborted) setError(e.message);});
|
||||
return () => controller.abort();
|
||||
}, []);
|
||||
return <SettingsCard eyebrow="ОБЩИЕ СЕТИ" title="Сетевые подключения"
|
||||
description="Профили доступны всему парку. Активное подключение выбирается отдельно в настройках каждого устройства.">
|
||||
{catalog?.profiles.map(profile => <p key={profile.id}>
|
||||
<strong>{profile.name}</strong> · {profile.provider === "tailscale" ? "Tailscale" : "WireGuard"}
|
||||
{profile.provider === "wireguard" ? " · подключение устройств настраивается отдельно" : " · сеть текущего клиента"}
|
||||
</p>)}
|
||||
<Description>Адреса WireGuard в списке — серверы VPN. Tailscale показывает текущую сеть приложения на этом компьютере.</Description>
|
||||
<ImportNetworkProfile onImported={refresh}/>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
{catalog?.notice && <Description>{catalog.notice}</Description>}
|
||||
</SettingsCard>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user