Skip to content

Commit

Permalink
fix(ui): show prompt when using prune option
Browse files Browse the repository at this point in the history
Signed-off-by: ashutosh16 <11219262+ashutosh16@users.noreply.github.com>

fix(ui): show prompt when using prune option

Signed-off-by: ashutosh16 <11219262+ashutosh16@users.noreply.github.com>
  • Loading branch information
ashutosh16 committed Dec 15, 2023
1 parent 5a4d161 commit adc897d
Showing 1 changed file with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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?', () => (
<div>
<i className='fa fa-exclamation-triangle' style={{color: ARGO_WARNING_COLOR}} />
{PRUNE_WARNING} Are you sure you want to continue?
</div>
));
if (!confirmed) {
setPending(false);
return;
}
}

if (resources.length === appResources.length) {
resources = null;
}
Expand All @@ -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};
Expand All @@ -101,19 +110,6 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {app
return;
}
}
if (prune) {
const confirmed = await ctx.popup.confirm('Synchronize with prune?', () => (
<div>
<i className='fa fa-exclamation-triangle'
style={{color: ARGO_WARNING_COLOR}}/> {PRUNE_WARNING} Are you sure you
want to continue?
</div>
));
if (!confirmed) {
setPending(false);
return;
}
}

try {
await services.applications.sync(
Expand Down

0 comments on commit adc897d

Please sign in to comment.