-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathGitMetadata.tsx
More file actions
86 lines (81 loc) · 2.17 KB
/
GitMetadata.tsx
File metadata and controls
86 lines (81 loc) · 2.17 KB
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
79
80
81
82
83
84
85
86
import { GitPullRequestIcon, GitCommitIcon, GitBranchIcon } from "lucide-react";
import { type GitMetaLinks } from "~/presenters/v3/BranchesPresenter.server";
import { LinkButton } from "./primitives/Buttons";
import { SimpleTooltip } from "./primitives/Tooltip";
export function GitMetadata({ git }: { git?: GitMetaLinks | null }) {
if (!git) return null;
return (
<>
{git.pullRequestUrl && git.pullRequestNumber && <GitMetadataPullRequest git={git} />}
{git.branchUrl && <GitMetadataBranch git={git} />}
{git.shortSha && <GitMetadataCommit git={git} />}
</>
);
}
export function GitMetadataBranch({
git,
}: {
git: Pick<GitMetaLinks, "branchUrl" | "branchName">;
}) {
return (
<SimpleTooltip
button={
<LinkButton
variant="minimal/small"
LeadingIcon={<GitBranchIcon className="size-4" />}
iconSpacing="gap-x-1"
to={git.branchUrl}
className="pl-1"
>
{git.branchName}
</LinkButton>
}
content="Jump to GitHub branch"
/>
);
}
export function GitMetadataCommit({
git,
}: {
git: Pick<GitMetaLinks, "commitUrl" | "shortSha" | "commitMessage">;
}) {
return (
<SimpleTooltip
button={
<LinkButton
variant="minimal/small"
to={git.commitUrl}
LeadingIcon={<GitCommitIcon className="size-4" />}
iconSpacing="gap-x-1"
className="pl-1"
>
{`${git.shortSha} / ${git.commitMessage}`}
</LinkButton>
}
content="Jump to GitHub commit"
/>
);
}
export function GitMetadataPullRequest({
git,
}: {
git: Pick<GitMetaLinks, "pullRequestUrl" | "pullRequestNumber" | "pullRequestTitle">;
}) {
if (!git.pullRequestUrl || !git.pullRequestNumber) return null;
return (
<SimpleTooltip
button={
<LinkButton
variant="minimal/small"
to={git.pullRequestUrl}
LeadingIcon={<GitPullRequestIcon className="size-4" />}
iconSpacing="gap-x-1"
className="pl-1"
>
#{git.pullRequestNumber} {git.pullRequestTitle}
</LinkButton>
}
content="Jump to GitHub pull request"
/>
);
}