@@ -491,37 +491,43 @@ def validate_documents():
491
491
"Configuration saved successfully! Please restart the chat service for these changes to take effect."
492
492
)
493
493
494
- with st .popover (":red[Reset configuration to defaults]" ):
495
-
496
- # Close button with a custom class
497
- if st .button ("X" , key = "close_popup" , help = "Close popup" ):
498
- st .session_state ["popup_open" ] = False
499
- st .rerun ()
500
-
501
- st .write (
502
- "**Resetting the configuration cannot be reversed, proceed with caution!**"
503
- )
494
+ @st .dialog ("Reset Configuration" , width = "small" )
495
+ def reset_config_dialog ():
496
+ st .write ("**Resetting the configuration cannot be reversed. Proceed with caution!**" )
504
497
505
498
st .text_input ('Enter "reset" to proceed' , key = "reset_configuration" )
506
499
if st .button (
507
- ":red[Reset]" , disabled = st .session_state ["reset_configuration" ] != "reset"
500
+ ":red[Reset Now]" ,
501
+ disabled = st .session_state .get ("reset_configuration" , "" ) != "reset" ,
502
+ key = "confirm_reset"
508
503
):
509
- try :
510
- ConfigHelper . delete_config ()
511
- except ResourceNotFoundError :
512
- pass
513
-
514
- for key in st . session_state :
515
- del st . session_state [ key ]
516
-
504
+ with st . spinner ( "Resetting Configuration to Default values..." ) :
505
+ try :
506
+ ConfigHelper . delete_config ()
507
+ except ResourceNotFoundError :
508
+ pass
509
+
510
+ ConfigHelper . clear_config ()
511
+ st . session_state . clear ()
517
512
st .session_state ["reset" ] = True
518
513
st .session_state ["reset_configuration" ] = ""
514
+ st .session_state ["show_reset_dialog" ] = False
519
515
st .rerun ()
520
516
521
- if st .session_state .get ("reset" ) is True :
522
- st .success ("Configuration reset successfully!" )
523
- del st .session_state ["reset" ]
524
- del st .session_state ["reset_configuration" ]
517
+ # Reset configuration button
518
+ if st .button (":red[Reset configuration to defaults]" ):
519
+ st .session_state ["show_reset_dialog" ] = True
520
+
521
+ # Open the dialog if needed
522
+ if st .session_state .get ("show_reset_dialog" ):
523
+ reset_config_dialog ()
524
+ st .session_state ["show_reset_dialog" ] = False
525
+
526
+ # After reset success
527
+ if st .session_state .get ("reset" ):
528
+ st .success ("Configuration reset successfully!" )
529
+ del st .session_state ["reset" ]
530
+ del st .session_state ["reset_configuration" ]
525
531
526
532
except Exception as e :
527
533
logger .error (f"Error occurred: { e } " )
0 commit comments