mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-20 12:29:09 +02:00
[management,client] 0.75.0 release with new desktop UI (#6473)
- **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>
This commit is contained in:
co-authored by
Zoltan Papp
Eduard Gert
braginini
Pascal Fischer
riccardom
parent
c9d387bd0d
commit
91acb8147c
@@ -0,0 +1,130 @@
|
||||
//go:build !android && !ios && !freebsd && !js
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/netbirdio/netbird/client/ui/i18n"
|
||||
"github.com/netbirdio/netbird/client/ui/preferences"
|
||||
"github.com/netbirdio/netbird/client/ui/services"
|
||||
)
|
||||
|
||||
// Localizer caches the active language so key lookups skip the preferences store.
|
||||
//
|
||||
// Kept in the main package (not i18n/) because StatusLabel maps daemon
|
||||
// status enum strings to translations; moving it would invert the
|
||||
// dependency direction.
|
||||
type Localizer struct {
|
||||
bundle *i18n.Bundle
|
||||
store *preferences.Store
|
||||
|
||||
mu sync.RWMutex
|
||||
lang i18n.LanguageCode
|
||||
|
||||
unsubscribe func()
|
||||
}
|
||||
|
||||
// NewLocalizer seeds the active language from the on-disk preference. Either
|
||||
// argument may be nil (tests): T then returns the raw key and Watch is a no-op.
|
||||
func NewLocalizer(bundle *i18n.Bundle, store *preferences.Store) *Localizer {
|
||||
l := &Localizer{
|
||||
bundle: bundle,
|
||||
store: store,
|
||||
lang: i18n.DefaultLanguage,
|
||||
}
|
||||
if store != nil {
|
||||
if p := store.Get(); p.Language != "" {
|
||||
l.lang = p.Language
|
||||
}
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
// Language returns the active language code.
|
||||
func (l *Localizer) Language() i18n.LanguageCode {
|
||||
l.mu.RLock()
|
||||
defer l.mu.RUnlock()
|
||||
return l.lang
|
||||
}
|
||||
|
||||
// T resolves key in the current language; args are {placeholder}/value pairs.
|
||||
// With no bundle wired it returns key unchanged.
|
||||
func (l *Localizer) T(key string, args ...string) string {
|
||||
if l == nil || l.bundle == nil {
|
||||
return key
|
||||
}
|
||||
l.mu.RLock()
|
||||
lang := l.lang
|
||||
l.mu.RUnlock()
|
||||
return l.bundle.Translate(lang, key, args...)
|
||||
}
|
||||
|
||||
// Watch invokes cb on each language change, after the cached language is
|
||||
// updated so cb may call l.T with the new locale. Replaces any prior subscription.
|
||||
func (l *Localizer) Watch(cb func(lang i18n.LanguageCode)) {
|
||||
if l.store == nil {
|
||||
return
|
||||
}
|
||||
ch, unsubscribe := l.store.Subscribe()
|
||||
l.mu.Lock()
|
||||
if l.unsubscribe != nil {
|
||||
l.unsubscribe()
|
||||
}
|
||||
l.unsubscribe = unsubscribe
|
||||
l.mu.Unlock()
|
||||
|
||||
go func() {
|
||||
for p := range ch {
|
||||
if p.Language == "" {
|
||||
continue
|
||||
}
|
||||
l.mu.Lock()
|
||||
if l.lang == p.Language {
|
||||
l.mu.Unlock()
|
||||
continue
|
||||
}
|
||||
l.lang = p.Language
|
||||
l.mu.Unlock()
|
||||
log.Infof("localizer: language switched to %s", p.Language)
|
||||
if cb != nil {
|
||||
cb(p.Language)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Close cancels the preference subscription.
|
||||
func (l *Localizer) Close() {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
if l.unsubscribe != nil {
|
||||
l.unsubscribe()
|
||||
l.unsubscribe = nil
|
||||
}
|
||||
}
|
||||
|
||||
// StatusLabel maps a daemon status string to its tray label; unrecognised
|
||||
// statuses pass through verbatim.
|
||||
func (l *Localizer) StatusLabel(status string) string {
|
||||
switch {
|
||||
case status == "", strings.EqualFold(status, services.StatusIdle):
|
||||
return l.T("tray.status.disconnected")
|
||||
case strings.EqualFold(status, services.StatusDaemonUnavailable):
|
||||
return l.T("tray.status.daemonUnavailable")
|
||||
case strings.EqualFold(status, services.StatusConnected):
|
||||
return l.T("tray.status.connected")
|
||||
case strings.EqualFold(status, services.StatusConnecting):
|
||||
return l.T("tray.status.connecting")
|
||||
case strings.EqualFold(status, services.StatusNeedsLogin):
|
||||
return l.T("tray.status.needsLogin")
|
||||
case strings.EqualFold(status, services.StatusLoginFailed):
|
||||
return l.T("tray.status.loginFailed")
|
||||
case strings.EqualFold(status, services.StatusSessionExpired):
|
||||
return l.T("tray.status.sessionExpired")
|
||||
}
|
||||
return status
|
||||
}
|
||||
Reference in New Issue
Block a user