aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2017-10-02 16:21:41 +0200
committerStas Vilchik <stas.vilchik@sonarsource.com>2017-10-03 09:12:07 +0200
commitc839d88af83ce551bd171703ec0902b1e79b3db1 (patch)
treec97eeb2109b6ecce278b81fcb30af58126c772d8 /server
parent1b75e33aa632a384e8c6b4c266a0c65ccd9fa5de (diff)
downloadsonarqube-c839d88af83ce551bd171703ec0902b1e79b3db1.tar.gz
sonarqube-c839d88af83ce551bd171703ec0902b1e79b3db1.zip
SONAR-9499 Secondary locations unclickable when code is not loaded
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js19
1 files 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 (
<div ref={node => (this.node = node)}>
<SourceViewer
- aroundLine={openIssue.textRange ? openIssue.textRange.endLine : undefined}
+ aroundLine={aroundLine}
branch={this.props.branch}
component={openIssue.component}
displayAllIssues={true}