mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 04:04:00 -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}>
|
<div className={styles.wrapper}>
|
||||||
<TabsBar className={styles.tabBar} hideBorder>
|
<TabsBar className={styles.tabBar} hideBorder>
|
||||||
{tabs.map((tab) => {
|
{tabs.map((tab) => {
|
||||||
if (config.unifiedAlertingEnabled && tab.id === PanelEditorTabId.Alert) {
|
if (tab.id === PanelEditorTabId.Alert) {
|
||||||
return (
|
renderAlertTab(tab, panel, dashboard, onChangeTab);
|
||||||
<PanelAlertTab
|
|
||||||
key={tab.id}
|
|
||||||
label={tab.text}
|
|
||||||
active={tab.active}
|
|
||||||
onChangeTab={() => onChangeTab(tab)}
|
|
||||||
icon={tab.icon as IconName}
|
|
||||||
panel={panel}
|
|
||||||
dashboard={dashboard}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Tab
|
<Tab
|
||||||
@ -90,6 +80,42 @@ function getCounter(panel: PanelModel, tab: PanelEditorTab) {
|
|||||||
return null;
|
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) => {
|
const getStyles = (theme: GrafanaTheme2) => {
|
||||||
return {
|
return {
|
||||||
wrapper: css`
|
wrapper: css`
|
||||||
|
Loading…
Reference in New Issue
Block a user