| ... | @@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from "react"; | ... | @@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from "react"; |
| 4 | import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react"; | 4 | import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react"; |
| 5 | import { GitHubIcon } from "./Icons"; | 5 | import { GitHubIcon } from "./Icons"; |
| 6 | import { | 6 | import { |
| | 7 | buildGitActionProgressStages, |
| 7 | buildMenuItems, | 8 | buildMenuItems, |
| 8 | type GitActionIconName, | 9 | type GitActionIconName, |
| 9 | type GitActionMenuItem, | 10 | type GitActionMenuItem, |
| ... | @@ -134,26 +135,6 @@ function GitQuickActionIcon({ quickAction }: { quickAction: GitQuickAction }) { | ... | @@ -134,26 +135,6 @@ function GitQuickActionIcon({ quickAction }: { quickAction: GitQuickAction }) { |
| 134 | return <InfoIcon className={iconClassName} />; | 135 | return <InfoIcon className={iconClassName} />; |
| 135 | } | 136 | } |
| 136 | | 137 | |
| 137 | function buildGitActionProgressStages(input: { | | |
| 138 | action: GitStackedAction; | | |
| 139 | hasCustomCommitMessage: boolean; | | |
| 140 | hasWorkingTreeChanges: boolean; | | |
| 141 | }): string[] { | | |
| 142 | const shouldIncludeCommitStages = input.action === "commit" || input.hasWorkingTreeChanges; | | |
| 143 | const commitStages = !shouldIncludeCommitStages | | |
| 144 | ? [] | | |
| 145 | : input.hasCustomCommitMessage | | |
| 146 | ? ["Committing..."] | | |
| 147 | : ["Generating commit message...", "Committing..."]; | | |
| 148 | if (input.action === "commit") { | | |
| 149 | return commitStages; | | |
| 150 | } | | |
| 151 | if (input.action === "commit_push") { | | |
| 152 | return [...commitStages, "Pushing..."]; | | |
| 153 | } | | |
| 154 | return [...commitStages, "Pushing...", "Creating PR..."]; | | |
| 155 | } | | |
| 156 | | | |
| 157 | export default function GitActionsControl({ api, gitCwd }: GitActionsControlProps) { | 138 | export default function GitActionsControl({ api, gitCwd }: GitActionsControlProps) { |
| 158 | const queryClient = useQueryClient(); | 139 | const queryClient = useQueryClient(); |
| 159 | const [activeDialogAction, setActiveDialogAction] = useState<GitDialogAction | null>(null); | 140 | const [activeDialogAction, setActiveDialogAction] = useState<GitDialogAction | null>(null); |
| ... | @@ -230,7 +211,15 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp | ... | @@ -230,7 +211,15 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 230 | }, [api, gitStatus?.openPr?.url]); | 211 | }, [api, gitStatus?.openPr?.url]); |
| 231 | | 212 | |
| 232 | const runGitActionWithToast = useCallback( | 213 | const runGitActionWithToast = useCallback( |
| 233 | async ({ action, commitMessage }: { action: GitStackedAction; commitMessage?: string }) => { | 214 | async ({ |
| | 215 | action, |
| | 216 | commitMessage, |
| | 217 | forcePushOnlyProgress = false, |
| | 218 | }: { |
| | 219 | action: GitStackedAction; |
| | 220 | commitMessage?: string; |
| | 221 | forcePushOnlyProgress?: boolean; |
| | 222 | }) => { |
| 234 | const confirmed = await maybeConfirmPushToDefaultBranch(action); | 223 | const confirmed = await maybeConfirmPushToDefaultBranch(action); |
| 235 | if (!confirmed) return; | 224 | if (!confirmed) return; |
| 236 | | 225 | |
| ... | @@ -238,6 +227,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp | ... | @@ -238,6 +227,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 238 | action, | 227 | action, |
| 239 | hasCustomCommitMessage: !!commitMessage?.trim(), | 228 | hasCustomCommitMessage: !!commitMessage?.trim(), |
| 240 | hasWorkingTreeChanges: !!gitStatus?.hasWorkingTreeChanges, | 229 | hasWorkingTreeChanges: !!gitStatus?.hasWorkingTreeChanges, |
| | 230 | forcePushOnly: forcePushOnlyProgress, |
| 241 | }); | 231 | }); |
| 242 | const progressToastId = toastManager.add({ | 232 | const progressToastId = toastManager.add({ |
| 243 | type: "loading", | 233 | type: "loading", |
| ... | @@ -290,7 +280,10 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp | ... | @@ -290,7 +280,10 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 290 | children: "Push", | 280 | children: "Push", |
| 291 | onClick: () => { | 281 | onClick: () => { |
| 292 | closeResultToast(); | 282 | closeResultToast(); |
| 293 | void runGitActionWithToast({ action: "commit_push" }); | 283 | void runGitActionWithToast({ |
| | 284 | action: "commit_push", |
| | 285 | forcePushOnlyProgress: true, |
| | 286 | }); |
| 294 | }, | 287 | }, |
| 295 | }, | 288 | }, |
| 296 | } | 289 | } |
| ... | @@ -381,7 +374,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp | ... | @@ -381,7 +374,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 381 | return; | 374 | return; |
| 382 | } | 375 | } |
| 383 | if (item.dialogAction === "push") { | 376 | if (item.dialogAction === "push") { |
| 384 | void runGitActionWithToast({ action: "commit_push" }); | 377 | void runGitActionWithToast({ action: "commit_push", forcePushOnlyProgress: true }); |
| 385 | return; | 378 | return; |
| 386 | } | 379 | } |
| 387 | if (item.dialogAction) { | 380 | if (item.dialogAction) { |
| ... | @@ -400,10 +393,12 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp | ... | @@ -400,10 +393,12 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 400 | ? "commit_push" | 393 | ? "commit_push" |
| 401 | : "commit_push_pr"; | 394 | : "commit_push_pr"; |
| 402 | const commitMessage = activeDialogAction === "commit" ? dialogCommitMessage.trim() : ""; | 395 | const commitMessage = activeDialogAction === "commit" ? dialogCommitMessage.trim() : ""; |
| | 396 | const forcePushOnlyProgress = activeDialogAction === "push"; |
| 403 | setActiveDialogAction(null); | 397 | setActiveDialogAction(null); |
| 404 | void runGitActionWithToast({ | 398 | void runGitActionWithToast({ |
| 405 | action, | 399 | action, |
| 406 | ...(commitMessage ? { commitMessage } : {}), | 400 | ...(commitMessage ? { commitMessage } : {}), |
| | 401 | ...(forcePushOnlyProgress ? { forcePushOnlyProgress } : {}), |
| 407 | }); | 402 | }); |
| 408 | }, [activeDialogAction, dialogCommitMessage, runGitActionWithToast]); | 403 | }, [activeDialogAction, dialogCommitMessage, runGitActionWithToast]); |
| 409 | | 404 | |