Skip to content

Commit

Permalink
Move editor_config_provider to ui/vis
Browse files Browse the repository at this point in the history
  • Loading branch information
sulemanof committed Jan 29, 2020
1 parent 29b3250 commit b5b295a
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

import { Field } from 'src/plugins/data/public';
import { VisState } from 'src/legacy/core_plugins/visualizations/public';
import { AggConfig, AggParam } from '../legacy_imports';
import { AggConfig, AggParam, EditorConfig } from '../legacy_imports';
import { ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from '../config/types';

// NOTE: we cannot export the interface with export { InterfaceName }
// as there is currently a bug on babel typescript transform plugin for it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const mockEditorConfig = {
};

jest.mock('ui/new_platform');

jest.mock('../config/editor_config_providers', () => ({
jest.mock('ui/vis/config', () => ({
editorConfigProviders: {
getConfigForAgg: jest.fn(() => mockEditorConfig),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ import { i18n } from '@kbn/i18n';
import useUnmount from 'react-use/lib/useUnmount';

import { IndexPattern } from 'src/plugins/data/public';
import { AggConfig, AggGroupNames } from '../legacy_imports';
import {
AggConfig,
AggGroupNames,
editorConfigProviders,
FixedParam,
TimeIntervalParam,
EditorParamConfig,
} from '../legacy_imports';

import { DefaultEditorAggSelect } from './agg_select';
import { DefaultEditorAggParam } from './agg_param';
Expand All @@ -38,8 +45,6 @@ import {
AGG_PARAMS_ACTION_KEYS,
initAggParamsState,
} from './agg_params_state';
import { editorConfigProviders } from '../config/editor_config_providers';
import { FixedParam, TimeIntervalParam, EditorParamConfig } from '../config/types';
import { DefaultEditorCommonProps } from './agg_common_props';

const FIXED_VALUE_PROP = 'fixedValue';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@

import { IndexPattern, Field } from 'src/plugins/data/public';
import { VisState } from 'src/legacy/core_plugins/visualizations/public';
import { AggConfig, AggType, AggGroupNames, BUCKET_TYPES, IndexedArray } from '../legacy_imports';
import {
AggConfig,
AggType,
AggGroupNames,
BUCKET_TYPES,
IndexedArray,
EditorConfig,
} from '../legacy_imports';
import {
getAggParamsToRender,
getAggTypeOptions,
isInvalidParamsTouched,
} from './agg_params_helper';
import { EditorConfig } from '../config/types';
import { FieldParamEditor, OrderByParamEditor } from './controls';

jest.mock('../utils', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { get, isEmpty } from 'lodash';
import { IndexPattern, Field } from 'src/plugins/data/public';
import { VisState } from 'src/legacy/core_plugins/visualizations/public';
import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from '../config/types';
import { AggTypeState, AggParamsState } from './agg_params_state';
import { AggParamEditorProps } from './agg_param_props';
import { aggParamsMap } from './agg_params_map';
Expand All @@ -34,6 +33,7 @@ import {
AggParam,
FieldParamType,
AggType,
EditorConfig,
} from '../legacy_imports';

interface ParamInstanceBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/

import { VisState } from 'src/legacy/core_plugins/visualizations/public';
import { EditorConfig } from '../../config/types';
import { AggConfig, AggParam } from '../../legacy_imports';
import { AggConfig, AggParam, EditorConfig } from '../../legacy_imports';

export const aggParamCommonPropsMock = {
agg: {} as AggConfig,
Expand Down
2 changes: 0 additions & 2 deletions src/legacy/core_plugins/vis_default_editor/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
*/

export { DefaultEditorController } from './default_editor_controller';
export { DefaultEditorAggParams } from './components/agg_params';
export { useValidation } from './components/controls/utils';
export { RangesParamEditor, RangeValues } from './components/controls/ranges';
export { editorConfigProviders } from './config/editor_config_providers';
export * from './editor_size';
export * from './vis_options_props';
export * from './utils';
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ export { getDocLink } from 'ui/documentation_links';
export { documentationLinks } from 'ui/documentation_links/documentation_links';
export { move } from 'ui/utils/collection';
export * from 'ui/vis/lib';
export * from 'ui/vis/config';
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/

import { AggConfig } from 'ui/agg_types';
import { EditorConfigProviderRegistry } from './editor_config_providers';
import { EditorParamConfig, FixedParam, NumericIntervalParam, TimeIntervalParam } from './types';
import { AggConfig } from '../legacy_imports';

jest.mock('ui/new_platform');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
*/

import { IndexPattern } from 'src/plugins/data/public';
import { parseEsInterval } from '../../../data/public';
import { AggConfig, leastCommonMultiple, leastCommonInterval } from '../legacy_imports';
import { AggConfig } from 'ui/agg_types';
import { parseEsInterval } from '../../../../core_plugins/data/public';
import {
TimeIntervalParam,
EditorConfig,
EditorParamConfig,
FixedParam,
NumericIntervalParam,
} from './types';
import { leastCommonInterval, leastCommonMultiple } from '../lib';

type EditorConfigProvider = (indexPattern: IndexPattern, aggConfig: AggConfig) => EditorConfig;

Expand Down
21 changes: 21 additions & 0 deletions src/legacy/ui/public/vis/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { editorConfigProviders } from './editor_config_providers';
export * from './types';
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import { editorConfigProviders } from '../../../../../../src/legacy/core_plugins/vis_default_editor/public';
import { editorConfigProviders } from 'ui/vis/config';

export function initEditorConfig() {
// Limit agg params based on rollup capabilities
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@
"charts.colormaps.greysText": "グレー",
"charts.colormaps.redsText": "赤",
"charts.colormaps.yellowToRedText": "黄色から赤",
"common.ui.visualize.queryGeohashBounds.unableToGetBoundErrorTitle": "バウンドを取得できませんでした",
"console.autocomplete.addMethodMetaText": "メソド",
"console.consoleDisplayName": "コンソール",
"console.consoleMenu.copyAsCurlMessage": "リクエストが URL としてコピーされました",
Expand Down Expand Up @@ -13202,4 +13201,4 @@
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。",
"xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。"
}
}
}
3 changes: 1 addition & 2 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@
"charts.colormaps.greysText": "灰色",
"charts.colormaps.redsText": "红色",
"charts.colormaps.yellowToRedText": "黄到红",
"common.ui.visualize.queryGeohashBounds.unableToGetBoundErrorTitle": "无法获取边界",
"console.autocomplete.addMethodMetaText": "方法",
"console.consoleDisplayName": "控制台",
"console.consoleMenu.copyAsCurlMessage": "请求已复制为 cURL",
Expand Down Expand Up @@ -13201,4 +13200,4 @@
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。",
"xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。"
}
}
}

0 comments on commit b5b295a

Please sign in to comment.