@@ -372,16 +372,18 @@ export const ApplicationSummary = (props: ApplicationSummaryProps) => {
372
372
} ) ;
373
373
}
374
374
375
- async function setAutoSync ( ctx : ContextApis , confirmationTitle : string , confirmationText : string , prune : boolean , selfHeal : boolean ) {
375
+ async function setAutoSync ( ctx : ContextApis , confirmationTitle : string , confirmationText : string , prune : boolean , selfHeal : boolean , enable : boolean ) {
376
376
const confirmed = await ctx . popup . confirm ( confirmationTitle , confirmationText ) ;
377
377
if ( confirmed ) {
378
378
try {
379
379
setChangeSync ( true ) ;
380
380
const updatedApp = JSON . parse ( JSON . stringify ( props . app ) ) as models . Application ;
381
- if ( ! updatedApp . spec . syncPolicy ) {
381
+ if ( ! updatedApp . spec . syncPolicy ) {
382
382
updatedApp . spec . syncPolicy = { } ;
383
383
}
384
- updatedApp . spec . syncPolicy . automated = { prune, selfHeal, enabled : true } ;
384
+ //preserve the current enabled state when modifying prune or self heal
385
+ const currentEnabled = updatedApp . spec . syncPolicy . automated ?. enabled ;
386
+ updatedApp . spec . syncPolicy . automated = { prune, selfHeal, enabled : currentEnabled ?? enable } ;
385
387
await updateApp ( updatedApp , { validate : false } ) ;
386
388
} catch ( e ) {
387
389
ctx . notifications . show ( {
@@ -518,7 +520,7 @@ export const ApplicationSummary = (props: ApplicationSummaryProps) => {
518
520
< button
519
521
className = 'argo-button argo-button--base'
520
522
onClick = { ( ) =>
521
- setAutoSync ( ctx , 'Enable Auto-Sync?' , 'Are you sure you want to enable automated application synchronization?' , false , false )
523
+ setAutoSync ( ctx , 'Enable Auto-Sync?' , 'Are you sure you want to enable automated application synchronization?' , false , false , true )
522
524
} >
523
525
< Spinner show = { changeSync } style = { { marginRight : '5px' } } />
524
526
Enable Auto-Sync
@@ -554,8 +556,7 @@ export const ApplicationSummary = (props: ApplicationSummaryProps) => {
554
556
await updateApp ( updatedApp , { validate : false } ) ;
555
557
}
556
558
} }
557
- checked = { ! ! app . spec . syncPolicy ?. automated ?. enabled }
558
- id = 'enable-auto-sync'
559
+ checked = { app . spec . syncPolicy ?. automated ? ( app . spec . syncPolicy . automated . enabled !== false ) : false } id = 'enable-auto-sync'
559
560
/>
560
561
< label htmlFor = 'enable-auto-sync' > ENABLE AUTO-SYNC</ label >
561
562
< HelpIcon title = 'If checked, application will automatically sync when changes are detected' />
0 commit comments