From 0359411125578632c70ccf458625d0163c2b8b16 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 13 Sep 2016 16:28:59 +0200 Subject: [PATCH] SONAR-8036 Code page does not expand root directory properly (#1239) --- .../src/main/js/apps/code/actions/index.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/code/actions/index.js b/server/sonar-web/src/main/js/apps/code/actions/index.js index f8ace5adf1d..464e8372b64 100644 --- a/server/sonar-web/src/main/js/apps/code/actions/index.js +++ b/server/sonar-web/src/main/js/apps/code/actions/index.js @@ -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 { -- 2.39.5