]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9605 Fix infinite spinner on rules page
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 16 Aug 2017 12:59:37 +0000 (14:59 +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/coding-rules/controller.js

index 5f61c68dda90dbe1ce80562370abe2c9a7c32d26..e659ea1fbfd6cf76b788baf301c138ec8064498a 100644 (file)
@@ -22,6 +22,7 @@ import key from 'keymaster';
 import Controller from '../../components/navigator/controller';
 import Rule from './models/rule';
 import RuleDetailsView from './rule-details-view';
+import throwGlobalError from '../../app/utils/throwGlobalError';
 
 export default Controller.extend({
   pageSize: 200,
@@ -59,28 +60,33 @@ export default Controller.extend({
     const that = this;
     const url = window.baseUrl + '/api/rules/search';
     const options = { ...this._searchParameters(), ...this.app.state.get('query') };
-    return $.get(url, options).done(r => {
-      const rules = that.app.list.parseRules(r);
-      if (firstPage) {
-        that.app.list.reset(rules);
-      } else {
-        that.app.list.add(rules);
-      }
-      that.app.list.setIndex();
-      that.app.list.addExtraAttributes(that.app.repositories);
-      that.app.facets.reset(that._allFacets());
-      that.app.facets.add(r.facets, { merge: true });
-      that.enableFacets(that._enabledFacets());
-      that.app.state.set({
-        page: r.p,
-        pageSize: r.ps,
-        total: r.total,
-        maxResultsReached: r.p * r.ps >= r.total
+    return $.get(url, options)
+      .done(r => {
+        const rules = that.app.list.parseRules(r);
+        if (firstPage) {
+          that.app.list.reset(rules);
+        } else {
+          that.app.list.add(rules);
+        }
+        that.app.list.setIndex();
+        that.app.list.addExtraAttributes(that.app.repositories);
+        that.app.facets.reset(that._allFacets());
+        that.app.facets.add(r.facets, { merge: true });
+        that.enableFacets(that._enabledFacets());
+        that.app.state.set({
+          page: r.p,
+          pageSize: r.ps,
+          total: r.total,
+          maxResultsReached: r.p * r.ps >= r.total
+        });
+        if (firstPage && that.isRulePermalink()) {
+          that.showDetails(that.app.list.first());
+        }
+      })
+      .fail(error => {
+        this.app.state.set({ maxResultsReached: true });
+        throwGlobalError(error);
       });
-      if (firstPage && that.isRulePermalink()) {
-        that.showDetails(that.app.list.first());
-      }
-    });
   },
 
   isRulePermalink() {