Skip to content

Commit

Permalink
client: Use the app build version as Version in UI in hamburger menu.
Browse files Browse the repository at this point in the history
	- This is a rework of decred#3096 and keeps the Build ID in the
	  settings dialog.

	- Webpack Build ID for caching site/dist build will be
	  addressed in another PR if required.
  • Loading branch information
dev-warrior777 committed Dec 14, 2024
1 parent 0030e49 commit a939101
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 6 deletions.
4 changes: 3 additions & 1 deletion client/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ type Config struct {
// Web creates a configuration for the webserver. This is a Config method
// instead of a WebConfig method because Language is an app-level setting used
// by both core and rpcserver.
func (cfg *Config) Web(c *core.Core, mm *mm.MarketMaker, log dex.Logger, utc bool) *webserver.Config {
func (cfg *Config) Web(c *core.Core, mm *mm.MarketMaker, log dex.Logger, utc bool, appVersion string) *webserver.Config {
addr := cfg.WebAddr
host, _, err := net.SplitHostPort(addr)
if err == nil && host != "" {
Expand Down Expand Up @@ -196,6 +196,7 @@ func (cfg *Config) Web(c *core.Core, mm *mm.MarketMaker, log dex.Logger, utc boo
NoEmbed: cfg.NoEmbedSite,
HttpProf: cfg.HTTPProfile,
Language: cfg.Language,
AppVersion: appVersion,
}
}

Expand Down Expand Up @@ -348,6 +349,7 @@ func ResolveConfig(appData string, cfg *Config) error {
if cfg.MMConfig.EventLogDBPath == "" {
cfg.MMConfig.EventLogDBPath = defaultMMEventLogDBPath
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion client/cmd/bisonw-desktop/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func mainCore() error {
}()
}

webSrv, err := webserver.New(cfg.Web(clientCore, marketMaker, logMaker.Logger("WEB"), utc))
webSrv, err := webserver.New(cfg.Web(clientCore, marketMaker, logMaker.Logger("WEB"), utc, app.Version))
if err != nil {
return fmt.Errorf("failed creating web server: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion client/cmd/bisonw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func runCore(cfg *app.Config) error {
}

if !cfg.NoWeb {
webSrv, err := webserver.New(cfg.Web(clientCore, marketMaker, logMaker.Logger("WEB"), utc))
webSrv, err := webserver.New(cfg.Web(clientCore, marketMaker, logMaker.Logger("WEB"), utc, app.Version))
if err != nil {
return fmt.Errorf("failed creating web server: %w", err)
}
Expand Down
4 changes: 4 additions & 0 deletions client/webserver/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type CommonArguments struct {
UserInfo *userInfo
Title string
UseDEXBranding bool
Version string
}

// Create the CommonArguments for the request.
Expand All @@ -66,6 +67,7 @@ func (s *WebServer) commonArgs(r *http.Request, title string) *CommonArguments {
UserInfo: extractUserInfo(r),
Title: title,
UseDEXBranding: s.useDEXBranding,
Version: s.appVersion,
}
}

Expand Down Expand Up @@ -260,13 +262,15 @@ func (s *WebServer) handleSettings(w http.ResponseWriter, r *http.Request) {
FiatCurrency string
Exchanges map[string]*core.Exchange
IsInitialized bool
AppVersion string
}{
CommonArguments: *common,
KnownExchanges: s.knownUnregisteredExchanges(xcs),
FiatCurrency: core.DefaultFiatCurrency,
FiatRateSources: s.core.FiatRateSources(),
Exchanges: xcs,
IsInitialized: s.core.IsInitialized(),
AppVersion: s.appVersion,
}
s.sendTemplate(w, "settings", data)
}
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/ar.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ var Ar = map[string]*intl.Translation{
"Export Account": {T: "تصدير الحساب"},
"simultaneous_servers_msg": {T: "يدعم عميل منصة المبادلات اللامركزية لديكريد الاستخدام المتزامن لأي عدد من خوادم منصة المبادلات اللامركزية DEX."},
"Change App Password": {T: "تغيير كلمة مرور التطبيق"},
"Version": {T: "إصدار"},
"Build ID": {T: "معرف البنية"},
"Connect": {T: "اتصل"},
"Send": {T: "ارسال"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/de-de.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ var DeDE = map[string]*intl.Translation{
"Export Account": {T: "Account exportieren"},
"simultaneous_servers_msg": {T: "Der <span class=brand></span> unterstützt die gleichzeitige Nutzung einer beliebigen Anzahl von DEX-Servern."},
"Change App Password": {T: "App-Passwort ändern"},
"Version": {T: "Version"},
"Build ID": {T: "Build ID"},
"Connect": {T: "Verbinden"},
"Send": {T: "Senden"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/en-us.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ var EnUS = map[string]*intl.Translation{
"browser_ntfn_blocked": {T: "Browser notifications are currently blocked. Please unblock this site in your browser to receive notifications."},
"enable_browser_ntfn_info": {T: "Desktop notifications appear even when this window is not active. When you have other applications open this can be helpful as you will be notified on DCRDEX events. Customize below the types of notifications you would like to receive."},
"Save Notifications": {T: "Save Notifications"},
"Version": {T: "Version"},
"Build ID": {T: "Build ID"},
"Connect": {T: "Connect"},
"Send": {T: "Send"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/pl-pl.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ var PlPL = map[string]*intl.Translation{
"Export Account": {T: "Eksportuj konto"},
"simultaneous_servers_msg": {T: "Klient Decred DEX wspiera jednoczesne korzystanie z wielu serwerów DEX."},
"Change App Password": {T: "Zmień hasło aplikacji"},
"Version": {T: "Wersja"},
"Build ID": {T: "ID builda"},
"Connect": {T: "Połącz"},
"Withdraw": {T: "Wypłać"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/pt-br.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ var PtBr = map[string]*intl.Translation{
"Export Account": {T: "Exportar Conta"},
"simultaneous_servers_msg": {T: "O cliente da DEX suporta simultâneos números de servidores DEX."},
"Change App Password": {T: "Trocar Senha do aplicativo"},
"Version": {T: "Versão"},
"Build ID": {T: "ID da Build"},
"Connect": {T: "Conectar"},
"Withdraw": {T: "Retirar"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/zh-cn.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ var ZhCN = map[string]*intl.Translation{
"Export Account": {T: "退出账户"},
"simultaneous_servers_msg": {T: "Decred DEX 客户端支持同时使用任意数量的 DEX 服务器。"},
"Change App Password": {T: "更改应用程序密码"},
"Version": {T: "版本"},
"Build ID": {T: "构建 ID"},
"Connect": {T: "连接"},
"Send": {T: "发送"},
Expand Down
8 changes: 7 additions & 1 deletion client/webserver/site/src/html/bodybuilder.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<span class="ico-barchart fs16 me-2"></span>
[[[Market Making]]]
</a>
<a href="/settings" class="demi hoverbright plainlink d-flex align-items-center py-1">
<a href="/settings" class="demi hoverbright plainlink d-flex align-items-center py-1 authed-only">
<span class="ico-settings fs16 me-2"></span>
[[[Settings]]]
</a>
Expand All @@ -118,6 +118,12 @@
<span class="ico-profile fs16 me-2"></span>
[[[Sign Out]]]
</div>
<div class="demi d-flex align-items-center py-1" id="version">
<br>
<div class="flex-center">
[[[Version]]] {{.Version}}
</div>
</div>
</div>

</header>
Expand Down
7 changes: 5 additions & 2 deletions client/webserver/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ type Config struct {
// should be used by default since site files from older distributions may
// be present on the disk. When NoEmbed is true, this also implies reloading
// and execution of html templates on each request.
NoEmbed bool
HttpProf bool
NoEmbed bool
HttpProf bool
AppVersion string
}

type valStamp struct {
Expand Down Expand Up @@ -271,6 +272,7 @@ type WebServer struct {
bondBuf map[uint32]valStamp

useDEXBranding bool
appVersion string
}

// New is the constructor for a new WebServer. CustomSiteDir in the Config can
Expand Down Expand Up @@ -392,6 +394,7 @@ func New(cfg *Config) (*WebServer, error) {
cachedPasswords: make(map[string]*cachedPassword),
bondBuf: map[uint32]valStamp{},
useDEXBranding: useDEXBranding,
appVersion: cfg.AppVersion,
}
s.lang.Store(lang)

Expand Down

0 comments on commit a939101

Please sign in to comment.