Skip to content

Commit 5423ba0

Browse files
Bil0000maria-rcks
andauthored
feat(web): merge the comment and review buttons into one composer (pingdotgg#12945)
Co-authored-by: maria-rcks <[email protected]>
1 parent 9a609a4 commit 5423ba0

7 files changed

Lines changed: 413 additions & 301 deletions

File tree

‎apps/web/src/components/pullRequest/PullRequestCodeTab.tsx‎

Lines changed: 6 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ import {
1818
Columns2Icon,
1919
FolderTreeIcon,
2020
InfoIcon,
21-
MessageSquareIcon,
2221
MessageSquareOffIcon,
2322
PilcrowIcon,
2423
Rows3Icon,
2524
TextWrapIcon,
2625
TriangleAlertIcon,
27-
XIcon,
2826
} from "lucide-react";
2927
import { useAtomRefresh } from "@effect/atom-react";
3028
import * as Schema from "effect/Schema";
@@ -78,7 +76,6 @@ import { toastManager } from "../ui/toast";
7876
import { Toggle, ToggleGroup } from "../ui/toggle-group";
7977
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
8078
import { PendingReviewCommentCard, ReviewThreadCard } from "./PullRequestReviewAnnotation";
81-
import { PullRequestReviewBar } from "./PullRequestReviewBar";
8279
import {
8380
isFileDiffCollapsed,
8481
isLineInFileDiff,
@@ -247,9 +244,6 @@ function PullRequestCodeTab({
247244
const [draft, setDraft] = useState<DraftAnchor | null>(null);
248245
const [threadPending, setThreadPending] = useState(false);
249246
const [orphansOpen, setOrphansOpen] = useState(false);
250-
// Closed by default so the review form does not permanently eat vertical space below the
251-
// diff; opened on demand as a floating overlay instead.
252-
const [reviewOpen, setReviewOpen] = useState(false);
253247
// Which pull request the slices belong to travels with them, so a render taken before the
254248
// reset below cannot read the previous one's slices — or send its cursor to the host.
255249
const [sliceState, setSliceState] = useState<{
@@ -378,7 +372,6 @@ function PullRequestCodeTab({
378372
inlineComment: hostReview.inlineComment && viewer.comment,
379373
reply: hostReview.reply && viewer.comment,
380374
resolve: hostReview.resolve && viewer.resolve,
381-
verdicts: hostReview.verdicts.filter((verdict) => viewer.verdicts.includes(verdict)),
382375
};
383376
}, [detail.capabilities.review, detail.viewerPermissions]);
384377
// A comment is posted against the pull request's head diff, so a line number taken from one
@@ -1054,70 +1047,6 @@ function PullRequestCodeTab({
10541047
],
10551048
);
10561049

1057-
/**
1058-
* The review overlay belongs to the pull request, not to the patch: a change whose diff
1059-
* cannot be structured — or read at all — is still one a reviewer can approve or reject, so
1060-
* it survives every branch below. It floats over the scroll area rather than sitting in the
1061-
* layout flow, so the diff keeps the full height instead of permanently losing a strip to a
1062-
* footer most reviews never touch. Hidden entirely where the host offers no verdicts, same as
1063-
* the bar it wraps did.
1064-
*/
1065-
const reviewOverlay =
1066-
review.verdicts.length === 0 ? null : (
1067-
<div className="pointer-events-none absolute inset-x-0 bottom-0 z-10">
1068-
{reviewOpen ? (
1069-
<div
1070-
className={cn(
1071-
"surface-glass pointer-events-auto absolute inset-x-3 rounded-xl border border-border/60 shadow-lg",
1072-
detail.capabilities.comment && detail.viewerPermissions.comment
1073-
? "bottom-16"
1074-
: "bottom-3",
1075-
)}
1076-
>
1077-
<Button
1078-
type="button"
1079-
size="icon-sm"
1080-
variant="ghost"
1081-
aria-label="Close review"
1082-
className="absolute right-2 top-2"
1083-
onClick={() => setReviewOpen(false)}
1084-
>
1085-
<XIcon className="size-3.5" />
1086-
</Button>
1087-
<PullRequestReviewBar
1088-
environmentId={environmentId}
1089-
reference={reference}
1090-
verdicts={review.verdicts}
1091-
requestChangesSummaryRequired={detail.provider === "forgejo"}
1092-
onSubmitted={() => {
1093-
onRefresh();
1094-
setReviewOpen(false);
1095-
}}
1096-
/>
1097-
</div>
1098-
) : (
1099-
<Button
1100-
className={cn(
1101-
"pointer-events-auto absolute bottom-3 rounded-full shadow-lg",
1102-
detail.capabilities.comment && detail.viewerPermissions.comment
1103-
? "right-16"
1104-
: "right-4",
1105-
)}
1106-
onClick={() => setReviewOpen(true)}
1107-
size="compact"
1108-
variant="glass"
1109-
>
1110-
<MessageSquareIcon className="size-3.5" />
1111-
Review
1112-
{pendingComments.length > 0 ? (
1113-
<span className="flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground">
1114-
{pendingComments.length}
1115-
</span>
1116-
) : null}
1117-
</Button>
1118-
)}
1119-
</div>
1120-
);
11211050
// A rebase or a force-push can take the scoped commit out of the change. Its diff may still
11221051
// be reachable on the host, but it is no longer part of what is being reviewed, so the scope
11231052
// goes back to the whole change rather than sitting under a name nothing matches.
@@ -1392,29 +1321,23 @@ function PullRequestCodeTab({
13921321
);
13931322
// The toolbar rides above every branch below, not just the one with a patch in it: a commit
13941323
// whose diff is empty or unreadable still needs the scope dropdown that got the reader there.
1395-
const withReviewBar = (body: ReactNode) => (
1324+
const withToolbar = (body: ReactNode) => (
13961325
<div className="flex h-full min-h-0 flex-col">
13971326
{toolbar}
1398-
{/* The overlay is anchored to this wrapper, not the scroller: absolute positioning
1399-
inside an overflowing element tracks the content's bottom edge, which would carry
1400-
the trigger away with the first scroll. */}
1401-
<div className="relative min-h-0 flex-1">
1402-
<div className="h-full overflow-auto">{body}</div>
1403-
{reviewOverlay}
1404-
</div>
1327+
<div className="min-h-0 flex-1 overflow-auto">{body}</div>
14051328
</div>
14061329
);
14071330

14081331
// Under the toolbar rather than in place of it, so choosing a commit does not take the
14091332
// dropdown that was just used off the screen while its diff loads.
14101333
if (diffQuery.isPending && loadedSlices.length === 0) {
1411-
return withReviewBar(<DiffPanelLoadingState label="Loading pull request diff..." />);
1334+
return withToolbar(<DiffPanelLoadingState label="Loading pull request diff..." />);
14121335
}
14131336

14141337
// A slice that fails once there are files on screen is reported at the end of them instead:
14151338
// the diff already read is worth more than the error that stopped it growing.
14161339
if (diffQuery.error && loadedSlices.length === 0) {
1417-
return withReviewBar(
1340+
return withToolbar(
14181341
<p className="px-4 py-5 text-sm text-muted-foreground">{diffQuery.error}</p>,
14191342
);
14201343
}
@@ -1428,7 +1351,7 @@ function PullRequestCodeTab({
14281351
? parsedSlices.flatMap((parsed) => (parsed?.kind === "raw" ? [parsed] : []))
14291352
: [];
14301353
if (files.length === 0 && rawSlices.length > 0) {
1431-
return withReviewBar(
1354+
return withToolbar(
14321355
<div className="space-y-4 px-4 py-5">
14331356
{rawSlices.map((slice) => (
14341357
<div key={`${slice.reason}:${slice.text.slice(0, 64)}`} className="space-y-2">
@@ -1441,7 +1364,7 @@ function PullRequestCodeTab({
14411364
}
14421365

14431366
if (items.length === 0 && nextCursor === null) {
1444-
return withReviewBar(
1367+
return withToolbar(
14451368
<p className="px-4 py-5 text-sm text-muted-foreground">
14461369
{commit === null
14471370
? "This pull request has no file changes."
@@ -1595,7 +1518,6 @@ function PullRequestCodeTab({
15951518
renderAnnotation={renderAnnotation}
15961519
unsafeCSSExtra={REPLACE_FILE_COUNTS_CSS}
15971520
/>
1598-
{reviewOverlay}
15991521
</div>
16001522
{fileTreeOpen ? (
16011523
<aside className="flex w-[min(20rem,40%)] min-w-48 shrink-0 border-l border-border/60">

‎apps/web/src/components/pullRequest/PullRequestCommentComposer.tsx‎

Lines changed: 0 additions & 171 deletions
This file was deleted.

0 commit comments

Comments
 (0)