console: getting-started card on the apps page
handleAccountHome computes liveness over every app (before the q filter), reads the viewer's CLI tokens and marks, stores completion, and renders the card from existing console components. A Show form sits beside the Trash link once the card is hidden or completed. The Copy buttons come from getting_started.js, allowed in the off-origin template check for this partial only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+435
−1
internal/console/gettingstarted.go+44 −0internal/console/gettingstarted_page_test.go+282 −0internal/console/icons_test.go+28 −1internal/console/server.go+10 −0internal/console/static/getting_started.js+20 −0internal/console/templates/apps.html+3 −0internal/console/templates/getting_started.html+48 −0
diff --git a/internal/console/gettingstarted.go b/internal/console/gettingstarted.go| index 98787f189..73a6a385a 100644 |
| --- a/internal/console/gettingstarted.go |
| +++ b/internal/console/gettingstarted.go |
| @@ -1,6 +1,7 @@ |
| package console |
| import ( |
| + "log" |
| "strings" |
| "time" |
| @@ -125,3 +126,46 @@ func buildGettingStarted(marks map[gsMark]bool, connected, anyLive bool, role st |
| Copy: c, |
| }, false |
| } |
| + |
| +// fillGettingStarted puts the Getting started card on the account home. |
| +// anyLive is appIsLive over every app in the account, not the filtered |
| +// lists. Only console-database reads: no bucket call. A failed read never |
| +// fails the page: unread tokens leave step 1 open, unread marks show no |
| +// card and no Show link. |
| +func (s *Server) fillGettingStarted(p *page, acct *Account, addr, role string, anyLive bool) { |
| + now := time.Now() |
| + connected := false |
| + if tokens, err := s.store.CLITokens(addr); err != nil { |
| + log.Printf("console: getting started tokens %s: %v", acct.Sqid, err) |
| + } else { |
| + connected = personConnected(tokens, now) |
| + } |
| + marks, err := s.store.GettingStartedMarks(acct.ID, addr) |
| + if err != nil { |
| + log.Printf("console: getting started marks %s: %v", acct.Sqid, err) |
| + return |
| + } |
| + // The domain link names the first app the page lists. |
| + firstApp := "" |
| + starred, regular, temporary := partitionApps(p.Apps) |
| + for _, rows := range [][]appRow{starred, regular, temporary} { |
| + if len(rows) > 0 { |
| + firstApp = rows[0].App |
| + break |
| + } |
| + } |
| + view, complete := buildGettingStarted(marks, connected, anyLive, role, firstApp, s.consoleName()) |
| + if complete { |
| + if err := s.store.SetGettingStartedMark(acct.ID, addr, gsCompleted, now); err != nil { |
| + log.Printf("console: getting started completed %s: %v", acct.Sqid, err) |
| + } |
| + p.ShowGettingStarted = true |
| + return |
| + } |
| + p.GettingStarted = view |
| + p.ShowGettingStarted = view == nil |
| +} |
| + |
| +// GettingStartedCopy is the card's strings, for the Show link the page |
| +// offers when there is no card to carry them. |
| +func (p page) GettingStartedCopy() gettingStartedCopy { return approvedGettingStartedCopy } |
diff --git a/internal/console/gettingstarted_page_test.go b/internal/console/gettingstarted_page_test.go| new file mode 100644 |
| index 000000000..12ee8c941 |
| --- /dev/null |
| +++ b/internal/console/gettingstarted_page_test.go |
| @@ -0,0 +1,282 @@ |
| +package console |
| + |
| +import ( |
| + "context" |
| + "net/http" |
| + "net/url" |
| + "regexp" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// gsRenderedState reads one step's rendered state off the account home, "" |
| +// when the card or the step is absent. |
| +func gsRenderedState(body, key string) string { |
| + m := regexp.MustCompile(`data-gs-step="` + key + `" data-gs-state="([a-z]+)"`).FindStringSubmatch(body) |
| + if m == nil { |
| + return "" |
| + } |
| + return m[1] |
| +} |
| + |
| +func gsCardShown(body string) bool { return strings.Contains(body, `id="getting-started"`) } |
| + |
| +// gsStaticSite gives the fixture account a static-only app the real way: a |
| +// console app row, a registry static route on the app's own stable channel, |
| +// and a signed stable pointer in the bucket. No instance reports anything, |
| +// so only the static branch of appIsLive can tick it. |
| +func gsStaticSite(t *testing.T, fx *consoleFixture, app string) { |
| + t.Helper() |
| + if _, err := fx.st.CreateAppIn(OpsAccountID, app, "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + reg, err := registry.Open(fx.regPath) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer reg.Close() |
| + if err := reg.Upsert(registry.Route{Host: app + ".carlosapp.dev", Kind: "static", Status: "ready", App: app, Channel: "stable"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + ctx := context.Background() |
| + m := release.Manifest{ |
| + Schema: 1, App: app, Version: "s1", Kind: "binary", BuiltAt: "2026-11-01T10:00:00Z", |
| + Artifacts: map[string]release.Artifact{"linux-amd64": {File: app}}, |
| + } |
| + if err := release.Ship(ctx, fx.rel, release.OpsAccount, m, map[string][]byte{"linux-amd64": []byte("site")}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := release.Promote(ctx, fx.rel, fx.priv, release.OpsAccount, app, "stable", "s1"); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +func gsHome(t *testing.T, fx *consoleFixture, c *http.Client, q string) string { |
| + t.Helper() |
| + u := fx.u("/") |
| + if q != "" { |
| + u += "?q=" + url.QueryEscape(q) |
| + } |
| + status, _, body := get(t, c, u) |
| + if status != http.StatusOK { |
| + t.Fatalf("GET %s = %d:\n%s", u, status, body) |
| + } |
| + return body |
| +} |
| + |
| +// A brand-new account with nobody connected: the card leads with Connect, |
| +// open, its prompt carrying this console's own name. |
| +func TestGettingStartedCardFresh(t *testing.T) { |
| + fx := newConsoleFixtureWith(t, consoleFixtureOptions{WithKey: true, Tweak: func(c *Config) { c.ConsoleName = "Example Cloud" }}) |
| + const newID = 4243 |
| + if err := fx.st.CreateAccount(newID, "cdef", "Fresh", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := fx.st.AddMember(newID, "paul@keymail.dev", RoleOwner, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + paul, _ := signInAs(t, fx, "paul@keymail.dev", "code-gs-fresh") |
| + status, _, body := get(t, paul, fx.ts.URL+"/a/cdef/") |
| + if status != http.StatusOK { |
| + t.Fatalf("GET fresh account = %d", status) |
| + } |
| + if !gsCardShown(body) { |
| + t.Fatalf("no Getting started card on a fresh account:\n%s", body) |
| + } |
| + for key, want := range map[string]string{"connect": "open", "deploy": "muted", "secrets": "muted", "domain": "muted"} { |
| + if got := gsRenderedState(body, key); got != want { |
| + t.Errorf("step %s = %q, want %q", key, got, want) |
| + } |
| + } |
| + prompt := `<code id="gs-prompt-connect">Sign in to Example Cloud with the carlos CLI: run carlos auth login --no-wait and give me the link it prints.</code>` |
| + if !strings.Contains(body, prompt) { |
| + t.Errorf("connect prompt missing or wrong; want %s", prompt) |
| + } |
| + if !strings.Contains(body, `data-copy-target="gs-prompt-connect"`) || !strings.Contains(body, `<script src="`+assetURL("getting_started.js")+`"></script>`) { |
| + t.Error("the prompt has no copy button, or the copy script is not loaded") |
| + } |
| + for _, bad := range []string{"Carloku", "{console}"} { |
| + if strings.Contains(body, bad) { |
| + t.Errorf("page contains %q", bad) |
| + } |
| + } |
| + // Dashes: the page's own chrome uses em dashes elsewhere, so check the |
| + // card alone. |
| + card := gsCard(t, body) |
| + for _, bad := range []string{"—", "–", "Carloku", "{console}"} { |
| + if strings.Contains(card, bad) { |
| + t.Errorf("card contains %q:\n%s", bad, card) |
| + } |
| + } |
| + if !strings.Contains(card, `name="csrf" value="`) { |
| + t.Error("the Hide form carries no csrf") |
| + } |
| +} |
| + |
| +// gsCard is the card's markup alone. |
| +func gsCard(t *testing.T, body string) string { |
| + t.Helper() |
| + _, rest, ok := strings.Cut(body, `id="getting-started"`) |
| + if !ok { |
| + t.Fatal("no card") |
| + } |
| + card, _, ok := strings.Cut(rest, "</section>") |
| + if !ok { |
| + t.Fatal("card never closes") |
| + } |
| + return card |
| +} |
| + |
| +// Liveness is over every app, never the filtered lists: a static-only site |
| +// ticks step 2 through the real view wiring, and a filter that hides it |
| +// does not untick it. |
| +func TestGettingStartedIgnoresFilter(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + paul, _ := signInAs(t, fx, "paul@keymail.dev", "code-gs-filter") |
| + // The fixture's kass reports v1; a failed instance takes it off live. |
| + reg, err := registry.Open(fx.regPath) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.Upsert(registry.Route{Host: "kass.carlosapp.dev", Kind: "instance", Status: "failed", |
| + Version: "v1", App: "kass", Channel: "stable", Addr: "127.0.0.1:9001"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + reg.Close() |
| + if got := gsRenderedState(gsHome(t, fx, paul, ""), "deploy"); got != "muted" { |
| + t.Fatalf("deploy before any live app = %q, want muted", got) |
| + } |
| + gsStaticSite(t, fx, "site") |
| + for _, q := range []string{"", "zzz"} { |
| + body := gsHome(t, fx, paul, q) |
| + if got := gsRenderedState(body, "deploy"); got != "done" { |
| + t.Fatalf("q=%q: deploy = %q, want done", q, got) |
| + } |
| + if got := gsRenderedState(body, "connect"); got != "open" { |
| + t.Fatalf("q=%q: connect = %q, want open", q, got) |
| + } |
| + } |
| +} |
| + |
| +func TestGettingStartedHiddenShowsLink(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + paul, _ := signInAs(t, fx, "paul@keymail.dev", "code-gs-hidden") |
| + show := `action="` + fx.path("/getting-started/show") + `"` |
| + body := gsHome(t, fx, paul, "") |
| + if !gsCardShown(body) || strings.Contains(body, show) { |
| + t.Fatal("before hiding: want the card and no Show form") |
| + } |
| + if err := fx.st.SetGettingStartedMark(OpsAccountID, "paul@keymail.dev", gsHidden, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + body = gsHome(t, fx, paul, "") |
| + if gsCardShown(body) { |
| + t.Fatal("hidden card still rendered") |
| + } |
| + if !strings.Contains(body, show) || !strings.Contains(body, approvedGettingStartedCopy.Show) { |
| + t.Fatalf("no Show getting started form:\n%s", body) |
| + } |
| +} |
| + |
| +func TestGettingStartedCompletionSticks(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + gsStaticSite(t, fx, "site") |
| + cliToken(t, fx, "paul@keymail.dev", "code-gs-done-cli") |
| + paul, csrf := signInAs(t, fx, "paul@keymail.dev", "code-gs-done") |
| + for _, m := range []gsMark{gsSecretsDone, gsDomainSkip} { |
| + if err := fx.st.SetGettingStartedMark(OpsAccountID, "paul@keymail.dev", m, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + body := gsHome(t, fx, paul, "") |
| + if gsCardShown(body) { |
| + t.Fatal("a complete checklist still shows") |
| + } |
| + if !gsMarksOf(t, fx, "paul@keymail.dev")[gsCompleted] { |
| + t.Fatal("completion was not stored") |
| + } |
| + if !strings.Contains(body, fx.path("/getting-started/show")) { |
| + t.Error("no Show form after completion") |
| + } |
| + // The token expires: the stored completion keeps the card away. |
| + if _, err := fx.st.db.Exec(`UPDATE cli_tokens SET expires_at = ? WHERE address = ?`, time.Now().Add(-time.Hour).Unix(), "paul@keymail.dev"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if gsCardShown(gsHome(t, fx, paul, "")) { |
| + t.Fatal("card came back after a fact changed") |
| + } |
| + // Show clears it: the live state again, connect open. |
| + if status, _ := gsPost(t, fx, paul, "show", url.Values{"csrf": {csrf}}); status != http.StatusSeeOther { |
| + t.Fatalf("show = %d", status) |
| + } |
| + body = gsHome(t, fx, paul, "") |
| + if got := gsRenderedState(body, "connect"); got != "open" { |
| + t.Fatalf("after show, connect = %q, want open", got) |
| + } |
| + if got := gsRenderedState(body, "deploy"); got != "done" { |
| + t.Fatalf("after show, deploy = %q, want done", got) |
| + } |
| +} |
| + |
| +// Browser domain attach is owner-only: with the domain step open, the owner |
| +// gets the settings link, a member only the CLI route. |
| +func TestGettingStartedMemberNoDomainLink(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + if err := fx.st.AddMember(OpsAccountID, "kim@keymail.dev", RoleMember, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + gsStaticSite(t, fx, "site") |
| + link := fx.path("/apps/kass/settings/domains") |
| + for _, who := range []struct { |
| + addr string |
| + want bool |
| + }{{"paul@keymail.dev", true}, {"kim@keymail.dev", false}} { |
| + cliToken(t, fx, who.addr, "code-gs-dom-cli-"+who.addr) |
| + c, _ := signInAs(t, fx, who.addr, "code-gs-dom-"+who.addr) |
| + if err := fx.st.SetGettingStartedMark(OpsAccountID, who.addr, gsSecretsSkip, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + body := gsHome(t, fx, c, "") |
| + if got := gsRenderedState(body, "domain"); got != "open" { |
| + t.Fatalf("%s: domain = %q, want open", who.addr, got) |
| + } |
| + card := gsCard(t, body) |
| + if got := strings.Contains(card, link); got != who.want { |
| + t.Errorf("%s: domain link present = %v, want %v", who.addr, got, who.want) |
| + } |
| + if !strings.Contains(card, "carlos domains attach --app <app> <hostname>") { |
| + t.Errorf("%s: no CLI route on the domain step", who.addr) |
| + } |
| + if !strings.Contains(card, fx.path("/getting-started/done")) || !strings.Contains(card, fx.path("/getting-started/skip")) { |
| + t.Errorf("%s: no Mark done / Skip forms", who.addr) |
| + } |
| + } |
| +} |
| + |
| +// The card reads only the console database: rendering it costs no S3 |
| +// request beyond what the page already makes. |
| +func TestGettingStartedNoS3(t *testing.T) { |
| + lat := &perfLatency{} |
| + fx := newConsoleFixtureWith(t, consoleFixtureOptions{WithKey: true, S3: lat}) |
| + paul, _ := signInAs(t, fx, "paul@keymail.dev", "code-gs-s3") |
| + count := func() int64 { |
| + t.Helper() |
| + before, _ := lat.Calls() |
| + gsHome(t, fx, paul, "") |
| + after, _ := lat.Calls() |
| + return after - before |
| + } |
| + count() // warm whatever the page caches |
| + withCard := count() |
| + if err := fx.st.SetGettingStartedMark(OpsAccountID, "paul@keymail.dev", gsHidden, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + without := count() |
| + if withCard != without { |
| + t.Fatalf("S3 requests with the card = %d, without = %d", withCard, without) |
| + } |
| +} |
diff --git a/internal/console/icons_test.go b/internal/console/icons_test.go| index 12fa98230..a252f7c06 100644 |
| --- a/internal/console/icons_test.go |
| +++ b/internal/console/icons_test.go |
| @@ -62,7 +62,8 @@ func TestSwitcherChromeIsInlineSVGNotTextGlyphs(t *testing.T) { |
| // loads Rastrillo's stylesheets and scripts, and it loads them from this |
| // origin only, through the {{asset "..."}} template func (/static/{hash}/...). |
| // sameOriginAssetTags is the exact shape it may use. The demo claim page |
| -// may load only its embedded demo_claim.js through the same asset helper. |
| +// may load only its embedded demo_claim.js through the same asset helper, |
| +// and the Getting started card only its getting_started.js. |
| // Its shared console styles are inline and covered by an exact CSP hash. |
| func TestConsoleTemplatesFetchNothingOffOrigin(t *testing.T) { |
| err := fs.WalkDir(tmplFS, ".", func(path string, d fs.DirEntry, err error) error { |
| @@ -133,6 +134,9 @@ func offOriginFetches(path, src string) []string { |
| if path == "templates/demo_claim.html" { |
| src = strings.ReplaceAll(src, `<script src="{{asset "demo_claim.js"}}"></script>`, "") |
| } |
| + if path == "templates/getting_started.html" { |
| + src = strings.ReplaceAll(src, `<script src="{{asset "getting_started.js"}}"></script>`, "") |
| + } |
| var found []string |
| for _, bad := range banned { |
| if strings.Contains(src, bad) { |
| @@ -244,3 +248,26 @@ func TestDemoClaimTemplateRefusesOtherSubresources(t *testing.T) { |
| } |
| } |
| } |
| + |
| +func TestGettingStartedTemplateRefusesOtherSubresources(t *testing.T) { |
| + const path = "templates/getting_started.html" |
| + const allowed = `<script src="{{asset "getting_started.js"}}"></script>` |
| + if got := offOriginFetches(path, allowed); len(got) != 0 { |
| + t.Fatal(got) |
| + } |
| + for _, tag := range []string{ |
| + `<script src="https://example.com/getting_started.js"></script>`, |
| + `<script src="{{asset "https://example.com/getting_started.js"}}"></script>`, |
| + `<script src="{{asset "getting_started.js"}}" data-url="https://example.com"></script>`, |
| + `<script src="{{asset "demo_claim.js"}}"></script>`, |
| + `<link rel="stylesheet" href="{{asset "ops.css"}}">`, |
| + } { |
| + if got := offOriginFetches(path, allowed+tag); len(got) == 0 { |
| + t.Errorf("allowed %s", tag) |
| + } |
| + } |
| + // The allowance is this template's alone. |
| + if got := offOriginFetches("templates/apps.html", allowed); len(got) == 0 { |
| + t.Error("apps.html may load getting_started.js directly") |
| + } |
| +} |
diff --git a/internal/console/server.go b/internal/console/server.go| index 06f41be0e..799359a79 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -2648,6 +2648,12 @@ type page struct { |
| Trashed []TrashedAppView |
| TrashN int |
| + // The account home's Getting started card (gettingstarted.go), nil when |
| + // it does not show; ShowGettingStarted offers the link that brings back |
| + // a card the viewer hid or completed. |
| + GettingStarted *gettingStartedView |
| + ShowGettingStarted bool |
| + |
| // ExpiresAt is when a temporary app moves to the Trash; zero for a |
| // permanent one. appnav shows it with the Keep button. |
| ExpiresAt time.Time |
| @@ -4267,6 +4273,7 @@ func (s *Server) handleAccountHome(w http.ResponseWriter, r *http.Request) { |
| s.renderMessage(w, r, http.StatusInternalServerError, "Error", "Could not read your apps. Please try again.") |
| return |
| } |
| + anyLive := false |
| if len(apps) > 0 { |
| views, err := s.assembleAppsNamed(r.Context(), acct.Sqid, acct.Name, apps) |
| if err != nil { |
| @@ -4280,6 +4287,8 @@ func (s *Server) handleAccountHome(w http.ResponseWriter, r *http.Request) { |
| row.Region = s.regionFactsFor(acct, v.App, v.routeFleet, true) |
| row.Elsewhere = elsewhereCounts(v.Routes, acct.Sqid, row.Region) |
| p.Apps = append(p.Apps, row) |
| + // Over every app, before the q filter narrows the lists. |
| + anyLive = anyLive || appIsLive(row, v, acct.Sqid) |
| } |
| // The viewer's stars, the expiries and the q filter (applist.go). |
| if err := s.fillAppLists(&p, acct, addr, r.URL.Query().Get("q")); err != nil { |
| @@ -4295,6 +4304,7 @@ func (s *Server) handleAccountHome(w http.ResponseWriter, r *http.Request) { |
| } else { |
| p.TrashN = len(trashed) |
| } |
| + s.fillGettingStarted(&p, acct, addr, role, anyLive) |
| s.render(w, http.StatusOK, "apps", p) |
| } |
diff --git a/internal/console/static/getting_started.js b/internal/console/static/getting_started.js| new file mode 100644 |
| index 000000000..264821312 |
| --- /dev/null |
| +++ b/internal/console/static/getting_started.js |
| @@ -0,0 +1,20 @@ |
| +(() => { |
| + "use strict"; |
| + // The Getting started card's Copy buttons (templates/getting_started.html): |
| + // hidden until this runs, so with JavaScript off the prompt is plain, |
| + // selectable text and no dead button shows. The loop is demo_claim.js's. |
| + for (const copy of document.querySelectorAll("#getting-started [data-copy-target]")) { |
| + const command = document.getElementById(copy.dataset.copyTarget); |
| + if (!command || typeof navigator.clipboard?.writeText !== "function") continue; |
| + copy.hidden = false; |
| + let reset; |
| + copy.addEventListener("click", async () => { |
| + try { |
| + await navigator.clipboard.writeText(command.textContent); |
| + copy.textContent = copy.dataset.copied; |
| + clearTimeout(reset); |
| + reset = setTimeout(() => { copy.textContent = copy.dataset.copy; }, 2000); |
| + } catch (_) { copy.hidden = true; } |
| + }); |
| + } |
| +})(); |
diff --git a/internal/console/templates/apps.html b/internal/console/templates/apps.html| index b5afd9792..771bdca81 100644 |
| --- a/internal/console/templates/apps.html |
| +++ b/internal/console/templates/apps.html |
| @@ -7,6 +7,7 @@ |
| {{if .Apps}} |
| <h1>Apps</h1> |
| </div> |
| +{{template "getting_started" .}} |
| <form class="app-filter" method="get" action="{{.Base}}/"> |
| <label for="app-filter">{{.AppListCopy.Filter}}</label> |
| <input id="app-filter" name="q" type="search" value="{{.AppFilter}}" placeholder="{{.AppListCopy.FilterPlaceholder}}" autocomplete="off" aria-controls="app-lists"> |
| @@ -67,10 +68,12 @@ |
| {{else}} |
| <h1>Welcome to {{.ConsoleName}}</h1> |
| </div> |
| +{{template "getting_started" .}} |
| <p>The account <strong>{{.Account.Name}}</strong> is ready. No apps live here yet — claim a name below and it's yours.</p> |
| {{end}} |
| {{if .TrashN}}<p class="small"><a href="{{.Nav}}/trash">Trash ({{.TrashN}})</a>: deleted apps you can still |
| restore, each until the date shown there.</p>{{end}} |
| +{{template "getting_started_show" .}} |
| <p><a class="btn" href="{{.Nav}}/apps/new">Create app</a></p> |
| <style> |
diff --git a/internal/console/templates/getting_started.html b/internal/console/templates/getting_started.html| new file mode 100644 |
| index 000000000..10ce6d3a0 |
| --- /dev/null |
| +++ b/internal/console/templates/getting_started.html |
| @@ -0,0 +1,48 @@ |
| +{{define "getting_started"}}{{with .GettingStarted}}{{$c := .Copy}} |
| +<section class="confirm-card gs-card" id="getting-started" aria-labelledby="gs-title"> |
| +<div class="sectionhead"><h2 id="gs-title">{{$c.Title}}</h2> |
| +<form method="post" action="{{$.Base}}/getting-started/hide"><input type="hidden" name="csrf" value="{{$.CSRF}}"><button class="linkish" type="submit">{{$c.Hide}}</button></form></div> |
| +<ol class="gs-steps"> |
| +{{range .Steps}}<li class="gs-step" data-gs-step="{{.Key}}" data-gs-state="{{.State}}"{{if eq .State "open"}} aria-current="step"{{end}}> |
| +{{if eq .State "done"}}<span class="chip chip-health-ok">{{$c.Done}}</span> <span class="gs-title">{{.Title}}</span> |
| +{{else if eq .State "skipped"}}<span class="chip chip-env">{{$c.Skipped}}</span> <span class="gs-title">{{.Title}}</span> |
| +{{else if eq .State "muted"}}<span class="gs-title small">{{.Title}}</span> |
| +{{else}}<strong class="gs-title">{{.Title}}</strong> |
| +<p>{{.Body}}</p> |
| +{{if .Prompt}}<div class="gs-paste"><code id="gs-prompt-{{.Key}}">{{.Prompt}}</code><button class="btn-sm btn-secondary" type="button" data-copy-target="gs-prompt-{{.Key}}" data-copy="{{$c.Copy}}" data-copied="{{$c.Copied}}" aria-live="polite" hidden>{{$c.Copy}}</button></div>{{end}} |
| +{{if .CLI}}<div class="gs-paste"><code id="gs-cli-{{.Key}}">{{.CLI}}</code><button class="btn-sm btn-secondary" type="button" data-copy-target="gs-cli-{{.Key}}" data-copy="{{$c.Copy}}" data-copied="{{$c.Copied}}" aria-live="polite" hidden>{{$c.Copy}}</button></div>{{end}} |
| +{{if or (and (eq .Key "deploy") $.GettingStarted.CanCreate) (eq .Key "secrets") (eq .Key "domain")}}<div class="gs-actions"> |
| +{{if and (eq .Key "deploy") $.GettingStarted.CanCreate}}<a class="btn btn-sm btn-secondary" href="{{$.Nav}}/apps/new">{{$c.DeployCreate}}</a>{{end}} |
| +{{if and (eq .Key "domain") $.GettingStarted.IsOwner $.GettingStarted.DomainApp}}<a class="btn btn-sm btn-secondary" href="{{$.Base}}/apps/{{$.GettingStarted.DomainApp}}/settings/domains">{{$c.DomainLink}}</a>{{end}} |
| +{{if or (eq .Key "secrets") (eq .Key "domain")}}<form method="post" action="{{$.Base}}/getting-started/done"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="step" value="{{.Key}}"><button class="btn-sm" type="submit">{{$c.MarkDone}}</button></form> |
| +<form method="post" action="{{$.Base}}/getting-started/skip"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="step" value="{{.Key}}"><button class="btn-sm btn-secondary" type="submit">{{$c.Skip}}</button></form>{{end}} |
| +</div>{{end}} |
| +{{end}}</li> |
| +{{end}}</ol> |
| +</section> |
| +<style> |
| +.gs-card { margin: 1rem 0 1.5rem; } |
| +.gs-card .sectionhead { margin: 0; } |
| +.gs-card .sectionhead form { margin: 0; } |
| +.gs-card .sectionhead button.linkish { min-height: 40px; min-width: 40px; } |
| +.gs-steps { margin: 0.5rem 0 0; padding-left: 1.5rem; } |
| +.gs-steps > li { padding: 0.6rem 0; } |
| +.gs-steps > li + li { border-top: 1px solid var(--rule); } |
| +.gs-steps .chip { margin: 0 0.4rem 0 0; } |
| +.gs-steps strong.gs-title { display: block; } |
| +.gs-steps p { margin: 0.35rem 0 0.75rem; } |
| +.gs-paste { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.75rem; margin: 0 0 0.6rem; padding: 0.6rem; border: 1px solid var(--rule); border-radius: var(--rst-radius-sm); background: var(--rst-surface-2); } |
| +.gs-paste code { background: transparent; padding: 0; white-space: normal; overflow-wrap: anywhere; font-size: 0.84rem; } |
| +.gs-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; } |
| +.gs-actions form { margin: 0; } |
| +.gs-card .btn-sm { display: inline-flex; align-items: center; min-height: 40px; font-size: 0.85rem; } |
| +@media (max-width: 30rem) { |
| +.gs-paste { grid-template-columns: minmax(0, 1fr); } |
| +.gs-paste button { justify-self: start; } |
| +} |
| +</style> |
| +<script src="{{asset "getting_started.js"}}"></script> |
| +{{end}}{{end}} |
| + |
| +{{define "getting_started_show"}}{{if .ShowGettingStarted}}<form class="gs-show small" method="post" action="{{.Base}}/getting-started/show"><input type="hidden" name="csrf" value="{{.CSRF}}"><button class="linkish" type="submit">{{.GettingStartedCopy.Show}}</button></form> |
| +<style>.gs-show { margin: 0 0 1rem; }.gs-show button.linkish { min-height: 40px; }</style>{{end}}{{end}} |