Skip to content

Commit 5ef4988

Browse files
committed
fix(web): include auto-merge in action divider
1 parent 49d7144 commit 5ef4988

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import {
103103
handoffPrompt,
104104
handoffReviewComments,
105105
pullRequestActionNeedsHostRefresh,
106+
pullRequestActionMenuHasGroup,
106107
pullRequestFindingKey,
107108
pullRequestHandoffLabels,
108109
readableFailure,
@@ -1039,6 +1040,14 @@ export function PullRequestDetailPanel({
10391040
detail?.state === "open" &&
10401041
can(detail.isDraft ? "ready" : "draft") &&
10411042
!(detail.isDraft && primaryAction === "ready");
1043+
const showsAutoMerge =
1044+
detail?.state === "open" &&
1045+
((autoMergeArmed && can("disable-auto-merge")) ||
1046+
(!autoMergeArmed &&
1047+
!detail.isDraft &&
1048+
!conflicting &&
1049+
can("enable-auto-merge") &&
1050+
allowedMergeMethods.length > 0));
10421051
const showsMergeMethods =
10431052
detail?.state === "open" &&
10441053
can("merge") &&
@@ -1266,7 +1275,13 @@ export function PullRequestDetailPanel({
12661275
</MenuRadioGroup>
12671276
</>
12681277
) : null}
1269-
{showsDraftToggle || showsMergeMethods ? <MenuSeparator /> : null}
1278+
{pullRequestActionMenuHasGroup(
1279+
showsDraftToggle,
1280+
showsAutoMerge,
1281+
showsMergeMethods,
1282+
) ? (
1283+
<MenuSeparator />
1284+
) : null}
12701285
</>
12711286
) : null}
12721287
<MenuItem onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}>

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
isThreadOwnPullRequest,
2020
orderPullRequestComments,
2121
pullRequestActionNeedsHostRefresh,
22+
pullRequestActionMenuHasGroup,
2223
pullRequestFindingKey,
2324
pullRequestHandoffLabels,
2425
readableFailure,
@@ -53,6 +54,12 @@ const TIMELINE_SOURCE: Pick<
5354
closedAt: null,
5455
};
5556

57+
describe("pull request action menu", () => {
58+
it("keeps the group divider when auto-merge is the only action", () => {
59+
expect(pullRequestActionMenuHasGroup(false, true, false)).toBe(true);
60+
});
61+
});
62+
5663
describe("pull request state description", () => {
5764
it("keeps draft and conflicts orthogonal to the terminal states", () => {
5865
expect(describePullRequestState("open", true)).toBe("Draft");

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ export function pullRequestHandoffLabels(inThisThread: boolean) {
5757
};
5858
}
5959

60+
/** Whether the open pull-request action group contains at least one action. */
61+
export function pullRequestActionMenuHasGroup(
62+
showsDraftToggle: boolean,
63+
showsAutoMerge: boolean,
64+
showsMergeMethods: boolean,
65+
): boolean {
66+
return showsDraftToggle || showsAutoMerge || showsMergeMethods;
67+
}
68+
6069
/** Plain-language state, shown beside the author. Conflicts are a merge signal, not a state. */
6170
export function describePullRequestState(state: PullRequestState, isDraft: boolean): string {
6271
if (state === "merged") return "Merged";

0 commit comments

Comments
 (0)