feat: 展示项目最近发布状态
- store: 将真实 deploy-runs 回填到项目环境最近发布摘要 - ProjectsView: 展示最近 run 状态、ref、操作者和跳转入口 - RunsView: 支持通过 runId query 定位运行记录
This commit is contained in:
@@ -55,6 +55,7 @@ export const usePlatformStore = defineStore('platform', () => {
|
||||
const summary = await devopsApi.getDashboard({ includeAdminConfig: includeAdminData })
|
||||
projects.value = summary.projects
|
||||
runs.value = summary.runs
|
||||
applyProjectRunSummaries()
|
||||
integrations.value = summary.integrations
|
||||
agentCards.value = summary.agentCards
|
||||
settings.value = summary.settings
|
||||
@@ -200,6 +201,49 @@ export const usePlatformStore = defineStore('platform', () => {
|
||||
|
||||
function upsertRun(run: ReleaseRun) {
|
||||
runs.value = [run, ...runs.value.filter((item) => item.id !== run.id)]
|
||||
applyProjectRunSummaries()
|
||||
}
|
||||
|
||||
function applyProjectRunSummaries() {
|
||||
const latestRunByEnvironment = new Map<string, ReleaseRun>()
|
||||
|
||||
// 后端 /deploy-runs 按最近记录返回;首次出现的项目环境即当前展示摘要。
|
||||
runs.value.forEach((run) => {
|
||||
const key = projectEnvironmentKey(run.projectKey, run.environment)
|
||||
|
||||
if (!latestRunByEnvironment.has(key)) {
|
||||
latestRunByEnvironment.set(key, run)
|
||||
}
|
||||
})
|
||||
|
||||
projects.value = projects.value.map((project) => ({
|
||||
...project,
|
||||
environments: project.environments.map((environment) => {
|
||||
const run = latestRunByEnvironment.get(
|
||||
projectEnvironmentKey(project.key, environment.name),
|
||||
)
|
||||
|
||||
if (!run) {
|
||||
return {
|
||||
...environment,
|
||||
status: 'idle',
|
||||
version: '-',
|
||||
lastRunId: '-',
|
||||
lastReleasedAt: '-',
|
||||
lastActor: '-',
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...environment,
|
||||
status: run.status,
|
||||
version: run.ref,
|
||||
lastRunId: run.id,
|
||||
lastReleasedAt: run.startedAt,
|
||||
lastActor: run.actor,
|
||||
}
|
||||
}),
|
||||
}))
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -263,3 +307,10 @@ function jenkinsDiagnosticMessage(
|
||||
|
||||
return 'Jenkins job 不可用'
|
||||
}
|
||||
|
||||
function projectEnvironmentKey(
|
||||
projectKey: string,
|
||||
environment: ReleaseRun['environment'],
|
||||
): string {
|
||||
return `${projectKey}:${environment}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user