Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/teams/git-integrations/GitIntegrationsList.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 { FunctionComponent, useCallback, useState } from "react";
8
import { Button } from "@podkit/buttons/Button";
9
import { EmptyMessage } from "../../components/EmptyMessage";
10
import { Item, ItemField, ItemFieldIcon, ItemsList } from "../../components/ItemsList";
11
import { Heading2, Subheading } from "../../components/typography/headings";
12
import { GitIntegrationListItem } from "./GitIntegrationListItem";
13
import { GitIntegrationModal } from "./GitIntegrationModal";
14
import { AuthProvider } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb";
15
16
type Props = {
17
providers: AuthProvider[];
18
};
19
export const GitIntegrationsList: FunctionComponent<Props> = ({ providers }) => {
20
const [showCreateModal, setShowCreateModal] = useState(false);
21
22
const onCreate = useCallback(() => setShowCreateModal(true), []);
23
const hideModal = useCallback(() => setShowCreateModal(false), []);
24
25
return (
26
<>
27
<div className="flex flex-col space-y-2 md:flex-row md:items-start md:justify-between md:space-y-0">
28
<div>
29
<Heading2>Git Provider</Heading2>
30
<Subheading>Configure Git provider integrations for your organization.</Subheading>
31
</div>
32
33
{providers.length !== 0 ? (
34
<div>
35
<Button className="whitespace-nowrap" onClick={onCreate}>
36
New Git Provider
37
</Button>
38
</div>
39
) : null}
40
</div>
41
42
{providers.length === 0 ? (
43
<EmptyMessage
44
title="No Git Providers"
45
subtitle="Configure a Git Provider with GitHub, GitLab, or Bitbucket Server."
46
buttonText="New Git Provider"
47
onClick={onCreate}
48
/>
49
) : (
50
<ItemsList className="pt-6">
51
<Item header={true}>
52
<ItemFieldIcon />
53
<ItemField className="w-5/12">Provider Type</ItemField>
54
<ItemField className="w-6/12">Host Name</ItemField>
55
</Item>
56
{providers.map((p) => (
57
<GitIntegrationListItem key={p.id} provider={p} />
58
))}
59
</ItemsList>
60
)}
61
{showCreateModal && <GitIntegrationModal onClose={hideModal} />}
62
</>
63
);
64
};
65
66