import { Badge } from '@/react/components/Badge';
import { Alert } from '@@/Alert';
import { HelmRelease } from '../types';
interface Props {
release: HelmRelease;
}
export enum DeploymentStatus {
DEPLOYED = 'deployed',
FAILED = 'failed',
PENDING = 'pending-install',
PENDINGUPGRADE = 'pending-upgrade',
PENDINGROLLBACK = 'pending-rollback',
SUPERSEDED = 'superseded',
UNINSTALLED = 'uninstalled',
UNINSTALLING = 'uninstalling',
}
export function HelmSummary({ release }: Props) {
const isSuccess =
release.info?.status === DeploymentStatus.DEPLOYED ||
release.info?.status === DeploymentStatus.SUPERSEDED;
return (
{getText(release.info?.status)}
{!!release.namespace && Namespace: {release.namespace}}
{!!release.version && Revision: #{release.version}}
{!!release.chart?.metadata?.name && (
Chart: {release.chart.metadata.name}
)}
{!!release.chart?.metadata?.appVersion && (
App version: {release.chart.metadata.appVersion}
)}
{!!release.chart?.metadata?.version && (
Chart version: {release.chart.metadata.name}-
{release.chart.metadata.version}
)}
{!!release.info?.description && !isSuccess && (
{release.info?.description}
)}
);
}
function getAlertColor(status?: string) {
switch (status?.toLowerCase()) {
case DeploymentStatus.DEPLOYED:
return 'success';
case DeploymentStatus.FAILED:
return 'error';
case DeploymentStatus.PENDING:
case DeploymentStatus.PENDINGUPGRADE:
case DeploymentStatus.PENDINGROLLBACK:
case DeploymentStatus.UNINSTALLING:
return 'warn';
case DeploymentStatus.SUPERSEDED:
default:
return 'info';
}
}
function getStatusColor(status?: string) {
switch (status?.toLowerCase()) {
case DeploymentStatus.DEPLOYED:
return 'success';
case DeploymentStatus.FAILED:
return 'danger';
case DeploymentStatus.PENDING:
case DeploymentStatus.PENDINGUPGRADE:
case DeploymentStatus.PENDINGROLLBACK:
case DeploymentStatus.UNINSTALLING:
return 'warn';
case DeploymentStatus.SUPERSEDED:
default:
return 'info';
}
}
function getText(status?: string) {
switch (status?.toLowerCase()) {
case DeploymentStatus.DEPLOYED:
return 'Deployed';
case DeploymentStatus.FAILED:
return 'Failed';
case DeploymentStatus.PENDING:
case DeploymentStatus.PENDINGUPGRADE:
case DeploymentStatus.PENDINGROLLBACK:
case DeploymentStatus.UNINSTALLING:
return 'Pending';
case DeploymentStatus.SUPERSEDED:
return 'Superseded';
default:
return 'Unknown';
}
}