@@ -16,14 +16,14 @@ import {
1616 allowedMergeMethods ,
1717 canPerformPullRequestAction ,
1818 mergeUnavailableReason ,
19- MERGE_CONFLICT_REASON ,
2019 MERGE_METHODS ,
2120 pullRequestActionLabel ,
2221} from "./pullRequestActions" ;
2322import { pullRequestStackMerge , singlePullRequestMergeAllowed } from "./pullRequestStack" ;
2423import { pullRequestTarget , type PullRequestParams } from "./usePullRequestDiff" ;
2524import { usePullRequestPermissions } from "./usePullRequestPermissions" ;
2625import { PullRequestGlyph } from "./pullRequestGlyphs" ;
26+ import type { AppSymbolName } from "../../components/ui/AppSymbol" ;
2727import type { PullRequestStackState } from "./usePullRequestStack" ;
2828
2929export 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 ? (
0 commit comments