From dda84dbf1a7c637333e7b739d3dc0353d4828e1b Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 20 Dec 2021 15:30:31 +0100 Subject: [PATCH] Alerting: Fixed logic on how to render alert tab (#43339) * fixed logic on how to render alert tab * remove console logs move some logic --- .../PanelEditor/PanelEditorTabs.tsx | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/public/app/features/dashboard/components/PanelEditor/PanelEditorTabs.tsx b/public/app/features/dashboard/components/PanelEditor/PanelEditorTabs.tsx index bc6a30ac454..1c04cfc2473 100644 --- a/public/app/features/dashboard/components/PanelEditor/PanelEditorTabs.tsx +++ b/public/app/features/dashboard/components/PanelEditor/PanelEditorTabs.tsx @@ -40,18 +40,8 @@ export const PanelEditorTabs: FC = React.memo(({ panel, da
{tabs.map((tab) => { - if (config.unifiedAlertingEnabled && tab.id === PanelEditorTabId.Alert) { - return ( - onChangeTab(tab)} - icon={tab.icon as IconName} - panel={panel} - dashboard={dashboard} - /> - ); + if (tab.id === PanelEditorTabId.Alert) { + renderAlertTab(tab, panel, dashboard, onChangeTab); } return ( void +) { + if (!config.alertingEnabled || !config.unifiedAlertingEnabled) { + return null; + } else if (config.unifiedAlertingEnabled) { + return ( + onChangeTab(tab)} + icon={tab.icon as IconName} + panel={panel} + dashboard={dashboard} + /> + ); + } else if (config.alertingEnabled) { + return ( + onChangeTab(tab)} + icon={tab.icon as IconName} + counter={getCounter(panel, tab)} + /> + ); + } + + return null; +} + const getStyles = (theme: GrafanaTheme2) => { return { wrapper: css`