value formats: another rename and updates code to use new valueFormats func

This commit is contained in:
Torkel Ödegaard 2019-01-11 13:31:25 +01:00
parent 8aae6e8c09
commit 9e6411bf4b
13 changed files with 14 additions and 12 deletions

View File

@ -1,2 +1,2 @@
export * from './processTimeSeries';
export * from './value_formats/valueFormats';
export * from './valueFormats/valueFormats';

View File

@ -158,7 +158,7 @@ export function getValueFormats() {
submenu: cat.formats.map(format => {
return {
text: format.name,
id: format.id,
value: format.id,
};
}),
};

View File

@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import Select from './Select';
import kbn from 'app/core/utils/kbn';
import { getValueFormats } from '@grafana/ui';
interface Props {
onChange: (item: any) => void;
@ -16,14 +16,14 @@ export default class UnitPicker extends PureComponent<Props> {
render() {
const { defaultValue, onChange, width } = this.props;
const unitGroups = kbn.getUnitFormats();
const unitGroups = getValueFormats();
// Need to transform the data structure to work well with Select
const groupOptions = unitGroups.map(group => {
const options = group.submenu.map(unit => {
return {
label: unit.text,
value: unit.id,
value: unit.value,
};
});

View File

@ -1,6 +1,5 @@
import _ from 'lodash';
import { getValueFormat, getValueFormatterIndex } from '@grafana/ui';
import { getUnitFormats } from '@grafana/ui/src';
import { getValueFormat, getValueFormatterIndex, getValueFormats } from '@grafana/ui';
const kbn: any = {};
@ -284,9 +283,12 @@ kbn.roundValue = (num, decimals) => {
///// FORMAT MENU /////
kbn.getUnitFormats = () => {
return getUnitFormats();
return getValueFormats();
};
//
// Backward compatible layer for value formats to support old plugins
//
if (typeof Proxy !== "undefined") {
kbn.valueFormats = new Proxy(kbn.valueFormats, {
get(target, name, receiver) {

View File

@ -1,4 +1,4 @@
import kbn from 'app/core/utils/kbn';
import { getValueFormats } from '@grafana/ui';
export class AxesEditorCtrl {
panel: any;
@ -15,7 +15,7 @@ export class AxesEditorCtrl {
this.panel = this.panelCtrl.panel;
this.$scope.ctrl = this;
this.unitFormats = kbn.getUnitFormats();
this.unitFormats = getValueFormats();
this.logScales = {
linear: 1,

View File

@ -1,5 +1,5 @@
import _ from 'lodash';
import kbn from 'app/core/utils/kbn';
import { getValueFormats } from '@grafana/ui';
export class ColumnOptionsCtrl {
panel: any;
@ -22,7 +22,7 @@ export class ColumnOptionsCtrl {
this.activeStyleIndex = 0;
this.panelCtrl = $scope.ctrl;
this.panel = this.panelCtrl.panel;
this.unitFormats = kbn.getUnitFormats();
this.unitFormats = getValueFormats();
this.colorModes = [
{ text: 'Disabled', value: null },
{ text: 'Cell', value: 'cell' },