"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 { ReviewPRSelector } from "@/components/review/review-pr-selector";
import type { TaskPR } from "@/lib/types/github";
import { PanelHeaderBar, PanelHeaderBarSplit } from "./panel-primitives";
import { useTranslation } from "react-i18next";
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;
prs: TaskPR[];
selectedPR: TaskPR | null;
prDiffLoading: boolean;
onSelectPR: (pr: TaskPR) => void;
};
function ChangesTopBarLeft({
autoMarkOnScroll,
totalCount,
reviewedCount,
progressPercent,
handleToggleAutoMark,
}: Pick<
ChangesTopBarProps,
"autoMarkOnScroll" | "totalCount" | "reviewedCount" | "progressPercent" | "handleToggleAutoMark"
>) {
const { t } = useTranslation();
return (
<>
{
e.preventDefault();
handleToggleAutoMark(!autoMarkOnScroll);
}}
>
{t("task:autoMarkReviewedOnScroll")}
{totalCount > 0 && (
{reviewedCount}/{totalCount} {t("task:reviewed")}
)}
>
);
}
function ReviewWalkthroughRequestButton({
handleRequestWalkthrough,
requestWalkthroughDisabled,
}: Pick) {
const { t } = useTranslation();
if (!handleRequestWalkthrough) return null;
const tooltip = requestWalkthroughDisabled
? t("task:loadingChangedFiles")
: t("task:walkMeThroughTheseChanges");
return (
{tooltip}
);
}
function ChangesTopBarRight({
splitView,
wordWrap,
totalCommentCount,
setWordWrap,
handleToggleSplitView,
handleFixComments,
handleRequestWalkthrough,
requestWalkthroughDisabled,
}: Pick<
ChangesTopBarProps,
| "splitView"
| "wordWrap"
| "totalCommentCount"
| "setWordWrap"
| "handleToggleSplitView"
| "handleFixComments"
| "handleRequestWalkthrough"
| "requestWalkthroughDisabled"
>) {
const { t } = useTranslation();
return (
<>
{t("task:expandReview")}
{t("task:toggleWordWrap")}
{splitView ? t("task:unifiedView") : t("task:splitView")}
{totalCommentCount > 0 && (
)}
>
);
}
export function ChangesTopBar({
autoMarkOnScroll,
splitView,
wordWrap,
totalCommentCount,
reviewedCount,
totalCount,
progressPercent,
setWordWrap,
handleToggleSplitView,
handleToggleAutoMark,
handleFixComments,
handleRequestWalkthrough,
requestWalkthroughDisabled,
prs,
selectedPR,
prDiffLoading,
onSelectPR,
}: ChangesTopBarProps) {
const selector = (
);
if (prs.length > 1 && selectedPR) {
return (
{selector}
);
}
return (
}
right={
}
/>
);
}