| ... | @@ -87,6 +87,11 @@ export function PullRequestStackMenu({ | ... | @@ -87,6 +87,11 @@ export function PullRequestStackMenu({ |
| 87 | layer.headSha ? [{ number: layer.number, headSha: layer.headSha }] : [], | 87 | layer.headSha ? [{ number: layer.number, headSha: layer.headSha }] : [], |
| 88 | ); | 88 | ); |
| 89 | setPending(true); | 89 | setPending(true); |
| | 90 | setConfirmation(null); |
| | 91 | const toastId = toastManager.add({ |
| | 92 | type: "loading", |
| | 93 | title: action === "merge" ? "Merging stack..." : "Rebasing stack...", |
| | 94 | }); |
| 90 | const result = await runAction({ | 95 | const result = await runAction({ |
| 91 | environmentId, | 96 | environmentId, |
| 92 | input: { | 97 | input: { |
| ... | @@ -99,16 +104,15 @@ export function PullRequestStackMenu({ | ... | @@ -99,16 +104,15 @@ export function PullRequestStackMenu({ |
| 99 | }, | 104 | }, |
| 100 | }); | 105 | }); |
| 101 | setPending(false); | 106 | setPending(false); |
| 102 | setConfirmation(null); | | |
| 103 | onActed(); | 107 | onActed(); |
| 104 | if (result._tag === "Failure") { | 108 | if (result._tag === "Failure") { |
| 105 | toastManager.add({ | 109 | toastManager.update(toastId, { |
| 106 | type: "error", | 110 | type: "error", |
| 107 | title: "Stack operation did not complete", | 111 | title: action === "merge" ? "Could not merge the stack" : "Could not rebase the stack", |
| 108 | description: String(squashAtomCommandFailure(result)), | 112 | description: String(squashAtomCommandFailure(result)), |
| 109 | }); | 113 | }); |
| 110 | } else { | 114 | } else { |
| 111 | toastManager.add({ | 115 | toastManager.update(toastId, { |
| 112 | type: "success", | 116 | type: "success", |
| 113 | title: action === "merge" ? "Stack merge request completed" : "Stack rebased", | 117 | title: action === "merge" ? "Stack merge request completed" : "Stack rebased", |
| 114 | description: | 118 | description: |
| ... | @@ -216,10 +220,10 @@ export function PullRequestStackMenu({ | ... | @@ -216,10 +220,10 @@ export function PullRequestStackMenu({ |
| 216 | <Dialog | 220 | <Dialog |
| 217 | open={confirmation !== null} | 221 | open={confirmation !== null} |
| 218 | onOpenChange={(value) => { | 222 | onOpenChange={(value) => { |
| 219 | if (!value && !pending) setConfirmation(null); | 223 | if (!value) setConfirmation(null); |
| 220 | }} | 224 | }} |
| 221 | > | 225 | > |
| 222 | <DialogPopup className="max-w-md" showCloseButton={!pending}> | 226 | <DialogPopup className="max-w-md"> |
| 223 | <DialogHeader> | 227 | <DialogHeader> |
| 224 | <DialogTitle> | 228 | <DialogTitle> |
| 225 | {confirmation === "merge" | 229 | {confirmation === "merge" |
| ... | @@ -245,11 +249,11 @@ export function PullRequestStackMenu({ | ... | @@ -245,11 +249,11 @@ export function PullRequestStackMenu({ |
| 245 | </ul> | 249 | </ul> |
| 246 | </DialogPanel> | 250 | </DialogPanel> |
| 247 | <DialogFooter> | 251 | <DialogFooter> |
| 248 | <Button variant="outline" disabled={pending} onClick={() => setConfirmation(null)}> | 252 | <Button variant="outline" onClick={() => setConfirmation(null)}> |
| 249 | Cancel | 253 | Cancel |
| 250 | </Button> | 254 | </Button> |
| 251 | <Button disabled={pending} onClick={() => void run()}> | 255 | <Button onClick={() => void run()}> |
| 252 | {pending ? "Working…" : confirmation === "merge" ? "Merge stack" : "Rebase stack"} | 256 | {confirmation === "merge" ? "Merge stack" : "Rebase stack"} |
| 253 | </Button> | 257 | </Button> |
| 254 | </DialogFooter> | 258 | </DialogFooter> |
| 255 | </DialogPopup> | 259 | </DialogPopup> |