Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
eee087fc
Unverified
提交
eee087fc
authored
7月 01, 2025
作者:
Will Chen
提交者:
GitHub
7月 01, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename Undo button in version pane to Restore (#536)
上级
9d11f6c7
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
37 行增加
和
23 行删除
+37
-23
switch_versions.spec.ts
e2e-tests/switch_versions.spec.ts
+4
-2
version_integrity.spec.ts
e2e-tests/version_integrity.spec.ts
+4
-2
VersionPane.tsx
src/components/chat/VersionPane.tsx
+29
-19
没有找到文件。
e2e-tests/switch_versions.spec.ts
浏览文件 @
eee087fc
...
@@ -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`
});
...
...
e2e-tests/version_integrity.spec.ts
浏览文件 @
eee087fc
...
@@ -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"
});
};
};
...
...
src/components/chat/VersionPane.tsx
浏览文件 @
eee087fc
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论