diff --git a/dashboard/src/api.ts b/dashboard/src/api.ts index e67a996e..b793ef74 100644 --- a/dashboard/src/api.ts +++ b/dashboard/src/api.ts @@ -20,7 +20,6 @@ const REQUEST_TIMEOUT_MS = 17000 export interface ApiError extends Error { detail?: unknown } - export async function request(path: string, options?: RequestInit, timeoutMs = REQUEST_TIMEOUT_MS): Promise { const controller = new AbortController() const timeoutId = window.setTimeout(() => controller.abort(), timeoutMs) @@ -1290,6 +1289,7 @@ export interface ReleaseTask { checks_summary: string | null can_create_pr: boolean can_deploy_staging: boolean + can_deploy_production?: boolean; resolved_commit_sha?: string | null; staging_deployment_record_id?: number | null; environment_gate_summary?: string | null blocked_reason: string | null } created_at: string | null diff --git a/dashboard/src/apiReleaseTasks.ts b/dashboard/src/apiReleaseTasks.ts index c16e8a45..bc8652cf 100644 --- a/dashboard/src/apiReleaseTasks.ts +++ b/dashboard/src/apiReleaseTasks.ts @@ -27,3 +27,7 @@ export function getReleaseTasksPage(filters?: { const q = params.toString() ? `?${params.toString()}` : '' return request(`/releases/tasks/query${q}`) } + +export function deployReleaseTask(id: number, data?: { actor?: string; note?: string | null; confirm_phrase?: string | null }) { + return request(`/releases/tasks/${id}/deploy`, { method: 'POST', body: JSON.stringify(data || {}) }) +} diff --git a/dashboard/src/pages/ProductionDeployModal.tsx b/dashboard/src/pages/ProductionDeployModal.tsx new file mode 100644 index 00000000..9b07a77f --- /dev/null +++ b/dashboard/src/pages/ProductionDeployModal.tsx @@ -0,0 +1,78 @@ +import { ReleaseTask } from '../api' +import { FieldLabel, OverlayModal } from '../components/workbench' + +export default function ProductionDeployModal({ + task, + confirmPhrase, + busyAction, + onConfirmPhraseChange, + onClose, + onDeploy, +}: Readonly<{ + task: ReleaseTask | null + confirmPhrase: string + busyAction: string | null + onConfirmPhraseChange: (value: string) => void + onClose: () => void + onDeploy: () => void +}>) { + const busyKey = task ? `release-task-${task.id}-deploy-production` : '' + return ( + + {task ? ( +
+
+
Production Human Gate
+

+ 请确认目标是 synapse-network-prod,分支为 main, + 且同一 commit 已通过 staging。确认后仍需要 GitHub production environment reviewers 放行。 +

+
+
+ + + + +
+ +
+ + +
+
+ ) : null} +
+ ) +} + +function InfoCard({ label, value, mono = false }: Readonly<{ label: string; value: string; mono?: boolean }>) { + return ( +
+
{label}
+
{value}
+
+ ) +} diff --git a/dashboard/src/pages/ReleaseTaskDetailPanel.tsx b/dashboard/src/pages/ReleaseTaskDetailPanel.tsx index 57675eb5..cbe6604e 100644 --- a/dashboard/src/pages/ReleaseTaskDetailPanel.tsx +++ b/dashboard/src/pages/ReleaseTaskDetailPanel.tsx @@ -247,6 +247,17 @@ export function ReleaseTaskDetailModal({ export function ReleaseTaskPrGate({ task }: Readonly<{ task: ReleaseTask }>) { const gate = task.pr_gate if (!gate) return null + if (task.environment === 'production') { + const ready = Boolean(gate.can_deploy_production) + return ( +
+ Production Gate: {ready ? '已满足' : gate.blocked_reason || '待满足'} + {gate.environment_gate_summary ?
{gate.environment_gate_summary}
: null} + {gate.resolved_commit_sha ?
main {gate.resolved_commit_sha.slice(0, 12)}
: null} + {gate.staging_deployment_record_id ?
staging deployment #{gate.staging_deployment_record_id}
: null} +
+ ) + } let label = gate.blocked_reason || 'PR gate 待同步' let tone: 'ready' | 'running' | 'blocked' | 'muted' | 'delivered' = 'muted' if (!gate.branch_exists) { diff --git a/dashboard/src/pages/ReleasesPage.tsx b/dashboard/src/pages/ReleasesPage.tsx index 588748da..43e4e162 100644 --- a/dashboard/src/pages/ReleasesPage.tsx +++ b/dashboard/src/pages/ReleasesPage.tsx @@ -1,17 +1,17 @@ import { useEffect, useMemo, useState } from 'react' import { useNavigate, useSearchParams } from 'react-router-dom' import { OnlineReleaseRecord, ProjectPolicy, ReleaseBranchOption, ReleaseCandidate, ReleaseTask, api } from '../api' -import { getReleaseTasksPage } from '../apiReleaseTasks' +import { deployReleaseTask, getReleaseTasksPage } from '../apiReleaseTasks' import { EmptyPane, FieldLabel, OverlayModal, StateBadge, useToast } from '../components/workbench' import { ReleaseTaskCompactFailure, ReleaseTaskDetailModal, ReleaseTaskFailureSnippet, ReleaseTaskPrGate, releaseTaskFailureSummary, shouldShowReleaseTaskFailure } from './ReleaseTaskDetailPanel' import { STATUS_LABEL, releaseTone } from './releaseListUi' import SdkPackagesPanel from './SdkPackagesPanel' import ScheduledJobsPanel from './ScheduledJobsPanel' +import ProductionDeployModal from './ProductionDeployModal' type ReleaseTab = 'candidates' | 'tasks' | 'scheduled-jobs' | 'sdk-packages' | 'online' const RELEASE_TABS: ReleaseTab[] = ['candidates', 'tasks', 'scheduled-jobs', 'sdk-packages', 'online'] const RELEASE_TASK_PAGE_SIZE = 10 - const SOURCE_LABEL: Record = { manual: '人工创建', requirement_flow: '需求流转', @@ -154,6 +154,8 @@ export default function ReleasesPage() { const [onlineDetail, setOnlineDetail] = useState(null) const [taskDraft, setTaskDraft] = useState(defaultTaskDraft([])) const [taskBusy, setTaskBusy] = useState(false) + const [productionDeployTask, setProductionDeployTask] = useState(null) + const [productionConfirmPhrase, setProductionConfirmPhrase] = useState('') const [branchOptions, setBranchOptions] = useState([]) const [branchQuery, setBranchQuery] = useState('') const [branchLoading, setBranchLoading] = useState(false) @@ -381,6 +383,28 @@ export default function ReleasesPage() { } } + const deployTaskToProduction = async () => { + if (!productionDeployTask || busyAction) return + const busyKey = `release-task-${productionDeployTask.id}-deploy-production` + setBusyAction(busyKey) + try { + await deployReleaseTask(productionDeployTask.id, { + actor: 'operator', + note: productionDeployTask.note, + confirm_phrase: productionConfirmPhrase, + }) + toast.success('Production 发布已触发') + setProductionDeployTask(null) + setProductionConfirmPhrase('') + await load() + } catch (error) { + const message = error instanceof Error ? error.message : '触发 production 发布失败' + toast.error(message) + } finally { + setBusyAction(null) + } + } + const createTaskPr = async (task: ReleaseTask) => { const busyKey = `release-task-${task.id}-create-pr` if (busyAction) return @@ -552,6 +576,10 @@ export default function ReleasesPage() { onUpdateStatus={updateTaskStatus} onCreatePr={createTaskPr} onDeployStaging={deployTaskToStaging} + onDeployProduction={(task) => { + setProductionConfirmPhrase('') + setProductionDeployTask(task) + }} onRefresh={() => load().catch(() => {})} onOpenDetails={(task) => { setTaskModalOpen(false) @@ -571,6 +599,18 @@ export default function ReleasesPage() { /> )} + { + setProductionDeployTask(null) + setProductionConfirmPhrase('') + }} + onDeploy={deployTaskToProduction} + /> + void onCreatePr: (task: ReleaseTask) => void onDeployStaging: (task: ReleaseTask) => void + onDeployProduction: (task: ReleaseTask) => void onRefresh: () => void onOpenDetails: (task: ReleaseTask) => void onPage: (offset: number) => void @@ -892,7 +934,7 @@ function ReleaseTasksTable({ ) : null} - {task.environment === 'staging' ? : null} + {task.environment === 'staging' || task.environment === 'production' ? : null}
创建:{task.actor || '-'}
@@ -967,9 +1009,18 @@ function ReleaseTasksTable({ 发布到 staging ) : null} - {task.environment === 'production' ? ( - - Production 需 Human Gate + {task.environment === 'production' && task.pr_gate?.can_deploy_production && !task.deployment_record_id ? ( + + ) : task.environment === 'production' ? ( + + {task.pr_gate?.blocked_reason || 'Production 需 Human Gate'} ) : null}