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