Show the suite's apps as tiles in the app switcher
Paul asked: "Can the 'All apps' dropdown just be a list of apps rather than a dropdown with a single-item list?" The switcher now lists the suite's six apps (estilo's chrome.SuiteApps over HOME_DIRECTORY_ORIGIN), each at its own host under the directory's, with Calls marked current and "All apps" kept below a divider. It still appears only when the directory is configured. The tiles' icons come from estilo's brand package, which Calls did not serve, so brand.Handler() is now mounted at brand.Prefix next to the sky and font handlers: public and sessionless, same-origin under the existing img-src 'self'. estilo is pinned to the estilo feat/switcher-tiles branch commit 0e4003429d57 until that merges; re-pin to the estilo main commit then.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+56
−13
go.mod+1 −1go.sum+2 −2internal/calls/app.go+4 −0internal/calls/chrome.go+4 −2internal/calls/home_consumer_test.go+45 −8
CI failed — run details
diff --git a/go.mod b/go.mod| index d260432..dac1449 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -3,7 +3,7 @@ module amadan.net/oficina/calls |
| go 1.26.0 |
| 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/connect v0.0.0-20261001093757-2bec942ddd0c |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 |
| amadan.net/rastrillo/rastrillo v0.27.1-0.20261006204347-fb806a287060 |
diff --git a/go.sum b/go.sum| index ed9096b..4b5a250 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/connect v0.0.0-20261001093757-2bec942ddd0c h1:3yxO2D8BxDLMGfFV2o6Sp9Z91yLnjDCIuRKHVWORa8A= |
| amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c/go.mod h1:YroavXe43Wietec+po8mtSk4a9Bir2h31Q3iAf4MWxI= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM= |
diff --git a/internal/calls/app.go b/internal/calls/app.go| index 76ac871..e3938f0 100644 |
| --- a/internal/calls/app.go |
| +++ b/internal/calls/app.go |
| @@ -1,6 +1,7 @@ |
| package calls |
| import ( |
| + "amadan.net/oficina/estilo.git/brand" |
| "amadan.net/oficina/estilo.git/chrome" |
| "amadan.net/oficina/estilo.git/sky" |
| "amadan.net/oficina/estilo.git/theme" |
| @@ -597,6 +598,9 @@ func build(ctx context.Context, d *db.DB, cfg Config) (*http.ServeMux, *app, err |
| mux.Handle("GET "+sky.Prefix, sky.Handler()) |
| // Onest, Calma's typeface, served by estilo under its versioned prefix. |
| mux.Handle("GET "+theme.FontPrefix, theme.FontHandler()) |
| + // The app switcher's tile icons: estilo's suite brand marks, public |
| + // and sessionless like the sky. |
| + mux.Handle("GET "+brand.Prefix, brand.Handler()) |
| mux.Handle("/", r) |
| return mux, a, nil |
| } |
diff --git a/internal/calls/chrome.go b/internal/calls/chrome.go| index 5f1169f..36358e1 100644 |
| --- a/internal/calls/chrome.go |
| +++ b/internal/calls/chrome.go |
| @@ -227,8 +227,9 @@ func (a *app) offersHomeLink(v viewer) bool { |
| } |
| // switcher is the app switcher, or nil when no hub directory is |
| -// configured. It shows "All apps" alone and no tiles (Paul's §13 answer |
| -// 2), as Docs, Sheets and Slides do. |
| +// configured: the suite's six apps as tiles, each at its own host under |
| +// the directory's (estilo's chrome.SuiteApps), with Calls marked current, |
| +// then "All apps". |
| func (a *app) switcher() *chrome.Switcher { |
| if a.cfg.home == nil || a.cfg.home.Directory == "" { |
| return nil |
| @@ -236,6 +237,7 @@ func (a *app) switcher() *chrome.Switcher { |
| return &chrome.Switcher{ |
| Label: "Oficina apps", |
| CurrentLabel: "(this app)", |
| + Apps: chrome.SuiteApps(a.cfg.home.Directory, "calls"), |
| AllApps: estilomenu.Item{Href: a.cfg.home.Directory + "/", Label: "All apps"}, |
| } |
| } |
diff --git a/internal/calls/home_consumer_test.go b/internal/calls/home_consumer_test.go| index 02575a9..5baf14e 100644 |
| --- a/internal/calls/home_consumer_test.go |
| +++ b/internal/calls/home_consumer_test.go |
| @@ -71,23 +71,60 @@ func TestHomeSigninWhenSignedInReturnsToPage(t *testing.T) { |
| } |
| } |
| -// "All apps" goes to the hub directory, from HOME_DIRECTORY_ORIGIN, in the |
| -// account corner, and is absent when no directory is configured. |
| -func TestAllAppsLinksToDirectory(t *testing.T) { |
| - link := `href="` + homeTestDirectory + `/"` |
| +// The switcher appears only with a hub directory (HOME_DIRECTORY_ORIGIN) |
| +// configured. It shows the suite's six apps as tiles at their hosts under |
| +// the directory's, with Calls marked current, and "All apps" to the |
| +// directory below a divider. The tiles' icons are served without a session. |
| +func TestTheSwitcherShowsTheSuite(t *testing.T) { |
| f := newHomeConsumerFixture(t, homeTestDirectory) |
| f.local(t) |
| + want := []string{"docs", "sheets", "slides", "calendar", "memoria", "calls"} |
| + names := []string{"Docs", "Sheets", "Slides", "Calendar", "Memoria", "Calls"} |
| for _, path := range []string{"/", "/settings"} { |
| w := f.do("GET", path, "") |
| - if body := w.Body.String(); w.Code != http.StatusOK || !strings.Contains(body, link) || !strings.Contains(body, ">All apps<") { |
| - t.Fatalf("GET %s (%d): no All apps link to %s/", path, w.Code, homeTestDirectory) |
| + body := w.Body.String() |
| + start := strings.Index(body, `<details estilo-switcher name="estilo-menus">`) |
| + if w.Code != http.StatusOK || start < 0 { |
| + t.Fatalf("GET %s (%d): no switcher", path, w.Code) |
| } |
| + 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="`+homeTestDirectory+`/"><span estilo-menu-label>All apps</span></a>`) { |
| + t.Errorf("GET %s: the switcher does not offer All apps below the tiles: %s", path, panel) |
| + } |
| + var tiles []string |
| + for _, tile := range strings.Split(grid, "<a estilo-switcher-app ")[1:] { |
| + tiles = append(tiles, tile[:strings.Index(tile, "</a>")]) |
| + } |
| + if len(tiles) != len(want) { |
| + t.Fatalf("GET %s: %d tiles, want %d: %s", path, len(tiles), len(want), grid) |
| + } |
| + for i, slug := range want { |
| + head := `href="https://` + slug + `.directory.example.test/"` |
| + if slug == "calls" { |
| + 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("GET %s: tile %d = %s, want it to start %s", path, i, tiles[i], head) |
| + } |
| + } |
| + if strings.Count(grid, "aria-current") != 1 || !strings.Contains(tiles[5], "<span estilo-visually-hidden> (this app)</span>") { |
| + t.Errorf("GET %s: Calls is not the one current tile: %s", path, grid) |
| + } |
| + } |
| + |
| + icon := httptest.NewRecorder() |
| + f.handler.ServeHTTP(icon, httptest.NewRequest("GET", homeTestOrigin+"/static/estilo/brand/calls.svg", nil)) |
| + if icon.Code != http.StatusOK { |
| + t.Errorf("a tile's icon, without a session, is %d", icon.Code) |
| } |
| bare := newHomeConsumerFixture(t, "") |
| bare.local(t) |
| - if body := bare.do("GET", "/", "").Body.String(); strings.Contains(body, "All apps") { |
| - t.Fatal("All apps shown with no directory configured") |
| + if body := bare.do("GET", "/", "").Body.String(); strings.Contains(body, "estilo-switcher") || strings.Contains(body, "All apps") { |
| + t.Fatal("a switcher with no directory configured") |
| } |
| } |