Deduplicate organization nav
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
fc6f281a28b6c3c63517989ca7fb6ac8eb142430- Parents
-
bfbafa1 - Tree
c242ecc
fc6f281
fc6f281a28b6c3c63517989ca7fb6ac8eb142430bfbafa1
c242ecc| Status | File | + | - |
|---|---|---|---|
| M |
internal/web/embed_test.go
|
40 | 0 |
| M |
internal/web/templates/orgs/repositories.html
|
0 | 1 |
| M |
internal/web/templates/orgs/settings_profile.html
|
0 | 11 |
internal/web/embed_test.gomodified@@ -80,6 +80,46 @@ func TestProductionTemplatesPartialsTolerateEmptyData(t *testing.T) { | ||
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | +func TestOrgPagesRenderSingleSharedOrgNav(t *testing.T) { | |
| 84 | + t.Parallel() | |
| 85 | + r, err := render.New(TemplatesFS(), render.Options{}) | |
| 86 | + if err != nil { | |
| 87 | + t.Fatalf("render.New: %v", err) | |
| 88 | + } | |
| 89 | + data := map[string]any{ | |
| 90 | + "Title": "Organization", | |
| 91 | + "Org": map[string]any{"Slug": "gardesk", "DisplayName": "gardesk"}, | |
| 92 | + "AvatarURL": "/avatars/gardesk", | |
| 93 | + "ActiveOrgNav": "repositories", | |
| 94 | + "RepoCount": 5, | |
| 95 | + "FilteredCount": 5, | |
| 96 | + "PageCount": 1, | |
| 97 | + "MemberCount": 1, | |
| 98 | + "IsOwner": true, | |
| 99 | + "Form": map[string]any{ | |
| 100 | + "DisplayName": "gardesk", | |
| 101 | + "Description": "", | |
| 102 | + "Website": "", | |
| 103 | + "Location": "", | |
| 104 | + "BillingEmail": "", | |
| 105 | + "AllowMemberRepoCreate": true, | |
| 106 | + }, | |
| 107 | + } | |
| 108 | + req := httptest.NewRequest("GET", "/", nil) | |
| 109 | + for _, page := range []string{"orgs/repositories", "orgs/settings_profile"} { | |
| 110 | + t.Run(page, func(t *testing.T) { | |
| 111 | + t.Parallel() | |
| 112 | + rw := httptest.NewRecorder() | |
| 113 | + if err := r.RenderPage(rw, req, page, data); err != nil { | |
| 114 | + t.Fatalf("RenderPage: %v", err) | |
| 115 | + } | |
| 116 | + if got := strings.Count(rw.Body.String(), `<nav class="shithub-org-nav"`); got != 1 { | |
| 117 | + t.Fatalf("org nav count = %d, want 1", got) | |
| 118 | + } | |
| 119 | + }) | |
| 120 | + } | |
| 121 | +} | |
| 122 | + | |
| 83 | 123 | // errorOriginatesInPartial returns true when an html/template execute |
| 84 | 124 | // error blames a file whose basename starts with `_`. Errors from such |
| 85 | 125 | // files are bugs in the partial because we render with an empty map |
internal/web/templates/orgs/repositories.htmlmodified@@ -7,7 +7,6 @@ | ||
| 7 | 7 | <span>{{ if .Org.DisplayName }}{{ .Org.DisplayName }}{{ else }}{{ .Org.Slug }}{{ end }}</span> |
| 8 | 8 | </a> |
| 9 | 9 | </div> |
| 10 | - {{ template "org-subnav" . }} | |
| 11 | 10 | </header> |
| 12 | 11 | |
| 13 | 12 | <main class="shithub-org-repositories-shell"> |
internal/web/templates/orgs/settings_profile.htmlmodified@@ -7,17 +7,6 @@ | ||
| 7 | 7 | <span>{{ if .Org.DisplayName }}{{ .Org.DisplayName }}{{ else }}{{ .Org.Slug }}{{ end }}</span> |
| 8 | 8 | </a> |
| 9 | 9 | </div> |
| 10 | - <nav class="shithub-org-nav" aria-label="Organization"> | |
| 11 | - <a href="/{{ .Org.Slug }}" class="shithub-org-nav-item">{{ octicon "home" }} Overview</a> | |
| 12 | - <a href="/orgs/{{ .Org.Slug }}/repositories" class="shithub-org-nav-item">{{ octicon "repo" }} Repositories</a> | |
| 13 | - <span class="shithub-org-nav-item is-disabled" aria-disabled="true">{{ octicon "table" }} Projects</span> | |
| 14 | - <span class="shithub-org-nav-item is-disabled" aria-disabled="true">{{ octicon "package" }} Packages</span> | |
| 15 | - <a href="/{{ .Org.Slug }}/teams" class="shithub-org-nav-item">{{ octicon "people" }} Teams</a> | |
| 16 | - <a href="/{{ .Org.Slug }}/people" class="shithub-org-nav-item">{{ octicon "person" }} People</a> | |
| 17 | - <span class="shithub-org-nav-item is-disabled" aria-disabled="true">{{ octicon "shield-check" }} Security and quality</span> | |
| 18 | - <span class="shithub-org-nav-item is-disabled" aria-disabled="true">{{ octicon "pulse" }} Insights</span> | |
| 19 | - <a href="/organizations/{{ .Org.Slug }}/settings/profile" class="shithub-org-nav-item is-active" aria-current="page">{{ octicon "gear" }} Settings</a> | |
| 20 | - </nav> | |
| 21 | 10 | </header> |
| 22 | 11 | |
| 23 | 12 | <div class="shithub-org-settings-layout"> |