Skip to content

Commit b1a8634

Browse files
Improve Workspace timeout error UX
1 parent d2872f5 commit b1a8634

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

components/dashboard/src/user-settings/Preferences.tsx

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default function Preferences() {
3131
const [dotfileRepo, setDotfileRepo] = useState<string>(user?.additionalData?.dotfileRepo || "");
3232
const [workspaceTimeout, setWorkspaceTimeout] = useState<string>(user?.additionalData?.workspaceTimeout ?? "");
3333
const [timeoutUpdating, setTimeoutUpdating] = useState(false);
34+
const [creationError, setCreationError] = useState<Error>();
3435

3536
const saveDotfileRepo = useCallback(
3637
async (e) => {
@@ -70,10 +71,11 @@ export default function Preferences() {
7071
);
7172
}
7273
}
74+
// Reset creationError to avoid displaying the error message and toast the success message
75+
setCreationError(undefined);
7376
toast(toastMessage);
7477
} 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));
7779
} finally {
7880
setTimeoutUpdating(false);
7981
}
@@ -159,21 +161,28 @@ export default function Preferences() {
159161
</span>
160162
}
161163
>
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>
169180
</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+
)}
177186
</div>
178187
</InputField>
179188
</form>

0 commit comments

Comments
 (0)