mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 03:11:49 +08:00

* Lint import member orders within alerting * Consistently order member imports in alerting code
32 lines
1.1 KiB
TypeScript
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,
|
|
});
|
|
}
|
|
}
|