Add a frontend version tag to Footer.tsx#960
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a visible SPA (frontend) version string to the application footer to help users report bugs with precise build context, aligning with issue #959.
Changes:
- Inject build/version metadata (package version, commit SHA, tag/ref) into the SPA at build time via Vite
define. - Add SPA version resolution helpers (
resolveSpaVersionDisplay,spaVersion) plus unit tests. - Render the SPA version in
Footerand add corresponding i18n strings and layout styling; update dev-env Vite configs to also define version metadata.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
vite.config.ts |
Computes version metadata from package/git/GitHub env and injects it via define. |
src/version/resolveSpaVersionDisplay.ts |
New helper to choose displayed version (release version vs commit SHA). |
src/version/spaVersion.ts |
Central exported SPA version string based on injected build metadata. |
src/vite-env.d.ts |
Adds TypeScript typings for the new import.meta.env keys. |
src/sections/layout/footer/Footer.tsx |
Displays the SPA version in the footer using i18n. |
src/sections/layout/footer/Footer.module.scss |
Adjusts footer layout to accommodate SPA + Dataverse version rows. |
public/locales/en/footer.json |
Adds spaVersion translation. |
public/locales/es/footer.json |
Adds spaVersion translation (currently English text). |
tests/component/version/resolveSpaVersionDisplay.spec.ts |
Adds unit tests for version display selection logic. |
tests/component/sections/layout/footer/Footer.spec.tsx |
Updates footer test expectations to include SPA version (currently mismatched). |
dev-env/vite.config.ts |
Adds version metadata injection for dev env, plus root/alias adjustments. |
dev-env/shib-dev-env/vite.config.ts |
Adds version metadata injection for shib dev env, plus root/alias adjustments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const projectRoot = candidates.find((candidate) => { | ||
| return Boolean(readTextFile(path.join(candidate, 'package.json'))) && Boolean(readTextFile(path.join(candidate, '.git'))) | ||
| }) |
There was a problem hiding this comment.
resolveProjectRoot tries to detect the repo root by calling readTextFile(..., '.git'). In a normal clone .git is a directory, so readFileSync throws and readTextFile returns undefined, causing the root detection to fail and projectRoot to incorrectly fall back to configDir. Use an existence check that works for directories (e.g., existsSync / statSync) or rework the condition to treat a .git directory as present.
| const projectRoot = candidates.find((candidate) => { | ||
| return Boolean(readTextFile(path.join(candidate, 'package.json'))) && Boolean(readTextFile(path.join(candidate, '.git'))) | ||
| }) |
There was a problem hiding this comment.
resolveProjectRoot uses readTextFile to check for .git, but .git is typically a directory. This makes the project root detection fail and can break root/alias resolution. Switch to an existence check that supports directories (e.g., existsSync / statSync) or otherwise handle .git directories explicitly.
| function resolveSpaVersionDisplay({ | ||
| packageVersion, | ||
| commitSha, | ||
| exactTag, | ||
| refName, | ||
| refType |
There was a problem hiding this comment.
The resolveSpaVersionDisplay logic is duplicated here even though an equivalent helper now exists in src/version/resolveSpaVersionDisplay.ts (and is imported by the root vite.config.ts). Consider importing the shared helper instead of maintaining another copy to avoid drift between dev-env and production version formatting.
| function resolveSpaVersionDisplay({ | ||
| packageVersion, | ||
| commitSha, | ||
| exactTag, | ||
| refName, | ||
| refType |
There was a problem hiding this comment.
This config duplicates resolveSpaVersionDisplay even though the same logic exists in src/version/resolveSpaVersionDisplay.ts. Importing the shared helper would reduce duplication and prevent dev-env version display from diverging from production builds.
| cy.findByText('Privacy Policy').should('exist') | ||
| cy.findByAltText('The Dataverse Project logo').should('exist') | ||
| cy.findByText(testVersion).should('exist') | ||
| cy.findByText(`SPA: ${spaVersion}`).should('exist') |
There was a problem hiding this comment.
The footer now renders the SPA version via the i18n string t('spaVersion', { version: spaVersion }), but this test asserts a hard-coded SPA: ${spaVersion} string. This will fail with the current footer.json values (e.g. "frontend version: {{version}}"). Update the assertion to match the translated output (or assert on the spaVersion key’s resolved text).
| cy.findByText(`SPA: ${spaVersion}`).should('exist') | |
| cy.findByText(spaVersion).should('exist') |
add spanish translation Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ChengShi-1
left a comment
There was a problem hiding this comment.
Looks good with new banner

What this PR does / why we need it:
Adds a frontend version label to the footer so the SPA shows either the official release version or, for non-release builds, the short commit SHA. The footer still shows the Dataverse backend version as before; this PR adds the SPA version alongside it. The display logic prefers the package version when the build is on an exact matching release tag and otherwise falls back to the commit hash.
Which issue(s) this PR closes:
Special notes for your reviewer:
To force the footer to update and show the version, disable the local cache in your browser
Suggestions on how to test this:
build the App and review the footer display. Is the right wording?
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes or changelog update needed for this change?:
Additional documentation: