Skip to content

Commit d200298

Browse files
committed
a
1 parent cca07f1 commit d200298

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { UserContext } from "../user-context";
1212
import { trackEvent } from "../Analytics";
1313
import SelectIDE from "./SelectIDE";
1414
import { PageWithSettingsSubMenu } from "./PageWithSettingsSubMenu";
15+
import CheckBox from "../components/CheckBox";
16+
import { WorkspaceTimeoutDuration } from "@gitpod/gitpod-protocol";
1517

1618
type Theme = "light" | "dark" | "system";
1719

@@ -47,6 +49,29 @@ export default function Preferences() {
4749
}
4850
};
4951

52+
const [disabledClosedTimeout] = useState<boolean>(user?.additionalData?.disabledClosedTimeout ?? false);
53+
const actuallySetDisabledClosedTimeout = async (value: boolean) => {
54+
try {
55+
const additionalData = user?.additionalData || {};
56+
additionalData.disabledClosedTimeout = value;
57+
await getGitpodService().server.updateLoggedInUser({ additionalData });
58+
} catch (e) {
59+
alert("Cannot set custom workspace timeout: " + e.message);
60+
}
61+
};
62+
63+
const [workspaceTimeout, setWorkspaceTimeout] = useState<string>(user?.additionalData?.workspaceTimeout ?? "");
64+
const actuallySetWorkspaceTimeout = async (value: string) => {
65+
try {
66+
const timeout = WorkspaceTimeoutDuration.validate(value);
67+
const additionalData = user?.additionalData || {};
68+
additionalData.workspaceTimeout = timeout;
69+
await getGitpodService().server.updateLoggedInUser({ additionalData });
70+
} catch (e) {
71+
alert("Cannot set custom workspace timeout: " + e.message);
72+
}
73+
};
74+
5075
return (
5176
<div>
5277
<PageWithSettingsSubMenu>
@@ -142,6 +167,37 @@ export default function Preferences() {
142167
</p>
143168
</div>
144169
</div>
170+
171+
<h3 className="mt-12">Timeout </h3>
172+
<p className="text-base text-gray-500 dark:text-gray-400">Customize timeout setting for workspace.</p>
173+
<div className="mt-4 max-w-xl">
174+
<h4>Workspace timeout</h4>
175+
<span className="flex">
176+
<input
177+
type="text"
178+
className="w-96 h-9"
179+
value={workspaceTimeout}
180+
placeholder="timeout time, such as 30m, 1h, max 24h"
181+
onChange={(e) => setWorkspaceTimeout(e.target.value)}
182+
/>
183+
<button
184+
className="secondary ml-2"
185+
onClick={() => actuallySetWorkspaceTimeout(workspaceTimeout)}
186+
>
187+
Save Changes
188+
</button>
189+
</span>
190+
<div className="mt-1">
191+
<p className="text-gray-500 dark:text-gray-400">some description</p>
192+
</div>
193+
194+
<CheckBox
195+
title="Disabled Close Timeout"
196+
desc={<span></span>}
197+
checked={disabledClosedTimeout}
198+
onChange={(e) => actuallySetDisabledClosedTimeout(e.target.checked)}
199+
/>
200+
</div>
145201
</PageWithSettingsSubMenu>
146202
</div>
147203
);

components/gitpod-protocol/src/protocol.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ export interface AdditionalUserData {
230230
// whether the user has been migrated to team attribution.
231231
// a corresponding feature flag (team_only_attribution) triggers the migration.
232232
isMigratedToTeamOnlyAttribution?: boolean;
233+
// user globol workspace timeout
234+
workspaceTimeout?: string;
235+
disabledClosedTimeout?: boolean;
233236
}
234237
export namespace AdditionalUserData {
235238
export function set(user: User, partialData: Partial<AdditionalUserData>): User {

0 commit comments

Comments
 (0)