]> source.dussan.org Git - sonarqube.git/commitdiff
display a real link to project on view projects page
authorStas Vilchik <vilchiks@gmail.com>
Wed, 3 Feb 2016 15:21:44 +0000 (16:21 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 3 Feb 2016 15:40:34 +0000 (16:40 +0100)
server/sonar-web/src/main/js/apps/code/components/ComponentName.js

index dde1849ce4b8b2c0882d0374e285bb27df99afa8..fff2478cfe34c31bac37ec6018259e1cab9a18c8 100644 (file)
@@ -22,6 +22,7 @@ import React from 'react';
 
 import Truncated from './Truncated';
 import QualifierIcon from '../../../components/shared/qualifier-icon';
+import { getComponentUrl } from '../../../helpers/urls';
 
 
 function getTooltip (component) {
@@ -62,23 +63,24 @@ const Component = ({ component, previous, onBrowse }) => {
         <span>{component.name.substr(prefix.length)}</span>
       </span>
   ) : component.name;
-  const canBrowse = !!onBrowse;
+
+  let inner = null;
+
+  if (component.refKey) {
+    inner = <a href={getComponentUrl(component.refKey)}>{name}</a>;
+  } else {
+    if (onBrowse) {
+      inner = <a onClick={handleClick} href="#">{name}</a>;
+    } else {
+      inner = <span>{name}</span>;
+    }
+  }
 
   return (
       <Truncated title={getTooltip(component)}>
         <QualifierIcon qualifier={component.qualifier}/>
         {' '}
-        {canBrowse ? (
-            <a
-                onClick={handleClick}
-                href="#">
-              {name}
-            </a>
-        ) : (
-            <span>
-              {name}
-            </span>
-        )}
+        {inner}
       </Truncated>
   );
 };