"use client";
import {
IconSettings,
IconTextWrap,
IconLayoutColumns,
IconLayoutRows,
IconMessageForward,
IconArrowsMaximize,
IconRoute,
} from "@tabler/icons-react";
import { Button } from "@kandev/ui/button";
import { Checkbox } from "@kandev/ui/checkbox";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@kandev/ui/dropdown-menu";
import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip";
import { PanelHeaderBarSplit } from "./panel-primitives";
export type ChangesTopBarProps = {
autoMarkOnScroll: boolean;
splitView: boolean;
wordWrap: boolean;
totalCommentCount: number;
reviewedCount: number;
totalCount: number;
progressPercent: number;
setWordWrap: (v: boolean) => void;
handleToggleSplitView: (v: boolean) => void;
handleToggleAutoMark: (v: boolean) => void;
handleFixComments: () => void;
handleRequestWalkthrough?: () => void;
requestWalkthroughDisabled?: boolean;
};
function ChangesTopBarLeft({
autoMarkOnScroll,
totalCount,
reviewedCount,
progressPercent,
handleToggleAutoMark,
}: Pick<
ChangesTopBarProps,
"autoMarkOnScroll" | "totalCount" | "reviewedCount" | "progressPercent" | "handleToggleAutoMark"
>) {
return (
<>
{
e.preventDefault();
handleToggleAutoMark(!autoMarkOnScroll);
}}
>
Auto-mark reviewed on scroll
{totalCount > 0 && (
{reviewedCount}/{totalCount} Reviewed
)}
>
);
}
function ReviewWalkthroughRequestButton({
handleRequestWalkthrough,
requestWalkthroughDisabled,
}: Pick) {
if (!handleRequestWalkthrough) return null;
const tooltip = requestWalkthroughDisabled
? "Loading changed files..."
: "Walk me through these changes";
return (
{tooltip}
);
}
function ChangesTopBarRight({
splitView,
wordWrap,
totalCommentCount,
setWordWrap,
handleToggleSplitView,
handleFixComments,
handleRequestWalkthrough,
requestWalkthroughDisabled,
}: Pick<
ChangesTopBarProps,
| "splitView"
| "wordWrap"
| "totalCommentCount"
| "setWordWrap"
| "handleToggleSplitView"
| "handleFixComments"
| "handleRequestWalkthrough"
| "requestWalkthroughDisabled"
>) {
return (
<>
Expand review
Toggle word wrap
{splitView ? "Unified view" : "Split view"}
{totalCommentCount > 0 && (
)}
>
);
}
export function ChangesTopBar({
autoMarkOnScroll,
splitView,
wordWrap,
totalCommentCount,
reviewedCount,
totalCount,
progressPercent,
setWordWrap,
handleToggleSplitView,
handleToggleAutoMark,
handleFixComments,
handleRequestWalkthrough,
requestWalkthroughDisabled,
}: ChangesTopBarProps) {
return (
}
right={
}
/>
);
}