aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-05-30 11:21:43 +0200
committerEric Hartmann <hartmann.eric@gmail.com>2017-06-14 15:43:12 +0200
commitf7e2e9c191c8da127f2d0d8504ad0fa9f816191b (patch)
tree19e6d702fa670db284affc81ae6386de0be8cd9f /server/sonar-web/src/main/js
parent702b6393c7b9e77886908bfd4565694b13ccdef8 (diff)
downloadsonarqube-f7e2e9c191c8da127f2d0d8504ad0fa9f816191b.tar.gz
sonarqube-f7e2e9c191c8da127f2d0d8504ad0fa9f816191b.zip
SONAR-9302 Display built-in flag on Quality profiles page
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js51
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js9
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js1
-rw-r--r--server/sonar-web/src/main/js/components/common/PrivateBadge.css12
-rw-r--r--server/sonar-web/src/main/js/components/common/PrivateBadge.js1
6 files changed, 63 insertions, 13 deletions
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 = (
+ <div className={classNames('built-in-badge', props.className)}>
+ {translate('quality_profiles.built_in')}
+ </div>
+ );
+
+ const overlay = (
+ <span>
+ {translate('quality_profiles.built_in.description.1')}
+ {' '}
+ {translate('quality_profiles.built_in.description.2')}
+ </span>
+ );
+
+ return props.tooltip ? <Tooltip overlay={overlay}>{badge}</Tooltip> : 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}>
<span>{profile.name}</span>
</ProfileLink>
+ {profile.isBuiltIn && <BuiltInBadge className="spacer-left" tooltip={false} />}
</h1>
<div className="pull-right">
@@ -146,6 +148,13 @@ export default class ProfileHeader extends React.PureComponent {
</li>
</ul>
</div>
+
+ {profile.isBuiltIn &&
+ <div className="page-description">
+ {translate('quality_profiles.built_in.description.1')}
+ <br />
+ {translate('quality_profiles.built_in.description.2')}
+ </div>}
</header>
);
}
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}
</ProfileLink>
+ {profile.isBuiltIn && <BuiltInBadge className="spacer-left" />}
</div>
);
}
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,