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