aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/code
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-01-12 15:57:03 +0100
committerStas Vilchik <vilchiks@gmail.com>2016-01-13 10:16:08 +0100
commit7254cedf6e352e2a74f2c1cb382208569c3815fd (patch)
tree3916c0b02cc6e9246cc94e06d353eae6860b7035 /server/sonar-web/src/main/js/apps/code
parent77a4197c7c2fe2b816f39d935413b4666de4fba7 (diff)
downloadsonarqube-7254cedf6e352e2a74f2c1cb382208569c3815fd.tar.gz
sonarqube-7254cedf6e352e2a74f2c1cb382208569c3815fd.zip
SONAR-7192 Create new 'Projects' page for views
Diffstat (limited to 'server/sonar-web/src/main/js/apps/code')
-rw-r--r--server/sonar-web/src/main/js/apps/code/actions/index.js3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Code.js4
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Component.js10
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/ComponentName.js3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/ComponentQualityGate.js40
-rw-r--r--server/sonar-web/src/main/js/apps/code/reducers/index.js4
-rw-r--r--server/sonar-web/src/main/js/apps/code/styles/code.css4
7 files changed, 58 insertions, 10 deletions
diff --git a/server/sonar-web/src/main/js/apps/code/actions/index.js b/server/sonar-web/src/main/js/apps/code/actions/index.js
index b387aad0aa0..040f07f5eb2 100644
--- a/server/sonar-web/src/main/js/apps/code/actions/index.js
+++ b/server/sonar-web/src/main/js/apps/code/actions/index.js
@@ -28,7 +28,8 @@ const METRICS = [
'ncloc',
'sqale_index',
'violations',
- 'duplicated_lines_density'
+ 'duplicated_lines_density',
+ 'alert_status'
];
const METRICS_WITH_COVERAGE = [
diff --git a/server/sonar-web/src/main/js/apps/code/components/Code.js b/server/sonar-web/src/main/js/apps/code/components/Code.js
index 0a78c6e6d63..31f21e09890 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Code.js
+++ b/server/sonar-web/src/main/js/apps/code/components/Code.js
@@ -72,15 +72,13 @@ class Code extends Component {
return (
<div className="page">
<header className="page-header">
- <h1 className="page-title">{translate('code.page')}</h1>
+ <Search component={this.props.component}/>
<div
className="pull-left"
style={{ visibility: fetching ? 'visible' : 'hidden' }}>
<i className="spinner"/>
</div>
-
- <Search component={this.props.component}/>
</header>
{errorMessage && (
diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.js b/server/sonar-web/src/main/js/apps/code/components/Component.js
index 4636da3028b..11471eaf355 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Component.js
+++ b/server/sonar-web/src/main/js/apps/code/components/Component.js
@@ -24,6 +24,7 @@ import { connect } from 'react-redux';
import ComponentName from './ComponentName';
import ComponentMeasure from './ComponentMeasure';
+import ComponentQualityGate from './ComponentQualityGate';
import ComponentDetach from './ComponentDetach';
import ComponentPin from './ComponentPin';
@@ -62,7 +63,7 @@ class Component extends React.Component {
}
render () {
- const { component, selected, previous, coverageMetric, onBrowse } = this.props;
+ const { component, selected, previous, coverageMetric, onBrowse, isView } = this.props;
let componentAction = null;
@@ -83,6 +84,10 @@ class Component extends React.Component {
</span>
</td>
<td className="code-name-cell">
+ {isView && (
+ <ComponentQualityGate
+ component={component}/>
+ )}
<ComponentName
component={component}
previous={previous}
@@ -136,7 +141,8 @@ class Component extends React.Component {
function mapStateToProps (state, ownProps) {
return {
- selected: state.current.searchSelectedItem === ownProps.component
+ selected: state.current.searchSelectedItem === ownProps.component,
+ isView: state.current.isView
};
}
diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.js b/server/sonar-web/src/main/js/apps/code/components/ComponentName.js
index 51ba9af79df..914e93e057c 100644
--- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.js
+++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.js
@@ -62,12 +62,13 @@ const Component = ({ component, previous, onBrowse }) => {
<span>{component.name.substr(prefix.length)}</span>
</span>
) : component.name;
+ const canBrowse = !!onBrowse && !component.copy;
return (
<Truncated title={getTooltip(component)}>
<QualifierIcon qualifier={component.qualifier}/>
{' '}
- {onBrowse ? (
+ {canBrowse ? (
<a
onClick={handleClick}
href="#">
diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentQualityGate.js b/server/sonar-web/src/main/js/apps/code/components/ComponentQualityGate.js
new file mode 100644
index 00000000000..b5bcfc7f1ef
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/code/components/ComponentQualityGate.js
@@ -0,0 +1,40 @@
+/*
+ * SonarQube :: Web
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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 _ from 'underscore';
+import React from 'react';
+
+import { translate } from '../../../helpers/l10n';
+
+const METRIC = 'alert_status';
+
+const ComponentQualityGate = ({ component }) => {
+ const measure = _.findWhere(component.msr, { key: METRIC });
+ return measure ? (
+ <span
+ className="spacer-right"
+ title={translate('metric.level', measure.data)}
+ style={{ position: 'relative', top: '-1px' }}>
+ <i className={`icon-alert-${measure.data.toLowerCase()}`}/>
+ </span>
+ ) : <span/>;
+};
+
+
+export default ComponentQualityGate;
diff --git a/server/sonar-web/src/main/js/apps/code/reducers/index.js b/server/sonar-web/src/main/js/apps/code/reducers/index.js
index 988140f717b..938e26c0f20 100644
--- a/server/sonar-web/src/main/js/apps/code/reducers/index.js
+++ b/server/sonar-web/src/main/js/apps/code/reducers/index.js
@@ -99,6 +99,7 @@ export const initialState = {
searchQuery: '',
searchSelectedItem: null,
coverageMetric: null,
+ isView: false,
baseBreadcrumbs: [],
errorMessage: null
};
@@ -109,8 +110,9 @@ export function current (state = initialState, action) {
case INIT:
const coverageMetric = selectCoverageMetric(action.component);
const baseBreadcrumbs = action.breadcrumbs.length > 1 ? _.initial(action.breadcrumbs) : [];
+ const isView = action.component.qualifier === 'VW' || action.component.qualifier === 'SVW';
- return { ...state, coverageMetric, baseBreadcrumbs };
+ return { ...state, coverageMetric, baseBreadcrumbs, isView };
case BROWSE:
const baseComponent = hasSourceCode(action.component) ? null : action.component;
const components = hasSourceCode(action.component) ? null : sortChildren(action.children);
diff --git a/server/sonar-web/src/main/js/apps/code/styles/code.css b/server/sonar-web/src/main/js/apps/code/styles/code.css
index 4df9d26c78d..1f9b70b6c4f 100644
--- a/server/sonar-web/src/main/js/apps/code/styles/code.css
+++ b/server/sonar-web/src/main/js/apps/code/styles/code.css
@@ -50,6 +50,6 @@
}
.code-search-box {
- padding-left: 10px;
- overflow: hidden;
+ float: left;
+ padding-right: 10px;
}