diff --git a/client/src/app/components/environments/deployment-state-tag/deployment-state-tag.component.html b/client/src/app/components/environments/deployment-state-tag/deployment-state-tag.component.html index 88eff91c7..fdb225143 100644 --- a/client/src/app/components/environments/deployment-state-tag/deployment-state-tag.component.html +++ b/client/src/app/components/environments/deployment-state-tag/deployment-state-tag.component.html @@ -1,70 +1,15 @@ -@switch (state()) { - @case ('SUCCESS') { - - - - - } - - @case ('WAITING') { - - - - - } - - @case ('PENDING') { - - - - - } - - @case ('IN_PROGRESS') { - - - - - } - - @case ('QUEUED') { - - - - - } - - @case ('ERROR') { - - - - - } - - @case ('FAILURE') { - - - - - } - - @case ('INACTIVE') { - - - - - } - - @case ('UNKNOWN') { - - - - - } +
+ +
+ +
+
- @default { - - + @if (showLatestDeployment() && latestDeployment()) { + now at + + + {{ latestDeployment()?.releaseCandidateName ?? latestDeployment()?.ref }} } -} +
diff --git a/client/src/app/components/environments/deployment-state-tag/deployment-state-tag.component.ts b/client/src/app/components/environments/deployment-state-tag/deployment-state-tag.component.ts index e070edad1..524867cca 100644 --- a/client/src/app/components/environments/deployment-state-tag/deployment-state-tag.component.ts +++ b/client/src/app/components/environments/deployment-state-tag/deployment-state-tag.component.ts @@ -1,14 +1,98 @@ -import { Component, input } from '@angular/core'; -import { IconsModule } from 'icons.module'; +// deployment-state-tag.component.ts +import { Component, computed, input } from '@angular/core'; import { TagModule } from 'primeng/tag'; +import { IconsModule } from 'icons.module'; import { TooltipModule } from 'primeng/tooltip'; +type DeploymentState = 'SUCCESS' | 'WAITING' | 'PENDING' | 'IN_PROGRESS' | 'QUEUED' | 'ERROR' | 'FAILURE' | 'INACTIVE' | 'UNKNOWN' | 'NEVER_DEPLOYED' | 'REPLACED'; + @Component({ selector: 'app-deployment-state-tag', + standalone: true, imports: [TagModule, IconsModule, TooltipModule], - providers: [], templateUrl: './deployment-state-tag.component.html', }) export class DeploymentStateTagComponent { - state = input.required(); + state = input.required(); + verbose = input(false); + showLatestDeployment = input(false); + latestDeployment = input<{ releaseCandidateName?: string; ref?: string } | null | undefined>(null); + + rounded = computed(() => !this.verbose()); + internalState = computed(() => this.state() || 'UNKNOWN'); + + getSeverity() { + const severityMap: Record = { + SUCCESS: 'success', + WAITING: 'warn', + PENDING: 'warn', + IN_PROGRESS: 'info', + QUEUED: 'info', + ERROR: 'danger', + FAILURE: 'danger', + INACTIVE: 'secondary', + UNKNOWN: 'secondary', + NEVER_DEPLOYED: 'secondary', + REPLACED: 'contrast', + }; + return severityMap[this.internalState()]; + } + + getIcon() { + const iconMap: Record = { + SUCCESS: 'check', + WAITING: 'progress', + PENDING: 'progress', + IN_PROGRESS: 'progress', + QUEUED: 'progress', + ERROR: 'exclamation-circle', + FAILURE: 'exclamation-mark', + INACTIVE: 'time-duration-off', + UNKNOWN: 'question-mark', + NEVER_DEPLOYED: 'question-mark', + REPLACED: 'repeat', + }; + return iconMap[this.internalState()]; + } + + getIconClass() { + const spinStates: DeploymentState[] = ['WAITING', 'PENDING', 'IN_PROGRESS', 'QUEUED']; + return `!size-5 ${spinStates.includes(this.internalState()) ? 'animate-spin' : ''}`; + } + + getValue() { + const valueMap: Record = { + SUCCESS: 'success', + WAITING: 'waiting', + PENDING: 'pending', + IN_PROGRESS: 'in progress', + QUEUED: 'queued', + ERROR: 'failed', + FAILURE: 'failed', + INACTIVE: 'inactive', + UNKNOWN: 'unknown', + NEVER_DEPLOYED: 'never deployed', + REPLACED: 'replaced', + }; + return valueMap[this.internalState()]; + } + + getTooltip() { + const tooltipMap: Record = { + SUCCESS: 'Latest Deployment Successful', + WAITING: 'Waiting deployment', + PENDING: 'Deployment pending', + IN_PROGRESS: 'Deployment in progress', + QUEUED: 'Deployment queued', + ERROR: 'Latest deployment failed', + FAILURE: 'Latest deployment failed', + INACTIVE: 'Deployment inactive', + UNKNOWN: 'Deployment state unknown', + NEVER_DEPLOYED: 'Never deployed', + REPLACED: 'Deployment was replaced', + }; + return tooltipMap[this.internalState()]; + } } + +type Severity = 'success' | 'secondary' | 'info' | 'warn' | 'danger' | 'contrast' | undefined; diff --git a/client/src/app/components/release-candidate-deployment-table/release-candidate-deployment-table.component.html b/client/src/app/components/release-candidate-deployment-table/release-candidate-deployment-table.component.html index 92f34c692..dcbfb0f83 100644 --- a/client/src/app/components/release-candidate-deployment-table/release-candidate-deployment-table.component.html +++ b/client/src/app/components/release-candidate-deployment-table/release-candidate-deployment-table.component.html @@ -35,63 +35,17 @@ {{ environment.name }} - - - + @if (environment.serverUrl) { + + + + } - @switch (deploymentStatus(environment)) { - @case ('SUCCESS') { - - } - @case ('REPLACED') { -
- - now at - @if (environment.latestDeployment) { - @if (environment.latestDeployment.releaseCandidateName) { - - - {{ environment.latestDeployment.releaseCandidateName }} - - } @else { - - - {{ environment.latestDeployment.ref }} - - } - } -
- } - @case ('FAILURE') { - - } - @case ('NEVER_DEPLOYED') { -
- @if (environment.latestDeployment) { - now at - @if (environment.latestDeployment.releaseCandidateName) { - - - {{ environment.latestDeployment.releaseCandidateName }} - - } @else { - - - {{ environment.latestDeployment.ref }} - - } - } @else { - no release candidate deployed yet - } -
- } - @default { - - now at {{ environment.latestDeployment.releaseCandidateName }} - } - } +
+ +
@if (userCanDeploy()) { diff --git a/client/src/app/components/release-candidate-deployment-table/release-candidate-deployment-table.component.ts b/client/src/app/components/release-candidate-deployment-table/release-candidate-deployment-table.component.ts index 82b2c134c..b587e4ead 100644 --- a/client/src/app/components/release-candidate-deployment-table/release-candidate-deployment-table.component.ts +++ b/client/src/app/components/release-candidate-deployment-table/release-candidate-deployment-table.component.ts @@ -22,10 +22,11 @@ import { TooltipModule } from 'primeng/tooltip'; import { MessageService } from 'primeng/api'; import { KeycloakService } from '@app/core/services/keycloak/keycloak.service'; import { PermissionService } from '@app/core/services/permission.service'; +import { DeploymentStateTagComponent } from '../environments/deployment-state-tag/deployment-state-tag.component'; @Component({ selector: 'app-release-candidate-deployment-table', - imports: [TableModule, ButtonModule, IconsModule, SkeletonModule, TagModule, AvatarModule, OverlayBadgeModule, BadgeModule, TooltipModule], + imports: [TableModule, ButtonModule, IconsModule, SkeletonModule, TagModule, AvatarModule, OverlayBadgeModule, BadgeModule, TooltipModule, DeploymentStateTagComponent], templateUrl: './release-candidate-deployment-table.component.html', }) export class ReleaseCandidateDeploymentTableComponent { @@ -136,12 +137,8 @@ export class ReleaseCandidateDeploymentTableComponent { return 'REPLACED'; } - if (deployment.state === 'SUCCESS') { - return 'SUCCESS'; - } - - if (deployment.state === 'ERROR') { - return 'FAILURE'; + if (deployment.state !== undefined) { + return deployment.state; } return 'UNKNOWN'; }; diff --git a/client/src/icons.module.ts b/client/src/icons.module.ts index 4ed9a7a21..a1780702a 100644 --- a/client/src/icons.module.ts +++ b/client/src/icons.module.ts @@ -37,6 +37,7 @@ import { IconGitMerge, IconPoint, IconPlus, + IconRepeat, IconFilter, IconFilterPlus, IconLock, @@ -96,6 +97,7 @@ const icons = { IconQuestionMark, IconPoint, IconPlus, + IconRepeat, IconFilter, IconFilterPlus, IconLock,