[v11.1.x] Alerting: Skip loading alert rules for dashboards when disabled (#89905)

Alerting: Skip loading alert rules for dashboards when disabled (#89361)

(cherry picked from commit 781e394118)

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-07-01 13:36:39 +03:00
committed by GitHub
co-authored by Gilles De Mey
parent fbcdaccb6d
commit 244d0cf46a
@@ -14,15 +14,17 @@ const AlertRulesToolbarButton = React.lazy(
export function initAlerting() {
const grafanaRulesPermissions = getRulesPermissions(GRAFANA_RULES_SOURCE_NAME);
const alertingEnabled = config.unifiedAlertingEnabled;
if (contextSrv.hasPermission(grafanaRulesPermissions.read)) {
addCustomRightAction({
show: () => config.unifiedAlertingEnabled,
component: ({ dashboard }) => (
<React.Suspense fallback={null} key="alert-rules-button">
{dashboard && <AlertRulesToolbarButton dashboardUid={dashboard.uid} />}
</React.Suspense>
),
show: () => alertingEnabled,
component: ({ dashboard }) =>
alertingEnabled ? (
<React.Suspense fallback={null} key="alert-rules-button">
{dashboard && <AlertRulesToolbarButton dashboardUid={dashboard.uid} />}
</React.Suspense>
) : null,
index: -2,
});
}