feat: 展示项目 Gitea 仓库诊断
- devopsApi: 接入项目 Gitea 诊断接口 - platform store: 回填仓库可达性和默认分支 commit - ProjectsView: 展示 Gitea 状态、分支 tag 数量和 commit 摘要
This commit is contained in:
@@ -1,24 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 项目配置页展示项目仓库、发布环境以及真实 Jenkins job 诊断状态。
|
||||
* 项目配置页展示项目仓库、发布环境、Gitea 仓库诊断和真实 Jenkins job 诊断状态。
|
||||
*/
|
||||
import { onMounted, ref } from 'vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
import { usePlatformStore } from '../stores/platform'
|
||||
import type { EnvironmentStatus } from '../types/devops'
|
||||
import type { EnvironmentStatus, ProjectConfig } from '../types/devops'
|
||||
|
||||
const platform = usePlatformStore()
|
||||
const diagnosticsLoading = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
void refreshJenkinsDiagnostics()
|
||||
void refreshProjectDiagnostics()
|
||||
})
|
||||
|
||||
async function refreshJenkinsDiagnostics() {
|
||||
async function refreshProjectDiagnostics() {
|
||||
diagnosticsLoading.value = true
|
||||
|
||||
try {
|
||||
await platform.loadProjectJenkinsDiagnostics()
|
||||
await Promise.all([
|
||||
platform.loadProjectJenkinsDiagnostics(),
|
||||
platform.loadProjectGiteaDiagnostics(),
|
||||
])
|
||||
} finally {
|
||||
diagnosticsLoading.value = false
|
||||
}
|
||||
@@ -35,6 +38,28 @@ function lastBuildText(env: EnvironmentStatus): string {
|
||||
|
||||
return `#${env.jenkinsLastBuild.number} ${env.jenkinsLastBuild.result || 'UNKNOWN'}`
|
||||
}
|
||||
|
||||
function commitText(project: ProjectConfig): string {
|
||||
const commit = project.giteaLatestCommit
|
||||
|
||||
if (!commit?.sha) {
|
||||
return '-'
|
||||
}
|
||||
|
||||
const title = commit.message.split('\n')[0] || '无提交说明'
|
||||
return `${commit.sha.slice(0, 8)} · ${title}`
|
||||
}
|
||||
|
||||
function branchTagText(project: ProjectConfig): string {
|
||||
if (project.giteaBranchCount === undefined && project.giteaTagCount === undefined) {
|
||||
return '尚未诊断'
|
||||
}
|
||||
|
||||
const branchCount = project.giteaBranchCount ?? 0
|
||||
const tagCount = project.giteaTagCount ?? 0
|
||||
|
||||
return `${branchCount} branches · ${tagCount} tags`
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -54,9 +79,9 @@ function lastBuildText(env: EnvironmentStatus): string {
|
||||
size="small"
|
||||
plain
|
||||
:loading="diagnosticsLoading"
|
||||
@click="refreshJenkinsDiagnostics"
|
||||
@click="refreshProjectDiagnostics"
|
||||
>
|
||||
刷新 Jenkins 诊断
|
||||
刷新项目诊断
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
@@ -64,6 +89,37 @@ function lastBuildText(env: EnvironmentStatus): string {
|
||||
<ElTableColumn type="expand">
|
||||
<template #default="{ row }">
|
||||
<div class="env-config">
|
||||
<div class="project-diagnostic-card">
|
||||
<div class="env-config-head">
|
||||
<strong>Gitea 仓库诊断</strong>
|
||||
<StatusPill :state="row.giteaStatus" />
|
||||
</div>
|
||||
<dl>
|
||||
<dt>仓库状态</dt>
|
||||
<dd>
|
||||
<StatusPill :state="row.giteaStatus" />
|
||||
<span class="diagnostic-message">{{ row.giteaMessage }}</span>
|
||||
</dd>
|
||||
<dt>公开地址</dt>
|
||||
<dd>
|
||||
<a
|
||||
v-if="row.giteaWebUrl"
|
||||
:href="row.giteaWebUrl"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
{{ row.giteaWebUrl }}
|
||||
</a>
|
||||
<span v-else class="mono">{{ row.repository }}</span>
|
||||
</dd>
|
||||
<dt>默认分支</dt>
|
||||
<dd>{{ row.giteaDefaultBranch || row.defaultBranch }}</dd>
|
||||
<dt>分支 / Tag</dt>
|
||||
<dd>{{ branchTagText(row) }}</dd>
|
||||
<dt>默认分支 commit</dt>
|
||||
<dd class="mono">{{ commitText(row) }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div v-for="env in row.environments" :key="env.name" class="env-config-card">
|
||||
<div class="env-config-head">
|
||||
<strong>{{ env.label }}</strong>
|
||||
@@ -157,6 +213,14 @@ function lastBuildText(env: EnvironmentStatus): string {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.project-diagnostic-card {
|
||||
grid-column: 1 / -1;
|
||||
padding: 14px;
|
||||
border: 1px solid #d7e5ff;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.env-config-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user