aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/overview/general/duplications.js
blob: bd95a2d4a3985f7ae156e48a37266d36ec08d5f4 (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
48
49
50
51
52
53
54
55
56
57
import React from 'react';

import { Domain, DomainHeader, DomainPanel, DomainNutshell, DomainLeak, MeasuresList, Measure, DomainMixin } from './components';
import DrilldownLink from '../helpers/drilldown-link';
import { TooltipsMixin } from '../../../components/mixins/tooltips-mixin';
import { getMetricName } from '../helpers/metrics';
import { formatMeasure, formatMeasureVariation } from '../../../helpers/measures';


export const GeneralDuplications = React.createClass({
  mixins: [TooltipsMixin, DomainMixin],

  propTypes: {
    leakPeriodLabel: React.PropTypes.string,
    leakPeriodDate: React.PropTypes.object
  },

  renderLeak () {
    if (!this.hasLeakPeriod()) {
      return null;
    }
    return <DomainLeak>
      <MeasuresList>
        <Measure label={getMetricName('duplications')}>
          {formatMeasureVariation(this.props.leak['duplicated_lines_density'], 'PERCENT')}
        </Measure>
      </MeasuresList>
      {this.renderTimeline('after')}
    </DomainLeak>;
  },

  render () {
    return <Domain>
      <DomainHeader title="Duplications"
                    leakPeriodLabel={this.props.leakPeriodLabel} leakPeriodDate={this.props.leakPeriodDate}/>

      <DomainPanel domain="duplications">
        <DomainNutshell>
          <MeasuresList>
            <Measure label={getMetricName('duplications')}>
              <DrilldownLink component={this.props.component.key} metric="duplicated_lines_density">
                {formatMeasure(this.props.measures['duplicated_lines_density'], 'PERCENT')}
              </DrilldownLink>
            </Measure>
            <Measure label={getMetricName('duplicated_blocks')}>
              <DrilldownLink component={this.props.component.key} metric="duplicated_blocks">
                {formatMeasure(this.props.measures['duplicated_blocks'], 'SHORT_INT')}
              </DrilldownLink>
            </Measure>
          </MeasuresList>
          {this.renderTimeline('before')}
        </DomainNutshell>
        {this.renderLeak()}
      </DomainPanel>
    </Domain>;
  }
});