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