Commit 5a41e8b1 by Ryan McKinley Committed by Torkel Ödegaard

Refactor: move KeyValue and deprecation warning to @grafana/data (#18582)

* move KeyValue and deprecation warning

* move KeyValue and deprecation warning

* rename displayProcessor file
parent 6335509a
export type KeyValue<T = any> = { [s: string]: T };
export enum LoadingState { export enum LoadingState {
NotStarted = 'NotStarted', NotStarted = 'NotStarted',
Loading = 'Loading', Loading = 'Loading',
......
import { KeyValue } from '../types/index'; import { KeyValue } from '../types';
// Avoid writing the warning message more than once every 10s // Avoid writing the warning message more than once every 10s
const history: KeyValue<number> = {}; const history: KeyValue<number> = {};
......
...@@ -2,6 +2,7 @@ export * from './string'; ...@@ -2,6 +2,7 @@ export * from './string';
export * from './registry'; export * from './registry';
export * from './markdown'; export * from './markdown';
export * from './processDataFrame'; export * from './processDataFrame';
export * from './deprecationWarning';
export * from './csv'; export * from './csv';
export * from './fieldReducer'; export * from './fieldReducer';
export * from './logs'; export * from './logs';
......
...@@ -20,6 +20,7 @@ import { ...@@ -20,6 +20,7 @@ import {
import { isDateTime } from './moment_wrapper'; import { isDateTime } from './moment_wrapper';
import { ArrayVector, SortedVector } from './vector'; import { ArrayVector, SortedVector } from './vector';
import { DataFrameHelper } from './dataFrameHelper'; import { DataFrameHelper } from './dataFrameHelper';
import { deprecationWarning } from './deprecationWarning';
function convertTableToDataFrame(table: TableData): DataFrame { function convertTableToDataFrame(table: TableData): DataFrame {
const fields = table.columns.map(c => { const fields = table.columns.map(c => {
...@@ -224,7 +225,7 @@ export const toDataFrame = (data: any): DataFrame => { ...@@ -224,7 +225,7 @@ export const toDataFrame = (data: any): DataFrame => {
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
v.appendRow(rows[i]); v.appendRow(rows[i]);
} }
// TODO: deprection warning deprecationWarning('DataFrame', '.rows', 'columnar format');
return v; return v;
} }
......
import { deprecationWarning } from '../../utils/deprecationWarning'; import { deprecationWarning } from '@grafana/data';
import { ColorPickerProps } from './ColorPickerPopover'; import { ColorPickerProps } from './ColorPickerPopover';
export const warnAboutColorPickerPropsDeprecation = (componentName: string, props: ColorPickerProps) => { export const warnAboutColorPickerPropsDeprecation = (componentName: string, props: ColorPickerProps) => {
......
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import { NavModel } from '@grafana/data'; import { NavModel, KeyValue } from '@grafana/data';
import { PluginMeta, PluginIncludeType, GrafanaPlugin, KeyValue } from './plugin'; import { PluginMeta, PluginIncludeType, GrafanaPlugin } from './plugin';
export interface AppRootProps<T = KeyValue> { export interface AppRootProps<T = KeyValue> {
meta: AppPluginMeta<T>; meta: AppPluginMeta<T>;
......
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import { KeyValue } from '@grafana/data';
export enum PluginState { export enum PluginState {
alpha = 'alpha', // Only included it `enable_alpha` is true alpha = 'alpha', // Only included it `enable_alpha` is true
...@@ -11,8 +12,6 @@ export enum PluginType { ...@@ -11,8 +12,6 @@ export enum PluginType {
app = 'app', app = 'app',
} }
export type KeyValue<T = any> = { [s: string]: T };
export interface PluginMeta<T extends {} = KeyValue> { export interface PluginMeta<T extends {} = KeyValue> {
id: string; id: string;
name: string; name: string;
......
import { MappingType, ValueMapping, DisplayProcessor, DisplayValue } from '@grafana/data'; import { MappingType, ValueMapping, DisplayProcessor, DisplayValue } from '@grafana/data';
import { getDisplayProcessor, getColorFromThreshold, getDecimalsForValue } from './displayValue'; import { getDisplayProcessor, getColorFromThreshold, getDecimalsForValue } from './displayProcessor';
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) { function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) {
processors.forEach(processor => { processors.forEach(processor => {
......
...@@ -15,9 +15,9 @@ import { getValueFormat } from './valueFormats/valueFormats'; ...@@ -15,9 +15,9 @@ import { getValueFormat } from './valueFormats/valueFormats';
import { getColorFromHexRgbOrName } from './namedColorsPalette'; import { getColorFromHexRgbOrName } from './namedColorsPalette';
// Types // Types
import { GrafanaTheme, GrafanaThemeType } from '../types'; import { GrafanaTheme, GrafanaThemeType } from '../types/index';
export interface DisplayValueOptions { interface DisplayProcessorOptions {
field?: FieldConfig; field?: FieldConfig;
// Context // Context
...@@ -25,7 +25,7 @@ export interface DisplayValueOptions { ...@@ -25,7 +25,7 @@ export interface DisplayValueOptions {
theme?: GrafanaTheme; // Will pick 'dark' if not defined theme?: GrafanaTheme; // Will pick 'dark' if not defined
} }
export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProcessor { export function getDisplayProcessor(options?: DisplayProcessorOptions): DisplayProcessor {
if (options && !_.isEmpty(options)) { if (options && !_.isEmpty(options)) {
const field = options.field ? options.field : {}; const field = options.field ? options.field : {};
const formatFunc = getValueFormat(field.unit || 'none'); const formatFunc = getValueFormat(field.unit || 'none');
......
...@@ -12,7 +12,7 @@ import toNumber from 'lodash/toNumber'; ...@@ -12,7 +12,7 @@ import toNumber from 'lodash/toNumber';
import toString from 'lodash/toString'; import toString from 'lodash/toString';
import { GrafanaTheme, InterpolateFunction, ScopedVars } from '../types/index'; import { GrafanaTheme, InterpolateFunction, ScopedVars } from '../types/index';
import { getDisplayProcessor } from './displayValue'; import { getDisplayProcessor } from './displayProcessor';
import { getFlotPairs } from './flotPairs'; import { getFlotPairs } from './flotPairs';
export interface FieldDisplayOptions { export interface FieldDisplayOptions {
......
export * from './valueFormats/valueFormats'; export * from './valueFormats/valueFormats';
export * from './colors'; export * from './colors';
export * from './namedColorsPalette'; export * from './namedColorsPalette';
export * from './displayValue'; export * from './displayProcessor';
export * from './fieldDisplay'; export * from './fieldDisplay';
export * from './deprecationWarning';
export * from './validate'; export * from './validate';
export { getFlotPairs } from './flotPairs'; export { getFlotPairs } from './flotPairs';
export * from './slate'; export * from './slate';
......
import { has } from 'lodash'; import { has } from 'lodash';
import { getValueFormat, getValueFormatterIndex, getValueFormats, deprecationWarning } from '@grafana/ui'; import { getValueFormat, getValueFormatterIndex, getValueFormats } from '@grafana/ui';
import { stringToJsRegex, TimeRange } from '@grafana/data'; import { stringToJsRegex, TimeRange, deprecationWarning } from '@grafana/data';
const kbn: any = {}; const kbn: any = {};
......
...@@ -3,8 +3,8 @@ import { TimeSrv } from 'app/features/dashboard/services/TimeSrv'; ...@@ -3,8 +3,8 @@ import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import templateSrv, { TemplateSrv } from 'app/features/templating/template_srv'; import templateSrv, { TemplateSrv } from 'app/features/templating/template_srv';
import coreModule from 'app/core/core_module'; import coreModule from 'app/core/core_module';
import { appendQueryToUrl, toUrlParams } from 'app/core/utils/url'; import { appendQueryToUrl, toUrlParams } from 'app/core/utils/url';
import { VariableSuggestion, KeyValue, ScopedVars, deprecationWarning, VariableOrigin } from '@grafana/ui'; import { VariableSuggestion, ScopedVars, VariableOrigin } from '@grafana/ui';
import { TimeSeriesValue, DateTime, dateTime, DataLink } from '@grafana/data'; import { TimeSeriesValue, DateTime, dateTime, DataLink, KeyValue, deprecationWarning } from '@grafana/data';
export const DataLinkBuiltInVars = { export const DataLinkBuiltInVars = {
keepTime: '__url_time_range', keepTime: '__url_time_range',
......
...@@ -3,7 +3,8 @@ import React, { PureComponent } from 'react'; ...@@ -3,7 +3,8 @@ import React, { PureComponent } from 'react';
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
import extend from 'lodash/extend'; import extend from 'lodash/extend';
import { PluginMeta, AppPlugin, Button, deprecationWarning } from '@grafana/ui'; import { PluginMeta, AppPlugin, Button } from '@grafana/ui';
import { deprecationWarning } from '@grafana/data';
import { AngularComponent, getAngularLoader } from '@grafana/runtime'; import { AngularComponent, getAngularLoader } from '@grafana/runtime';
import { getBackendSrv } from 'app/core/services/backend_srv'; import { getBackendSrv } from 'app/core/services/backend_srv';
......
import { ElasticResponse } from '../elastic_response'; import { ElasticResponse } from '../elastic_response';
import { DataFrameHelper, DataFrameView } from '@grafana/data'; import { DataFrameHelper, DataFrameView, KeyValue } from '@grafana/data';
import { KeyValue } from '@grafana/ui';
describe('ElasticResponse', () => { describe('ElasticResponse', () => {
let targets; let targets;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment