Skip to content

Commit

Permalink
Move ui/field_formats to src/plugins/data (#44883) (#45780)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp authored Sep 16, 2019
1 parent 7edcc62 commit d8b95c5
Show file tree
Hide file tree
Showing 50 changed files with 81 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ObjDefine } from './obj_define';
// @ts-ignore
import { getKbnFieldType } from '../../../../../utils/kbn_field_types';
// @ts-ignore
import { FieldFormat } from '../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../plugins/data/common/field_formats';
// @ts-ignore
import { shortenDottedString } from '../../../../../core_plugins/kibana/common/utils/shorten_dotted_string';
import { IndexPattern } from '../index_patterns';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createBoolFormat } from '../boolean';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const BoolFormat = createBoolFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createBytesFormat } from '../bytes';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const BytesFormat = createBytesFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createColorFormat } from '../color';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const ColorFormat = createColorFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import expect from '@kbn/expect';
import moment from 'moment-timezone';
import { createDateFormat } from '../date';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const DateFormat = createDateFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import expect from '@kbn/expect';
import moment from 'moment-timezone';
import { createDateNanosFormat, analysePatternForFract, formatWithNanos } from '../date_nanos';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const DateFormat = createDateNanosFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createDurationFormat } from '../duration';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const DurationFormat = createDurationFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createIpFormat } from '../ip';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const IpFormat = createIpFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createNumberFormat } from '../number';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const NumberFormat = createNumberFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createPercentFormat } from '../percent';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const PercentFormat = createPercentFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import expect from '@kbn/expect';
import moment from 'moment-timezone';
import { createRelativeDateFormat } from '../relative_date';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const RelativeDateFormat = createRelativeDateFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createStringFormat } from '../string';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const StringFormat = createStringFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createTruncateFormat } from '../truncate';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const TruncateFormat = createTruncateFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import { createUrlFormat } from '../url';
import { FieldFormat } from '../../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../plugins/data/common/field_formats';

