Refactor: move more files to @grafana/data (#17972)

This commit is contained in:
Ryan McKinley 2019-07-06 09:18:23 -07:00 committed by GitHub
parent fcdc29746f
commit bdaf0aa81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 84 additions and 88 deletions

View File

@ -0,0 +1,5 @@
export interface DataLink {
url: string;
title: string;
targetBlank?: boolean;
}

View File

@ -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';

View File

@ -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;
}

View File

@ -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';

View File

@ -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', () => {

View File

@ -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[],

View File

@ -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;

View File

@ -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';

View File

@ -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';

View File

@ -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;

View File

@ -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';

View File

@ -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;

View File

@ -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 = {

View File

@ -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 {

View File

@ -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';

View File

@ -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',

View File

@ -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 => {

View File

@ -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;

View File

@ -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

View File

@ -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';

View File

@ -9,7 +9,8 @@ import templateSrv from 'app/features/templating/template_srv';
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
import { ClickOutsideWrapper, DataLink } from '@grafana/ui';
import { ClickOutsideWrapper } from '@grafana/ui';
import { DataLink } from '@grafana/data';
export interface Props {
panel: PanelModel;

View File

@ -1,7 +1,8 @@
import React, { Component } from 'react';
import { renderMarkdown } from '@grafana/data';
import { Tooltip, ScopedVars, DataLink } from '@grafana/ui';
import { Tooltip, ScopedVars } from '@grafana/ui';
import { DataLink } from '@grafana/data';
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
import templateSrv from 'app/features/templating/template_srv';

View File

@ -8,7 +8,8 @@ import './../../panel/GeneralTabCtrl';
// Types
import { PanelModel } from '../state/PanelModel';
import { DataLink, PanelOptionsGroup, DataLinksEditor } from '@grafana/ui';
import { DataLink } from '@grafana/data';
import { PanelOptionsGroup, DataLinksEditor } from '@grafana/ui';
import { getPanelLinksVariableSuggestions } from 'app/features/panel/panellinks/link_srv';
interface Props {

View File

@ -9,7 +9,7 @@ import kbn from 'app/core/utils/kbn';
// Types
import { PanelModel } from './PanelModel';
import { DashboardModel } from './DashboardModel';
import { DataLink } from '@grafana/ui/src/types/panel';
import { DataLink } from '@grafana/data';
// Constants
import {

View File

@ -6,7 +6,9 @@ import { Emitter } from 'app/core/utils/emitter';
import { getNextRefIdChar } from 'app/core/utils/query';
// Types
import { DataQuery, ScopedVars, DataQueryResponseData, PanelPlugin, DataLink } from '@grafana/ui';
import { DataQuery, ScopedVars, DataQueryResponseData, PanelPlugin } from '@grafana/ui';
import { DataLink } from '@grafana/data';
import config from 'app/core/config';
import { PanelQueryRunner } from './PanelQueryRunner';

View File

@ -3,9 +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 { DataLink, VariableSuggestion, KeyValue, ScopedVars } from '@grafana/ui';
import { TimeSeriesValue, DateTime, dateTime } from '@grafana/data';
import { deprecationWarning, VariableOrigin } from '@grafana/ui';
import { VariableSuggestion, KeyValue, ScopedVars, deprecationWarning, VariableOrigin } from '@grafana/ui';
import { TimeSeriesValue, DateTime, dateTime, DataLink } from '@grafana/data';
export const DataLinkBuiltInVars = {
keepTime: '__url_time_range',

View File

@ -1,7 +1,6 @@
// Libraries
import React, { PureComponent } from 'react';
// Components
import {
ThresholdsEditor,
ValueMappingsEditor,
@ -10,11 +9,13 @@ import {
FieldDisplayOptions,
FieldPropertiesEditor,
PanelOptionsGroup,
FormLabel,
PanelEditorProps,
Select,
} from '@grafana/ui';
import { Field } from '@grafana/data';
// Types
import { FormLabel, PanelEditorProps, Threshold, Select, ValueMapping } from '@grafana/ui';
import { Threshold, ValueMapping } from '@grafana/data';
import { BarGaugeOptions, orientationOptions, displayModes } from './types';
export class BarGaugePanelEditor extends PureComponent<PanelEditorProps<BarGaugeOptions>> {

View File

@ -3,17 +3,15 @@ import React, { PureComponent } from 'react';
import {
PanelEditorProps,
ThresholdsEditor,
Threshold,
PanelOptionsGrid,
ValueMappingsEditor,
ValueMapping,
FieldDisplayOptions,
FieldDisplayEditor,
FieldPropertiesEditor,
Switch,
PanelOptionsGroup,
} from '@grafana/ui';
import { Field } from '@grafana/data';
import { Field, Threshold, ValueMapping } from '@grafana/data';
import { GaugeOptions } from './types';

View File

@ -25,9 +25,9 @@ import ReactDOM from 'react-dom';
import { GraphLegendProps, Legend } from './Legend/Legend';
import { GraphCtrl } from './module';
import { getValueFormat, ContextMenuItem, ContextMenuGroup, DataLink } from '@grafana/ui';
import { getValueFormat, ContextMenuItem, ContextMenuGroup } from '@grafana/ui';
import { provideTheme } from 'app/core/utils/ConfigProvider';
import { toUtc } from '@grafana/data';
import { DataLink, toUtc } from '@grafana/data';
import { GraphContextMenuCtrl, FlotDataPoint } from './GraphContextMenuCtrl';
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { ContextSrv } from 'app/core/services/context_srv';

View File

@ -11,8 +11,8 @@ import { DataProcessor } from './data_processor';
import { axesEditorComponent } from './axes_editor';
import config from 'app/core/config';
import TimeSeries from 'app/core/time_series2';
import { DataFrame } from '@grafana/data';
import { getColorFromHexRgbOrName, LegacyResponseData, DataLink, VariableSuggestion } from '@grafana/ui';
import { DataFrame, DataLink } from '@grafana/data';
import { getColorFromHexRgbOrName, LegacyResponseData, VariableSuggestion } from '@grafana/ui';
import { getProcessedDataFrame } from 'app/features/dashboard/state/PanelQueryState';
import { PanelQueryRunnerFormat } from 'app/features/dashboard/state/PanelQueryRunner';
import { GraphContextMenuCtrl } from './GraphContextMenuCtrl';

View File

@ -3,13 +3,12 @@ import {
PanelEditorProps,
PanelOptionsGrid,
ValueMappingsEditor,
ValueMapping,
FieldDisplayEditor,
FieldDisplayOptions,
FieldPropertiesEditor,
PanelOptionsGroup,
} from '@grafana/ui';
import { Field } from '@grafana/data';
import { ValueMapping, Field } from '@grafana/data';
import { PieChartOptionsBox } from './PieChartOptionsBox';
import { PieChartOptions } from './types';

View File

@ -3,16 +3,14 @@ import React, { PureComponent } from 'react';
import {
PanelEditorProps,
ThresholdsEditor,
Threshold,
PanelOptionsGrid,
ValueMappingsEditor,
ValueMapping,
FieldDisplayOptions,
FieldDisplayEditor,
FieldPropertiesEditor,
PanelOptionsGroup,
} from '@grafana/ui';
import { Field } from '@grafana/data';
import { Threshold, ValueMapping, Field } from '@grafana/data';
import { SingleStatOptions, SparklineOptions } from './types';
import { ColoringEditor } from './ColoringEditor';