@grafana/data#FieldConfigEditorProps TypeScript Examples

The following examples show how to use @grafana/data#FieldConfigEditorProps. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: links.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
DataLinksValueEditor: React.FC<FieldConfigEditorProps<DataLink[], DataLinksFieldConfigSettings>> = ({
  value,
  onChange,
  context,
}) => {
  return (
    <DataLinksInlineEditor
      links={value}
      onChange={onChange}
      data={context.data}
      suggestions={context.getSuggestions ? context.getSuggestions() : []}
    />
  );
}
Example #2
Source File: mappings.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
export class ValueMappingsValueEditor extends React.PureComponent<
  FieldConfigEditorProps<ValueMapping[], ValueMappingFieldConfigSettings>
> {
  constructor(props: FieldConfigEditorProps<ValueMapping[], ValueMappingFieldConfigSettings>) {
    super(props);
  }

  render() {
    const { onChange } = this.props;
    let value = this.props.value;
    if (!value) {
      value = [];
    }

    return <ValueMappingsEditor valueMappings={value} onChange={onChange} />;
  }
}
Example #3
Source File: number.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
NumberValueEditor: React.FC<FieldConfigEditorProps<number, NumberFieldConfigSettings>> = ({
  value,
  onChange,
  item,
}) => {
  const { settings } = item;
  return (
    <Forms.Input
      value={isNaN(value) ? '' : value}
      min={settings.min}
      max={settings.max}
      type="number"
      step={settings.step}
      placeholder={settings.placeholder}
      onChange={e => {
        onChange(
          settings.integer ? toIntegerOrUndefined(e.currentTarget.value) : toFloatOrUndefined(e.currentTarget.value)
        );
      }}
    />
  );
}
Example #4
Source File: thresholds.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
export class ThresholdsValueEditor extends React.PureComponent<
  FieldConfigEditorProps<ThresholdsConfig, ThresholdsFieldConfigSettings>
> {
  constructor(props: FieldConfigEditorProps<ThresholdsConfig, ThresholdsFieldConfigSettings>) {
    super(props);
  }

  render() {
    const { onChange } = this.props;
    let value = this.props.value;
    if (!value) {
      value = {
        mode: ThresholdsMode.Percentage,

        // Must be sorted by 'value', first value is always -Infinity
        steps: [
          // anything?
        ],
      };
    }

    return <ThresholdsEditor thresholds={value} onChange={onChange} />;
  }
}
Example #5
Source File: mappings.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
constructor(props: FieldConfigEditorProps<ValueMapping[], ValueMappingFieldConfigSettings>) {
    super(props);
  }
Example #6
Source File: select.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
SelectValueEditor: FC<FieldConfigEditorProps<string, SelectFieldConfigSettings<any>>> = ({
  item,
  value,
  onChange,
}) => {
  return <Forms.Select value={value || ''} onChange={e => onChange(e.value)} options={item.settings.options} />;
}
Example #7
Source File: string.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
StringValueEditor: React.FC<FieldConfigEditorProps<string, StringFieldConfigSettings>> = ({
  value,
  onChange,
}) => {
  return <Forms.Input value={value || ''} onChange={e => onChange(e.currentTarget.value)} />;
}
Example #8
Source File: thresholds.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
constructor(props: FieldConfigEditorProps<ThresholdsConfig, ThresholdsFieldConfigSettings>) {
    super(props);
  }
Example #9
Source File: units.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
UnitValueEditor: React.FC<FieldConfigEditorProps<string, UnitFieldConfigSettings>> = ({
  value,
  onChange,
}) => {
  return <UnitPicker value={value} onChange={onChange} useNewForms />;
}