aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-03-28 13:13:06 +0200
committerSonarTech <sonartech@sonarsource.com>2018-03-29 20:20:47 +0200
commitc992c853f2efb2f7fcb72471af5f69feed99ba39 (patch)
treea6b39484be2ff64c2b8d80445123e9b65dcbb9e9 /server/sonar-web/src/main
parentd83499117dfcdfb1664e98d61ddd511a7248f135 (diff)
downloadsonarqube-c992c853f2efb2f7fcb72471af5f69feed99ba39.tar.gz
sonarqube-c992c853f2efb2f7fcb72471af5f69feed99ba39.zip
SONAR-10381 Activity page of a file should not be accessible
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js24
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.js14
2 files changed, 27 insertions, 11 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js
index 9455760a908..1e247a65c21 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js
@@ -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 && (
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.js b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.js
index 8e177e736df..3d1130b7862 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.js
@@ -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);