Skip to content

Commit

Permalink
Exclude importing of register.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinar-24 committed Oct 24, 2019
1 parent 95a3b88 commit 0fe1044
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

// @ts-ignore
import { fieldFormats } from 'ui/registry/field_formats';
import { i18n } from '@kbn/i18n';
// @ts-ignore
import { ObjDefine } from './obj_define';
Expand All @@ -28,7 +26,7 @@ import { shortenDottedString } from '../../../../../core_plugins/kibana/common/u
import { IndexPattern } from '../index_patterns';
import { getNotifications } from '../services';

import { getKbnFieldType } from '../../../../../../plugins/data/public';
import { getKbnFieldType, getFieldFormats } from '../../../../../../plugins/data/public';

export type FieldSpec = Record<string, any>;
export interface FieldType {
Expand Down Expand Up @@ -117,6 +115,8 @@ export class Field implements FieldType {

let format = spec.format;
if (!format || !(format instanceof FieldFormat)) {
const fieldFormats = getFieldFormats();

format =
indexPattern.fieldFormatMap[spec.name] ||
fieldFormats.getDefaultInstance(spec.type, spec.esTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import 'uiExports/docViews';
import 'uiExports/embeddableFactories';
import 'uiExports/embeddableActions';
import 'uiExports/fieldFormatEditors';
import 'uiExports/fieldFormats';
import 'uiExports/home';
import 'uiExports/indexManagement';
import 'uiExports/inspectorViews';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

import handlebars from 'handlebars/dist/handlebars';
import { isNumber } from 'lodash';
import { fieldFormats } from 'ui/registry/field_formats';
import { getFieldFormats } from '../../../../../../plugins/data/public';
import { inputFormats, outputFormats, isDuration } from '../lib/durations';

const fieldFormats = getFieldFormats();

export const createTickFormatter = (format = '0,0.[00]', template, getConfig = null) => {
if (!template) template = '{{value}}';
const render = handlebars.compile(template, { knownHelpersOnly: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
import _, { isArray, last, get } from 'lodash';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { fieldFormats } from 'ui/registry/field_formats';
import { createTickFormatter } from '../../lib/tick_formatter';
import { calculateLabel } from '../../../../common/calculate_label';
import { isSortable } from './is_sortable';
import { EuiToolTip, EuiIcon } from '@elastic/eui';
import { replaceVars } from '../../lib/replace_vars';
import { FormattedMessage } from '@kbn/i18n/react';
import { getFieldFormats } from '../../../../../../../plugins/data/public';

import { METRIC_TYPES } from '../../../../common/metric_types';

const fieldFormats = getFieldFormats();
const DateFormat = fieldFormats.getType('date');

function getColor(rules, colorKey, value) {
Expand Down
15 changes: 7 additions & 8 deletions src/legacy/ui/public/field_editor/field_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ import {
getSupportedScriptingLanguages,
} from 'ui/scripting_languages';

import {
fieldFormats
} from 'ui/registry/field_formats';

import {
getDocLink
} from 'ui/documentation_links';
Expand Down Expand Up @@ -78,6 +74,8 @@ import {
import { FIELD_TYPES_BY_LANG, DEFAULT_FIELD_TYPES } from './constants';
import { copyField, getDefaultFormat, executeScript, isScriptValid } from './lib';

import { getFieldFormats } from '../../../../plugins/data/public';

import { injectI18n, FormattedMessage } from '@kbn/i18n/react';

// This loads Ace editor's "groovy" mode, used below to highlight the script.
Expand Down Expand Up @@ -124,6 +122,7 @@ export class FieldEditorComponent extends PureComponent {
};
this.supportedLangs = getSupportedScriptingLanguages();
this.deprecatedLangs = getDeprecatedScriptingLanguages();
this.fieldFormats = getFieldFormats();
this.init();
}

Expand All @@ -140,10 +139,10 @@ export class FieldEditorComponent extends PureComponent {
const fieldTypes = get(FIELD_TYPES_BY_LANG, field.lang, DEFAULT_FIELD_TYPES);
field.type = fieldTypes.includes(field.type) ? field.type : fieldTypes[0];

const DefaultFieldFormat = fieldFormats.getDefaultType(field.type, field.esTypes);
const DefaultFieldFormat = this.fieldFormats.getDefaultType(field.type, field.esTypes);
const fieldTypeFormats = [
getDefaultFormat(DefaultFieldFormat),
...fieldFormats.getByFieldType(field.type),
...this.fieldFormats.getByFieldType(field.type),
];

this.setState({
Expand All @@ -168,12 +167,12 @@ export class FieldEditorComponent extends PureComponent {
onTypeChange = (type) => {
const { getConfig } = this.props.helpers;
const { field } = this.state;
const DefaultFieldFormat = fieldFormats.getDefaultType(type);
const DefaultFieldFormat = this.fieldFormats.getDefaultType(type);
field.type = type;

const fieldTypeFormats = [
getDefaultFormat(DefaultFieldFormat),
...fieldFormats.getByFieldType(field.type),
...this.fieldFormats.getByFieldType(field.type),
];

const FieldFormat = fieldTypeFormats[0];
Expand Down
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/ml/public/util/time_buckets.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import _ from 'lodash';
import moment from 'moment';
import dateMath from '@elastic/datemath';
import chrome from 'ui/chrome';
import { fieldFormats } from 'ui/registry/field_formats';
import { getFieldFormats } from '../../../../../../src/plugins/data/public';

import { timeBucketsCalcAutoIntervalProvider } from './calc_auto_interval';
import { parseInterval } from '../../common/util/parse_interval';
Expand Down Expand Up @@ -316,6 +316,7 @@ TimeBuckets.prototype.getScaledDateFormat = function () {
};

TimeBuckets.prototype.getScaledDateFormatter = function () {
const fieldFormats = getFieldFormats();
const DateFieldFormat = fieldFormats.getType('date');
return new DateFieldFormat({
pattern: this.getScaledDateFormat()
Expand Down

0 comments on commit 0fe1044

Please sign in to comment.