mirror of
https://github.com/grafana/grafana.git
synced 2025-09-22 23:53:09 +08:00
31 lines
858 B
TypeScript
31 lines
858 B
TypeScript
import { GrafanaTheme } from '@grafana/data';
|
|
import { useStyles } from '@grafana/ui';
|
|
import { css } from '@emotion/css';
|
|
import React from 'react';
|
|
import { AlertLabel } from './AlertLabel';
|
|
|
|
type Props = { labels: Record<string, string> };
|
|
|
|
export const AlertLabels = ({ labels }: Props) => {
|
|
const styles = useStyles(getStyles);
|
|
const pairs = Object.entries(labels).filter(([key]) => !(key.startsWith('__') && key.endsWith('__')));
|
|
|
|
return (
|
|
<div className={styles.wrapper}>
|
|
{pairs.map(([key, value], index) => (
|
|
<AlertLabel key={`${key}-${value}-${index}`} labelKey={key} value={value} />
|
|
))}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const getStyles = (theme: GrafanaTheme) => ({
|
|
wrapper: css`
|
|
& > * {
|
|
margin-top: ${theme.spacing.xs};
|
|
margin-right: ${theme.spacing.xs};
|
|
}
|
|
padding-bottom: ${theme.spacing.xs};
|
|
`,
|
|
});
|