diff --git a/ui/src/app/applications/components/applications-sync-panel/applications-sync-panel.tsx b/ui/src/app/applications/components/applications-sync-panel/applications-sync-panel.tsx index 97a13d14ec..b90a8f376b 100644 --- a/ui/src/app/applications/components/applications-sync-panel/applications-sync-panel.tsx +++ b/ui/src/app/applications/components/applications-sync-panel/applications-sync-panel.tsx @@ -1,13 +1,20 @@ import {ErrorNotification, NotificationType, SlidingPanel} from 'argo-ui'; import * as React from 'react'; import {Checkbox, Form, FormApi} from 'react-form'; +import {ProgressPopup} from '../../../shared/components'; import {Consumer} from '../../../shared/context'; import * as models from '../../../shared/models'; import {services} from '../../../shared/services'; import {ComparisonStatusIcon, HealthStatusIcon, OperationPhaseIcon} from '../utils'; +interface Progress { + percentage: number; + title: string; +} + export const ApplicationsSyncPanel = ({show, apps, hide}: {show: boolean; apps: models.Application[]; hide: () => void}) => { const [form, setForm] = React.useState(null); + const [progress, setProgress] = React.useState(null); const getSelectedApps = (params: any) => apps.filter(app => params['app/' + app.metadata.name]); return ( @@ -33,11 +40,9 @@ export const ApplicationsSyncPanel = ({show, apps, hide}: {show: boolean; apps: ctx.notifications.show({content: `No apps selected`, type: NotificationType.Error}); return; } - ctx.notifications.show({ - content: `Syncing ${selectedApps.length} app(s)`, - type: NotificationType.Success - }); const syncStrategy = (params.applyOnly ? {apply: {force: params.force}} : {hook: {force: params.force}}) as models.SyncStrategy; + setProgress({percentage: 0, title: 'Starting...'}); + let i = 0; for (const app of selectedApps) { await services.applications.sync(app.metadata.name, app.spec.source.targetRevision, params.prune, params.dryRun, syncStrategy, null).catch(e => { ctx.notifications.show({ @@ -45,14 +50,20 @@ export const ApplicationsSyncPanel = ({show, apps, hide}: {show: boolean; apps: type: NotificationType.Error }); }); + i++; + setProgress({ + percentage: i / selectedApps.length, + title: `${i} of ${selectedApps.length} apps synced` + }); } - hide(); + setProgress({percentage: 100, title: 'Complete'}); }} getApi={setForm}> {formApi => (

Sync app(s)

+ {progress !== null && setProgress(null)} percentage={progress.percentage} title={progress.title} />}