aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-10-23 11:08:28 +0200
committerSonarTech <sonartech@sonarsource.com>2018-11-07 20:21:03 +0100
commitdbee5e8b4541305dc8e7610757d50551a1593267 (patch)
treeabdf1847bfe0b1ecd19f363647a9d52c1e3e54ba
parent7c8113fcecf6e123c9cff834ecf50df20a30825d (diff)
downloadsonarqube-dbee5e8b4541305dc8e7610757d50551a1593267.tar.gz
sonarqube-dbee5e8b4541305dc8e7610757d50551a1593267.zip
SONAR-11379 Display estimated duplications and disable drilldown (#868)
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/App.tsx21
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx11
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap46
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/utils.ts1
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties1
5 files changed, 76 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx
index 97111db9d91..3ecb85b9786 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx
@@ -37,7 +37,12 @@ import {
groupByDomains,
sortMeasures
} from '../utils';
-import { isSameBranchLike, getBranchLikeQuery } from '../../../helpers/branches';
+import {
+ isSameBranchLike,
+ getBranchLikeQuery,
+ isShortLivingBranch,
+ isPullRequest
+} from '../../../helpers/branches';
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
import {
getLocalizedMetricDomain,
@@ -224,6 +229,20 @@ export default class App extends React.PureComponent<Props, State> {
return <MeasuresEmpty />;
}
+ const hideDrilldown =
+ (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) &&
+ (metric.key === 'coverage' || metric.key === 'duplicated_lines_density');
+
+ if (hideDrilldown) {
+ return (
+ <div className="layout-page-main">
+ <div className="layout-page-main-inner">
+ <div className="note">{translate('component_measures.details_are_not_available')}</div>
+ </div>
+ </div>
+ );
+ }
+
return (
<MeasureContentContainer
branchLike={branchLike}
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx
index a289907ff56..4880363f374 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx
@@ -44,8 +44,8 @@ const METRICS = {
new_bugs: { id: '4', key: 'new_bugs', type: 'INT', name: 'New Bugs', domain: 'Reliability' }
};
-const PROPS = {
- branch: { isMain: true, name: 'master' },
+const PROPS: App['props'] = {
+ branchLike: { isMain: true, name: 'master' },
component: COMPONENT,
currentUser: { isLoggedIn: false },
location: { pathname: '/component_measures', query: { metric: 'coverage' } },
@@ -84,3 +84,10 @@ it('should render a message when there are no measures', async () => {
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot();
});
+
+it('should not render drilldown for estimated duplications', async () => {
+ const pullRequest = { base: 'master', branch: 'feature-x', key: '5', title: '' };
+ const wrapper = shallow(<App {...PROPS} branchLike={pullRequest} />);
+ await waitAndUpdate(wrapper);
+ expect(wrapper).toMatchSnapshot();
+});
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap
index 1360a4c4482..ff587bed735 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap
@@ -1,5 +1,40 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`should not render drilldown for estimated duplications 1`] = `
+<div
+ id="component-measures"
+>
+ <Suggestions
+ suggestions="component_measures"
+ />
+ <HelmetWrapper
+ defer={true}
+ encodeSpecialCharacters={true}
+ title="Coverage"
+ />
+ <div
+ className="layout-page"
+ >
+ <ScreenPositionHelper
+ className="layout-page-side-outer"
+ />
+ <div
+ className="layout-page-main"
+ >
+ <div
+ className="layout-page-main-inner"
+ >
+ <div
+ className="note"
+ >
+ component_measures.details_are_not_available
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+`;
+
exports[`should render a message when there are no measures 1`] = `
<div
id="component-measures"
@@ -37,6 +72,12 @@ exports[`should render correctly 1`] = `
<Component />
</ScreenPositionHelper>
<MeasureContentContainer
+ branchLike={
+ Object {
+ "isMain": true,
+ "name": "master",
+ }
+ }
className="layout-page-main"
currentUser={
Object {
@@ -54,7 +95,10 @@ exports[`should render correctly 1`] = `
"duplicated_lines_density",
"new_bugs",
],
- undefined,
+ Object {
+ "isMain": true,
+ "name": "master",
+ },
],
],
"results": Array [
diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts
index 12884e3046e..05f0713f257 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts
+++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts
@@ -172,6 +172,7 @@ export function getMeasuresPageMetricKeys(metrics: { [key: string]: Metric }, br
'new_uncovered_conditions',
'new_branch_coverage',
+ 'duplicated_lines_density',
'new_duplicated_lines_density',
'new_duplicated_lines',
'new_duplicated_blocks'
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 373aa1a57ce..880990a561b 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -2535,6 +2535,7 @@ code.search_placeholder.portfolio=Search for projects and sub-portfolios...
# COMPONENT MEASURES
#
#------------------------------------------------------------------------------
+component_measures.details_are_not_available=Details are not available for estimated measures.
component_measures.domain_x_overview={0} Overview
component_measures.domain_overview=Overview
component_measures.files=files