@@ -31,6 +31,7 @@ export default function Preferences() {
31
31
const [ dotfileRepo , setDotfileRepo ] = useState < string > ( user ?. additionalData ?. dotfileRepo || "" ) ;
32
32
const [ workspaceTimeout , setWorkspaceTimeout ] = useState < string > ( user ?. additionalData ?. workspaceTimeout ?? "" ) ;
33
33
const [ timeoutUpdating , setTimeoutUpdating ] = useState ( false ) ;
34
+ const [ creationError , setCreationError ] = useState < Error > ( ) ;
34
35
35
36
const saveDotfileRepo = useCallback (
36
37
async ( e ) => {
@@ -70,10 +71,11 @@ export default function Preferences() {
70
71
) ;
71
72
}
72
73
}
74
+ // Reset creationError to avoid displaying the error message and toast the success message
75
+ setCreationError ( undefined ) ;
73
76
toast ( toastMessage ) ;
74
77
} catch ( e ) {
75
- // TODO: Convert this to an error style toast
76
- alert ( "Cannot set custom workspace timeout: " + e . message ) ;
78
+ setCreationError ( new Error ( e . message ) ) ;
77
79
} finally {
78
80
setTimeoutUpdating ( false ) ;
79
81
}
@@ -159,21 +161,28 @@ export default function Preferences() {
159
161
</ span >
160
162
}
161
163
>
162
- < div className = "flex space-x-2" >
163
- < div className = "flex-grow" >
164
- < TextInput
165
- value = { workspaceTimeout }
166
- placeholder = "e.g. 30m"
167
- onChange = { setWorkspaceTimeout }
168
- />
164
+ < div className = "flex flex-col" >
165
+ < div className = "flex items-center space-x-2 mb-2" >
166
+ < div className = "flex-grow" >
167
+ < TextInput
168
+ value = { workspaceTimeout }
169
+ placeholder = "e.g. 30m"
170
+ onChange = { setWorkspaceTimeout }
171
+ />
172
+ </ div >
173
+ < Button
174
+ htmlType = "submit"
175
+ loading = { timeoutUpdating }
176
+ disabled = { workspaceTimeout === user ?. additionalData ?. workspaceTimeout ?? "" }
177
+ >
178
+ Save
179
+ </ Button >
169
180
</ div >
170
- < Button
171
- htmlType = "submit"
172
- loading = { timeoutUpdating }
173
- disabled = { workspaceTimeout === user ?. additionalData ?. workspaceTimeout ?? "" }
174
- >
175
- Save
176
- </ Button >
181
+ { ! ! creationError && (
182
+ < p className = "text-gitpod-red w-full max-w-lg" >
183
+ Cannot set custom workspace timeout: { creationError . message }
184
+ </ p >
185
+ ) }
177
186
</ div >
178
187
</ InputField >
179
188
</ form >
0 commit comments