Path: blob/main/components/dashboard/src/repositories/list/RepoListItem.tsx
2501 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 { usePrettyRepoURL } from "../../hooks/use-pretty-repo-url";8import { TextMuted } from "@podkit/typography/TextMuted";9import { Text } from "@podkit/typography/Text";10import { LinkButton } from "@podkit/buttons/LinkButton";11import type { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb";12import { AlertTriangleIcon, CheckCircle2Icon } from "lucide-react";13import { TableCell, TableRow } from "@podkit/tables/Table";14import PillLabel from "../../components/PillLabel";1516type Props = {17configuration: Configuration;18isSuggested: boolean;19};20export const RepositoryListItem: FC<Props> = ({ configuration, isSuggested }) => {21const url = usePrettyRepoURL(configuration.cloneUrl);22const prebuildsEnabled = !!configuration.prebuildSettings?.enabled;23const created =24configuration.creationTime25?.toDate()26.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }) ?? "";2728return (29<TableRow>30<TableCell>31<div className="flex flex-col gap-1 break-words w-auto md:w-64">32<Text className="font-semibold flex items-center justify-between gap-1">33{configuration.name}34{isSuggested && (35<PillLabel36className="capitalize bg-kumquat-light shrink-0 text-sm hidden xl:block"37type="warn"38>39Suggested40</PillLabel>41)}42</Text>43{/* We show the url on a 2nd line for smaller screens since we hide the column */}44<TextMuted className="inline md:hidden text-sm break-all">{url}</TextMuted>45</div>46</TableCell>4748<TableCell hideOnSmallScreen>49<TextMuted className="text-sm break-all">{url}</TextMuted>50</TableCell>5152<TableCell hideOnSmallScreen>{created}</TableCell>5354<TableCell hideOnSmallScreen>55<div className="flex flex-row gap-1 items-center">56{prebuildsEnabled ? (57<CheckCircle2Icon size={20} className="text-green-500" />58) : (59<AlertTriangleIcon size={20} className="text-kumquat-base" />60)}6162<TextMuted>{prebuildsEnabled ? "Enabled" : "Disabled"}</TextMuted>63</div>64</TableCell>6566<TableCell>67<LinkButton href={`/repositories/${configuration.id}`} variant="secondary">68View69</LinkButton>70</TableCell>71</TableRow>72);73};747576