From: Stas Vilchik Date: Mon, 30 Nov 2015 10:24:50 +0000 (+0100) Subject: SONAR-7069 Improve support of views on the overview page X-Git-Tag: 5.3-RC1~133 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=368ac5fb26d47ec153426185f76191df428207a9;p=sonarqube.git SONAR-7069 Improve support of views on the overview page --- 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 f67d5d02873..69c2be4f1ba 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 @@ -102,6 +102,10 @@ export class DomainBubbleChart extends React.Component { } render () { + if (this.props.component.qualifier === 'DEV' || this.props.component.qualifier === 'VW') { + return null; + } + return

{window.t('overview.chart.files')}

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 d153b98ef1e..0014cd54e9f 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 @@ -62,11 +62,21 @@ export class DomainTreemap extends React.Component {
; } + renderWhenNoData () { + return
+ {window.t('no_data')} +
; + } + renderTreemap () { if (this.state.loading) { return this.renderLoading(); } + if (!this.state.components.length) { + return this.renderWhenNoData(); + } + // TODO filter out zero sized components let items = this.state.components.map(component => { let colorMeasure = this.props.colorMetric ? component.measures[this.props.colorMetric] : null; diff --git a/server/sonar-web/src/main/js/apps/overview/domains/size-domain.js b/server/sonar-web/src/main/js/apps/overview/domains/size-domain.js index dcdab0821fd..18f0f4caddf 100644 --- a/server/sonar-web/src/main/js/apps/overview/domains/size-domain.js +++ b/server/sonar-web/src/main/js/apps/overview/domains/size-domain.js @@ -90,6 +90,43 @@ export const SizeMain = React.createClass({ return this.renderOtherMeasures('Documentation', []); }, + renderLanguageDistribution() { + let distribution = this.state.measures['ncloc_language_distribution']; + if (distribution == null) { + return null; + } + return ; + }, + + renderComplexityDistribution(distribution, props) { + if (distribution == null) { + return null; + } + return + }, + + renderComplexityCard() { + if (this.state.measures['complexity'] == null) { + return null; + } + + return
+
+ + + {this.renderComplexityDistribution(this.state.measures['function_complexity_distribution'], + { of: 'function' })} + + + {this.renderComplexityDistribution(this.state.measures['file_complexity_distribution'], + { of: 'file' })} + + + {this.renderOtherComplexityMeasures()} +
+
; + }, + render () { if (!this.state.ready) { return this.renderLoading(); @@ -105,30 +142,13 @@ export const SizeMain = React.createClass({
- + {this.renderLanguageDistribution()} {this.renderOtherSizeMeasures()}
-
-
- - - - - - - - - {this.renderOtherComplexityMeasures()} -
-
+ {this.renderComplexityCard()}
diff --git a/server/sonar-web/src/main/js/apps/overview/gate/gate.js b/server/sonar-web/src/main/js/apps/overview/gate/gate.js index 076cbcd376a..97592b68455 100644 --- a/server/sonar-web/src/main/js/apps/overview/gate/gate.js +++ b/server/sonar-web/src/main/js/apps/overview/gate/gate.js @@ -5,6 +5,22 @@ import GateEmpty from './gate-empty'; export default React.createClass({ + renderGateConditions () { + return ; + }, + + renderGateText () { + let text = ''; + if (this.props.gate.level === 'ERROR') { + text = window.t('widget.alerts.errors') + this.props.gate.text + '.'; + } else if (this.props.gate.level === 'WARN') { + text = window.t('widget.alerts.warnings') + this.props.gate.text + '.'; + } else { + text = window.t('widget.alerts.no_alert'); + } + return
{text}
; + }, + render() { if (!this.props.gate || !this.props.gate.level) { return this.props.component.qualifier === 'TRK' ? : null; @@ -20,7 +36,7 @@ export default React.createClass({ {window.t('overview.quality_gate')} {badgeText} - + {this.props.gate.conditions ? this.renderGateConditions() : this.renderGateText()}
); } diff --git a/server/sonar-web/src/main/js/apps/overview/meta.js b/server/sonar-web/src/main/js/apps/overview/meta.js index e6a48e71e09..dea84f07899 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta.js +++ b/server/sonar-web/src/main/js/apps/overview/meta.js @@ -4,9 +4,16 @@ import { QualityProfileLink } from './../../components/shared/quality-profile-li import { QualityGateLink } from './../../components/shared/quality-gate-link'; export default React.createClass({ + isView() { + return this.props.component.qualifier === 'VW' || this.props.component.qualifier === 'SVW'; + }, + + isDeveloper() { + return this.props.component.qualifier === 'DEV'; + }, + render() { - let - profiles = (this.props.component.profiles || []).map(profile => { + let profiles = (this.props.component.profiles || []).map(profile => { return (
  • ({profile.language}) @@ -36,21 +43,23 @@ export default React.createClass({
  • ) : null, - profilesCard = _.size(this.props.component.profiles) > 0 ? ( + profilesCard = !this.isView() && !this.isDeveloper() && _.size(this.props.component.profiles) > 0 ? (

    {window.t('overview.quality_profiles')}

      {profiles}
    ) : null, - gateCard = this.props.component.gate ? ( + gateCard = !this.isView() && !this.isDeveloper() && this.props.component.gate ? (

    {window.t('overview.quality_gate')}

    • {this.props.component.gate.isDefault ? (Default) : null} - {this.props.component.gate.name} + + {this.props.component.gate.name} +
    diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb index 450678e7a4c..f81ae58beb3 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb @@ -25,20 +25,17 @@ <% if @snapshot m = @snapshot.measure(Metric::QUALITY_GATE_DETAILS) + alert_status = @snapshot.measure(Metric::ALERT_STATUS) if m && !m.data.blank? details = JSON.parse m.data m.alert_status = details['level'] raw_conditions = details['conditions'] conditions = [] - missing_metric = false raw_conditions.each do |condition| - if metric(condition['metric']).nil? - missing_metric = true - else + if !metric(condition['metric']).nil? conditions << condition end end - alert_metric = metric(Metric::ALERT_STATUS) end end %> @@ -116,7 +113,14 @@ ] }; <% else %> - var gate = null; + <% if alert_status && !alert_status.alert_status.blank? %> + var gate = { + level: '<%= alert_status.alert_status -%>', + text: '<%= alert_status.alert_text -%>' + }; + <% else %> + var gate = null; + <% end %> <% end %> window.sonarqube.overview = {