aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/overview/nutshell-coverage.js
blob: e478a7152590a9b25ec6faed7a30cb39ef8abdbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from 'react';
import Card from './card';
import Measure from './helpers/measure';
import DrilldownLink from './helpers/drilldown-link';
import Donut from './helpers/donut';

export default React.createClass({
  render() {
    let
        coverage = this.props.measures.coverage,
        tests = this.props.measures.tests,
        donutData = [
          { value: coverage, fill: '#85bb43' },
          { value: 100 - coverage, fill: '#d4333f' }
        ];

    if (coverage == null) {
      return null;
    }

    return (
        <Card>
          <div className="measures">
            <div className="measures-chart">
              <Donut data={donutData} size="47"/>
            </div>
            <div className="measure measure-big">
              <span className="measure-value">
                <DrilldownLink component={this.props.component.key} metric="overall_coverage">
                  <Measure value={coverage} type="PERCENT"/>
                </DrilldownLink>
              </span>
              <span className="measure-name">{window.t('overview.metric.coverage')}</span>
            </div>
          </div>
          <ul className="list-inline big-spacer-top measures-chart-indent">
            <li>
              <DrilldownLink component={this.props.component.key} metric="tests">
                <Measure value={tests} type="SHORT_INT"/>
              </DrilldownLink>&nbsp;
              <span>{window.t('overview.metric.tests')}</span>
            </li>
          </ul>
        </Card>
    );
  }
});