module.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { FieldConfigProperty, PanelPlugin } from '@grafana/data';
  2. import { CanvasElementOptions } from 'app/features/canvas';
  3. import { IconConfig, iconItem } from 'app/features/canvas/elements/icon';
  4. import { optionBuilder } from '../canvas/editor/options';
  5. import { IconPanel } from './IconPanel';
  6. import { defaultPanelOptions, PanelOptions } from './models.gen';
  7. export const plugin = new PanelPlugin<PanelOptions>(IconPanel)
  8. .setNoPadding() // extend to panel edges
  9. .useFieldConfig({
  10. standardOptions: {
  11. [FieldConfigProperty.Mappings]: {
  12. settings: {
  13. icon: true,
  14. },
  15. },
  16. },
  17. })
  18. .setPanelOptions((builder) => {
  19. builder.addNestedOptions<CanvasElementOptions<IconConfig>>({
  20. category: ['Icon'],
  21. path: 'root',
  22. // Dynamically fill the selected element
  23. build: (builder, ctx) => {
  24. iconItem.registerOptionsUI!(builder, ctx);
  25. optionBuilder.addBackground(builder, ctx);
  26. optionBuilder.addBorder(builder, ctx);
  27. },
  28. defaultValue: defaultPanelOptions.root as any,
  29. });
  30. });