const UrlFormat = createUrlFormat(FieldFormat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { asPrettyString } from '../../../../../../plugins/data/common/utils/as_pretty_string';
import { asPrettyString } from '../../../../../../plugins/data/common/field_formats';

export function createBoolFormat(FieldFormat) {
return class BoolFormat extends FieldFormat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import _ from 'lodash';
import { asPrettyString } from '../../../../../../plugins/data/common/utils/as_pretty_string';
import { asPrettyString } from '../../../../../../plugins/data/common/field_formats';
import { DEFAULT_COLOR } from './color_default';

const convertTemplate = _.template('<span style="<%- style %>"><%- val %></span>');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { asPrettyString } from '../../../../../../plugins/data/common/utils/as_pretty_string';
import { asPrettyString } from '../../../../../../plugins/data/common/field_formats';
import { shortenDottedString } from '../../utils/shorten_dotted_string';

const TRANSFORM_OPTIONS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import _ from 'lodash';
import { getHighlightHtml } from '../../../../../../plugins/data/common/highlight/highlight_html';
import { getHighlightHtml } from '../../../../../../plugins/data/common/field_formats';

const templateMatchRE = /{{([\s\S]+?)}}/g;
const whitelistUrlSchemes = ['http://', 'https://'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import _ from 'lodash';
import expect from '@kbn/expect';
import chrome from 'ui/chrome';
import { fieldFormats } from 'ui/registry/field_formats';
import { FieldFormat } from '../../../../../ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../plugins/data/common/field_formats';

const config = chrome.getUiSettingsClient();

Expand Down
1 change: 0 additions & 1 deletion src/legacy/ui/field_formats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
*/

export { fieldFormatsMixin } from './mixin/field_formats_mixin';
export { FieldFormat } from './field_format';
2 changes: 1 addition & 1 deletion src/legacy/ui/field_formats/mixin/field_formats_mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { has } from 'lodash';
import { Legacy } from 'kibana';
import { FieldFormatsService } from './field_formats_service';
import { FieldFormat } from '../field_format';
import { FieldFormat } from '../../../../plugins/data/common/field_formats';

export function fieldFormatsMixin(kbnServer: any, server: Legacy.Server) {
const fieldFormatClasses: FieldFormat[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { FieldFormat } from '../field_format';
import { FieldFormat } from '../../../../plugins/data/common/field_formats';
import { FieldFormatsService } from './field_formats_service';

// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/field_formats/mixin/field_formats_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { indexBy, Dictionary } from 'lodash';
import { FieldFormat } from '../field_format';
import { FieldFormat } from '../../../../plugins/data/common/field_formats';

interface FieldFormatConfig {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/agg_types/buckets/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React from 'react';
import { BucketAggType } from './_bucket_agg_type';
import { createFilterRange } from './create_filter/range';
import { FieldFormat } from '../../../field_formats/field_format';
import { FieldFormat } from '../../../../../plugins/data/common/field_formats';
import { RangeKey } from './range_key';
import { RangesParamEditor } from '../../vis/editors/default/controls/ranges';
import { i18n } from '@kbn/i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import { SearchRequestProvider } from '../fetch/request';
import { searchRequestQueue } from '../search_request_queue';
import { FetchSoonProvider } from '../fetch';
import { FieldWildcardProvider } from '../../field_wildcard';
import { getHighlightRequest } from '../../../../../plugins/data/common/highlight';
import { getHighlightRequest } from '../../../../../plugins/data/common/field_formats';

const FIELDS = [
'type',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { getDefaultFormat } from '../get_default_format';
import { FieldFormat } from '../../../../field_formats';
import { FieldFormat } from '../../../../../../plugins/data/common/field_formats';
import { createNumberFormat } from '../../../../../core_plugins/kibana/common/field_formats/types/number';

const Format = createNumberFormat(FieldFormat);
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/registry/field_formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import _ from 'lodash';
import chrome from '../chrome';
import { FieldFormat } from '../../field_formats/field_format';
import { FieldFormat } from '../../../../plugins/data/common/field_formats';
import { IndexedArray } from '../indexed_array';

class FieldFormatRegistry extends IndexedArray {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import { i18n } from '@kbn/i18n';
import { identity } from 'lodash';
import { AggConfig, Vis } from 'ui/vis';
import { SerializedFieldFormat } from 'src/plugins/expressions/common/expressions/types/common';
// @ts-ignore
import { FieldFormat } from '../../../../field_formats/field_format';

import { FieldFormat } from '../../../../../../plugins/data/common/field_formats';

// @ts-ignore
import { tabifyGetColumns } from '../../../agg_response/tabify/_get_columns';
import chrome from '../../../chrome';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
import { escape, isFunction } from 'lodash';
import { FieldFormatConvert, IFieldFormat, HtmlConventTypeConvert } from '../types';
import { getHighlightHtml } from '../../../../plugins/data/common/highlight/highlight_html';
import { asPrettyString } from '../../../../plugins/data/common/utils/as_pretty_string';

import { asPrettyString, getHighlightHtml } from '../utils';

const CONTEXT_TYPE = 'html';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import { isFunction } from 'lodash';
import { IFieldFormat, FieldFormatConvert, TextContextTypeConvert } from '../types';
import { asPrettyString } from '../../../../plugins/data/common/utils/as_pretty_string';

import { asPrettyString } from '../utils';

const CONTEXT_TYPE = 'text';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { constant, trimRight, trimLeft, get } from 'lodash';
import { FieldFormat } from './field_format';
import { FieldFormatConvert } from './types';
import { asPrettyString } from '../../../plugins/data/common/utils/as_pretty_string';
import { asPrettyString } from './utils/as_pretty_string';

const getTestFormat = (
_convert: FieldFormatConvert = {
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions src/plugins/data/common/field_formats/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 { FieldFormat } from './field_format';
export { getHighlightRequest, asPrettyString, getHighlightHtml } from './utils';
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

import { Field } from '../../core_plugins/data/public/index_patterns';

/** @public **/
export type ContentType = 'html' | 'text';

Expand All @@ -28,7 +26,7 @@ export { IFieldFormat } from './field_format';
/** @internal **/
export type HtmlConventTypeConvert = (
value: any,
field?: Field,
field?: any,
hit?: Record<string, any>,
meta?: any
) => string;
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions src/plugins/data/common/field_formats/utils/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 { asPrettyString } from './as_pretty_string';
export { getHighlightHtml, getHighlightRequest } from './highlight';
1 change: 1 addition & 0 deletions src/plugins/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

export * from './timefilter/types';
export * from './query/types';
export * from './field_formats';
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FieldFormatService {
// specified IDs. List of Kibana index patterns is passed, with a title
// attribute set in each pattern which will be compared to the index pattern
// configured in the datafeed of each job.
// Builds a map of Kibana FieldFormats (ui/field_formats/field_format)
// Builds a map of Kibana FieldFormats (plugins/data/common/field_formats)
// against detector index by job ID.
populateFormats(jobIds, indexPatterns) {
return new Promise((resolve, reject) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sinon from 'sinon';
import nodeCrypto from '@elastic/node-crypto';

import { CancellationToken } from '../../../../common/cancellation_token';
import { FieldFormat } from '../../../../../../../../src/legacy/ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../../src/plugins/data/common/field_formats';
import { FieldFormatsService } from '../../../../../../../../src/legacy/ui/field_formats/mixin/field_formats_service';
import { createStringFormat } from '../../../../../../../../src/legacy/core_plugins/kibana/common/field_formats/types/string';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import expect from '@kbn/expect';

import { FieldFormat } from '../../../../../../../../../src/legacy/ui/field_formats/field_format';
import { FieldFormat } from '../../../../../../../../../src/plugins/data/common/field_formats';
import { FieldFormatsService } from '../../../../../../../../../src/legacy/ui/field_formats/mixin/field_formats_service';
import { createBytesFormat } from '../../../../../../../../../src/legacy/core_plugins/kibana/common/field_formats/types/bytes';
import { createNumberFormat } from '../../../../../../../../../src/legacy/core_plugins/kibana/common/field_formats/types/number';
Expand Down

0 comments on commit d8b95c5

Please sign in to comment.