mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-10 03:55:37 -04:00
- **Wails v3 application** (`client/ui`) with a React + TypeScript + Tailwind frontend replacing the Fyne UI: main connection view, exit-node switcher, networks/peers browser with detail panels, profile management, settings (general, network, SSH, security, troubleshooting, appearance), debug-bundle creation, and a first-run welcome flow. - **Internationalization**: go-i18n bundle with 9 locales (en, de, es, fr, hu, it, pt, ru, zh-CN) shared between the tray and the frontend. - **New system tray** implementation with per-platform theme-aware icons, including a native XEmbed host for Linux (`xembed_tray_linux.c`) and a Linux theme watcher. - **Session handling**: auth session watcher (`client/internal/auth/sessionwatch`), pending login flow, session-expiration dialog and tray notifications, and `netbird login` improvements. - **Daemon API extensions** (`daemon.proto`): status stream subscription, event stream, networks/exit-node selection endpoints, and richer full status — with probe throttling on the daemon side to protect against UI-driven request storms. - **UI preferences store** persisted per profile, autostart management via the daemon (single source of truth in HKCU on Windows). - **Build system**: Taskfile-based builds per platform (macOS, Linux, Windows), Docker cross-compilation images, MSIX/NSIS/nfpm/AppImage packaging, and a new `frontend-ui` CI workflow. Co-authored-by: Zoltan Papp <zoltan.pmail@gmail.com> Co-authored-by: Eduard Gert <kontakt@eduardgert.de> Co-authored-by: braginini <bangvalo@gmail.com> Co-authored-by: Pascal Fischer <32096965+pascal-fischer@users.noreply.github.com> Co-authored-by: riccardom <riccardomanfrin@gmail.com>
132 lines
5.8 KiB
TypeScript
132 lines
5.8 KiB
TypeScript
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
|
import { useLocation } from "react-router-dom";
|
|
import { Events } from "@wailsio/runtime";
|
|
import * as ScrollArea from "@radix-ui/react-scroll-area";
|
|
import { cn } from "@/lib/cn";
|
|
import { isMacOS } from "@/lib/platform";
|
|
import { AppRightPanel } from "@/layouts/AppRightPanel.tsx";
|
|
import { VerticalTabs } from "@/components/VerticalTabs.tsx";
|
|
import { SettingsNavigation } from "@/modules/settings/SettingsNavigation.tsx";
|
|
import { AutostartSettingsProvider, SettingsProvider } from "@/contexts/SettingsContext.tsx";
|
|
import { SettingsGeneral } from "@/modules/settings/SettingsGeneral.tsx";
|
|
import { SettingsNetwork } from "@/modules/settings/SettingsNetwork.tsx";
|
|
import { SettingsSecurity } from "@/modules/settings/SettingsSecurity.tsx";
|
|
import { ProfilesTab } from "@/modules/profiles/ProfilesTab.tsx";
|
|
import { SettingsSSH } from "@/modules/settings/SettingsSSH.tsx";
|
|
import { SettingsAdvanced } from "@/modules/settings/SettingsAdvanced.tsx";
|
|
import { SettingsTroubleshooting } from "@/modules/settings/SettingsTroubleshooting.tsx";
|
|
import { SettingsAbout } from "@/modules/settings/SettingsAbout.tsx";
|
|
import { useRestrictions } from "@/contexts/RestrictionsContext.tsx";
|
|
|
|
const EVENT_SETTINGS_OPEN = "netbird:settings:open";
|
|
|
|
const enum Tab {
|
|
General = "general",
|
|
Network = "network",
|
|
Security = "security",
|
|
Profiles = "profiles",
|
|
SSH = "ssh",
|
|
Advanced = "advanced",
|
|
Troubleshooting = "troubleshooting",
|
|
About = "about",
|
|
}
|
|
|
|
const TAB_CONTENT: Record<Tab, ReactNode> = {
|
|
[Tab.General]: <SettingsGeneral />,
|
|
[Tab.Network]: <SettingsNetwork />,
|
|
[Tab.Security]: <SettingsSecurity />,
|
|
[Tab.Profiles]: <ProfilesTab />,
|
|
[Tab.SSH]: <SettingsSSH />,
|
|
[Tab.Advanced]: <SettingsAdvanced />,
|
|
[Tab.Troubleshooting]: <SettingsTroubleshooting />,
|
|
[Tab.About]: <SettingsAbout />,
|
|
};
|
|
|
|
export const SettingsPage = () => {
|
|
const location = useLocation();
|
|
const navState = location.state as { tab?: string } | null;
|
|
const { mdm, features } = useRestrictions();
|
|
|
|
const visibleTabs = useMemo<Tab[]>(() => {
|
|
const editable = !features.disableUpdateSettings;
|
|
const visibility: Record<Tab, boolean> = {
|
|
[Tab.General]: true,
|
|
[Tab.Network]: editable,
|
|
[Tab.Security]: editable,
|
|
[Tab.Profiles]: !features.disableProfiles,
|
|
[Tab.SSH]: mdm.allowServerSSH ?? editable,
|
|
[Tab.Advanced]: editable,
|
|
[Tab.Troubleshooting]: true,
|
|
[Tab.About]: true,
|
|
};
|
|
return (Object.keys(visibility) as Tab[]).filter((t) => visibility[t]);
|
|
}, [features.disableUpdateSettings, features.disableProfiles, mdm.allowServerSSH]);
|
|
|
|
const defaultTab = visibleTabs[0];
|
|
const [active, setActive] = useState<string>(() => navState?.tab ?? defaultTab);
|
|
|
|
useEffect(() => {
|
|
if (navState?.tab) setActive(navState.tab);
|
|
}, [navState?.tab, location.key]);
|
|
|
|
useEffect(() => {
|
|
return Events.On(EVENT_SETTINGS_OPEN, (e: { data: string }) => {
|
|
setActive(e.data || defaultTab);
|
|
});
|
|
}, [defaultTab]);
|
|
|
|
// Reset active tab if it got disabled by any feature flag or mdm restrictions
|
|
useEffect(() => {
|
|
if (!visibleTabs.includes(active as Tab)) setActive(defaultTab);
|
|
}, [visibleTabs, active, defaultTab]);
|
|
|
|
return (
|
|
<>
|
|
{isMacOS() ? (
|
|
<div className={"wails-draggable h-12 shrink-0 cursor-default select-none"} />
|
|
) : (
|
|
<div className={"h-px shrink-0 bg-nb-gray-920/0"} />
|
|
)}
|
|
<main className={"flex min-h-0 flex-1"}>
|
|
<VerticalTabs value={active} onValueChange={setActive}>
|
|
<SettingsNavigation />
|
|
<AppRightPanel>
|
|
<AutostartSettingsProvider>
|
|
<SettingsProvider>
|
|
<ScrollArea.Root
|
|
key={active}
|
|
type={"auto"}
|
|
className={"min-h-0 flex-1 overflow-hidden"}
|
|
>
|
|
<ScrollArea.Viewport className={"h-full w-full"}>
|
|
<div className={"px-7 py-6"}>
|
|
{visibleTabs.map((tab) => (
|
|
<VerticalTabs.Content key={tab} value={tab}>
|
|
{TAB_CONTENT[tab]}
|
|
</VerticalTabs.Content>
|
|
))}
|
|
</div>
|
|
</ScrollArea.Viewport>
|
|
<ScrollArea.Scrollbar
|
|
orientation={"vertical"}
|
|
className={cn(
|
|
"flex touch-none select-none transition-colors",
|
|
"w-1.5 bg-transparent py-1",
|
|
)}
|
|
>
|
|
<ScrollArea.Thumb
|
|
className={
|
|
"relative flex-1 rounded-full bg-nb-gray-800 hover:bg-nb-gray-700"
|
|
}
|
|
/>
|
|
</ScrollArea.Scrollbar>
|
|
</ScrollArea.Root>
|
|
</SettingsProvider>
|
|
</AutostartSettingsProvider>
|
|
</AppRightPanel>
|
|
</VerticalTabs>
|
|
</main>
|
|
</>
|
|
);
|
|
};
|