diff --git a/packages/grafana-ui/src/utils/index.ts b/packages/grafana-ui/src/utils/index.ts index 15694248832..77940e19719 100644 --- a/packages/grafana-ui/src/utils/index.ts +++ b/packages/grafana-ui/src/utils/index.ts @@ -1,2 +1,2 @@ export * from './processTimeSeries'; -export * from './value_formats/valueFormats'; +export * from './valueFormats/valueFormats'; diff --git a/packages/grafana-ui/src/utils/value_formats/arithmeticFormatters.test.ts b/packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.test.ts similarity index 100% rename from packages/grafana-ui/src/utils/value_formats/arithmeticFormatters.test.ts rename to packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.test.ts diff --git a/packages/grafana-ui/src/utils/value_formats/arithmeticFormatters.ts b/packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.ts similarity index 100% rename from packages/grafana-ui/src/utils/value_formats/arithmeticFormatters.ts rename to packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.ts diff --git a/packages/grafana-ui/src/utils/value_formats/categories.ts b/packages/grafana-ui/src/utils/valueFormats/categories.ts similarity index 100% rename from packages/grafana-ui/src/utils/value_formats/categories.ts rename to packages/grafana-ui/src/utils/valueFormats/categories.ts diff --git a/packages/grafana-ui/src/utils/value_formats/dateTimeFormatters.test.ts b/packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.test.ts similarity index 100% rename from packages/grafana-ui/src/utils/value_formats/dateTimeFormatters.test.ts rename to packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.test.ts diff --git a/packages/grafana-ui/src/utils/value_formats/dateTimeFormatters.ts b/packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.ts similarity index 100% rename from packages/grafana-ui/src/utils/value_formats/dateTimeFormatters.ts rename to packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.ts diff --git a/packages/grafana-ui/src/utils/value_formats/symbolFormatters.test.ts b/packages/grafana-ui/src/utils/valueFormats/symbolFormatters.test.ts similarity index 100% rename from packages/grafana-ui/src/utils/value_formats/symbolFormatters.test.ts rename to packages/grafana-ui/src/utils/valueFormats/symbolFormatters.test.ts diff --git a/packages/grafana-ui/src/utils/value_formats/symbolFormatters.ts b/packages/grafana-ui/src/utils/valueFormats/symbolFormatters.ts similarity index 100% rename from packages/grafana-ui/src/utils/value_formats/symbolFormatters.ts rename to packages/grafana-ui/src/utils/valueFormats/symbolFormatters.ts diff --git a/packages/grafana-ui/src/utils/value_formats/valueFormats.ts b/packages/grafana-ui/src/utils/valueFormats/valueFormats.ts similarity index 99% rename from packages/grafana-ui/src/utils/value_formats/valueFormats.ts rename to packages/grafana-ui/src/utils/valueFormats/valueFormats.ts index dc06ce7848e..0a56ce58e5b 100644 --- a/packages/grafana-ui/src/utils/value_formats/valueFormats.ts +++ b/packages/grafana-ui/src/utils/valueFormats/valueFormats.ts @@ -158,7 +158,7 @@ export function getValueFormats() { submenu: cat.formats.map(format => { return { text: format.name, - id: format.id, + value: format.id, }; }), }; diff --git a/public/app/core/components/Select/UnitPicker.tsx b/public/app/core/components/Select/UnitPicker.tsx index 29fa2928045..0da8a148b9a 100644 --- a/public/app/core/components/Select/UnitPicker.tsx +++ b/public/app/core/components/Select/UnitPicker.tsx @@ -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 { 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, }; }); diff --git a/public/app/core/utils/kbn.ts b/public/app/core/utils/kbn.ts index 20088c60f66..a3a96f8afc3 100644 --- a/public/app/core/utils/kbn.ts +++ b/public/app/core/utils/kbn.ts @@ -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) { diff --git a/public/app/plugins/panel/graph/axes_editor.ts b/public/app/plugins/panel/graph/axes_editor.ts index 3d2dd4acbc5..04ef62f16fb 100644 --- a/public/app/plugins/panel/graph/axes_editor.ts +++ b/public/app/plugins/panel/graph/axes_editor.ts @@ -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, diff --git a/public/app/plugins/panel/table/column_options.ts b/public/app/plugins/panel/table/column_options.ts index 4c810d9987d..dfe5ff8fdcd 100644 --- a/public/app/plugins/panel/table/column_options.ts +++ b/public/app/plugins/panel/table/column_options.ts @@ -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' },