mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
Alerting: Fixed logic on how to render alert tab (#43339)
* fixed logic on how to render alert tab * remove console logs move some logic
This commit is contained in:
parent
18fdb89554
commit
dda84dbf1a
@ -40,18 +40,8 @@ export const PanelEditorTabs: FC<PanelEditorTabsProps> = React.memo(({ panel, da
|
||||
<div className={styles.wrapper}>
|
||||
<TabsBar className={styles.tabBar} hideBorder>
|
||||
{tabs.map((tab) => {
|
||||
if (config.unifiedAlertingEnabled && tab.id === PanelEditorTabId.Alert) {
|
||||
return (
|
||||
<PanelAlertTab
|
||||
key={tab.id}
|
||||
label={tab.text}
|
||||
active={tab.active}
|
||||
onChangeTab={() => onChangeTab(tab)}
|
||||
icon={tab.icon as IconName}
|
||||
panel={panel}
|
||||
dashboard={dashboard}
|
||||
/>
|
||||
);
|
||||
if (tab.id === PanelEditorTabId.Alert) {
|
||||
renderAlertTab(tab, panel, dashboard, onChangeTab);
|
||||
}
|
||||
return (
|
||||
<Tab
|
||||
@ -90,6 +80,42 @@ function getCounter(panel: PanelModel, tab: PanelEditorTab) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function renderAlertTab(
|
||||
tab: PanelEditorTab,
|
||||
panel: PanelModel,
|
||||
dashboard: DashboardModel,
|
||||
onChangeTab: (tab: PanelEditorTab) => void
|
||||
) {
|
||||
if (!config.alertingEnabled || !config.unifiedAlertingEnabled) {
|
||||
return null;
|
||||
} else if (config.unifiedAlertingEnabled) {
|
||||
return (
|
||||
<PanelAlertTab
|
||||
key={tab.id}
|
||||
label={tab.text}
|
||||
active={tab.active}
|
||||
onChangeTab={() => onChangeTab(tab)}
|
||||
icon={tab.icon as IconName}
|
||||
panel={panel}
|
||||
dashboard={dashboard}
|
||||
/>
|
||||
);
|
||||
} else if (config.alertingEnabled) {
|
||||
return (
|
||||
<Tab
|
||||
key={tab.id}
|
||||
label={tab.text}
|
||||
active={tab.active}
|
||||
onChangeTab={() => onChangeTab(tab)}
|
||||
icon={tab.icon as IconName}
|
||||
counter={getCounter(panel, tab)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => {
|
||||
return {
|
||||
wrapper: css`
|
||||
|
Loading…
Reference in New Issue
Block a user