Skip to content
Open
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
27 changes: 19 additions & 8 deletions apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,18 @@ export function PullRequestDetailPanel({
: allowedMergeMethods.length > 0
? "merge"
: null;
// What the menu's action group holds. Named once so the separators around it are drawn from
// the same answer as its contents, rather than on the assumption that it has any.
const showsDraftToggle =
detail?.state === "open" &&
can(detail.isDraft ? "ready" : "draft") &&
!(detail.isDraft && primaryAction === "ready");
const showsMergeMethods =
detail?.state === "open" &&
can("merge") &&
!detail.isDraft &&
!conflicting &&
allowedMergeMethods.length > 1;
// The pull request number carries this state in the overview and the right-panel tab mirrors
// it. Conflicts keep their own row below: an open pull request remains green there.
const statePresentation = detail
Expand Down Expand Up @@ -669,8 +681,7 @@ export function PullRequestDetailPanel({
{/* Only where the button row could not take it: "Ready for review" on a
draft is the primary header button, so offering it here as well would
show the same action twice. */}
{can(detail.isDraft ? "ready" : "draft") &&
!(detail.isDraft && primaryAction === "ready") ? (
{showsDraftToggle ? (
<MenuItem
disabled={actionPending}
onClick={() => void perform(detail.isDraft ? "ready" : "draft")}
Expand All @@ -688,12 +699,12 @@ export function PullRequestDetailPanel({
Hidden while conflicting: every method would fail. */}
{/* Only where merging is on offer at all: a strategy to merge with is not
a choice for someone who may not merge. */}
{can("merge") &&
!detail.isDraft &&
!conflicting &&
allowedMergeMethods.length > 1 ? (
{showsMergeMethods ? (
<>
<MenuSeparator />
{/* Only below the draft control. A host with no draft of its own, or
a draft whose control is already the header button, would leave
this against the separator that opened the group. */}
{showsDraftToggle ? <MenuSeparator /> : null}
<MenuRadioGroup
value={selectedMergeMethod}
onValueChange={(method) =>
Expand All @@ -713,7 +724,7 @@ export function PullRequestDetailPanel({
</MenuRadioGroup>
</>
) : null}
<MenuSeparator />
{showsDraftToggle || showsMergeMethods ? <MenuSeparator /> : null}
</>
) : null}
<MenuItem onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}>
Expand Down
Loading