diff --git a/public/app/features/alerting/unified/components/AlertLabels.tsx b/public/app/features/alerting/unified/components/AlertLabels.tsx index d4bbf0f5bbb..4397e56fd9e 100644 --- a/public/app/features/alerting/unified/components/AlertLabels.tsx +++ b/public/app/features/alerting/unified/components/AlertLabels.tsx @@ -1,30 +1,13 @@ -import { GrafanaTheme } from '@grafana/data'; -import { useStyles } from '@grafana/ui'; -import { css, cx } from '@emotion/css'; import React from 'react'; -import { AlertLabel } from './AlertLabel'; +import { TagList } from '@grafana/ui'; type Props = { labels: Record; className?: string }; export const AlertLabels = ({ labels, className }: Props) => { - const styles = useStyles(getStyles); const pairs = Object.entries(labels).filter(([key]) => !(key.startsWith('__') && key.endsWith('__'))); - return ( -
- {pairs.map(([key, value], index) => ( - - ))} +
+ `${label}=${value}`)} />
); }; - -const getStyles = (theme: GrafanaTheme) => ({ - wrapper: css` - & > * { - margin-bottom: ${theme.spacing.xs}; - margin-right: ${theme.spacing.xs}; - } - padding-bottom: ${theme.spacing.xs}; - `, -}); diff --git a/public/app/features/alerting/unified/components/silences/Matchers.tsx b/public/app/features/alerting/unified/components/silences/Matchers.tsx index 7b3520cec38..0d686d7027f 100644 --- a/public/app/features/alerting/unified/components/silences/Matchers.tsx +++ b/public/app/features/alerting/unified/components/silences/Matchers.tsx @@ -1,49 +1,25 @@ -import React, { useCallback } from 'react'; -import { GrafanaTheme } from '@grafana/data'; -import { useStyles } from '@grafana/ui'; +import React, { FC } from 'react'; import { css } from '@emotion/css'; +import { TagList, useStyles2 } from '@grafana/ui'; import { Matcher } from 'app/plugins/datasource/alertmanager/types'; -import { AlertLabel } from '../AlertLabel'; import { matcherToOperator } from '../../utils/alertmanager'; -type MatchersProps = { matchers: Matcher[]; onRemoveLabel?(index: number): void }; - -export const Matchers = ({ matchers, onRemoveLabel }: MatchersProps) => { - const styles = useStyles(getStyles); - - const removeLabel = useCallback( - (index: number) => { - if (!!onRemoveLabel) { - onRemoveLabel(index); - } - }, - [onRemoveLabel] - ); +type MatchersProps = { matchers: Matcher[] }; +export const Matchers: FC = ({ matchers }) => { + const styles = useStyles2(getStyles); return ( -
- {matchers.map((matcher, index) => { - const { name, value } = matcher; - return ( - removeLabel(index) : undefined} - /> - ); - })} +
+ `${matcher.name}${matcherToOperator(matcher)}${matcher.value}`)} + />
); }; -const getStyles = (theme: GrafanaTheme) => ({ - wrapper: css` - & > * { - margin-top: ${theme.spacing.xs}; - margin-right: ${theme.spacing.xs}; - } - padding-bottom: ${theme.spacing.xs}; +const getStyles = () => ({ + tags: css` + justify-content: flex-start; `, });