From f7e2e9c191c8da127f2d0d8504ad0fa9f816191b Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 30 May 2017 11:21:43 +0200 Subject: SONAR-9302 Display built-in flag on Quality profiles page --- .../quality-profiles/components/BuiltInBadge.js | 51 ++++++++++++++++++++++ .../apps/quality-profiles/details/ProfileHeader.js | 9 ++++ .../apps/quality-profiles/home/ProfilesListRow.js | 2 + .../src/main/js/apps/quality-profiles/propTypes.js | 1 + .../src/main/js/components/common/PrivateBadge.css | 12 ----- .../src/main/js/components/common/PrivateBadge.js | 1 - 6 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js delete mode 100644 server/sonar-web/src/main/js/components/common/PrivateBadge.css (limited to 'server/sonar-web/src/main/js') diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js new file mode 100644 index 00000000000..1703b88767f --- /dev/null +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js @@ -0,0 +1,51 @@ +/* + * 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. + */ +// @flow +import React from 'react'; +import classNames from 'classnames'; +import Tooltip from '../../../components/controls/Tooltip'; +import { translate } from '../../../helpers/l10n'; + +type Props = {| + className?: string, + tooltip?: boolean +|}; + +export default function BuiltInBadge(props: Props) { + const badge = ( +
+ {translate('quality_profiles.built_in')} +
+ ); + + const overlay = ( + + {translate('quality_profiles.built_in.description.1')} + {' '} + {translate('quality_profiles.built_in.description.2')} + + ); + + return props.tooltip ? {badge} : badge; +} + +BuiltInBadge.defaultProps = { + tooltip: true +}; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js index 02e1b508ff2..2073ecb7c2a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js @@ -23,6 +23,7 @@ import { Link, IndexLink } from 'react-router'; import ProfileLink from '../components/ProfileLink'; import ProfileActions from '../components/ProfileActions'; import ProfileDate from '../components/ProfileDate'; +import BuiltInBadge from '../components/BuiltInBadge'; import { translate } from '../../../helpers/l10n'; import { isStagnant, @@ -115,6 +116,7 @@ export default class ProfileHeader extends React.PureComponent { organization={organization}> {profile.name} + {profile.isBuiltIn && }
@@ -146,6 +148,13 @@ export default class ProfileHeader extends React.PureComponent {
+ + {profile.isBuiltIn && +
+ {translate('quality_profiles.built_in.description.1')} +
+ {translate('quality_profiles.built_in.description.2')} +
} ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js index ec8bcf086e4..0547623d744 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js @@ -23,6 +23,7 @@ import { Link } from 'react-router'; import ProfileLink from '../components/ProfileLink'; import ProfileDate from '../components/ProfileDate'; import ProfileActions from '../components/ProfileActions'; +import BuiltInBadge from '../components/BuiltInBadge'; import { translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; import { isStagnant } from '../utils'; @@ -50,6 +51,7 @@ export default class ProfilesListRow extends React.PureComponent { organization={this.props.organization}> {profile.name} + {profile.isBuiltIn && } ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js b/server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js index 92af7067b7b..12a872f056b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js @@ -25,6 +25,7 @@ const { shape, string, number, bool, arrayOf } = PropTypes; export type Profile = { key: string, name: string, + isBuiltIn: boolean, isDefault: boolean, isInherited: boolean, language: string, diff --git a/server/sonar-web/src/main/js/components/common/PrivateBadge.css b/server/sonar-web/src/main/js/components/common/PrivateBadge.css deleted file mode 100644 index a5a772ac53a..00000000000 --- a/server/sonar-web/src/main/js/components/common/PrivateBadge.css +++ /dev/null @@ -1,12 +0,0 @@ -.private-badge { - display: inline-block; - vertical-align: middle; - height: 20px; - line-height: 19px; - padding: 0 8px; - border: 1px solid #cdcdcd; - border-radius: 2px; - box-sizing: border-box; - color: #777; - font-size: 12px; -} diff --git a/server/sonar-web/src/main/js/components/common/PrivateBadge.js b/server/sonar-web/src/main/js/components/common/PrivateBadge.js index a949dc4d1dc..cee6b2f3ffd 100644 --- a/server/sonar-web/src/main/js/components/common/PrivateBadge.js +++ b/server/sonar-web/src/main/js/components/common/PrivateBadge.js @@ -22,7 +22,6 @@ import React from 'react'; import classNames from 'classnames'; import Tooltip from '../controls/Tooltip'; import { translate } from '../../helpers/l10n'; -import './PrivateBadge.css'; type Props = { className?: string, -- cgit v1.2.3