diff --git a/ui/src/app/applications/components/application-sync-panel/application-sync-panel.tsx b/ui/src/app/applications/components/application-sync-panel/application-sync-panel.tsx index 293e34d2a6873..6bf9190122b4e 100644 --- a/ui/src/app/applications/components/application-sync-panel/application-sync-panel.tsx +++ b/ui/src/app/applications/components/application-sync-panel/application-sync-panel.tsx @@ -7,14 +7,7 @@ import {Consumer} from '../../../shared/context'; import * as models from '../../../shared/models'; import {services} from '../../../shared/services'; import {ApplicationRetryOptions} from '../application-retry-options/application-retry-options'; -import { - ApplicationManualSyncFlags, - ApplicationSyncOptions, - FORCE_WARNING, - SyncFlags, - REPLACE_WARNING, - PRUNE_WARNING -} from '../application-sync-options/application-sync-options'; +import {ApplicationManualSyncFlags, ApplicationSyncOptions, FORCE_WARNING, SyncFlags, REPLACE_WARNING, PRUNE_WARNING} from '../application-sync-options/application-sync-options'; import {ComparisonStatusIcon, getAppDefaultSource, nodeKey} from '../utils'; import './application-sync-panel.scss'; @@ -65,6 +58,24 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {app onSubmit={async (params: any) => { setPending(true); let resources = appResources.filter((_, i) => params.resources[i]); + + const syncFlags = {...params.syncFlags} as SyncFlags; + const prune = syncFlags.Prune || false; + const requiresPrune = resources.filter(resource => resource?.requiresPruning === true); + + if (prune && appResources.length === requiresPrune.length) { + const confirmed = await ctx.popup.confirm('Synchronize with prune?', () => ( +
+ + {PRUNE_WARNING} Are you sure you want to continue? +
+ )); + if (!confirmed) { + setPending(false); + return; + } + } + if (resources.length === appResources.length) { resources = null; } @@ -81,9 +92,7 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {app } } - const syncFlags = {...params.syncFlags} as SyncFlags; const force = syncFlags.Force || false; - const prune = syncFlags.Prune || false; if (syncFlags.ApplyOnly) { syncStrategy.apply = {force}; @@ -101,19 +110,6 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {app return; } } - if (prune) { - const confirmed = await ctx.popup.confirm('Synchronize with prune?', () => ( -
- {PRUNE_WARNING} Are you sure you - want to continue? -
- )); - if (!confirmed) { - setPending(false); - return; - } - } try { await services.applications.sync(