chrome: the switcher shows the suite's six apps, not "All apps" alone
Paul: "Can the 'All apps' dropdown just be a list of apps rather than a dropdown with a single-item list?" The switcher now passes estilo's chrome.SuiteApps(directory, "docs"): Docs, Sheets, Slides, Calendar, Memoria and Calls as tiles at <slug>.<directory host>, Docs marked current, and "All apps" below the divider. It still appears only when a hub directory is configured. estilo is pinned to its feat/switcher-tiles branch commit (0e40034) until that merges; re-pin to the main commit then.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+44
−14
go.mod+1 −1go.sum+2 −2internal/docs/chrome.go+4 −4internal/docs/chrome_test.go+37 −7
CI passed — run details
diff --git a/go.mod b/go.mod| index 47c91b6..ba9a304 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -3,7 +3,7 @@ module github.com/carlosframework/docs |
| go 1.26.5 |
| require ( |
| - amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768 |
| + amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57 |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 |
| amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf |
| amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3 |
diff --git a/go.sum b/go.sum| index a01869c..7fe82f7 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -1,5 +1,5 @@ |
| -amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768 h1:bVscoa9fH5LdLDjlyecZhrX7JzWPT0blb57MH0FIm2U= |
| -amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| +amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57 h1:5z3h+F5H9gpa4gLWxJKFaLFwNiNsI7zDKoRx9VPnwvI= |
| +amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k= |
| amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf h1:SRKjCUgtk42WwR7VSn+V0eLNk20mfiY8dQmzdw13Sbo= |
diff --git a/internal/docs/chrome.go b/internal/docs/chrome.go| index ffa37db..1279ad7 100644 |
| --- a/internal/docs/chrome.go |
| +++ b/internal/docs/chrome.go |
| @@ -126,10 +126,9 @@ func (h *handlers) account(r *http.Request, address string) *chrome.Account { |
| } |
| // switcher is the app switcher, or nil when no hub directory is |
| -// configured. Until Home's /apps/<slug> changes and the hidden id.* |
| -// interstitial have merged (spec §6.2 a, b and the §9.3 hide), it shows |
| -// "All apps" alone and no tiles: a tile today costs two assertion |
| -// exchanges and flashes an interstitial mid-switch. |
| +// configured: the suite's six apps as tiles, each at its own host under |
| +// the directory's (estilo's chrome.SuiteApps), with Docs marked current, |
| +// then "All apps". |
| func (h *handlers) switcher(r *http.Request) *chrome.Switcher { |
| if h.directory == "" { |
| return nil |
| @@ -137,6 +136,7 @@ func (h *handlers) switcher(r *http.Request) *chrome.Switcher { |
| return &chrome.Switcher{ |
| Label: rastrillo.T(r, "docs.chrome.apps"), |
| CurrentLabel: rastrillo.T(r, "docs.chrome.thisapp"), |
| + Apps: chrome.SuiteApps(h.directory, "docs"), |
| AllApps: estilomenu.Item{Href: h.directory + "/", Label: rastrillo.T(r, "docs.chrome.allapps")}, |
| } |
| } |
diff --git a/internal/docs/chrome_test.go b/internal/docs/chrome_test.go| index 0433ba5..389c566 100644 |
| --- a/internal/docs/chrome_test.go |
| +++ b/internal/docs/chrome_test.go |
| @@ -134,9 +134,10 @@ func TestTheSignedOutCorner(t *testing.T) { |
| } |
| } |
| -// The switcher appears only with a hub directory configured, and until |
| -// Home's /apps/<slug> changes land it is "All apps" alone, with no tiles. |
| -func TestTheSwitcherIsAllAppsOnly(t *testing.T) { |
| +// The switcher appears only with a hub directory configured. It shows the |
| +// suite's six apps as tiles at their hosts under the directory's, with |
| +// Docs marked current, and "All apps" below a divider. |
| +func TestTheSwitcherShowsTheSuite(t *testing.T) { |
| plain, _ := docs.NewForTest(t) |
| if body := get(t, plain, signInCookies(t, plain, "a@example.com"), "/").Body.String(); strings.Contains(body, "estilo-switcher") { |
| t.Error("a switcher with no hub directory") |
| @@ -146,11 +147,40 @@ func TestTheSwitcherIsAllAppsOnly(t *testing.T) { |
| t.Fatal(err) |
| } |
| body := get(t, app, signInCookies(t, app, "a@example.com"), "/").Body.String() |
| - if !strings.Contains(body, `<details estilo-switcher name="estilo-menus">`) || !strings.Contains(body, `<a estilo-menu-item href="https://oficina.works/"><span estilo-menu-label>docs.chrome.allapps</span></a>`) { |
| - t.Error("the switcher does not offer All apps", body) |
| + start := strings.Index(body, `<details estilo-switcher name="estilo-menus">`) |
| + if start < 0 { |
| + t.Fatal("no switcher", body) |
| + } |
| + panel := body[start:] |
| + panel = panel[:strings.Index(panel, "</details>")] |
| + grid, allApps, ok := strings.Cut(panel, "<hr>") |
| + if !ok || !strings.Contains(allApps, `<a estilo-menu-item href="https://oficina.works/"><span estilo-menu-label>docs.chrome.allapps</span></a>`) { |
| + t.Error("the switcher does not offer All apps below the tiles", panel) |
| + } |
| + var tiles []string |
| + for _, tile := range strings.Split(grid, "<a estilo-switcher-app ")[1:] { |
| + tiles = append(tiles, tile[:strings.Index(tile, "</a>")]) |
| + } |
| + want := []string{"docs", "sheets", "slides", "calendar", "memoria", "calls"} |
| + names := []string{"Docs", "Sheets", "Slides", "Calendar", "Memoria", "Calls"} |
| + if len(tiles) != len(want) { |
| + t.Fatalf("%d tiles, want %d: %s", len(tiles), len(want), grid) |
| + } |
| + for i, slug := range want { |
| + head := `href="https://` + slug + `.oficina.works/"` |
| + if slug == "docs" { |
| + head += ` aria-current="true"` |
| + } |
| + head += `><img src="/static/estilo/brand/` + slug + `.svg" alt="" width="32" height="32"><span>` + names[i] |
| + if !strings.HasPrefix(tiles[i], head) { |
| + t.Errorf("tile %d = %s, want it to start %s", i, tiles[i], head) |
| + } |
| + } |
| + if strings.Count(grid, "aria-current") != 1 || !strings.Contains(tiles[0], "<span estilo-visually-hidden> docs.chrome.thisapp</span>") { |
| + t.Error("Docs is not the one current tile", grid) |
| } |
| - if strings.Contains(body, "estilo-switcher-app") { |
| - t.Error("the switcher renders tiles before Home can serve them") |
| + if res := get(t, app, nil, "/static/estilo/brand/calls.svg"); res.Code != http.StatusOK { |
| + t.Errorf("a tile's icon is %d", res.Code) |
| } |
| for _, bad := range []string{"http://oficina.works", "https://oficina.works/", "https://Oficina.works", "https://127.0.0.1", "https://localhost", "https://a.b:8443", "https://user@a.b"} { |
| if _, err := docs.NewForTestWith(t, docs.Config{Directory: bad}); err == nil { |