From 59c2ffec0b4230e34d0ee1e16b119e9bd3ac1da7 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Wed, 12 Jan 2022 14:16:51 +0100 Subject: [PATCH] Alerting: manual backport of #43367 --- .../unified/components/rules/ActionIcon.tsx | 37 ++++++++++++++----- .../silences/SilencedAlertsTable.tsx | 2 - .../silences/SilencedAlertsTableRow.tsx | 7 ---- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/public/app/features/alerting/unified/components/rules/ActionIcon.tsx b/public/app/features/alerting/unified/components/rules/ActionIcon.tsx index dee4d21887a..eeff5435a16 100644 --- a/public/app/features/alerting/unified/components/rules/ActionIcon.tsx +++ b/public/app/features/alerting/unified/components/rules/ActionIcon.tsx @@ -34,20 +34,37 @@ export const ActionIcon: FC = ({ const ariaLabel = typeof tooltip === 'string' ? tooltip : undefined; return ( - {(() => { - if (to) { - return ( - - {iconEl} - - ); - } - return iconEl; - })()} + {to ? ( + + {iconEl} + + ) : ( + iconEl + )} ); }; +interface GoToProps { + url: string; + label?: string; + target?: string; +} + +const GoTo: FC = ({ url, label, target, children }) => { + const absoluteUrl = url?.startsWith('http'); + + return absoluteUrl ? ( + + {children} + + ) : ( + + {children} + + ); +}; + export const getStyle = () => css` cursor: pointer; `; diff --git a/public/app/features/alerting/unified/components/silences/SilencedAlertsTable.tsx b/public/app/features/alerting/unified/components/silences/SilencedAlertsTable.tsx index 0fc2376367a..14b08b8dc8f 100644 --- a/public/app/features/alerting/unified/components/silences/SilencedAlertsTable.tsx +++ b/public/app/features/alerting/unified/components/silences/SilencedAlertsTable.tsx @@ -22,7 +22,6 @@ const SilencedAlertsTable: FC = ({ silencedAlerts }) => { - @@ -30,7 +29,6 @@ const SilencedAlertsTable: FC = ({ silencedAlerts }) => { State Alert name - Actions diff --git a/public/app/features/alerting/unified/components/silences/SilencedAlertsTableRow.tsx b/public/app/features/alerting/unified/components/silences/SilencedAlertsTableRow.tsx index 9cdb73ec3d1..3b14a25436b 100644 --- a/public/app/features/alerting/unified/components/silences/SilencedAlertsTableRow.tsx +++ b/public/app/features/alerting/unified/components/silences/SilencedAlertsTableRow.tsx @@ -1,9 +1,6 @@ import { AlertmanagerAlert } from 'app/plugins/datasource/alertmanager/types'; import React, { FC, useState } from 'react'; import { CollapseToggle } from '../CollapseToggle'; -import { ActionIcon } from '../rules/ActionIcon'; -import { getAlertTableStyles } from '../../styles/table'; -import { useStyles2 } from '@grafana/ui'; import { intervalToAbbreviatedDurationString } from '@grafana/data'; import { AlertLabels } from '../AlertLabels'; import { AmAlertStateTag } from './AmAlertStateTag'; @@ -15,7 +12,6 @@ interface Props { export const SilencedAlertsTableRow: FC = ({ alert, className }) => { const [isCollapsed, setIsCollapsed] = useState(true); - const tableStyles = useStyles2(getAlertTableStyles); const duration = intervalToAbbreviatedDurationString({ start: new Date(alert.startsAt), @@ -38,9 +34,6 @@ export const SilencedAlertsTableRow: FC = ({ alert, className }) => { for {duration} seconds {alertName} - - - {!isCollapsed && (