diff --git a/src/pages/applications/ReleaseManagementPage.tsx b/src/pages/applications/ReleaseManagementPage.tsx index 53ca628..185b193 100644 --- a/src/pages/applications/ReleaseManagementPage.tsx +++ b/src/pages/applications/ReleaseManagementPage.tsx @@ -29,17 +29,39 @@ function statusTone(status: string): 'neutral' | 'green' | 'amber' | 'red' | 'bl type ImageTags = { images?: Record; artifacts?: Record; + buildJobs?: Array<{ + component?: string; + type?: string; + }>; error?: string; promotion?: { sourceBuildJobIds?: string[]; }; }; +function releaseBuildComponentTypes(imageTags: ImageTags | null | undefined) { + const map = new Map(); + for (const job of imageTags?.buildJobs ?? []) { + if (job.component && job.type) map.set(job.component, job.type); + } + return map; +} + +function isReleaseArtifactVisible(componentName: string, componentTypes: Map) { + const type = componentTypes.get(componentName); + return type !== 'DATABASE' && type !== 'MIGRATION'; +} + function releaseArtifacts(release: AppRelease) { const imageTags = release.imageTags as ImageTags | null | undefined; + const componentTypes = releaseBuildComponentTypes(imageTags); const values = [ - ...Object.values(imageTags?.images ?? {}), - ...Object.values(imageTags?.artifacts ?? {}) + ...Object.entries(imageTags?.images ?? {}) + .filter(([componentName]) => isReleaseArtifactVisible(componentName, componentTypes)) + .map(([, value]) => value), + ...Object.entries(imageTags?.artifacts ?? {}) + .filter(([componentName]) => isReleaseArtifactVisible(componentName, componentTypes)) + .map(([, value]) => value) ].filter(Boolean); if (values.length) return values; @@ -137,7 +159,9 @@ function nextReleaseVersion(releases: AppRelease[], appId: string, builds: Build function buildCount(release: AppRelease) { const imageTags = release.imageTags as ImageTags | null | undefined; - const count = Object.keys(imageTags?.images ?? {}).length + Object.keys(imageTags?.artifacts ?? {}).length; + const componentTypes = releaseBuildComponentTypes(imageTags); + const count = Object.keys(imageTags?.images ?? {}).filter((componentName) => isReleaseArtifactVisible(componentName, componentTypes)).length + + Object.keys(imageTags?.artifacts ?? {}).filter((componentName) => isReleaseArtifactVisible(componentName, componentTypes)).length; return count || (release.artifact ? 1 : 0); }