diff --git a/CHANGELOG.md b/CHANGELOG.md index 752c8f8caf9..b920883ffff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 6.2.0 (unreleased) +### Breaking changes + +* **Gauge Panel**: The suffix / prefix options have been removed from the new Guage Panel (introduced in v6.0). [#16870](https://github.com/grafana/grafana/issues/16870). + # 6.1.6 (2019-04-29) ### Features / Enhancements * **Security**: Bump jQuery to 3.4.0 . [#16761](https://github.com/grafana/grafana/pull/16761), [@dprokop](https://github.com/dprokop) diff --git a/packages/grafana-ui/src/components/SingleStatShared/FieldDisplayEditor.tsx b/packages/grafana-ui/src/components/SingleStatShared/FieldDisplayEditor.tsx new file mode 100644 index 00000000000..fccf211004d --- /dev/null +++ b/packages/grafana-ui/src/components/SingleStatShared/FieldDisplayEditor.tsx @@ -0,0 +1,98 @@ +// Libraries +import React, { PureComponent, ChangeEvent } from 'react'; + +// Components +import { FormField, FormLabel, PanelOptionsGroup, StatsPicker, ReducerID } from '@grafana/ui'; + +// Types +import { FieldDisplayOptions, DEFAULT_FIELD_DISPLAY_VALUES_LIMIT } from '../../utils/fieldDisplay'; +import { Field } from '../../types/data'; +import Select, { SelectOptionItem } from '../Select/Select'; +import { toNumberString, toIntegerOrUndefined } from '../../utils'; + +const showOptions: Array> = [ + { + value: true, + label: 'All Values', + description: 'Each row in the response data', + }, + { + value: false, + label: 'Calculation', + description: 'Calculate a value based on the response', + }, +]; + +export interface Props { + options: FieldDisplayOptions; + onChange: (valueOptions: FieldDisplayOptions) => void; + labelWidth?: number; + children?: JSX.Element[]; +} + +export class FieldDisplayEditor extends PureComponent { + onShowValuesChange = (item: SelectOptionItem) => { + const val = item.value === true; + this.props.onChange({ ...this.props.options, values: val }); + }; + + onCalcsChange = (calcs: string[]) => { + this.props.onChange({ ...this.props.options, calcs }); + }; + + onDefaultsChange = (value: Partial) => { + this.props.onChange({ ...this.props.options, defaults: value }); + }; + + onLimitChange = (event: ChangeEvent) => { + this.props.onChange({ + ...this.props.options, + limit: toIntegerOrUndefined(event.target.value), + }); + }; + + render() { + const { options, children } = this.props; + const { calcs, values, limit } = options; + + const labelWidth = this.props.labelWidth || 5; + + return ( + + <> +
+ Show +
- Display Mode + Mode