Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 115 additions & 63 deletions apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
MessageSquareOffIcon,
PilcrowIcon,
Rows3Icon,
Settings2Icon,
TextWrapIcon,
TriangleAlertIcon,
} from "lucide-react";
Expand Down Expand Up @@ -68,10 +69,12 @@ import { Checkbox } from "../ui/checkbox";
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "../ui/menu";
import { toastManager } from "../ui/toast";
Expand Down Expand Up @@ -1059,8 +1062,13 @@ function PullRequestCodeTab({
}
}, [commit, onSelectedCommitChange, selectedCommit]);
const scopeLabel = selectedCommit ? selectedCommit.messageHeadline : "All commits";
const changeIgnoreWhitespace = (next: boolean) => {
setIgnoreWhitespace(next);
setDraft(null);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
setSelectedLines(null);
};
const toolbar = (
<div className="flex h-10 min-h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 bg-background px-4 text-xs text-muted-foreground">
<div className="@container flex h-10 min-h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 bg-background px-4 text-xs text-muted-foreground">
<div className="flex min-w-0 flex-1 items-center gap-3">
{/* A host that reports no commits has nothing to scope by, and a dropdown whose only
entry is the scope already showing is a control that does nothing. */}
Expand Down Expand Up @@ -1117,7 +1125,7 @@ function PullRequestCodeTab({
) : null}
{/* One count, and the caveats as icons that carry their own words. Spelled out they
competed for a strip this narrow and every one of them truncated to nothing. */}
<PullRequestMetaLine className="shrink-0">
<PullRequestMetaLine>
<span className="shrink-0 tabular-nums">
{files.length} {files.length === 1 ? "file" : "files"}
{nextCursor === null ? "" : "+"}
Expand Down Expand Up @@ -1208,30 +1216,113 @@ function PullRequestCodeTab({
</PullRequestMetaLine>
</div>
<div className="flex shrink-0 items-center gap-1">
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={
ignoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"
<DropdownMenu>
<Tooltip>
<TooltipTrigger
render={
<DropdownMenuTrigger
render={<Button size="icon-sm" variant="ghost" />}
className="@lg:hidden"
aria-label="Diff options"
/>
}
>
<Settings2Icon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">Diff options</TooltipPopup>
</Tooltip>
<DropdownMenuContent align="end">
<DropdownMenuCheckboxItem
checked={ignoreWhitespace}
onCheckedChange={(checked) => changeIgnoreWhitespace(checked)}
>
Hide whitespace changes
</DropdownMenuCheckboxItem>
<DropdownMenuCheckboxItem
checked={wordWrap}
onCheckedChange={(checked) => setWordWrap(checked)}
>
Wrap lines
</DropdownMenuCheckboxItem>
<DropdownMenuSeparator />
<DropdownMenuRadioGroup
value={diffLayout}
onValueChange={(value) => {
if (value === "stacked" || value === "split") {
updateClientSettings({ diffLayout: value });
}
variant="ghost"
size="sm"
pressed={ignoreWhitespace}
onPressedChange={(pressed) => {
setIgnoreWhitespace(Boolean(pressed));
setDraft(null);
setSelectedLines(null);
}}
/>
}
}}
>
<DropdownMenuRadioItem value="stacked" closeOnClick>
Stacked
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="split" closeOnClick>
Split
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
<div className="hidden items-center gap-1 @lg:flex">
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={
ignoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"
}
variant="ghost"
size="sm"
pressed={ignoreWhitespace}
onPressedChange={(pressed) => changeIgnoreWhitespace(Boolean(pressed))}
/>
}
>
<PilcrowIcon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">
{ignoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}
</TooltipPopup>
</Tooltip>
<ToggleGroup
aria-label="Diff layout"
className="shrink-0"
variant="segmented"
value={[diffLayout]}
onValueChange={(value) => {
const next = value[0];
if (next === "stacked" || next === "split") {
updateClientSettings({ diffLayout: next });
}
}}
>
<PilcrowIcon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">
{ignoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}
</TooltipPopup>
</Tooltip>
<Toggle aria-label="Stacked diff view" value="stacked">
<Rows3Icon className="size-3.5" />
</Toggle>
<Toggle aria-label="Split diff view" value="split">
<Columns2Icon className="size-3.5" />
</Toggle>
</ToggleGroup>
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={wordWrap ? "Disable diff line wrapping" : "Enable diff line wrapping"}
variant="ghost"
size="sm"
pressed={wordWrap}
onPressedChange={(pressed) => {
setWordWrap(Boolean(pressed));
}}
/>
}
>
<TextWrapIcon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">
{wordWrap ? "Disable line wrapping" : "Enable line wrapping"}
</TooltipPopup>
</Tooltip>
</div>
{fileKeys.length > 0 ? (
<Tooltip>
<TooltipTrigger
Expand All @@ -1255,45 +1346,6 @@ function PullRequestCodeTab({
</TooltipPopup>
</Tooltip>
) : null}
<ToggleGroup
aria-label="Diff layout"
className="shrink-0"
variant="segmented"
value={[diffLayout]}
onValueChange={(value) => {
const next = value[0];
if (next === "stacked" || next === "split") {
updateClientSettings({ diffLayout: next });
}
}}
>
<Toggle aria-label="Stacked diff view" value="stacked">
<Rows3Icon className="size-3.5" />
</Toggle>
<Toggle aria-label="Split diff view" value="split">
<Columns2Icon className="size-3.5" />
</Toggle>
</ToggleGroup>
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={wordWrap ? "Disable diff line wrapping" : "Enable diff line wrapping"}
variant="ghost"
size="sm"
pressed={wordWrap}
onPressedChange={(pressed) => {
setWordWrap(Boolean(pressed));
}}
/>
}
>
<TextWrapIcon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">
{wordWrap ? "Disable line wrapping" : "Enable line wrapping"}
</TooltipPopup>
</Tooltip>
{fileKeys.length > 0 ? (
<Tooltip>
<TooltipTrigger
Expand Down
Loading