diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-01-20 14:39:06 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-01-20 14:41:39 +0100 |
commit | 9e9b54fbe1e332e8aa7a13d2ce670fee2fde41f0 (patch) | |
tree | a2af4d98acd414ae8f79c8087bf3549e7018fdb2 /server/sonar-web/src/main/js/apps | |
parent | 626f44e72a2a5954bcb3a2c05843ad8b9a933e90 (diff) | |
download | sonarqube-9e9b54fbe1e332e8aa7a13d2ce670fee2fde41f0.tar.gz sonarqube-9e9b54fbe1e332e8aa7a13d2ce670fee2fde41f0.zip |
use new WS on code, projects and overview pages
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
12 files changed, 56 insertions, 44 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 fcf52337263..e39f46d0327 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 @@ -22,6 +22,7 @@ import { pushPath } from 'redux-simple-router'; import { getChildren, getComponent, getTree, getBreadcrumbs } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; +import { getComponentUrl } from '../../../helpers/urls'; const METRICS = [ @@ -192,7 +193,12 @@ export function browse (componentKey) { dispatch(startFetching()); return retrieveComponent(componentKey, bucket) .then(([component, children, breadcrumbs]) => { - dispatch(browseAction(component, children, breadcrumbs)); + if (component.refKey) { + window.location = getComponentUrl(component.refKey); + return new Promise(); + } else { + dispatch(browseAction(component, children, breadcrumbs)); + } }) .then(() => dispatch(pushPath(getPath(componentKey)))) .then(() => dispatch(stopFetching())) 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 ea6e17a23f5..ef1b1e561bb 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 @@ -67,13 +67,15 @@ class Component extends React.Component { let componentAction = null; - switch (component.qualifier) { - case 'FIL': - case 'UTS': - componentAction = <ComponentPin component={component}/>; - break; - default: - componentAction = <ComponentDetach component={component}/>; + if (!component.refKey) { + switch (component.qualifier) { + case 'FIL': + case 'UTS': + componentAction = <ComponentPin component={component}/>; + break; + default: + componentAction = <ComponentDetach component={component}/>; + } } return ( diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentDetach.js b/server/sonar-web/src/main/js/apps/code/components/ComponentDetach.js index 9666577ed34..c2a18b6defd 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentDetach.js +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentDetach.js @@ -27,7 +27,7 @@ const ComponentDetach = ({ component }) => ( <a className="icon-detach" title={translate('code.open_component_page')} - href={getComponentUrl(component.copy || component.key)}/> + href={getComponentUrl(component.refKey || component.key)}/> ); diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.js b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.js index df7e1812d32..7845e5d1178 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.js +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.js @@ -24,10 +24,10 @@ import { formatMeasure } from '../../../helpers/measures'; const ComponentMeasure = ({ component, metricKey, metricType }) => { - const measure = _.findWhere(component.msr, { key: metricKey }); + const measure = _.findWhere(component.measures, { metric: metricKey }); return ( <span> - {measure ? formatMeasure(measure.val, metricType) : ''} + {measure ? formatMeasure(measure.value, metricType) : ''} </span> ); }; 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 77405448839..dde1849ce4b 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,7 +62,7 @@ const Component = ({ component, previous, onBrowse }) => { <span>{component.name.substr(prefix.length)}</span> </span> ) : component.name; - const canBrowse = !!onBrowse && !component.copy; + const canBrowse = !!onBrowse; return ( <Truncated title={getTooltip(component)}> diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js index d51a1dd0a18..9e3484cdbdc 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js @@ -27,7 +27,7 @@ import { translate } from '../../../helpers/l10n'; const ComponentPin = ({ component }) => { const handleClick = (e) => { e.preventDefault(); - Workspace.openComponent({ uuid: component.uuid || component.id }); + Workspace.openComponent({ uuid: component.id }); }; return ( 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 index 040e243e74f..9fb381e6833 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentQualityGate.js +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentQualityGate.js @@ -25,13 +25,13 @@ import { translate } from '../../../helpers/l10n'; const METRIC = 'alert_status'; const ComponentQualityGate = ({ component }) => { - const measure = _.findWhere(component.msr, { key: METRIC }); + const measure = _.findWhere(component.measures, { metric: METRIC }); return measure ? ( <span className="spacer-right" - title={translate('metric.level', measure.data)} + title={translate('metric.level', measure.value)} style={{ position: 'relative', top: '-1px' }}> - <i className={`icon-alert-${measure.data.toLowerCase()}`}/> + <i className={`icon-alert-${measure.value.toLowerCase()}`}/> </span> ) : <span/>; }; diff --git a/server/sonar-web/src/main/js/apps/code/components/SourceViewer.js b/server/sonar-web/src/main/js/apps/code/components/SourceViewer.js index 8645c362148..ddedbf2617d 100644 --- a/server/sonar-web/src/main/js/apps/code/components/SourceViewer.js +++ b/server/sonar-web/src/main/js/apps/code/components/SourceViewer.js @@ -28,7 +28,7 @@ export default class SourceViewer extends Component { } shouldComponentUpdate (nextProps) { - return nextProps.component.uuid !== this.props.component.uuid; + return nextProps.component.id !== this.props.component.id; } componentWillUpdate () { @@ -46,7 +46,7 @@ export default class SourceViewer extends Component { renderSourceViewer () { this.sourceViewer = new BaseSourceViewer(); this.sourceViewer.render().$el.appendTo(this.refs.container); - this.sourceViewer.open(this.props.component.uuid); + this.sourceViewer.open(this.props.component.id); } destroySourceViewer () { 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 728782c97e7..eb7c09c8301 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 @@ -28,9 +28,9 @@ function hasSourceCode (component) { } function selectCoverageMetric (component) { - const coverage = _.findWhere(component.msr, { key: 'coverage' }); - const itCoverage = _.findWhere(component.msr, { key: 'it_coverage' }); - const overallCoverage = _.findWhere(component.msr, { key: 'overall_coverage' }); + const coverage = _.findWhere(component.measures, { metric: 'coverage' }); + const itCoverage = _.findWhere(component.measures, { metric: 'it_coverage' }); + const overallCoverage = _.findWhere(component.measures, { metric: 'overall_coverage' }); if (coverage != null && itCoverage != null && overallCoverage != null) { return 'overall_coverage'; diff --git a/server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js b/server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js index e7ae61e7ca8..6554987adf6 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js +++ b/server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js @@ -32,7 +32,7 @@ const BUBBLES_LIMIT = 500; function getMeasure (component, metric) { - return component.measures[metric] || 0; + return Number(component.measures[metric]) || 0; } @@ -53,28 +53,29 @@ export class DomainBubbleChart extends React.Component { } requestFiles () { - let metrics = [].concat(this.props.xMetric, this.props.yMetric, this.props.sizeMetrics); - return getFiles(this.props.component.key, metrics).then(r => { + const metrics = [].concat(this.props.xMetric, this.props.yMetric, this.props.sizeMetrics); + const options = { + s: 'metric', + metricSort: this.props.sizeMetrics, + asc: false, + ps: BUBBLES_LIMIT + }; + return getFiles(this.props.component.key, metrics, options).then(r => { let files = r.map(file => { let measures = {}; - (file.msr || []).forEach(measure => { - measures[measure.key] = measure.val; + (file.measures || []).forEach(measure => { + measures[measure.metric] = measure.value; }); return _.extend(file, { measures }); }); this.setState({ loading: false, - files: this.limitFiles(files), + files: files, total: files.length }); }); } - limitFiles (files) { - const comparator = file => -1 * this.getSizeMetricsValue(file); - return _.sortBy(files, comparator).slice(0, BUBBLES_LIMIT); - } - getMetricObject (metrics, metricKey) { return _.findWhere(metrics, { key: metricKey }); } @@ -96,15 +97,17 @@ export class DomainBubbleChart extends React.Component { /* eslint max-len: 0 */ let inner = [ component.name, - `${this.state.xMetric.name}: ${formatMeasure(getMeasure(component, this.props.xMetric), this.state.xMetric.type)}`, - `${this.state.yMetric.name}: ${formatMeasure(getMeasure(component, this.props.yMetric), this.state.yMetric.type)}`, + `${this.state.xMetric.name}: ${formatMeasure(getMeasure(component, this.props.xMetric), + this.state.xMetric.type)}`, + `${this.state.yMetric.name}: ${formatMeasure(getMeasure(component, this.props.yMetric), + this.state.yMetric.type)}`, `${sizeMetricsTitle}: ${formatMeasure(this.getSizeMetricsValue(component), sizeMetricsType)}` ].join('<br>'); return `<div class="text-left">${inner}</div>`; } - handleBubbleClick (uuid) { - Workspace.openComponent({ uuid }); + handleBubbleClick (id) { + Workspace.openComponent({ uuid: id }); } renderLoading () { @@ -123,7 +126,7 @@ export class DomainBubbleChart extends React.Component { x: getMeasure(component, this.props.xMetric), y: getMeasure(component, this.props.yMetric), size: this.getSizeMetricsValue(component), - link: component.uuid, + link: component.id, tooltip: this.getTooltip(component) }; }); @@ -160,7 +163,8 @@ export class DomainBubbleChart extends React.Component { {this.state.xMetric.name} </div> {this.state.total > BUBBLES_LIMIT && - <div className="note text-center">{translateWithParameters('overview.chart.files.limit_message', BUBBLES_LIMIT)}</div>} + <div className="note text-center">{translateWithParameters('overview.chart.files.limit_message', + BUBBLES_LIMIT)}</div>} </div> </div>; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/domain-treemap.js b/server/sonar-web/src/main/js/apps/overview/components/domain-treemap.js index 4ea27a3523a..3ea605187df 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/domain-treemap.js +++ b/server/sonar-web/src/main/js/apps/overview/components/domain-treemap.js @@ -51,12 +51,12 @@ export class DomainTreemap extends React.Component { return getChildren(componentKey, metrics).then(r => { let components = r.map(component => { let measures = {}; - (component.msr || []).forEach(measure => { - measures[measure.key] = measure.val; + (component.measures || []).forEach(measure => { + measures[measure.metric] = measure.value; }); return _.extend(component, { measures, - key: component.copy ? `${component.copy}` : component.key + key: component.refKey || component.key }); }); this.setState({ loading: false, components }); diff --git a/server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js b/server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js index d0c6e5f793e..dfe8cff2dbc 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js +++ b/server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js @@ -50,8 +50,8 @@ export const NclocDistribution = React.createClass({ return getChildren(this.props.component.key, metrics).then(r => { let components = r.map(component => { let measures = {}; - (component.msr || []).forEach(measure => { - measures[measure.key] = measure.val; + (component.measures || []).forEach(measure => { + measures[measure.metric] = measure.value; }); return _.extend(component, { measures }); }); @@ -76,7 +76,7 @@ export const NclocDistribution = React.createClass({ let data = this.state.components.map((component, index) => { return { - x: parseInt(component.measures[METRIC], 10), + x: component.measures[METRIC] ? parseInt(component.measures[METRIC], 10) : 0, y: index, value: component.name, component: component |