grafana/public/app/plugins/panel/alertGroups/module.tsx
sam boyer 33fd83f7e3
kindsys: Adapt to new PanelCfg schema interface (#65297)
* kindsys: Adapt to new PanelCfg schema interface

* building locally

* Remove Panel prefix in cue files

* Regenerate

* Update imports

* fixup! Merge branch 'remove-panel-prefix' into sdboyer/redundant-panelcfg-prefixes

* Fix formatting

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Tania B <yalyna.ts@gmail.com>
2023-05-15 23:07:54 -04:00

48 lines
1.4 KiB
TypeScript

import React, { useMemo } from 'react';
import { PanelPlugin } from '@grafana/data';
import { AlertManagerPicker } from 'app/features/alerting/unified/components/AlertManagerPicker';
import {
getAllAlertManagerDataSources,
GRAFANA_RULES_SOURCE_NAME,
} from 'app/features/alerting/unified/utils/datasource';
import { AlertGroupsPanel } from './AlertGroupsPanel';
import { Options } from './panelcfg.gen';
export const plugin = new PanelPlugin<Options>(AlertGroupsPanel).setPanelOptions((builder) => {
return builder
.addCustomEditor({
name: 'Alertmanager',
path: 'alertmanager',
id: 'alertmanager',
defaultValue: GRAFANA_RULES_SOURCE_NAME,
category: ['Options'],
editor: function RenderAlertmanagerPicker(props) {
const alertManagers = useMemo(getAllAlertManagerDataSources, []);
return (
<AlertManagerPicker
current={props.value}
onChange={(alertManagerSourceName) => {
return props.onChange(alertManagerSourceName);
}}
dataSources={alertManagers}
/>
);
},
})
.addBooleanSwitch({
name: 'Expand all by default',
path: 'expandAll',
defaultValue: false,
category: ['Options'],
})
.addTextInput({
description: 'Filter results by matching labels, ex: env=production,severity=~critical|warning',
name: 'Labels',
path: 'labels',
category: ['Filter'],
});
});