]> source.dussan.org Git - sonarqube.git/commitdiff
Fix for failing IT should_drilldown_on_tree_view
authorPascal Mugnier <pascal.mugnier@sonarsource.com>
Thu, 19 Apr 2018 06:29:30 +0000 (08:29 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 19 Apr 2018 18:20:44 +0000 (20:20 +0200)
server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.js

index 25b6b7b4f107de3d2b66c634b677b353afd1a984..9b2ce2e9b6ee06c09a8ca8d6a1304f38ee289311 100644 (file)
@@ -23,7 +23,11 @@ import { Link } from 'react-router';
 import LinkIcon from '../../../components/icons-components/LinkIcon';
 import QualifierIcon from '../../../components/icons-components/QualifierIcon';
 import { splitPath } from '../../../helpers/path';
-import { getBranchLikeUrl, getComponentDrilldownUrlWithSelection } from '../../../helpers/urls';
+import {
+  getPathUrlAsString,
+  getBranchLikeUrl,
+  getComponentDrilldownUrlWithSelection
+} from '../../../helpers/urls';
 /*:: import type { Component, ComponentEnhanced } from '../types'; */
 /*:: import type { Metric } from '../../../store/metrics/actions'; */
 
@@ -38,6 +42,16 @@ import { getBranchLikeUrl, getComponentDrilldownUrlWithSelection } from '../../.
 export default class ComponentCell extends React.PureComponent {
   /*:: props: Props; */
 
+  handleClick = (e /*: MouseEvent */) => {
+    const isLeftClickEvent = e.button === 0;
+    const isModifiedEvent = !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
+
+    if (isLeftClickEvent && !isModifiedEvent) {
+      e.preventDefault();
+      this.props.onClick(this.props.component.key);
+    }
+  };
+
   renderInner() {
     const { component } = this.props;
     let head = '';
@@ -63,17 +77,20 @@ export default class ComponentCell extends React.PureComponent {
       <td className="measure-details-component-cell">
         <div className="text-ellipsis">
           {component.refKey == null ? (
-            <Link
+            <a
               className="link-no-underline"
+              href={getPathUrlAsString(
+                getComponentDrilldownUrlWithSelection(
+                  rootComponent.key,
+                  component.key,
+                  metric.key,
+                  branchLike
+                )
+              )}
               id={'component-measures-component-link-' + component.key}
-              to={getComponentDrilldownUrlWithSelection(
-                rootComponent.key,
-                component.key,
-                metric.key,
-                branchLike
-              )}>
+              onClick={this.handleClick}>
               {this.renderInner()}
-            </Link>
+            </a>
           ) : (
             <Link
               className="link-no-underline"