Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/dedicated-setup/SetupLayout.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, useEffect } from "react";
8
import gitpodIcon from "../icons/gitpod.svg";
9
import { OrgIcon } from "../components/org-icon/OrgIcon";
10
import { useCurrentOrg } from "../data/organizations/orgs-query";
11
import check from "../images/check.svg";
12
import "./styles.css";
13
14
type Props = {
15
showOrg?: boolean;
16
noMaxWidth?: boolean;
17
progressCurrent?: number;
18
progressTotal?: number;
19
};
20
export const SetupLayout: FC<Props> = ({
21
showOrg = false,
22
noMaxWidth = false,
23
progressCurrent,
24
progressTotal,
25
children,
26
}) => {
27
const currentOrg = useCurrentOrg();
28
29
useEffect(() => {
30
document.body.classList.add("honeycomb-bg");
31
32
return () => {
33
document.body.classList.remove("honeycomb-bg");
34
};
35
}, []);
36
37
return (
38
<div className="container">
39
<div className="app-container">
40
<div className="flex justify-between items-center">
41
<div className="flex items-center justify-start py-3 space-x-1">
42
<img src={gitpodIcon} className="w-6 h-6" alt="Gitpod's logo" />
43
{showOrg ? (
44
<div className="pr-1 flex font-semibold whitespace-nowrap max-w-xs overflow-hidden">
45
<OrgIcon
46
id={currentOrg?.data?.id || "empty"}
47
name={currentOrg.data?.name || ""}
48
size="small"
49
className="mr-2"
50
/>
51
{currentOrg.data?.name}
52
</div>
53
) : (
54
<span className="text-lg">Gitpod</span>
55
)}
56
</div>
57
</div>
58
<div className={`mt-24 ${noMaxWidth ? "" : "max-w-md"} pb-4`}>
59
{/* generate the rounded dots for the progress */}
60
{progressCurrent !== undefined && progressTotal !== undefined ? (
61
<div className="flex flex-row space-x-2 mb-4">
62
{[...Array(progressTotal).keys()].map((i) => (
63
<ProgressElement key={i} i={i + 1} current={progressCurrent} />
64
))}
65
</div>
66
) : null}
67
<>{children}</>
68
</div>
69
</div>
70
</div>
71
);
72
};
73
74
const ProgressElement: FC<{ i: number; current: number }> = ({ current, i }) => {
75
if (i < current) {
76
return (
77
<div className="w-5 h-5 bg-green-600 rounded-full flex justify-center items-center text-color-white">
78
<img src={check} width={15} height={15} alt="checkmark" />
79
</div>
80
);
81
} else if (i === current) {
82
return <div className="w-5 h-5 rounded-full bg-gray-400" />;
83
} else {
84
return <div className="w-5 h-5 rounded-full border-2 border-dashed border-gray-400" />;
85
}
86
};
87
88