ConfigEditor.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React from 'react';
  2. import { DataSourcePluginOptionsEditorProps, SelectableValue } from '@grafana/data';
  3. import { DataSourceHttpSettings, InlineFormLabel, Select } from '@grafana/ui';
  4. import { AlertManagerDataSourceJsonData, AlertManagerImplementation } from './types';
  5. export type Props = DataSourcePluginOptionsEditorProps<AlertManagerDataSourceJsonData>;
  6. const IMPL_OPTIONS: SelectableValue[] = [
  7. {
  8. value: AlertManagerImplementation.mimir,
  9. icon: 'public/img/alerting/mimir_logo.svg',
  10. label: 'Mimir',
  11. description: `https://grafana.com/oss/mimir/. An open source, horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.`,
  12. },
  13. {
  14. value: AlertManagerImplementation.cortex,
  15. label: 'Cortex',
  16. description: `https://cortexmetrics.io/`,
  17. },
  18. {
  19. value: AlertManagerImplementation.prometheus,
  20. label: 'Prometheus',
  21. description:
  22. 'https://prometheus.io/. Does not support editing configuration via API, so contact points and notification policies are read-only.',
  23. },
  24. ];
  25. export const ConfigEditor: React.FC<Props> = ({ options, onOptionsChange }) => {
  26. return (
  27. <>
  28. <h3 className="page-heading">Alertmanager</h3>
  29. <div className="gf-form-group">
  30. <div className="gf-form-inline">
  31. <div className="gf-form">
  32. <InlineFormLabel width={13}>Implementation</InlineFormLabel>
  33. <Select
  34. width={40}
  35. options={IMPL_OPTIONS}
  36. value={options.jsonData.implementation || AlertManagerImplementation.mimir}
  37. onChange={(value) =>
  38. onOptionsChange({
  39. ...options,
  40. jsonData: {
  41. ...options.jsonData,
  42. implementation: value.value as AlertManagerImplementation,
  43. },
  44. })
  45. }
  46. />
  47. </div>
  48. </div>
  49. </div>
  50. <DataSourceHttpSettings
  51. defaultUrl={''}
  52. dataSourceConfig={options}
  53. showAccessOptions={true}
  54. onChange={onOptionsChange}
  55. />
  56. </>
  57. );
  58. };