]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10087 SONAR-10113 Display built-in badges on quality gates
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 23 Nov 2017 13:19:58 +0000 (14:19 +0100)
committerEric Hartmann <hartmann.eric@gmail.Com>
Mon, 4 Dec 2017 12:44:55 +0000 (13:44 +0100)
server/sonar-web/src/main/js/api/quality-gates.ts
server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInBadge.tsx [new file with mode: 0644]
server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js
server/sonar-web/src/main/js/apps/quality-gates/components/List.js
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 9857a9c2b2a2c58257f784dcc9f5f60808ea2ccc..325f181c7bb5a4e3f1256ca28e294e95881deec6 100644 (file)
@@ -25,6 +25,7 @@ export function fetchQualityGatesAppDetails(): Promise<any> {
 }
 
 export interface QualityGate {
+  isBuiltIn?: boolean;
   isDefault?: boolean;
   id: number;
   name: string;
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInBadge.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInBadge.tsx
new file mode 100644 (file)
index 0000000..6d5ad23
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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 * as React from 'react';
+import * as classNames from 'classnames';
+import Tooltip from '../../../components/controls/Tooltip';
+import { translate } from '../../../helpers/l10n';
+
+interface Props {
+  className?: string;
+  tooltip?: boolean;
+}
+
+export default function BuiltInBadge({ className, tooltip = true }: Props) {
+  const badge = (
+    <div className={classNames('outline-badge', className)}>
+      {translate('quality_gates.built_in')}
+    </div>
+  );
+
+  const overlay = (
+    <div>
+      <p>{translate('quality_gates.built_in.description.1')}</p>
+      <p>{translate('quality_gates.built_in.description.2')}</p>
+    </div>
+  );
+
+  return tooltip ? <Tooltip overlay={overlay}>{badge}</Tooltip> : badge;
+}
index f70313e9a59a86fbfc1b0944832242b193024a86..db4c2bb5fcd3c81a4976faed0c331c473a4d7d2b 100644 (file)
@@ -18,6 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import React from 'react';
+import BuiltInBadge from './BuiltInBadge';
 import { translate } from '../../../helpers/l10n';
 
 export default class DetailsHeader extends React.PureComponent {
@@ -48,7 +49,10 @@ export default class DetailsHeader extends React.PureComponent {
       <div className="layout-page-header-panel layout-page-main-header issues-main-header">
         <div className="layout-page-header-panel-inner layout-page-main-header-inner">
           <div className="layout-page-main-inner">
-            <h2 className="pull-left">{qualityGate.name}</h2>
+            <h2 className="pull-left">
+              {qualityGate.name}
+              {qualityGate.isBuiltIn && <BuiltInBadge className="spacer-left" tooltip={true} />}
+            </h2>
             {edit && (
               <div className="pull-right">
                 <button id="quality-gate-rename" onClick={this.handleRenameClick}>
index 8d84ec0e6774574b3ef8830f5f521628f4010a2f..f99de57f40036543cc7e66c8cdd63e2e61dc03aa 100644 (file)
@@ -19,6 +19,7 @@
  */
 import React from 'react';
 import { Link } from 'react-router';
+import BuiltInBadge from './BuiltInBadge';
 import { translate } from '../../../helpers/l10n';
 import { getQualityGateUrl } from '../../../helpers/urls';
 
@@ -35,10 +36,13 @@ export default function List({ organization, qualityGates }) {
           <table>
             <tbody>
               <tr>
-                <td className="text-top">{qualityGate.name}</td>
-                <td className="text-top thin nowrap spacer-left">
+                <td>{qualityGate.name}</td>
+                <td className="thin nowrap spacer-left text-right">
                   {qualityGate.isDefault && (
-                    <span className="badge pull-right">{translate('default')}</span>
+                    <span className="text-middle badge">{translate('default')}</span>
+                  )}
+                  {qualityGate.isBuiltIn && (
+                    <BuiltInBadge className="little-spacer-left" tooltip={false} />
                   )}
                 </td>
               </tr>
index cc182652392838ce14c2da90ab7dec494fe6f668..ddcfa8d7041de83508a26ab059da1365440981b8 100644 (file)
@@ -1158,6 +1158,10 @@ quality_gates.conditions.error=Error
 quality_gates.duplicated_conditions=This quality gate has duplicated conditions:
 quality_gates.intro.1=Quality Gate is the set of conditions the project must meet before it can be released into production.
 quality_gates.intro.2=It is possible to set a default Quality Gate, which will be applied to all projects not explicitly assigned to some other gate.
+quality_gates.built_in=Built-in
+quality_gates.built_in.description.1=This quality gate is provided by default.
+quality_gates.built_in.description.2=It will automatically be updated with the latest recommendations.
+
 
 #------------------------------------------------------------------------------
 #