Skip to content

Add a frontend version tag to Footer.tsx#960

Merged
jp-tosca merged 11 commits intodevelopfrom
959-display-version
Apr 24, 2026
Merged

Add a frontend version tag to Footer.tsx#960
jp-tosca merged 11 commits intodevelopfrom
959-display-version

Conversation

@ekraffmiller
Copy link
Copy Markdown
Contributor

@ekraffmiller ekraffmiller commented Apr 20, 2026

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:

Screenshot 2026-04-21 at 1 32 32 PM

Is there a release notes or changelog update needed for this change?:

Additional documentation:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Footer and 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.

Comment thread public/locales/es/footer.json Outdated
Comment thread dev-env/vite.config.ts Outdated
Comment on lines +44 to +46
const projectRoot = candidates.find((candidate) => {
return Boolean(readTextFile(path.join(candidate, 'package.json'))) && Boolean(readTextFile(path.join(candidate, '.git')))
})
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread dev-env/shib-dev-env/vite.config.ts Outdated
Comment on lines +44 to +46
const projectRoot = candidates.find((candidate) => {
return Boolean(readTextFile(path.join(candidate, 'package.json'))) && Boolean(readTextFile(path.join(candidate, '.git')))
})
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread dev-env/vite.config.ts Outdated
Comment on lines +14 to +19
function resolveSpaVersionDisplay({
packageVersion,
commitSha,
exactTag,
refName,
refType
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread dev-env/shib-dev-env/vite.config.ts Outdated
Comment on lines +14 to +19
function resolveSpaVersionDisplay({
packageVersion,
commitSha,
exactTag,
refName,
refType
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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')
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
cy.findByText(`SPA: ${spaVersion}`).should('exist')
cy.findByText(spaVersion).should('exist')

Copilot uses AI. Check for mistakes.
ekraffmiller and others added 2 commits April 20, 2026 09:58
add spanish translation

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 20, 2026

Coverage Status

coverage: 97.515% (-0.06%) from 97.57% — 959-display-version into develop

@ekraffmiller ekraffmiller marked this pull request as ready for review April 21, 2026 17:38
@ekraffmiller ekraffmiller moved this to Ready for Review ⏩ in IQSS Dataverse Project Apr 21, 2026
@ekraffmiller ekraffmiller added GREI Re-arch GREI re-architecture-related FY26 Sprint 21 FY26 Sprint 21 (2026-04-08 - 2026-04-22) labels Apr 21, 2026
@ChengShi-1 ChengShi-1 self-assigned this Apr 22, 2026
@ChengShi-1 ChengShi-1 self-requested a review April 22, 2026 14:51
Copy link
Copy Markdown
Contributor

@ChengShi-1 ChengShi-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks goodImage

@github-project-automation github-project-automation Bot moved this from Ready for Review ⏩ to Ready for QA ⏩ in IQSS Dataverse Project Apr 22, 2026
@cmbz cmbz added the FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) label Apr 22, 2026
@ChengShi-1 ChengShi-1 removed their assignment Apr 23, 2026
Copy link
Copy Markdown
Contributor

@ChengShi-1 ChengShi-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with new banner

@jp-tosca jp-tosca self-assigned this Apr 23, 2026
@jp-tosca jp-tosca merged commit 3895667 into develop Apr 24, 2026
16 of 22 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for QA ⏩ to Merged 🚀 in IQSS Dataverse Project Apr 24, 2026
@jp-tosca jp-tosca removed their assignment Apr 24, 2026
@scolapasta scolapasta moved this from Merged 🚀 to Done 🧹 in IQSS Dataverse Project Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY26 Sprint 21 FY26 Sprint 21 (2026-04-08 - 2026-04-22) FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) GREI Re-arch GREI re-architecture-related Project: HDV SPA Rollout

Projects

Status: Done 🧹

Development

Successfully merging this pull request may close these issues.

Feature Request/Idea: Show the version of the SPA

7 participants