Browse Source

SONAR-9352 display a message on project dashboard

tags/6.6-RC1
Stas Vilchik 6 years ago
parent
commit
6b3ff763eb

+ 17
- 1
server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js View File

@@ -23,6 +23,8 @@ import QualityGateConditions from './QualityGateConditions';
import EmptyQualityGate from './EmptyQualityGate';
import { translate } from '../../../helpers/l10n';
import Level from '../../../components/ui/Level';
import Tooltip from '../../../components/controls/Tooltip';
import HelpIcon from '../../../components/icons-components/HelpIcon';
/*:: import type { Component, MeasuresList } from '../types'; */

function parseQualityGateDetails(rawDetails /*: string */) {
@@ -52,8 +54,11 @@ export default function QualityGate({ branch, component, measures } /*: Props */
const level = statusMeasure.value;

let conditions = [];
let ignoredConditions = false;
if (detailsMeasure && detailsMeasure.value) {
conditions = parseQualityGateDetails(detailsMeasure.value).conditions || [];
const details = parseQualityGateDetails(detailsMeasure.value);
conditions = details.conditions || [];
ignoredConditions = details.ignoredConditions;
}

return (
@@ -63,6 +68,17 @@ export default function QualityGate({ branch, component, measures } /*: Props */
<Level level={level} />
</h2>

{ignoredConditions && (
<div className="alert alert-info display-inline-block big-spacer-top">
{translate('overview.quality_gate.ignored_conditions')}
<Tooltip overlay={translate('overview.quality_gate.ignored_conditions.tooltip')}>
<span className="spacer-left">
<HelpIcon fill="#4b9fd5" />
</span>
</Tooltip>
</div>
)}

{conditions.length > 0 && (
<QualityGateConditions branch={branch} component={component} conditions={conditions} />
)}

+ 42
- 0
server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js View File

@@ -0,0 +1,42 @@
/*
* SonarQube
* Copyright (C) 2009-2017 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
import { shallow } from 'enzyme';
import QualityGate from '../QualityGate';

it('renders message about ignored conditions', () => {
expect(
shallow(
<QualityGate
component={{ id: 'foo' }}
measures={[
{
metric: { key: 'alert_status' },
value: 'OK'
},
{
metric: { key: 'quality_gate_details' },
value: '{"level":"OK","conditions":[],"ignoredConditions":true}'
}
]}
/>
)
).toMatchSnapshot();
});

+ 34
- 0
server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap View File

@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders message about ignored conditions 1`] = `
<div
className="overview-quality-gate"
id="overview-quality-gate"
>
<h2
className="overview-title"
>
overview.quality_gate
<Level
level="OK"
/>
</h2>
<div
className="alert alert-info display-inline-block big-spacer-top"
>
overview.quality_gate.ignored_conditions
<Tooltip
overlay="overview.quality_gate.ignored_conditions.tooltip"
placement="bottom"
>
<span
className="spacer-left"
>
<HelpIcon
fill="#4b9fd5"
/>
</span>
</Tooltip>
</div>
</div>
`;

+ 1
- 1
server/sonar-web/src/main/less/init/misc.less View File

@@ -227,7 +227,7 @@ td.big-spacer-top {
}

.display-inline-block {
display: inline-block;
display: inline-block !important;
}

.rounded {

+ 2
- 0
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -2239,6 +2239,8 @@ system.set_log_level=Set logs level
overview.quality_gate=Quality Gate
overview.quality_gate_x=Quality Gate: {0}
overview.you_should_define_quality_gate=You should define a quality gate on this project.
overview.quality_gate.ignored_conditions=Some Quality Gate conditions on New Code were ignored because of the small number of New Lines
overview.quality_gate.ignored_conditions.tooltip=At the start of a leak period, if very few lines have been added or modified, it might be difficult to reach the desired level of code coverage or duplications. To prevent Quality Gate failure when there's little that can be done about it, Quality Gate conditions about duplications in new code and coverage on new code are ignored until the number of new lines is at least 20.
overview.quality_profiles=Quality Profiles
overview.leak_period_x=Leak Period: {0}
overview.started_x=started {0}

Loading…
Cancel
Save