From c52c1d6e5602b77d8f90f634911c6885ca1e09c8 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 21 Mar 2016 14:14:18 +0100 Subject: [PATCH] SONAR-7349 apply feedback --- .../main/js/apps/overview/main/code-smells.js | 34 +++++++++--- .../src/main/js/apps/overview/main/main.js | 52 ++++--------------- .../src/main/js/apps/overview/main/risk.js | 40 +++++++++++--- server/sonar-web/src/main/js/main/app.js | 3 +- .../resources/org/sonar/l10n/core.properties | 4 +- 5 files changed, 75 insertions(+), 58 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/overview/main/code-smells.js b/server/sonar-web/src/main/js/apps/overview/main/code-smells.js index 2d754263334..319f9909528 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/code-smells.js +++ b/server/sonar-web/src/main/js/apps/overview/main/code-smells.js @@ -36,7 +36,7 @@ import { DrilldownLink } from '../../../components/shared/drilldown-link'; import { TooltipsMixin } from '../../../components/mixins/tooltips-mixin'; import { getMetricName } from '../helpers/metrics'; import { formatMeasure } from '../../../helpers/measures'; -import { translate } from '../../../helpers/l10n'; +import { translate, translateWithParameters } from '../../../helpers/l10n'; export const CodeSmells = React.createClass({ @@ -52,6 +52,8 @@ export const CodeSmells = React.createClass({ return null; } + const { snapshotDate } = this.props.component; + const formattedSnapshotDate = moment(snapshotDate).format('LLL'); const createdAfter = moment(this.props.leakPeriodDate).format('YYYY-MM-DDTHH:mm:ssZZ'); const newDebt = this.props.leak['new_technical_debt'] || 0; const newCodeSmells = this.props.leak['new_code_smells'] || 0; @@ -62,14 +64,22 @@ export const CodeSmells = React.createClass({ - {formatMeasure(newDebt, 'SHORT_WORK_DUR')} + + {formatMeasure(newDebt, 'SHORT_WORK_DUR')} + - {formatMeasure(newCodeSmells, 'SHORT_INT')} + + {formatMeasure(newCodeSmells, 'SHORT_INT')} + @@ -80,6 +90,8 @@ export const CodeSmells = React.createClass({ render () { const debt = this.props.measures['sqale_index'] || 0; const codeSmells = this.props.measures['code_smells'] || 0; + const { snapshotDate } = this.props.component; + const formattedSnapshotDate = moment(snapshotDate).format('LLL'); return
-
+
-
+
@@ -113,7 +131,11 @@ export const CodeSmells = React.createClass({ - {formatMeasure(codeSmells, 'SHORT_INT')} + + {formatMeasure(codeSmells, 'SHORT_INT')} + diff --git a/server/sonar-web/src/main/js/apps/overview/main/main.js b/server/sonar-web/src/main/js/apps/overview/main/main.js index 3af8d825751..fdb05b26b53 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/main.js +++ b/server/sonar-web/src/main/js/apps/overview/main/main.js @@ -29,7 +29,6 @@ import { GeneralStructure } from './structure'; import { CoverageSelectionMixin } from '../components/coverage-selection-mixin'; import { getPeriodLabel, getPeriodDate } from './../helpers/periods'; import { getMeasures } from '../../../api/measures'; -import { getFacet } from '../../../api/issues'; import { getTimeMachineData } from '../../../api/time-machine'; @@ -48,9 +47,15 @@ const METRICS_LIST = [ 'sqale_index', 'new_technical_debt', + 'code_smells', + 'new_code_smells', 'sqale_rating', 'reliability_rating', - 'security_rating' + 'bugs', + 'new_bugs', + 'security_rating', + 'vulnerabilities', + 'new_vulnerabilities' ]; const HISTORY_METRICS_LIST = [ @@ -77,24 +82,12 @@ export default React.createClass({ }, componentDidMount() { - Promise.all([ - this.requestMeasures(), - this.requestIssues(), - this.requestNewIssues() - ]).then(responses => { - const measures = this.getMeasuresValues(responses[0]); - const typesFacet = responses[1]; - measures['code_smells'] = this.getFacetCount(typesFacet, 'CODE_SMELL'); - measures['bugs'] = this.getFacetCount(typesFacet, 'BUG'); - measures['vulnerabilities'] = this.getFacetCount(typesFacet, 'VULNERABILITY'); + this.requestMeasures().then(r => { + const measures = this.getMeasuresValues(r); let leak; if (this.state.leakPeriodDate) { - const newTypesFacet = responses[2]; - leak = this.getMeasuresValues(responses[0], Number(this.props.leakPeriodIndex)); - leak['new_code_smells'] = this.getFacetCount(newTypesFacet, 'CODE_SMELL'); - leak['new_bugs'] = this.getFacetCount(newTypesFacet, 'BUG'); - leak['new_vulnerabilities'] = this.getFacetCount(newTypesFacet, 'VULNERABILITY'); + leak = this.getMeasuresValues(r, Number(this.props.leakPeriodIndex)); } this.setState({ @@ -121,31 +114,6 @@ export default React.createClass({ return values; }, - requestIssues (criteria = {}) { - const { component } = this.props; - const query = { - componentUuids: component.id, - resolved: false, - ...criteria - }; - return getFacet(query, 'types').then(r => r.facet); - }, - - requestNewIssues () { - const { leakPeriodDate } = this.state; - - if (!leakPeriodDate) { - return Promise.resolve(); - } - - const createdAfter = moment(leakPeriodDate).format('YYYY-MM-DDTHH:mm:ssZZ'); - return this.requestIssues({ createdAfter }); - }, - - getFacetCount (facet, value) { - return facet.find(item => item.val === value).count; - }, - requestHistory () { const coverageMetric = this.state.coverageMetricPrefix + 'coverage'; const metrics = [].concat(HISTORY_METRICS_LIST, coverageMetric).join(','); diff --git a/server/sonar-web/src/main/js/apps/overview/main/risk.js b/server/sonar-web/src/main/js/apps/overview/main/risk.js index 4afae273f82..122162d7312 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/risk.js +++ b/server/sonar-web/src/main/js/apps/overview/main/risk.js @@ -36,7 +36,7 @@ import { TooltipsMixin } from '../../../components/mixins/tooltips-mixin'; import { Legend } from '../components/legend'; import { getMetricName } from '../helpers/metrics'; import { formatMeasure } from '../../../helpers/measures'; -import { translate } from '../../../helpers/l10n'; +import { translate, translateWithParameters } from '../../../helpers/l10n'; export const Risk = React.createClass({ @@ -52,6 +52,8 @@ export const Risk = React.createClass({ return null; } + const { snapshotDate } = this.props.component; + const formattedSnapshotDate = moment(snapshotDate).format('LLL'); const createdAfter = moment(this.props.leakPeriodDate).format('YYYY-MM-DDTHH:mm:ssZZ'); const newBugs = this.props.leak['new_bugs'] || 0; const newVulnerabilities = this.props.leak['new_vulnerabilities'] || 0; @@ -64,14 +66,22 @@ export const Risk = React.createClass({ - {formatMeasure(newBugs, 'SHORT_INT')} + + {formatMeasure(newBugs, 'SHORT_INT')} + - {formatMeasure(newVulnerabilities, 'SHORT_INT')} + + {formatMeasure(newVulnerabilities, 'SHORT_INT')} + @@ -79,6 +89,8 @@ export const Risk = React.createClass({ }, render () { + const { snapshotDate } = this.props.component; + const formattedSnapshotDate = moment(snapshotDate).format('LLL'); const bugs = this.props.measures['bugs'] || 0; const vulnerabilities = this.props.measures['vulnerabilities'] || 0; @@ -92,7 +104,10 @@ export const Risk = React.createClass({
-
+
@@ -103,7 +118,11 @@ export const Risk = React.createClass({ - {formatMeasure(bugs, 'SHORT_INT')} + + {formatMeasure(bugs, 'SHORT_INT')} +
{getMetricName('bugs')}
@@ -112,7 +131,10 @@ export const Risk = React.createClass({
-
+
@@ -123,7 +145,11 @@ export const Risk = React.createClass({ - {formatMeasure(vulnerabilities, 'SHORT_INT')} + + {formatMeasure(vulnerabilities, 'SHORT_INT')} +
{getMetricName('vulnerabilities')}
diff --git a/server/sonar-web/src/main/js/main/app.js b/server/sonar-web/src/main/js/main/app.js index 90f27396cfa..e3341bf337d 100644 --- a/server/sonar-web/src/main/js/main/app.js +++ b/server/sonar-web/src/main/js/main/app.js @@ -60,7 +60,8 @@ function prepareAppOptions (navResponse) { key: navResponse.component.key, name: navResponse.component.name, qualifier: _.last(navResponse.component.breadcrumbs).qualifier, - breadcrumbs: navResponse.component.breadcrumbs + breadcrumbs: navResponse.component.breadcrumbs, + snapshotDate: navResponse.component.snapshotDate }; } } diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index d3c4893cd07..7306c76a101 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3175,9 +3175,9 @@ overview.metric.new_bugs=New Bugs overview.metric.vulnerabilities=Vulnerabilities overview.metric.new_vulnerabilities=New Vulnerabilities overview.metric.issues=Issues -overview.metric.effort=Effort +overview.metric.effort=Debt overview.metric.new_issues=New Issues -overview.metric.new_effort=New Effort +overview.metric.new_effort=New Debt overview.metric.coverage=Coverage overview.metric.tests=Tests overview.metric.new_coverage=Coverage on New Code -- 2.39.5