From 7674a1465d06a513879ff09e66e0eb8746dcc837 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Thu, 23 Nov 2017 14:19:58 +0100 Subject: [PATCH] SONAR-10087 SONAR-10113 Display built-in badges on quality gates --- .../src/main/js/api/quality-gates.ts | 1 + .../quality-gates/components/BuiltInBadge.tsx | 45 +++++++++++++++++++ .../quality-gates/components/DetailsHeader.js | 6 ++- .../js/apps/quality-gates/components/List.js | 10 +++-- .../resources/org/sonar/l10n/core.properties | 4 ++ 5 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInBadge.tsx diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts index 9857a9c2b2a..325f181c7bb 100644 --- a/server/sonar-web/src/main/js/api/quality-gates.ts +++ b/server/sonar-web/src/main/js/api/quality-gates.ts @@ -25,6 +25,7 @@ export function fetchQualityGatesAppDetails(): Promise { } 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 index 00000000000..6d5ad233540 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/BuiltInBadge.tsx @@ -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 = ( +
+ {translate('quality_gates.built_in')} +
+ ); + + const overlay = ( +
+

{translate('quality_gates.built_in.description.1')}

+

{translate('quality_gates.built_in.description.2')}

+
+ ); + + return tooltip ? {badge} : badge; +} diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js index f70313e9a59..db4c2bb5fcd 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js @@ -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 {
-

{qualityGate.name}

+

+ {qualityGate.name} + {qualityGate.isBuiltIn && } +

{edit && (