Rename Undo button in version pane to Restore (#536)

This commit is contained in:
Will Chen
2025-07-01 11:12:40 -07:00
committed by GitHub
parent 9d11f6c73f
commit eee087fc81
3 changed files with 37 additions and 23 deletions

View File

@@ -11,10 +11,12 @@ const runSwitchVersionTest = async (po: PageObject, nativeGit: boolean) => {
await po.page.getByRole("button", { name: "Version" }).textContent(),
).toBe("Version 2");
await po.page.getByRole("button", { name: "Version" }).click();
await po.page.getByText("Init Dyad app Undo").click();
await po.page.getByText("Init Dyad app Restore").click();
await po.snapshotPreview({ name: `v1` });
await po.page.getByRole("button", { name: "Undo to latest version" }).click();
await po.page
.getByRole("button", { name: "Restore to this version" })
.click();
// Should be same as the previous snapshot, but just to be sure.
await po.snapshotPreview({ name: `v1` });

View File

@@ -34,10 +34,12 @@ const runVersionIntegrityTest = async (po: PageObject, nativeGit: boolean) => {
// Open version pane
await po.page.getByRole("button", { name: "Version 3" }).click();
await po.page.getByText("Init Dyad app Undo").click();
await po.page.getByText("Init Dyad app Restore").click();
await po.snapshotAppFiles({ name: "v1" });
await po.page.getByRole("button", { name: "Undo to latest version" }).click();
await po.page
.getByRole("button", { name: "Restore to this version" })
.click();
// Should be same as the previous snapshot, but just to be sure.
await po.snapshotAppFiles({ name: "v1" });
};

View File

@@ -8,6 +8,11 @@ import { cn } from "@/lib/utils";
import { useEffect, useRef, useState } from "react";
import { useCheckoutVersion } from "@/hooks/useCheckoutVersion";
import { useLoadApp } from "@/hooks/useLoadApp";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
interface VersionPaneProps {
isVisible: boolean;
@@ -153,6 +158,8 @@ export function VersionPane({ isVisible, onClose }: VersionPaneProps) {
</p>
)}
<Tooltip>
<TooltipTrigger asChild>
<button
onClick={async (e) => {
e.stopPropagation();
@@ -167,11 +174,14 @@ export function VersionPane({ isVisible, onClose }: VersionPaneProps) {
"invisible mt-1 flex items-center gap-1 px-2 py-0.5 text-sm font-medium bg-(--primary) text-(--primary-foreground) hover:bg-background-lightest rounded-md transition-colors",
selectedVersionId === version.oid && "visible",
)}
aria-label="Undo to latest version"
aria-label="Restore to this version"
>
<RotateCcw size={12} />
<span>Undo</span>
<span>Restore</span>
</button>
</TooltipTrigger>
<TooltipContent>Restore to this version</TooltipContent>
</Tooltip>
</div>
</div>
))}