import React, { FC, useCallback } from 'react'; import { FieldNamePickerConfigSettings, StandardEditorProps, StandardEditorsRegistryItem, StringFieldConfigSettings, } from '@grafana/data'; import { Button, InlineField, InlineFieldRow, RadioButtonGroup, StringValueEditor } from '@grafana/ui'; import { FieldNamePicker } from '../../../../../packages/grafana-ui/src/components/MatchersUI/FieldNamePicker'; import { TextDimensionConfig, TextDimensionMode, TextDimensionOptions } from '../types'; const textOptions = [ { label: 'Fixed', value: TextDimensionMode.Fixed, description: 'Fixed value' }, { label: 'Field', value: TextDimensionMode.Field, description: 'Display field value' }, // { label: 'Template', value: TextDimensionMode.Template, description: 'use template text' }, ]; const dummyFieldSettings: StandardEditorsRegistryItem = { settings: {}, } as any; const dummyStringSettings: StandardEditorsRegistryItem = { settings: {}, } as any; export const TextDimensionEditor: FC> = (props) => { const { value, context, onChange } = props; const labelWidth = 9; const onModeChange = useCallback( (mode) => { onChange({ ...value, mode, }); }, [onChange, value] ); const onFieldChange = useCallback( (field) => { onChange({ ...value, field, }); }, [onChange, value] ); const onFixedChange = useCallback( (fixed) => { onChange({ ...value, fixed, }); }, [onChange, value] ); const onClearFixedText = () => { // Need to first change to field in order to clear fixed value in editor onChange({ mode: TextDimensionMode.Field, fixed: '', field: '' }); onChange({ mode: TextDimensionMode.Fixed, fixed: '', field: '' }); }; const mode = value?.mode ?? TextDimensionMode.Fixed; return ( <> {mode !== TextDimensionMode.Fixed && ( )} {mode === TextDimensionMode.Fixed && ( <> {value?.fixed && (