Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { i18n } from '@kbn/i18n';
import type { EuiThemeComputed } from '@elastic/eui';
import { ML_ANOMALY_SEVERITY } from '@kbn/ml-anomaly-utils/anomaly_severity';
import type { NamedColor } from '@elastic/eui/src/components/icon/named_colors';

export enum ServiceHealthStatus {
healthy = 'healthy',
Expand Down Expand Up @@ -50,19 +51,16 @@ export function getServiceHealthStatusColor(
}
}

export function getServiceHealthStatusBadgeColor(
euiTheme: EuiThemeComputed,
status: ServiceHealthStatus
) {
export function getServiceHealthStatusBadgeColor(status: ServiceHealthStatus): NamedColor {
switch (status) {
case ServiceHealthStatus.healthy:
return euiTheme.colors.severity.success;
return 'success';
case ServiceHealthStatus.warning:
return euiTheme.colors.severity.warning;
return 'warning';
case ServiceHealthStatus.critical:
return euiTheme.colors.severity.risk;
return 'danger';
case ServiceHealthStatus.unknown:
return euiTheme.colors.mediumShade;
return 'default';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
*/

import React from 'react';
import { EuiBadge, useEuiTheme } from '@elastic/eui';
import { EuiBadge } from '@elastic/eui';
import type { ServiceHealthStatus } from '../../../../../common/service_health_status';
import {
getServiceHealthStatusBadgeColor,
getServiceHealthStatusLabel,
} from '../../../../../common/service_health_status';

export function HealthBadge({ healthStatus }: { healthStatus: ServiceHealthStatus }) {
const { euiTheme } = useEuiTheme();

return (
<EuiBadge color={getServiceHealthStatusBadgeColor(euiTheme, healthStatus)}>
<EuiBadge color={getServiceHealthStatusBadgeColor(healthStatus)}>
{getServiceHealthStatusLabel(healthStatus)}
</EuiBadge>
);
Expand Down
Loading