From 77136fabae44a62e007f19e79b03de893c1fc463 Mon Sep 17 00:00:00 2001 From: Yader Velasquez Date: Thu, 15 Feb 2024 16:31:55 -0600 Subject: [PATCH] Highlight org that belongs to an specific domain References: https://todo.code.netlandish.com/~netlandish/links/48 --- core/routes.go | 29 ++++++++++++++++++++++++++--- static/css/style.css | 4 ++++ templates/inactive_domain.html | 2 +- templates/org_list.html | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/core/routes.go b/core/routes.go index d2e5f5d..df75ba6 100644 --- a/core/routes.go +++ b/core/routes.go @@ -100,7 +100,8 @@ func (s *Service) InvalidDomain(c echo.Context) error { gctx := c.(*server.Context) lt := localizer.GetSessionLocalizer(c) pd := localizer.NewPageData(lt.Translate("Invalid Domain")) - gmap := gobwebs.Map{"pd": pd} + pd.Data["msg"] = lt.Translate("The %s domain is currently inactive", d) + pd.Data["please_upgrade"] = lt.Translate("Please upgrade your account to reactivate it") opts := &database.FilterOptions{ Filter: sq.And{ @@ -117,8 +118,7 @@ func (s *Service) InvalidDomain(c echo.Context) error { // NOTE Should not happens, but just in case return echo.NotFoundHandler(c) } - pd.Data["msg"] = lt.Translate("The %s domain is currently inactive", d) - pd.Data["please_upgrade"] = lt.Translate("Please upgrade your account to reactivate it") + gmap := gobwebs.Map{"pd": pd, "domain": d} return gctx.Render(http.StatusOK, "inactive_domain.html", gmap) } @@ -501,11 +501,34 @@ func (s *Service) OrgList(c echo.Context) error { pd.Data["import"] = lt.Translate("Import") pd.Data["integrations"] = lt.Translate("Integrations") pd.Data["payment_history"] = lt.Translate("Payment History") + + // If we want to highlight an org based on a given domain + var dOrgSlug string + if c.QueryParam("d") != "" { + opts := &database.FilterOptions{ + Filter: sq.And{ + sq.Eq{"o.owner_id": gctx.User.GetID()}, + sq.Eq{"d.lookup_name": c.QueryParam("d")}, + }, + Limit: 1, + } + domains, err := models.GetDomains(c.Request().Context(), opts) + if err != nil { + return err + } + + if len(domains) == 1 { + if domains[0].OrgSlug.Valid { + dOrgSlug = domains[0].OrgSlug.String + } + } + } gmap := gobwebs.Map{ "pd": pd, "settingSection": true, "navFlag": "settings", "navSubFlag": "orgAdd", + "dOrgSlug": dOrgSlug, "orgs": result.Orgs, } return gctx.Render(http.StatusOK, "org_list.html", gmap) diff --git a/static/css/style.css b/static/css/style.css index 389d633..e5ef8b1 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -494,3 +494,7 @@ a.bullet-link:before { padding: 0 2px 0 3px; opacity: 1 !important; } + +.active-row { + border: 2px solid var(--color-primary); +} diff --git a/templates/inactive_domain.html b/templates/inactive_domain.html index 0b018b8..250bea7 100644 --- a/templates/inactive_domain.html +++ b/templates/inactive_domain.html @@ -4,6 +4,6 @@

{{.pd.Data.msg}}

-

{{.pd.Data.please_upgrade}}

+

{{.pd.Data.please_upgrade}}

{{template "base_footer" .}} diff --git a/templates/org_list.html b/templates/org_list.html index 884f38b..947556b 100644 --- a/templates/org_list.html +++ b/templates/org_list.html @@ -16,7 +16,7 @@ {{range .orgs}} - + {{.Name}} {{.Slug}} -- 2.45.2