Skip to content

Commit c632b7e

Browse files
authored
[dashboard] don't ask again on ws creation (#17297)
1 parent e8a3c4e commit c632b7e

File tree

4 files changed

+210
-35
lines changed

4 files changed

+210
-35
lines changed

components/dashboard/src/start/start-workspace-options.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
import { GitpodServer } from "@gitpod/gitpod-protocol";
7+
import { IDESettings } from "@gitpod/gitpod-protocol";
88

9+
export interface StartWorkspaceOptions {
10+
workspaceClass?: string;
11+
ideSettings?: IDESettings;
12+
autostart?: boolean;
13+
}
914
export namespace StartWorkspaceOptions {
1015
// The workspace class to use for the workspace. If not specified, the default workspace class is used.
1116
export const WORKSPACE_CLASS = "workspaceClass";
1217

1318
// The editor to use for the workspace. If not specified, the default editor is used.
1419
export const EDITOR = "editor";
1520

16-
export function parseSearchParams(search: string): GitpodServer.StartWorkspaceOptions {
21+
// whether the workspace should automatically start
22+
export const AUTOSTART = "autostart";
23+
24+
export function parseSearchParams(search: string): StartWorkspaceOptions {
1725
const params = new URLSearchParams(search);
18-
const options: GitpodServer.StartWorkspaceOptions = {};
26+
const options: StartWorkspaceOptions = {};
1927
const workspaceClass = params.get(StartWorkspaceOptions.WORKSPACE_CLASS);
2028
if (workspaceClass) {
2129
options.workspaceClass = workspaceClass;
@@ -34,10 +42,13 @@ export namespace StartWorkspaceOptions {
3442
};
3543
}
3644
}
45+
if (params.get(StartWorkspaceOptions.AUTOSTART) === "true") {
46+
options.autostart = true;
47+
}
3748
return options;
3849
}
3950

40-
export function toSearchParams(options: GitpodServer.StartWorkspaceOptions): string {
51+
export function toSearchParams(options: StartWorkspaceOptions): string {
4152
const params = new URLSearchParams();
4253
if (options.workspaceClass) {
4354
params.set(StartWorkspaceOptions.WORKSPACE_CLASS, options.workspaceClass);
@@ -47,6 +58,9 @@ export namespace StartWorkspaceOptions {
4758
const latest = options.ideSettings.useLatestVersion;
4859
params.set(StartWorkspaceOptions.EDITOR, latest ? ide + "-latest" : ide);
4960
}
61+
if (options.autostart) {
62+
params.set(StartWorkspaceOptions.AUTOSTART, "true");
63+
}
5064
return params.toString();
5165
}
5266

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import { PageWithSettingsSubMenu } from "./PageWithSettingsSubMenu";
1111
import { ThemeSelector } from "../components/ThemeSelector";
1212
import Alert from "../components/Alert";
1313
import { Link } from "react-router-dom";
14-
import { Heading2, Subheading } from "../components/typography/headings";
14+
import { Heading2, Heading3, Subheading } from "../components/typography/headings";
1515
import { useUserMaySetTimeout } from "../data/current-user/may-set-timeout-query";
1616
import { Button } from "../components/Button";
1717
import SelectIDE from "./SelectIDE";
1818
import { InputField } from "../components/forms/InputField";
1919
import { TextInput } from "../components/forms/TextInputField";
2020
import { useToast } from "../components/toasts/Toasts";
2121
import { useUpdateCurrentUserDotfileRepoMutation } from "../data/current-user/update-mutation";
22+
import { AdditionalUserData } from "@gitpod/gitpod-protocol";
2223

2324
export type IDEChangedTrackLocation = "workspace_list" | "workspace_start" | "preferences";
2425

@@ -67,12 +68,22 @@ export default function Preferences() {
6768
[toast, setUser, workspaceTimeout],
6869
);
6970

71+
const clearAutostartWorkspaceOptions = useCallback(async () => {
72+
if (!user) {
73+
return;
74+
}
75+
AdditionalUserData.set(user, { workspaceAutostartOptions: [] });
76+
setUser(user);
77+
await getGitpodService().server.updateLoggedInUser(user);
78+
toast("Your autostart options were cleared.");
79+
}, [setUser, toast, user]);
80+
7081
return (
7182
<div>
7283
<PageWithSettingsSubMenu>
73-
<Heading2>Editor</Heading2>
84+
<Heading2>New Workspaces</Heading2>
7485
<Subheading>
75-
Choose the editor for opening workspaces.{" "}
86+
Choose your default editor.{" "}
7687
<a
7788
className="gp-link"
7889
href="https://www.gitpod.io/docs/references/ides-and-editors"
@@ -83,6 +94,11 @@ export default function Preferences() {
8394
</a>
8495
</Subheading>
8596
<SelectIDE location="preferences" />
97+
<Heading3 className="mt-12">Autostart Options</Heading3>
98+
<Subheading>Forget any saved autostart options for all repositories.</Subheading>
99+
<Button className="mt-4" type="secondary" onClick={clearAutostartWorkspaceOptions}>
100+
Reset Options
101+
</Button>
86102

87103
<ThemeSelector className="mt-12" />
88104

0 commit comments

Comments
 (0)