]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8036 Code page does not expand root directory properly (#1239)
authorStas Vilchik <vilchiks@gmail.com>
Tue, 13 Sep 2016 14:28:59 +0000 (16:28 +0200)
committerGitHub <noreply@github.com>
Tue, 13 Sep 2016 14:28:59 +0000 (16:28 +0200)
server/sonar-web/src/main/js/apps/code/actions/index.js

index f8ace5adf1db78e5fba2a53ae8781cf673e1c218..464e8372b641892065be77e46671edc1864377e7 100644 (file)
@@ -129,13 +129,28 @@ function getPath (componentKey) {
   return '/' + encodeURIComponent(componentKey);
 }
 
+function requestChildren (componentKey, metrics, page) {
+  return getChildren(componentKey, metrics, { p: page, ps: PAGE_SIZE }).then(r => {
+    if (r.paging.total > r.paging.pageSize * r.paging.pageIndex) {
+      return requestChildren(componentKey, metrics, page + 1).then(moreComponents => {
+        return [...r.components, ...moreComponents];
+      })
+    }
+    return r.components;
+  });
+}
+
+function requestAllChildren (componentKey, metrics) {
+  return requestChildren(componentKey, metrics, 1);
+}
+
 function expandRootDir (metrics) {
   return function ({ children, total, ...other }) {
     const rootDir = children.find(component => component.qualifier === 'DIR' && component.name === '/');
     if (rootDir) {
-      return getChildren(rootDir.key, metrics).then(r => {
-        const nextChildren = _.without([...children, ...r.components], rootDir);
-        const nextTotal = total + r.components.length - /* root dir */ 1;
+      return requestAllChildren(rootDir.key, metrics).then(components => {
+        const nextChildren = _.without([...children, ...components], rootDir);
+        const nextTotal = total + components.length - /* root dir */ 1;
         return { children: nextChildren, total: nextTotal, ...other };
       });
     } else {