}
render () {
+ if (this.props.component.qualifier === 'DEV' || this.props.component.qualifier === 'VW') {
+ return null;
+ }
+
return <div className="overview-domain-chart">
<div className="overview-card-header">
<h2 className="overview-title">{window.t('overview.chart.files')}</h2>
</div>;
}
+ renderWhenNoData () {
+ return <div className="overview-chart-placeholder" style={{ height: HEIGHT }}>
+ {window.t('no_data')}
+ </div>;
+ }
+
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;
return this.renderOtherMeasures('Documentation', []);
},
+ renderLanguageDistribution() {
+ let distribution = this.state.measures['ncloc_language_distribution'];
+ if (distribution == null) {
+ return null;
+ }
+ return <LanguageDistribution lines={this.state.measures['ncloc']} distribution={distribution}/>;
+ },
+
+ renderComplexityDistribution(distribution, props) {
+ if (distribution == null) {
+ return null;
+ }
+ return <ComplexityDistribution distribution={distribution} {...props}/>
+ },
+
+ renderComplexityCard() {
+ if (this.state.measures['complexity'] == null) {
+ return null;
+ }
+
+ return <div className="overview-detailed-layout-column">
+ <div className="overview-detailed-measures-list">
+ <DetailedMeasure {...this.props} {...this.state} metric="complexity" type="INT"/>
+ <DetailedMeasure {...this.props} {...this.state} metric="function_complexity" type="FLOAT">
+ {this.renderComplexityDistribution(this.state.measures['function_complexity_distribution'],
+ { of: 'function' })}
+ </DetailedMeasure>
+ <DetailedMeasure {...this.props} {...this.state} metric="file_complexity" type="FLOAT">
+ {this.renderComplexityDistribution(this.state.measures['file_complexity_distribution'],
+ { of: 'file' })}
+ </DetailedMeasure>
+ <DetailedMeasure {...this.props} {...this.state} metric="class_complexity" type="FLOAT"/>
+ {this.renderOtherComplexityMeasures()}
+ </div>
+ </div>;
+ },
+
render () {
if (!this.state.ready) {
return this.renderLoading();
<div className="overview-detailed-layout-column">
<div className="overview-detailed-measures-list">
<DetailedMeasure {...this.props} {...this.state} metric="ncloc" type="INT">
- <LanguageDistribution lines={this.state.measures['ncloc']}
- distribution={this.state.measures['ncloc_language_distribution']}/>
+ {this.renderLanguageDistribution()}
</DetailedMeasure>
{this.renderOtherSizeMeasures()}
</div>
</div>
- <div className="overview-detailed-layout-column">
- <div className="overview-detailed-measures-list">
- <DetailedMeasure {...this.props} {...this.state} metric="complexity" type="INT"/>
- <DetailedMeasure {...this.props} {...this.state} metric="function_complexity" type="FLOAT">
- <ComplexityDistribution
- distribution={this.state.measures['function_complexity_distribution']}
- of="function"/>
- </DetailedMeasure>
- <DetailedMeasure {...this.props} {...this.state} metric="file_complexity" type="FLOAT">
- <ComplexityDistribution
- distribution={this.state.measures['file_complexity_distribution']}
- of="file"/>
- </DetailedMeasure>
- <DetailedMeasure {...this.props} {...this.state} metric="class_complexity" type="FLOAT"/>
- {this.renderOtherComplexityMeasures()}
- </div>
- </div>
+ {this.renderComplexityCard()}
<div className="overview-detailed-layout-column">
<div className="overview-detailed-measures-list">
export default React.createClass({
+ renderGateConditions () {
+ return <GateConditions gate={this.props.gate} component={this.props.component}/>;
+ },
+
+ 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 <div className="overview-card">{text}</div>;
+ },
+
render() {
if (!this.props.gate || !this.props.gate.level) {
return this.props.component.qualifier === 'TRK' ? <GateEmpty/> : null;
{window.t('overview.quality_gate')}
<span className={badgeClassName}>{badgeText}</span>
</h2>
- <GateConditions gate={this.props.gate} component={this.props.component}/>
+ {this.props.gate.conditions ? this.renderGateConditions() : this.renderGateText()}
</div>
);
}
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 (
<li key={profile.key}>
<span className="note spacer-right">({profile.language})</span>
</div>
) : null,
- profilesCard = _.size(this.props.component.profiles) > 0 ? (
+ profilesCard = !this.isView() && !this.isDeveloper() && _.size(this.props.component.profiles) > 0 ? (
<div className="overview-meta-card">
<h4 className="overview-meta-header">{window.t('overview.quality_profiles')}</h4>
<ul className="overview-meta-list">{profiles}</ul>
</div>
) : null,
- gateCard = this.props.component.gate ? (
+ gateCard = !this.isView() && !this.isDeveloper() && this.props.component.gate ? (
<div className="overview-meta-card">
<h4 className="overview-meta-header">{window.t('overview.quality_gate')}</h4>
<ul className="overview-meta-list">
<li>
{this.props.component.gate.isDefault ?
<span className="note spacer-right">(Default)</span> : null}
- <QualityGateLink gate={this.props.component.gate.key}>{this.props.component.gate.name}</QualityGateLink>
+ <QualityGateLink gate={this.props.component.gate.key}>
+ {this.props.component.gate.name}
+ </QualityGateLink>
</li>
</ul>
</div>
<%
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
%>
]
};
<% 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 = {