Skip to content
Permalink
Browse files

Chore: Reorg packages (#20111)

Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data

* Move types from grafana-ui to grafana-data

* Move valueFormats to grafana-data

* Move utils from grafana-ui to grafana-data

* Update imports in grafana-ui

* revert data's tsconfig change

* Update imports in grafana-runtime

* Fix import paths in grafana-ui

* Move rxjs to devDeps

* Core import updates batch 1

* Import updates batch 2

* Imports fix batch 3

* Imports fixes batch i don't know

* Fix imorts in grafana-toolkit

* Fix imports after master merge
  • Loading branch information
dprokop committed Oct 31, 2019
1 parent 3e8c00d commit 9b7748ec133cb2ce4b092e523cb6d70a7b89de83
Showing 379 changed files with 984 additions and 892 deletions.
@@ -12,6 +12,7 @@
"url": "http://github.com/grafana/grafana.git"
},
"main": "src/index.ts",
"types": "src/index.ts",
"scripts": {
"tslint": "tslint -c tslint.json --project tsconfig.json",
"typecheck": "tsc --noEmit",
@@ -37,8 +38,8 @@
"rollup-plugin-terser": "4.0.4",
"rollup-plugin-typescript2": "0.19.3",
"rollup-plugin-visualizer": "0.9.2",
"rxjs": "6.4.0",
"sinon": "1.17.6",
"typescript": "3.6.3"
},
"types": "src/index.ts"
}
}
@@ -1,5 +1,6 @@
import { MappingType, ValueMapping, DisplayProcessor, DisplayValue } from '@grafana/data';
import { getDisplayProcessor, getColorFromThreshold } from './displayProcessor';
import { DisplayProcessor, DisplayValue } from '../types/displayValue';
import { ValueMapping, MappingType } from '../types/valueMapping';

