Files
Tom Ratcliffe 4f7ffafe98 Alerting: Consistently order member imports in alerting code (#97688)
* Lint import member orders within alerting

* Consistently order member imports in alerting code
2024-12-10 17:42:33 +00:00

32 lines
1.1 KiB
TypeScript

import { Suspense, lazy } from 'react';
import { config } from '@grafana/runtime';
import { contextSrv } from 'app/core/services/context_srv';
import { addCustomRightAction } from '../../dashboard/components/DashNav/DashNav';
import { getRulesPermissions } from './utils/access-control';
import { GRAFANA_RULES_SOURCE_NAME } from './utils/datasource';
const AlertRulesToolbarButton = lazy(
() => import(/* webpackChunkName: "alert-rules-toolbar-button" */ './integration/AlertRulesToolbarButton')
);
export function initAlerting() {
const grafanaRulesPermissions = getRulesPermissions(GRAFANA_RULES_SOURCE_NAME);
const alertingEnabled = config.unifiedAlertingEnabled;
if (contextSrv.hasPermission(grafanaRulesPermissions.read)) {
addCustomRightAction({
show: () => alertingEnabled,
component: ({ dashboard }) =>
alertingEnabled ? (
<Suspense fallback={null} key="alert-rules-button">
{dashboard && <AlertRulesToolbarButton dashboardUid={dashboard.uid} />}
</Suspense>
) : null,
index: -2,
});
}
}