mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Refactor: move KeyValue and deprecation warning to @grafana/data (#18582)
* move KeyValue and deprecation warning * move KeyValue and deprecation warning * rename displayProcessor file
This commit is contained in:
parent
6335509a23
commit
5a41e8b119
@ -1,3 +1,5 @@
|
||||
export type KeyValue<T = any> = { [s: string]: T };
|
||||
|
||||
export enum LoadingState {
|
||||
NotStarted = 'NotStarted',
|
||||
Loading = 'Loading',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { KeyValue } from '../types/index';
|
||||
import { KeyValue } from '../types';
|
||||
|
||||
// Avoid writing the warning message more than once every 10s
|
||||
const history: KeyValue<number> = {};
|
@ -2,6 +2,7 @@ export * from './string';
|
||||
export * from './registry';
|
||||
export * from './markdown';
|
||||
export * from './processDataFrame';
|
||||
export * from './deprecationWarning';
|
||||
export * from './csv';
|
||||
export * from './fieldReducer';
|
||||
export * from './logs';
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
import { isDateTime } from './moment_wrapper';
|
||||
import { ArrayVector, SortedVector } from './vector';
|
||||
import { DataFrameHelper } from './dataFrameHelper';
|
||||
import { deprecationWarning } from './deprecationWarning';
|
||||
|
||||
function convertTableToDataFrame(table: TableData): DataFrame {
|
||||
const fields = table.columns.map(c => {
|
||||
@ -224,7 +225,7 @@ export const toDataFrame = (data: any): DataFrame => {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
v.appendRow(rows[i]);
|
||||
}
|
||||
// TODO: deprection warning
|
||||
deprecationWarning('DataFrame', '.rows', 'columnar format');
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { deprecationWarning } from '../../utils/deprecationWarning';
|
||||
import { deprecationWarning } from '@grafana/data';
|
||||
import { ColorPickerProps } from './ColorPickerPopover';
|
||||
|
||||
export const warnAboutColorPickerPropsDeprecation = (componentName: string, props: ColorPickerProps) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ComponentClass } from 'react';
|
||||
import { NavModel } from '@grafana/data';
|
||||
import { PluginMeta, PluginIncludeType, GrafanaPlugin, KeyValue } from './plugin';
|
||||
import { NavModel, KeyValue } from '@grafana/data';
|
||||
import { PluginMeta, PluginIncludeType, GrafanaPlugin } from './plugin';
|
||||
|
||||
export interface AppRootProps<T = KeyValue> {
|
||||
meta: AppPluginMeta<T>;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ComponentClass } from 'react';
|
||||
import { KeyValue } from '@grafana/data';
|
||||
|
||||
export enum PluginState {
|
||||
alpha = 'alpha', // Only included it `enable_alpha` is true
|
||||
@ -11,8 +12,6 @@ export enum PluginType {
|
||||
app = 'app',
|
||||
}
|
||||
|
||||
export type KeyValue<T = any> = { [s: string]: T };
|
||||
|
||||
export interface PluginMeta<T extends {} = KeyValue> {
|
||||
id: string;
|
||||
name: string;
|
||||
|
@ -1,6 +1,6 @@
|
||||
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) {
|
||||
processors.forEach(processor => {
|
@ -15,9 +15,9 @@ import { getValueFormat } from './valueFormats/valueFormats';
|
||||
import { getColorFromHexRgbOrName } from './namedColorsPalette';
|
||||
|
||||
// Types
|
||||
import { GrafanaTheme, GrafanaThemeType } from '../types';
|
||||
import { GrafanaTheme, GrafanaThemeType } from '../types/index';
|
||||
|
||||
export interface DisplayValueOptions {
|
||||
interface DisplayProcessorOptions {
|
||||
field?: FieldConfig;
|
||||
|
||||
// Context
|
||||
@ -25,7 +25,7 @@ export interface DisplayValueOptions {
|
||||
theme?: GrafanaTheme; // Will pick 'dark' if not defined
|
||||
}
|
||||
|
||||
export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProcessor {
|
||||
export function getDisplayProcessor(options?: DisplayProcessorOptions): DisplayProcessor {
|
||||
if (options && !_.isEmpty(options)) {
|
||||
const field = options.field ? options.field : {};
|
||||
const formatFunc = getValueFormat(field.unit || 'none');
|
@ -12,7 +12,7 @@ import toNumber from 'lodash/toNumber';
|
||||
import toString from 'lodash/toString';
|
||||
|
||||
import { GrafanaTheme, InterpolateFunction, ScopedVars } from '../types/index';
|
||||
import { getDisplayProcessor } from './displayValue';
|
||||
import { getDisplayProcessor } from './displayProcessor';
|
||||
import { getFlotPairs } from './flotPairs';
|
||||
|
||||
export interface FieldDisplayOptions {
|
||||
|
@ -1,9 +1,8 @@
|
||||
export * from './valueFormats/valueFormats';
|
||||
export * from './colors';
|
||||
export * from './namedColorsPalette';
|
||||
export * from './displayValue';
|
||||
export * from './displayProcessor';
|
||||
export * from './fieldDisplay';
|
||||
export * from './deprecationWarning';
|
||||
export * from './validate';
|
||||
export { getFlotPairs } from './flotPairs';
|
||||
export * from './slate';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { has } from 'lodash';
|
||||
import { getValueFormat, getValueFormatterIndex, getValueFormats, deprecationWarning } from '@grafana/ui';
|
||||
import { stringToJsRegex, TimeRange } from '@grafana/data';
|
||||
import { getValueFormat, getValueFormatterIndex, getValueFormats } from '@grafana/ui';
|
||||
import { stringToJsRegex, TimeRange, deprecationWarning } from '@grafana/data';
|
||||
|
||||
const kbn: any = {};
|
||||
|
||||
|
@ -3,8 +3,8 @@ import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import templateSrv, { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import coreModule from 'app/core/core_module';
|
||||
import { appendQueryToUrl, toUrlParams } from 'app/core/utils/url';
|
||||
import { VariableSuggestion, KeyValue, ScopedVars, deprecationWarning, VariableOrigin } from '@grafana/ui';
|
||||
import { TimeSeriesValue, DateTime, dateTime, DataLink } from '@grafana/data';
|
||||
import { VariableSuggestion, ScopedVars, VariableOrigin } from '@grafana/ui';
|
||||
import { TimeSeriesValue, DateTime, dateTime, DataLink, KeyValue, deprecationWarning } from '@grafana/data';
|
||||
|
||||
export const DataLinkBuiltInVars = {
|
||||
keepTime: '__url_time_range',
|
||||
|
@ -3,7 +3,8 @@ import React, { PureComponent } from 'react';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
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 { getBackendSrv } from 'app/core/services/backend_srv';
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { ElasticResponse } from '../elastic_response';
|
||||
import { DataFrameHelper, DataFrameView } from '@grafana/data';
|
||||
import { KeyValue } from '@grafana/ui';
|
||||
import { DataFrameHelper, DataFrameView, KeyValue } from '@grafana/data';
|
||||
|
||||
describe('ElasticResponse', () => {
|
||||
let targets;
|
||||
|
Loading…
Reference in New Issue
Block a user