From bb9bd2ac32e8c51d8d10762828e7060c2da65dbc Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Tue, 13 Feb 2024 17:42:57 -0600 Subject: [PATCH] Hiding navigation when browsing user domain --- core/templates.go | 9 ++++++++- templates/base.html | 2 +- templates/link_list.html | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/templates.go b/core/templates.go index a5150c2..bb2bd5b 100644 --- a/core/templates.go +++ b/core/templates.go @@ -2,6 +2,7 @@ package core import ( "links" + "links/domain" "links/internal/localizer" "links/models" "log" @@ -48,10 +49,16 @@ func AddGlobalTmpl(c echo.Context) gobwebs.Map { gmap["serverVersion"] = serverVersion[len(serverVersion)-1] // Show left setting menu for oauth links - if strings.Contains(c.Path(), "oauth2/") { + if strings.Contains(c.Path(), "/oauth2/") { gmap["settingSection"] = true } + dom := domain.ForContext(c.Request().Context()) + if dom.Level == models.DomainLevelUser && dom.OrgID.Valid { + gmap["isUserDomain"] = true + gmap["hideNav"] = true + } + if gctx.User != nil && gctx.User.IsAuthenticated() { gmap["isAuthorized"] = true user := gctx.User.(*models.User) diff --git a/templates/base.html b/templates/base.html index d18fd5a..b54bf0c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -217,7 +217,7 @@ {{if .useTagAutocomplete}} {{end}} - {{if .advancedSearch}} + {{if and (not .hideNav) (.advancedSearch)}} {{end}} diff --git a/templates/link_list.html b/templates/link_list.html index 1667864..2a266e8 100644 --- a/templates/link_list.html +++ b/templates/link_list.html @@ -1,6 +1,6 @@ {{template "base" .}}
- {{if .advancedSearch}} + {{if and (not .hideNav) (.advancedSearch)}}
@@ -41,7 +41,7 @@ {{end}}
- {{if .isOrgLink}} + {{if and (not .hideNav) .isOrgLink}}

{{.pd.Data.all}} {{.pd.Data.unread}} -- 2.45.2