Fix missing code navigation for blame on legacy files
What does this MR do and why?
legacyViewerLoaded did not account for BLAME_VIEWER, even though loadLegacyViewer already assigns blame HTML to legacySimpleViewer. This left the computed property false while blame was active, which defeated the early-return guard in loadLegacyViewer and prevented CodeIntelligence from rendering for blame on legacy files.
The problem is pre-existing, but became observable after inline blame was fixed for legacy files.
References :
- Closes #605636
- Related: !244836 (merged) added the
BLAME_VIEWERbranch inloadLegacyViewerthat routes blame HTML intolegacySimpleViewer. That routing is inmaster, and it's what makes this gap observable. - Related: #605627 (closed), the inline blame bug that MR fixed.
Differences and Changes :
Before :
- Blame HTML was fetched and stored in
legacySimpleViewer. legacyViewerLoadednever checkedBLAME_VIEWER, so it stayedfalse.- The duplicate-fetch guard stopped blocking once loading finished, allowing re-fetches.
<code-intelligence>and the code-navigation button never rendered in blame view.
After :
- Blame HTML is fetched and stored in
legacySimpleViewer. legacyViewerLoadednow checksBLAME_VIEWER, so it becomestrueonce loaded.- The duplicate-fetch guard blocks repeat requests as intended.
<code-intelligence>and the code-navigation button render in blame view.
How to set up and validate locally :
Automated (no GDK required):
yarn install --frozen-lockfileyarn jest spec/frontend/repository/components/blob_content_viewer_spec.js
The added test is renders CodeIntelligence when blame is active on load for a legacy file. I confirmed it catches the bug by reverting the source change and running it alone:
● Blob content viewer component › simple viewer › legacy viewers ›
renders CodeIntelligence when blame is active on load for a legacy file
Expected: true
Received: false
Tests: 1 failed, 90 skipped, 91 totalWith the fix in place, both the CE and EE suites pass:
PASS ee/spec/frontend/repository/components/blob_content_viewer_spec.js
PASS spec/frontend/repository/components/blob_content_viewer_spec.js
Tests: 91 passed, 91 totalManual (optional, requires GDK):
- Open a legacy-type file with blame active, for example
/<group>/<project>/-/blob/<ref>/go.mod?blame=1 - In Vue DevTools, select
BlobContentViewerand inspect the computed propertylegacyViewerLoaded.- Before:
false, even though the blame content has rendered - After:
true
- Before:
- Confirm
<code-intelligence>is present in the DOM after the change and absent before.
MR acceptance checklist :
I went through the acceptance checklist. It's a small frontend change, so here's what's relevant:
- Added a test, and confirmed it fails without the fix.
- Follows the Vue style guide.
-
Changelog: fixedtrailer is on the commit. - No user-facing strings, so nothing to translate.
- CE-only change, so no
EE: truetrailer. - No performance, security, or database impact, only one extra boolean check in an existing computed property.
Let me know if you'd like anything expanded.