@@ -3,6 +3,7 @@ import { Portal } from 'react-portal';
33
44import { Close } from './Icon' ;
55import { useAppDispatch , useAppSelector } from './hooks' ;
6+ import * as client from './reducers/client' ;
67import { seenRustSurvey2025 } from './reducers/notifications' ;
78import { allowLongRun , wsExecuteKillCurrent } from './reducers/output/execute' ;
89import * as selectors from './selectors' ;
@@ -17,6 +18,8 @@ const Notifications: React.FC = () => {
1718 < div className = { styles . container } >
1819 < RustSurvey2025Notification />
1920 < ExcessiveExecutionNotification />
21+ < ResetConfigurationNotification />
22+ < ResetOldConfigurationNotification />
2023 </ div >
2124 </ Portal >
2225 ) ;
@@ -61,6 +64,54 @@ const ExcessiveExecutionNotification: React.FC = () => {
6164 ) : null ;
6265} ;
6366
67+ interface ResetNotificationCommonProps {
68+ preamble ?: string ;
69+ onReset : ( ) => void ;
70+ onCancel : ( ) => void ;
71+ }
72+
73+ const ResetNotificationCommon : React . FC < ResetNotificationCommonProps > = ( {
74+ preamble,
75+ onReset,
76+ onCancel,
77+ } ) => (
78+ < Notification onClose = { onReset } >
79+ { preamble }
80+ Would you like to reset all code and configuration back to the default values to get a fresh
81+ start?
82+ < div className = { styles . action } >
83+ < button onClick = { onReset } > Reset all code and configuration</ button >
84+ < button onClick = { onCancel } > Keep the current code and configuration</ button >
85+ </ div >
86+ </ Notification >
87+ ) ;
88+
89+ const ResetConfigurationNotification : React . FC = ( ) => {
90+ const showResetConfiguration = useAppSelector ( selectors . resetConfigurationSelector ) ;
91+
92+ const dispatch = useAppDispatch ( ) ;
93+ const reset = useCallback ( ( ) => dispatch ( client . resetEverything ( ) ) , [ dispatch ] ) ;
94+ const keep = useCallback ( ( ) => dispatch ( client . hideConfigReset ( ) ) , [ dispatch ] ) ;
95+
96+ return showResetConfiguration ? (
97+ < ResetNotificationCommon onReset = { reset } onCancel = { keep } />
98+ ) : null ;
99+ } ;
100+
101+ const ResetOldConfigurationNotification : React . FC = ( ) => {
102+ const showResetOldConfiguration = useAppSelector ( selectors . resetOldConfigurationSelector ) ;
103+
104+ const dispatch = useAppDispatch ( ) ;
105+ const reset = useCallback ( ( ) => dispatch ( client . resetEverything ( ) ) , [ dispatch ] ) ;
106+ const keep = useCallback ( ( ) => dispatch ( client . updateLastVisitedAt ( ) ) , [ dispatch ] ) ;
107+
108+ const preamble = "It's been a while since you've used the Playground. " ;
109+
110+ return showResetOldConfiguration ? (
111+ < ResetNotificationCommon preamble = { preamble } onReset = { reset } onCancel = { keep } />
112+ ) : null ;
113+ } ;
114+
64115interface NotificationProps {
65116 children : React . ReactNode ;
66117 onClose : ( ) => void ;
0 commit comments