Put the Update and Packages pages on one Updates page

Router software and packages are two parts of one page, with one overlay,
one confirmation banner and both logs. /upgrade redirects to it; the
actions keep their addresses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 22:55:54 +01:00
co-authored by Claude Sonnet 5.5
parent 4aef47a350
commit 9cb2d28ea1
11 changed files with 231 additions and 192 deletions
+25 -9
View File
@@ -289,15 +289,31 @@ func (a *app) updateData() updateData {
return d
}
// updatesData is the Updates page: the router software (a release of
// nixos-router) and the packages (nixpkgs) on one page.
type updatesData struct {
Update updateData
Upgrade upgradeData
}
func (a *app) updatesData() updatesData {
return updatesData{Update: a.updateData(), Upgrade: a.upgradeData()}
}
func (a *app) updatePage(w http.ResponseWriter, r *http.Request, sess session) {
d := a.updateData()
p := page{Title: "Update", CSRF: sess.csrf, LoggedIn: true, Data: d, Flash: r.URL.Query().Get("msg")}
if d.Status.Running {
d := a.updatesData()
p := page{Title: "Updates", CSRF: sess.csrf, LoggedIn: true, Data: d, Flash: r.URL.Query().Get("msg")}
if d.Update.Status.Running || d.Upgrade.Run.Running {
p.Live = 3
}
a.render(w, "update", p)
}
// upgradeRedirect sends the old address of the packages part to the page.
func upgradeRedirect(w http.ResponseWriter, r *http.Request, _ session) {
http.Redirect(w, r, "/update#packages", http.StatusSeeOther)
}
func (a *app) updateBack(w http.ResponseWriter, r *http.Request, msg string) {
http.Redirect(w, r, "/update?msg="+url.QueryEscape(msg), http.StatusSeeOther)
}
@@ -324,17 +340,17 @@ func (a *app) updateSaveURL(w http.ResponseWriter, r *http.Request, _ session) {
}
func (a *app) updateCheck(w http.ResponseWriter, r *http.Request, sess session) {
d := a.updateData()
p := page{Title: "Update", CSRF: sess.csrf, LoggedIn: true}
if d.URL == "" {
d := a.updatesData()
p := page{Title: "Updates", CSRF: sess.csrf, LoggedIn: true}
if d.Update.URL == "" {
a.updateBack(w, r, "Set the update server first.")
return
}
offer, err := a.sys.checkUpdate(d.URL)
offer, err := a.sys.checkUpdate(d.Update.URL)
if err != nil {
d.OfferErr = err.Error()
d.Update.OfferErr = err.Error()
} else {
d.Offer = &offer
d.Update.Offer = &offer
}
p.Data = d
a.render(w, "update", p)