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

This commit is contained in:
Gilles De Mey 2024-06-19 16:29:44 +02:00 committed by GitHub
parent 64e134c601
commit 781e394118
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,
});
}