From c839d88af83ce551bd171703ec0902b1e79b3db1 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 2 Oct 2017 16:21:41 +0200 Subject: [PATCH] SONAR-9499 Secondary locations unclickable when code is not loaded --- .../issues/components/IssuesSourceViewer.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js index ef5904ea704..06ba694e1cd 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js @@ -75,17 +75,28 @@ export default class IssuesSourceViewer extends React.PureComponent { ? openIssue.flows[selectedFlowIndex] : openIssue.flows.length > 0 ? openIssue.flows[0] : openIssue.secondaryLocations; - const locationMessage = + let locationMessage = undefined; + let locationLine = undefined; + if ( locations != null && selectedLocationIndex != null && locations.length >= selectedLocationIndex - ? { index: selectedLocationIndex, text: locations[selectedLocationIndex].msg } - : undefined; + ) { + locationMessage = { + index: selectedLocationIndex, + text: locations[selectedLocationIndex].msg + }; + locationLine = locations[selectedLocationIndex].textRange.startLine; + } + + // if location is selected, show (and load) code around it + // otherwise show code around the open issue + const aroundLine = locationLine || (openIssue.textRange && openIssue.textRange.endLine); return (
(this.node = node)}>