]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9605 Fix infinite spinner on project overview page
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 16 Aug 2017 10:13:51 +0000 (12:13 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 17 Aug 2017 14:42:34 +0000 (16:42 +0200)
server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js
server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.js
server/sonar-web/src/main/js/apps/overview/main/CodeSmells.js

index dc43acba02ced331f434b7fb7d64e9d3e2365c9a..11d0988237552be06a7b2a39a01468135175de8b 100644 (file)
@@ -93,15 +93,23 @@ export default class OverviewApp extends React.PureComponent {
 
     return getMeasuresAndMeta(componentKey, METRICS, {
       additionalFields: 'metrics,periods'
-    }).then(r => {
-      if (this.mounted) {
-        this.setState({
-          loading: false,
-          measures: enhanceMeasuresWithMetrics(r.component.measures, r.metrics),
-          periods: r.periods
-        });
+    }).then(
+      r => {
+        if (this.mounted) {
+          this.setState({
+            loading: false,
+            measures: enhanceMeasuresWithMetrics(r.component.measures, r.metrics),
+            periods: r.periods
+          });
+        }
+      },
+      error => {
+        throwGlobalError(error);
+        if (this.mounted) {
+          this.setState({ loading: false });
+        }
       }
-    }, throwGlobalError);
+    );
   }
 
   loadHistory(component /*: Component */) {
index 95f88510f199c85d03c07d6224eb95f16783e031..4841f32c2cba25546d1c248322c0712a00315785 100644 (file)
@@ -138,6 +138,11 @@ class BugsAndVulnerabilities extends React.PureComponent {
   }
 
   render() {
+    const { measures } = this.props;
+    const bugsMeasure = measures.find(measure => measure.metric.key === 'bugs');
+    if (bugsMeasure == null) {
+      return null;
+    }
     return (
       <div className="overview-card overview-card-special">
         {this.renderHeader()}
index 2c5a5e9289c7a8c55e647795aba75f1d173b20c2..00e81e9d47ac5104ef61741acf2a25dae0bc14fa 100644 (file)
@@ -148,6 +148,11 @@ class CodeSmells extends React.PureComponent {
   }
 
   render() {
+    const { measures } = this.props;
+    const codeSmellsMeasure = measures.find(measure => measure.metric.key === 'code_smells');
+    if (codeSmellsMeasure == null) {
+      return null;
+    }
     return (
       <div className="overview-card" id="overview-code-smells">
         {this.renderHeader()}