module.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React, { useMemo } from 'react';
  2. import { PanelPlugin } from '@grafana/data';
  3. import { AlertManagerPicker } from 'app/features/alerting/unified/components/AlertManagerPicker';
  4. import {
  5. getAllAlertManagerDataSources,
  6. GRAFANA_RULES_SOURCE_NAME,
  7. } from 'app/features/alerting/unified/utils/datasource';
  8. import { AlertGroupsPanel } from './AlertGroupsPanel';
  9. import { AlertGroupPanelOptions } from './types';
  10. export const plugin = new PanelPlugin<AlertGroupPanelOptions>(AlertGroupsPanel).setPanelOptions((builder) => {
  11. return builder
  12. .addCustomEditor({
  13. name: 'Alertmanager',
  14. path: 'alertmanager',
  15. id: 'alertmanager',
  16. defaultValue: GRAFANA_RULES_SOURCE_NAME,
  17. category: ['Options'],
  18. editor: function RenderAlertmanagerPicker(props) {
  19. const alertManagers = useMemo(getAllAlertManagerDataSources, []);
  20. return (
  21. <AlertManagerPicker
  22. current={props.value}
  23. onChange={(alertManagerSourceName) => {
  24. return props.onChange(alertManagerSourceName);
  25. }}
  26. dataSources={alertManagers}
  27. />
  28. );
  29. },
  30. })
  31. .addBooleanSwitch({
  32. name: 'Expand all by default',
  33. path: 'expandAll',
  34. defaultValue: false,
  35. category: ['Options'],
  36. })
  37. .addTextInput({
  38. description: 'Filter results by matching labels, ex: env=production,severity=~critical|warning',
  39. name: 'Labels',
  40. path: 'labels',
  41. category: ['Filter'],
  42. });
  43. });