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