Skip to content

Commit b8e843c

Browse files
fix(mobile): merge button names merged, closed, draft, and conflict states
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8657eec commit b8e843c

2 files changed

Lines changed: 47 additions & 36 deletions

File tree

‎apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx‎

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ import {
1616
allowedMergeMethods,
1717
canPerformPullRequestAction,
1818
mergeUnavailableReason,
19-
MERGE_CONFLICT_REASON,
2019
MERGE_METHODS,
2120
pullRequestActionLabel,
2221
} from "./pullRequestActions";
2322
import { pullRequestStackMerge, singlePullRequestMergeAllowed } from "./pullRequestStack";
2423
import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";
2524
import { usePullRequestPermissions } from "./usePullRequestPermissions";
2625
import { PullRequestGlyph } from "./pullRequestGlyphs";
26+
import type { AppSymbolName } from "../../components/ui/AppSymbol";
2727
import type { PullRequestStackState } from "./usePullRequestStack";
2828

2929
export function PullRequestMergeControls(props: {
@@ -82,8 +82,24 @@ export function PullRequestMergeControls(props: {
8282
? `${MERGE_METHODS[method].title} stack (${scope.layers.length})`
8383
: MERGE_METHODS[method].title
8484
: "Merge unavailable";
85-
const autoMergeArmed = pr.state === "open" && pr.autoMergeEnabled === true;
86-
const armedLabel = `Auto-merge pending${pr.autoMergeMethod ? ` (${pr.autoMergeMethod})` : ""}`;
85+
// States the button itself names, instead of a reason line under it.
86+
const status: { label: string; icon: AppSymbolName; final?: boolean } | null =
87+
pr.state === "merged"
88+
? { label: "Merged", icon: PullRequestGlyph.merged, final: true }
89+
: pr.state === "closed"
90+
? { label: "Closed", icon: PullRequestGlyph.closed, final: true }
91+
: pr.isDraft
92+
? { label: "Draft", icon: PullRequestGlyph.draft }
93+
: pr.mergeability === "conflicting"
94+
? { label: "Resolve conflicts to merge", icon: PullRequestGlyph.conflicting }
95+
: pr.autoMergeEnabled
96+
? {
97+
label: `Auto-merge pending${pr.autoMergeMethod ? ` (${pr.autoMergeMethod})` : ""}`,
98+
icon: "clock",
99+
}
100+
: checkingStack && !busy
101+
? { label: "Checking stack…", icon: PullRequestGlyph.merged }
102+
: null;
87103
const autoAction = pr.autoMergeEnabled ? "disable-auto-merge" : "enable-auto-merge";
88104
const canAutoMerge =
89105
!busy &&
@@ -174,39 +190,41 @@ export function PullRequestMergeControls(props: {
174190
? "Working…"
175191
: !permissions.connected
176192
? "Reconnect to merge"
177-
: autoMergeArmed
178-
? armedLabel
179-
: label
193+
: (status?.label ?? label)
180194
}
181195
accessibilityLabel={
182-
autoMergeArmed
183-
? `${armedLabel}, merges once its requirements are met`
196+
status
197+
? status.label
184198
: scope
185199
? `${label}, ${scope.layers.length} stack layers through #${pr.number}`
186200
: label
187201
}
188-
icon={autoMergeArmed ? "clock" : PullRequestGlyph.merged}
189-
disabled={!canMerge || autoMergeArmed}
190-
loading={busy || (!autoMergeArmed && checkingStack)}
202+
icon={status?.icon ?? PullRequestGlyph.merged}
203+
disabled={!canMerge || status !== null}
204+
loading={busy || checkingStack}
191205
onPress={() => confirm("merge")}
192206
menuTitle="Merge options"
193-
actions={[
194-
...methods.map((id) => ({
195-
id,
196-
title: MERGE_METHODS[id].title,
197-
state: id === method ? ("on" as const) : ("off" as const),
198-
attributes: { disabled: !canMerge && !canAutoMerge },
199-
})),
200-
...(canAutoMerge
201-
? [
202-
{
203-
id: autoAction,
204-
title: pr.autoMergeEnabled ? "Disable auto-merge" : "Enable auto-merge",
205-
image: "clock",
206-
},
207+
actions={
208+
status?.final
209+
? []
210+
: [
211+
...methods.map((id) => ({
212+
id,
213+
title: MERGE_METHODS[id].title,
214+
state: id === method ? ("on" as const) : ("off" as const),
215+
attributes: { disabled: !canMerge && !canAutoMerge },
216+
})),
217+
...(canAutoMerge
218+
? [
219+
{
220+
id: autoAction,
221+
title: pr.autoMergeEnabled ? "Disable auto-merge" : "Enable auto-merge",
222+
image: "clock",
223+
},
224+
]
225+
: []),
207226
]
208-
: []),
209-
]}
227+
}
210228
onPressAction={(id) => {
211229
const selected = methods.find((method) => method === id);
212230
if (selected) {
@@ -215,12 +233,7 @@ export function PullRequestMergeControls(props: {
215233
} else if (id === autoAction && canAutoMerge) confirm(autoAction);
216234
}}
217235
/>
218-
{permissions.connected &&
219-
!autoMergeArmed &&
220-
reason &&
221-
reason !== MERGE_CONFLICT_REASON &&
222-
reason !== "Checking stack membership…" &&
223-
!(checkingStack && reason === "Refresh the stack before merging.") ? (
236+
{permissions.connected && !status && reason ? (
224237
<Text className="px-1 text-xs text-foreground-muted">{reason}</Text>
225238
) : null}
226239
{stack.error && stack.supportsStackActions ? (

‎apps/mobile/src/features/pull-requests/pullRequestActions.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ export function canPerformPullRequestAction(pr: ActionDetail, action: PullReques
117117
}
118118
}
119119

120-
export const MERGE_CONFLICT_REASON = "Resolve the branch conflicts before merging.";
121-
122120
export function mergeUnavailableReason(
123121
pr: ActionDetail,
124122
connectionAllowsWrites: boolean,
@@ -132,7 +130,7 @@ export function mergeUnavailableReason(
132130
if (!pr.viewerPermissions.actions.includes("merge"))
133131
return `Your account cannot merge this ${terminology.singular}.`;
134132
if (pr.isDraft) return "Mark this draft ready for review before merging.";
135-
if (pr.mergeability === "conflicting") return MERGE_CONFLICT_REASON;
133+
if (pr.mergeability === "conflicting") return "Resolve the branch conflicts before merging.";
136134
if (!allowedMergeMethods(pr).length) return "This repository has no available merge methods.";
137135
return null;
138136
}

0 commit comments

Comments
 (0)