Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions apps/web/src/components/pullRequest/PullRequestStackMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export function PullRequestStackMenu({
layer.headSha ? [{ number: layer.number, headSha: layer.headSha }] : [],
);
setPending(true);
setConfirmation(null);
const toastId = toastManager.add({
type: "loading",
title: action === "merge" ? "Merging stack..." : "Rebasing stack...",
});
const result = await runAction({
environmentId,
input: {
Expand All @@ -99,16 +104,15 @@ export function PullRequestStackMenu({
},
});
setPending(false);
setConfirmation(null);
onActed();
if (result._tag === "Failure") {
toastManager.add({
toastManager.update(toastId, {
type: "error",
title: "Stack operation did not complete",
title: action === "merge" ? "Could not merge the stack" : "Could not rebase the stack",
description: String(squashAtomCommandFailure(result)),
});
} else {
toastManager.add({
toastManager.update(toastId, {
type: "success",
title: action === "merge" ? "Stack merge request completed" : "Stack rebased",
description:
Expand Down Expand Up @@ -216,10 +220,10 @@ export function PullRequestStackMenu({
<Dialog
open={confirmation !== null}
onOpenChange={(value) => {
if (!value && !pending) setConfirmation(null);
if (!value) setConfirmation(null);
}}
>
<DialogPopup className="max-w-md" showCloseButton={!pending}>
<DialogPopup className="max-w-md">
<DialogHeader>
<DialogTitle>
{confirmation === "merge"
Expand All @@ -245,11 +249,11 @@ export function PullRequestStackMenu({
</ul>
</DialogPanel>
<DialogFooter>
<Button variant="outline" disabled={pending} onClick={() => setConfirmation(null)}>
<Button variant="outline" onClick={() => setConfirmation(null)}>
Cancel
</Button>
<Button disabled={pending} onClick={() => void run()}>
{pending ? "Working…" : confirmation === "merge" ? "Merge stack" : "Rebase stack"}
<Button onClick={() => void run()}>
{confirmation === "merge" ? "Merge stack" : "Rebase stack"}
</Button>
</DialogFooter>
</DialogPopup>
Expand Down
Loading