Alerting: List V2 - Add labels popup (#107193)

* Display labels popup when hovering over labels count

* Remove unused imports
pull/107162/head^2
Konrad Lalik 2 days ago committed by GitHub
parent 2bcc1d86fc
commit ea1d3cc3ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 37
      public/app/features/alerting/unified/rule-list/components/AlertRuleListItem.tsx

@ -9,6 +9,7 @@ import { Rule, RuleGroupIdentifierV2, RuleHealth, RulesSourceIdentifier } from '
import { Labels, PromAlertingRuleState, RulerRuleDTO, RulesSourceApplication } from 'app/types/unified-alerting-dto';
import { logError } from '../../Analytics';
import { AlertLabels } from '../../components/AlertLabels';
import { MetaText } from '../../components/MetaText';
import { ProvisioningBadge } from '../../components/Provisioning';
import { PluginOriginBadge } from '../../plugins/PluginOriginBadge';
@ -103,12 +104,10 @@ export const AlertRuleListItem = (props: AlertRuleListItemProps) => {
}
}
if (labelsSize(labels) > 0) {
if (labels && labelsSize(labels) > 0) {
metadata.push(
<MetaText icon="tag-alt">
<TextLink href={href} variant="bodySmall" color="primary" inline={false}>
{pluralize('label', labelsSize(labels), true)}
</TextLink>
<RuleLabels labels={labels} />
</MetaText>
);
}
@ -271,6 +270,28 @@ function Summary({ content, error }: SummaryProps) {
return null;
}
function RuleLabels({ labels }: { labels: Labels }) {
const styles = useStyles2(getStyles);
return (
<Tooltip
content={
<div className={styles.ruleLabels.tooltip}>
<AlertLabels labels={labels} size="sm" />
</div>
}
placement="right"
interactive
>
<div>
<Text variant="bodySmall" color="primary">
{pluralize('label', labelsSize(labels), true)}
</Text>
</div>
</Tooltip>
);
}
interface EvaluationMetadataProps {
lastEvaluation?: string;
evaluationInterval?: string;
@ -391,6 +412,14 @@ const getStyles = (theme: GrafanaTheme2) => ({
resetMargin: css({
margin: 0,
}),
ruleLabels: {
tooltip: css({
padding: theme.spacing(1),
}),
text: css({
cursor: 'pointer',
}),
},
});
export type RuleListItemCommonProps = Pick<

Loading…
Cancel
Save