Explorar el Código

SONAR-11379 Display estimated duplications and disable drilldown (#868)

tags/7.5
Stas Vilchik hace 5 años
padre
commit
dbee5e8b45

+ 20
- 1
server/sonar-web/src/main/js/apps/component-measures/components/App.tsx Ver fichero

@@ -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}

+ 9
- 2
server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx Ver fichero

@@ -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();
});

+ 45
- 1
server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap Ver fichero

@@ -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 [

+ 1
- 0
server/sonar-web/src/main/js/apps/component-measures/utils.ts Ver fichero

@@ -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'

+ 1
- 0
sonar-core/src/main/resources/org/sonar/l10n/core.properties Ver fichero

@@ -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

Cargando…
Cancelar
Guardar