The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/panel/canvas/module.tsx

60 lines
1.8 KiB

import { FieldConfigProperty, PanelOptionsEditorBuilder, PanelPlugin } from '@grafana/data';
import { FrameState } from 'app/features/canvas/runtime/frame';
import { CanvasPanel, InstanceState } from './CanvasPanel';
import { getElementEditor } from './editor/elementEditor';
import { getLayerEditor } from './editor/layerEditor';
import { canvasMigrationHandler } from './migrations';
import { PanelOptions } from './models.gen';
export const addStandardCanvasEditorOptions = (builder: PanelOptionsEditorBuilder<PanelOptions>) => {
builder.addBooleanSwitch({
path: 'inlineEditing',
name: 'Inline editing',
description: 'Enable editing the panel directly',
defaultValue: true,
});
builder.addBooleanSwitch({
path: 'showAdvancedTypes',
name: 'Show advanced element types',
description: '',
defaultValue: false,
});
};
export const plugin = new PanelPlugin<PanelOptions>(CanvasPanel)
.setNoPadding() // extend to panel edges
.useFieldConfig({
standardOptions: {
[FieldConfigProperty.Mappings]: {
settings: {
icon: true,
},
},
},
})
.setMigrationHandler(canvasMigrationHandler)
.setPanelOptions((builder, context) => {
const state: InstanceState = context.instanceState;
addStandardCanvasEditorOptions(builder);
if (state) {
builder.addNestedOptions(getLayerEditor(state));
const selection = state.selected;
if (selection?.length === 1) {
const element = selection[0];
if (!(element instanceof FrameState)) {
builder.addNestedOptions(
getElementEditor({
category: [`Selected element (${element.options.name})`],
element,
scene: state.scene,
})
);
}
}
}
});