authorgravatar for Taras.Fomin@gmail.comTaras <Taras.Fomin@gmail.com> 2026-08-18 23:51:47+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-08-18 16:51:47-04:00
log26af903b9bec7f8da56bb5f545d9980d08d418e1
treeee8b76eb7160b5364ede14e8ac30afaad84e830e
parentdb0659fead9b7f29f4668c9ba3eb16702c2cff7f
signature Signed by PGP key B5690EEEBB952194

fix(web): label pull request merge actions (#7381)


1 files changed, 26 insertions(+), 12 deletions(-)

apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx+26-12
......@@ -147,6 +147,12 @@ const ACTION_SUCCESS_LABELS: Record<PullRequestAction, string> = {
147147 "disable-auto-merge": "Auto-merge turned off",
148148};
149149
150const MERGE_METHOD_LABELS: Record<PullRequestMergeMethod, string> = {
151 merge: "Merge",
152 squash: "Squash",
153 rebase: "Rebase",
154};
155
150156/** Said as the thing that did not happen, rather than as the operation that returned an error. */
151157const ACTION_FAILURE_LABELS: Record<PullRequestAction, string> = {
152158 merge: "Could not merge this pull request",
......@@ -460,9 +466,11 @@ export function PullRequestDetailPanel({
460466 if (scroller) scroller.scrollTop = Math.max(0, scroller.scrollTop + delta);
461467 }, [condensed]);
462468 const [mergeMethod, setMergeMethod] = useState<PullRequestMergeMethod>("merge");
463 const [confirmAction, setConfirmAction] = useState<
464 "merge" | "close" | "enable-auto-merge" | null
465 >(null);
469 const [confirmation, setConfirmation] = useState<{
470 readonly open: boolean;
471 readonly action: "merge" | "close" | "enable-auto-merge";
472 }>({ open: false, action: "merge" });
473 const confirmAction = confirmation.action;
466474 // Which handoff is preparing, keyed so a per-finding button can say "Preparing..." on itself
467475 // alone. One at a time whatever the key: they all check the same pull request out.
468476 const [handoff, setHandoff] = useState<string | null>(null);
......@@ -1013,6 +1021,7 @@ export function PullRequestDetailPanel({
10131021 const selectedMergeMethod = allowedMergeMethods.includes(mergeMethod)
10141022 ? mergeMethod
10151023 : (allowedMergeMethods[0] ?? "merge");
1024 const selectedMergeMethodLabel = MERGE_METHOD_LABELS[selectedMergeMethod];
10161025 const conflicting = detail?.state === "open" && detail.mergeability === "conflicting";
10171026 // Only an outright yes arms it. A host that reports nothing has not said the merge is already
10181027 // spoken for, and an off switch for something that may not be on says the wrong thing twice.
......@@ -1297,7 +1306,9 @@ export function PullRequestDetailPanel({
12971306 allowedMergeMethods.length > 0 ? (
12981307 <MenuItem
12991308 disabled={actionPending}
1300 onClick={() => setConfirmAction("enable-auto-merge")}
1309 onClick={() =>
1310 setConfirmation({ open: true, action: "enable-auto-merge" })
1311 }
13011312 >
13021313 <GitMergeIcon className="size-3.5" />
13031314 Enable auto-merge
......@@ -1326,7 +1337,7 @@ export function PullRequestDetailPanel({
13261337 icon and the label need their own row to share a line. */}
13271338 <span className="flex min-w-0 items-center gap-2">
13281339 <GitMergeIcon className="size-3.5" />
1329 <span className="capitalize">{method}</span>
1340 <span>{MERGE_METHOD_LABELS[method]}</span>
13301341 </span>
13311342 </MenuRadioItem>
13321343 ))}
......@@ -1363,7 +1374,7 @@ export function PullRequestDetailPanel({
13631374 <MenuItem
13641375 variant="destructive"
13651376 disabled={actionPending}
1366 onClick={() => setConfirmAction("close")}
1377 onClick={() => setConfirmation({ open: true, action: "close" })}
13671378 >
13681379 <GitPullRequestClosedIcon className="size-3.5" />
13691380 Close pull request
......@@ -1461,9 +1472,9 @@ export function PullRequestDetailPanel({
14611472 <Button
14621473 size="xs"
14631474 disabled={actionPending}
1464 onClick={() => setConfirmAction("merge")}
1475 onClick={() => setConfirmation({ open: true, action: "merge" })}
14651476 >
1466 {pendingAction === "merge" ? "Merging..." : "Merge"}
1477 {pendingAction === "merge" ? "Merging..." : selectedMergeMethodLabel}
14671478 </Button>
14681479 ) : null}
14691480 </>
......@@ -1980,8 +1991,11 @@ export function PullRequestDetailPanel({
19801991 </div>
19811992
19821993 <AlertDialog
1983 open={confirmAction !== null}
1984 onOpenChange={(open) => !open && setConfirmAction(null)}
1994 open={confirmation.open}
1995 onOpenChange={(open) => setConfirmation((current) => ({ ...current, open }))}
1996 onOpenChangeComplete={(open) => {
1997 if (!open) setConfirmation({ open: false, action: "merge" });
1998 }}
19851999 >
19862000 <AlertDialogPopup>
19872001 <AlertDialogHeader>
......@@ -2013,7 +2027,7 @@ export function PullRequestDetailPanel({
20132027 disabled={actionPending}
20142028 onClick={() => {
20152029 const action = confirmAction;
2016 setConfirmAction(null);
2030 setConfirmation((current) => ({ ...current, open: false }));
20172031 if (action === "merge") void perform("merge", selectedMergeMethod);
20182032 if (action === "enable-auto-merge")
20192033 void perform("enable-auto-merge", selectedMergeMethod);
......@@ -2021,7 +2035,7 @@ export function PullRequestDetailPanel({
20212035 }}
20222036 >
20232037 {confirmAction === "merge"
2024 ? "Merge"
2038 ? selectedMergeMethodLabel
20252039 : confirmAction === "enable-auto-merge"
20262040 ? "Enable auto-merge"
20272041 : "Close"}