BlueGit

timfa bluegit

fix: zet de clone-knop terug in de werkbalk

De Code-dropdown stond sinds de layoutwijziging alleen in de
paginakop. !24 maakte van het paneel een popover, waardoor de
werkbalk leeg oogde. De knop staat weer rechts naast de branchkiezer
op het overzicht en bij de bestanden. SSH gebruikt public_host en
public_port. Het paneel opent in de top-layer.

Een test eist de knop, beide URLs en de kopieerknoppen in de werkbalk.

Co-authored-by: tim <tim@timfalken.com>

timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa

Authored 2026-10-22 · 3 weeks ago

Hash
f0b666cc8a42bd7a1d0ec17b13e0c465b7261651
Parent
22c95bf5
4 files changed +68 −6
internal/server/server_test.go +46 −0
@@ -83,6 +83,17 @@ func TestWebRepoPushAndSecretBoundary(t *testing.T) {
83 83 if strings.Contains(body, ":2222/") {
84 84 t.Fatalf("clone-URL toont de bindpoort:\n%s", body)
85 85 }
86 sshURL := "ssh://git@git.timfalken.com:22/tim/demo.git"
87 httpURL := "http://127.0.0.1:9/tim/demo.git"
88 assertCloneMenu(t, body, "overzicht", sshURL, httpURL)
89 res, err = client.Get(ts.URL + "/tim/demo/-/tree")
90 if err != nil {
91 t.Fatal(err)
92 }
93 if res.StatusCode != http.StatusOK {
94 t.Fatalf("bestanden %d", res.StatusCode)
95 }
96 assertCloneMenu(t, read(t, res), "bestanden", sshURL, httpURL)
86 97
87 98 res, err = client.PostForm(ts.URL+"/settings/tokens", url.Values{"csrf": {csrfOf(t, body)}, "name": {"test"}})
88 99 if err != nil {
@@ -631,6 +642,41 @@ func csrfOf(t *testing.T, body string) string {
631 642 return rest[:j]
632 643 }
633 644
645 // assertCloneMenu faalt als de Code-dropdown de werkbalk verlaat.
646 // De SSH-URL gebruikt ssh.public_host en ssh.public_port, niet de bindpoort.
647 func assertCloneMenu(t *testing.T, body, where, sshURL, httpURL string) {
648 t.Helper()
649 tool := strings.Index(body, `<div class="toolbar">`)
650 clone := strings.Index(body, `data-clone`)
651 if tool < 0 || clone < tool {
652 t.Fatalf("%s: clone-knop hoort in de werkbalk", where)
653 }
654 end := strings.Index(body[clone:], `</details>`)
655 if end < 0 {
656 t.Fatalf("%s: clone-menu niet gesloten", where)
657 }
658 menu := body[clone : clone+end]
659 for _, want := range []string{
660 `popover="manual"`,
661 `class="menu-panel"`,
662 `>Code</summary>`,
663 `value="` + sshURL + `"`,
664 `data-copy="` + sshURL + `"`,
665 `value="` + httpURL + `"`,
666 `data-copy="` + httpURL + `"`,
667 } {
668 if !strings.Contains(menu, want) {
669 t.Fatalf("%s: clone-menu mist %q:\n%s", where, want, menu)
670 }
671 }
672 if strings.Count(menu, `data-copy="`) != 2 {
673 t.Fatalf("%s: clone-menu hoort twee kopieerknoppen te hebben:\n%s", where, menu)
674 }
675 if strings.Contains(menu, ":2222/") {
676 t.Fatalf("%s: clone-menu toont de bindpoort:\n%s", where, menu)
677 }
678 }
679
634 680 func between(s, a, b string) string {
635 681 i := strings.Index(s, a)
636 682 if i < 0 {
@@ -83,6 +83,17 @@ func TestWebRepoPushAndSecretBoundary(t *testing.T) {
83 if strings.Contains(body, ":2222/") {
83 if strings.Contains(body, ":2222/") {
84 t.Fatalf("clone-URL toont de bindpoort:\n%s", body)
84 t.Fatalf("clone-URL toont de bindpoort:\n%s", body)
85 }
85 }
86 sshURL := "ssh://git@git.timfalken.com:22/tim/demo.git"
87 httpURL := "http://127.0.0.1:9/tim/demo.git"
88 assertCloneMenu(t, body, "overzicht", sshURL, httpURL)
89 res, err = client.Get(ts.URL + "/tim/demo/-/tree")
90 if err != nil {
91 t.Fatal(err)
92 }
93 if res.StatusCode != http.StatusOK {
94 t.Fatalf("bestanden %d", res.StatusCode)
95 }
96 assertCloneMenu(t, read(t, res), "bestanden", sshURL, httpURL)
86
97
87 res, err = client.PostForm(ts.URL+"/settings/tokens", url.Values{"csrf": {csrfOf(t, body)}, "name": {"test"}})
98 res, err = client.PostForm(ts.URL+"/settings/tokens", url.Values{"csrf": {csrfOf(t, body)}, "name": {"test"}})
88 if err != nil {
99 if err != nil {
@@ -631,6 +642,41 @@ func csrfOf(t *testing.T, body string) string {
631 return rest[:j]
642 return rest[:j]
632}
643}
633
644
645// assertCloneMenu faalt als de Code-dropdown de werkbalk verlaat.
646// De SSH-URL gebruikt ssh.public_host en ssh.public_port, niet de bindpoort.
647func assertCloneMenu(t *testing.T, body, where, sshURL, httpURL string) {
648 t.Helper()
649 tool := strings.Index(body, `<div class="toolbar">`)
650 clone := strings.Index(body, `data-clone`)
651 if tool < 0 || clone < tool {
652 t.Fatalf("%s: clone-knop hoort in de werkbalk", where)
653 }
654 end := strings.Index(body[clone:], `</details>`)
655 if end < 0 {
656 t.Fatalf("%s: clone-menu niet gesloten", where)
657 }
658 menu := body[clone : clone+end]
659 for _, want := range []string{
660 `popover="manual"`,
661 `class="menu-panel"`,
662 `>Code</summary>`,
663 `value="` + sshURL + `"`,
664 `data-copy="` + sshURL + `"`,
665 `value="` + httpURL + `"`,
666 `data-copy="` + httpURL + `"`,
667 } {
668 if !strings.Contains(menu, want) {
669 t.Fatalf("%s: clone-menu mist %q:\n%s", where, want, menu)
670 }
671 }
672 if strings.Count(menu, `data-copy="`) != 2 {
673 t.Fatalf("%s: clone-menu hoort twee kopieerknoppen te hebben:\n%s", where, menu)
674 }
675 if strings.Contains(menu, ":2222/") {
676 t.Fatalf("%s: clone-menu toont de bindpoort:\n%s", where, menu)
677 }
678}
679
634func between(s, a, b string) string {
680func between(s, a, b string) string {
635 i := strings.Index(s, a)
681 i := strings.Index(s, a)
636 if i < 0 {
682 if i < 0 {
internal/server/static/float.js +6 −0
@@ -248,6 +248,12 @@
248 248 det.addEventListener("toggle", function () {
249 249 var summary = det.querySelector("summary");
250 250 if (det.open && summary) {
251 // A popover nested in <details> stays display:none in the top layer
252 // until it leaves the details element. Park the panel on body first.
253 if (panel.classList.contains("menu-panel") && panel.parentNode !== document.body) {
254 panel._home = panel.parentNode;
255 document.body.appendChild(panel);
256 }
251 257 openLayer(panel);
252 258 track(panel, summary, "below-end");
253 259 } else {
@@ -248,6 +248,12 @@
248 det.addEventListener("toggle", function () {
248 det.addEventListener("toggle", function () {
249 var summary = det.querySelector("summary");
249 var summary = det.querySelector("summary");
250 if (det.open && summary) {
250 if (det.open && summary) {
251 // A popover nested in <details> stays display:none in the top layer
252 // until it leaves the details element. Park the panel on body first.
253 if (panel.classList.contains("menu-panel") && panel.parentNode !== document.body) {
254 panel._home = panel.parentNode;
255 document.body.appendChild(panel);
256 }
251 openLayer(panel);
257 openLayer(panel);
252 track(panel, summary, "below-end");
258 track(panel, summary, "below-end");
253 } else {
259 } else {
internal/server/static/style.css +11 −2
@@ -181,6 +181,12 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
181 181 .menu { position: relative; }
182 182 .menu summary { list-style: none; cursor: pointer; }
183 183 .menu summary::-webkit-details-marker { display: none; }
184 .menu > summary::after {
185 content: "";
186 width: 0.4rem; height: 0.4rem; margin-left: 0.2rem;
187 border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
188 transform: translateY(-2px) rotate(45deg);
189 }
184 190 .menu-panel {
185 191 position: absolute; right: 0; top: 2.3rem; z-index: 4; width: min(420px, 80vw);
186 192 background: white; border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem;
@@ -197,9 +203,12 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
197 203 max-width: min(420px, calc(100vw - 16px));
198 204 height: auto;
199 205 }
200 .menu-panel[popover]:popover-open { width: min(420px, calc(100vw - 16px)); }
206 .menu-panel[popover]:popover-open {
207 width: min(32rem, calc(100vw - 16px));
208 max-width: min(32rem, calc(100vw - 16px));
209 }
201 210 .copyline { display: flex; gap: 0.4rem; }
202 .copyline input { font-family: ui-monospace, monospace; font-size: 0.85rem; }
211 .copyline input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 0.85rem; }
203 212 .commitbar {
204 213 display: flex; gap: 0.7rem; align-items: center; background: #f6f8fa;
205 214 border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.75rem; margin: 0.4rem 0 0.8rem;
@@ -181,6 +181,12 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
181.menu { position: relative; }
181.menu { position: relative; }
182.menu summary { list-style: none; cursor: pointer; }
182.menu summary { list-style: none; cursor: pointer; }
183.menu summary::-webkit-details-marker { display: none; }
183.menu summary::-webkit-details-marker { display: none; }
184.menu > summary::after {
185 content: "";
186 width: 0.4rem; height: 0.4rem; margin-left: 0.2rem;
187 border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
188 transform: translateY(-2px) rotate(45deg);
189}
184.menu-panel {
190.menu-panel {
185 position: absolute; right: 0; top: 2.3rem; z-index: 4; width: min(420px, 80vw);
191 position: absolute; right: 0; top: 2.3rem; z-index: 4; width: min(420px, 80vw);
186 background: white; border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem;
192 background: white; border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem;
@@ -197,9 +203,12 @@ td, th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px
197 max-width: min(420px, calc(100vw - 16px));
203 max-width: min(420px, calc(100vw - 16px));
198 height: auto;
204 height: auto;
199}
205}
200.menu-panel[popover]:popover-open { width: min(420px, calc(100vw - 16px)); }
206.menu-panel[popover]:popover-open {
207 width: min(32rem, calc(100vw - 16px));
208 max-width: min(32rem, calc(100vw - 16px));
209}
201.copyline { display: flex; gap: 0.4rem; }
210.copyline { display: flex; gap: 0.4rem; }
202.copyline input { font-family: ui-monospace, monospace; font-size: 0.85rem; }
211.copyline input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 0.85rem; }
203.commitbar {
212.commitbar {
204 display: flex; gap: 0.7rem; align-items: center; background: #f6f8fa;
213 display: flex; gap: 0.7rem; align-items: center; background: #f6f8fa;
205 border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.75rem; margin: 0.4rem 0 0.8rem;
214 border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.75rem; margin: 0.4rem 0 0.8rem;
internal/server/templates/pages.html +5 −4
@@ -260,9 +260,9 @@
260 260 {{end}}
261 261
262 262 {{define "codemenu"}}
263 <details class="menu">
264 <summary class="btn ghost">{{t "repo.code"}}</summary>
265 <div class="menu-panel">
263 <details class="menu" data-clone>
264 <summary class="btn">{{t "repo.code"}}</summary>
265 <div class="menu-panel" popover="manual">
266 266 {{if .CloneSSH}}
267 267 <p class="muted">{{t "repo.ssh"}}</p>
268 268 <div class="copyline"><input readonly value="{{.CloneSSH}}"><button type="button" data-copy="{{.CloneSSH}}">{{t "action.copy"}}</button></div>
@@ -299,7 +299,6 @@
299 299 <h1>{{t "tab.overview"}}</h1>
300 300 <div class="pageacts">
301 301 <a class="btn ghost" href="/{{.Repo.FullPath}}/-/tree?rev={{.Rev}}&amp;focus=1">{{t "repo.searchFile"}}</a>
302 {{template "codemenu" .}}
303 302 </div>
304 303 </header>
305 304 {{if .Heat}}{{template "heatmap" .Heat}}{{end}}
@@ -307,6 +306,7 @@
307 306 <div>
308 307 <div class="toolbar">
309 308 <div class="left">{{template "branchpick" .}} <span class="pathnow">{{.Repo.Name}}</span></div>
309 <div class="right">{{template "codemenu" .}}</div>
310 310 </div>
311 311 {{template "commitbar" .}}
312 312 {{template "filetable" .}}
@@ -361,6 +361,7 @@
361 361 </span>
362 362 {{if or .BlobPath .TreePath}}<button type="button" class="iconbtn" data-copy="{{if .BlobPath}}{{.BlobPath}}{{else}}{{.TreePath}}{{end}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button>{{end}}
363 363 </div>
364 <div class="right">{{template "codemenu" .}}</div>
364 365 </div>
365 366 {{if .BlobPath}}
366 367 <h2 class="filename">{{template "ficon" (iconOf .FileName)}} {{.FileName}}</h2>
@@ -260,9 +260,9 @@
260{{end}}
260{{end}}
261
261
262{{define "codemenu"}}
262{{define "codemenu"}}
263<details class="menu">
263<details class="menu" data-clone>
264 <summary class="btn ghost">{{t "repo.code"}}</summary>
264 <summary class="btn">{{t "repo.code"}}</summary>
265 <div class="menu-panel">
265 <div class="menu-panel" popover="manual">
266 {{if .CloneSSH}}
266 {{if .CloneSSH}}
267 <p class="muted">{{t "repo.ssh"}}</p>
267 <p class="muted">{{t "repo.ssh"}}</p>
268 <div class="copyline"><input readonly value="{{.CloneSSH}}"><button type="button" data-copy="{{.CloneSSH}}">{{t "action.copy"}}</button></div>
268 <div class="copyline"><input readonly value="{{.CloneSSH}}"><button type="button" data-copy="{{.CloneSSH}}">{{t "action.copy"}}</button></div>
@@ -299,7 +299,6 @@
299 <h1>{{t "tab.overview"}}</h1>
299 <h1>{{t "tab.overview"}}</h1>
300 <div class="pageacts">
300 <div class="pageacts">
301 <a class="btn ghost" href="/{{.Repo.FullPath}}/-/tree?rev={{.Rev}}&amp;focus=1">{{t "repo.searchFile"}}</a>
301 <a class="btn ghost" href="/{{.Repo.FullPath}}/-/tree?rev={{.Rev}}&amp;focus=1">{{t "repo.searchFile"}}</a>
302 {{template "codemenu" .}}
303 </div>
302 </div>
304</header>
303</header>
305{{if .Heat}}{{template "heatmap" .Heat}}{{end}}
304{{if .Heat}}{{template "heatmap" .Heat}}{{end}}
@@ -307,6 +306,7 @@
307 <div>
306 <div>
308 <div class="toolbar">
307 <div class="toolbar">
309 <div class="left">{{template "branchpick" .}} <span class="pathnow">{{.Repo.Name}}</span></div>
308 <div class="left">{{template "branchpick" .}} <span class="pathnow">{{.Repo.Name}}</span></div>
309 <div class="right">{{template "codemenu" .}}</div>
310 </div>
310 </div>
311 {{template "commitbar" .}}
311 {{template "commitbar" .}}
312 {{template "filetable" .}}
312 {{template "filetable" .}}
@@ -361,6 +361,7 @@
361 </span>
361 </span>
362 {{if or .BlobPath .TreePath}}<button type="button" class="iconbtn" data-copy="{{if .BlobPath}}{{.BlobPath}}{{else}}{{.TreePath}}{{end}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button>{{end}}
362 {{if or .BlobPath .TreePath}}<button type="button" class="iconbtn" data-copy="{{if .BlobPath}}{{.BlobPath}}{{else}}{{.TreePath}}{{end}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button>{{end}}
363 </div>
363 </div>
364 <div class="right">{{template "codemenu" .}}</div>
364 </div>
365 </div>
365 {{if .BlobPath}}
366 {{if .BlobPath}}
366 <h2 class="filename">{{template "ficon" (iconOf .FileName)}} {{.FileName}}</h2>
367 <h2 class="filename">{{template "ficon" (iconOf .FileName)}} {{.FileName}}</h2>