import type { FC } from 'react'; import type { InstanceInsightsSchemaProjectFlagTrendsItem } from 'openapi'; import { Box, Divider, Paper, Typography, styled } from '@mui/material'; import { Badge } from 'component/common/Badge/Badge'; import type { TooltipState } from 'component/insights/components/LineChart/ChartTooltip/ChartTooltip'; import { HorizontalDistributionChart } from 'component/insights/components/HorizontalDistributionChart/HorizontalDistributionChart'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { getTechnicalDebtColor } from 'utils/getTechnicalDebtColor.ts'; const StyledTooltipItemContainer = styled(Paper)(({ theme }) => ({ padding: theme.spacing(2), })); const StyledItemHeader = styled(Box)(({ theme }) => ({ display: 'flex', justifyContent: 'space-between', gap: theme.spacing(2), alignItems: 'center', })); const getTechnicalDebtBadgeColor = (technicalDebt?: number | null) => { if (technicalDebt === undefined || technicalDebt === null) { return 'info'; } return getTechnicalDebtColor(technicalDebt); }; const Distribution = ({ stale = 0, potentiallyStale = 0, total = 0 }) => { const healthyFlagCount = total - stale - potentiallyStale; return ( <> ({ marginTop: theme.spacing(0.5) })} > ({ color: theme.palette.error.border, })} > {'● '} Stale flags: {stale} ({ color: theme.palette.warning.border, })} > {'● '} Potentially stale flags: {potentiallyStale} ({ color: theme.palette.success.border, })} > {'● '} Healthy flags: {healthyFlagCount} ); }; export const HealthTooltip: FC<{ tooltip: TooltipState | null }> = ({ tooltip, }) => { const data = tooltip?.dataPoints.map((point) => { return { label: point.label, title: point.dataset.label, color: point.dataset.borderColor, value: point.raw as InstanceInsightsSchemaProjectFlagTrendsItem, }; }); const limitedData = data?.slice(0, 5); return ( ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(2), width: '300px', })} > {limitedData?.map((point, index) => ( {point.label} Technical debt {'● '} {point.title} {point.value.technicalDebt}% {' '} ({ margin: theme.spacing(1.5, 0) })} /> ({ marginBottom: theme.spacing(0.5), })} > Total flags: {point.value.total} } /> )) || null} ); };