Jelajahi Sumber

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

Torkel Ödegaard 7 tahun lalu
induk
melakukan
9e6411bf4b

+ 1 - 1
packages/grafana-ui/src/utils/index.ts

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

+ 0 - 0
packages/grafana-ui/src/utils/value_formats/arithmeticFormatters.test.ts → packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.test.ts


+ 0 - 0
packages/grafana-ui/src/utils/value_formats/arithmeticFormatters.ts → packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.ts


+ 0 - 0
packages/grafana-ui/src/utils/value_formats/categories.ts → packages/grafana-ui/src/utils/valueFormats/categories.ts


+ 0 - 0
packages/grafana-ui/src/utils/value_formats/dateTimeFormatters.test.ts → packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.test.ts


+ 0 - 0
packages/grafana-ui/src/utils/value_formats/dateTimeFormatters.ts → packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.ts


+ 0 - 0
packages/grafana-ui/src/utils/value_formats/symbolFormatters.test.ts → packages/grafana-ui/src/utils/valueFormats/symbolFormatters.test.ts


+ 0 - 0
packages/grafana-ui/src/utils/value_formats/symbolFormatters.ts → packages/grafana-ui/src/utils/valueFormats/symbolFormatters.ts


+ 1 - 1
packages/grafana-ui/src/utils/value_formats/valueFormats.ts → 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,
         };
       }),
     };

+ 3 - 3
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<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,
         };
       });
 

+ 5 - 3
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) {

+ 2 - 2
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,

+ 2 - 2
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' },