Path: blob/main/components/dashboard/src/dedicated-setup/SetupCompleteStep.tsx
2506 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, useCallback, useState } from "react";7import { Button } from "@podkit/buttons/Button";8import { Heading1, Subheading } from "../components/typography/headings";9import Tooltip from "../components/Tooltip";10import copy from "../images/copy.svg";11import { copyToClipboard } from "../utils";12import { SetupLayout } from "./SetupLayout";13import { useTemporaryState } from "../hooks/use-temporary-value";1415type Props = {16onComplete: () => void;17};18export const SetupCompleteStep: FC<Props> = ({ onComplete }) => {19const url = document.location.origin;20const [copied, setCopied] = useTemporaryState(false, 2000);21const [copyError, setCopyError] = useState<string | undefined>();2223const handleCopyToClipboard = useCallback(() => {24copyToClipboard(url)25.then(() => setCopied(true))26.catch((error) => {27if (error instanceof DOMException) {28setCopyError(29"Gitpod is not allowed to copy to clipboard. Please copy the URL manually or adjust your browser permissions.",30);31return;32}3334setCopyError("Failed to copy to clipboard. Please copy the URL manually.");35});36}, [setCopied, url]);3738return (39<SetupLayout showOrg noMaxWidth>40<Heading1>Welcome to Gitpod</Heading1>41<Subheading>Your teammates can now sign in to Gitpod using single sign-on (SSO).</Subheading>4243<div className="flex flex-row items-center space-x-2 mt-4">44<div className="flex flex-row items-center space-x-1 font-mono text-sm text-pk-content-secondary">45{/* Keep the caret in a separate tag so triple clicking url doesn't select caret too */}46<pre>{`>`}</pre>47<pre>{url}</pre>48</div>49<div className="cursor-pointer" onClick={handleCopyToClipboard}>50<Tooltip content={copied ? "Copied" : "Click to copy"}>51<img src={copy} alt="copy icon" title="Click to copy" />52</Tooltip>53</div>54</div>5556<div className="my-4 text-pk-content-danger">{copyError && <p>{copyError}</p>}</div>5758<div className="mt-6 max-w-md">59<Button className="w-full" onClick={onComplete}>60Add a Git Integration61</Button>62</div>63</SetupLayout>64);65};666768