Unverified 提交 eee087fc authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

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

上级 9d11f6c7
......@@ -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` });
......
......@@ -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" });
};
......
......@@ -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,25 +158,30 @@ export function VersionPane({ isVisible, onClose }: VersionPaneProps) {
</p>
)}
<button
onClick={async (e) => {
e.stopPropagation();
setSelectedVersionId(null);
await revertVersion({
versionId: version.oid,
});
// Close the pane after revert to force a refresh on next open
onClose();
}}
className={cn(
"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"
>
<RotateCcw size={12} />
<span>Undo</span>
</button>
<Tooltip>
<TooltipTrigger asChild>
<button
onClick={async (e) => {
e.stopPropagation();
setSelectedVersionId(null);
await revertVersion({
versionId: version.oid,
});
// Close the pane after revert to force a refresh on next open
onClose();
}}
className={cn(
"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="Restore to this version"
>
<RotateCcw size={12} />
<span>Restore</span>
</button>
</TooltipTrigger>
<TooltipContent>Restore to this version</TooltipContent>
</Tooltip>
</div>
</div>
))}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论