~netlandish/links

77136fabae44a62e007f19e79b03de893c1fc463 — Yader Velasquez 9 months ago 4d43559
Highlight org that belongs to an specific domain

References: https://todo.code.netlandish.com/~netlandish/links/48
4 files changed, 32 insertions(+), 5 deletions(-)

M core/routes.go
M static/css/style.css
M templates/inactive_domain.html
M templates/org_list.html
M core/routes.go => core/routes.go +26 -3
@@ 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)

M static/css/style.css => static/css/style.css +4 -0
@@ 494,3 494,7 @@ a.bullet-link:before {
    padding: 0 2px 0 3px;
    opacity: 1 !important;
}

.active-row {
    border: 2px solid var(--color-primary);
}

M templates/inactive_domain.html => templates/inactive_domain.html +1 -1
@@ 4,6 4,6 @@
</section>
<section class="card shadow-card">
  <p class="text-center">{{.pd.Data.msg}}</p>
  <p class="text-center"><a href={{reverse "core:org_list"}}>{{.pd.Data.please_upgrade}}</a></p>
  <p class="text-center"><a href="{{reverse "core:org_list"}}?d={{.domain}}">{{.pd.Data.please_upgrade}}</a></p>
</section>
{{template "base_footer" .}}

M templates/org_list.html => templates/org_list.html +1 -1
@@ 16,7 16,7 @@
        </thead>
        <tbody>
          {{range .orgs}}
              <tr>
             <tr {{if eq .Slug $.dOrgSlug }}class="active-row"{{end}}>
                <td>{{.Name}}</td>
                <td>{{.Slug}}</td>
                <td>