Add selected-team recent documents and calendar dashboard
14 files changed,
+954
−2
go.mod+1 −0go.sum+2 −0internal/home/app.go+3 −0internal/home/dashboard.go+261 −0internal/home/dashboard_config.go+109 −0internal/home/dashboard_exchange.go+169 −0internal/home/dashboard_preference.go+57 −0internal/home/dashboard_state.go+89 −0internal/home/dashboard_test.go+201 −0internal/home/directory.go+3 −1internal/home/runtime.go+4 −0internal/home/signin_return.go+1 −1internal/home/static/calma.css+19 −0internal/home/templates/dashboard.html+35 −0
CI failed — run details
diff --git a/go.mod b/go.mod| index dab5a0a..d47d8c2 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -6,6 +6,7 @@ toolchain go1.26.5 |
| require ( |
| amadan.net/oficina/estilo.git v0.0.0-20261001084202-0b4d92c3dc16 |
| + amadan.net/oficina/home/dashboard v0.0.0-20261024234842-3774eb68f816 |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 |
| amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf |
| amadan.net/rastrillo/rastrillo v0.26.1-0.20260908075707-29e4491631bd |
diff --git a/go.sum b/go.sum| index 253b264..e2d6c6b 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -2,6 +2,8 @@ amadan.net/carlos/platform.git/launchctx v0.0.0-20260911135504-fb577f96f7d1 h1:R |
| amadan.net/carlos/platform.git/launchctx v0.0.0-20260911135504-fb577f96f7d1/go.mod h1:6fBmMWgtESLFXZURzu/HyRXM0vyLuo4+XGGdKuZ+wao= |
| amadan.net/oficina/estilo.git v0.0.0-20261001084202-0b4d92c3dc16 h1:F5v3x25dEj1rJNnBm71G7shN+fM+T2actUlaGPvoeH8= |
| amadan.net/oficina/estilo.git v0.0.0-20261001084202-0b4d92c3dc16/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| +amadan.net/oficina/home/dashboard v0.0.0-20261024234842-3774eb68f816 h1:AFDuOio0MxNxN9ZWVc3lul1QHkNjNUCO56kXpe/Fw3I= |
| +amadan.net/oficina/home/dashboard v0.0.0-20261024234842-3774eb68f816/go.mod h1:+7xsX+QyVFrKy5gDAGh+FZ5+75z4CibWTL0wl9DWAw0= |
| 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/home/app.go b/internal/home/app.go| index acf81fb..abd4186 100644 |
| --- a/internal/home/app.go |
| +++ b/internal/home/app.go |
| @@ -38,6 +38,7 @@ import ( |
| // is sealed on the way in, and the database handle because that is what |
| // it is sealed into. Nothing here reaches for a raw key. |
| type App struct { |
| + dash *dashboardState |
| runtime *Runtime |
| directory *directoryFeatures |
| consumer *handoff.Consumer |
| @@ -198,6 +199,8 @@ func (a *App) Router() http.Handler { |
| r.Use(csrf.Protect(a.origins.Credential)) |
| if a.runtime != nil && a.runtime.role == "credential" { |
| r.Get("/authorize", a.handleAuthorize) |
| + r.Get("/dashboard/authorize", a.beginDashboard) |
| + r.With(a.sessions.Require).Get("/dashboard/resume", a.authorizeDashboard) |
| r.With(a.sessions.Require).Get("/authorize/resume", a.handleAssertion) |
| r.Get("/static/assertion.js", serveAsset(staticAsset("assertion.js"), "text/javascript; charset=utf-8")) |
| } |
diff --git a/internal/home/dashboard.go b/internal/home/dashboard.go| new file mode 100644 |
| index 0000000..7c0ba8d |
| --- /dev/null |
| +++ b/internal/home/dashboard.go |
| @@ -0,0 +1,261 @@ |
| +package home |
| + |
| +import ( |
| + "context" |
| + "io" |
| + "net/http" |
| + "net/url" |
| + "sort" |
| + "strings" |
| + "time" |
| + |
| + "amadan.net/oficina/home/dashboard" |
| + "github.com/go-json-experiment/json" |
| +) |
| + |
| +type dashboardRow struct { |
| + dashboard.Item |
| + App, When, DateTime string |
| +} |
| +type dashboardPage struct { |
| + Apps []catalogApp |
| + Teams []dashboardTeam |
| + Team dashboardTeam |
| + Documents, Events []dashboardRow |
| + Sources []dashboardResult |
| + DocumentsComplete, EventsComplete bool |
| +} |
| + |
| +func (a *App) handleDashboard(w http.ResponseWriter, r *http.Request) { |
| + if len(a.runtime.dashboard) == 0 { |
| + a.render(w, r, 200, "directory.html", map[string]any{"Apps": directoryCatalog(*a.runtime)}) |
| + return |
| + } |
| + subject, session, ok := a.dashboardSession(r) |
| + if !ok { |
| + http.Error(w, "Unable to load your dashboard", 400) |
| + return |
| + } |
| + q, e := url.ParseQuery(r.URL.RawQuery) |
| + if e != nil || len(q) > 2 || len(q["team"]) > 1 || len(q["dashboard"]) > 1 { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + for k := range q { |
| + if k != "team" && k != "dashboard" { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + } |
| + selected := q.Get("team") |
| + if selected == "" { |
| + var valid bool |
| + selected, valid = a.selectedDashboardTeam(r, session) |
| + if !valid { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + if selected == "" { |
| + selected = a.runtime.dashboard[0].ID |
| + } |
| + } |
| + team, ok := a.dashboardTeam(selected) |
| + if !ok { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + a.rememberDashboardTeam(w, session, team.ID) |
| + key := dashboardCacheKey(subject, session, team.ID) |
| + now := time.Now() |
| + a.dash.mu.Lock() |
| + a.dash.sweep(now) |
| + cached, found := a.dash.cache[key] |
| + if q.Get("dashboard") == "" && found && now.Sub(cached.At) < 30*time.Second { |
| + a.dash.mu.Unlock() |
| + a.renderDashboard(w, r, team, cached.Results) |
| + return |
| + } |
| + nonce := q.Get("dashboard") |
| + if nonce != "" { |
| + pending, present := a.dash.pending[nonce] |
| + if !present || nonce != dashboardNonce(r) || pending.Tokens == nil || pending.Subject != subject || pending.Session != session || pending.Team != team.ID { |
| + a.dash.mu.Unlock() |
| + http.Error(w, "Dashboard refresh expired. Return to Oficina and try again.", 400) |
| + return |
| + } |
| + delete(a.dash.pending, nonce) |
| + a.dash.mu.Unlock() |
| + http.SetCookie(w, &http.Cookie{Name: dashboardCookie, Path: "/", Value: "", MaxAge: -1, Secure: true, HttpOnly: true, SameSite: http.SameSiteNoneMode}) |
| + results := a.pullDashboard(r.Context(), team, pending.Tokens) |
| + a.dash.mu.Lock() |
| + a.dash.sweep(time.Now()) |
| + if len(a.dash.cache) >= 256 { |
| + for k := range a.dash.cache { |
| + delete(a.dash.cache, k) |
| + break |
| + } |
| + } |
| + cachedAt := time.Now() |
| + a.dash.cache[key] = dashboardCache{Results: results, At: cachedAt} |
| + // Drop content even when nobody visits Home again. |
| + time.AfterFunc(120*time.Second, func() { |
| + a.dash.mu.Lock() |
| + defer a.dash.mu.Unlock() |
| + if current, ok := a.dash.cache[key]; ok && current.At.Equal(cachedAt) { |
| + delete(a.dash.cache, key) |
| + } |
| + }) |
| + a.dash.mu.Unlock() |
| + // Finish at the ordinary selected-team URL, so refresh never reuses a token. |
| + http.Redirect(w, r, "/?team="+url.QueryEscape(team.ID), http.StatusSeeOther) |
| + return |
| + } |
| + if len(a.dash.pending) >= 256 { |
| + a.dash.mu.Unlock() |
| + http.Error(w, "Dashboard busy. Please try again.", 503) |
| + return |
| + } |
| + nonce, e = dashboard.ID() |
| + if e != nil { |
| + a.dash.mu.Unlock() |
| + http.Error(w, "Dashboard unavailable", 503) |
| + return |
| + } |
| + // A new tab replaces only this browser's pending flow, never another viewer's. |
| + if previous := dashboardNonce(r); previous != "" { |
| + delete(a.dash.pending, previous) |
| + } |
| + a.dash.pending[nonce] = dashboardPending{Subject: subject, Session: session, Team: team.ID, Expires: now.Add(5 * time.Minute)} |
| + a.dash.mu.Unlock() |
| + http.SetCookie(w, &http.Cookie{Name: dashboardCookie, Path: "/", Value: nonce, MaxAge: 300, Secure: true, HttpOnly: true, SameSite: http.SameSiteNoneMode}) |
| + http.Redirect(w, r, a.origins.Credential+"/dashboard/authorize?"+url.Values{"team": {team.ID}, "nonce": {nonce}}.Encode(), http.StatusSeeOther) |
| +} |
| +func (a *App) pullDashboard(parent context.Context, team dashboardTeam, tokens map[string]string) []dashboardResult { |
| + ctx, cancel := context.WithTimeout(parent, 3*time.Second) |
| + defer cancel() |
| + results := make(chan dashboardResult, len(team.Sources)) |
| + for _, source := range team.Sources { |
| + go func(s dashboardSource) { |
| + result := dashboardResult{Source: s, Status: "Could not load. Refresh or open the app."} |
| + defer func() { results <- result }() |
| + select { |
| + case a.dash.slots <- struct{}{}: |
| + defer func() { <-a.dash.slots }() |
| + case <-ctx.Done(): |
| + result.Status = "Not loaded yet. Refresh to try again." |
| + return |
| + } |
| + req, e := http.NewRequestWithContext(ctx, http.MethodGet, s.Origin+dashboard.Path, nil) |
| + if e != nil { |
| + return |
| + } |
| + req.Header.Set("Authorization", "Bearer "+tokens[s.Origin]) |
| + req.Header.Set("Accept", "application/json") |
| + req.Header.Set("Cache-Control", "no-store") |
| + response, e := a.dash.client.Do(req) |
| + if e != nil { |
| + return |
| + } |
| + defer response.Body.Close() |
| + if response.StatusCode == 403 { |
| + result.Status = "Connect your Oficina account in this app to see your work." |
| + return |
| + } |
| + if response.StatusCode != 200 || !dashboardNoStore(response.Header.Values("Cache-Control")) { |
| + return |
| + } |
| + b, e := io.ReadAll(io.LimitReader(response.Body, dashboard.MaxBody+1)) |
| + if e != nil || len(b) > dashboard.MaxBody { |
| + return |
| + } |
| + var data dashboard.Response |
| + if json.Unmarshal(b, &data, json.RejectUnknownMembers(true)) != nil || !data.Valid(s.Origin, team.ID, s.kind()) { |
| + return |
| + } |
| + result.Response = data |
| + result.Status = "" |
| + }(source) |
| + } |
| + out := make([]dashboardResult, 0, len(team.Sources)) |
| + for range team.Sources { |
| + out = append(out, <-results) |
| + } |
| + sort.Slice(out, func(i, j int) bool { return out[i].Source.App < out[j].Source.App }) |
| + return out |
| +} |
| +func (a *App) renderDashboard(w http.ResponseWriter, r *http.Request, team dashboardTeam, results []dashboardResult) { |
| + page := dashboardPage{Apps: directoryCatalog(*a.runtime), Teams: a.runtime.dashboard, Team: team, Sources: results, DocumentsComplete: false, EventsComplete: false} |
| + // Every launcher belongs to this explicit grouping; no global preview fallback. |
| + page.Apps = nil |
| + for _, source := range team.launchers() { |
| + for _, app := range directoryCatalog(*a.runtime) { |
| + if app.Name == source.Name() { |
| + app.Href = source.Origin + "/" |
| + app.Status = "" |
| + page.Apps = append(page.Apps, app) |
| + } |
| + } |
| + } |
| + documentProviders, eventProviders, documentFailures, eventFailures := 0, 0, 0, 0 |
| + for _, result := range results { |
| + if result.Source.kind() == "events" { |
| + eventProviders++ |
| + } else { |
| + documentProviders++ |
| + } |
| + if result.Status != "" { |
| + if result.Source.kind() == "events" { |
| + eventFailures++ |
| + } else { |
| + documentFailures++ |
| + } |
| + continue |
| + } |
| + for _, item := range result.Response.Items { |
| + row := dashboardRow{Item: item, App: result.Source.Name()} |
| + if result.Source.kind() == "documents" { |
| + row.When = item.Updated.UTC().Format("2 Jan 2006, 15:04 UTC") |
| + row.DateTime = item.Updated.Format(time.RFC3339) |
| + page.Documents = append(page.Documents, row) |
| + } else { |
| + loc, _ := time.LoadLocation(result.Response.Timezone) |
| + row.When = item.Start.In(loc).Format("Mon 2 Jan, 15:04 MST") |
| + row.DateTime = item.Start.Format(time.RFC3339) |
| + if item.AllDay { |
| + row.When = item.StartDate + " · All day" |
| + row.DateTime = item.StartDate |
| + } |
| + page.Events = append(page.Events, row) |
| + } |
| + } |
| + } |
| + page.DocumentsComplete = documentProviders > 0 && documentFailures == 0 |
| + page.EventsComplete = eventProviders > 0 && eventFailures == 0 |
| + sort.SliceStable(page.Documents, func(i, j int) bool { |
| + if page.Documents[i].Updated.Equal(page.Documents[j].Updated) { |
| + return page.Documents[i].URL < page.Documents[j].URL |
| + } |
| + return page.Documents[i].Updated.After(page.Documents[j].Updated) |
| + }) |
| + if len(page.Documents) > 20 { |
| + page.Documents = page.Documents[:20] |
| + } |
| + sort.SliceStable(page.Events, func(i, j int) bool { return page.Events[i].Start.Before(page.Events[j].Start) }) |
| + a.render(w, r, 200, "dashboard.html", page) |
| +} |
| + |
| +func dashboardNoStore(headers []string) bool { |
| + found := false |
| + for _, header := range headers { |
| + for _, raw := range strings.Split(header, ",") { |
| + directive := strings.ToLower(strings.TrimSpace(raw)) |
| + if directive == "no-store" { |
| + found = true |
| + } |
| + if directive == "public" || strings.HasPrefix(directive, "s-maxage=") || strings.HasPrefix(directive, "max-age=") { |
| + return false |
| + } |
| + } |
| + } |
| + return found |
| +} |
diff --git a/internal/home/dashboard_config.go b/internal/home/dashboard_config.go| new file mode 100644 |
| index 0000000..4b8a220 |
| --- /dev/null |
| +++ b/internal/home/dashboard_config.go |
| @@ -0,0 +1,109 @@ |
| +package home |
| + |
| +import ( |
| + "amadan.net/oficina/home/dashboard" |
| + "github.com/go-json-experiment/json" |
| +) |
| + |
| +type dashboardSource struct { |
| + App string `json:"app"` |
| + Origin string `json:"origin"` |
| +} |
| +type dashboardTeam struct { |
| + ID string `json:"id"` |
| + Name string `json:"name"` |
| + Sources []dashboardSource `json:"sources"` |
| + Apps []dashboardSource `json:"apps,omitempty"` |
| +} |
| + |
| +func (t dashboardTeam) launchers() []dashboardSource { |
| + if len(t.Apps) > 0 { |
| + return t.Apps |
| + } |
| + return t.Sources |
| +} |
| + |
| +func (s dashboardSource) kind() string { |
| + if s.App == "calendar" { |
| + return "events" |
| + } |
| + return "documents" |
| +} |
| +func (s dashboardSource) Name() string { |
| + for _, a := range directoryApps() { |
| + if a.slug == s.App { |
| + return a.name |
| + } |
| + } |
| + return "" |
| +} |
| +func loadDashboardConfig(cfg *Runtime) error { |
| + raw, e := exchangeJSON("HOME_DASHBOARD_TEAMS", 16384) |
| + if e != nil { |
| + return errExchangeConfig |
| + } |
| + if raw == "" { |
| + return nil |
| + } |
| + if cfg.role != "directory" && cfg.role != "credential" { |
| + return errExchangeConfig |
| + } |
| + if json.Unmarshal([]byte(raw), &cfg.dashboard, json.RejectUnknownMembers(true)) != nil || len(cfg.dashboard) == 0 || len(cfg.dashboard) > 8 { |
| + return errExchangeConfig |
| + } |
| + teams, origins := map[string]bool{}, map[string]string{} |
| + for _, t := range cfg.dashboard { |
| + if !dashboard.ValidName(t.ID) || teams[t.ID] || len(t.Name) == 0 || len(t.Name) > 128 || len(t.Sources) == 0 || len(t.Sources) > 4 || len(t.Apps) > 6 { |
| + return errExchangeConfig |
| + } |
| + teams[t.ID] = true |
| + apps := map[string]bool{} |
| + for _, s := range t.Sources { |
| + if s.App != "docs" && s.App != "sheets" && s.App != "slides" && s.App != "calendar" { |
| + return errExchangeConfig |
| + } |
| + if !dashboard.ValidOrigin(s.Origin) || s.Origin == cfg.origins.Credential || s.Origin == cfg.origins.Directory || (origins[s.Origin] != "" && origins[s.Origin] != t.ID) || apps[s.App] { |
| + return errExchangeConfig |
| + } |
| + origins[s.Origin] = t.ID |
| + apps[s.App] = true |
| + if cfg.role == "credential" { |
| + found := false |
| + for _, v := range cfg.consumers { |
| + if v == s.Origin { |
| + found = true |
| + } |
| + } |
| + if !found { |
| + return errExchangeConfig |
| + } |
| + } |
| + } |
| + launchers := map[string]string{} |
| + for _, s := range t.launchers() { |
| + if s.Name() == "" || launchers[s.App] != "" || !dashboard.ValidOrigin(s.Origin) || s.Origin == cfg.origins.Credential || s.Origin == cfg.origins.Directory || (origins[s.Origin] != "" && origins[s.Origin] != t.ID) { |
| + return errExchangeConfig |
| + } |
| + launchers[s.App] = s.Origin |
| + origins[s.Origin] = t.ID |
| + } |
| + for _, s := range t.Sources { |
| + if launchers[s.App] != s.Origin { |
| + return errExchangeConfig |
| + } |
| + } |
| + |
| + } |
| + return nil |
| +} |
| +func (a *App) dashboardTeam(id string) (dashboardTeam, bool) { |
| + if a.runtime == nil { |
| + return dashboardTeam{}, false |
| + } |
| + for _, t := range a.runtime.dashboard { |
| + if t.ID == id { |
| + return t, true |
| + } |
| + } |
| + return dashboardTeam{}, false |
| +} |
diff --git a/internal/home/dashboard_exchange.go b/internal/home/dashboard_exchange.go| new file mode 100644 |
| index 0000000..8af81ac |
| --- /dev/null |
| +++ b/internal/home/dashboard_exchange.go |
| @@ -0,0 +1,169 @@ |
| +package home |
| + |
| +import ( |
| + "encoding/base64" |
| + "io" |
| + "mime" |
| + "net/http" |
| + "net/url" |
| + "time" |
| + |
| + "amadan.net/oficina/home/dashboard" |
| + "amadan.net/rastrillo/rastrillo/sessions" |
| + "github.com/go-json-experiment/json" |
| +) |
| + |
| +const dashboardCallback = "/dashboard/callback" |
| + |
| +const dashboardIntentCookie = "__Host-oficina-dashboard-intent" |
| + |
| +type dashboardIntent struct { |
| + Team, Nonce string |
| + Expires int64 |
| +} |
| + |
| +func (a *App) beginDashboard(w http.ResponseWriter, r *http.Request) { |
| + w.Header().Set("Cache-Control", "private, no-store") |
| + q, e := url.ParseQuery(r.URL.RawQuery) |
| + if e != nil || len(q) != 2 || len(q["team"]) != 1 || len(q["nonce"]) != 1 || !dashboard.ValidID(q.Get("nonce")) { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + if _, ok := a.dashboardTeam(q.Get("team")); !ok { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + b, e := json.Marshal(dashboardIntent{q.Get("team"), q.Get("nonce"), time.Now().Unix() + 300}) |
| + if e != nil { |
| + http.Error(w, "Dashboard unavailable", 503) |
| + return |
| + } |
| + sealed, e := a.secrets.Sealer.Seal("dashboard.intent", b) |
| + if e != nil { |
| + http.Error(w, "Dashboard unavailable", 503) |
| + return |
| + } |
| + http.SetCookie(w, &http.Cookie{Name: dashboardIntentCookie, Value: base64.RawURLEncoding.EncodeToString(sealed), Path: "/", MaxAge: 300, Secure: true, HttpOnly: true, SameSite: http.SameSiteLaxMode}) |
| + http.Redirect(w, r, "/dashboard/resume", http.StatusSeeOther) |
| +} |
| +func (a *App) authorizeDashboard(w http.ResponseWriter, r *http.Request) { |
| + w.Header().Set("Cache-Control", "private, no-store") |
| + value := "" |
| + count := 0 |
| + for _, c := range r.Cookies() { |
| + if c.Name == dashboardIntentCookie { |
| + value = c.Value |
| + count++ |
| + } |
| + } |
| + if count != 1 || len(value) > 2048 || r.URL.RawQuery != "" { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + sealed, e := base64.RawURLEncoding.Strict().DecodeString(value) |
| + if e != nil { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + b, e := a.secrets.Sealer.Open("dashboard.intent", sealed) |
| + if e != nil { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + var intent dashboardIntent |
| + if json.Unmarshal(b, &intent, json.RejectUnknownMembers(true)) != nil || !dashboard.ValidID(intent.Nonce) || intent.Expires <= time.Now().Unix() || intent.Expires > time.Now().Unix()+300 { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + team, ok := a.dashboardTeam(intent.Team) |
| + if !ok { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + |
| + session, ok := sessions.Current(r) |
| + if !ok || !ValidPersonRef(session.Subject) { |
| + http.Error(w, "Sign in to continue", 401) |
| + return |
| + } |
| + tokens := map[string]string{} |
| + now := time.Now() |
| + for _, s := range team.Sources { |
| + id, e := dashboard.ID() |
| + if e != nil { |
| + http.Error(w, "Dashboard unavailable", 503) |
| + return |
| + } |
| + token, e := dashboard.Sign(a.runtime.signer, dashboard.Claims{Version: 1, Issuer: a.origins.Credential, Audience: s.Origin, Directory: a.origins.Directory, Subject: session.Subject, Team: team.ID, Purpose: "dashboard-read", KeyID: a.runtime.keyID, ID: id, Nonce: intent.Nonce, Issued: now.Unix(), Expires: now.Unix() + 120}) |
| + if e != nil { |
| + http.Error(w, "Dashboard unavailable", 503) |
| + return |
| + } |
| + tokens[s.Origin] = token |
| + } |
| + b, e = json.Marshal(tokens) |
| + if e != nil { |
| + http.Error(w, "Dashboard unavailable", 503) |
| + return |
| + } |
| + w.Header().Set("Referrer-Policy", "strict-origin") |
| + a.render(w, r, 200, "assertion.html", map[string]any{"Action": a.origins.Directory + dashboardCallback, "Token": string(b)}) |
| +} |
| +func (a *App) receiveDashboard(w http.ResponseWriter, r *http.Request) { |
| + w.Header().Set("Cache-Control", "private, no-store") |
| + fail := func() { http.Error(w, "Unable to load your dashboard. Return to Oficina and try again.", 400) } |
| + if a.dash == nil || len(r.Header.Values("Origin")) != 1 || r.Header.Get("Origin") != a.origins.Credential { |
| + fail() |
| + return |
| + } |
| + media, _, e := mime.ParseMediaType(r.Header.Get("Content-Type")) |
| + if e != nil || media != "application/x-www-form-urlencoded" { |
| + fail() |
| + return |
| + } |
| + b, e := io.ReadAll(http.MaxBytesReader(w, r.Body, 24576)) |
| + if e != nil { |
| + fail() |
| + return |
| + } |
| + form, e := url.ParseQuery(string(b)) |
| + if e != nil || len(form) != 1 || len(form["assertion"]) != 1 { |
| + fail() |
| + return |
| + } |
| + var tokens map[string]string |
| + if json.Unmarshal([]byte(form.Get("assertion")), &tokens) != nil { |
| + fail() |
| + return |
| + } |
| + nonce := dashboardNonce(r) |
| + if nonce == "" { |
| + fail() |
| + return |
| + } |
| + now := time.Now() |
| + a.dash.mu.Lock() |
| + defer a.dash.mu.Unlock() |
| + a.dash.sweep(now) |
| + pending, ok := a.dash.pending[nonce] |
| + if !ok || pending.Tokens != nil { |
| + fail() |
| + return |
| + } |
| + team, ok := a.dashboardTeam(pending.Team) |
| + if !ok || len(tokens) != len(team.Sources) { |
| + fail() |
| + return |
| + } |
| + for _, s := range team.Sources { |
| + c, e := dashboard.Verify(tokens[s.Origin], a.origins.Credential, s.Origin, a.origins.Directory, team.ID, a.runtime.keys, now) |
| + if e != nil || c.Subject != pending.Subject || c.Nonce != nonce { |
| + fail() |
| + return |
| + } |
| + } |
| + pending.Tokens = tokens |
| + pending.Expires = now.Add(120 * time.Second) |
| + a.dash.pending[nonce] = pending |
| + http.Redirect(w, r, "/?"+url.Values{"team": {team.ID}, "dashboard": {nonce}}.Encode(), http.StatusSeeOther) |
| +} |
diff --git a/internal/home/dashboard_preference.go b/internal/home/dashboard_preference.go| new file mode 100644 |
| index 0000000..448b42c |
| --- /dev/null |
| +++ b/internal/home/dashboard_preference.go |
| @@ -0,0 +1,57 @@ |
| +package home |
| + |
| +import ( |
| + "encoding/base64" |
| + "net/http" |
| + |
| + "amadan.net/oficina/home/dashboard" |
| + "github.com/go-json-experiment/json" |
| +) |
| + |
| +const dashboardTeamCookie = "__Host-oficina-dashboard-team" |
| + |
| +type dashboardPreference struct{ Session, Team string } |
| + |
| +func (a *App) selectedDashboardTeam(r *http.Request, session string) (string, bool) { |
| + count := 0 |
| + value := "" |
| + for _, c := range r.Cookies() { |
| + if c.Name == dashboardTeamCookie { |
| + count++ |
| + value = c.Value |
| + } |
| + } |
| + if count == 0 { |
| + return "", true |
| + } |
| + if count != 1 || len(value) > 2048 { |
| + return "", false |
| + } |
| + b, e := base64.RawURLEncoding.Strict().DecodeString(value) |
| + if e != nil { |
| + return "", false |
| + } |
| + plain, e := a.secrets.Sealer.Open("dashboard.team", b) |
| + if e != nil { |
| + return "", false |
| + } |
| + var p dashboardPreference |
| + if json.Unmarshal(plain, &p, json.RejectUnknownMembers(true)) != nil || !dashboard.ValidName(p.Team) { |
| + return "", false |
| + } |
| + if p.Session != base64.RawURLEncoding.EncodeToString([]byte(session)) { |
| + return "", true |
| + } |
| + return p.Team, true |
| +} |
| +func (a *App) rememberDashboardTeam(w http.ResponseWriter, session, team string) { |
| + b, e := json.Marshal(dashboardPreference{base64.RawURLEncoding.EncodeToString([]byte(session)), team}) |
| + if e != nil { |
| + return |
| + } |
| + sealed, e := a.secrets.Sealer.Seal("dashboard.team", b) |
| + if e != nil { |
| + return |
| + } |
| + http.SetCookie(w, &http.Cookie{Name: dashboardTeamCookie, Value: base64.RawURLEncoding.EncodeToString(sealed), Path: "/", MaxAge: 30 * 24 * 3600, Secure: true, HttpOnly: true, SameSite: http.SameSiteLaxMode}) |
| +} |
diff --git a/internal/home/dashboard_state.go b/internal/home/dashboard_state.go| new file mode 100644 |
| index 0000000..af5f74a |
| --- /dev/null |
| +++ b/internal/home/dashboard_state.go |
| @@ -0,0 +1,89 @@ |
| +package home |
| + |
| +import ( |
| + "crypto/sha256" |
| + "net/http" |
| + "sync" |
| + "time" |
| + |
| + "amadan.net/oficina/home/dashboard" |
| + "amadan.net/rastrillo/rastrillo/sessions" |
| +) |
| + |
| +const dashboardCookie = "__Host-oficina-dashboard" |
| + |
| +type dashboardPending struct { |
| + Subject, Team, Session string |
| + Expires time.Time |
| + Tokens map[string]string |
| +} |
| +type dashboardResult struct { |
| + Source dashboardSource |
| + Response dashboard.Response |
| + Status string |
| +} |
| +type dashboardCache struct { |
| + Results []dashboardResult |
| + At time.Time |
| +} |
| +type dashboardState struct { |
| + mu sync.Mutex |
| + pending map[string]dashboardPending |
| + cache map[string]dashboardCache |
| + slots chan struct{} |
| + client *http.Client |
| +} |
| + |
| +func newDashboardState() *dashboardState { |
| + return &dashboardState{pending: map[string]dashboardPending{}, cache: map[string]dashboardCache{}, slots: make(chan struct{}, 16), client: &http.Client{Timeout: 3 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}} |
| +} |
| + |
| +// Sweep every access; hard expiry is independent of whether a source recovers. |
| +func (d *dashboardState) sweep(now time.Time) { |
| + for k, v := range d.pending { |
| + if !now.Before(v.Expires) { |
| + delete(d.pending, k) |
| + } |
| + } |
| + for k, v := range d.cache { |
| + if now.Sub(v.At) >= 120*time.Second { |
| + delete(d.cache, k) |
| + } |
| + } |
| +} |
| +func (a *App) dashboardSession(r *http.Request) (string, string, bool) { |
| + s, ok := sessions.Current(r) |
| + if !ok || !ValidPersonRef(s.Subject) { |
| + return "", "", false |
| + } |
| + count := 0 |
| + value := "" |
| + for _, c := range r.Cookies() { |
| + if c.Name == a.sessions.CookieName() { |
| + count++ |
| + value = c.Value |
| + } |
| + } |
| + if count != 1 || value == "" { |
| + return "", "", false |
| + } |
| + h := sha256.Sum256([]byte(value)) |
| + return s.Subject, string(h[:]), true |
| +} |
| +func dashboardCacheKey(subject, session, team string) string { |
| + return subject + "\x00" + session + "\x00" + team |
| +} |
| +func dashboardNonce(r *http.Request) string { |
| + count := 0 |
| + v := "" |
| + for _, c := range r.Cookies() { |
| + if c.Name == dashboardCookie { |
| + count++ |
| + v = c.Value |
| + } |
| + } |
| + if count != 1 || !dashboard.ValidID(v) { |
| + return "" |
| + } |
| + return v |
| +} |
diff --git a/internal/home/dashboard_test.go b/internal/home/dashboard_test.go| new file mode 100644 |
| index 0000000..b4ef26e |
| --- /dev/null |
| +++ b/internal/home/dashboard_test.go |
| @@ -0,0 +1,201 @@ |
| +package home |
| + |
| +import ( |
| + "context" |
| + "html" |
| + "io" |
| + "net/http" |
| + "net/http/httptest" |
| + "net/url" |
| + "os" |
| + "regexp" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/home/dashboard" |
| + "amadan.net/oficina/home/internal/home/sealtest" |
| + "github.com/go-json-experiment/json" |
| +) |
| + |
| +type dashboardTransport func(*http.Request) (*http.Response, error) |
| + |
| +func (f dashboardTransport) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) } |
| +func dashboardTestBody(t *testing.T, v any) string { |
| + t.Helper() |
| + b, e := json.Marshal(v) |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + return string(b) |
| +} |
| +func dashboardTestResponse(body string) *http.Response { |
| + return &http.Response{StatusCode: 200, Header: http.Header{"Cache-Control": {"private, no-store"}}, Body: io.NopCloser(strings.NewReader(body))} |
| +} |
| + |
| +func TestDashboardExchangeIsolationAndPrivacy(t *testing.T) { |
| + p := newExchangePair(t) |
| + credentialSession := signInFully(t, p.credential, sealtest.CanaryAddress) |
| + pending, intent := p.start(t) |
| + token, _ := p.mint(t, intent, credentialSession) |
| + directorySession := p.finish(t, token, pending) |
| + teams := []dashboardTeam{{ID: "blue", Name: "Blue", Sources: []dashboardSource{{"docs", "https://blue.docs.oficina.works"}}}, {ID: "red", Name: "Red", Sources: []dashboardSource{{"docs", "https://red.docs.oficina.works"}}}} |
| + p.directory.runtime.dashboard = teams |
| + p.credential.runtime.dashboard = teams |
| + subject := subjectOf(t, p.credential, credentialSession) |
| + calls := 0 |
| + p.directory.dash.client.Transport = dashboardTransport(func(r *http.Request) (*http.Response, error) { |
| + calls++ |
| + if r.URL.Host != "red.docs.oficina.works" { |
| + t.Error("crossed selected team") |
| + } |
| + c, e := dashboard.Verify(strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer "), Origin, "https://red.docs.oficina.works", directoryOrigin, "red", p.credential.runtime.keys, time.Now()) |
| + if e != nil || c.Subject != subject { |
| + t.Error("invalid source authority") |
| + } |
| + return dashboardTestResponse(dashboardTestBody(t, dashboard.Response{Version: 1, Team: "red", Kind: "documents", Items: []dashboard.Item{{ID: "one", Title: "Dashboard private title <script>", URL: "https://red.docs.oficina.works/d/private-canary", Updated: time.Now()}}})), nil |
| + }) |
| + start := exchangeRequest(p.directory, "GET", directoryOrigin+"/?team=red", "", nil, directorySession) |
| + if start.Code != 303 { |
| + t.Fatal("start", start.Code) |
| + } |
| + nonce := namedCookie(t, start, dashboardCookie) |
| + preference := namedCookie(t, start, dashboardTeamCookie) |
| + begin := exchangeRequest(p.credential.App, "GET", start.Header().Get("Location"), "", nil) |
| + dashboardIntent := namedCookie(t, begin, dashboardIntentCookie) |
| + unsigned := exchangeRequest(p.credential.App, "GET", Origin+"/dashboard/resume", "", nil, dashboardIntent) |
| + if unsigned.Code != 303 { |
| + t.Fatal("missing sign-in gate", unsigned.Code) |
| + } |
| + signin := exchangeRequest(p.credential.App, "GET", Origin+unsigned.Header().Get("Location"), "", nil, dashboardIntent) |
| + if namedCookie(t, signin, returnCookie).Value != "/dashboard/resume" { |
| + t.Fatal("lost sign-in return") |
| + } |
| + minted := exchangeRequest(p.credential.App, "GET", Origin+"/dashboard/resume", "", nil, dashboardIntent, credentialSession) |
| + if minted.Code != 200 { |
| + t.Fatal("mint", minted.Code) |
| + } |
| + m := regexp.MustCompile(`name="assertion" value="([^"]+)"`).FindStringSubmatch(minted.Body.String()) |
| + if len(m) != 2 { |
| + t.Fatal("no form") |
| + } |
| + form := url.Values{"assertion": {html.UnescapeString(m[1])}} |
| + for _, origin := range []string{"", "https://evil.invalid"} { |
| + if rec := exchangeRequest(p.directory, "POST", directoryOrigin+dashboardCallback, origin, form, nonce); rec.Code != 400 { |
| + t.Fatal("accepted wrong origin") |
| + } |
| + } |
| + if rec := exchangeRequest(p.directory, "POST", directoryOrigin+dashboardCallback, Origin, form, nonce, nonce); rec.Code != 400 { |
| + t.Fatal("accepted duplicate cookie") |
| + } |
| + callback := exchangeRequest(p.directory, "POST", directoryOrigin+dashboardCallback, Origin, form, nonce) |
| + if callback.Code != 303 { |
| + t.Fatal("callback", callback.Code) |
| + } |
| + if rec := exchangeRequest(p.directory, "POST", directoryOrigin+dashboardCallback, Origin, form, nonce); rec.Code != 400 { |
| + t.Fatal("callback replay") |
| + } |
| + finishURL := directoryOrigin + callback.Header().Get("Location") |
| + if rec := exchangeRequest(p.directory, "GET", strings.Replace(finishURL, "team=red", "team=blue", 1), "", nil, nonce, directorySession); rec.Code != 400 { |
| + t.Fatal("team substitution", rec.Code) |
| + } |
| + if rec := exchangeRequest(p.directory, "GET", finishURL, "", nil, nonce, directorySession, directorySession); rec.Code != 400 { |
| + t.Fatal("ambiguous session") |
| + } |
| + finish := exchangeRequest(p.directory, "GET", finishURL, "", nil, nonce, directorySession) |
| + if finish.Code != 303 || calls != 1 { |
| + t.Fatal("finish", finish.Code, calls) |
| + } |
| + if rec := exchangeRequest(p.directory, "GET", finishURL, "", nil, nonce, directorySession); rec.Code != 400 { |
| + t.Fatal("finish replay") |
| + } |
| + page := exchangeRequest(p.directory, "GET", directoryOrigin+"/", "", nil, directorySession, preference) |
| + if page.Code != 200 || !strings.Contains(page.Body.String(), "Dashboard private title <script>") || strings.Contains(page.Body.String(), "https://blue.docs.oficina.works/") || calls != 1 { |
| + t.Fatal("selection, rendering, or cache failed", page.Code) |
| + } |
| + if strings.Contains(page.Body.String(), "Nothing scheduled") { |
| + t.Fatal("unconfigured calendar looks empty") |
| + } |
| + for _, path := range []string{p.credential.dbPath, p.directoryPath} { |
| + for _, suffix := range []string{"", "-wal"} { |
| + b, e := os.ReadFile(path + suffix) |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + for _, canary := range []string{"Dashboard private title", "private-canary", form.Get("assertion")} { |
| + if strings.Contains(string(b), canary) { |
| + t.Fatal("content retained on disk") |
| + } |
| + } |
| + } |
| + } |
| + if strings.Contains(p.logs.String(), "private title") || strings.Contains(p.logs.String(), "private-canary") { |
| + t.Fatal("content logged") |
| + } |
| + p.directory.dash.mu.Lock() |
| + p.directory.dash.sweep(time.Now().Add(121 * time.Second)) |
| + n := len(p.directory.dash.cache) |
| + p.directory.dash.mu.Unlock() |
| + if n != 0 { |
| + t.Fatal("hard expiry") |
| + } |
| +} |
| + |
| +func TestDashboardPullRejectsInvalidSourceData(t *testing.T) { |
| + p := newExchangePair(t) |
| + source := dashboardSource{"docs", "https://blue.docs.oficina.works"} |
| + team := dashboardTeam{ID: "blue", Sources: []dashboardSource{source}} |
| + good := dashboardTestBody(t, dashboard.Response{Version: 1, Team: "blue", Kind: "documents", Items: []dashboard.Item{}}) |
| + cases := []struct { |
| + name, body, cache string |
| + status int |
| + }{ |
| + {"valid", good, "private, no-store", 200}, |
| + {"missing items", `{"v":1,"team":"blue","kind":"documents"}`, "no-store", 200}, |
| + {"wrong team", strings.Replace(good, "blue", "red", 1), "no-store", 200}, |
| + {"oversized", strings.Repeat("x", dashboard.MaxBody+1), "no-store", 200}, |
| + {"malformed", "{", "no-store", 200}, |
| + {"cacheable", good, "public, no-store", 200}, |
| + {"fake cache directive", good, "x-no-store", 200}, |
| + {"redirect", good, "no-store", 302}, |
| + {"disconnected", "", "no-store", 403}, |
| + } |
| + for _, tc := range cases { |
| + t.Run(tc.name, func(t *testing.T) { |
| + p.directory.dash.client.Transport = dashboardTransport(func(r *http.Request) (*http.Response, error) { |
| + res := dashboardTestResponse(tc.body) |
| + res.StatusCode = tc.status |
| + res.Header.Set("Cache-Control", tc.cache) |
| + res.Header.Set("Location", "https://evil.invalid") |
| + return res, nil |
| + }) |
| + got := p.directory.pullDashboard(context.Background(), team, map[string]string{source.Origin: "token"}) |
| + if len(got) != 1 || (got[0].Status == "") != (tc.name == "valid") { |
| + t.Fatal("incorrect provider state") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestDashboardCacheDirectives(t *testing.T) { |
| + for _, s := range []string{"x-no-store", "public, no-store", "no-store, max-age=1", "no-store, s-maxage=1", "no-store=1"} { |
| + if dashboardNoStore([]string{s}) { |
| + t.Fatal("accepted", s) |
| + } |
| + } |
| + if !dashboardNoStore([]string{"private", "NO-STORE"}) { |
| + t.Fatal("rejected no-store") |
| + } |
| +} |
| + |
| +func TestDashboardDuplicateOriginRefused(t *testing.T) { |
| + p := newExchangePair(t) |
| + r := httptest.NewRequest("POST", directoryOrigin+dashboardCallback, strings.NewReader("assertion=x")) |
| + r.Header["Origin"] = []string{Origin, Origin} |
| + r.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + w := httptest.NewRecorder() |
| + p.directory.Router().ServeHTTP(w, r) |
| + if w.Code != 400 { |
| + t.Fatal(w.Code) |
| + } |
| +} |
diff --git a/internal/home/directory.go b/internal/home/directory.go| index 3c06ed7..8be4069 100644 |
| --- a/internal/home/directory.go |
| +++ b/internal/home/directory.go |
| @@ -54,6 +54,7 @@ func newDirectory(cfg Runtime, d *db.DB, logger *slog.Logger) (*App, error) { |
| if err != nil { |
| return nil, err |
| } |
| + a.dash = newDashboardState() |
| a.directory, err = a.newDirectoryFeatures() |
| if err != nil { |
| return nil, err |
| @@ -74,6 +75,7 @@ func (a *App) directoryRouter() http.Handler { |
| // This callback alone accepts a cross-origin POST, with its own exact issuer |
| // check and browser-bound finish. Every other mutation retains CSRF protection. |
| r.Post(handoff.CallbackPath, a.consumer.Callback) |
| + r.Post(dashboardCallback, a.receiveDashboard) |
| r.Group(func(r chi.Router) { |
| r.Use(csrf.Protect(a.origins.Directory)) |
| for _, chooser := range a.directory.choosers { |
| @@ -108,7 +110,7 @@ func (a *App) directoryRouter() http.Handler { |
| a.handleIndex(w, r) |
| return |
| } |
| - a.render(w, r, 200, "directory.html", map[string]any{"Apps": directoryCatalog(*a.runtime)}) |
| + a.handleDashboard(w, r) |
| }) |
| // The account menu's Appearance (spec §8.3): inside Protect, outside |
| // any session requirement, so a session that expired mid-page does |
diff --git a/internal/home/runtime.go b/internal/home/runtime.go| index 7c0d792..ecd6f39 100644 |
| --- a/internal/home/runtime.go |
| +++ b/internal/home/runtime.go |
| @@ -24,6 +24,7 @@ var errExchangeConfig = errors.New("home: invalid assertion configuration") |
| var directorySchema = migrate.Merge(sessions.Schema, migrate.MustFromFS(handoff.Migrations, "oficina_handoff"), directorydata.Schema, directorydata.RosterSchema) |
| type Runtime struct { |
| + dashboard []dashboardTeam |
| docsPreviewOrigin string |
| appPreviewOrigins map[string]string |
| roster rosterRuntime |
| @@ -148,6 +149,9 @@ func LoadRuntime(dbPath string, logger *slog.Logger) (Runtime, error) { |
| default: |
| return Runtime{}, errExchangeConfig |
| } |
| + if err := loadDashboardConfig(&cfg); err != nil { |
| + return Runtime{}, err |
| + } |
| return cfg, nil |
| } |
| func consumerName(s string) bool { |
diff --git a/internal/home/signin_return.go b/internal/home/signin_return.go| index 8363b65..05e08fc 100644 |
| --- a/internal/home/signin_return.go |
| +++ b/internal/home/signin_return.go |
| @@ -11,7 +11,7 @@ const returnTTL = 10 * time.Minute |
| func credentialReturn(value string) string { |
| switch value { |
| - case "/passkey/enrol", "/passkey/codes", "/authorize/resume": |
| + case "/passkey/enrol", "/passkey/codes", "/authorize/resume", "/dashboard/resume": |
| return value |
| } |
| return "/" |
diff --git a/internal/home/static/calma.css b/internal/home/static/calma.css| index 0e54152..11f2973 100644 |
| --- a/internal/home/static/calma.css |
| +++ b/internal/home/static/calma.css |
| @@ -84,3 +84,22 @@ div[home-app] img { filter: saturate(0.6); opacity: 0.8; } |
| /* The team chooser: one button per team, stacked. */ |
| [home-teams] { display: grid; justify-items: start; gap: var(--rst-sp-2); } |
| + |
| +/* The selected team's work takes priority over its compact app launcher. */ |
| +[home-apps-compact] { grid-template-columns: repeat(auto-fit, minmax(95px, 1fr)); gap: 8px; margin-bottom: 32px; } |
| +[home-apps-compact] [home-app] { padding: 12px 8px; gap: 5px; border-radius: 12px; } |
| +[home-apps-compact] img { margin: 0; } |
| +[home-apps-compact] small { font-size: .75rem; } |
| +[home-dashboard] { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 40px; } |
| +[home-dashboard] h2 { margin: 0 0 16px; } |
| +[home-recent] { margin: 0; padding: 0; list-style: none; } |
| +[home-recent] li { border-bottom: 1px solid var(--rst-line); } |
| +[home-recent] a { display: flex; flex-direction: column; gap: 5px; padding: 15px 8px; color: var(--rst-text); text-decoration: none; overflow-wrap: anywhere; border-radius: 8px; } |
| +[home-recent] a:hover { background: var(--rst-surface); } |
| +[home-recent] span, [home-recent] time, [home-dashboard-note] { color: var(--rst-text-muted); font-size: .875rem; } |
| +[home-dashboard-note] { line-height: 1.6; } |
| +[home-dashboard-sources] { border-top: 1px solid var(--rst-line); margin-top: 32px; padding-top: 16px; font-size: .875rem; } |
| +[home-team-nav] { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; } |
| +[home-team-nav] a { padding: 8px 12px; border-radius: 8px; } |
| +[home-team-nav] [aria-current] { background: var(--rst-surface); font-weight: 650; } |
| +@media (max-width: 700px) { [home-dashboard] { grid-template-columns: minmax(0, 1fr); gap: 32px; } } |
diff --git a/internal/home/templates/dashboard.html b/internal/home/templates/dashboard.html| new file mode 100644 |
| index 0000000..0af86c7 |
| --- /dev/null |
| +++ b/internal/home/templates/dashboard.html |
| @@ -0,0 +1,35 @@ |
| +{{define "title"}}{{.Data.Team.Name}} · Oficina{{end}} |
| +{{define "content"}} |
| +<header home-hub-head estilo-sky-host> |
| +{{template "estilo-sky" suiteSky}} |
| +<h1>{{.Data.Team.Name}}</h1> |
| +<p home-hub-lede>Your recent work and what’s coming up.</p> |
| +{{if gt (len .Data.Teams) 1}}<nav home-team-nav aria-label="Teams">{{range .Data.Teams}}<a href="/?team={{.ID}}" {{if eq .ID $.Data.Team.ID}}aria-current="page"{{end}}>{{.Name}}</a>{{end}}</nav>{{end}} |
| +</header> |
| +<nav aria-label="Apps"><ul home-apps home-apps-compact> |
| +{{range .Data.Apps}}<li>{{if .Href}}<a home-app href="{{.Href}}">{{else}}<div home-app>{{end}} |
| +<img src="{{.Icon}}" alt="" width="28" height="28"><b>{{.Name}}</b> |
| +{{if not .Href}}<small>{{.Status}}</small>{{end}} |
| +{{if .Href}}</a>{{else}}</div>{{end}}</li>{{end}} |
| +</ul></nav> |
| +<div home-dashboard> |
| +<section aria-labelledby="recent-heading"> |
| +<h2 id="recent-heading">Recent documents</h2> |
| +{{if .Data.Documents}}<ul home-recent>{{range .Data.Documents}} |
| +<li><a href="{{.URL}}"><b><bdi>{{if .Title}}{{.Title}}{{else}}Untitled{{end}}</bdi></b><span>{{.App}} · <time datetime="{{.DateTime}}">{{.When}}</time></span></a></li> |
| +{{end}}</ul>{{else if .Data.DocumentsComplete}}<p>No recent documents yet. Open an app to get started.</p>{{else}}<p>Your recent documents will appear here when the apps are connected and available.</p>{{end}} |
| +<p home-dashboard-note>The 20 most recently updated documents across your connected apps. Open an app for its full list.</p> |
| +</section> |
| +<section aria-labelledby="agenda-heading"> |
| +<h2 id="agenda-heading">Coming up</h2> |
| +<p home-dashboard-note>Today and the next seven days.</p> |
| +{{if .Data.Events}}<ul home-recent>{{range .Data.Events}} |
| +<li><a href="{{.URL}}"><time datetime="{{.DateTime}}">{{.When}}</time><b><bdi>{{if .Title}}{{.Title}}{{else}}Untitled event{{end}}</bdi></b><span><bdi>{{.Calendar}}</bdi></span></a></li> |
| +{{end}}</ul>{{else if .Data.EventsComplete}}<p>Nothing scheduled in this window.</p>{{else}}<p>Your agenda is unavailable right now.</p>{{end}} |
| +</section> |
| +</div> |
| +<section home-dashboard-sources aria-label="Connected apps"> |
| +{{range .Data.Sources}}{{if .Status}}<p><b>{{.Source.Name}}</b>: {{.Status}} <a href="{{.Source.Origin}}/">Open {{.Source.Name}}</a></p>{{else if .Response.Truncated}}<p><a href="{{.Source.Origin}}/">More in {{.Source.Name}}</a></p>{{end}}{{end}} |
| +<p><a href="/?team={{.Data.Team.ID}}">Refresh dashboard</a></p> |
| +</section> |
| +{{end}} |