-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathtreePreviewPanel.tsx
More file actions
76 lines (71 loc) · 2.84 KB
/
treePreviewPanel.tsx
File metadata and controls
76 lines (71 loc) · 2.84 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
import { Separator } from "@/components/ui/separator";
import { getRepoInfoByName } from "@/actions";
import { PathHeader } from "@/app/[domain]/components/pathHeader";
import { getFolderContents } from "@/features/fileTree/api";
import { isServiceError } from "@/lib/utils";
import { PureTreePreviewPanel } from "./pureTreePreviewPanel";
import { FolderOpen } from "lucide-react";
interface TreePreviewPanelProps {
path: string;
repoName: string;
revisionName?: string;
}
export const TreePreviewPanel = async ({ path, repoName, revisionName }: TreePreviewPanelProps) => {
const [repoInfoResponse, folderContentsResponse] = await Promise.all([
getRepoInfoByName(repoName),
getFolderContents({
repoName,
revisionName: revisionName ?? 'HEAD',
path,
})
]);
if (isServiceError(folderContentsResponse) || isServiceError(repoInfoResponse)) {
return <div>Error loading tree preview</div>
}
if (folderContentsResponse.length === 0) {
return (
<>
<div className="flex flex-row py-1 px-2 items-center justify-between">
<PathHeader
path={path}
repo={{
name: repoName,
codeHostType: repoInfoResponse.codeHostType,
displayName: repoInfoResponse.displayName,
externalWebUrl: repoInfoResponse.externalWebUrl,
}}
pathType="tree"
isFileIconVisible={false}
revisionName={revisionName}
/>
</div>
<Separator />
<div className="flex flex-col items-center justify-center h-full text-muted-foreground">
<FolderOpen className="w-16 h-16 mb-4" />
<p className="text-sm font-medium">No commits yet</p>
<p className="text-xs mt-1">This repository doesn't have any code yet</p>
</div>
</>
)
}
return (
<>
<div className="flex flex-row py-1 px-2 items-center justify-between">
<PathHeader
path={path}
repo={{
name: repoName,
codeHostType: repoInfoResponse.codeHostType,
displayName: repoInfoResponse.displayName,
externalWebUrl: repoInfoResponse.externalWebUrl,
}}
pathType="tree"
isFileIconVisible={false}
revisionName={revisionName}
/>
</div>
<Separator />
<PureTreePreviewPanel items={folderContentsResponse} />
</>
)
}