Files
grafana/public/app/features/alerting/unified/integration/AlertRulesDrawerContent.tsx
Sonia Aguilar 4b720206d4 Alerting: Reduce number of request fetching rules in the dashboard view using rtkq (#86991)
* Reduce number of request fetching rules in the dashboard view using rtkq

* Fix UnifiedAlertStatesWorker work

* refactor ungroupRulesByFileName

* Address review comments and fix test

* fix DashboardQueryRunner test

* Fix tests

* Update AlertStatesDataLayer to use RTKQ

* Fix PanelAlertTabContent test

* Fix PanelAlertTabContent test after adding RTKQ

* fix test and address PR review comments

* Update useCombinedRuleNamespaces to have both dashboardUID and panelId as optional params and rename the hook

* Address review pr comment

* remove test about template variables

* Use poll interval in useCombinedRules
2024-05-10 12:27:06 +02:00

26 lines
750 B
TypeScript

import React from 'react';
import { LoadingPlaceholder } from '@grafana/ui';
import { RulesTable } from '../components/rules/RulesTable';
import { useCombinedRules } from '../hooks/useCombinedRuleNamespaces';
interface Props {
dashboardUid: string;
}
export default function AlertRulesDrawerContent({ dashboardUid }: Props) {
const { loading, result: grafanaNamespaces } = useCombinedRules(dashboardUid);
const rules = grafanaNamespaces ? grafanaNamespaces.flatMap((ns) => ns.groups).flatMap((g) => g.rules) : [];
return (
<>
{loading ? (
<LoadingPlaceholder text="Loading alert rules" />
) : (
<RulesTable rules={rules} showNextEvaluationColumn={false} showGroupColumn={false} />
)}
</>
);
}