Skip to content

Commit

Permalink
feat: run refresh from UI in parallel (argoproj#15138)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Wöhrl <[email protected]>
  • Loading branch information
woehrl01 authored Aug 22, 2023
1 parent 386d177 commit 3a72786
Showing 1 changed file with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: <ErrorNotification title={`Unable to refresh ${app.metadata.name}`} e={e} />,
type: NotificationType.Error
const refreshAction = async () => {
await services.applications.get(app.metadata.name, app.metadata.namespace, params.refreshType).catch(e => {
ctx.notifications.show({
content: <ErrorNotification title={`Unable to refresh ${app.metadata.name}`} e={e} />,
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}>
Expand Down

0 comments on commit 3a72786

Please sign in to comment.