console: Domains page and a domain's own page
A Domains item in the account nav, between Apps and Fleet, opens
GET /a/{sqid}/domains: tiles for addresses live and the next expiry, then
one card per registrable domain (bought here with its expiry and next
year's price, being bought with a link to its purchase card, or
registered elsewhere), each with its addresses, app and state chip. The
owner gets Buy a domain (when buying is configured), Add a domain you own
(one button per app, posting to that app's attach door) and the saved
contacts list.
GET /a/{sqid}/domains/{domain} is the domain's page: chips, tiles, the
addresses with Detach (each app's own detach door), Point at an app for
an unpointed bought domain (each app's point door), Registered to and the
managed-records line; a domain registered elsewhere lists the records
still to set, from domainRecords and domainGuidance. A segment that is
not a registrable domain, or not this account's, is the same 404.
Neither page is gated on buying or HostClaim. App settings links to the
account's domains and buys through /a/{sqid}/domains/buy?app= (Task 9).
Route registers, parity rows, perf records and the census list (which
also drops nine buy-door lines left from Task 4's gating) are updated;
the mockup kit shell is regenerated. Copy is a draft.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 files changed,
+1,295
−20
.amadan/code-health.tsv+1 −1docs/console-mockup-kit/shell.html+9 −0docs/parity.md+4 −2internal/console/accountdomains_copy.go+109 −0internal/console/accountdomainspage.go+488 −0internal/console/accountdomainspage_test.go+487 −0internal/console/apidomainbuy_test.go+1 −1internal/console/claim_invariant_fixtures_test.go+2 −0internal/console/claim_invariant_probes_read_test.go+4 −1internal/console/mobilenav.go+1 −0internal/console/mobilenav_test.go+2 −1internal/console/perfwalk_test.go+2 −0internal/console/routedecls.go+5 −0internal/console/server.go+4 −4internal/console/templates/account_domain.html+73 −0internal/console/templates/account_domains.html+85 −0internal/console/templates/app_settings.html+2 −1internal/console/templates/console_chrome.html+10 −0internal/console/testdata/claim-routes.txt+2 −9internal/console/testdata/perf-budgets.txt+2 −0parity/parity.tsv+2 −0
diff --git a/.amadan/code-health.tsv b/.amadan/code-health.tsv| index 407c61ca6..26514eedb 100644 |
| --- a/.amadan/code-health.tsv |
| +++ b/.amadan/code-health.tsv |
| @@ -2229,7 +2229,7 @@ file-lines . apimode.go - 4199 |
| file-lines . apimode_test.go - 3530 # raised: fdc912b (batch 2, #1123) landed before the ratchet; tests for the system update refusals |
| file-lines internal/activator activator.go - 3778 |
| file-lines internal/activator activator_test.go - 5499 |
| -file-lines internal/console server.go - 4219 |
| +file-lines internal/console server.go - 4218 |
| file-lines internal/host agent.go - 3214 |
| file-lines internal/provision reconcile_test.go - 3094 |
| file-lines internal/registry registry_test.go - 3261 |
diff --git a/docs/console-mockup-kit/shell.html b/docs/console-mockup-kit/shell.html| index 81a499f81..5ad1b70ff 100644 |
| --- a/docs/console-mockup-kit/shell.html |
| +++ b/docs/console-mockup-kit/shell.html |
| @@ -412,6 +412,14 @@ |
| .envvar-panel { padding: 0 0.9rem 0.6rem; } |
| .envvar-panel .settings-row { margin: 0; } |
| .envvar-panel input[type=text], .envvar-panel input[type=password] { flex: 1; min-width: 8rem; } |
| + |
| + .domain-head { flex-wrap: wrap; row-gap: 0.2rem; background-color: var(--panel-cool); border-bottom: 1px solid var(--rule); } |
| + .domain-head .envvar-name { font-weight: 600; } |
| + .domain-head .envvar-value { flex: 1 1 14rem; white-space: normal; } |
| + .domain-head .chip { margin: 0; } |
| + |
| + .addr-rows .envvar > summary, .addr-rows .envvar-row { flex-wrap: wrap; row-gap: 0.3rem; } |
| + .addr-rows .envvar-value { flex: 1 0 auto; } |
| .envhead { margin: 1.75rem 0 0.15rem; } |
| .envhead + .small { margin: 0 0 0.6rem; } |
| .addvar { margin: 0.6rem 0 0.25rem; } |
| @@ -1171,6 +1179,7 @@ |
| <div class="mobile-back"><a href="/a/shop/index#nav-apps" rel="up">shop</a></div> |
| <nav> |
| <span class="account-links"><a href="/a/shop/" aria-current="page">Apps</a> |
| + <a href="/a/shop/domains">Domains</a> |
| <a href="/a/shop/fleet">Fleet</a> |
| <a href="/a/shop/team">Team</a> |
| <a href="/a/shop/settings">Settings</a> |
diff --git a/docs/parity.md b/docs/parity.md| index 90f838def..cef8a5a11 100644 |
| --- a/docs/parity.md |
| +++ b/docs/parity.md |
| @@ -14,8 +14,8 @@ CLI rows are checked against the command registry (`parity/cli.tsv`). |
| | partial | 9 | |
| | gap | 65 | |
| | cli-only | 17 | |
| -| console-only | 18 | |
| -| Total | 153 | |
| +| console-only | 20 | |
| +| Total | 155 | |
| ## account |
| @@ -103,6 +103,8 @@ CLI rows are checked against the command registry (`parity/cli.tsv`). |
| | Row | Status | CLI | Console | Package | Note | |
| |---|---|---|---|---|---| |
| | domains-list | both | `domains list` | `GET /a/{sqid}/apps/{app}/settings/{section}` | | | |
| +| domains-account | console-only | | `GET /a/{sqid}/domains` | | The account's domains, bought here and registered elsewhere; the CLI list comes later. | |
| +| domains-account-page | console-only | | `GET /a/{sqid}/domains/{domain}` | | One domain's addresses, expiry and the records to set; the CLI list comes later. | |
| | domains-attach | both | `domains attach`<br>`domains detach` | `POST /a/{sqid}/apps/{app}/domains/attach`<br>`POST /a/{sqid}/apps/{app}/domains/detach` | | | |
| | domains-verify | partial | `domains verify` | `POST /a/{sqid}/apps/{app}/domains/attach` | | There is no Verify button; attaching again verifies. | |
| | domains-buy | both | `domains check`<br>`domains buy` | `GET /a/{sqid}/apps/{app}/domains/buy`<br>`POST /a/{sqid}/apps/{app}/domains/check`<br>`POST /a/{sqid}/apps/{app}/domains/buy`<br>`GET /a/{sqid}/apps/{app}/domains/purchases/{id}`<br>`GET /a/{sqid}/apps/{app}/domains/purchases/{id}/status` | | | |
diff --git a/internal/console/accountdomains_copy.go b/internal/console/accountdomains_copy.go| new file mode 100644 |
| index 000000000..d9bd6b2a6 |
| --- /dev/null |
| +++ b/internal/console/accountdomains_copy.go |
| @@ -0,0 +1,109 @@ |
| +package console |
| + |
| +// The account's Domains page and a domain's own page (Plan 2a Task 8). |
| +// |
| +// DRAFTS (2026-11-19), awaiting the copy pass (Plan 2a Task 11). Plain and |
| +// short; no registrar or DNS host is named, and nothing says a domain |
| +// renews (renewals are Plan 3). {placeholders} are filled by the page. |
| +var domainsPageCopy = struct { |
| + Title, Eyebrow, PageEyebrow string |
| + TileLive, TileLiveValue, TileNotLive string |
| + TileNextExpiry string |
| + CountOne, CountMany string |
| + Buy, AddOwn, Add, Close string |
| + AddHost, AddHostPlaceholder, AttachTo, AttachToApp string |
| + NoApps string |
| + EmptyTitle, EmptyLede, EmptyLedeAdd string |
| + BoughtHere, Elsewhere, Buying, NotPointed string |
| + ExpiresLine, NextYearLine, FollowPurchase string |
| + PointAtApp, PointTo, PointToApp, PointNote string |
| + InTrash string |
| + Contacts, ContactsNote, ContactsEmpty string |
| + Unread, NotFound string |
| + Addresses, Detach, DetachLabel, DetachPlaceholder string |
| + TileExpires, TileExpired, TilePrice string |
| + InDays, InWeeks string |
| + ChangeCard string |
| + RegisteredTo, Name, Email, Country string |
| + DNS, DNSManaged string |
| + RecordsToSet, RecordsNote, Or string |
| + RecordName, RecordType, RecordValue string |
| + AllDomains string |
| +}{ |
| + Title: "Domains", |
| + Eyebrow: "Account · {account}", |
| + PageEyebrow: "Domains · {account}", |
| + TileLive: "Addresses live", |
| + TileLiveValue: "{live} of {total}", |
| + TileNotLive: "{n} not live yet", |
| + TileNextExpiry: "Next expiry", |
| + CountOne: "1 domain", |
| + CountMany: "{n} domains", |
| + Buy: "Buy a domain", |
| + AddOwn: "Add a domain you own", |
| + Add: "Add", |
| + Close: "Close", |
| + AddHost: "Domain", |
| + AddHostPlaceholder: "www.example.com", |
| + AttachTo: "Attach it to", |
| + AttachToApp: "Attach to {app}", |
| + NoApps: "Create an app first.", |
| + EmptyTitle: "No domains yet", |
| + EmptyLede: "Buy one here, or add one you already own.", |
| + EmptyLedeAdd: "Add one you already own.", |
| + BoughtHere: "Bought here", |
| + Elsewhere: "Registered elsewhere", |
| + Buying: "Being bought", |
| + NotPointed: "Not pointed at an app", |
| + ExpiresLine: "Expires", |
| + NextYearLine: "next year", |
| + FollowPurchase: "See the purchase", |
| + PointAtApp: "Point at an app", |
| + PointTo: "Point it at", |
| + PointToApp: "Point at {app}", |
| + PointNote: "The app answers at {domain} and www.{domain}.", |
| + InTrash: "In Trash", |
| + Contacts: "Saved contacts", |
| + ContactsNote: "Changes apply to future purchases only.", |
| + ContactsEmpty: "No saved contacts yet.", |
| + Unread: "Could not read your domains. Try again.", |
| + NotFound: "No such domain here.", |
| + Addresses: "Addresses", |
| + Detach: "Detach", |
| + DetachLabel: "Type {host} to confirm detaching it", |
| + DetachPlaceholder: "type {host} to confirm", |
| + TileExpires: "Expires", |
| + TileExpired: "expired", |
| + TilePrice: "Next year’s price", |
| + InDays: "in {n} days", |
| + InWeeks: "in {n} weeks", |
| + ChangeCard: "Change card", |
| + RegisteredTo: "Registered to", |
| + Name: "Name", |
| + Email: "Email", |
| + Country: "Country", |
| + DNS: "DNS", |
| + DNSManaged: "The records for these addresses are managed for you.", |
| + RecordsToSet: "DNS records to set", |
| + RecordsNote: "Add these where {domain} is registered. Checks run every few minutes.", |
| + Or: "or", |
| + RecordName: "Name", |
| + RecordType: "Type", |
| + RecordValue: "Value", |
| + AllDomains: "All domains", |
| +} |
| + |
| +// domainStateChips is an address's attach state as a chip: its words and |
| +// its class. An empty state (the state read failed) is "checking", never |
| +// blank. DRAFT words, as above. |
| +var domainStateChips = map[string][2]string{ |
| + StateLive: {"Live", "chip-health-ok"}, |
| + StatePendingDNS: {"Waiting for DNS", "chip-stale"}, |
| + StateMisdirected: {"DNS points elsewhere", "chip-stale"}, |
| + StateUnverified: {"Waiting for proof", "chip-stale"}, |
| + StateUnknown: {"Could not check", "chip-stale"}, |
| + StateFailed: {"Not working", "chip-health-attention"}, |
| + StateIssuingCert: {"Getting a certificate", "chip-env"}, |
| + StateRegional: {"Per region", "chip-env"}, |
| + StateChecking: {"Checking", "chip-env"}, |
| +} |
diff --git a/internal/console/accountdomainspage.go b/internal/console/accountdomainspage.go| new file mode 100644 |
| index 000000000..0cd269383 |
| --- /dev/null |
| +++ b/internal/console/accountdomainspage.go |
| @@ -0,0 +1,488 @@ |
| +package console |
| + |
| +// The account's Domains page and a domain's own page (spec §11.3, §11.6; |
| +// Plan 2a Task 8). Both are members' reads, built from accountDomains and |
| +// accountDomain (accountdomains.go). Neither needs buying configured: a |
| +// domain registered elsewhere needs nothing but its addresses. Only the |
| +// owner's actions that go through buying (Buy a domain, Point at an app, |
| +// the purchase card, Change card) wait on domainBuyReady. Every form posts |
| +// to an existing door: an app's attach, detach and point. |
| + |
| +import ( |
| + "context" |
| + "log" |
| + "math" |
| + "net/http" |
| + "net/url" |
| + "strconv" |
| + "strings" |
| + "time" |
| + |
| + "golang.org/x/net/publicsuffix" |
| + |
| + "github.com/carlosframework/platform/internal/plans" |
| +) |
| + |
| +// domainPageFields is what a page carries for domains: Plan 1's buy flow |
| +// and the account's Domains pages. page embeds it. |
| +type domainPageFields struct { |
| + DomainBuy *domainBuyView |
| + DomainBuyCopy map[string]string |
| + AccountDomains *accountDomainsView |
| + DomainPage *domainPageView |
| +} |
| + |
| +// DomainsCopy is the Domains pages' strings, for the templates. |
| +func (p page) DomainsCopy() any { return domainsPageCopy } |
| + |
| +// domainAddressView is one address row. |
| +type domainAddressView struct { |
| + Host, App, AppHref string |
| + Chip, ChipClass string |
| + DetachAction string // the app's detach door; "" when the viewer cannot detach |
| + DetachLabel string |
| + DetachPlaceholder string |
| +} |
| + |
| +// domainCardView is one domain, as both pages draw it. |
| +type domainCardView struct { |
| + Domain, Href string |
| + Bought bool // registered here |
| + Buying bool // a purchase not finished yet |
| + PurchaseHref string // its card, for an owner who can open it |
| + PurchaseStatus string |
| + ExpiresText string // "" when not bought here |
| + ExpiresISO string |
| + expires time.Time |
| + Price string // next year's, "" when the catalog has none in the account's currency |
| + Addresses []domainAddressView |
| + PointHref string // the owner's way to the picker, on an unpointed bought domain |
| + live, total int // addresses live, of those on apps not in Trash |
| +} |
| + |
| +// Unpointed is a bought domain with no addresses. |
| +func (c domainCardView) Unpointed() bool { return c.Bought && len(c.Addresses) == 0 } |
| + |
| +// domainAppAction is one app an owner can send a form to. |
| +type domainAppAction struct{ App, Action, Label string } |
| + |
| +// domainContactRow is one saved contact, as the list shows it. |
| +type domainContactRow struct{ Name, Detail string } |
| + |
| +// domainTile is one stat tile. Href, when set, is a link under its value. |
| +type domainTile struct { |
| + Label, Value, ValueISO, Detail string |
| + Href, HrefText string |
| + Warn bool |
| +} |
| + |
| +type accountDomainsView struct { |
| + Eyebrow string |
| + Tiles []domainTile |
| + Count string |
| + Cards []domainCardView |
| + BuyHref string // owners, when buying is configured |
| + AttachApps []domainAppAction // owners: the add form's apps |
| + CanAdd bool |
| + ShowContacts bool |
| + Contacts []domainContactRow |
| +} |
| + |
| +type domainPageView struct { |
| + Eyebrow string |
| + Card domainCardView |
| + Tiles []domainTile |
| + PointApps []domainAppAction // owners, on an unpointed bought domain |
| + PointNote string |
| + Registrant []domainTile // label and value pairs; nil when none is recorded |
| + ChangeCardHref string // owners; shown alone when there is no price tile to carry it |
| + Managed bool // bought here with addresses: its records are ours |
| + Records []domainRecordRow |
| + Guidance []string // a host whose advice has no records to list |
| + RecordsNote string |
| +} |
| + |
| +// domainRecordRow is one record to set at the other registrar. Or marks |
| +// the first record of an alternative to the rows above it. |
| +type domainRecordRow struct { |
| + Name, Type, Value string |
| + Or bool |
| +} |
| + |
| +func domainsFill(s string, kv ...string) string { return strings.NewReplacer(kv...).Replace(s) } |
| + |
| +func domainsBase(acct *Account) string { return "/a/" + url.PathEscape(acct.Sqid) } |
| + |
| +// domainPageURL is a domain's own page. |
| +func domainPageURL(acct *Account, domain string) string { |
| + return domainsBase(acct) + "/domains/" + url.PathEscape(domain) |
| +} |
| + |
| +// domainBuyURL starts buying, with app chosen when it is not "" (Task 9's |
| +// door). |
| +func domainBuyURL(sqid, app string) string { |
| + u := "/a/" + url.PathEscape(sqid) + "/domains/buy" |
| + if app != "" { |
| + u += "?app=" + url.QueryEscape(app) |
| + } |
| + return u |
| +} |
| + |
| +// domainStateChip is an address's chip: In Trash for an app in Trash, |
| +// otherwise its attach state. An empty or unknown state reads as checking, |
| +// never blank. |
| +func domainStateChip(a domainAddress) (label, class string) { |
| + if a.AppInTrash { |
| + return domainsPageCopy.InTrash, "chip-env" |
| + } |
| + c, ok := domainStateChips[a.State] |
| + if !ok { |
| + c = domainStateChips[StateChecking] |
| + } |
| + return c[0], c[1] |
| +} |
| + |
| +// domainRegistrable is the path segment as a registrable domain, or "". |
| +func domainRegistrable(seg string) string { |
| + d := strings.TrimSuffix(strings.ToLower(strings.TrimSpace(seg)), ".") |
| + if d == "" { |
| + return "" |
| + } |
| + if r, err := publicsuffix.EffectiveTLDPlusOne(d); err != nil || r != d { |
| + return "" |
| + } |
| + return d |
| +} |
| + |
| +// domainActionApps is the account's apps an owner can attach to or point |
| +// at: live, and not linked (a linked app refuses domains). |
| +func (s *Server) domainActionApps(ctx context.Context, acct *Account) []string { |
| + apps, err := s.store.AppsInContext(ctx, acct.ID) |
| + if err != nil { |
| + log.Printf("console: domains apps %s: %v", acct.Sqid, err) |
| + return nil |
| + } |
| + out := apps[:0] |
| + for _, app := range apps { |
| + link, err := s.store.appLinkIDContext(ctx, acct.ID, app) |
| + if err != nil { |
| + log.Printf("console: domains apps %s/%s: %v", acct.Sqid, app, err) |
| + continue |
| + } |
| + if link == "" { |
| + out = append(out, app) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +func domainAppActions(acct *Account, apps []string, door, label string) []domainAppAction { |
| + out := make([]domainAppAction, 0, len(apps)) |
| + for _, app := range apps { |
| + out = append(out, domainAppAction{App: app, |
| + Action: domainsBase(acct) + "/apps/" + url.PathEscape(app) + "/domains/" + door, |
| + Label: domainsFill(label, "{app}", app)}) |
| + } |
| + return out |
| +} |
| + |
| +// domainRenewPrice is next year's price for a domain in currency from the |
| +// catalog, or "". |
| +func (s *Server) domainRenewPrice(domain, currency string) string { |
| + if s.cfg.DomainCatalog == nil || currency == "" { |
| + return "" |
| + } |
| + suffix, _ := publicsuffix.PublicSuffix(domain) |
| + if amt := s.cfg.DomainCatalog.TLDs[suffix].Renew[currency]; amt > 0 { |
| + return plans.FormatMinor(currency, amt) |
| + } |
| + return "" |
| +} |
| + |
| +// domainCurrency is the account's billing currency, or "". |
| +func (s *Server) domainCurrency(acct *Account) string { |
| + if s.cfg.DomainCatalog == nil { |
| + return "" |
| + } |
| + b, err := s.store.BillingAccount(acct.ID) |
| + if err != nil { |
| + log.Printf("console: domains currency %s: %v", acct.Sqid, err) |
| + return "" |
| + } |
| + if b == nil { |
| + return "" |
| + } |
| + return b.Currency |
| +} |
| + |
| +// domainCardFor is the card's view. owner and ready decide the owner's |
| +// actions; detachable is the apps whose detach door the viewer may use. |
| +func (s *Server) domainCardFor(acct *Account, c domainCard, currency string, owner, ready bool, detachable map[string]bool) domainCardView { |
| + v := domainCardView{Domain: c.Domain, Href: domainPageURL(acct, c.Domain), Bought: c.Registration != nil} |
| + base := domainsBase(acct) |
| + for _, a := range c.Addresses { |
| + av := domainAddressView{Host: a.Host, App: a.App, AppHref: base + "/apps/" + url.PathEscape(a.App)} |
| + if a.AppInTrash { |
| + av.AppHref = base + "/trash" |
| + } else { |
| + v.total++ |
| + if a.State == StateLive { |
| + v.live++ |
| + } |
| + } |
| + av.Chip, av.ChipClass = domainStateChip(a) |
| + if owner && !a.AppInTrash && detachable[a.App] { |
| + av.DetachAction = base + "/apps/" + url.PathEscape(a.App) + "/domains/detach" |
| + av.DetachLabel = domainsFill(domainsPageCopy.DetachLabel, "{host}", a.Host) |
| + av.DetachPlaceholder = domainsFill(domainsPageCopy.DetachPlaceholder, "{host}", a.Host) |
| + } |
| + v.Addresses = append(v.Addresses, av) |
| + } |
| + if p := c.Purchase; p != nil { |
| + v.Buying = true |
| + v.PurchaseStatus = purchaseCard(p, "").Status |
| + if owner && ready && p.App != "" { |
| + v.PurchaseHref = domainPurchaseURL(acct.Sqid, p.App, p.ID) |
| + } |
| + } |
| + if r := c.Registration; r != nil { |
| + v.expires = r.Expires.UTC() |
| + v.ExpiresText, v.ExpiresISO = v.expires.Format("2 Jan 2006"), v.expires.Format("2006-01-02") |
| + v.Price = s.domainRenewPrice(c.Domain, currency) |
| + if owner && ready && !v.Buying && len(v.Addresses) == 0 { |
| + v.PointHref = v.Href + "#point" |
| + } |
| + } |
| + return v |
| +} |
| + |
| +// detachableApps is the apps whose detach door an owner can use. |
| +func detachableApps(apps []string) map[string]bool { |
| + out := make(map[string]bool, len(apps)) |
| + for _, a := range apps { |
| + out[a] = true |
| + } |
| + return out |
| +} |
| + |
| +// domainLiveTile is the "Addresses live" tile, or nil with no addresses. |
| +func domainLiveTile(live, total int) *domainTile { |
| + if total == 0 { |
| + return nil |
| + } |
| + t := domainTile{Label: domainsPageCopy.TileLive, |
| + Value: domainsFill(domainsPageCopy.TileLiveValue, "{live}", strconv.Itoa(live), "{total}", strconv.Itoa(total))} |
| + if live < total { |
| + t.Warn = true |
| + t.Detail = domainsFill(domainsPageCopy.TileNotLive, "{n}", strconv.Itoa(total-live)) |
| + } |
| + return &t |
| +} |
| + |
| +func (s *Server) handleAccountDomains(w http.ResponseWriter, r *http.Request) { |
| + addr, raw, acct, role, ok := s.account(w, r) |
| + if !ok { |
| + return |
| + } |
| + ctx := r.Context() |
| + cards, err := s.accountDomains(ctx, acct) |
| + if err != nil { |
| + log.Printf("console: domains %s: %v", acct.Sqid, err) |
| + s.renderMessage(w, r, http.StatusServiceUnavailable, "Error", domainsPageCopy.Unread) |
| + return |
| + } |
| + p := s.accountPage(w, r, addr, raw, acct, role) |
| + p.Title = domainsPageCopy.Title |
| + p.ActiveNav = "domains" |
| + p.AccountDomains = s.domainsOverview(ctx, acct, role == RoleOwner, cards) |
| + s.render(w, http.StatusOK, "account_domains", p) |
| +} |
| + |
| +func (s *Server) domainsOverview(ctx context.Context, acct *Account, owner bool, cards []domainCard) *accountDomainsView { |
| + ready := s.domainBuyReady() |
| + v := &accountDomainsView{Eyebrow: domainsFill(domainsPageCopy.Eyebrow, "{account}", acct.Name), CanAdd: owner} |
| + var apps []string |
| + if owner { |
| + apps = s.domainActionApps(ctx, acct) |
| + v.AttachApps = domainAppActions(acct, apps, "attach", domainsPageCopy.AttachToApp) |
| + if ready { |
| + v.BuyHref = domainBuyURL(acct.Sqid, "") |
| + } |
| + } |
| + currency := s.domainCurrency(acct) |
| + detachable := detachableApps(apps) |
| + live, total, next := 0, 0, -1 |
| + for _, c := range cards { |
| + cv := s.domainCardFor(acct, c, currency, owner, ready, detachable) |
| + live, total = live+cv.live, total+cv.total |
| + if cv.Bought && (next < 0 || cv.expires.Before(v.Cards[next].expires)) { |
| + next = len(v.Cards) |
| + } |
| + v.Cards = append(v.Cards, cv) |
| + } |
| + if t := domainLiveTile(live, total); t != nil { |
| + v.Tiles = append(v.Tiles, *t) |
| + } |
| + if next >= 0 { |
| + n := v.Cards[next] |
| + v.Tiles = append(v.Tiles, domainTile{Label: domainsPageCopy.TileNextExpiry, Value: n.ExpiresText, ValueISO: n.ExpiresISO, Detail: n.Domain}) |
| + } |
| + v.Count = domainsFill(domainsPageCopy.CountMany, "{n}", strconv.Itoa(len(cards))) |
| + if len(cards) == 1 { |
| + v.Count = domainsPageCopy.CountOne |
| + } |
| + if owner { |
| + s.domainsContacts(ctx, acct, ready, v) |
| + } |
| + return v |
| +} |
| + |
| +// domainsContacts fills the owner's saved contacts: shown when buying is |
| +// configured or the account has some. |
| +func (s *Server) domainsContacts(ctx context.Context, acct *Account, ready bool, v *accountDomainsView) { |
| + contacts, err := s.store.SavedContacts(ctx, acct.ID) |
| + if err != nil { |
| + log.Printf("console: saved contacts %s: %v", acct.Sqid, err) |
| + return |
| + } |
| + v.ShowContacts = ready || len(contacts) > 0 |
| + for _, c := range contacts { |
| + name := strings.TrimSpace(c.Contact.FirstName + " " + c.Contact.LastName) |
| + v.Contacts = append(v.Contacts, domainContactRow{Name: name, Detail: c.Contact.Email + " · " + c.Contact.Country}) |
| + } |
| +} |
| + |
| +func (s *Server) handleAccountDomain(w http.ResponseWriter, r *http.Request) { |
| + addr, raw, acct, role, ok := s.account(w, r) |
| + if !ok { |
| + return |
| + } |
| + ctx := r.Context() |
| + // Only a registrable domain has a page; a subdomain or a public |
| + // suffix is the same 404 as a domain the account does not use. |
| + domain := domainRegistrable(r.PathValue("domain")) |
| + var card *domainCard |
| + if domain != "" { |
| + var err error |
| + if card, err = s.accountDomain(ctx, acct, domain); err != nil { |
| + log.Printf("console: domain %s/%s: %v", acct.Sqid, domain, err) |
| + s.renderMessage(w, r, http.StatusServiceUnavailable, "Error", domainsPageCopy.Unread) |
| + return |
| + } |
| + } |
| + if card == nil { |
| + s.renderMessage(w, r, http.StatusNotFound, "Not found", domainsPageCopy.NotFound) |
| + return |
| + } |
| + p := s.accountPage(w, r, addr, raw, acct, role) |
| + p.Title = card.Domain |
| + p.ActiveNav = "domains" |
| + p.MobileParent = &navLink{Label: domainsPageCopy.Title, Href: p.Nav + "/domains"} |
| + p.DomainPage = s.domainPage(ctx, acct, role == RoleOwner, *card) |
| + s.render(w, http.StatusOK, "account_domain", p) |
| +} |
| + |
| +func (s *Server) domainPage(ctx context.Context, acct *Account, owner bool, c domainCard) *domainPageView { |
| + ready := s.domainBuyReady() |
| + var apps []string |
| + if owner { |
| + apps = s.domainActionApps(ctx, acct) |
| + } |
| + cv := s.domainCardFor(acct, c, s.domainCurrency(acct), owner, ready, detachableApps(apps)) |
| + v := &domainPageView{Eyebrow: domainsFill(domainsPageCopy.PageEyebrow, "{account}", acct.Name), Card: cv} |
| + if !cv.Bought { |
| + if t := domainLiveTile(cv.live, cv.total); t != nil { |
| + v.Tiles = append(v.Tiles, *t) |
| + } |
| + v.Records, v.Guidance = s.domainRecordsToSet(ctx, acct, c.Addresses) |
| + v.RecordsNote = domainsFill(domainsPageCopy.RecordsNote, "{domain}", c.Domain) |
| + return v |
| + } |
| + if owner && ready && s.billing != nil { |
| + v.ChangeCardHref = billingPagePath(acct.Sqid) |
| + } |
| + v.Tiles = append(v.Tiles, domainExpiresTile(cv, time.Now())) |
| + if cv.Price != "" { |
| + // The card goes with the price it would pay. |
| + v.Tiles = append(v.Tiles, domainTile{Label: domainsPageCopy.TilePrice, Value: cv.Price, Href: v.ChangeCardHref, HrefText: domainsPageCopy.ChangeCard}) |
| + v.ChangeCardHref = "" |
| + } |
| + if cv.PointHref != "" { |
| + v.PointApps = domainAppActions(acct, apps, "point", domainsPageCopy.PointToApp) |
| + v.PointNote = domainsFill(domainsPageCopy.PointNote, "{domain}", c.Domain) |
| + } |
| + if rc := c.Registration.Registrant; rc.FirstName != "" || rc.LastName != "" || rc.Email != "" { |
| + v.Registrant = []domainTile{ |
| + {Label: domainsPageCopy.Name, Value: strings.TrimSpace(rc.FirstName + " " + rc.LastName)}, |
| + {Label: domainsPageCopy.Email, Value: rc.Email}, |
| + {Label: domainsPageCopy.Country, Value: countryName(rc.Country)}, |
| + } |
| + } |
| + v.Managed = len(cv.Addresses) > 0 |
| + return v |
| +} |
| + |
| +// domainExpiresTile is a bought domain's expiry, with how long is left. |
| +func domainExpiresTile(c domainCardView, now time.Time) domainTile { |
| + t := domainTile{Label: domainsPageCopy.TileExpires, Value: c.ExpiresText, ValueISO: c.ExpiresISO} |
| + days := int(math.Round(c.expires.Sub(now).Hours() / 24)) |
| + switch { |
| + case days < 0: |
| + t.Detail, t.Warn = domainsPageCopy.TileExpired, true |
| + case days < 14: |
| + t.Detail = domainsFill(domainsPageCopy.InDays, "{n}", strconv.Itoa(days)) |
| + default: |
| + t.Detail = domainsFill(domainsPageCopy.InWeeks, "{n}", strconv.Itoa(days/7)) |
| + } |
| + return t |
| +} |
| + |
| +// domainNeedsRecords is a state whose records may still be missing at the |
| +// other registrar: DNS not seen pointing here yet, or not checked yet. |
| +func domainNeedsRecords(state string) bool { |
| + switch state { |
| + case StateLive, StateIssuingCert, StateFailed, StateRegional: |
| + return false |
| + } |
| + return true |
| +} |
| + |
| +// domainRecordsToSet is the records a domain registered elsewhere still |
| +// needs, for its addresses not yet live: domainRecords, the structured form |
| +// of domainGuidance, from the deployment's own targets, with an unproven |
| +// address's proof first. A host whose advice has no records (no edge |
| +// addresses known) gets domainGuidance's sentence instead. |
| +func (s *Server) domainRecordsToSet(ctx context.Context, acct *Account, addrs []domainAddress) ([]domainRecordRow, []string) { |
| + var rows []domainRecordRow |
| + var guidance []string |
| + var targets *DNSTargets |
| + for _, a := range addrs { |
| + if a.AppInTrash || !domainNeedsRecords(a.State) { |
| + continue |
| + } |
| + if targets == nil { |
| + t := s.dnsTargets(ctx) |
| + targets = &t |
| + } |
| + recs := domainRecords(a.Host, *targets, false, "") |
| + if len(recs) == 0 { |
| + guidance = append(guidance, domainGuidance(a.Host, *targets)) |
| + } |
| + if a.State == StateUnverified { |
| + recs = append([]dnsRecord{s.domainChallenge(a.Host, acct.Sqid)}, recs...) |
| + } |
| + first, last := "", "" |
| + for _, r := range recs { |
| + row := domainRecordRow{Name: r.Name, Type: r.Type, Value: r.Value} |
| + if !r.Required { |
| + if first == "" { |
| + first = r.Set |
| + } |
| + row.Or = r.Set != first && r.Set != last |
| + last = r.Set |
| + } |
| + rows = append(rows, row) |
| + } |
| + } |
| + return rows, guidance |
| +} |
diff --git a/internal/console/accountdomainspage_test.go b/internal/console/accountdomainspage_test.go| new file mode 100644 |
| index 000000000..f8dda3703 |
| --- /dev/null |
| +++ b/internal/console/accountdomainspage_test.go |
| @@ -0,0 +1,487 @@ |
| +package console |
| + |
| +// Plan 2a Task 8: the Domains nav item, the account's Domains page and a |
| +// domain's own page. |
| + |
| +import ( |
| + "context" |
| + "net/http" |
| + "regexp" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +// adSignIn is a fresh browser signed in as address. |
| +func adSignIn(t *testing.T, fx *consoleFixture, address string) *http.Client { |
| + t.Helper() |
| + c := newBrowser(t) |
| + fx.setUser(address) |
| + signUp(t, fx, c, "code-"+address) |
| + return c |
| +} |
| + |
| +func adOwner(acct *Account) string { return "owner" + acct.Sqid + "@example.com" } |
| + |
| +// adMember adds a member to acct and signs them in. |
| +func adMember(t *testing.T, fx *consoleFixture, acct *Account) *http.Client { |
| + t.Helper() |
| + if err := fx.st.AddMember(acct.ID, "member@example.com", RoleMember, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + return adSignIn(t, fx, "member@example.com") |
| +} |
| + |
| +func adGet(t *testing.T, fx *consoleFixture, c *http.Client, acct *Account, path string) (int, string) { |
| + t.Helper() |
| + status, _, body := get(t, c, fx.ts.URL+"/a/"+acct.Sqid+path) |
| + return status, body |
| +} |
| + |
| +// adBought registers domain for acct, expiring on expires. |
| +func adBought(t *testing.T, fx *consoleFixture, acct *Account, domain string, expires time.Time) { |
| + t.Helper() |
| + if err := fx.st.AddDomainRegistration(DomainRegistration{Domain: domain, AccountID: acct.ID, RegistrarID: "reg-" + domain, |
| + ZoneID: "zone-" + domain, Expires: expires, Registrant: purchaseContact()}); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +// adPurchaseFixture is a console where buying works, with a renew price for |
| +// .com in the account's currency. |
| +func adPurchaseFixture(t *testing.T) *purchaseFixture { |
| + t.Helper() |
| + f := newPurchaseFixture(t) |
| + tld := f.srv.cfg.DomainCatalog.TLDs["com"] |
| + tld.Renew = map[string]int64{"usd": 1800} |
| + f.srv.cfg.DomainCatalog.TLDs["com"] = tld |
| + if b, err := f.st.BillingAccount(f.acct.ID); err != nil || b == nil || b.Currency != "usd" { |
| + t.Fatalf("billing account %+v %v, want usd", b, err) |
| + } |
| + return f |
| +} |
| + |
| +// mainOf is the page's <main>, so the header's nav does not count. |
| +func mainOf(t *testing.T, body string) string { |
| + t.Helper() |
| + _, after, ok := strings.Cut(body, "<main") |
| + if !ok { |
| + t.Fatalf("no <main> in:\n%s", body) |
| + } |
| + m, _, _ := strings.Cut(after, "</main>") |
| + return m |
| +} |
| + |
| +// adSection is the <section> whose aria-label is label. |
| +func adSection(t *testing.T, body, label string) string { |
| + t.Helper() |
| + _, after, ok := strings.Cut(body, `aria-label="`+label+`"`) |
| + if !ok { |
| + t.Fatalf("no section %q in:\n%s", label, body) |
| + } |
| + s, _, _ := strings.Cut(after, "</section>") |
| + return s |
| +} |
| + |
| +func TestDomainsNavBetweenAppsAndFleet(t *testing.T) { |
| + p := page{Account: &Account{Sqid: "x", Name: "x"}, Nav: "/a/x", ActiveNav: "domains"} |
| + var keys []string |
| + for _, l := range p.AccountLinks() { |
| + keys = append(keys, l.Key) |
| + if l.Key == "domains" && (l.Label != "Domains" || l.Href != "/a/x/domains" || !l.Current) { |
| + t.Errorf("domains link = %+v", l) |
| + } |
| + } |
| + if got := strings.Join(keys, ","); got != "apps,domains,fleet,team,settings" { |
| + t.Fatalf("account links = %s", got) |
| + } |
| + |
| + fx, acct := adFixture(t, consoleFixtureOptions{}) |
| + c := adSignIn(t, fx, adOwner(acct)) |
| + status, body := adGet(t, fx, c, acct, "/domains") |
| + if status != http.StatusOK { |
| + t.Fatalf("GET /domains = %d:\n%s", status, body) |
| + } |
| + // The header's links use the account's preferred segment (its name here). |
| + nav := regexp.MustCompile(`<a href="/a/([^/"]+)/">Apps</a>\s*<a href="/a/([^/"]+)/domains" aria-current="page">Domains</a>\s*<a href="/a/([^/"]+)/fleet">Fleet</a>`) |
| + if !nav.MatchString(body) { |
| + t.Errorf("the header nav lacks Domains, current, between Apps and Fleet:\n%s", body) |
| + } |
| +} |
| + |
| +func TestDomainsOverviewCards(t *testing.T) { |
| + f := adPurchaseFixture(t) |
| + fx, acct := f.consoleFixture, f.acct |
| + adApp(t, fx, acct, "docs") |
| + adBought(t, fx, acct, "bought.com", time.Date(2027, 11, 4, 0, 0, 0, 0, time.UTC)) |
| + adClaim(t, fx, acct, "kass", "www.example.org") |
| + adClaim(t, fx, acct, "docs", "docs.example.org") |
| + if err := fx.st.TrashAppRowContext(context.Background(), acct.ID, "docs", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + buying := f.start(t) // shop.com for kass, awaiting payment |
| + c := adSignIn(t, fx, adOwner(acct)) |
| + status, body := adGet(t, fx, c, acct, "/domains") |
| + if status != http.StatusOK { |
| + t.Fatalf("GET /domains = %d:\n%s", status, body) |
| + } |
| + main := mainOf(t, body) |
| + base := "/a/" + acct.Sqid |
| + |
| + // A purchase in flight is its own card, linking to the purchase card. |
| + inflight := adSection(t, main, "shop.com") |
| + for _, want := range []string{ |
| + `<span class="chip chip-canary">` + domainsPageCopy.Buying + `</span>`, |
| + `href="` + domainPurchaseURL(acct.Sqid, "kass", buying.ID) + `"`, |
| + } { |
| + if !strings.Contains(inflight, want) { |
| + t.Errorf("in-flight card lacks %q:\n%s", want, inflight) |
| + } |
| + } |
| + |
| + bought := adSection(t, main, "bought.com") |
| + for _, want := range []string{ |
| + `href="` + base + `/domains/bought.com"`, |
| + `<span class="chip chip-canary">Bought here</span>`, |
| + `Expires <time datetime="2027-11-04">4 Nov 2027</time>`, |
| + "next year $18", |
| + domainsPageCopy.NotPointed, |
| + } { |
| + if !strings.Contains(bought, want) { |
| + t.Errorf("bought card lacks %q:\n%s", want, bought) |
| + } |
| + } |
| + // An unpointed bought domain offers the owner its page's picker. |
| + if !strings.Contains(bought, `href="`+base+`/domains/bought.com#point"`) { |
| + t.Errorf("bought card has no Point at an app:\n%s", bought) |
| + } |
| + |
| + elsewhere := adSection(t, main, "example.org") |
| + for _, want := range []string{ |
| + `<span class="chip chip-env">Registered elsewhere</span>`, |
| + `<code class="envvar-name">docs.example.org</code>`, |
| + `<a href="` + base + `/trash">docs</a> <span class="chip chip-env">In Trash</span>`, |
| + `<code class="envvar-name">www.example.org</code>`, |
| + `<a href="` + base + `/apps/kass">kass</a> <span class="chip chip-env">Checking</span>`, |
| + } { |
| + if !strings.Contains(elsewhere, want) { |
| + t.Errorf("elsewhere card lacks %q:\n%s", want, elsewhere) |
| + } |
| + } |
| + if strings.Contains(elsewhere, "Expires") || strings.Contains(elsewhere, "next year") { |
| + t.Errorf("an elsewhere card shows an expiry or price:\n%s", elsewhere) |
| + } |
| + if strings.Index(elsewhere, "www.example.org") > strings.Index(elsewhere, "docs.example.org") { |
| + t.Errorf("rows out of order, want www before docs:\n%s", elsewhere) |
| + } |
| + // The page opens with its state: live addresses (Trash not counted) and |
| + // the next expiry. |
| + for _, want := range []string{ |
| + `<p class="tile-value">0 of 1</p>`, |
| + `<time datetime="2027-11-04">4 Nov 2027</time></p>`, |
| + `href="` + base + `/domains/buy"`, |
| + domainsPageCopy.AddOwn, |
| + `formaction="` + base + `/apps/kass/domains/attach"`, |
| + "<h2>3 domains</h2>", |
| + } { |
| + if !strings.Contains(main, want) { |
| + t.Errorf("overview lacks %q", want) |
| + } |
| + } |
| + // A trashed app is not offered as an attach target. |
| + if strings.Contains(main, `formaction="`+base+`/apps/docs/domains/attach"`) { |
| + t.Error("the add form offers an app in Trash") |
| + } |
| + for _, banned := range []string{"renew", "Renew", "auto-renew", "Transfer", "Change owner", "Add address", "—", "–"} { |
| + if strings.Contains(main, banned) { |
| + t.Errorf("overview says %q", banned) |
| + } |
| + } |
| +} |
| + |
| +func TestDomainsOverviewWithoutBuyConfigured(t *testing.T) { |
| + fx, acct := adFixture(t, consoleFixtureOptions{}) |
| + adApp(t, fx, acct, "a") |
| + adClaim(t, fx, acct, "a", "shop.example") |
| + if fx.srv.domainBuyReady() { |
| + t.Fatal("buying is configured") |
| + } |
| + c := adSignIn(t, fx, adOwner(acct)) |
| + status, body := adGet(t, fx, c, acct, "/domains") |
| + if status != http.StatusOK { |
| + t.Fatalf("GET /domains = %d:\n%s", status, body) |
| + } |
| + main := mainOf(t, body) |
| + if !strings.Contains(adSection(t, main, "shop.example"), domainsPageCopy.Elsewhere) { |
| + t.Errorf("no elsewhere card:\n%s", main) |
| + } |
| + if strings.Contains(main, "/domains/buy") || strings.Contains(main, domainsPageCopy.Buy) { |
| + t.Errorf("Buy offered with buying unconfigured:\n%s", main) |
| + } |
| + // Adding a domain you own needs nothing configured. |
| + if !strings.Contains(main, domainsPageCopy.AddOwn) { |
| + t.Errorf("no Add a domain you own:\n%s", main) |
| + } |
| + |
| + // The empty state still has a way in. |
| + empty := planAccount(t, fx, 503) |
| + adApp(t, fx, empty, "a") |
| + c = adSignIn(t, fx, adOwner(empty)) |
| + status, body = adGet(t, fx, c, empty, "/domains") |
| + if status != http.StatusOK || !strings.Contains(body, domainsPageCopy.EmptyTitle) || !strings.Contains(body, domainsPageCopy.AddOwn) { |
| + t.Fatalf("empty state %d:\n%s", status, mainOf(t, body)) |
| + } |
| +} |
| + |
| +func TestDomainsOverviewMemberSeesNoBuyOrContacts(t *testing.T) { |
| + f := adPurchaseFixture(t) |
| + fx, acct := f.consoleFixture, f.acct |
| + if err := f.addContact(purchaseContact()); err != nil { |
| + t.Fatal(err) |
| + } |
| + other := purchaseContact() |
| + other.FirstName, other.Email = "Sam", "sam@example.test" |
| + if err := f.addContact(other); err != nil { |
| + t.Fatal(err) |
| + } |
| + adBought(t, fx, acct, "bought.com", time.Now().AddDate(1, 0, 0)) |
| + |
| + owner := adSignIn(t, fx, adOwner(acct)) |
| + _, body := adGet(t, fx, owner, acct, "/domains") |
| + main := mainOf(t, body) |
| + for _, want := range []string{domainsPageCopy.Contacts, "Jane Buyer", "Sam Buyer", "buyer@example.test · IE", domainsPageCopy.Buy} { |
| + if !strings.Contains(main, want) { |
| + t.Errorf("owner's overview lacks %q", want) |
| + } |
| + } |
| + if n := strings.Count(main, domainsPageCopy.ContactsNote); n != 1 { |
| + t.Errorf("the R12 note appears %d times, want once", n) |
| + } |
| + if strings.Contains(main, "Only owners") { |
| + t.Error("the page narrates who sees contacts") |
| + } |
| + |
| + member := adMember(t, fx, acct) |
| + status, body := adGet(t, fx, member, acct, "/domains") |
| + if status != http.StatusOK { |
| + t.Fatalf("member GET /domains = %d", status) |
| + } |
| + main = mainOf(t, body) |
| + if !strings.Contains(main, `aria-label="bought.com"`) { |
| + t.Errorf("member does not see the domain:\n%s", main) |
| + } |
| + for _, banned := range []string{domainsPageCopy.Contacts, "Jane Buyer", "buyer@example.test", "/domains/buy", domainsPageCopy.Buy, |
| + domainsPageCopy.AddOwn, "/domains/attach", "#point"} { |
| + if strings.Contains(main, banned) { |
| + t.Errorf("member's overview shows %q", banned) |
| + } |
| + } |
| +} |
| + |
| +func TestDomainPageBoughtCardsInOrder(t *testing.T) { |
| + f := adPurchaseFixture(t) |
| + fx, acct := f.consoleFixture, f.acct |
| + base := "/a/" + acct.Sqid |
| + adBought(t, fx, acct, "bought.com", time.Now().AddDate(0, 0, 70)) |
| + adClaim(t, fx, acct, "kass", "bought.com") |
| + adClaim(t, fx, acct, "kass", "www.bought.com") |
| + adBought(t, fx, acct, "spare.com", time.Now().AddDate(1, 0, 0)) |
| + |
| + owner := adSignIn(t, fx, adOwner(acct)) |
| + status, body := adGet(t, fx, owner, acct, "/domains/bought.com") |
| + if status != http.StatusOK { |
| + t.Fatalf("GET bought.com = %d:\n%s", status, body) |
| + } |
| + main := mainOf(t, body) |
| + order := []string{ |
| + "<h1>bought.com</h1>", |
| + domainsPageCopy.BoughtHere, |
| + "<h2>" + domainsPageCopy.TileExpires + "</h2>", |
| + "in 10 weeks", |
| + "<h2>" + domainsPageCopy.TilePrice + "</h2>", |
| + "$18", |
| + "<h2>" + domainsPageCopy.Addresses + "</h2>", |
| + `<code class="envvar-name">bought.com</code>`, |
| + `<code class="envvar-name">www.bought.com</code>`, |
| + "<h2>" + domainsPageCopy.RegisteredTo + "</h2>", |
| + "<dd>Jane Buyer</dd>", |
| + "<dd>buyer@example.test</dd>", |
| + "<dd>Ireland</dd>", |
| + "<h2>" + domainsPageCopy.DNS + "</h2>", |
| + domainsPageCopy.DNSManaged, |
| + } |
| + at := 0 |
| + for _, want := range order { |
| + i := strings.Index(main[at:], want) |
| + if i < 0 { |
| + t.Fatalf("after offset %d the page lacks %q:\n%s", at, want, main) |
| + } |
| + at += i + len(want) |
| + } |
| + for _, want := range []string{ |
| + `action="` + base + `/apps/kass/domains/detach"`, |
| + `<input type="hidden" name="host" value="www.bought.com">`, |
| + `href="` + base + `/billing"`, |
| + domainsPageCopy.ChangeCard, |
| + } { |
| + if !strings.Contains(main, want) { |
| + t.Errorf("owner's page lacks %q", want) |
| + } |
| + } |
| + // Addresses already there: no picker. Nothing Plan 3 or 4. |
| + for _, banned := range []string{"/domains/point", "renew", "Renew", "Transfer", "Change owner", "Add address", "—", "–", "Street", "871234567"} { |
| + if strings.Contains(main, banned) { |
| + t.Errorf("bought page says %q", banned) |
| + } |
| + } |
| + |
| + // The unpointed one: the owner's picker posts to each app's point door. |
| + _, body = adGet(t, fx, owner, acct, "/domains/spare.com") |
| + main = mainOf(t, body) |
| + for _, want := range []string{ |
| + `id="point"`, |
| + `<input type="hidden" name="domain" value="spare.com">`, |
| + `formaction="` + base + `/apps/kass/domains/point"`, |
| + domainsPageCopy.NotPointed, |
| + } { |
| + if !strings.Contains(main, want) { |
| + t.Errorf("unpointed page lacks %q:\n%s", want, main) |
| + } |
| + } |
| + |
| + // A member sees the page, without the owner's forms. |
| + member := adMember(t, fx, acct) |
| + for _, d := range []string{"bought.com", "spare.com"} { |
| + status, body := adGet(t, fx, member, acct, "/domains/"+d) |
| + if status != http.StatusOK { |
| + t.Fatalf("member GET %s = %d", d, status) |
| + } |
| + main := mainOf(t, body) |
| + for _, banned := range []string{"/domains/detach", "/domains/point", "/billing", domainsPageCopy.ChangeCard} { |
| + if strings.Contains(main, banned) { |
| + t.Errorf("member's %s page shows %q", d, banned) |
| + } |
| + } |
| + if !strings.Contains(main, domainsPageCopy.RegisteredTo) { |
| + t.Errorf("member's %s page lacks Registered to", d) |
| + } |
| + } |
| +} |
| + |
| +func TestDomainPageElsewhereShowsRecordsToSet(t *testing.T) { |
| + fx, acct := adFixture(t, consoleFixtureOptions{}) |
| + fx.srv.cfg.EdgeIPs = []string{"192.0.2.10"} |
| + adApp(t, fx, acct, "a") |
| + adClaim(t, fx, acct, "a", "docs.example.org") |
| + c := adSignIn(t, fx, adOwner(acct)) |
| + |
| + status, body := adGet(t, fx, c, acct, "/domains/example.org") |
| + if status != http.StatusOK { |
| + t.Fatalf("GET example.org = %d:\n%s", status, body) |
| + } |
| + main := mainOf(t, body) |
| + records := func(main string) string { |
| + _, after, ok := strings.Cut(main, "<h2>"+domainsPageCopy.RecordsToSet+"</h2>") |
| + if !ok { |
| + t.Fatalf("no records to set:\n%s", main) |
| + } |
| + return after |
| + } |
| + table := records(main) |
| + if !regexp.MustCompile(`<td><code>docs.example.org</code></td>\s*<td>A</td>\s*<td><code>192.0.2.10</code></td>`).MatchString(table) { |
| + t.Errorf("records table lacks docs.example.org A 192.0.2.10:\n%s", table) |
| + } |
| + for _, banned := range []string{domainsPageCopy.RegisteredTo, domainsPageCopy.TileExpires, domainsPageCopy.DNSManaged, "CNAME"} { |
| + if strings.Contains(main, banned) { |
| + t.Errorf("elsewhere page shows %q", banned) |
| + } |
| + } |
| + if !strings.Contains(main, domainsPageCopy.Elsewhere) || !strings.Contains(main, `action="/a/`+acct.Sqid+`/apps/a/domains/detach"`) { |
| + t.Errorf("elsewhere page lacks its chip or Detach:\n%s", main) |
| + } |
| + |
| + // The records are domainGuidance's, as data: a steering deployment |
| + // offers a subdomain the CNAME, with the A records as the alternative. |
| + fx.srv.steeringHost = "edge.oncarlos.test" |
| + _, body = adGet(t, fx, c, acct, "/domains/example.org") |
| + table = records(mainOf(t, body)) |
| + if !regexp.MustCompile(`<td><code>docs.example.org</code></td>\s*<td>CNAME</td>\s*<td><code>edge.oncarlos.test</code></td>`).MatchString(table) { |
| + t.Errorf("steering table lacks the CNAME:\n%s", table) |
| + } |
| + if !regexp.MustCompile(domainsPageCopy.Or + `</span> <code>docs.example.org</code></td>\s*<td>A</td>`).MatchString(table) { |
| + t.Errorf("steering table lacks the A alternative marked or:\n%s", table) |
| + } |
| +} |
| + |
| +func TestDomainPageOtherAccount404(t *testing.T) { |
| + fx, acct := adFixture(t, consoleFixtureOptions{}) |
| + other := planAccount(t, fx, 502) |
| + adApp(t, fx, acct, "a") |
| + adApp(t, fx, other, "a") |
| + adClaim(t, fx, acct, "a", "www.mine.example") |
| + adClaim(t, fx, other, "a", "www.theirs.example") |
| + adBought(t, fx, other, "bought-theirs.com", time.Now().AddDate(1, 0, 0)) |
| + c := adSignIn(t, fx, adOwner(acct)) |
| + |
| + if status, _ := adGet(t, fx, c, acct, "/domains/mine.example"); status != http.StatusOK { |
| + t.Fatalf("own domain = %d", status) |
| + } |
| + _, unknown := adGet(t, fx, c, acct, "/domains/nobody.example") |
| + for _, seg := range []string{"theirs.example", "bought-theirs.com", "nobody.example", "www.mine.example", "example", "co.uk", "%20"} { |
| + status, body := adGet(t, fx, c, acct, "/domains/"+seg) |
| + if status != http.StatusNotFound { |
| + t.Errorf("GET /domains/%s = %d, want 404", seg, status) |
| + } |
| + if body != unknown { |
| + t.Errorf("GET /domains/%s differs from an unknown domain's 404", seg) |
| + } |
| + } |
| + // The segment is normalised before the registrable-domain check. |
| + if status, _ := adGet(t, fx, c, acct, "/domains/MINE.example."); status != http.StatusOK { |
| + t.Errorf("GET /domains/MINE.example. = %d, want the page", status) |
| + } |
| + // A non-member's request is the account gate's 404. |
| + assertNonMember404(t, fx, "/domains/mine.example") |
| +} |
| + |
| +func TestAppSettingsLinksToAccountDomains(t *testing.T) { |
| + f := adPurchaseFixture(t) |
| + c := adSignIn(t, f.consoleFixture, adOwner(f.acct)) |
| + base := "/a/" + f.acct.Sqid |
| + status, body := adGet(t, f.consoleFixture, c, f.acct, "/apps/kass/settings/domains") |
| + if status != http.StatusOK { |
| + t.Fatalf("settings = %d", status) |
| + } |
| + for _, want := range []string{ |
| + `<a href="` + base + `/domains">` + domainsPageCopy.AllDomains + `</a>`, |
| + `href="` + base + `/domains/buy?app=kass"`, |
| + } { |
| + if !strings.Contains(body, want) { |
| + t.Errorf("app settings lacks %q", want) |
| + } |
| + } |
| + if strings.Contains(body, base+"/apps/kass/domains/buy") { |
| + t.Error("app settings still links the app's own buy form") |
| + } |
| +} |
| + |
| +// The chip for every state the attach can be in, and for a failed read. |
| +func TestDomainStateChipNeverBlank(t *testing.T) { |
| + for _, st := range append(domainStatesForChips(), "", "something-new") { |
| + label, class := domainStateChip(domainAddress{State: st}) |
| + if label == "" || class == "" { |
| + t.Errorf("state %q: chip %q %q", st, label, class) |
| + } |
| + } |
| + if l, c := domainStateChip(domainAddress{}); l != "Checking" || c != "chip-env" { |
| + t.Errorf("empty state chip = %q %q, want the neutral checking chip", l, c) |
| + } |
| + if l, c := domainStateChip(domainAddress{State: StateLive, AppInTrash: true}); l != domainsPageCopy.InTrash || c != "chip-env" { |
| + t.Errorf("trash chip = %q %q", l, c) |
| + } |
| +} |
| + |
| +// domainStatesForChips is every state the attach reports. |
| +func domainStatesForChips() []string { |
| + return []string{StatePendingDNS, StateMisdirected, StateIssuingCert, StateLive, StateChecking, StateFailed, StateUnknown, StateUnverified, StateRegional} |
| +} |
diff --git a/internal/console/apidomainbuy_test.go b/internal/console/apidomainbuy_test.go| index 85309f7f6..ab7985071 100644 |
| --- a/internal/console/apidomainbuy_test.go |
| +++ b/internal/console/apidomainbuy_test.go |
| @@ -401,7 +401,7 @@ func TestBrowserBuyPrefillsContactAndHidesUnconfigured(t *testing.T) { |
| t.Fatalf("prefill %d %s", status, body) |
| } |
| status, _, body = get(t, c, base+"/settings/domains") |
| - if status != 200 || !strings.Contains(body, base[len(f.ts.URL):]+"/domains/buy") { |
| + if status != 200 || !strings.Contains(body, "/a/"+f.acct.Sqid+"/domains/buy?app=kass") { |
| t.Fatalf("buy link %d %s", status, body) |
| } |
| f.srv.cfg.DomainCatalog = nil |
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go| index 380981d5b..33efa0794 100644 |
| --- a/internal/console/claim_invariant_fixtures_test.go |
| +++ b/internal/console/claim_invariant_fixtures_test.go |
| @@ -843,6 +843,8 @@ var claimFixtures = map[string]claimFixture{ |
| "route GET /a/{sqid}/apps/{app}/settings/{section}": claimRead("renders one app settings section"), |
| "route GET /a/{sqid}/apps/{app}/settings/index": claimRead("renders the app's settings sections as a phone index; reads only the gate"), |
| "route GET /a/{sqid}/billing": claimRead("renders the billing page (plans 6b) from stored billing facts, the plan row and the member count; no provider request; names no app"), |
| + "route GET /a/{sqid}/domains": claimRead("renders the account's domains from its registrations, purchases and claims; writes nothing"), |
| + "route GET /a/{sqid}/domains/{domain}": claimRead("renders one of the account's domains; writes nothing"), |
| "route GET /a/{sqid}/fleet": claimRead("renders the account's fleet tab"), |
| "route GET /a/{sqid}/fleet/byo": claimRead("renders bring-your-own-box instructions"), |
| "route GET /a/{sqid}/fleets/{fleet}": claimRead("renders one fleet's boxes and placements"), |
diff --git a/internal/console/claim_invariant_probes_read_test.go b/internal/console/claim_invariant_probes_read_test.go| index 28ea01003..6e440c576 100644 |
| --- a/internal/console/claim_invariant_probes_read_test.go |
| +++ b/internal/console/claim_invariant_probes_read_test.go |
| @@ -208,7 +208,10 @@ var claimReadProbes = map[string]claimProbe{ |
| "/apps/titogo/control-plane/set"), |
| "route GET /a/{sqid}/apps/{app}/settings/index": claimPageRead(nil, "/a/bab/apps/titogo/settings/index", |
| `id="nav-general"`), |
| - "route GET /a/{sqid}/billing": claimPageRead(claimBillingWorld, "/a/bab/billing", "<h1>"+billingCopy["page.title"]+"</h1>"), |
| + "route GET /a/{sqid}/billing": claimPageRead(claimBillingWorld, "/a/bab/billing", "<h1>"+billingCopy["page.title"]+"</h1>"), |
| + "route GET /a/{sqid}/domains": claimPageRead(claimWorldAlias, "/a/bab/domains", `aria-label="example.com"`, "tickets.example.com"), |
| + "route GET /a/{sqid}/domains/{domain}": claimPageRead(claimWorldAlias, "/a/bab/domains/example.com", |
| + "<h1>example.com</h1>", "tickets.example.com"), |
| "route GET /a/{sqid}/fleet": claimPageRead(claimWorldFleet, "/a/bab/fleet", "pi"), |
| "route GET /a/{sqid}/fleet/byo": claimPageRead(nil, "/a/bab/fleet/byo", "<h1>Bring your own fleet</h1>"), |
| "route GET /a/{sqid}/fleets/{fleet}": claimPageRead(claimWorldFleet, "/a/bab/fleets/pi", "<h1>pi</h1>"), |
diff --git a/internal/console/mobilenav.go b/internal/console/mobilenav.go| index 13425e74b..100d2b7dd 100644 |
| --- a/internal/console/mobilenav.go |
| +++ b/internal/console/mobilenav.go |
| @@ -40,6 +40,7 @@ func (p page) AccountLinks() []navLink { |
| } |
| links := []navLink{ |
| {Key: "apps", Label: "Apps", Href: p.Nav + "/"}, |
| + {Key: "domains", Label: domainsPageCopy.Title, Href: p.Nav + "/domains"}, |
| {Key: "fleet", Label: "Fleet", Href: p.Nav + "/fleet"}, |
| {Key: "team", Label: "Team", Href: p.Nav + "/team"}, |
| } |
diff --git a/internal/console/mobilenav_test.go b/internal/console/mobilenav_test.go| index cbf4f8bff..16953791a 100644 |
| --- a/internal/console/mobilenav_test.go |
| +++ b/internal/console/mobilenav_test.go |
| @@ -109,6 +109,7 @@ func TestAccountIndex(t *testing.T) { |
| } |
| want := []indexRow{ |
| {"apps", navPath("/"), "Apps"}, |
| + {"domains", navPath("/domains"), "Domains"}, |
| {"fleet", navPath("/fleet"), "Fleet"}, |
| {"team", navPath("/team"), "Team"}, |
| {"settings", navPath("/settings"), "Settings"}, |
| @@ -138,7 +139,7 @@ func TestAccountIndex(t *testing.T) { |
| enableBilling(t, fx.srv) |
| _, _, body = get(t, c, fx.u("/index")) |
| - want = append(want[:3:3], indexRow{"billing", navPath("/billing"), billingCopy["page.title"]}, want[3]) |
| + want = append(want[:4:4], indexRow{"billing", navPath("/billing"), billingCopy["page.title"]}, want[4]) |
| if got := indexRows(t, body); !equalRows(got, want) { |
| t.Errorf("account index with billing on = %v, want %v", got, want) |
| } |
diff --git a/internal/console/perfwalk_test.go b/internal/console/perfwalk_test.go| index ccf86426e..346506fb3 100644 |
| --- a/internal/console/perfwalk_test.go |
| +++ b/internal/console/perfwalk_test.go |
| @@ -495,6 +495,8 @@ func perfTargets(fx *consoleFixture) map[string][]perfTarget { |
| "GET /a/{sqid}/{$}": ok(fx.path("/")), |
| "GET /a/{sqid}/index": ok(fx.path("/index")), |
| "GET /a/{sqid}/apps/new": ok(fx.path("/apps/new")), |
| + "GET /a/{sqid}/domains": ok(fx.path("/domains")), |
| + "GET /a/{sqid}/domains/{domain}": ok(fx.path("/domains/example.com")), |
| "GET /a/{sqid}/fleet": ok(fx.path("/fleet")), |
| "GET /a/{sqid}/fleet/byo": ok(fx.path("/fleet/byo")), |
| "GET /a/{sqid}/fleets/{fleet}": ok(fx.path("/fleets/fleet-a")), |
diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go| index 6214afb61..03a40d206 100644 |
| --- a/internal/console/routedecls.go |
| +++ b/internal/console/routedecls.go |
| @@ -189,6 +189,11 @@ var routeDecls = []routeDecl{ |
| // account-by-session, so a link a teammate opens lands where you meant. |
| {Pattern: "GET /a/{sqid}/{$}", Handler: (*Server).handleAccountHome}, |
| {Pattern: "GET /a/{sqid}/index", Handler: (*Server).handleAccountIndex}, |
| + // The account's domains (accountdomainspage.go, Plan 2a): member reads, |
| + // not gated on buying, since a domain registered elsewhere needs nothing |
| + // configured. |
| + {Pattern: "GET /a/{sqid}/domains", Handler: (*Server).handleAccountDomains}, |
| + {Pattern: "GET /a/{sqid}/domains/{domain}", Handler: (*Server).handleAccountDomain}, |
| {Pattern: "GET /a/{sqid}/fleet", Handler: (*Server).handleAccountFleetTab}, |
| {Pattern: "GET /a/{sqid}/fleet/byo", Handler: (*Server).handleFleetBYO}, |
| {Pattern: "GET /a/{sqid}/team", Handler: (*Server).handleTeam}, |
diff --git a/internal/console/server.go b/internal/console/server.go| index 9311c0548..16820872a 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -2388,7 +2388,7 @@ type page struct { |
| AccountReview AccountReview |
| MismatchCopy MismatchCopy |
| - ActiveNav string // account nav section this page sits in: "apps" | "fleet" | "team" | "billing" | "settings" |
| + ActiveNav string // account nav section this page sits in: "apps" | "domains" | "fleet" | "team" | "billing" | "settings" |
| ActiveTab string // app pages: "overview" | "releases" | "instances" | "activity" | "settings" |
| AppName string // app pages: the {app} segment, for the tab bar and eyebrow |
| @@ -2770,9 +2770,9 @@ type page struct { |
| Confirm *ConfirmView |
| // App Settings (appsettings.go): what the tab knows beyond the AppView. |
| - Settings *SettingsView |
| - DomainBuy *domainBuyView |
| - DomainBuyCopy map[string]string |
| + Settings *SettingsView |
| + // The buy flow and the Domains pages (accountdomainspage.go). |
| + domainPageFields |
| // /a/{sqid}/fleets/{fleet} (Task 9): the owner's own remote boxes, |
| // joined to their heartbeats, and the account's apps placed on this |
diff --git a/internal/console/templates/account_domain.html b/internal/console/templates/account_domain.html| new file mode 100644 |
| index 000000000..0080e0998 |
| --- /dev/null |
| +++ b/internal/console/templates/account_domain.html |
| @@ -0,0 +1,73 @@ |
| +{{define "account_domain"}}{{template "top" .}} |
| +{{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}} |
| +{{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}} |
| +{{$c := .DomainsCopy}}{{$v := .DomainPage}}{{$d := $v.Card}} |
| +<div class="pagehead"> |
| + <p class="eyebrow">{{$v.Eyebrow}}</p> |
| + <h1>{{$d.Domain}}</h1> |
| +</div> |
| +<p class="chips">{{if $d.Bought}}<span class="chip chip-canary">{{$c.BoughtHere}}</span>{{else if $d.Buying}}<span class="chip chip-canary">{{$c.Buying}}</span>{{else}}<span class="chip chip-env">{{$c.Elsewhere}}</span>{{end}}{{if and $d.Unpointed (not $d.Buying)}}<span class="chip chip-env">{{$c.NotPointed}}</span>{{end}}</p> |
| +{{if $d.Buying}}<p class="small">{{$d.PurchaseStatus}}{{with $d.PurchaseHref}} <a href="{{.}}">{{$c.FollowPurchase}}</a>{{end}}</p>{{end}} |
| + |
| +{{template "domain_tiles" $v.Tiles}} |
| +{{with $v.ChangeCardHref}}<p class="small"><a href="{{.}}">{{$c.ChangeCard}}</a></p>{{end}} |
| + |
| +{{if $d.Addresses}} |
| +<h2>{{$c.Addresses}}</h2> |
| +<div class="tablewrap"> |
| + <ul class="envvars addr-rows"> |
| + {{range $d.Addresses}}{{if .DetachAction}}<li><details class="envvar"><summary><code class="envvar-name">{{.Host}}</code>{{template "domain_address_value" .}}<span class="envvar-edit"><span class="envvar-when-closed">{{$c.Detach}}</span><span class="envvar-when-open">{{$c.Close}}</span></span></summary> |
| + <form class="envvar-panel settings-row" method="post" action="{{.DetachAction}}"> |
| + <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| + <input type="hidden" name="host" value="{{.Host}}"> |
| + <label class="visually-hidden" for="detach-{{.Host}}">{{.DetachLabel}}</label> |
| + <input type="text" id="detach-{{.Host}}" name="confirm" placeholder="{{.DetachPlaceholder}}" autocomplete="off" required> |
| + <button type="submit" class="btn-sm btn-danger">{{$c.Detach}}</button> |
| + </form> |
| + </details></li>{{else}}<li><div class="envvar-row"><code class="envvar-name">{{.Host}}</code>{{template "domain_address_value" .}}</div></li>{{end}}{{end}} |
| + </ul> |
| +</div> |
| +{{end}} |
| + |
| +{{if $v.PointApps}} |
| +<h2 id="point">{{$c.PointAtApp}}</h2> |
| +<form method="post" action="{{(index $v.PointApps 0).Action}}" class="settings-row"> |
| + <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| + <input type="hidden" name="domain" value="{{$d.Domain}}"> |
| + <span class="small">{{$c.PointTo}}</span> |
| + {{range $v.PointApps}}<button type="submit" class="btn-sm btn-secondary" formaction="{{.Action}}" aria-label="{{.Label}}" data-busy>{{.App}}</button>{{end}} |
| +</form> |
| +<p class="small">{{$v.PointNote}}</p> |
| +{{end}} |
| + |
| +{{if $d.Bought}}{{with $v.Registrant}} |
| +<h2>{{$c.RegisteredTo}}</h2> |
| +<dl class="instance-facts"> |
| + {{range .}}<dt>{{.Label}}</dt><dd>{{.Value}}</dd> |
| + {{end}} |
| +</dl> |
| +{{end}}{{end}} |
| + |
| +{{if $v.Managed}} |
| +<h2>{{$c.DNS}}</h2> |
| +<p class="small">{{$c.DNSManaged}}</p> |
| +{{end}} |
| + |
| +{{if or $v.Records $v.Guidance}} |
| +<h2>{{$c.RecordsToSet}}</h2> |
| +<p class="small">{{$v.RecordsNote}}</p> |
| +{{if $v.Records}} |
| +<div class="tablewrap"> |
| +<table> |
| + <tr><th>{{$c.RecordName}}</th><th>{{$c.RecordType}}</th><th>{{$c.RecordValue}}</th></tr> |
| + {{range $v.Records}}<tr> |
| + <td>{{if .Or}}<span class="small">{{$c.Or}}</span> {{end}}<code>{{.Name}}</code></td> |
| + <td>{{.Type}}</td> |
| + <td><code>{{.Value}}</code></td> |
| + </tr>{{end}} |
| +</table> |
| +</div> |
| +{{end}} |
| +{{range $v.Guidance}}<p class="small">{{.}}</p>{{end}} |
| +{{end}} |
| +{{template "bottom" .}}{{end}} |
diff --git a/internal/console/templates/account_domains.html b/internal/console/templates/account_domains.html| new file mode 100644 |
| index 000000000..1d764677a |
| --- /dev/null |
| +++ b/internal/console/templates/account_domains.html |
| @@ -0,0 +1,85 @@ |
| +{{define "domain_tiles"}}{{if .}}<section class="tiles stat-tiles" aria-label="{{(index . 0).Label}}"> |
| + {{range .}}<div class="tile{{if .Warn}} tile-warn{{end}}"> |
| + <h2>{{.Label}}</h2> |
| + <p class="tile-value">{{if .ValueISO}}<time datetime="{{.ValueISO}}">{{.Value}}</time>{{else}}{{.Value}}{{end}}</p> |
| + {{with .Detail}}<p class="tile-detail">{{.}}</p>{{end}} |
| + {{if .Href}}<p class="tile-detail"><a href="{{.Href}}">{{.HrefText}}</a></p>{{end}} |
| + </div>{{end}} |
| +</section>{{end}}{{end}} |
| + |
| +{{define "domain_address_value"}}<span class="envvar-value"><a href="{{.AppHref}}">{{.App}}</a> <span class="chip {{.ChipClass}}">{{.Chip}}</span></span>{{end}} |
| + |
| +{{define "account_domains"}}{{template "top" .}} |
| +{{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}} |
| +{{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}} |
| +{{$c := .DomainsCopy}}{{$v := .AccountDomains}} |
| +<div class="pagehead"> |
| + <p class="eyebrow">{{$v.Eyebrow}}</p> |
| + <h1>{{$c.Title}}</h1> |
| +</div> |
| + |
| +{{template "domain_tiles" $v.Tiles}} |
| + |
| +{{if $v.Cards}} |
| +<div class="sectionhead"> |
| + <h2>{{$v.Count}}</h2> |
| + {{with $v.BuyHref}}<div class="listctl"><a class="btn btn-sm" href="{{.}}">{{$c.Buy}}</a></div>{{end}} |
| +</div> |
| + |
| +{{range $v.Cards}} |
| +<section class="tablewrap" aria-label="{{.Domain}}"> |
| + <div class="envvar-row domain-head"><a class="envvar-name" href="{{.Href}}">{{.Domain}}</a> |
| + {{if .Bought}}<span class="chip chip-canary">{{$c.BoughtHere}}</span>{{else if .Buying}}<span class="chip chip-canary">{{$c.Buying}}</span>{{else}}<span class="chip chip-env">{{$c.Elsewhere}}</span>{{end}} |
| + {{if .Bought}}<span class="envvar-value small">{{$c.ExpiresLine}} <time datetime="{{.ExpiresISO}}">{{.ExpiresText}}</time>{{with .Price}} · {{$c.NextYearLine}} {{.}}{{end}}</span>{{end}} |
| + </div> |
| + <ul class="envvars outcomes"> |
| + {{if .Buying}}<li><div class="envvar-row"><span class="envvar-name small">{{.PurchaseStatus}}</span>{{with .PurchaseHref}}<span class="envvar-value"><a href="{{.}}">{{$c.FollowPurchase}}</a></span>{{end}}</div></li>{{end}} |
| + {{range .Addresses}}<li><div class="envvar-row"><code class="envvar-name">{{.Host}}</code>{{template "domain_address_value" .}}</div></li>{{end}} |
| + {{if and .Unpointed (not .Buying)}}<li><div class="envvar-row"><span class="envvar-name small">{{$c.NotPointed}}</span>{{with .PointHref}}<span class="envvar-value"><a class="btn btn-sm btn-secondary" href="{{.}}">{{$c.PointAtApp}}</a></span>{{end}}</div></li>{{end}} |
| + </ul> |
| +</section> |
| +{{end}} |
| +{{else}} |
| +<div class="sectionhead"> |
| + <h2>{{$c.EmptyTitle}}</h2> |
| + {{with $v.BuyHref}}<div class="listctl"><a class="btn btn-sm" href="{{.}}">{{$c.Buy}}</a></div>{{end}} |
| +</div> |
| +{{if $v.CanAdd}}<p class="small">{{if $v.BuyHref}}{{$c.EmptyLede}}{{else}}{{$c.EmptyLedeAdd}}{{end}}</p>{{end}} |
| +{{end}} |
| + |
| +{{if $v.CanAdd}} |
| +<div class="tablewrap"> |
| + <ul class="envvars"> |
| + <li><details class="envvar" id="add"><summary><span class="envvar-name">{{$c.AddOwn}}</span><span class="envvar-value"></span><span class="envvar-edit"><span class="envvar-when-closed">{{$c.Add}}</span><span class="envvar-when-open">{{$c.Close}}</span></span></summary> |
| + {{if $v.AttachApps}} |
| + <form class="envvar-panel" method="post" action="{{(index $v.AttachApps 0).Action}}"> |
| + <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| + <div class="settings-row"> |
| + <label for="add-host">{{$c.AddHost}}</label> |
| + <input type="text" id="add-host" name="host" placeholder="{{$c.AddHostPlaceholder}}" autocomplete="off" required> |
| + </div> |
| + <div class="settings-row"> |
| + <span class="small">{{$c.AttachTo}}</span> |
| + {{range $v.AttachApps}}<button type="submit" class="btn-sm btn-secondary" formaction="{{.Action}}" aria-label="{{.Label}}">{{.App}}</button>{{end}} |
| + </div> |
| + </form> |
| + {{else}}<p class="envvar-panel small">{{$c.NoApps}}</p>{{end}} |
| + </details></li> |
| + </ul> |
| +</div> |
| +{{end}} |
| + |
| +{{if $v.ShowContacts}} |
| +<div class="sectionhead" id="contacts"> |
| + <h2>{{$c.Contacts}}</h2> |
| +</div> |
| +{{if $v.Contacts}} |
| +<p class="small">{{$c.ContactsNote}}</p> |
| +<div class="tablewrap"> |
| + <ul class="envvars"> |
| + {{range $v.Contacts}}<li><div class="envvar-row"><span class="envvar-name">{{.Name}}</span><span class="envvar-value small">{{.Detail}}</span></div></li>{{end}} |
| + </ul> |
| +</div> |
| +{{else}}<p class="small">{{$c.ContactsEmpty}}</p>{{end}} |
| +{{end}} |
| +{{template "bottom" .}}{{end}} |
diff --git a/internal/console/templates/app_settings.html b/internal/console/templates/app_settings.html| index de27fa67d..38ec7aff7 100644 |
| --- a/internal/console/templates/app_settings.html |
| +++ b/internal/console/templates/app_settings.html |
| @@ -79,6 +79,7 @@ bucket keys and stays.</p> |
| {{end}} |
| {{if eq .SettingsSection "domains"}} |
| <h2>Domains & TLS</h2> |
| +<p class="small"><a href="{{.Base}}/domains">{{.DomainsCopy.AllDomains}}</a></p> |
| {{if .Settings.Domains}} |
| <div class="tablewrap"> |
| <table> |
| @@ -110,7 +111,7 @@ bucket keys and stays.</p> |
| </div> |
| {{else}}<p class="small">No domains yet — the first shipped route brings one.</p>{{end}} |
| {{if .IsOwner}} |
| -{{if .Settings.BuyReady}}<p><a href="{{.Base}}/apps/{{.Detail.App}}/domains/buy">{{.DomainBuyCopy.title}}</a></p>{{end}} |
| +{{if .Settings.BuyReady}}<p><a href="{{.Base}}/domains/buy?app={{.Detail.App}}">{{.DomainBuyCopy.title}}</a></p>{{end}} |
| <h3>Attach a custom domain</h3> |
| {{if .Settings.OnlyPlatformDomain}}<p class="small">This app already answers |
| at its platform domain; attaching adds addresses, it never removes one.</p>{{end}} |
diff --git a/internal/console/templates/console_chrome.html b/internal/console/templates/console_chrome.html| index 781f5a065..92656daa3 100644 |
| --- a/internal/console/templates/console_chrome.html |
| +++ b/internal/console/templates/console_chrome.html |
| @@ -274,6 +274,16 @@ |
| .envvar-panel { padding: 0 0.9rem 0.6rem; } |
| .envvar-panel .settings-row { margin: 0; } |
| .envvar-panel input[type=text], .envvar-panel input[type=password] { flex: 1; min-width: 8rem; } |
| + /* The Domains page (account_domains.html): a domain card's header row, |
| + its name in bold, the expiry line wrapping under it on a phone. */ |
| + .domain-head { flex-wrap: wrap; row-gap: 0.2rem; background-color: var(--panel-cool); border-bottom: 1px solid var(--rule); } |
| + .domain-head .envvar-name { font-weight: 600; } |
| + .domain-head .envvar-value { flex: 1 1 14rem; white-space: normal; } |
| + .domain-head .chip { margin: 0; } |
| + /* Address rows wrap on a phone, so the app and its state chip are never |
| + cut off. */ |
| + .addr-rows .envvar > summary, .addr-rows .envvar-row { flex-wrap: wrap; row-gap: 0.3rem; } |
| + .addr-rows .envvar-value { flex: 1 0 auto; } |
| .envhead { margin: 1.75rem 0 0.15rem; } |
| .envhead + .small { margin: 0 0 0.6rem; } |
| .addvar { margin: 0.6rem 0 0.25rem; } |
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt| index eca795d4f..be1575168 100644 |
| --- a/internal/console/testdata/claim-routes.txt |
| +++ b/internal/console/testdata/claim-routes.txt |
| @@ -37,9 +37,6 @@ route GET /a/{sqid}/apps/{app}/analytics |
| route GET /a/{sqid}/apps/{app}/analytics/live |
| route GET /a/{sqid}/apps/{app}/availability |
| route GET /a/{sqid}/apps/{app}/deployments |
| -route GET /a/{sqid}/apps/{app}/domains/buy |
| -route GET /a/{sqid}/apps/{app}/domains/purchases/{id} |
| -route GET /a/{sqid}/apps/{app}/domains/purchases/{id}/status |
| route GET /a/{sqid}/apps/{app}/errors |
| route GET /a/{sqid}/apps/{app}/index |
| route GET /a/{sqid}/apps/{app}/instances |
| @@ -57,6 +54,8 @@ route GET /a/{sqid}/apps/{app}/source |
| route GET /a/{sqid}/billing |
| route GET /a/{sqid}/billing/continue |
| route GET /a/{sqid}/billing/done |
| +route GET /a/{sqid}/domains |
| +route GET /a/{sqid}/domains/{domain} |
| route GET /a/{sqid}/fleet |
| route GET /a/{sqid}/fleet/byo |
| route GET /a/{sqid}/fleets/{fleet} |
| @@ -74,7 +73,6 @@ route GET /alerts/snooze/{token} |
| route GET /alerts/unsubscribe/{token} |
| route GET /api/box/interactive/{id} |
| route GET /api/box/runs/{id} |
| -route GET /api/cli/accounts/{account}/domains/purchases/{id} |
| route GET /api/cli/accounts/{account}/plan |
| route GET /api/cli/accounts/{account}/subdomain |
| route GET /api/cli/apps |
| @@ -197,8 +195,6 @@ route POST /a/{sqid}/apps/{app}/control-plane/clear |
| route POST /a/{sqid}/apps/{app}/control-plane/set |
| route POST /a/{sqid}/apps/{app}/delete |
| route POST /a/{sqid}/apps/{app}/domains/attach |
| -route POST /a/{sqid}/apps/{app}/domains/buy |
| -route POST /a/{sqid}/apps/{app}/domains/check |
| route POST /a/{sqid}/apps/{app}/domains/detach |
| route POST /a/{sqid}/apps/{app}/errors/level |
| route POST /a/{sqid}/apps/{app}/extend |
| @@ -226,7 +222,6 @@ route POST /a/{sqid}/apps/{app}/settings/environments |
| route POST /a/{sqid}/apps/{app}/star |
| route POST /a/{sqid}/apps/{app}/store/destroy |
| route POST /a/{sqid}/apps/{app}/swap |
| -route POST /a/{sqid}/billing/card |
| route POST /a/{sqid}/billing/change |
| route POST /a/{sqid}/billing/checkout |
| route POST /a/{sqid}/billing/confirm |
| @@ -258,8 +253,6 @@ route POST /accounts/new |
| route POST /alerts/confirm/{token} |
| route POST /alerts/snooze/{token} |
| route POST /alerts/unsubscribe/{token} |
| -route POST /api/cli/accounts/{account}/domains/check |
| -route POST /api/cli/accounts/{account}/domains/purchases |
| route POST /api/cli/accounts/{account}/plan |
| route POST /api/cli/accounts/{account}/store/apply |
| route POST /api/cli/accounts/{account}/store/approve |
diff --git a/internal/console/testdata/perf-budgets.txt b/internal/console/testdata/perf-budgets.txt| index 1c4ce2efa..279edc6d0 100644 |
| --- a/internal/console/testdata/perf-budgets.txt |
| +++ b/internal/console/testdata/perf-budgets.txt |
| @@ -104,6 +104,8 @@ GET /fleet/store calls 3: lists the storage entitlements and the storage usage d |
| GET /a/{sqid}/apps/{app} over: cold, the app-tab frame, the account manifest and every box's metrics hours for two days (141 S3 calls, about 715 ms, over 500 ms); a repeat view is the release listing and every manifest (3 S3 calls, about 80 ms) |
| GET /a/{sqid}/apps/{app}/instances over: cold, the app-tab frame, the account manifest, the metrics sweep, instances.json, and every edges file and box report (122 S3 calls and 1 host call, about 1,315 ms, over 500 ms); a repeat view still reads instances.json and every edges file and box report (17 S3 calls, 500 to 620 ms, at or over 500 ms: the edges files are read one after another) |
| GET /a/{sqid}/apps/{app}/instances/{host} over: cold, the app-tab frame, the account manifest and the metrics sweep beside the instance record, instances.json, the edges listing and the box and fleet box reports (119 S3 calls, about 505 ms, over 500 ms); a repeat view reads the last five (14 S3 calls, 210 to 325 ms) |
| +GET /a/{sqid}/domains calls 13: the account's domain claims (one listing and each claim), then for each app holding addresses the attach state the Settings Domains section reads (claims, cert-warm records, box reports); about 400 ms, no instance records; Plan 2a Task 5 budget 1 + one per app |
| +GET /a/{sqid}/domains/{domain} calls 13: the same reads as the Domains page, narrowed to the apps holding this domain's addresses; about 400 ms |
| GET /a/{sqid}/apps/{app}/settings/{section} over: Domains reads the domain claims, cert-warm records, every box report and every instance record (16 S3 calls on a repeat view, 430 to 470 ms; cold 24, about 555 ms, over 500 ms); every other section passes and reads only its own data on a repeat view: General 2 (cold 9), Environments 5 (12), Storage 4 (11), Email 1 (8), Feature flags 1 (8), Errors and analytics 2 (9), the pipeline section, Placement and Delete none (7); the advanced redirect none, warm or cold |
| POST /a/{sqid}/apps/{app}/promote over: promoting v2 to stable reads and writes 18 S3 objects, about 520 ms from the body read to the first byte, over 500 ms (console-slow-writes is speeding it up) |
diff --git a/parity/parity.tsv b/parity/parity.tsv| index 6366434ff..5f71afd28 100644 |
| --- a/parity/parity.tsv |
| +++ b/parity/parity.tsv |
| @@ -82,6 +82,8 @@ move instances gap move ; move status ; move cut ; move abort ; move resolve [-- |
| # domains |
| domains-list domains both domains list GET /a/{sqid}/apps/{app}/settings/{section} |
| +domains-account domains console-only GET /a/{sqid}/domains The account's domains, bought here and registered elsewhere; the CLI list comes later. |
| +domains-account-page domains console-only GET /a/{sqid}/domains/{domain} One domain's addresses, expiry and the records to set; the CLI list comes later. |
| domains-attach domains both domains attach ; domains detach POST /a/{sqid}/apps/{app}/domains/attach ; POST /a/{sqid}/apps/{app}/domains/detach |
| domains-verify domains partial domains verify POST /a/{sqid}/apps/{app}/domains/attach There is no Verify button; attaching again verifies. |
| domains-buy domains both domains check ; domains buy GET /a/{sqid}/apps/{app}/domains/buy ; POST /a/{sqid}/apps/{app}/domains/check ; POST /a/{sqid}/apps/{app}/domains/buy ; GET /a/{sqid}/apps/{app}/domains/purchases/{id} ; GET /a/{sqid}/apps/{app}/domains/purchases/{id}/status |