2025-06-06 19:38:16 +00:00
|
|
|
|
|
|
|
|
import { Separator } from "@/components/ui/separator";
|
|
|
|
|
import { getRepoInfoByName } from "@/actions";
|
|
|
|
|
import { PathHeader } from "@/app/[domain]/components/pathHeader";
|
2025-07-14 23:07:09 +00:00
|
|
|
import { getFolderContents } from "@/features/fileTree/actions";
|
|
|
|
|
import { isServiceError } from "@/lib/utils";
|
|
|
|
|
import { PureTreePreviewPanel } from "./pureTreePreviewPanel";
|
|
|
|
|
|
|
|
|
|
interface TreePreviewPanelProps {
|
|
|
|
|
path: string;
|
|
|
|
|
repoName: string;
|
|
|
|
|
revisionName?: string;
|
|
|
|
|
domain: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const TreePreviewPanel = async ({ path, repoName, revisionName, domain }: TreePreviewPanelProps) => {
|
|
|
|
|
const [repoInfoResponse, folderContentsResponse] = await Promise.all([
|
|
|
|
|
getRepoInfoByName(repoName, domain),
|
|
|
|
|
getFolderContents({
|
|
|
|
|
repoName,
|
|
|
|
|
revisionName: revisionName ?? 'HEAD',
|
|
|
|
|
path,
|
|
|
|
|
}, domain)
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (isServiceError(folderContentsResponse) || isServiceError(repoInfoResponse)) {
|
|
|
|
|
return <div>Error loading tree preview</div>
|
2025-06-06 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
webUrl: repoInfoResponse.webUrl,
|
|
|
|
|
}}
|
|
|
|
|
pathType="tree"
|
2025-07-23 18:25:15 +00:00
|
|
|
isFileIconVisible={false}
|
2025-06-06 19:38:16 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<Separator />
|
2025-07-14 23:07:09 +00:00
|
|
|
<PureTreePreviewPanel items={folderContentsResponse} />
|
2025-06-06 19:38:16 +00:00
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|