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