diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-07-26 16:04:19 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-08-14 11:44:44 +0200 |
commit | f2c95a685a3b950a68122af1e5673978a07df773 (patch) | |
tree | a81639fe40a98b6d746369658d8a3f88082fd3a2 /server/sonar-web/src/main/js/components | |
parent | cadc6bb011393ff5092f83f146bd9b74bad21460 (diff) | |
download | sonarqube-f2c95a685a3b950a68122af1e5673978a07df773.tar.gz sonarqube-f2c95a685a3b950a68122af1e5673978a07df773.zip |
SONAR-9608 SONAR-9609 Create the new measures page sidebar with all facets
Diffstat (limited to 'server/sonar-web/src/main/js/components')
-rw-r--r-- | server/sonar-web/src/main/js/components/measure/Measure.js | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/server/sonar-web/src/main/js/components/measure/Measure.js b/server/sonar-web/src/main/js/components/measure/Measure.js index a2b1e4dd22f..3ce72c83ee0 100644 --- a/server/sonar-web/src/main/js/components/measure/Measure.js +++ b/server/sonar-web/src/main/js/components/measure/Measure.js @@ -28,45 +28,18 @@ import type { MeasureEnhanced } from './types'; type Props = { className?: string, - measure: MeasureEnhanced, - decimals?: ?number + decimals?: ?number, + measure: MeasureEnhanced }; -export default class Measure extends React.PureComponent { - props: Props; +export default function Measure({ className, decimals, measure }: Props) { + const metric = measure.metric; - renderRating() { - const { measure } = this.props; - const metric = measure.metric; - const value = isDiffMetric(metric.key) ? measure.leak : measure.value; - const tooltip = getRatingTooltip(metric.key, value); - const rating = <Rating value={value} />; - - if (tooltip) { - return ( - <Tooltips overlay={tooltip}> - <span className={this.props.className}> - {rating} - </span> - </Tooltips> - ); - } - - return rating; + if (metric.type === 'LEVEL') { + return <Level className={className} level={measure.value} />; } - render() { - const { className, decimals, measure } = this.props; - const metric = measure.metric; - - if (metric.type === 'RATING') { - return this.renderRating(); - } - - if (metric.type === 'LEVEL') { - return <Level className={className} level={measure.value} />; - } - + if (metric.type !== 'RATING') { const formattedValue = isDiffMetric(metric.key) ? formatLeak(measure.leak, metric, { decimals }) : formatMeasure(measure.value, metric.type, { decimals }); @@ -76,4 +49,18 @@ export default class Measure extends React.PureComponent { </span> ); } + + const value = isDiffMetric(metric.key) ? measure.leak : measure.value; + const tooltip = getRatingTooltip(metric.key, value); + const rating = <Rating value={value} />; + if (tooltip) { + return ( + <Tooltips overlay={tooltip}> + <span className={className}> + {rating} + </span> + </Tooltips> + ); + } + return rating; } |