TransformersUI: move transformer ui to grafana app (#24360)

This commit is contained in:
Ryan McKinley 2020-05-07 10:53:58 -07:00 committed by GitHub
parent a3ffbd9a70
commit e36a6ac476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 38 additions and 68 deletions

View File

@ -98,6 +98,7 @@
"@types/prismjs": "1.16.0", "@types/prismjs": "1.16.0",
"@types/puppeteer-core": "2.0.0", "@types/puppeteer-core": "2.0.0",
"@types/react": "16.8.16", "@types/react": "16.8.16",
"@types/react-beautiful-dnd": "12.1.2",
"@types/react-dom": "16.8.4", "@types/react-dom": "16.8.4",
"@types/react-grid-layout": "0.16.7", "@types/react-grid-layout": "0.16.7",
"@types/react-redux": "7.1.7", "@types/react-redux": "7.1.7",

View File

@ -3,18 +3,6 @@ export * from './transformers/ids';
export * from './matchers'; export * from './matchers';
export { standardTransformers } from './transformers'; export { standardTransformers } from './transformers';
export * from './fieldReducer'; export * from './fieldReducer';
export { FilterFieldsByNameTransformerOptions } from './transformers/filterByName';
export { FilterFramesByRefIdTransformerOptions } from './transformers/filterByRefId';
export { SeriesToColumnsOptions } from './transformers/seriesToColumns';
export { ReduceTransformerOptions } from './transformers/reduce';
export { LabelsToFieldsOptions } from './transformers/labelsToFields';
export {
CalculateFieldTransformerOptions,
CalculateFieldMode,
getResultFieldNameForCalculateFieldTransformerOptions,
} from './transformers/calculateField';
export { OrganizeFieldsTransformerOptions } from './transformers/organize';
export { createOrderFieldsComparer } from './transformers/order';
export { transformDataFrame } from './transformDataFrame'; export { transformDataFrame } from './transformDataFrame';
export { export {
TransformerRegistyItem, TransformerRegistyItem,

View File

@ -16,13 +16,13 @@ export enum CalculateFieldMode {
BinaryOperation = 'binary', BinaryOperation = 'binary',
} }
interface ReduceOptions { export interface ReduceOptions {
include?: string; // Assume all fields include?: string; // Assume all fields
reducer: ReducerID; reducer: ReducerID;
nullValueMode?: NullValueMode; nullValueMode?: NullValueMode;
} }
interface BinaryOptions { export interface BinaryOptions {
left: string; left: string;
operator: BinaryOperationID; operator: BinaryOperationID;
right: string; right: string;
@ -99,7 +99,7 @@ export const calculateFieldTransformer: DataTransformerInfo<CalculateFieldTransf
} }
const field = { const field = {
name: getResultFieldNameForCalculateFieldTransformerOptions(options), name: getNameFromOptions(options),
type: FieldType.number, type: FieldType.number,
config: {}, config: {},
values, values,
@ -229,7 +229,7 @@ function findConsistentTimeFieldName(data: DataFrame[]): string | undefined {
return name; return name;
} }
export function getResultFieldNameForCalculateFieldTransformerOptions(options: CalculateFieldTransformerOptions) { export function getNameFromOptions(options: CalculateFieldTransformerOptions) {
if (options.alias?.length) { if (options.alias?.length) {
return options.alias; return options.alias;
} }

View File

@ -29,6 +29,7 @@ export { TagsInput } from './TagsInput/TagsInput';
export { Pagination } from './Pagination/Pagination'; export { Pagination } from './Pagination/Pagination';
export { Tag } from './Tags/Tag'; export { Tag } from './Tags/Tag';
export { TagList } from './Tags/TagList'; export { TagList } from './Tags/TagList';
export { FilterPill } from './FilterPill/FilterPill';
export { ConfirmModal } from './ConfirmModal/ConfirmModal'; export { ConfirmModal } from './ConfirmModal/ConfirmModal';
export { QueryField } from './QueryField/QueryField'; export { QueryField } from './QueryField/QueryField';

View File

@ -11,5 +11,3 @@ export * from './slate-plugins';
// Exposes standard editors for registries of optionsUi config and panel options UI // Exposes standard editors for registries of optionsUi config and panel options UI
export { getStandardFieldConfigs, getStandardOptionEditors } from './utils//standardEditors'; export { getStandardFieldConfigs, getStandardOptionEditors } from './utils//standardEditors';
// Exposes standard transformers for registry of Transformations
export { getStandardTransformers } from './utils/standardTransformers';

View File

@ -47,9 +47,10 @@ import { reportPerformance } from './core/services/echo/EchoSrv';
import { PerformanceBackend } from './core/services/echo/backends/PerformanceBackend'; import { PerformanceBackend } from './core/services/echo/backends/PerformanceBackend';
import 'app/routes/GrafanaCtrl'; import 'app/routes/GrafanaCtrl';
import 'app/features/all'; import 'app/features/all';
import { getStandardFieldConfigs, getStandardOptionEditors, getStandardTransformers } from '@grafana/ui'; import { getStandardFieldConfigs, getStandardOptionEditors } from '@grafana/ui';
import { getDefaultVariableAdapters, variableAdapters } from './features/variables/adapters'; import { getDefaultVariableAdapters, variableAdapters } from './features/variables/adapters';
import { initDevFeatures } from './dev'; import { initDevFeatures } from './dev';
import { getStandardTransformers } from 'app/core/utils/standardTransformers';
// add move to lodash for backward compatabiltiy // add move to lodash for backward compatabiltiy
// @ts-ignore // @ts-ignore

View File

@ -1,6 +1,6 @@
import React, { ChangeEvent } from 'react'; import React, { ChangeEvent } from 'react';
import { import {
CalculateFieldTransformerOptions,
DataTransformerID, DataTransformerID,
FieldType, FieldType,
KeyValue, KeyValue,
@ -8,35 +8,22 @@ import {
standardTransformers, standardTransformers,
TransformerRegistyItem, TransformerRegistyItem,
TransformerUIProps, TransformerUIProps,
NullValueMode,
BinaryOperationID, BinaryOperationID,
SelectableValue, SelectableValue,
binaryOperators, binaryOperators,
CalculateFieldMode,
getResultFieldNameForCalculateFieldTransformerOptions,
getFieldTitle, getFieldTitle,
} from '@grafana/data'; } from '@grafana/data';
import { StatsPicker } from '../StatsPicker/StatsPicker'; import { Select, StatsPicker, LegacyForms, Input, FilterPill, HorizontalGroup } from '@grafana/ui';
import { Switch } from '../Forms/Legacy/Switch/Switch'; import {
import { Input } from '../Input/Input'; CalculateFieldTransformerOptions,
import { FilterPill } from '../FilterPill/FilterPill'; CalculateFieldMode,
import { HorizontalGroup } from '../Layout/Layout'; getNameFromOptions,
import { Select } from '../Select/Select'; ReduceOptions,
BinaryOptions,
} from '@grafana/data/src/transformations/transformers/calculateField';
import defaults from 'lodash/defaults'; import defaults from 'lodash/defaults';
// Copied from @grafana/data ;( not sure how to best support his
interface ReduceOptions {
include?: string; // Assume all fields
reducer: ReducerID;
nullValueMode?: NullValueMode;
}
interface BinaryOptions {
left: string;
operator: BinaryOperationID;
right: string;
}
interface CalculateFieldTransformerEditorProps extends TransformerUIProps<CalculateFieldTransformerOptions> {} interface CalculateFieldTransformerEditorProps extends TransformerUIProps<CalculateFieldTransformerOptions> {}
interface CalculateFieldTransformerEditorState { interface CalculateFieldTransformerEditorState {
@ -342,14 +329,14 @@ export class CalculateFieldTransformerEditor extends React.PureComponent<
<Input <Input
className="width-18" className="width-18"
value={options.alias ?? ''} value={options.alias ?? ''}
placeholder={getResultFieldNameForCalculateFieldTransformerOptions(options)} placeholder={getNameFromOptions(options)}
onChange={this.onAliasChanged} onChange={this.onAliasChanged}
/> />
</div> </div>
</div> </div>
<div className="gf-form-inline"> <div className="gf-form-inline">
<div className="gf-form"> <div className="gf-form">
<Switch <LegacyForms.Switch
label="Replace all fields" label="Replace all fields"
labelClass="width-8" labelClass="width-8"
checked={!!options.replaceFields} checked={!!options.replaceFields}

View File

@ -1,18 +1,15 @@
import React from 'react'; import React from 'react';
import { import {
DataTransformerID, DataTransformerID,
FilterFieldsByNameTransformerOptions,
KeyValue, KeyValue,
standardTransformers, standardTransformers,
TransformerRegistyItem, TransformerRegistyItem,
TransformerUIProps, TransformerUIProps,
getFieldTitle, getFieldTitle,
} from '@grafana/data'; } from '@grafana/data';
import { HorizontalGroup } from '../Layout/Layout'; import { Field, Input, FilterPill, HorizontalGroup } from '@grafana/ui';
import { Input } from '../Input/Input';
import { FilterPill } from '../FilterPill/FilterPill';
import { Field } from '../Forms/Field';
import { css } from 'emotion'; import { css } from 'emotion';
import { FilterFieldsByNameTransformerOptions } from '@grafana/data/src/transformations/transformers/filterByName';
interface FilterByNameTransformerEditorProps extends TransformerUIProps<FilterFieldsByNameTransformerOptions> {} interface FilterByNameTransformerEditorProps extends TransformerUIProps<FilterFieldsByNameTransformerOptions> {}

View File

@ -1,14 +1,14 @@
import React from 'react'; import React from 'react';
import { import {
DataTransformerID, DataTransformerID,
FilterFramesByRefIdTransformerOptions,
KeyValue, KeyValue,
standardTransformers, standardTransformers,
TransformerRegistyItem, TransformerRegistyItem,
TransformerUIProps, TransformerUIProps,
} from '@grafana/data'; } from '@grafana/data';
import { HorizontalGroup } from '../Layout/Layout'; import { HorizontalGroup, FilterPill } from '@grafana/ui';
import { FilterPill } from '../FilterPill/FilterPill';
import { FilterFramesByRefIdTransformerOptions } from '@grafana/data/src/transformations/transformers/filterByRefId';
interface FilterByRefIdTransformerEditorProps extends TransformerUIProps<FilterFramesByRefIdTransformerOptions> {} interface FilterByRefIdTransformerEditorProps extends TransformerUIProps<FilterFramesByRefIdTransformerOptions> {}

View File

@ -1,11 +1,7 @@
import React from 'react'; import React from 'react';
import { import { DataTransformerID, standardTransformers, TransformerRegistyItem, TransformerUIProps } from '@grafana/data';
DataTransformerID,
standardTransformers, import { LabelsToFieldsOptions } from '@grafana/data/src/transformations/transformers/labelsToFields';
TransformerRegistyItem,
TransformerUIProps,
LabelsToFieldsOptions,
} from '@grafana/data';
export const LabelsAsFieldsTransformerEditor: React.FC<TransformerUIProps<LabelsToFieldsOptions>> = ({ export const LabelsAsFieldsTransformerEditor: React.FC<TransformerUIProps<LabelsToFieldsOptions>> = ({
input, input,

View File

@ -2,19 +2,18 @@ import React, { useCallback, useMemo } from 'react';
import { css, cx } from 'emotion'; import { css, cx } from 'emotion';
import { DragDropContext, Draggable, Droppable, DropResult } from 'react-beautiful-dnd'; import { DragDropContext, Draggable, Droppable, DropResult } from 'react-beautiful-dnd';
import { import {
createOrderFieldsComparer,
DataFrame, DataFrame,
DataTransformerID, DataTransformerID,
GrafanaTheme, GrafanaTheme,
OrganizeFieldsTransformerOptions,
standardTransformers, standardTransformers,
TransformerRegistyItem, TransformerRegistyItem,
TransformerUIProps, TransformerUIProps,
getFieldTitle, getFieldTitle,
} from '@grafana/data'; } from '@grafana/data';
import { stylesFactory, useTheme } from '../../themes'; import { stylesFactory, useTheme, Input, IconButton } from '@grafana/ui';
import { Input } from '../Input/Input';
import { IconButton } from '../IconButton/IconButton'; import { OrganizeFieldsTransformerOptions } from '@grafana/data/src/transformations/transformers/organize';
import { createOrderFieldsComparer } from '@grafana/data/src/transformations/transformers/order';
interface OrganizeFieldsTransformerEditorProps extends TransformerUIProps<OrganizeFieldsTransformerOptions> {} interface OrganizeFieldsTransformerEditorProps extends TransformerUIProps<OrganizeFieldsTransformerOptions> {}

View File

@ -1,7 +1,6 @@
import React from 'react'; import React from 'react';
import { StatsPicker } from '../StatsPicker/StatsPicker'; import { StatsPicker } from '@grafana/ui';
import { import {
ReduceTransformerOptions,
DataTransformerID, DataTransformerID,
ReducerID, ReducerID,
standardTransformers, standardTransformers,
@ -9,6 +8,8 @@ import {
TransformerUIProps, TransformerUIProps,
} from '@grafana/data'; } from '@grafana/data';
import { ReduceTransformerOptions } from '@grafana/data/src/transformations/transformers/reduce';
// TODO: Minimal implementation, needs some <3 // TODO: Minimal implementation, needs some <3
export const ReduceTransformerEditor: React.FC<TransformerUIProps<ReduceTransformerOptions>> = ({ export const ReduceTransformerEditor: React.FC<TransformerUIProps<ReduceTransformerOptions>> = ({
options, options,

View File

@ -2,13 +2,14 @@ import React, { useCallback, useMemo } from 'react';
import { import {
DataTransformerID, DataTransformerID,
SelectableValue, SelectableValue,
SeriesToColumnsOptions,
standardTransformers, standardTransformers,
TransformerRegistyItem, TransformerRegistyItem,
TransformerUIProps, TransformerUIProps,
} from '@grafana/data'; } from '@grafana/data';
import { getAllFieldNamesFromDataFrames } from './OrganizeFieldsTransformerEditor'; import { getAllFieldNamesFromDataFrames } from './OrganizeFieldsTransformerEditor';
import { Select } from '../Select/Select'; import { Select } from '@grafana/ui';
import { SeriesToColumnsOptions } from '@grafana/data/src/transformations/transformers/seriesToColumns';
export const SeriesToFieldsTransformerEditor: React.FC<TransformerUIProps<SeriesToColumnsOptions>> = ({ export const SeriesToFieldsTransformerEditor: React.FC<TransformerUIProps<SeriesToColumnsOptions>> = ({
input, input,