]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9352 display a message on project dashboard
authorStas Vilchik <stas.vilchik@sonarsource.com>
Wed, 4 Oct 2017 13:55:42 +0000 (15:55 +0200)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Sat, 7 Oct 2017 07:06:25 +0000 (09:06 +0200)
server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js
server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js [new file with mode: 0644]
server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap [new file with mode: 0644]
server/sonar-web/src/main/less/init/misc.less
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index b840599b347e79f7b82bbf6b06733f18d365b8ea..df5fbf0c8018f2f9898a73f86a9bb3a5ae32d1aa 100644 (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} />
       )}
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 (file)
index 0000000..b21b1c6
--- /dev/null
@@ -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();
+});
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 (file)
index 0000000..13d1efd
--- /dev/null
@@ -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>
+`;
index ddca44d3771d36b2fb62cde6dadad6edc62b5d36..c927347bea701c11408a8bd9c3e101811ea2c040 100644 (file)
@@ -227,7 +227,7 @@ td.big-spacer-top {
 }
 
 .display-inline-block {
-  display: inline-block;
+  display: inline-block !important;
 }
 
 .rounded {
index 7d1eed01f404a19205e92206678d85625ec6532c..699371156784c2bb35496b559b796c058911a88a 100644 (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}