@@ -1152,6 +1152,27 @@ export default function ChecksPanel(): React.JSX.Element {
11521152
11531153 const canCreate = hostedReviewCreation ?. canCreate
11541154 const canPushCreate = hostedReviewCreation ?. blockedReason === 'needs_push'
1155+ const createPrAvailable = Boolean ( canCreate || canPushCreate )
1156+ const createPrDisabledReason =
1157+ hostedReviewCreation === null
1158+ ? 'Checking whether this branch can create a pull request.'
1159+ : hostedReviewCreation . blockedReason === 'dirty'
1160+ ? 'Commit or discard local changes before creating a pull request.'
1161+ : hostedReviewCreation . blockedReason === 'detached_head'
1162+ ? 'Switch to a branch before creating a pull request.'
1163+ : hostedReviewCreation . blockedReason === 'default_branch'
1164+ ? 'Choose a feature branch before creating a pull request.'
1165+ : hostedReviewCreation . blockedReason === 'no_upstream'
1166+ ? 'Publish this branch before creating a pull request.'
1167+ : hostedReviewCreation . blockedReason === 'needs_sync'
1168+ ? 'Sync this branch before creating a pull request.'
1169+ : hostedReviewCreation . blockedReason === 'auth_required'
1170+ ? 'Authenticate with your git provider before creating a pull request.'
1171+ : hostedReviewCreation . blockedReason === 'unsupported_provider'
1172+ ? 'Pull request creation is not supported for this provider yet.'
1173+ : hostedReviewCreation . blockedReason === 'existing_review'
1174+ ? 'A pull request already exists for this branch.'
1175+ : 'Refresh source control status and try again.'
11551176 return (
11561177 < >
11571178 { repo && (
@@ -1197,17 +1218,20 @@ export default function ChecksPanel(): React.JSX.Element {
11971218 </ div >
11981219 { ! operationInProgress && (
11991220 < div className = "mt-3 flex flex-wrap gap-2" >
1200- { ( canCreate || canPushCreate ) && (
1201- < Button
1202- size = "xs"
1203- onClick = { ( ) => {
1204- setCreatePrPushFirst ( canPushCreate )
1205- setCreatePrDialogOpen ( true )
1206- } }
1207- >
1208- { canPushCreate ? 'Push & Create PR' : 'Create PR' }
1209- </ Button >
1210- ) }
1221+ < Button
1222+ size = "xs"
1223+ disabled = { ! createPrAvailable }
1224+ title = { createPrAvailable ? undefined : createPrDisabledReason }
1225+ onClick = { ( ) => {
1226+ if ( ! createPrAvailable ) {
1227+ return
1228+ }
1229+ setCreatePrPushFirst ( canPushCreate )
1230+ setCreatePrDialogOpen ( true )
1231+ } }
1232+ >
1233+ { canPushCreate ? 'Push & Create PR' : 'Create PR' }
1234+ </ Button >
12111235 < Button
12121236 size = "xs"
12131237 variant = "outline"
0 commit comments