"use client";
import { SymlinkIndicator } from "@/components/shared/symlink-indicator";
import type { ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { IconDownload } from "@tabler/icons-react";
import { Button } from "@kandev/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip";
import { toRelativePath } from "@/lib/utils";
import {
ExternalVcsFileLink,
useExternalVcsFileStatus,
} from "@/components/editors/external-vcs-file-link";
type FileViewerHeaderProps = {
path: string;
isSymlink?: boolean;
worktreePath?: string;
actions?: ReactNode;
};
export function FileViewerHeader({
path,
isSymlink,
worktreePath,
actions,
}: FileViewerHeaderProps) {
const label = toRelativePath(path, worktreePath);
if (!actions) {
return (
{label}
);
}
return (
{label}
{actions}
);
}
type FileViewerExternalLinkProps = {
path: string;
sessionId?: string | null;
taskId?: string | null;
repositoryId?: string | null;
repositoryName?: string;
};
export function FileViewerExternalLink({
path,
sessionId,
taskId,
repositoryId,
repositoryName,
}: FileViewerExternalLinkProps) {
const fileStatus = useExternalVcsFileStatus(path, sessionId, repositoryName);
return (
);
}
type FileViewerDownloadButtonProps = {
onDownload?: () => void;
};
/**
* Download control for the viewer header. Shared by the binary and image
* viewers so both screens, and the mobile viewer that renders the same
* `headerActions`, gain the action from one place.
*/
export function FileViewerDownloadButton({ onDownload }: FileViewerDownloadButtonProps) {
const { t } = useTranslation();
if (!onDownload) return null;
return (
{t("editors:downloadFile")}
);
}