fix: guarantee panel version badge always renders - #4
Open
ShiyunXu wants to merge 6 commits into
Open
Conversation
…ANGELOG) VERSION and CHANGELOG.md already record 1.4.1 as released, but several hardcoded fallback version strings were still stuck at 1.4.0, so the dashboard (via GET /api/version, whose response comes from cmd/panel/main.go's package-level 'version' var) reported the previous release unless the binary happened to be built with -ldflags "-X main.version=..." overriding it (confirmed no build script in this repo passes that flag, so the stale default was actually served). - cmd/panel/main.go: version fallback 1.4.0 -> 1.4.1 - web/package.json + package-lock.json (root package only): 1.4.0 -> 1.4.1 - mkdocs.yml site_description: v1.4.0 -> v1.4.1 - docs/landing (Navbar, Footer, i18n translations en/ar/tr): v1.4.0 -> v1.4.1 Verified: go build ./... succeeds, npx tsc --noEmit clean, vite build bundle contains "1.4.1" and no remaining "1.4.0", vitest passes (one pre-existing unrelated failure in modal-bugcondition.test.ts reproduces identically on master before this change). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ile / CHANGELOG)" This reverts commit 8125fbe.
/api/version returned the hardcoded main.go default (1.4.0) while VERSION was already 1.4.1. The UI prefers the API value over the __PANEL_VERSION__ build-time fallback, so the stale backend value won. Bump main.go and package.json to 1.4.1 to match the VERSION file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Overview (dashboard heading) and AppHeader read useVersion().data with no fallback, so the version disappeared whenever GET /api/version errored or was still loading (e.g. an admin/reseller lacking system:read gets 403). Fall back to the build-time __PANEL_VERSION__ constant, matching AppSidebar, so the installed panel version always renders. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The 1fcef72 fallback (?? __PANEL_VERSION__) only helps while the query is pending or errored, but a 401 from /api/version also clears the auth token and retries could leave data undefined in edge states. Passing the build-time version as initialData makes useVersion().data a string from the very first render — it flows through select() (unlike placeholderData) and is upgraded to the live backend version when the fetch succeeds. retry: false avoids hammering the endpoint on failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ew/AppHeader - hooks.ts now exports PANEL_VERSION (the Vite-injected build version) and uses it for initialData, keeping one source of truth. - Overview.tsx and AppHeader.tsx mirror the AppSidebar pattern: useVersion().data ?? PANEL_VERSION, so the version badge can never render empty even if the query data is somehow undefined. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ensures the panel version always displays in the sidebar, header and dashboard overview:
hooks.ts: exportPANEL_VERSION(Vite-injected build version) and use it asinitialDatasouseVersion().datais a string from first renderOverview.tsx/AppHeader.tsx: fall back toPANEL_VERSIONlike AppSidebar doescmd/panel/main.go+web/package.json: sync fallback version to 1.3.2