fix: 修复普通成员发布页加载
This commit is contained in:
@@ -41,6 +41,9 @@ import { http } from './http'
|
|||||||
type DataSource = 'backend'
|
type DataSource = 'backend'
|
||||||
type BackendHealthStatus = 'ok' | 'not_configured' | 'unavailable'
|
type BackendHealthStatus = 'ok' | 'not_configured' | 'unavailable'
|
||||||
type BackendRunStatus = 'pending' | 'queued' | 'running' | 'success' | 'failed' | 'canceled'
|
type BackendRunStatus = 'pending' | 'queued' | 'running' | 'success' | 'failed' | 'canceled'
|
||||||
|
type DashboardOptions = {
|
||||||
|
includeAdminConfig?: boolean
|
||||||
|
}
|
||||||
type BackendVariableHelpValue =
|
type BackendVariableHelpValue =
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
@@ -311,12 +314,15 @@ export const devopsApi = {
|
|||||||
lastDataSource = 'backend'
|
lastDataSource = 'backend'
|
||||||
},
|
},
|
||||||
|
|
||||||
async getDashboard(): Promise<DashboardSummary> {
|
async getDashboard(options: DashboardOptions = {}): Promise<DashboardSummary> {
|
||||||
|
const integrationConfigPromise = options.includeAdminConfig
|
||||||
|
? fetchIntegrationConfigStatus()
|
||||||
|
: Promise.resolve(emptyIntegrationConfigStatus())
|
||||||
const [health, backendProjects, backendRuns, integrationConfig] = await Promise.all([
|
const [health, backendProjects, backendRuns, integrationConfig] = await Promise.all([
|
||||||
fetchHealth(),
|
fetchHealth(),
|
||||||
fetchProjects(),
|
fetchProjects(),
|
||||||
fetchRuns(),
|
fetchRuns(),
|
||||||
fetchIntegrationConfigStatus(),
|
integrationConfigPromise,
|
||||||
])
|
])
|
||||||
const adaptedProjects = toProjectConfigs(backendProjects)
|
const adaptedProjects = toProjectConfigs(backendProjects)
|
||||||
lastDataSource = 'backend'
|
lastDataSource = 'backend'
|
||||||
@@ -482,6 +488,13 @@ async function fetchIntegrationConfigStatus(): Promise<IntegrationConfigStatus>
|
|||||||
return sanitizeIntegrationConfigStatus(data)
|
return sanitizeIntegrationConfigStatus(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function emptyIntegrationConfigStatus(): IntegrationConfigStatus {
|
||||||
|
return {
|
||||||
|
checkedAt: new Date().toISOString(),
|
||||||
|
integrations: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toIntegrationStatuses(health: BackendHealth): IntegrationStatus[] {
|
function toIntegrationStatuses(health: BackendHealth): IntegrationStatus[] {
|
||||||
return [
|
return [
|
||||||
toIntegrationStatus('jenkins', 'Jenkins', health),
|
toIntegrationStatus('jenkins', 'Jenkins', health),
|
||||||
|
|||||||
+10
-5
@@ -4,6 +4,7 @@
|
|||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { devopsApi } from '../services/devopsApi'
|
import { devopsApi } from '../services/devopsApi'
|
||||||
|
import { useSessionStore } from './session'
|
||||||
import type {
|
import type {
|
||||||
AgentCard,
|
AgentCard,
|
||||||
AuditLogEntry,
|
AuditLogEntry,
|
||||||
@@ -42,19 +43,23 @@ export const usePlatformStore = defineStore('platform', () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
async function loadAll() {
|
async function loadAll() {
|
||||||
|
const session = useSessionStore()
|
||||||
|
const includeAdminData = session.role === 'super_admin'
|
||||||
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const summary = await devopsApi.getDashboard()
|
const summary = await devopsApi.getDashboard({ includeAdminConfig: includeAdminData })
|
||||||
projects.value = summary.projects
|
projects.value = summary.projects
|
||||||
runs.value = summary.runs
|
runs.value = summary.runs
|
||||||
integrations.value = summary.integrations
|
integrations.value = summary.integrations
|
||||||
agentCards.value = summary.agentCards
|
agentCards.value = summary.agentCards
|
||||||
settings.value = summary.settings
|
settings.value = summary.settings
|
||||||
integrationConfig.value = summary.integrationConfig
|
integrationConfig.value = summary.integrationConfig
|
||||||
const [processXml, recentAuditLogs] = await Promise.all([
|
const processXmlPromise = devopsApi.getReleaseProcessXml()
|
||||||
devopsApi.getReleaseProcessXml(),
|
const auditLogsPromise = includeAdminData
|
||||||
devopsApi.getAuditLogs(),
|
? devopsApi.getAuditLogs()
|
||||||
])
|
: Promise.resolve<AuditLogEntry[]>([])
|
||||||
|
const [processXml, recentAuditLogs] = await Promise.all([processXmlPromise, auditLogsPromise])
|
||||||
releaseProcessXml.value = processXml
|
releaseProcessXml.value = processXml
|
||||||
auditLogs.value = recentAuditLogs
|
auditLogs.value = recentAuditLogs
|
||||||
dataSource.value = devopsApi.getLastDataSource()
|
dataSource.value = devopsApi.getLastDataSource()
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import type { EnvironmentName, ProjectRefItem, ReleaseRun, ReleaseStatus } from
|
|||||||
const platform = usePlatformStore()
|
const platform = usePlatformStore()
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
projectKey: 'access-manage',
|
projectKey: '',
|
||||||
environment: 'test' as EnvironmentName,
|
environment: 'test' as EnvironmentName,
|
||||||
ref: 'develop',
|
ref: '',
|
||||||
note: '测试环境部署验证',
|
note: '发布验证',
|
||||||
confirmed: false,
|
confirmed: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ async function syncJenkinsRun() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadProjectRefs() {
|
async function loadProjectRefs() {
|
||||||
if (!form.projectKey) {
|
if (!form.projectKey || !selectedProject.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,6 +270,17 @@ function useFailedRun() {
|
|||||||
watch(
|
watch(
|
||||||
() => [form.projectKey, platform.projects.length],
|
() => [form.projectKey, platform.projects.length],
|
||||||
() => {
|
() => {
|
||||||
|
const availableProject = selectedProject.value ?? platform.projects[0]
|
||||||
|
|
||||||
|
if (!availableProject) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form.projectKey !== availableProject.key) {
|
||||||
|
form.projectKey = availableProject.key
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const firstEnvironment = selectedProject.value?.environments[0]
|
const firstEnvironment = selectedProject.value?.environments[0]
|
||||||
|
|
||||||
if (firstEnvironment && !selectedProject.value?.environments.some((env) => env.name === form.environment)) {
|
if (firstEnvironment && !selectedProject.value?.environments.some((env) => env.name === form.environment)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user