]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10381 Activity page of a file should not be accessible
authorStas Vilchik <stas.vilchik@sonarsource.com>
Wed, 28 Mar 2018 11:13:06 +0000 (13:13 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 29 Mar 2018 18:20:47 +0000 (20:20 +0200)
server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js
server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.js

index 9455760a908e4b9f3d532f07bfd028e6845ae5d6..1e247a65c21eb4fac4ee95617d469ecfcd9c3728 100644 (file)
@@ -46,6 +46,7 @@ import { isDiffMetric } from '../../../helpers/measures';
 export default function MeasureHeader(props /*: Props*/) {
   const { branchLike, component, leakPeriod, measure, metric, secondaryMeasure } = props;
   const isDiff = isDiffMetric(metric.key);
+  const hasHistory = component.qualifier !== 'FIL' && component.qualifier !== 'UTS';
   return (
     <div className="measure-details-header big-spacer-bottom">
       <div className="measure-details-primary">
@@ -70,17 +71,18 @@ export default function MeasureHeader(props /*: Props*/) {
               )}
             </strong>
           </span>
-          {!isDiff && (
-            <Tooltip
-              overlay={translate('component_measures.show_metric_history')}
-              placement="right">
-              <Link
-                className="js-show-history spacer-left button button-small"
-                to={getMeasureHistoryUrl(component.key, metric.key, branchLike)}>
-                <HistoryIcon />
-              </Link>
-            </Tooltip>
-          )}
+          {!isDiff &&
+            hasHistory && (
+              <Tooltip
+                overlay={translate('component_measures.show_metric_history')}
+                placement="right">
+                <Link
+                  className="js-show-history spacer-left button button-small"
+                  to={getMeasureHistoryUrl(component.key, metric.key, branchLike)}>
+                  <HistoryIcon />
+                </Link>
+              </Tooltip>
+            )}
         </div>
         <div className="measure-details-primary-actions">
           {leakPeriod != null && (
index 8e177e736dfd76c4809afe7ea35c56dac8252730..3d1130b7862f5160e6f3464cf7a2455e26cba3dd 100644 (file)
@@ -90,6 +90,20 @@ it('should render with branch', () => {
   ).toMatchSnapshot();
 });
 
+it('should not render link to activity page for files', () => {
+  expect(
+    shallow(<MeasureHeader {...PROPS} />)
+      .find('IconHistory')
+      .exists()
+  ).toBeTruthy();
+
+  expect(
+    shallow(<MeasureHeader {...PROPS} component={{ ...PROPS.component, qualifier: 'FIL' }} />)
+      .find('IconHistory')
+      .exists()
+  ).toBeFalsy();
+});
+
 it('should display secondary measure too', () => {
   const wrapper = shallow(<MeasureHeader {...PROPS} secondaryMeasure={SECONDARY} />);
   expect(wrapper.find('Connect(LanguageDistribution)')).toHaveLength(1);