From 6b3ff763eb594ea00e3d179104c624c946e77fae Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 4 Oct 2017 15:55:42 +0200 Subject: [PATCH] SONAR-9352 display a message on project dashboard --- .../apps/overview/qualityGate/QualityGate.js | 18 +++++++- .../qualityGate/__tests__/QualityGate-test.js | 42 +++++++++++++++++++ .../__snapshots__/QualityGate-test.js.snap | 34 +++++++++++++++ server/sonar-web/src/main/less/init/misc.less | 2 +- .../resources/org/sonar/l10n/core.properties | 2 + 5 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js create mode 100644 server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js index b840599b347..df5fbf0c801 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js @@ -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 */ + {ignoredConditions && ( +
+ {translate('overview.quality_gate.ignored_conditions')} + + + + + +
+ )} + {conditions.length > 0 && ( )} diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js new file mode 100644 index 00000000000..b21b1c67a16 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js @@ -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( + + ) + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap new file mode 100644 index 00000000000..13d1efdd295 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap @@ -0,0 +1,34 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders message about ignored conditions 1`] = ` +
+

+ overview.quality_gate + +

+
+ overview.quality_gate.ignored_conditions + + + + + +
+
+`; diff --git a/server/sonar-web/src/main/less/init/misc.less b/server/sonar-web/src/main/less/init/misc.less index ddca44d3771..c927347bea7 100644 --- a/server/sonar-web/src/main/less/init/misc.less +++ b/server/sonar-web/src/main/less/init/misc.less @@ -227,7 +227,7 @@ td.big-spacer-top { } .display-inline-block { - display: inline-block; + display: inline-block !important; } .rounded { 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 7d1eed01f40..69937115678 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -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} -- 2.39.5