Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/onboarding/StepPersonalize.tsx
2500 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { FC, ReactNode, useCallback, useState } from "react";
8
import SelectIDEComponent from "../components/SelectIDEComponent";
9
import { ThemeSelector } from "../components/ThemeSelector";
10
import { Heading2, Subheading } from "../components/typography/headings";
11
import { OnboardingStep } from "./OnboardingStep";
12
import { User } from "@gitpod/public-api/lib/gitpod/v1/user_pb";
13
import Alert from "../components/Alert";
14
15
type Props = {
16
user: User;
17
onComplete(ide: string, useLatest: boolean): void;
18
};
19
export const StepPersonalize: FC<Props> = ({ user, onComplete }) => {
20
const [ide, setIDE] = useState(user?.editorSettings?.name || "code");
21
const [useLatest, setUseLatest] = useState(user?.editorSettings?.version === "latest");
22
const [ideWarning, setIdeWarning] = useState<ReactNode | undefined>(undefined);
23
24
// This step doesn't save the ide selection yet (happens at the end), just passes them along
25
const handleSubmitted = useCallback(() => {
26
onComplete(ide, useLatest);
27
}, [ide, onComplete, useLatest]);
28
29
const isValid = !!ide;
30
31
return (
32
<OnboardingStep
33
title="How are you going to use Gitpod?"
34
subtitle="We will tailor your experience based on your preferences."
35
isValid={isValid}
36
onSubmit={handleSubmitted}
37
>
38
<Heading2>Choose an editor</Heading2>
39
<Subheading className="mb-2">You can change this later in your user preferences.</Subheading>
40
{ideWarning && (
41
// We set a max width so that the layout does not shift when the warning is displayed.
42
<Alert type="warning" className="my-2 max-w-[28.5rem]">
43
<span className="text-sm">{ideWarning}</span>
44
</Alert>
45
)}
46
<SelectIDEComponent
47
onSelectionChange={(ide, latest) => {
48
setIDE(ide);
49
setUseLatest(latest);
50
}}
51
setWarning={setIdeWarning}
52
ignoreRestrictionScopes={["configuration", "organization"]}
53
selectedIdeOption={ide}
54
useLatest={useLatest}
55
hideVersions
56
/>
57
58
<ThemeSelector className="mt-4" />
59
</OnboardingStep>
60
);
61
};
62
63