function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) {
processors.forEach(processor => {
@@ -1,21 +1,17 @@
// Libraries
import _ from 'lodash';
import {
Threshold,
getMappedValue,
FieldConfig,
DisplayProcessor,
DecimalInfo,
DisplayValue,
DecimalCount,
} from '@grafana/data';

// Utils
import { getValueFormat } from './valueFormats/valueFormats';
import { getColorFromHexRgbOrName } from './namedColorsPalette';
import { getColorFromHexRgbOrName } from '../utils/namedColorsPalette';

// Types
import { GrafanaTheme, GrafanaThemeType } from '../types/index';
import { FieldConfig } from '../types/dataFrame';
import { GrafanaTheme, GrafanaThemeType } from '../types/theme';
import { DisplayProcessor, DisplayValue, DecimalCount, DecimalInfo } from '../types/displayValue';
import { getValueFormat } from '../valueFormats/valueFormats';
import { getMappedValue } from '../utils/valueMappings';
import { Threshold } from '../types/threshold';
// import { GrafanaTheme, GrafanaThemeType, FieldConfig } from '../types/index';

interface DisplayProcessorOptions {
config?: FieldConfig;
@@ -1,7 +1,8 @@
import { getFieldProperties, getFieldDisplayValues, GetFieldDisplayValuesOptions } from './fieldDisplay';
import { ReducerID, Threshold, toDataFrame } from '@grafana/data';
import { GrafanaThemeType } from '../types/theme';
import { getTheme } from '../themes/index';
import { toDataFrame } from '../dataframe/processDataFrame';
import { ReducerID } from '../transformations/fieldReducer';
import { Threshold } from '../types/threshold';
import { GrafanaTheme } from '../types/theme';

describe('FieldDisplay', () => {
it('Construct simple field properties', () => {
@@ -32,6 +33,7 @@ describe('FieldDisplay', () => {
});

// Simple test dataset

const options: GetFieldDisplayValuesOptions = {
data: [
toDataFrame({
@@ -51,7 +53,7 @@ describe('FieldDisplay', () => {
override: {},
defaults: {},
},
theme: getTheme(GrafanaThemeType.Dark),
theme: {} as GrafanaTheme,
};

it('show first numeric values', () => {
@@ -148,7 +150,7 @@ describe('FieldDisplay', () => {
thresholds: [{ color: '#F2495C', value: 50 }],
},
},
theme: getTheme(GrafanaThemeType.Dark),
theme: {} as GrafanaTheme,
};

const display = getFieldDisplayValues(options);
@@ -1,22 +1,17 @@
import {
ReducerID,
reduceField,
FieldType,
DataFrame,
FieldConfig,
DisplayValue,
GraphSeriesValue,
DataFrameView,
getTimeField,
ScopedVars,
} from '@grafana/data';

import toNumber from 'lodash/toNumber';
import toString from 'lodash/toString';

import { GrafanaTheme, InterpolateFunction } from '../types/index';
import { getDisplayProcessor } from './displayProcessor';
import { getFlotPairs } from './flotPairs';
import { getFlotPairs } from '../utils/flotPairs';
import { FieldConfig, DataFrame, FieldType } from '../types/dataFrame';
import { InterpolateFunction } from '../types/panel';
import { DataFrameView } from '../dataframe/DataFrameView';
import { GraphSeriesValue } from '../types/graph';
import { DisplayValue } from '../types/displayValue';
import { GrafanaTheme } from '../types/theme';
import { ReducerID, reduceField } from '../transformations/fieldReducer';
import { ScopedVars } from '../types/ScopedVars';
import { getTimeField } from '../dataframe/processDataFrame';

export interface FieldDisplayOptions {
values?: boolean; // If true show each row value
@@ -0,0 +1,2 @@
export * from './fieldDisplay';
export * from './displayProcessor';
@@ -5,3 +5,5 @@ export * from './dataframe';
export * from './transformations';
export * from './datetime';
export * from './text';
export * from './valueFormats';
export * from './field';
@@ -1,6 +1,7 @@
import { ComponentClass } from 'react';
import { NavModel, KeyValue } from '@grafana/data';
import { PluginMeta, PluginIncludeType, GrafanaPlugin } from './plugin';
import { KeyValue } from './data';
import { NavModel } from './navModel';
import { PluginMeta, GrafanaPlugin, PluginIncludeType } from './plugin';

export interface AppRootProps<T = KeyValue> {
meta: AppPluginMeta<T>;

This file was deleted.

@@ -1,5 +1,10 @@
import { eventFactory } from './utils';

export interface AppEvent<T> {
readonly name: string;
payload?: T;
}

export type AlertPayload = [string, string?];

export const alertSuccess = eventFactory<AlertPayload>('alert-success');
@@ -1,20 +1,12 @@
import { Observable } from 'rxjs';
import { ComponentType } from 'react';
import {
TimeRange,
RawTimeRange,
TableData,
TimeSeries,
DataFrame,
LogRowModel,
LoadingState,
DataFrameDTO,
AnnotationEvent,
ScopedVars,
KeyValue,
} from '@grafana/data';
import { PluginMeta, GrafanaPlugin } from './plugin';
import { PanelData } from './panel';
import { Observable } from 'rxjs';
import { LogRowModel } from './logs';
import { AnnotationEvent, TimeSeries, TableData, LoadingState, KeyValue } from './data';
import { DataFrame, DataFrameDTO } from './dataFrame';
import { TimeRange, RawTimeRange } from './time';
import { ScopedVars } from './ScopedVars';

export interface DataSourcePluginOptionsEditorProps<JSONData = DataSourceJsonData, SecureJSONData = {}> {
options: DataSourceSettings<JSONData, SecureJSONData>;
@@ -13,7 +13,15 @@ export * from './graph';
export * from './ScopedVars';
export * from './transformations';
export * from './vector';
export * from './appEvent';
export * from './app';
export * from './datasource';
export * from './panel';
export * from './plugin';
export * from './theme';

import * as AppEvents from './events';
export { AppEvents };
import * as AppEvents from './appEvents';
import { AppEvent } from './appEvents';
export { AppEvent, AppEvents };

import * as PanelEvents from './panelEvents';
export { PanelEvents };
@@ -1,7 +1,10 @@
import { ComponentClass, ComponentType } from 'react';
import { LoadingState, DataFrame, TimeRange, TimeZone, ScopedVars, AbsoluteTimeRange } from '@grafana/data';
import { DataQueryRequest, DataQueryError } from './datasource';
import { PluginMeta, GrafanaPlugin } from './plugin';
import { ScopedVars } from './ScopedVars';
import { LoadingState } from './data';
import { DataFrame } from './dataFrame';
import { TimeRange, TimeZone, AbsoluteTimeRange } from './time';

export type InterpolateFunction = (value: string, scopedVars?: ScopedVars, format?: string | Function) => string;

@@ -1,8 +1,7 @@
import { eventFactory } from '@grafana/data';
import { DataQueryResponseData, DataQueryError } from '.';
import { eventFactory } from './utils';
import { DataQueryError, DataQueryResponseData } from './datasource';

/** Payloads */

export interface PanelChangeViewPayload {
fullscreen?: boolean;
edit?: boolean;
@@ -1,5 +1,5 @@
import { ComponentClass } from 'react';
import { KeyValue } from '@grafana/data';
import { KeyValue } from './data';

export enum PluginState {
alpha = 'alpha', // Only included it `enable_alpha` is true

0 comments on commit 9b7748e

Please sign in to comment.
You can’t perform that action at this time.