Simplify server file toolbar

This commit is contained in:
npc0-hue
2026-08-26 15:24:21 +08:00
parent c996297c9d
commit d395019848
3 changed files with 15 additions and 13 deletions
@@ -98,6 +98,8 @@ describe("ServerDetailPage config write approval", () => {
expect(serverDetailPageSource).not.toContain("entry.editable");
expect(serverDetailPageSource).not.toContain("entry.downloadable");
expect(serverDetailPageSource).not.toContain("当前目录暂无缓存结果;点击刷新目录读取实时文件。");
expect(serverDetailPageSource).not.toContain("独立通道");
expect(serverDetailPageSource).not.toContain("目录已更新");
});
it("keeps run distribution and client-manager workflows out of server detail tabs", () => {
+9 -10
View File
@@ -596,7 +596,7 @@ function ServerFilesSection({ instance, session, operations }: ServerFilesSectio
try {
const response = await platformApiClient.listServerFiles(instance.id, { directoryKey, path: relativePath || undefined, query: searchQuery || undefined, recursive });
setList({ status: "ready", data: response });
if (options.silent && response.state === "ready") setPanelResult({ status: "succeeded", label: `目录已更新:${response.entries.length}` });
if (options.silent && response.state === "ready") setPanelResult(null);
if (options.silent && response.state === "pending") setPanelResult({ status: "pending", label: serverFileListPendingLabel(response) });
if (options.silent && response.state === "failed") setPanelResult({ status: "failed", label: response.reason ?? "目录刷新失败" });
} catch (error) {
@@ -616,7 +616,8 @@ function ServerFilesSection({ instance, session, operations }: ServerFilesSectio
const response = await platformApiClient.refreshServerFiles(instance.id, { directoryKey, path: relativePath || undefined, query: searchQuery || undefined, recursive, idempotencyKey: serverFileIdempotency("list", instance.id, directoryKey) });
setList({ status: "ready", data: response });
if (operationId) operations.succeed(operationId, `目录刷新任务 ${response.job?.id ?? "已派发"}`, response.job);
setPanelResult({ status: serverFileListResultStatus(response), label: serverFileListResultLabel(response) });
if (response.state === "ready") setPanelResult(null);
else setPanelResult({ status: serverFileListResultStatus(response), label: serverFileListResultLabel(response) });
} catch (error) {
const reason = error instanceof Error ? error.message : "目录刷新失败";
if (operationId) operations.fail(operationId, reason, operationId);
@@ -761,14 +762,13 @@ function ServerFilesSection({ instance, session, operations }: ServerFilesSectio
<article className="console-panel server-file-manager" aria-label="server file manager">
<div className="panel-header">
<h2><Folder size={16} style={{ verticalAlign: "-2px" }} /> </h2>
<span className="page-status"> {workspace.data.transfer.channel} · {formatBytes(workspace.data.transfer.maxInlineEditBytes)}</span>
</div>
<div className="server-file-pathbar" aria-label="当前文件路径">
<button type="button" className="icon-command" onClick={goUp} disabled={!relativePath && directoryKey === workspace.data.defaultDirectoryKey}><ChevronRight size={14} className="server-file-back-icon" /><span></span></button>
<span className="server-file-path-chip">{activeDirectory?.label ?? (directoryKey || "服务器根目录")}</span>
{relativePath.split("/").filter(Boolean).map((part) => <span key={part} className="server-file-path-chip server-file-path-child"><ChevronRight size={12} />{part}</span>)}
</div>
<div className={cx("server-file-toolbar", workspace.data.directories.length > 1 && "server-file-toolbar-has-tabs")}>
<div className="server-file-toolbar">
<div className="server-file-pathbar" aria-label="当前文件路径">
<button type="button" className="icon-command" onClick={goUp} disabled={!relativePath && directoryKey === workspace.data.defaultDirectoryKey}><ChevronRight size={14} className="server-file-back-icon" /><span></span></button>
<span className="server-file-path-chip">{activeDirectory?.label ?? (directoryKey || "服务器根目录")}</span>
{relativePath.split("/").filter(Boolean).map((part) => <span key={part} className="server-file-path-chip server-file-path-child"><ChevronRight size={12} />{part}</span>)}
</div>
{workspace.data.directories.length > 1 && <div className="server-file-directory-tabs" role="tablist" aria-label="文件目录">
{workspace.data.directories.map((directory) => (
<button key={directory.key} type="button" className={cx("segmented-button", directory.key === directoryKey && "segmented-button-active")} onClick={() => { setDirectoryKey(directory.key); setRelativePath(""); }}>
@@ -861,7 +861,6 @@ function serverFileListResultStatus(response: ServerFileListResponse): "pending"
}
function serverFileListResultLabel(response: ServerFileListResponse): string {
if (response.state === "ready") return `目录已更新:${response.entries.length}`;
if (response.state === "failed") return response.reason ?? "目录刷新失败";
return serverFileListPendingLabel(response);
}