fix: restore server create deployment wizard

This commit is contained in:
npc0-hue
2026-07-30 21:02:17 +08:00
parent e614a17fe3
commit 2a17718158
7 changed files with 77 additions and 30 deletions
+9 -6
View File
@@ -168,7 +168,7 @@ describe("first-party console pages", () => {
expect(serversPageSource).toContain("旧 run 会话已失效");
});
it("separates minimal creation from post-create deployment editing without exposing protected inputs", () => {
it("keeps deployment startup inputs in the create wizard without exposing protected values", () => {
expect(serversPageSource).toContain("<ServerDeploymentWorkflow");
expect(serversPageSource).toContain("openEditDeployment");
expect(serversPageSource).toContain("编辑部署");
@@ -192,14 +192,14 @@ describe("first-party console pages", () => {
expect(serverDeploymentWorkflowSource).toContain("当前平台尚未提供 SCUM 服务端的受控升级任务");
expect(serverDeploymentWorkflowSource).toContain("已绑定服务器编辑时会直接进入相关配置");
expect(serverDeploymentWorkflowSource).toContain("可在此调整部署方式;不会重复要求选择已绑定的运行节点");
expect(serversPageSource).toContain('onNavigate("serverDetail", { serverId: result.instance.id })');
expect(serversPageSource).toContain('onNavigate("serverDetail", { serverId: result.instance.id, routeKey: "run-builder" })');
expect(serverDetailPageSource).toContain("运行配置绑定");
expect(serverDetailPageSource).toContain('type={field.sensitive ? "password" : "text"}');
expect(serverDeploymentWorkflowSource).toContain("显示已保存配置");
expect(serverDeploymentWorkflowSource).toContain("revealSavedInputs");
expect(serversPageSource).toContain("revealServerDeployment");
expect(serverDetailPageSource).toContain("最近 Run 调度");
expect(serversPageSource).toContain("minimalServerCreateRequestFromForm(nextForm)");
expect(serversPageSource).toContain("serverCreateRequestFromForm(nextForm)");
expect(serverDeploymentWorkflowSource).not.toContain('name="id"');
expect(serverDeploymentWorkflowSource).not.toContain("实例 ID");
for (const forbidden of ["secret://", "/Users/", "/var/run/", "unix://", "tcp://"]) {
@@ -207,7 +207,7 @@ describe("first-party console pages", () => {
}
});
it("keeps create-only controls structurally minimal", () => {
it("keeps create target and profile controls out while preserving deployment steps", () => {
expect(serverDeploymentWorkflowSource).not.toContain('name="deploymentTargetId"');
expect(serverDeploymentWorkflowSource).not.toContain("请选择部署目标");
expect(serverDeploymentWorkflowSource).not.toContain("saveAsDraft");
@@ -216,9 +216,12 @@ describe("first-party console pages", () => {
expect(serverDeploymentWorkflowSource).toContain("await onSubmit(form)");
expect(serverDeploymentWorkflowSource).not.toContain('kind === "create" && <label>运行预设');
expect(serverDeploymentWorkflowSource).not.toContain('kind === "create" && bindingFields');
expect(serverDeploymentWorkflowSource).toContain("插件类型和服务器名称是创建时仅有的必填信息");
expect(serverDeploymentWorkflowSource).toContain("配置启动项");
expect(serverDeploymentWorkflowSource).toContain("本次保存创建向导配置");
expect(serverDeploymentWorkflowSource).toContain('const modeStep = kind === "create" ? 1 : -1;');
expect(serverDeploymentWorkflowSource).toContain('const configurationStep = kind === "create" ? 2 : needsTargetSelection ? 1 : 0;');
expect(serverDeploymentWorkflowSource).toContain('const needsTargetSelection = kind === "edit" && !initialForm.runEndpointId;');
expect(serversPageSource).toContain("minimalServerCreateRequestFromForm(nextForm)");
expect(serversPageSource).toContain("serverCreateRequestFromForm(nextForm)");
});
it("renders server runtime actions as a compact popover trigger instead of an in-card details stack", () => {
+4 -4
View File
@@ -35,7 +35,7 @@ import {
logBackfillRequest,
runDistributionGenerateRequest,
runUpdateRequest,
minimalServerCreateRequestFromForm,
serverCreateRequestFromForm,
serverDeleteConfirmation
} from "../schemas/serverManagement";
import { isPlatformAdmin } from "../contracts/workspace";
@@ -156,12 +156,12 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
async function handleCreate(nextForm: ServerCreateFormState) {
const operationId = operations.begin({ intent: "创建服务器", targetKind: "server", targetId: "platform", requester: session.displayName });
try {
const result = await platformApiClient.createServerWorkflow(minimalServerCreateRequestFromForm(nextForm));
operations.succeed(operationId, result.job.id ? `已创建实例 ${result.instance.id},安装任务 ${result.job.id} 已派发` : `已创建服务器 ${result.instance.id}可在详情页按需补充运行配置和部署设置,再生成专属 Run。`, result.job.id ? result.job : undefined);
const result = await platformApiClient.createServerWorkflow(serverCreateRequestFromForm(nextForm));
operations.succeed(operationId, result.job.id ? `已创建实例 ${result.instance.id},安装任务 ${result.job.id} 已派发` : `已创建服务器 ${result.instance.id}部署方式和启动项已随创建向导保存,请生成并启动专属 Run。`, result.job.id ? result.job : undefined);
setForm(defaultServerCreateForm(plugins, endpoints));
setShowCreate(false);
await refresh();
onNavigate("serverDetail", { serverId: result.instance.id });
onNavigate("serverDetail", { serverId: result.instance.id, routeKey: "run-builder" });
} catch (error) {
operations.fail(operationId, error instanceof Error ? error.message : "创建失败", operationId);
}