mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* 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
26 lines
750 B
TypeScript
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} />
|
|
)}
|
|
</>
|
|
);
|
|
}
|