import Button from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { Fragment } from "react/jsx-runtime"; type Props = { bucketName?: string; curPrefix: number; setCurPrefix: React.Dispatch>; prefixHistory: string[]; actions?: React.ReactNode; }; const ObjectListNavigator = ({ bucketName, curPrefix, setCurPrefix, prefixHistory, actions, }: Props) => { const onGoBack = () => { if (curPrefix >= 0) setCurPrefix(curPrefix - 1); }; const onGoForward = () => { if (curPrefix < prefixHistory.length - 1) setCurPrefix(curPrefix + 1); }; return (
setCurPrefix(-1)} /> {prefixHistory.map((prefix, i) => ( setCurPrefix(i)} /> ))}
{actions}
); }; type HistoryItemProps = { title?: string; isActive: boolean; onClick: () => void; }; const HistoryItem = ({ title, isActive, onClick }: HistoryItemProps) => { if (!title) { return null; } return ( { e.preventDefault(); onClick(); }} className={cn("px-2 rounded-sm shrink-0", isActive && "bg-neutral")} > {title} ); }; export default ObjectListNavigator;