Hide the Pages live block when there is no active deployment

What does this MR do and why?

On Deploy > Pages, a project with Pages but no active primary deployment (for example after its only deployment was stopped) throws TypeError: Cannot read properties of null (reading 'active') in the live block.

deployments.vue passes newestDeployment to live-block, and that computed returns null when the query has no active primary deployment. Once loading finishes, isLoading becomes false while deployment is still null. The deployment prop default (() => ({})) only applies to undefined, so the #title slot reads deployment.active (and domainName reads deployment.url) on null and throws. This happens on Vue 2 and Vue 3.

This MR renders live-block only while the deployments are loading (so the skeleton loader still shows) or when there is a deployment to show. The block says "Your Pages site is live", which is not true without a deployment, and the Deployments list below already shows its "No deployments yet" empty state. With Show stopped deployments turned on, the newest deployment may be a stopped one, and the block keeps its existing non-link rendering for it.

Screenshots or screen recordings

I cannot capture live GitLab UI screenshots from this environment (no signed-in Pages UI to record). Written before and after:

  • Before: On Deploy > Pages, after deployments finish loading, the "Your Pages site is live" block still rendered when there was no active primary deployment (newestDeployment was null). The console showed TypeError: Cannot read properties of null (reading 'active'), and the live block had no title.
  • After: The live block renders only while deployments are loading (skeleton) or when there is a deployment to show. With no active primary deployment, the live block is not rendered. The Deployments list keeps its existing "No deployments yet" empty state. When a deployment does exist, the live block is unchanged.

If actual screenshots are still needed, I would be grateful if a reviewer can attach them, or can point me at another way to provide them.

How to set up and validate locally

  1. Create a project with a Pages deployment, then stop or delete the deployment so there is no active primary deployment.
  2. Open Deploy > Pages with the browser console open.
  3. Before: the console shows the TypeError and the live block has no title. After: no error, and the live block is not rendered.

Jest (spec/frontend/gitlab_pages/components/deployments_spec.js) now checks that the live block shows the newest deployment, renders its loading state while the queries are in flight, and is not rendered once the query returns no active primary deployment.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

References

Closes #642598 (closed)

Found during #642429.

Edited by Priyanshu Jha

Merge request reports

Loading
Loading