Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/repositories/detail/shared/WorkspaceClassOptions.tsx
2502 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 } from "react";
8
import { useOrgWorkspaceClassesQuery } from "../../../data/organizations/org-workspace-classes-query";
9
import { LoadingState } from "@podkit/loading/LoadingState";
10
import { cn } from "@podkit/lib/cn";
11
import Alert from "../../../components/Alert";
12
import { Label } from "@podkit/forms/Label";
13
import { RadioGroup, RadioGroupItem } from "@podkit/forms/RadioListField";
14
15
type Props = {
16
value: string;
17
className?: string;
18
onChange: (newValue: string) => void;
19
};
20
export const WorkspaceClassOptions: FC<Props> = ({ value, className, onChange }) => {
21
const { data: classes, isLoading } = useOrgWorkspaceClassesQuery();
22
23
if (isLoading) {
24
return <LoadingState />;
25
}
26
27
if (!classes) {
28
return <Alert type="error">There was a problem loading workspace classes.</Alert>;
29
}
30
31
return (
32
<RadioGroup value={value} onValueChange={onChange} className={cn("my-4 gap-4", className)}>
33
{classes.map((wsClass) => (
34
<Label className="flex items-start space-x-2" key={wsClass.id}>
35
<RadioGroupItem value={wsClass.id} />
36
<div className="flex flex-col text-sm">
37
<span className="font-semibold">{wsClass.displayName}</span>
38
<span className="text-pk-content-tertiary">{wsClass.description}</span>
39
</div>
40
</Label>
41
))}
42
</RadioGroup>
43
);
44
};
45
46