Allow active deployment edits
This commit is contained in:
@@ -173,6 +173,7 @@ describe("first-party console pages", () => {
|
||||
expect(serversPageSource).toContain("<ServerDeploymentWorkflow");
|
||||
expect(serversPageSource).toContain("openEditDeployment");
|
||||
expect(serversPageSource).toContain("编辑部署");
|
||||
expect(serversPageSource).not.toContain('instance.state === "running" || instance.state === "installing"');
|
||||
expect(serverDetailPageSource).not.toContain("<ServerDeploymentWorkflow");
|
||||
expect(serverDetailPageSource).toContain("ServerDeploymentSection");
|
||||
expect(serverDeploymentWorkflowSource).toContain("基本信息");
|
||||
@@ -209,6 +210,17 @@ describe("first-party console pages", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps live logs and management terminal on server detail instead of the server list", () => {
|
||||
expect(serversPageSource).not.toContain("ServerLiveLogDrawer");
|
||||
expect(serversPageSource).not.toContain("ServerManagementTerminalDrawer");
|
||||
expect(serversPageSource).not.toContain("live-logs");
|
||||
expect(serversPageSource).not.toContain("管理终端");
|
||||
expect(serverDetailPageSource).toContain("ServerLiveLogDrawer");
|
||||
expect(serverDetailPageSource).toContain("ServerManagementTerminalDrawer");
|
||||
expect(serverDetailPageSource).toContain("实时日志");
|
||||
expect(serverDetailPageSource).toContain("管理终端");
|
||||
});
|
||||
|
||||
it("keeps create target and profile controls out while preserving deployment steps", () => {
|
||||
expect(serverDeploymentWorkflowSource).not.toContain('name="deploymentTargetId"');
|
||||
expect(serverDeploymentWorkflowSource).not.toContain("请选择部署目标");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AlertTriangle, CakeSlice, Candy, ScrollText, Search, Sparkles, Terminal, Trash2 } from "lucide-react";
|
||||
import { AlertTriangle, CakeSlice, Candy, Search, Sparkles, Trash2 } from "lucide-react";
|
||||
import { type CSSProperties, type FormEvent, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
runtimeUpdateStages,
|
||||
useRuntimeTaskController
|
||||
} from "../components/RuntimeTaskProgress";
|
||||
import { ServerLiveLogDrawer, ServerManagementTerminalDrawer } from "../components/ServerLiveOperations";
|
||||
import { ConfirmDialog, ManagementDialog, UsageMeter } from "../components/OperationControls";
|
||||
import { ServerDeploymentWorkflow } from "../components/ServerDeploymentWorkflow";
|
||||
import { EmptyState, ErrorState, LoadingState, ResultBadge } from "../components/StateViews";
|
||||
@@ -82,8 +81,6 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
|
||||
const [deletePassword, setDeletePassword] = useState("");
|
||||
const [deleteBusy, setDeleteBusy] = useState(false);
|
||||
const [runTargetSelection, setRunTargetSelection] = useState<RunTargetSelectionState | null>(null);
|
||||
const [liveLogTarget, setLiveLogTarget] = useState<ServerInstanceResponse | null>(null);
|
||||
const [terminalTarget, setTerminalTarget] = useState<ServerInstanceResponse | null>(null);
|
||||
|
||||
const refreshList = useCallback(async (showLoading = true) => {
|
||||
if (showLoading) setListState("loading");
|
||||
@@ -184,7 +181,6 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
|
||||
}
|
||||
|
||||
async function openEditDeployment(instance: ServerInstanceResponse) {
|
||||
if (instance.state === "running" || instance.state === "installing") return;
|
||||
try {
|
||||
const deployment = await platformApiClient.getServerDeployment(instance.id);
|
||||
const plugin = plugins.find((item) => item.id === instance.pluginId);
|
||||
@@ -363,10 +359,6 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
|
||||
const job = await platformApiClient.installDependencies(instance.id, dependencyJobRequest(instance.id, probe.key, plan.key, plan.digest));
|
||||
return `依赖安装任务已排队,job ${job.id}`;
|
||||
}
|
||||
if (action === "live-logs") {
|
||||
onNavigate("serverDetail", { serverId: instance.id });
|
||||
return "已打开服务器详情,可切换到日志页查看实时日志";
|
||||
}
|
||||
const job = await platformApiClient.requestLogBackfill(instance.id, logBackfillRequest(instance.id, defaults.logSourceKey));
|
||||
return `历史日志回填任务已排队,job ${job.id}`;
|
||||
}
|
||||
@@ -612,8 +604,6 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
|
||||
deleteDisabledReason={serverDeleteDisabledReason(session, card.instance)}
|
||||
onOpen={() => onNavigate("serverDetail", { serverId: card.instance.id })}
|
||||
onEdit={() => void openEditDeployment(card.instance)}
|
||||
onOpenLogs={() => setLiveLogTarget(card.instance)}
|
||||
onOpenTerminal={() => setTerminalTarget(card.instance)}
|
||||
onQuickAction={(action) => void handleQuickRuntimeAction(card.instance, action)}
|
||||
onDelete={() => {
|
||||
setDeletePassword("");
|
||||
@@ -648,8 +638,6 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
|
||||
</label>
|
||||
</ConfirmDialog>
|
||||
<RuntimeTaskProgressDialog task={runtimeTask.task} onClose={runtimeTask.closeTask} actions={runtimeTaskActions} />
|
||||
<ServerLiveLogDrawer open={liveLogTarget !== null} serverId={liveLogTarget?.id ?? ""} serverName={liveLogTarget?.name ?? ""} onClose={() => setLiveLogTarget(null)} />
|
||||
<ServerManagementTerminalDrawer open={terminalTarget !== null} serverId={terminalTarget?.id ?? ""} serverName={terminalTarget?.name ?? ""} pluginId={terminalTarget?.pluginId ?? ""} canManage={canManageServers} onClose={() => setTerminalTarget(null)} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -662,7 +650,6 @@ type ServerQuickRuntimeAction =
|
||||
| "generate-client-manager"
|
||||
| "dependencies-check"
|
||||
| "dependencies-install"
|
||||
| "live-logs"
|
||||
| "historical-logs";
|
||||
|
||||
async function requireQuickRuntimeActionAvailable(serverInstanceId: string, action: ServerQuickRuntimeAction): Promise<void> {
|
||||
@@ -694,13 +681,11 @@ interface ServerCardProps {
|
||||
deleteDisabledReason: string;
|
||||
onOpen: () => void;
|
||||
onEdit: () => void;
|
||||
onOpenLogs: () => void;
|
||||
onOpenTerminal: () => void;
|
||||
onQuickAction: (action: ServerQuickRuntimeAction) => void;
|
||||
onDelete: () => void;
|
||||
}
|
||||
|
||||
function ServerCard({ card, metricsPending, metricsUnavailable, canManage, deleteDisabledReason, onOpen, onEdit, onOpenLogs, onOpenTerminal, onQuickAction, onDelete }: ServerCardProps) {
|
||||
function ServerCard({ card, metricsPending, metricsUnavailable, canManage, deleteDisabledReason, onOpen, onEdit, onQuickAction, onDelete }: ServerCardProps) {
|
||||
const { instance, metrics, pendingJobs, failedJobs = 0 } = card;
|
||||
const online = serverIsOnline(instance.state);
|
||||
const canDelete = deleteDisabledReason === "";
|
||||
@@ -825,9 +810,7 @@ function ServerCard({ card, metricsPending, metricsUnavailable, canManage, delet
|
||||
<Sparkles size={14} />
|
||||
<span>详情</span>
|
||||
</button>
|
||||
<button type="button" className="icon-command" disabled={!canManage || instance.state === "running" || instance.state === "installing"} title={instance.state === "running" || instance.state === "installing" ? "请先停止服务器再编辑部署" : "编辑部署"} onClick={onEdit}><span>编辑部署</span></button>
|
||||
<button type="button" className="icon-command" onClick={onOpenLogs}><ScrollText size={14} /><span>实时日志</span></button>
|
||||
<button type="button" className="icon-command" disabled={!canManage} title={canManage ? "管理终端" : "当前账号没有运行操作权限"} onClick={onOpenTerminal}><Terminal size={14} /><span>管理终端</span></button>
|
||||
<button type="button" className="icon-command" disabled={!canManage} title={canManage ? "编辑部署" : "当前账号没有运行操作权限"} onClick={onEdit}><span>编辑部署</span></button>
|
||||
<button ref={menuButtonRef} type="button" className="icon-command" disabled={!canOpenActions} title={canOpenActions ? "运行操作" : "当前账号没有运行操作权限"} aria-haspopup="menu" aria-expanded={menuOpen} onClick={toggleMenu}>
|
||||
<span>运行操作</span>
|
||||
</button>
|
||||
@@ -892,7 +875,7 @@ const serverQuickActionGroups: Array<{ label: string; actions: ServerQuickRuntim
|
||||
},
|
||||
{
|
||||
label: "诊断维护",
|
||||
actions: ["dependencies-check", "dependencies-install", "live-logs", "historical-logs"]
|
||||
actions: ["dependencies-check", "dependencies-install", "historical-logs"]
|
||||
}
|
||||
];
|
||||
|
||||
@@ -912,8 +895,6 @@ function quickRuntimeActionLabel(action: ServerQuickRuntimeAction): string {
|
||||
return "依赖检查";
|
||||
case "dependencies-install":
|
||||
return "依赖安装";
|
||||
case "live-logs":
|
||||
return "实时日志";
|
||||
case "historical-logs":
|
||||
return "历史日志";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user