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) => { ...@@ -11,10 +11,12 @@ const runSwitchVersionTest = async (po: PageObject, nativeGit: boolean) => {
await po.page.getByRole("button", { name: "Version" }).textContent(), await po.page.getByRole("button", { name: "Version" }).textContent(),
).toBe("Version 2"); ).toBe("Version 2");
await po.page.getByRole("button", { name: "Version" }).click(); 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.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. // Should be same as the previous snapshot, but just to be sure.
await po.snapshotPreview({ name: `v1` }); await po.snapshotPreview({ name: `v1` });
......
...@@ -34,10 +34,12 @@ const runVersionIntegrityTest = async (po: PageObject, nativeGit: boolean) => { ...@@ -34,10 +34,12 @@ const runVersionIntegrityTest = async (po: PageObject, nativeGit: boolean) => {
// Open version pane // Open version pane
await po.page.getByRole("button", { name: "Version 3" }).click(); 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.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. // Should be same as the previous snapshot, but just to be sure.
await po.snapshotAppFiles({ name: "v1" }); await po.snapshotAppFiles({ name: "v1" });
}; };
......
...@@ -8,6 +8,11 @@ import { cn } from "@/lib/utils"; ...@@ -8,6 +8,11 @@ import { cn } from "@/lib/utils";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { useCheckoutVersion } from "@/hooks/useCheckoutVersion"; import { useCheckoutVersion } from "@/hooks/useCheckoutVersion";
import { useLoadApp } from "@/hooks/useLoadApp"; import { useLoadApp } from "@/hooks/useLoadApp";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
interface VersionPaneProps { interface VersionPaneProps {
isVisible: boolean; isVisible: boolean;
...@@ -153,25 +158,30 @@ export function VersionPane({ isVisible, onClose }: VersionPaneProps) { ...@@ -153,25 +158,30 @@ export function VersionPane({ isVisible, onClose }: VersionPaneProps) {
</p> </p>
)} )}
<button <Tooltip>
onClick={async (e) => { <TooltipTrigger asChild>
e.stopPropagation(); <button
setSelectedVersionId(null); onClick={async (e) => {
await revertVersion({ e.stopPropagation();
versionId: version.oid, setSelectedVersionId(null);
}); await revertVersion({
// Close the pane after revert to force a refresh on next open versionId: version.oid,
onClose(); });
}} // Close the pane after revert to force a refresh on next open
className={cn( onClose();
"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", 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",
aria-label="Undo to latest version" selectedVersionId === version.oid && "visible",
> )}
<RotateCcw size={12} /> aria-label="Restore to this version"
<span>Undo</span> >
</button> <RotateCcw size={12} />
<span>Restore</span>
</button>
</TooltipTrigger>
<TooltipContent>Restore to this version</TooltipContent>
</Tooltip>
</div> </div>
</div> </div>
))} ))}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论