Skip to content
Open
Show file tree
Hide file tree
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
46 changes: 23 additions & 23 deletions apps/web/src/components/settings/UpdateTrackSwitchDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ import {
nothingToMove,
prepareLocalTrackSwitch,
} from "./updateTrackSwitch.logic";
import {
AlertDialog,
AlertDialogClose,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogPopup,
AlertDialogTitle,
} from "../ui/alert-dialog";
import { Button } from "../ui/button";
import {
Dialog,
DialogClose,
DialogDescription,
DialogFooter,
DialogHeader,
DialogPopup,
DialogTitle,
} from "../ui/dialog";
import { stackedThreadToast, toastManager } from "../ui/toast";

/** Moves this app and every connected machine to `channel`. */
Expand All @@ -56,15 +56,15 @@ export function UpdateTrackSwitchDialog({
}
const label = channelSwitchLabel(channel, m);
return (
<AlertDialog open onOpenChange={(open) => !open && onClose()}>
<AlertDialogPopup>
<AlertDialogHeader>
<AlertDialogTitle>
<Dialog open onOpenChange={(open) => !open && onClose()}>
<DialogPopup role="alertdialog" showCloseButton={false}>
<DialogHeader>
<DialogTitle>
<T>
Switch to <Var>{label}</Var>
</T>
</AlertDialogTitle>
<AlertDialogDescription>
</DialogTitle>
<DialogDescription className="wrap-anywhere">
{AsyncResult.isFailure(release)
? npmReleaseFailureMessage(release.cause, m)
: AsyncResult.isSuccess(release)
Expand All @@ -75,15 +75,15 @@ export function UpdateTrackSwitchDialog({
},
)
: gt("Checking releases…")}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogClose render={<Button variant="outline" />}>
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose render={<Button variant="outline" />}>
<T>Cancel</T>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogPopup>
</AlertDialog>
</DialogClose>
</DialogFooter>
</DialogPopup>
</Dialog>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,17 @@ describe("SidebarUpdatePill release notes", () => {
});

describe("SidebarUpdatePill update everything", () => {
it("does not refocus the update button after a pointer cancel", async () => {
it.each([
["Cancel", () => userEvent.click(page.getByRole("button", { name: "Cancel" }))],
["an outside press", () => userEvent.click(document.body, { position: { x: 1, y: 1 } })],
])("closes without refocusing the update button after %s", async (_closer, close) => {
setup(null, { hasUpdates: true });
await using screen = await render(<SidebarUpdatePill />);
const button = screen.getByRole("button", { name: "Update everything" });
await userEvent.click(button);
const cancel = page.getByRole("button", { name: "Cancel" });
await expect.element(cancel).toBeVisible();
await expect.element(page.getByRole("alertdialog")).toBeVisible();

await userEvent.click(cancel);
await close();
await vi.waitFor(() => expect(document.querySelector('[role="alertdialog"]')).toBeNull());
expect(document.activeElement).not.toBe(button.element());
});
Expand Down
48 changes: 25 additions & 23 deletions apps/web/src/components/sidebar/UpdateEverythingDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { msg, T, useGT, useMessages } from "gt-react";
import { Fragment, type RefObject, useRef } from "react";

import { environmentThreadShells } from "~/state/threads";
import {
AlertDialog,
AlertDialogClose,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogPopup,
AlertDialogTitle,
} from "../ui/alert-dialog";
import { Button } from "../ui/button";
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
import {
Dialog,
DialogClose,
DialogDescription,
DialogFooter,
DialogHeader,
DialogPopup,
DialogTitle,
} from "../ui/dialog";
import { MiddleTruncate } from "../ui/middle-truncate";
import { ScrollArea } from "../ui/scroll-area";
import type { RestartingMachine, UpdateEverythingRow } from "./updateEverything.logic";
Expand Down Expand Up @@ -74,16 +74,18 @@ export function UpdateEverythingDialog({
}: UpdateEverythingDialogProps) {
const cancelRef = useRef<HTMLButtonElement>(null);
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
<Dialog open={open} onOpenChange={onOpenChange}>
{/* Refocusing the trigger after a pointer close shows its focus ring and opens its tooltip. */}
<AlertDialogPopup
<DialogPopup
className="sm:max-w-xl"
role="alertdialog"
showCloseButton={false}
initialFocus={cancelRef}
finalFocus={(closeType) => closeType === "keyboard"}
>
<UpdateEverythingDialogContent {...content} cancelRef={cancelRef} />
</AlertDialogPopup>
</AlertDialog>
</DialogPopup>
</Dialog>
);
}

Expand Down Expand Up @@ -132,14 +134,14 @@ function UpdateEverythingDialogContent({

return (
<>
<AlertDialogHeader className="shrink-0">
<AlertDialogTitle>
<DialogHeader className="shrink-0">
<DialogTitle>
{title ??
gt("{count, plural, one {Update {count} machine?} other {Update {count} machines?}}", {
count: updating.length,
})}
</AlertDialogTitle>
<AlertDialogDescription>
</DialogTitle>
<DialogDescription>
{version !== null ? (
<>
T3 Code <span className="font-mono text-xs">{version}</span>
Expand All @@ -155,8 +157,8 @@ function UpdateEverythingDialogContent({
{checking
? `${version !== null || providerCount > 0 ? " · " : ""}${gt("Checking for more…")}`
: null}
</AlertDialogDescription>
</AlertDialogHeader>
</DialogDescription>
</DialogHeader>
<ScrollArea scrollFade>
<div className="flex flex-col gap-3 px-6 pb-4">
{notes.map((note) => (
Expand Down Expand Up @@ -245,7 +247,7 @@ function UpdateEverythingDialogContent({
) : null}
</div>
</ScrollArea>
<AlertDialogFooter>
<DialogFooter>
{disabledReason !== null ? (
<p className="self-center text-sm max-sm:order-1 max-sm:text-center sm:mr-auto">
{disabledReason}
Expand All @@ -271,13 +273,13 @@ function UpdateEverythingDialogContent({
)}`}
</p>
) : null}
<AlertDialogClose ref={cancelRef} render={<Button variant="outline" disabled={busy} />}>
<DialogClose ref={cancelRef} render={<Button variant="outline" disabled={busy} />}>
<T>Cancel</T>
</AlertDialogClose>
</DialogClose>
<Button disabled={disabledReason !== null || busy} onClick={onConfirm}>
{confirmLabel ?? gt("Update", { $context: "verb, confirms the update" })}
</Button>
</AlertDialogFooter>
</DialogFooter>
</>
);
}
Expand Down
Loading