fix
This commit is contained in:
parent
1c9a192a96
commit
f3c4e3c60b
12 changed files with 95 additions and 16 deletions
45
cmd/telesrv-admin/buildinfo.go
Normal file
45
cmd/telesrv-admin/buildinfo.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package main
|
||||
|
||||
import "runtime/debug"
|
||||
|
||||
// gitCommit/buildTime can be set via -ldflags "-X main.gitCommit=... -X
|
||||
// main.buildTime=...", mirroring cmd/telesrv/buildinfo.go -- but in
|
||||
// practice neither procctl's goBuild (used by the admin panel's own
|
||||
// Restart/Update) nor a plain `go build` sets them, so this normally falls
|
||||
// back to Go's automatic VCS stamping (debug.ReadBuildInfo's vcs.revision),
|
||||
// which needs nothing extra to work from a git checkout.
|
||||
var (
|
||||
gitCommit = ""
|
||||
buildTime = ""
|
||||
)
|
||||
|
||||
type buildMetadata struct {
|
||||
Commit string
|
||||
Dirty bool
|
||||
BuildTime string
|
||||
}
|
||||
|
||||
// shortCommit is what the sidebar footer shows next to "Version: O7" -- the
|
||||
// full hash is one click away in git log, the footer just needs enough to
|
||||
// tell two builds apart at a glance.
|
||||
func (m buildMetadata) shortCommit() string {
|
||||
if len(m.Commit) > 7 {
|
||||
return m.Commit[:7]
|
||||
}
|
||||
return m.Commit
|
||||
}
|
||||
|
||||
func currentBuildMetadata() buildMetadata {
|
||||
meta := buildMetadata{Commit: gitCommit, BuildTime: buildTime}
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
settings := map[string]string{}
|
||||
for _, setting := range info.Settings {
|
||||
settings[setting.Key] = setting.Value
|
||||
}
|
||||
if meta.Commit == "" {
|
||||
meta.Commit = settings["vcs.revision"]
|
||||
}
|
||||
meta.Dirty = settings["vcs.modified"] == "true"
|
||||
}
|
||||
return meta
|
||||
}
|
||||
|
|
@ -292,6 +292,7 @@ func (s *server) handleAPILogout(w http.ResponseWriter, _ *http.Request) {
|
|||
// session carries, so the UI can hide a section the operator may not use rather
|
||||
// than letting them walk into a 403.
|
||||
func (s *server) handleSession(w http.ResponseWriter, r *http.Request) {
|
||||
build := currentBuildMetadata()
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"actor": actorFromContext(r.Context()),
|
||||
"permissions": permissionsFromContext(r.Context()).List(),
|
||||
|
|
@ -302,6 +303,15 @@ func (s *server) handleSession(w http.ResponseWriter, r *http.Request) {
|
|||
// tells "the old admin process died and a new one answered" apart
|
||||
// from "the old one is just slow to respond".
|
||||
"boot_id": bootID,
|
||||
// build is this admin binary's own commit -- shown under "Version"
|
||||
// in the sidebar footer so an operator can tell at a glance which
|
||||
// build is actually running, independent of the app version string.
|
||||
"build": map[string]any{
|
||||
"commit": build.Commit,
|
||||
"short_commit": build.shortCommit(),
|
||||
"dirty": build.Dirty,
|
||||
"build_time": build.BuildTime,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ func (s *server) handleRestartServerAPI(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
meta := s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "restart-server")
|
||||
if meta.DryRun {
|
||||
writeJSON(w, http.StatusOK, serverCommandResult(meta, "server.restart", nil, "restart validated -- rebuilds and relaunches bin/owpengram-server", nil))
|
||||
writeJSON(w, http.StatusOK, serverCommandResult(meta, "server.restart", nil, "restart validated -- rebuilds both bin/owpengram-server and bin/owpengram-admin-panel, relaunches owpengram-server", nil))
|
||||
return
|
||||
}
|
||||
log, err := s.serverCtl.Restart(r.Context())
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
cmd/telesrv-admin/web/dist/assets/index-hA2EpjuH.css
vendored
Normal file
1
cmd/telesrv-admin/web/dist/assets/index-hA2EpjuH.css
vendored
Normal file
File diff suppressed because one or more lines are too long
4
cmd/telesrv-admin/web/dist/index.html
vendored
4
cmd/telesrv-admin/web/dist/index.html
vendored
|
|
@ -23,8 +23,8 @@
|
|||
})();
|
||||
</script>
|
||||
|
||||
<script type="module" crossorigin src="/assets/index-qfdwgPZE.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-Dc3900m_.css">
|
||||
<script type="module" crossorigin src="/assets/index-CgFYD-Jw.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-hA2EpjuH.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export function App() {
|
|||
|
||||
return (
|
||||
<PermissionsProvider permissions={session.permissions ?? []} hideThirdPartyVerification={session.hide_third_party_verification ?? true}>
|
||||
<Shell actor={session.actor} route={route} navigate={navigate} onLogout={() => setSession(null)}>
|
||||
<Shell actor={session.actor} build={session.build} route={route} navigate={navigate} onLogout={() => setSession(null)}>
|
||||
<Routes route={route} navigate={navigate} />
|
||||
</Shell>
|
||||
</PermissionsProvider>
|
||||
|
|
|
|||
|
|
@ -41,12 +41,14 @@ export function BootScreen() {
|
|||
|
||||
export function Shell({
|
||||
actor,
|
||||
build,
|
||||
route,
|
||||
navigate,
|
||||
onLogout,
|
||||
children
|
||||
}: {
|
||||
actor: string;
|
||||
build?: { commit: string; short_commit: string; dirty: boolean; build_time: string };
|
||||
route: RouteState;
|
||||
navigate: Navigate;
|
||||
onLogout: () => void;
|
||||
|
|
@ -143,6 +145,11 @@ export function Shell({
|
|||
</nav>
|
||||
<div className="sidebar-status">
|
||||
<span className="sidebar-label">{"Version: O7"}</span>
|
||||
{build?.short_commit && (
|
||||
<span className="sidebar-label sidebar-build" title={build.commit + (build.dirty ? " (uncommitted changes)" : "")}>
|
||||
{`Build: ${build.short_commit}${build.dirty ? "+" : ""}`}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</aside>
|
||||
<div className="workspace">
|
||||
|
|
|
|||
|
|
@ -263,6 +263,13 @@ a {
|
|||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.sidebar-build {
|
||||
font-weight: 500;
|
||||
text-transform: none;
|
||||
font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.nav-list {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
|
|
|
|||
|
|
@ -584,6 +584,14 @@ export type AdminSession = {
|
|||
// comment. Used by Server Settings' Restart/Update flow to detect a
|
||||
// genuinely new admin process after asking it to bounce.
|
||||
boot_id?: string;
|
||||
// This admin binary's own build -- shown under "Version" in the sidebar
|
||||
// footer so an operator can tell which build is actually running.
|
||||
build?: {
|
||||
commit: string;
|
||||
short_commit: string;
|
||||
dirty: boolean;
|
||||
build_time: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type AdminLoginResult = AdminSession & {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue