Refactor: move more files to @grafana/data (#17972)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
export interface DataLink {
|
||||
url: string;
|
||||
title: string;
|
||||
targetBlank?: boolean;
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
export * from './data';
|
||||
export * from './dataLink';
|
||||
export * from './logs';
|
||||
export * from './navModel';
|
||||
export * from './time';
|
||||
export * from './threshold';
|
||||
export * from './utils';
|
||||
export * from './valueMapping';
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
export enum MappingType {
|
||||
ValueToText = 1,
|
||||
RangeToText = 2,
|
||||
}
|
||||
|
||||
interface BaseMap {
|
||||
id: number;
|
||||
operator: string;
|
||||
text: string;
|
||||
type: MappingType;
|
||||
}
|
||||
|
||||
export type ValueMapping = ValueMap | RangeMap;
|
||||
|
||||
export interface ValueMap extends BaseMap {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface RangeMap extends BaseMap {
|
||||
from: string;
|
||||
to: string;
|
||||
}
|
||||
@@ -9,6 +9,9 @@ export * from './labels';
|
||||
export * from './object';
|
||||
export * from './fieldCache';
|
||||
export * from './moment_wrapper';
|
||||
export * from './thresholds';
|
||||
|
||||
export { getMappedValue } from './valueMappings';
|
||||
|
||||
// Names are too general to export globally
|
||||
import * as dateMath from './datemath';
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { getMappedValue } from './valueMappings';
|
||||
import { ValueMapping, MappingType } from '../types/panel';
|
||||
import { ValueMapping, MappingType } from '../types';
|
||||
|
||||
describe('Format value with value mappings', () => {
|
||||
it('should return undefined with no valuemappings', () => {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { ValueMapping, MappingType, ValueMap, RangeMap } from '../types';
|
||||
|
||||
export type TimeSeriesValue = string | number | null;
|
||||
type TimeSeriesValue = string | number | null;
|
||||
|
||||
const addValueToTextMappingText = (
|
||||
allValueMappings: ValueMapping[],
|
||||
@@ -3,11 +3,11 @@ import React, { PureComponent, CSSProperties, ReactNode } from 'react';
|
||||
import tinycolor from 'tinycolor2';
|
||||
|
||||
// Utils
|
||||
import { getColorFromHexRgbOrName, getThresholdForValue } from '../../utils';
|
||||
import { getColorFromHexRgbOrName } from '../../utils';
|
||||
|
||||
// Types
|
||||
import { DisplayValue, Themeable, Threshold, VizOrientation } from '../../types';
|
||||
import { TimeSeriesValue } from '@grafana/data';
|
||||
import { DisplayValue, Themeable, VizOrientation } from '../../types';
|
||||
import { Threshold, TimeSeriesValue, getThresholdForValue } from '@grafana/data';
|
||||
|
||||
const MIN_VALUE_HEIGHT = 18;
|
||||
const MAX_VALUE_HEIGHT = 50;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useState, ChangeEvent, useContext } from 'react';
|
||||
import { DataLink } from '../../index';
|
||||
import { DataLink } from '@grafana/data';
|
||||
import { FormField, Switch } from '../index';
|
||||
import { VariableSuggestion } from './DataLinkSuggestions';
|
||||
import { css, cx } from 'emotion';
|
||||
|
||||
@@ -4,7 +4,8 @@ import React, { FC, useContext } from 'react';
|
||||
import Prism from 'prismjs';
|
||||
// Components
|
||||
import { css } from 'emotion';
|
||||
import { DataLink, ThemeContext } from '../../index';
|
||||
import { DataLink } from '@grafana/data';
|
||||
import { ThemeContext } from '../../index';
|
||||
import { Button } from '../index';
|
||||
import { DataLinkEditor } from './DataLinkEditor';
|
||||
import { VariableSuggestion } from './DataLinkSuggestions';
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import $ from 'jquery';
|
||||
import { getColorFromHexRgbOrName } from '../../utils';
|
||||
import { DisplayValue, Threshold, Themeable } from '../../types';
|
||||
import { DisplayValue, Themeable } from '../../types';
|
||||
import { selectThemeVariant } from '../../themes';
|
||||
import { Threshold } from '@grafana/data';
|
||||
|
||||
export interface Props extends Themeable {
|
||||
height: number;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { PureComponent, ChangeEvent } from 'react';
|
||||
import { Threshold } from '../../types';
|
||||
import { Threshold } from '@grafana/data';
|
||||
import { colors } from '../../utils';
|
||||
import { ThemeContext } from '../../themes';
|
||||
import { getColorFromHexRgbOrName } from '../../utils';
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { ChangeEvent, PureComponent } from 'react';
|
||||
|
||||
import { FormField, FormLabel, Input, Select } from '..';
|
||||
|
||||
import { MappingType, ValueMapping } from '../../types';
|
||||
import { MappingType, ValueMapping } from '@grafana/data';
|
||||
|
||||
export interface Props {
|
||||
valueMapping: ValueMapping;
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { ValueMappingsEditor, Props } from './ValueMappingsEditor';
|
||||
import { MappingType } from '../../types';
|
||||
import { MappingType } from '@grafana/data';
|
||||
|
||||
const setup = (propOverrides?: object) => {
|
||||
const props: Props = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
|
||||
import MappingRow from './MappingRow';
|
||||
import { MappingType, ValueMapping } from '../../types';
|
||||
import { MappingType, ValueMapping } from '@grafana/data';
|
||||
import { PanelOptionsGroup } from '../PanelOptionsGroup/PanelOptionsGroup';
|
||||
|
||||
export interface Props {
|
||||
|
||||
@@ -4,6 +4,5 @@ export * from './app';
|
||||
export * from './datasource';
|
||||
export * from './theme';
|
||||
export * from './graph';
|
||||
export * from './threshold';
|
||||
export * from './input';
|
||||
export * from './displayValue';
|
||||
|
||||
@@ -123,35 +123,6 @@ export interface PanelMenuItem {
|
||||
subMenu?: PanelMenuItem[];
|
||||
}
|
||||
|
||||
export enum MappingType {
|
||||
ValueToText = 1,
|
||||
RangeToText = 2,
|
||||
}
|
||||
|
||||
interface BaseMap {
|
||||
id: number;
|
||||
operator: string;
|
||||
text: string;
|
||||
type: MappingType;
|
||||
}
|
||||
|
||||
export type ValueMapping = ValueMap | RangeMap;
|
||||
|
||||
export interface ValueMap extends BaseMap {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface RangeMap extends BaseMap {
|
||||
from: string;
|
||||
to: string;
|
||||
}
|
||||
|
||||
export interface DataLink {
|
||||
url: string;
|
||||
title: string;
|
||||
targetBlank?: boolean;
|
||||
}
|
||||
|
||||
export enum VizOrientation {
|
||||
Auto = 'auto',
|
||||
Vertical = 'vertical',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { getDisplayProcessor, getColorFromThreshold, DisplayProcessor, getDecimalsForValue } from './displayValue';
|
||||
import { DisplayValue, MappingType, ValueMapping } from '../types';
|
||||
import { DisplayValue } from '../types';
|
||||
import { MappingType, ValueMapping } from '@grafana/data';
|
||||
|
||||
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) {
|
||||
processors.forEach(processor => {
|
||||
|
||||
@@ -3,20 +3,11 @@ import _ from 'lodash';
|
||||
|
||||
// Utils
|
||||
import { getValueFormat } from './valueFormats/valueFormats';
|
||||
import { getMappedValue } from './valueMappings';
|
||||
import { getColorFromHexRgbOrName } from './namedColorsPalette';
|
||||
|
||||
// Types
|
||||
import {
|
||||
Threshold,
|
||||
ValueMapping,
|
||||
DecimalInfo,
|
||||
DisplayValue,
|
||||
GrafanaTheme,
|
||||
GrafanaThemeType,
|
||||
DecimalCount,
|
||||
} from '../types';
|
||||
import { DateTime, dateTime, Field } from '@grafana/data';
|
||||
import { DecimalInfo, DisplayValue, GrafanaTheme, GrafanaThemeType, DecimalCount } from '../types';
|
||||
import { DateTime, dateTime, Threshold, ValueMapping, getMappedValue, Field } from '@grafana/data';
|
||||
|
||||
export type DisplayProcessor = (value: any) => DisplayValue;
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import toNumber from 'lodash/toNumber';
|
||||
import toString from 'lodash/toString';
|
||||
|
||||
import { DisplayValue, GrafanaTheme, InterpolateFunction, ScopedVars, GraphSeriesValue } from '../types/index';
|
||||
import { getDisplayProcessor } from './displayValue';
|
||||
import { getFlotPairs } from './flotPairs';
|
||||
import {
|
||||
ValueMapping,
|
||||
Threshold,
|
||||
DisplayValue,
|
||||
GrafanaTheme,
|
||||
InterpolateFunction,
|
||||
ScopedVars,
|
||||
GraphSeriesValue,
|
||||
} from '../types/index';
|
||||
import { getDisplayProcessor } from './displayValue';
|
||||
import { getFlotPairs } from './flotPairs';
|
||||
import { ReducerID, reduceField, FieldType, NullValueMode, DataFrame, Field } from '@grafana/data';
|
||||
ReducerID,
|
||||
reduceField,
|
||||
FieldType,
|
||||
NullValueMode,
|
||||
DataFrame,
|
||||
Field,
|
||||
} from '@grafana/data';
|
||||
|
||||
export interface FieldDisplayOptions {
|
||||
values?: boolean; // If true show each row value
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
export * from './valueFormats/valueFormats';
|
||||
export * from './colors';
|
||||
export * from './namedColorsPalette';
|
||||
export * from './thresholds';
|
||||
export * from './displayValue';
|
||||
export * from './fieldDisplay';
|
||||
export * from './deprecationWarning';
|
||||
export { getMappedValue } from './valueMappings';
|
||||
export * from './validate';
|
||||
export { getFlotPairs } from './flotPairs';
|
||||
export * from './slate';
|
||||
|
||||
Reference in New Issue
Block a user