forked from weaveworks/weave-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitRepositoryDetail.tsx
78 lines (73 loc) · 2.05 KB
/
GitRepositoryDetail.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import * as React from "react";
import styled from "styled-components";
import Link from "../components/Link";
import SourceDetail from "../components/SourceDetail";
import Timestamp from "../components/Timestamp";
import { useFeatureFlags } from "../hooks/featureflags";
import { Kind } from "../lib/api/core/types.pb";
import { GitRepository } from "../lib/objects";
import { convertGitURLToGitProvider } from "../lib/utils";
import ClusterDashboardLink from "./ClusterDashboardLink";
import { InfoField } from "./InfoList";
type Props = {
className?: string;
gitRepository: GitRepository;
customActions?: JSX.Element[];
};
function GitRepositoryDetail({
className,
gitRepository,
customActions,
}: Props) {
const { isFlagEnabled } = useFeatureFlags();
const tenancyInfo: InfoField[] =
isFlagEnabled("WEAVE_GITOPS_FEATURE_TENANCY") && gitRepository.tenant
? [["Tenant", gitRepository.tenant]]
: [];
const clusterInfo: InfoField[] = isFlagEnabled("WEAVE_GITOPS_FEATURE_CLUSTER")
? [
[
"Cluster",
<ClusterDashboardLink
key={gitRepository.uid}
clusterName={gitRepository?.clusterName}
/>,
],
]
: [];
return (
<SourceDetail
className={className}
type={Kind.GitRepository}
source={gitRepository}
customActions={customActions}
info={[
["Kind", Kind.GitRepository],
[
"URL",
<Link
key={gitRepository.uid}
newTab
href={convertGitURLToGitProvider(gitRepository.url)}
>
{gitRepository.url}
</Link>,
],
["Ref", gitRepository.reference?.branch],
[
"Last Updated",
<Timestamp
key={gitRepository.uid}
time={gitRepository.lastUpdatedAt}
/>,
],
...clusterInfo,
["Namespace", gitRepository.namespace],
...tenancyInfo,
]}
/>
);
}
export default styled(GitRepositoryDetail).attrs({
className: GitRepositoryDetail.name,
})``;