From db0ff89a7ffb8cfa09e72086087d79bbd3485344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Tue, 22 Aug 2023 19:19:12 +0200 Subject: [PATCH] feat: run refresh from UI in parallel (#15138) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Wöhrl Signed-off-by: Alexy Mantha --- .../applications-refresh-panel.tsx | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ui/src/app/applications/components/applications-refresh-panel/applications-refresh-panel.tsx b/ui/src/app/applications/components/applications-refresh-panel/applications-refresh-panel.tsx index 8aa2bcacdbb0d2..56cab7a39e9825 100644 --- a/ui/src/app/applications/components/applications-refresh-panel/applications-refresh-panel.tsx +++ b/ui/src/app/applications/components/applications-refresh-panel/applications-refresh-panel.tsx @@ -47,19 +47,29 @@ export const ApplicationsRefreshPanel = ({show, apps, hide}: {show: boolean; app setProgress({percentage: 0, title: 'Refreshing applications'}); let i = 0; + const refreshActions = []; for (const app of selectedApps) { - await services.applications.get(app.metadata.name, app.metadata.namespace, params.refreshType).catch(e => { - ctx.notifications.show({ - content: , - type: NotificationType.Error + const refreshAction = async () => { + await services.applications.get(app.metadata.name, app.metadata.namespace, params.refreshType).catch(e => { + ctx.notifications.show({ + content: , + type: NotificationType.Error + }); }); - }); - i++; - setProgress({ - percentage: i / selectedApps.length, - title: `Refreshed ${i} of ${selectedApps.length} applications` - }); + i++; + setProgress({ + percentage: i / selectedApps.length, + title: `Refreshed ${i} of ${selectedApps.length} applications` + }); + }; + refreshActions.push(refreshAction()); + + if (refreshActions.length >= 20) { + await Promise.all(refreshActions); + refreshActions.length = 0; + } } + await Promise.all(refreshActions); setProgress({percentage: 100, title: 'Complete'}); }} getApi={setForm}>