You need additional privileges to edit this dashboard.
@@ -1023,6 +1025,7 @@ exports[`DashboardEmptyScreen renders correctly with view mode 1`] = `
>
Click edit in the menu bar above to start adding panels.
diff --git a/src/plugins/data/README.mdx b/src/plugins/data/README.mdx
index fba5cbd6d48e1..c2da9a686cacb 100644
--- a/src/plugins/data/README.mdx
+++ b/src/plugins/data/README.mdx
@@ -49,10 +49,6 @@ This is helpful when you want to provide a user with options, for example when c
```
-## Field Formats
-
-Coming soon.
-
## Index Patterns
The Index Patterns API provides a consistent method of structuring and formatting documents
diff --git a/src/plugins/data/common/constants.ts b/src/plugins/data/common/constants.ts
index 89ccdfcc0479e..406da4e56d150 100644
--- a/src/plugins/data/common/constants.ts
+++ b/src/plugins/data/common/constants.ts
@@ -31,13 +31,6 @@ export const UI_SETTINGS = {
HISTOGRAM_BAR_TARGET: 'histogram:barTarget',
HISTOGRAM_MAX_BARS: 'histogram:maxBars',
HISTORY_LIMIT: 'history:limit',
- SHORT_DOTS_ENABLE: 'shortDots:enable',
- FORMAT_DEFAULT_TYPE_MAP: 'format:defaultTypeMap',
- FORMAT_NUMBER_DEFAULT_PATTERN: 'format:number:defaultPattern',
- FORMAT_PERCENT_DEFAULT_PATTERN: 'format:percent:defaultPattern',
- FORMAT_BYTES_DEFAULT_PATTERN: 'format:bytes:defaultPattern',
- FORMAT_CURRENCY_DEFAULT_PATTERN: 'format:currency:defaultPattern',
- FORMAT_NUMBER_DEFAULT_LOCALE: 'format:number:defaultLocale',
TIMEPICKER_REFRESH_INTERVAL_DEFAULTS: 'timepicker:refreshIntervalDefaults',
TIMEPICKER_QUICK_RANGES: 'timepicker:quickRanges',
TIMEPICKER_TIME_DEFAULTS: 'timepicker:timeDefaults',
diff --git a/src/plugins/data/common/exports/export_csv.test.ts b/src/plugins/data/common/exports/export_csv.test.ts
index 8bf44fe48a589..f108e69c68d56 100644
--- a/src/plugins/data/common/exports/export_csv.test.ts
+++ b/src/plugins/data/common/exports/export_csv.test.ts
@@ -7,7 +7,7 @@
*/
import { Datatable } from 'src/plugins/expressions';
-import { FieldFormat } from '../../common/field_formats';
+import { FieldFormat } from '../../../field_formats/common';
import { datatableToCSV } from './export_csv';
function getDefaultOptions() {
diff --git a/src/plugins/data/common/exports/export_csv.tsx b/src/plugins/data/common/exports/export_csv.tsx
index d4477e72b64c4..68f817d1b1484 100644
--- a/src/plugins/data/common/exports/export_csv.tsx
+++ b/src/plugins/data/common/exports/export_csv.tsx
@@ -8,8 +8,8 @@
// Inspired by the inspector CSV exporter
-import { FormatFactory } from 'src/plugins/data/common/field_formats/utils';
import { Datatable } from 'src/plugins/expressions';
+import { FormatFactory } from '../../../field_formats/common';
import { createEscapeValue } from './escape_value';
export const LINE_FEED_CHARACTER = '\r\n';
diff --git a/src/plugins/data/common/index.ts b/src/plugins/data/common/index.ts
index cd05c613f793f..2bc383db6f530 100644
--- a/src/plugins/data/common/index.ts
+++ b/src/plugins/data/common/index.ts
@@ -8,7 +8,6 @@
export * from './constants';
export * from './es_query';
-export * from './field_formats';
export * from './index_patterns';
export * from './kbn_field_types';
export * from './query';
diff --git a/src/plugins/data/common/index_patterns/fields/index_pattern_field.test.ts b/src/plugins/data/common/index_patterns/fields/index_pattern_field.test.ts
index 73f015ca5517c..f95de90955b65 100644
--- a/src/plugins/data/common/index_patterns/fields/index_pattern_field.test.ts
+++ b/src/plugins/data/common/index_patterns/fields/index_pattern_field.test.ts
@@ -8,8 +8,9 @@
import { IndexPatternField } from './index_pattern_field';
import { IndexPattern } from '../index_patterns';
-import { KBN_FIELD_TYPES, FieldFormat } from '../../../common';
+import { KBN_FIELD_TYPES } from '../../../common';
import { FieldSpec, RuntimeField } from '../types';
+import { FieldFormat } from '../../../../field_formats/common';
describe('Field', function () {
function flatten(obj: Record) {
diff --git a/src/plugins/data/common/index_patterns/index_patterns/flatten_hit.test.ts b/src/plugins/data/common/index_patterns/index_patterns/flatten_hit.test.ts
index 9a33b0cfa6f1c..f4f94856c7226 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/flatten_hit.test.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/flatten_hit.test.ts
@@ -12,7 +12,7 @@ import { IndexPattern } from './index_pattern';
import mockLogStashFields from './fixtures/logstash_fields';
import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern';
-import { fieldFormatsMock } from '../../field_formats/mocks';
+import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
import { flattenHitWrapper } from './flatten_hit';
class MockFieldFormatter {}
diff --git a/src/plugins/data/common/index_patterns/index_patterns/format_hit.ts b/src/plugins/data/common/index_patterns/index_patterns/format_hit.ts
index 732b9c7c8eab0..fe872ae929899 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/format_hit.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/format_hit.ts
@@ -8,7 +8,7 @@
import _ from 'lodash';
import { IndexPattern } from './index_pattern';
-import { FieldFormatsContentType } from '../../../common';
+import { FieldFormatsContentType } from '../../../../field_formats/common';
const formattedCache = new WeakMap();
const partialFormattedCache = new WeakMap();
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
index 508bddb7a4096..7c111f7666544 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
@@ -16,8 +16,8 @@ import mockLogStashFields from './fixtures/logstash_fields';
import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern';
import { IndexPatternField } from '../fields';
-import { fieldFormatsMock } from '../../field_formats/mocks';
-import { FieldFormat } from '../..';
+import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
+import { FieldFormat } from '../../../../field_formats/common';
import { RuntimeField } from '../types';
class MockFieldFormatter {}
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts
index b3f2605723c02..48bcdf6982b67 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts
@@ -15,7 +15,7 @@ import { ES_FIELD_TYPES, KBN_FIELD_TYPES, IIndexPattern, IFieldType } from '../.
import { IndexPatternField, IIndexPatternFieldList, fieldList } from '../fields';
import { formatHitProvider } from './format_hit';
import { flattenHitWrapper } from './flatten_hit';
-import { FieldFormatsStartCommon, FieldFormat } from '../../field_formats';
+import { FieldFormatsStartCommon, FieldFormat } from '../../../../field_formats/common';
import { IndexPatternSpec, TypeMeta, SourceFilter, IndexPatternFieldMap } from '../types';
import { SerializedFieldFormat } from '../../../../expressions/common';
import { castEsToKbnFieldTypeName } from '../../kbn_field_types';
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts
index 8715f8feb067a..a80e97b4e2cab 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts
@@ -8,7 +8,7 @@
import { defaults } from 'lodash';
import { IndexPatternsService, IndexPattern } from '.';
-import { fieldFormatsMock } from '../../field_formats/mocks';
+import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern';
import { UiSettingsCommon, SavedObjectsClientCommon, SavedObject } from '../types';
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
index cecf3b8c07d1a..64628f7165f27 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
@@ -29,7 +29,7 @@ import {
FieldSpec,
IndexPatternFieldMap,
} from '../types';
-import { FieldFormatsStartCommon } from '../../field_formats';
+import { FieldFormatsStartCommon, FORMATS_UI_SETTINGS } from '../../../../field_formats/common/';
import { UI_SETTINGS, SavedObject } from '../../../common';
import { SavedObjectNotFound } from '../../../../kibana_utils/common';
import { IndexPatternMissingIndices } from '../lib';
@@ -500,7 +500,7 @@ export class IndexPatternsService {
* @returns IndexPattern
*/
async create(spec: IndexPatternSpec, skipFetchFields = false): Promise {
- const shortDotsEnable = await this.config.get(UI_SETTINGS.SHORT_DOTS_ENABLE);
+ const shortDotsEnable = await this.config.get(FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE);
const metaFields = await this.config.get(UI_SETTINGS.META_FIELDS);
const indexPattern = new IndexPattern({
@@ -528,7 +528,7 @@ export class IndexPatternsService {
const indexPattern = await this.create(spec, skipFetchFields);
const createdIndexPattern = await this.createSavedObject(indexPattern, override);
await this.setDefault(createdIndexPattern.id!);
- return createdIndexPattern;
+ return createdIndexPattern!;
}
/**
diff --git a/src/plugins/data/common/index_patterns/types.ts b/src/plugins/data/common/index_patterns/types.ts
index d05a7ea6e2d93..56a79dd9cfada 100644
--- a/src/plugins/data/common/index_patterns/types.ts
+++ b/src/plugins/data/common/index_patterns/types.ts
@@ -13,7 +13,8 @@ import type { SavedObject } from 'src/core/server';
import { IFieldType } from './fields';
import { RUNTIME_FIELD_TYPES } from './constants';
import { SerializedFieldFormat } from '../../../expressions/common';
-import { KBN_FIELD_TYPES, IndexPatternField, FieldFormat } from '..';
+import { KBN_FIELD_TYPES, IndexPatternField } from '..';
+import { FieldFormat } from '../../../field_formats/common';
export type FieldFormatMap = Record;
diff --git a/src/plugins/data/common/search/aggs/agg_types.ts b/src/plugins/data/common/search/aggs/agg_types.ts
index 1db60db507f0f..375de79f7f081 100644
--- a/src/plugins/data/common/search/aggs/agg_types.ts
+++ b/src/plugins/data/common/search/aggs/agg_types.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { FieldFormatsStartCommon } from '../../field_formats';
+import { FieldFormatsStartCommon } from '../../../../field_formats/common';
import * as buckets from './buckets';
import * as metrics from './metrics';
diff --git a/src/plugins/data/common/search/aggs/buckets/create_filter/histogram.test.ts b/src/plugins/data/common/search/aggs/buckets/create_filter/histogram.test.ts
index c147708b5b2f9..0cefd6b73b336 100644
--- a/src/plugins/data/common/search/aggs/buckets/create_filter/histogram.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/create_filter/histogram.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../common/field_formats';
+import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../../field_formats/common';
import { AggConfigs } from '../../agg_configs';
import { mockAggTypesRegistry, mockGetFieldFormatsStart } from '../../test_helpers';
import { BUCKET_TYPES } from '../bucket_agg_types';
diff --git a/src/plugins/data/common/search/aggs/buckets/create_filter/ip_range.test.ts b/src/plugins/data/common/search/aggs/buckets/create_filter/ip_range.test.ts
index 1e4d97a007301..51ea6d081d139 100644
--- a/src/plugins/data/common/search/aggs/buckets/create_filter/ip_range.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/create_filter/ip_range.test.ts
@@ -9,7 +9,7 @@
import { createFilterIpRange } from './ip_range';
import { AggConfigs, CreateAggConfigParams } from '../../agg_configs';
import { mockAggTypesRegistry } from '../../test_helpers';
-import { IpFormat } from '../../../../../common';
+import { IpFormat } from '../../../../../../field_formats/common';
import { BUCKET_TYPES } from '../bucket_agg_types';
import { IBucketAggConfig } from '../bucket_agg_type';
diff --git a/src/plugins/data/common/search/aggs/buckets/create_filter/range.test.ts b/src/plugins/data/common/search/aggs/buckets/create_filter/range.test.ts
index 7e4289e23cfae..c9ab1617929dc 100644
--- a/src/plugins/data/common/search/aggs/buckets/create_filter/range.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/create_filter/range.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../common/field_formats';
+import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../../field_formats/common';
import { AggConfigs } from '../../agg_configs';
import { mockAggTypesRegistry, mockGetFieldFormatsStart } from '../../test_helpers';
import { IBucketAggConfig } from '../bucket_agg_type';
diff --git a/src/plugins/data/common/search/aggs/buckets/range.test.ts b/src/plugins/data/common/search/aggs/buckets/range.test.ts
index 60a58a68e18e0..202cc59c83c0f 100644
--- a/src/plugins/data/common/search/aggs/buckets/range.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/range.test.ts
@@ -9,7 +9,7 @@
import { AggConfigs } from '../agg_configs';
import { mockAggTypesRegistry } from '../test_helpers';
import { BUCKET_TYPES } from './bucket_agg_types';
-import { FieldFormatsGetConfigFn, NumberFormat } from '../../../../common/field_formats';
+import { FieldFormatsGetConfigFn, NumberFormat } from '../../../../../field_formats/common';
describe('Range Agg', () => {
const getConfig = (() => {}) as FieldFormatsGetConfigFn;
diff --git a/src/plugins/data/common/search/aggs/buckets/shard_delay.test.ts b/src/plugins/data/common/search/aggs/buckets/shard_delay.test.ts
index 51c71cd1a2994..9f7559c6fe34f 100644
--- a/src/plugins/data/common/search/aggs/buckets/shard_delay.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/shard_delay.test.ts
@@ -7,7 +7,7 @@
*/
import { AggConfigs } from '../agg_configs';
-import { FieldFormatsGetConfigFn, NumberFormat } from '../../../../common/field_formats';
+import { FieldFormatsGetConfigFn, NumberFormat } from '../../../../../field_formats/common';
import { getShardDelayBucketAgg, SHARD_DELAY_AGG_NAME } from './shard_delay';
describe('Shard Delay Agg', () => {
diff --git a/src/plugins/data/common/search/aggs/test_helpers/mock_agg_types_registry.ts b/src/plugins/data/common/search/aggs/test_helpers/mock_agg_types_registry.ts
index ff22af720bde6..50c8966d284a0 100644
--- a/src/plugins/data/common/search/aggs/test_helpers/mock_agg_types_registry.ts
+++ b/src/plugins/data/common/search/aggs/test_helpers/mock_agg_types_registry.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { fieldFormatsMock } from '../../../field_formats/mocks';
+import { fieldFormatsMock } from '../../../../../field_formats/common/mocks';
import { AggTypesRegistry, AggTypesRegistryStart } from '../agg_types_registry';
import { AggTypesDependencies, getAggTypes } from '../agg_types';
diff --git a/src/plugins/data/common/search/aggs/utils/get_aggs_formats.test.ts b/src/plugins/data/common/search/aggs/utils/get_aggs_formats.test.ts
index 1cf80a6d0085c..76112980c55fb 100644
--- a/src/plugins/data/common/search/aggs/utils/get_aggs_formats.test.ts
+++ b/src/plugins/data/common/search/aggs/utils/get_aggs_formats.test.ts
@@ -8,8 +8,11 @@
import { identity } from 'lodash';
-import { SerializedFieldFormat } from 'src/plugins/expressions/common/types';
-import { FieldFormat, IFieldFormat } from '../../../../common';
+import {
+ FieldFormat,
+ IFieldFormat,
+ SerializedFieldFormat,
+} from '../../../../../field_formats/common';
import { getAggsFormats } from './get_aggs_formats';
const getAggFormat = (
diff --git a/src/plugins/data/common/search/aggs/utils/get_aggs_formats.ts b/src/plugins/data/common/search/aggs/utils/get_aggs_formats.ts
index 175b6832b3c85..2aead866c6b60 100644
--- a/src/plugins/data/common/search/aggs/utils/get_aggs_formats.ts
+++ b/src/plugins/data/common/search/aggs/utils/get_aggs_formats.ts
@@ -15,7 +15,7 @@ import {
FieldFormatInstanceType,
FieldFormatsContentType,
IFieldFormat,
-} from '../../../../common/field_formats';
+} from '../../../../../field_formats/common';
import { DateRange } from '../../expressions';
import { convertDateRangeToString } from '../buckets/lib/date_range';
import { convertIPRangeToString, IpRangeKey } from '../buckets/lib/ip_range';
diff --git a/src/plugins/data/common/search/expressions/esaggs/create_filter.test.ts b/src/plugins/data/common/search/expressions/esaggs/create_filter.test.ts
index b78980cb5136e..e200f9bf02536 100644
--- a/src/plugins/data/common/search/expressions/esaggs/create_filter.test.ts
+++ b/src/plugins/data/common/search/expressions/esaggs/create_filter.test.ts
@@ -7,7 +7,7 @@
*/
import { isRangeFilter } from '@kbn/es-query';
-import { BytesFormat, FieldFormatsGetConfigFn } from '../../../field_formats';
+import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../field_formats/common';
import { AggConfigs, IAggConfig } from '../../aggs';
import { mockAggTypesRegistry } from '../../aggs/test_helpers';
diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts
index c982ba1e7a293..c72976e3412a6 100644
--- a/src/plugins/data/common/search/search_source/search_source.ts
+++ b/src/plugins/data/common/search/search_source/search_source.ts
@@ -99,7 +99,7 @@ import {
isPartialResponse,
IKibanaSearchResponse,
} from '../../../common';
-import { getHighlightRequest } from '../../../common/field_formats';
+import { getHighlightRequest } from '../../../../field_formats/common';
import { extractReferences } from './extract_references';
/** @internal */
diff --git a/src/plugins/data/kibana.json b/src/plugins/data/kibana.json
index e425d0701155b..e6faa6bd0b1a7 100644
--- a/src/plugins/data/kibana.json
+++ b/src/plugins/data/kibana.json
@@ -3,8 +3,8 @@
"version": "kibana",
"server": true,
"ui": true,
- "requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector"],
- "serviceFolders": ["search", "index_patterns", "query", "autocomplete", "ui", "field_formats"],
+ "requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector", "fieldFormats"],
+ "serviceFolders": ["search", "index_patterns", "query", "autocomplete", "ui"],
"optionalPlugins": ["usageCollection"],
"extraPublicDirs": ["common"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "inspector"],
diff --git a/src/plugins/data/public/actions/filters/create_filters_from_range_select.test.ts b/src/plugins/data/public/actions/filters/create_filters_from_range_select.test.ts
index ea7d7690fb876..5c3b016dc631e 100644
--- a/src/plugins/data/public/actions/filters/create_filters_from_range_select.test.ts
+++ b/src/plugins/data/public/actions/filters/create_filters_from_range_select.test.ts
@@ -10,14 +10,11 @@ import moment from 'moment';
import { createFiltersFromRangeSelectAction } from './create_filters_from_range_select';
-import {
- fieldFormats,
- FieldFormatsGetConfigFn,
- IndexPatternsContract,
- RangeFilter,
-} from '../../../public';
+import { IndexPatternsContract, RangeFilter } from '../../../public';
import { dataPluginMock } from '../../../public/mocks';
import { setIndexPatterns, setSearchService } from '../../../public/services';
+import { FieldFormatsGetConfigFn } from '../../../../field_formats/common';
+import { DateFormat } from '../../../../field_formats/public/';
describe('brushEvent', () => {
const DAY_IN_MS = 24 * 60 * 60 * 1000;
@@ -35,7 +32,7 @@ describe('brushEvent', () => {
id: 'logstash-*',
},
filterable: true,
- format: new fieldFormats.DateFormat({}, (() => {}) as FieldFormatsGetConfigFn),
+ format: new DateFormat({}, (() => {}) as FieldFormatsGetConfigFn),
};
const indexPattern = {
diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts
index 14ae24a2a5626..563321cf56fef 100644
--- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts
+++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts
@@ -6,18 +6,14 @@
* Side Public License, v 1.
*/
-import {
- fieldFormats,
- FieldFormatsGetConfigFn,
- esFilters,
- IndexPatternsContract,
-} from '../../../public';
+import { esFilters, IndexPatternsContract } from '../../../public';
import { dataPluginMock } from '../../../public/mocks';
import { setIndexPatterns, setSearchService } from '../../../public/services';
import {
createFiltersFromValueClickAction,
ValueClickDataContext,
} from './create_filters_from_value_click';
+import { FieldFormatsGetConfigFn, BytesFormat } from '../../../../field_formats/common';
const mockField = {
name: 'bytes',
@@ -72,8 +68,7 @@ describe('createFiltersFromValueClick', () => {
getByName: () => mockField,
filter: () => [mockField],
},
- getFormatterForField: () =>
- new fieldFormats.BytesFormat({}, (() => {}) as FieldFormatsGetConfigFn),
+ getFormatterForField: () => new BytesFormat({}, (() => {}) as FieldFormatsGetConfigFn),
}),
} as unknown) as IndexPatternsContract);
});
diff --git a/src/plugins/data/public/field_formats/field_formats_registry.stub.ts b/src/plugins/data/public/field_formats/field_formats_registry.stub.ts
deleted file mode 100644
index 566532085059d..0000000000000
--- a/src/plugins/data/public/field_formats/field_formats_registry.stub.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { CoreSetup } from 'src/core/public';
-import { baseFormattersPublic } from './constants';
-import { fieldFormats } from '..';
-
-export const getFieldFormatsRegistry = (core: CoreSetup) => {
- const fieldFormatsRegistry = new fieldFormats.FieldFormatsRegistry();
- const getConfig = core.uiSettings.get.bind(core.uiSettings);
-
- fieldFormatsRegistry.init(getConfig, {}, baseFormattersPublic);
-
- return fieldFormatsRegistry;
-};
diff --git a/src/plugins/data/public/index.scss b/src/plugins/data/public/index.scss
index c0eebf3402771..467efa98934ec 100644
--- a/src/plugins/data/public/index.scss
+++ b/src/plugins/data/public/index.scss
@@ -1,3 +1,2 @@
@import './ui/index';
@import './utils/table_inspector_view/index';
-@import './field_formats/converters/index';
diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts
index e3ecacfbda5ad..fb35d00545040 100644
--- a/src/plugins/data/public/index.ts
+++ b/src/plugins/data/public/index.ts
@@ -19,75 +19,6 @@ export { getEsQueryConfig } from '../common';
export { FilterLabel, FilterItem } from './ui';
export { getDisplayValueFromFilter, generateFilters, extractTimeRange } from './query';
-/*
- * Field Formatters:
- */
-
-import {
- FieldFormat,
- FieldFormatsRegistry,
- DEFAULT_CONVERTER_COLOR,
- HTML_CONTEXT_TYPE,
- TEXT_CONTEXT_TYPE,
- FIELD_FORMAT_IDS,
- BoolFormat,
- BytesFormat,
- ColorFormat,
- DurationFormat,
- IpFormat,
- NumberFormat,
- PercentFormat,
- RelativeDateFormat,
- SourceFormat,
- StaticLookupFormat,
- UrlFormat,
- StringFormat,
- TruncateFormat,
- HistogramFormat,
-} from '../common/field_formats';
-
-import { DateNanosFormat, DateFormat } from './field_formats';
-export { baseFormattersPublic, FieldFormatsStart } from './field_formats';
-
-// Field formats helpers namespace:
-export const fieldFormats = {
- FieldFormat,
- FieldFormatsRegistry, // exported only for tests. Consider mock.
-
- DEFAULT_CONVERTER_COLOR,
- HTML_CONTEXT_TYPE,
- TEXT_CONTEXT_TYPE,
- FIELD_FORMAT_IDS,
-
- BoolFormat,
- BytesFormat,
- ColorFormat,
- DateFormat,
- DateNanosFormat,
- DurationFormat,
- IpFormat,
- NumberFormat,
- PercentFormat,
- RelativeDateFormat,
- SourceFormat,
- StaticLookupFormat,
- UrlFormat,
- StringFormat,
- TruncateFormat,
- HistogramFormat,
-};
-
-export {
- IFieldFormat,
- FieldFormatInstanceType,
- IFieldFormatsRegistry,
- FieldFormatsContentType,
- FieldFormatsGetConfigFn,
- FieldFormatConfig,
- FieldFormatId,
- FieldFormat,
-} from '../common';
-
/**
* Exporters (CSV)
*/
@@ -152,7 +83,9 @@ export {
IndexPatternSpec,
IndexPatternLoadExpressionFunctionDefinition,
fieldList,
+ GetFieldsOptions,
INDEX_PATTERN_SAVED_OBJECT_TYPE,
+ AggregationRestrictions,
IndexPatternType,
} from '../common';
diff --git a/src/plugins/data/public/mocks.ts b/src/plugins/data/public/mocks.ts
index 9e01350add2e3..ba1cba987c0b9 100644
--- a/src/plugins/data/public/mocks.ts
+++ b/src/plugins/data/public/mocks.ts
@@ -7,7 +7,7 @@
*/
import { DataPlugin, IndexPatternsContract } from '.';
-import { fieldFormatsServiceMock } from './field_formats/mocks';
+import { fieldFormatsServiceMock } from '../../field_formats/public/mocks';
import { searchServiceMock } from './search/mocks';
import { queryServiceMock } from './query/mocks';
import { AutocompleteStart, AutocompleteSetup } from './autocomplete';
diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts
index 7a071dbffe696..46b1d4a14be78 100644
--- a/src/plugins/data/public/plugin.ts
+++ b/src/plugins/data/public/plugin.ts
@@ -19,7 +19,6 @@ import {
} from './types';
import { AutocompleteService } from './autocomplete';
import { SearchService } from './search/search_service';
-import { FieldFormatsService } from './field_formats';
import { QueryService } from './query';
import { createIndexPatternSelect } from './ui/index_pattern_select';
import {
@@ -62,7 +61,6 @@ export class DataPublicPlugin
> {
private readonly autocomplete: AutocompleteService;
private readonly searchService: SearchService;
- private readonly fieldFormatsService: FieldFormatsService;
private readonly queryService: QueryService;
private readonly storage: IStorageWrapper;
private usageCollection: UsageCollectionSetup | undefined;
@@ -71,7 +69,6 @@ export class DataPublicPlugin
constructor(initializerContext: PluginInitializerContext) {
this.searchService = new SearchService(initializerContext);
this.queryService = new QueryService();
- this.fieldFormatsService = new FieldFormatsService();
this.autocomplete = new AutocompleteService(initializerContext);
this.storage = new Storage(window.localStorage);
@@ -80,7 +77,14 @@ export class DataPublicPlugin
public setup(
core: CoreSetup,
- { bfetch, expressions, uiActions, usageCollection, inspector }: DataSetupDependencies
+ {
+ bfetch,
+ expressions,
+ uiActions,
+ usageCollection,
+ inspector,
+ fieldFormats,
+ }: DataSetupDependencies
): DataPublicPluginSetup {
const startServices = createStartServicesGetter(core.getStartServices);
@@ -115,10 +119,9 @@ export class DataPublicPlugin
}))
);
- const fieldFormats = this.fieldFormatsService.setup(core);
fieldFormats.register(
getAggsFormats((serializedFieldFormat) =>
- startServices().self.fieldFormats.deserialize(serializedFieldFormat)
+ startServices().plugins.fieldFormats.deserialize(serializedFieldFormat)
)
);
@@ -133,14 +136,15 @@ export class DataPublicPlugin
};
}
- public start(core: CoreStart, { uiActions }: DataStartDependencies): DataPublicPluginStart {
+ public start(
+ core: CoreStart,
+ { uiActions, fieldFormats }: DataStartDependencies
+ ): DataPublicPluginStart {
const { uiSettings, http, notifications, savedObjects, overlays, application } = core;
setNotifications(notifications);
setOverlays(overlays);
setUiSettings(uiSettings);
- const fieldFormats = this.fieldFormatsService.start();
-
const indexPatterns = new IndexPatternsService({
uiSettings: new UiSettingsPublicToCommon(uiSettings),
savedObjectsClient: new SavedObjectsClientPublicToCommon(savedObjects.client),
diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md
index ce105b8cc94ac..64b73ded88eef 100644
--- a/src/plugins/data/public/public.api.md
+++ b/src/plugins/data/public/public.api.md
@@ -43,9 +43,10 @@ import { ExpressionAstExpression } from 'src/plugins/expressions/common';
import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { ExpressionsSetup } from 'src/plugins/expressions/public';
import { ExpressionValueBoxed } from 'src/plugins/expressions/common';
+import { FieldFormatsSetup } from 'src/plugins/field_formats/public';
+import { FieldFormatsStart } from 'src/plugins/field_formats/public';
import { Filter as Filter_2 } from '@kbn/es-query';
import { FilterStateStore } from '@kbn/es-query';
-import { FormatFactory as FormatFactory_2 } from 'src/plugins/data/common/field_formats/utils';
import { History } from 'history';
import { Href } from 'history';
import { HttpSetup } from 'kibana/public';
@@ -107,7 +108,7 @@ import { SavedObjectsFindOptions } from 'kibana/public';
import { SavedObjectsFindResponse } from 'kibana/server';
import { SavedObjectsUpdateResponse } from 'kibana/server';
import { SchemaTypeError } from '@kbn/config-schema';
-import { SerializedFieldFormat as SerializedFieldFormat_2 } from 'src/plugins/expressions/common';
+import { SerializedFieldFormat as SerializedFieldFormat_3 } from 'src/plugins/expressions/common';
import { StartServicesAccessor } from 'kibana/public';
import { ToastInputFields } from 'src/core/public/notifications';
import { ToastsSetup } from 'kibana/public';
@@ -207,7 +208,7 @@ export class AggConfig {
// @deprecated (undocumented)
toJSON(): AggConfigSerialized;
// Warning: (ae-forgotten-export) The symbol "SerializableState" needs to be exported by the entry point index.d.ts
- toSerializedFieldFormat(): {} | Ensure, SerializableState_2>;
+ toSerializedFieldFormat(): {} | Ensure, SerializableState_2>;
// (undocumented)
get type(): IAggType;
set type(type: IAggType);
@@ -537,6 +538,22 @@ export class AggParamType extends Ba
makeAgg: (agg: TAggConfig, state?: AggConfigSerialized) => TAggConfig;
}
+// Warning: (ae-missing-release-tag) "AggregationRestrictions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+type AggregationRestrictions = Record;
+
+export { AggregationRestrictions }
+
+export { AggregationRestrictions as IndexPatternAggRestrictions }
+
// Warning: (ae-forgotten-export) The symbol "AggsCommonStart" needs to be exported by the entry point index.d.ts
//
// @public
@@ -573,13 +590,6 @@ export type AutocompleteStart = ReturnType;
// @public (undocumented)
export type AutoRefreshDoneFn = () => void;
-// Warning: (ae-forgotten-export) The symbol "DateFormat" needs to be exported by the entry point index.d.ts
-// Warning: (ae-forgotten-export) The symbol "DateNanosFormat" needs to be exported by the entry point index.d.ts
-// Warning: (ae-missing-release-tag) "baseFormattersPublic" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export const baseFormattersPublic: (import("../../common").FieldFormatInstanceType | typeof DateFormat | typeof DateNanosFormat)[];
-
// Warning: (ae-missing-release-tag) "BUCKET_TYPES" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -644,9 +654,9 @@ export class DataPlugin implements Plugin);
// (undocumented)
- setup(core: CoreSetup, { bfetch, expressions, uiActions, usageCollection, inspector }: DataSetupDependencies): DataPublicPluginSetup;
+ setup(core: CoreSetup, { bfetch, expressions, uiActions, usageCollection, inspector, fieldFormats, }: DataSetupDependencies): DataPublicPluginSetup;
// (undocumented)
- start(core: CoreStart_2, { uiActions }: DataStartDependencies): DataPublicPluginStart;
+ start(core: CoreStart_2, { uiActions, fieldFormats }: DataStartDependencies): DataPublicPluginStart;
// (undocumented)
stop(): void;
}
@@ -659,9 +669,7 @@ export interface DataPublicPluginSetup {
//
// (undocumented)
autocomplete: AutocompleteSetup;
- // Warning: (ae-forgotten-export) The symbol "FieldFormatsSetup" needs to be exported by the entry point index.d.ts
- //
- // (undocumented)
+ // @deprecated (undocumented)
fieldFormats: FieldFormatsSetup;
// (undocumented)
query: QuerySetup;
@@ -675,6 +683,7 @@ export interface DataPublicPluginSetup {
export interface DataPublicPluginStart {
actions: DataPublicPluginStartActions;
autocomplete: AutocompleteStart;
+ // @deprecated (undocumented)
fieldFormats: FieldFormatsStart;
indexPatterns: IndexPatternsContract;
// Warning: (ae-forgotten-export) The symbol "NowProviderPublicContract" needs to be exported by the entry point index.d.ts
@@ -896,124 +905,6 @@ export function extractTimeRange(filters: Filter_2[], timeFieldName?: string): {
timeRange?: TimeRange;
};
-// Warning: (ae-missing-release-tag) "FieldFormat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export abstract class FieldFormat {
- // Warning: (ae-forgotten-export) The symbol "IFieldFormatMetaParams" needs to be exported by the entry point index.d.ts
- constructor(_params?: IFieldFormatMetaParams, getConfig?: FieldFormatsGetConfigFn);
- // (undocumented)
- allowsNumericalAggregations?: boolean;
- // Warning: (ae-forgotten-export) The symbol "HtmlContextTypeOptions" needs to be exported by the entry point index.d.ts
- // Warning: (ae-forgotten-export) The symbol "TextContextTypeOptions" needs to be exported by the entry point index.d.ts
- convert(value: any, contentType?: FieldFormatsContentType, options?: HtmlContextTypeOptions | TextContextTypeOptions): string;
- // Warning: (ae-forgotten-export) The symbol "FieldFormatConvert" needs to be exported by the entry point index.d.ts
- convertObject: FieldFormatConvert | undefined;
- static fieldType: string | string[];
- // Warning: (ae-incompatible-release-tags) The symbol "from" is marked as @public, but its signature references "FieldFormatInstanceType" which is marked as @internal
- //
- // (undocumented)
- static from(convertFn: FieldFormatConvertFunction): FieldFormatInstanceType;
- // (undocumented)
- protected getConfig: FieldFormatsGetConfigFn | undefined;
- // Warning: (ae-forgotten-export) The symbol "FieldFormatConvertFunction" needs to be exported by the entry point index.d.ts
- getConverterFor(contentType?: FieldFormatsContentType): FieldFormatConvertFunction;
- getParamDefaults(): Record;
- static hidden: boolean;
- // Warning: (ae-forgotten-export) The symbol "HtmlContextTypeConvert" needs to be exported by the entry point index.d.ts
- htmlConvert: HtmlContextTypeConvert | undefined;
- static id: string;
- // (undocumented)
- static isInstanceOfFieldFormat(fieldFormat: any): fieldFormat is FieldFormat;
- param(name: string): any;
- params(): Record;
- // (undocumented)
- protected readonly _params: any;
- // (undocumented)
- setupContentType(): FieldFormatConvert;
- // Warning: (ae-forgotten-export) The symbol "TextContextTypeConvert" needs to be exported by the entry point index.d.ts
- textConvert: TextContextTypeConvert | undefined;
- static title: string;
- toJSON(): {
- id: any;
- params: any;
- };
- type: any;
-}
-
-// Warning: (ae-missing-release-tag) "FieldFormatConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export interface FieldFormatConfig {
- // (undocumented)
- es?: boolean;
- // (undocumented)
- id: FieldFormatId;
- // (undocumented)
- params: Record;
-}
-
-// Warning: (ae-forgotten-export) The symbol "FIELD_FORMAT_IDS" needs to be exported by the entry point index.d.ts
-// Warning: (ae-missing-release-tag) "FieldFormatId" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public
-export type FieldFormatId = FIELD_FORMAT_IDS | string;
-
-// @internal (undocumented)
-export type FieldFormatInstanceType = (new (params?: any, getConfig?: FieldFormatsGetConfigFn) => FieldFormat) & {
- id: FieldFormatId;
- title: string;
- hidden?: boolean;
- fieldType: string | string[];
-};
-
-// Warning: (ae-missing-release-tag) "fieldFormats" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export const fieldFormats: {
- FieldFormat: typeof FieldFormat;
- FieldFormatsRegistry: typeof FieldFormatsRegistry;
- DEFAULT_CONVERTER_COLOR: {
- range: string;
- regex: string;
- text: string;
- background: string;
- };
- HTML_CONTEXT_TYPE: import("../common").FieldFormatsContentType;
- TEXT_CONTEXT_TYPE: import("../common").FieldFormatsContentType;
- FIELD_FORMAT_IDS: typeof FIELD_FORMAT_IDS;
- BoolFormat: typeof BoolFormat;
- BytesFormat: typeof BytesFormat;
- ColorFormat: typeof ColorFormat;
- DateFormat: typeof DateFormat;
- DateNanosFormat: typeof DateNanosFormat;
- DurationFormat: typeof DurationFormat;
- IpFormat: typeof IpFormat;
- NumberFormat: typeof NumberFormat;
- PercentFormat: typeof PercentFormat;
- RelativeDateFormat: typeof RelativeDateFormat;
- SourceFormat: typeof SourceFormat;
- StaticLookupFormat: typeof StaticLookupFormat;
- UrlFormat: typeof UrlFormat;
- StringFormat: typeof StringFormat;
- TruncateFormat: typeof TruncateFormat;
- HistogramFormat: typeof HistogramFormat;
-};
-
-// @public (undocumented)
-export type FieldFormatsContentType = 'html' | 'text';
-
-// Warning: (ae-forgotten-export) The symbol "GetConfigFn" needs to be exported by the entry point index.d.ts
-// Warning: (ae-missing-release-tag) "FieldFormatsGetConfigFn" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export type FieldFormatsGetConfigFn = GetConfigFn;
-
-// @public (undocumented)
-export type FieldFormatsStart = Omit & {
- deserialize: FormatFactory;
-};
-
// Warning: (ae-forgotten-export) The symbol "FieldSpec" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "fieldList" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -1112,6 +1003,24 @@ export function getEsPreference(uiSettings: IUiSettingsClient_2, sessionId?: str
// @public (undocumented)
export function getEsQueryConfig(config: KibanaConfig): EsQueryConfig_2;
+// Warning: (ae-missing-release-tag) "GetFieldsOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export interface GetFieldsOptions {
+ // (undocumented)
+ allowNoIndex?: boolean;
+ // (undocumented)
+ lookBack?: boolean;
+ // (undocumented)
+ metaFields?: string[];
+ // (undocumented)
+ pattern: string;
+ // (undocumented)
+ rollupIndex?: string;
+ // (undocumented)
+ type?: string;
+}
+
// Warning: (ae-missing-release-tag) "getKbnTypeNames" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public @deprecated (undocumented)
@@ -1191,16 +1100,6 @@ export interface IEsSearchRequest extends IKibanaSearchRequest = IKibanaSearchResponse>;
-// Warning: (ae-missing-release-tag) "IFieldFormat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export type IFieldFormat = FieldFormat;
-
-// Warning: (ae-missing-release-tag) "IFieldFormatsRegistry" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export type IFieldFormatsRegistry = PublicMethodsOf;
-
// Warning: (ae-forgotten-export) The symbol "FieldParamType" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "IFieldParamType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -1254,6 +1153,7 @@ export interface IIndexPattern extends IndexPatternBase {
fieldFormatMap?: Record | undefined>;
// (undocumented)
fields: IFieldType[];
+ // Warning: (ae-forgotten-export) The symbol "FieldFormat" needs to be exported by the entry point index.d.ts
getFormatterForField?: (field: IndexPatternField | IndexPatternField['spec'] | IFieldType) => FieldFormat;
// (undocumented)
getTimeField?(): IFieldType | undefined;
@@ -1437,18 +1337,6 @@ export class IndexPattern implements IIndexPattern {
version: string | undefined;
}
-// Warning: (ae-missing-release-tag) "AggregationRestrictions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export type IndexPatternAggRestrictions = Record;
-
// Warning: (ae-missing-release-tag) "IndexPatternAttributes" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
@@ -1640,7 +1528,6 @@ export class IndexPatternsService {
getDefault: () => Promise;
getDefaultId: () => Promise;
getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise;
- // Warning: (ae-forgotten-export) The symbol "GetFieldsOptions" needs to be exported by the entry point index.d.ts
getFieldsForWildcard: (options: GetFieldsOptions) => Promise;
getIds: (refresh?: boolean) => Promise;
getIdsWithTitle: (refresh?: boolean) => Promise;
+ aggs?: Record;
// (undocumented)
params?: {
rollup_index: string;
@@ -2578,13 +2465,6 @@ export const UI_SETTINGS: {
readonly HISTOGRAM_BAR_TARGET: "histogram:barTarget";
readonly HISTOGRAM_MAX_BARS: "histogram:maxBars";
readonly HISTORY_LIMIT: "history:limit";
- readonly SHORT_DOTS_ENABLE: "shortDots:enable";
- readonly FORMAT_DEFAULT_TYPE_MAP: "format:defaultTypeMap";
- readonly FORMAT_NUMBER_DEFAULT_PATTERN: "format:number:defaultPattern";
- readonly FORMAT_PERCENT_DEFAULT_PATTERN: "format:percent:defaultPattern";
- readonly FORMAT_BYTES_DEFAULT_PATTERN: "format:bytes:defaultPattern";
- readonly FORMAT_CURRENCY_DEFAULT_PATTERN: "format:currency:defaultPattern";
- readonly FORMAT_NUMBER_DEFAULT_LOCALE: "format:number:defaultLocale";
readonly TIMEPICKER_REFRESH_INTERVAL_DEFAULTS: "timepicker:refreshIntervalDefaults";
readonly TIMEPICKER_QUICK_RANGES: "timepicker:quickRanges";
readonly TIMEPICKER_TIME_DEFAULTS: "timepicker:timeDefaults";
@@ -2614,45 +2494,30 @@ export interface WaitUntilNextSessionCompletesOptions {
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:139:7 - (ae-forgotten-export) The symbol "FieldAttrSet" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:170:7 - (ae-forgotten-export) The symbol "RuntimeField" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/search/aggs/types.ts:128:51 - (ae-forgotten-export) The symbol "AggTypesRegistryStart" needs to be exported by the entry point index.d.ts
+// src/plugins/data/common/search/search_source/fetch/get_search_params.ts:35:19 - (ae-forgotten-export) The symbol "GetConfigFn" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/deprecated.ts:98:23 - (ae-forgotten-export) The symbol "changeTimeFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/deprecated.ts:98:23 - (ae-forgotten-export) The symbol "convertRangeFilterToTimeRangeString" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/deprecated.ts:98:23 - (ae-forgotten-export) The symbol "extractTimeFilter" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/field_formats/field_formats_service.ts:51:3 - (ae-forgotten-export) The symbol "FormatFactory" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "DurationFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:53:26 - (ae-forgotten-export) The symbol "HistogramFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:96:23 - (ae-forgotten-export) The symbol "datatableToCSV" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:123:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:123:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:123:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:123:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:123:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:294:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:294:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:294:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:296:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:297:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:306:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:307:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:308:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:309:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:313:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:314:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:317:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:318:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:321:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:27:23 - (ae-forgotten-export) The symbol "datatableToCSV" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:54:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:54:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:54:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:54:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:54:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:227:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:227:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:227:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:229:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:230:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:239:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:240:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:241:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:242:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:246:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:247:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:250:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:251:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:254:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/search/session/session_service.ts:62:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts
// (No @packageDocumentation comment for this package)
diff --git a/src/plugins/data/public/search/aggs/aggs_service.test.ts b/src/plugins/data/public/search/aggs/aggs_service.test.ts
index cd2ee69d33996..563fd5d044073 100644
--- a/src/plugins/data/public/search/aggs/aggs_service.test.ts
+++ b/src/plugins/data/public/search/aggs/aggs_service.test.ts
@@ -11,7 +11,7 @@ import { BehaviorSubject, Subscription } from 'rxjs';
import { coreMock } from '../../../../../core/public/mocks';
import { expressionsPluginMock } from '../../../../../plugins/expressions/public/mocks';
import { BucketAggType, getAggTypes, MetricAggType } from '../../../common';
-import { fieldFormatsServiceMock } from '../../field_formats/mocks';
+import { fieldFormatsServiceMock } from '../../../../field_formats/public/mocks';
import { dataPluginMock } from '../../mocks';
import {
diff --git a/src/plugins/data/public/search/aggs/aggs_service.ts b/src/plugins/data/public/search/aggs/aggs_service.ts
index f603bd733f601..3f91ced6de950 100644
--- a/src/plugins/data/public/search/aggs/aggs_service.ts
+++ b/src/plugins/data/public/search/aggs/aggs_service.ts
@@ -10,7 +10,7 @@ import { Subscription } from 'rxjs';
import { IUiSettingsClient } from 'src/core/public';
import { ExpressionsServiceSetup } from 'src/plugins/expressions/common';
-import { FieldFormatsStart } from '../../field_formats';
+import { FieldFormatsStart } from '../../../../field_formats/public';
import { calculateBounds, TimeRange } from '../../../common';
import {
aggsRequiredUiSettings,
diff --git a/src/plugins/data/public/test_utils.ts b/src/plugins/data/public/test_utils.ts
index b964ddbd2a379..613e3850c922e 100644
--- a/src/plugins/data/public/test_utils.ts
+++ b/src/plugins/data/public/test_utils.ts
@@ -6,5 +6,5 @@
* Side Public License, v 1.
*/
-export { getFieldFormatsRegistry } from './field_formats/field_formats_registry.stub';
+export { getFieldFormatsRegistry } from '../../field_formats/public/mocks';
export { getStubIndexPattern, StubIndexPattern } from './index_patterns/index_pattern.stub';
diff --git a/src/plugins/data/public/types.ts b/src/plugins/data/public/types.ts
index 5ba4ba2bc48af..d8bfcfdb6ddb1 100644
--- a/src/plugins/data/public/types.ts
+++ b/src/plugins/data/public/types.ts
@@ -12,8 +12,8 @@ import { BfetchPublicSetup } from 'src/plugins/bfetch/public';
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { ExpressionsSetup } from 'src/plugins/expressions/public';
import { UiActionsSetup, UiActionsStart } from 'src/plugins/ui_actions/public';
+import { FieldFormatsSetup, FieldFormatsStart } from 'src/plugins/field_formats/public';
import { AutocompleteSetup, AutocompleteStart } from './autocomplete';
-import { FieldFormatsSetup, FieldFormatsStart } from './field_formats';
import { createFiltersFromRangeSelectAction, createFiltersFromValueClickAction } from './actions';
import { ISearchSetup, ISearchStart } from './search';
import { QuerySetup, QueryStart } from './query';
@@ -29,10 +29,12 @@ export interface DataSetupDependencies {
uiActions: UiActionsSetup;
inspector: InspectorSetup;
usageCollection?: UsageCollectionSetup;
+ fieldFormats: FieldFormatsSetup;
}
export interface DataStartDependencies {
uiActions: UiActionsStart;
+ fieldFormats: FieldFormatsStart;
}
/**
@@ -41,6 +43,9 @@ export interface DataStartDependencies {
export interface DataPublicPluginSetup {
autocomplete: AutocompleteSetup;
search: ISearchSetup;
+ /**
+ * @deprecated Use fieldFormats plugin instead
+ */
fieldFormats: FieldFormatsSetup;
query: QuerySetup;
}
@@ -86,8 +91,7 @@ export interface DataPublicPluginStart {
*/
search: ISearchStart;
/**
- * field formats service
- * {@link FieldFormatsStart}
+ * @deprecated Use fieldFormats plugin instead
*/
fieldFormats: FieldFormatsStart;
/**
diff --git a/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap b/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap
index 1e7b59d8a9e76..612ffdcf5029e 100644
--- a/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap
+++ b/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap
@@ -196,6 +196,7 @@ exports[`Inspector Data View component should render empty state 1`] = `
>
import('./data_view'));
diff --git a/src/plugins/data/public/utils/table_inspector_view/components/download_options.tsx b/src/plugins/data/public/utils/table_inspector_view/components/download_options.tsx
index e79a1c2b52e03..57e586eaf12f8 100644
--- a/src/plugins/data/public/utils/table_inspector_view/components/download_options.tsx
+++ b/src/plugins/data/public/utils/table_inspector_view/components/download_options.tsx
@@ -22,7 +22,7 @@ import {
import { CSV_MIME_TYPE, datatableToCSV, tableHasFormulas } from '../../../../common';
import { Datatable } from '../../../../../expressions';
import { downloadMultipleAs } from '../../../../../share/public';
-import { FieldFormatsStart } from '../../../field_formats';
+import { FieldFormatsStart } from '../../../../../field_formats/public';
import { IUiSettingsClient } from '../../../../../../core/public';
interface DataDownloadOptionsState {
diff --git a/src/plugins/data/public/utils/table_inspector_view/index.ts b/src/plugins/data/public/utils/table_inspector_view/index.ts
index 10c74bbc99dd0..498fe8d7fcca0 100644
--- a/src/plugins/data/public/utils/table_inspector_view/index.ts
+++ b/src/plugins/data/public/utils/table_inspector_view/index.ts
@@ -11,7 +11,7 @@ import { IUiSettingsClient } from 'kibana/public';
import { Adapters, InspectorViewDescription } from '../../../../inspector/public';
import { getDataViewComponentWrapper } from './components/data_view_wrapper';
import { UiActionsStart } from '../../../../ui_actions/public';
-import { FieldFormatsStart } from '../../field_formats';
+import { FieldFormatsStart } from '../../../../field_formats/public';
import { DatatableColumn } from '../../../../expressions/common/expression_types/specs';
export const getTableViewDescription = (
diff --git a/src/plugins/data/server/index.ts b/src/plugins/data/server/index.ts
index e5656ceabc151..d010819d14e94 100644
--- a/src/plugins/data/server/index.ts
+++ b/src/plugins/data/server/index.ts
@@ -27,50 +27,7 @@ export const exporters = {
* Field Formats:
*/
-import {
- FieldFormatsRegistry,
- FieldFormat,
- BoolFormat,
- BytesFormat,
- ColorFormat,
- DurationFormat,
- IpFormat,
- NumberFormat,
- PercentFormat,
- RelativeDateFormat,
- SourceFormat,
- StaticLookupFormat,
- UrlFormat,
- StringFormat,
- TruncateFormat,
- HistogramFormat,
-} from '../common/field_formats';
-
-export const fieldFormats = {
- FieldFormatsRegistry,
- FieldFormat,
- BoolFormat,
- BytesFormat,
- ColorFormat,
- DurationFormat,
- IpFormat,
- NumberFormat,
- PercentFormat,
- RelativeDateFormat,
- SourceFormat,
- StaticLookupFormat,
- UrlFormat,
- StringFormat,
- TruncateFormat,
- HistogramFormat,
-};
-
-export {
- IFieldFormatsRegistry,
- FieldFormatsGetConfigFn,
- FieldFormatConfig,
- INDEX_PATTERN_SAVED_OBJECT_TYPE,
-} from '../common';
+export { INDEX_PATTERN_SAVED_OBJECT_TYPE } from '../common';
/*
* Index patterns:
diff --git a/src/plugins/data/server/index_patterns/index_patterns_service.ts b/src/plugins/data/server/index_patterns/index_patterns_service.ts
index 4269f15127daf..c3cdc65d3fa04 100644
--- a/src/plugins/data/server/index_patterns/index_patterns_service.ts
+++ b/src/plugins/data/server/index_patterns/index_patterns_service.ts
@@ -22,7 +22,7 @@ import { registerRoutes } from './routes';
import { indexPatternSavedObjectType } from '../saved_objects';
import { capabilitiesProvider } from './capabilities_provider';
import { IndexPatternsCommonService } from '../';
-import { FieldFormatsStart } from '../field_formats';
+import { FieldFormatsStart } from '../../../field_formats/server';
import { getIndexPatternLoad } from './expressions';
import { UiSettingsServerToCommon } from './ui_settings_wrapper';
import { IndexPatternsApiServer } from './index_patterns_api_client';
diff --git a/src/plugins/data/server/mocks.ts b/src/plugins/data/server/mocks.ts
index 786dd30dbabd0..af104dea72af7 100644
--- a/src/plugins/data/server/mocks.ts
+++ b/src/plugins/data/server/mocks.ts
@@ -11,13 +11,19 @@ import {
createSearchStartMock,
createSearchRequestHandlerContext,
} from './search/mocks';
-import { createFieldFormatsSetupMock, createFieldFormatsStartMock } from './field_formats/mocks';
+import {
+ createFieldFormatsSetupMock,
+ createFieldFormatsStartMock,
+} from '../../field_formats/server/mocks';
import { createIndexPatternsStartMock } from './index_patterns/mocks';
import { DataRequestHandlerContext } from './search';
function createSetupContract() {
return {
search: createSearchSetupMock(),
+ /**
+ * @deprecated - use directly from "fieldFormats" plugin instead
+ */
fieldFormats: createFieldFormatsSetupMock(),
};
}
@@ -25,6 +31,9 @@ function createSetupContract() {
function createStartContract() {
return {
search: createSearchStartMock(),
+ /**
+ * @deprecated - use directly from "fieldFormats" plugin instead
+ */
fieldFormats: createFieldFormatsStartMock(),
indexPatterns: createIndexPatternsStartMock(),
};
diff --git a/src/plugins/data/server/plugin.ts b/src/plugins/data/server/plugin.ts
index 7b73802f1a34d..e04095ed26a46 100644
--- a/src/plugins/data/server/plugin.ts
+++ b/src/plugins/data/server/plugin.ts
@@ -18,7 +18,7 @@ import { ScriptsService } from './scripts';
import { KqlTelemetryService } from './kql_telemetry';
import { UsageCollectionSetup } from '../../usage_collection/server';
import { AutocompleteService } from './autocomplete';
-import { FieldFormatsService, FieldFormatsSetup, FieldFormatsStart } from './field_formats';
+import { FieldFormatsSetup, FieldFormatsStart } from '../../field_formats/server';
import { getUiSettings } from './ui_settings';
export interface DataEnhancements {
@@ -27,6 +27,9 @@ export interface DataEnhancements {
export interface DataPluginSetup {
search: ISearchSetup;
+ /**
+ * @deprecated - use "fieldFormats" plugin directly instead
+ */
fieldFormats: FieldFormatsSetup;
/**
* @internal
@@ -36,6 +39,9 @@ export interface DataPluginSetup {
export interface DataPluginStart {
search: ISearchStart;
+ /**
+ * @deprecated - use "fieldFormats" plugin directly instead
+ */
fieldFormats: FieldFormatsStart;
indexPatterns: IndexPatternsServiceStart;
}
@@ -44,6 +50,7 @@ export interface DataPluginSetupDependencies {
bfetch: BfetchServerSetup;
expressions: ExpressionsServerSetup;
usageCollection?: UsageCollectionSetup;
+ fieldFormats: FieldFormatsSetup;
}
export interface DataPluginStartDependencies {
@@ -64,7 +71,6 @@ export class DataServerPlugin
private readonly kqlTelemetryService: KqlTelemetryService;
private readonly autocompleteService: AutocompleteService;
private readonly indexPatterns = new IndexPatternsServiceProvider();
- private readonly fieldFormats = new FieldFormatsService();
private readonly queryService = new QueryService();
private readonly logger: Logger;
@@ -78,7 +84,7 @@ export class DataServerPlugin
public setup(
core: CoreSetup,
- { bfetch, expressions, usageCollection }: DataPluginSetupDependencies
+ { bfetch, expressions, usageCollection, fieldFormats }: DataPluginSetupDependencies
) {
this.scriptsService.setup(core);
this.queryService.setup(core);
@@ -103,12 +109,11 @@ export class DataServerPlugin
searchSetup.__enhance(enhancements.search);
},
search: searchSetup,
- fieldFormats: this.fieldFormats.setup(),
+ fieldFormats,
};
}
- public start(core: CoreStart) {
- const fieldFormats = this.fieldFormats.start();
+ public start(core: CoreStart, { fieldFormats }: DataPluginStartDependencies) {
const indexPatterns = this.indexPatterns.start(core, {
fieldFormats,
logger: this.logger.get('indexPatterns'),
diff --git a/src/plugins/data/server/search/aggs/aggs_service.test.ts b/src/plugins/data/server/search/aggs/aggs_service.test.ts
index 0a4f54ee339a1..fdff2a4a8118c 100644
--- a/src/plugins/data/server/search/aggs/aggs_service.test.ts
+++ b/src/plugins/data/server/search/aggs/aggs_service.test.ts
@@ -11,7 +11,7 @@ import { KibanaRequest, ElasticsearchClient } from 'src/core/server';
import { coreMock } from '../../../../../core/server/mocks';
import { expressionsPluginMock } from '../../../../../plugins/expressions/server/mocks';
import { BucketAggType, getAggTypes, MetricAggType } from '../../../common';
-import { createFieldFormatsStartMock } from '../../field_formats/mocks';
+import { createFieldFormatsStartMock } from '../../../../field_formats/server/mocks';
import { createIndexPatternsStartMock } from '../../index_patterns/mocks';
import { AggsService, AggsSetupDependencies, AggsStartDependencies } from './aggs_service';
diff --git a/src/plugins/data/server/search/aggs/aggs_service.ts b/src/plugins/data/server/search/aggs/aggs_service.ts
index 96927728f2f2f..197d8fd7caa99 100644
--- a/src/plugins/data/server/search/aggs/aggs_service.ts
+++ b/src/plugins/data/server/search/aggs/aggs_service.ts
@@ -22,7 +22,7 @@ import {
calculateBounds,
TimeRange,
} from '../../../common';
-import { FieldFormatsStart } from '../../field_formats';
+import { FieldFormatsStart } from '../../../../field_formats/server';
import { IndexPatternsServiceStart } from '../../index_patterns';
import { AggsSetup, AggsStart } from './types';
diff --git a/src/plugins/data/server/search/search_service.test.ts b/src/plugins/data/server/search/search_service.test.ts
index 314cb2c3acbf8..e6db3c76ef9ba 100644
--- a/src/plugins/data/server/search/search_service.test.ts
+++ b/src/plugins/data/server/search/search_service.test.ts
@@ -11,7 +11,7 @@ import { CoreSetup, CoreStart, SavedObject } from '../../../../core/server';
import { coreMock } from '../../../../core/server/mocks';
import { DataPluginStart, DataPluginStartDependencies } from '../plugin';
-import { createFieldFormatsStartMock } from '../field_formats/mocks';
+import { createFieldFormatsStartMock } from '../../../field_formats/server/mocks';
import { createIndexPatternsStartMock } from '../index_patterns/mocks';
import { SearchService, SearchServiceSetupDependencies } from './search_service';
diff --git a/src/plugins/data/server/search/search_service.ts b/src/plugins/data/server/search/search_service.ts
index cc7981220fa6f..5b4ff121f3c77 100644
--- a/src/plugins/data/server/search/search_service.ts
+++ b/src/plugins/data/server/search/search_service.ts
@@ -34,7 +34,7 @@ import type {
import { AggsService } from './aggs';
-import { FieldFormatsStart } from '../field_formats';
+import { FieldFormatsStart } from '../../../field_formats/server';
import { IndexPatternsServiceStart } from '../index_patterns';
import { registerMsearchRoute, registerSearchRoute } from './routes';
import { ES_SEARCH_STRATEGY, esSearchStrategyProvider } from './strategies/es_search';
diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md
index 9d5e598588f25..51436dabe05a0 100644
--- a/src/plugins/data/server/server.api.md
+++ b/src/plugins/data/server/server.api.md
@@ -33,7 +33,6 @@ import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
import { ExpressionValueBoxed } from 'src/plugins/expressions/common';
import { Filter as Filter_2 } from '@kbn/es-query';
-import { FormatFactory as FormatFactory_2 } from 'src/plugins/data/common/field_formats/utils';
import { IAggConfigs as IAggConfigs_2 } from 'src/plugins/data/public';
import { IEsSearchResponse as IEsSearchResponse_2 } from 'src/plugins/data/public';
import { IFieldSubType as IFieldSubType_2 } from '@kbn/es-query';
@@ -60,7 +59,6 @@ import { PathConfigType } from '@kbn/utils';
import { Plugin as Plugin_2 } from 'src/core/server';
import { Plugin as Plugin_3 } from 'kibana/server';
import { PluginInitializerContext as PluginInitializerContext_2 } from 'src/core/server';
-import { PublicMethodsOf } from '@kbn/utility-types';
import { Query } from '@kbn/es-query';
import { RecursiveReadonly } from '@kbn/utility-types';
import { RequestAdapter } from 'src/plugins/inspector/common';
@@ -73,7 +71,7 @@ import { SavedObjectsFindOptions } from 'kibana/server';
import { SavedObjectsFindResponse } from 'kibana/server';
import { SavedObjectsUpdateResponse } from 'kibana/server';
import { Search } from '@elastic/elasticsearch/api/requestParams';
-import { SerializedFieldFormat as SerializedFieldFormat_2 } from 'src/plugins/expressions/common';
+import { SerializedFieldFormat as SerializedFieldFormat_3 } from 'src/plugins/expressions/common';
import { SharedGlobalConfig as SharedGlobalConfig_2 } from 'kibana/server';
import { ToastInputFields } from 'src/core/public/notifications';
import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport';
@@ -488,48 +486,6 @@ export { FieldDescriptor }
export { FieldDescriptor as IndexPatternFieldDescriptor }
-// Warning: (ae-missing-release-tag) "FieldFormatConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export interface FieldFormatConfig {
- // (undocumented)
- es?: boolean;
- // Warning: (ae-forgotten-export) The symbol "FieldFormatId" needs to be exported by the entry point index.d.ts
- //
- // (undocumented)
- id: FieldFormatId;
- // (undocumented)
- params: Record;
-}
-
-// Warning: (ae-missing-release-tag) "fieldFormats" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export const fieldFormats: {
- FieldFormatsRegistry: typeof FieldFormatsRegistry;
- FieldFormat: typeof FieldFormat;
- BoolFormat: typeof BoolFormat;
- BytesFormat: typeof BytesFormat;
- ColorFormat: typeof ColorFormat;
- DurationFormat: typeof DurationFormat;
- IpFormat: typeof IpFormat;
- NumberFormat: typeof NumberFormat;
- PercentFormat: typeof PercentFormat;
- RelativeDateFormat: typeof RelativeDateFormat;
- SourceFormat: typeof SourceFormat;
- StaticLookupFormat: typeof StaticLookupFormat;
- UrlFormat: typeof UrlFormat;
- StringFormat: typeof StringFormat;
- TruncateFormat: typeof TruncateFormat;
- HistogramFormat: typeof HistogramFormat;
-};
-
-// Warning: (ae-forgotten-export) The symbol "GetConfigFn" needs to be exported by the entry point index.d.ts
-// Warning: (ae-missing-release-tag) "FieldFormatsGetConfigFn" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export type FieldFormatsGetConfigFn = GetConfigFn;
-
// Warning: (ae-missing-release-tag) "Filter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public @deprecated (undocumented)
@@ -607,11 +563,6 @@ export interface IEsSearchRequest extends IKibanaSearchRequest = IKibanaSearchResponse>;
-// Warning: (ae-missing-release-tag) "IFieldFormatsRegistry" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export type IFieldFormatsRegistry = PublicMethodsOf;
-
// Warning: (ae-forgotten-export) The symbol "FieldParamType" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "IFieldParamType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -721,6 +672,7 @@ export class IndexPattern implements IIndexPattern {
};
// (undocumented)
getFieldByName(name: string): IndexPatternField | undefined;
+ // Warning: (ae-forgotten-export) The symbol "FieldFormat" needs to be exported by the entry point index.d.ts
getFormatterForField(field: IndexPatternField | IndexPatternField['spec'] | IFieldType): FieldFormat;
getFormatterForFieldNoDefault(fieldname: string): FieldFormat | undefined;
// @deprecated (undocumented)
@@ -769,7 +721,7 @@ export class IndexPattern implements IIndexPattern {
// Warning: (ae-forgotten-export) The symbol "SerializedFieldFormat" needs to be exported by the entry point index.d.ts
//
// (undocumented)
- readonly setFieldFormat: (fieldName: string, format: SerializedFieldFormat) => void;
+ readonly setFieldFormat: (fieldName: string, format: SerializedFieldFormat_2) => void;
// Warning: (ae-forgotten-export) The symbol "SourceFilter" needs to be exported by the entry point index.d.ts
//
// (undocumented)
@@ -1196,18 +1148,14 @@ export function parseInterval(interval: string): moment.Duration | null;
export class Plugin implements Plugin_2 {
constructor(initializerContext: PluginInitializerContext_2);
// (undocumented)
- setup(core: CoreSetup, { bfetch, expressions, usageCollection }: DataPluginSetupDependencies): {
+ setup(core: CoreSetup, { bfetch, expressions, usageCollection, fieldFormats }: DataPluginSetupDependencies): {
__enhance: (enhancements: DataEnhancements) => void;
search: ISearchSetup;
- fieldFormats: {
- register: (customFieldFormat: import("../public").FieldFormatInstanceType) => number;
- };
+ fieldFormats: FieldFormatsSetup;
};
// (undocumented)
- start(core: CoreStart_2): {
- fieldFormats: {
- fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise;
- };
+ start(core: CoreStart_2, { fieldFormats }: DataPluginStartDependencies): {
+ fieldFormats: FieldFormatsStart;
indexPatterns: {
indexPatternsServiceFactory: (savedObjectsClient: Pick, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise;
};
@@ -1228,9 +1176,7 @@ export function plugin(initializerContext: PluginInitializerContext void;
- // Warning: (ae-forgotten-export) The symbol "FieldFormatsSetup" needs to be exported by the entry point index.d.ts
- //
- // (undocumented)
+ // @deprecated (undocumented)
fieldFormats: FieldFormatsSetup;
// (undocumented)
search: ISearchSetup;
@@ -1240,9 +1186,7 @@ export interface PluginSetup {
//
// @public (undocumented)
export interface PluginStart {
- // Warning: (ae-forgotten-export) The symbol "FieldFormatsStart" needs to be exported by the entry point index.d.ts
- //
- // (undocumented)
+ // @deprecated (undocumented)
fieldFormats: FieldFormatsStart;
// (undocumented)
indexPatterns: IndexPatternsServiceStart;
@@ -1425,13 +1369,6 @@ export const UI_SETTINGS: {
readonly HISTOGRAM_BAR_TARGET: "histogram:barTarget";
readonly HISTOGRAM_MAX_BARS: "histogram:maxBars";
readonly HISTORY_LIMIT: "history:limit";
- readonly SHORT_DOTS_ENABLE: "shortDots:enable";
- readonly FORMAT_DEFAULT_TYPE_MAP: "format:defaultTypeMap";
- readonly FORMAT_NUMBER_DEFAULT_PATTERN: "format:number:defaultPattern";
- readonly FORMAT_PERCENT_DEFAULT_PATTERN: "format:percent:defaultPattern";
- readonly FORMAT_BYTES_DEFAULT_PATTERN: "format:bytes:defaultPattern";
- readonly FORMAT_CURRENCY_DEFAULT_PATTERN: "format:currency:defaultPattern";
- readonly FORMAT_NUMBER_DEFAULT_LOCALE: "format:number:defaultLocale";
readonly TIMEPICKER_REFRESH_INTERVAL_DEFAULTS: "timepicker:refreshIntervalDefaults";
readonly TIMEPICKER_QUICK_RANGES: "timepicker:quickRanges";
readonly TIMEPICKER_TIME_DEFAULTS: "timepicker:timeDefaults";
@@ -1455,37 +1392,23 @@ export function usageProvider(core: CoreSetup_2): SearchUsage;
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:139:7 - (ae-forgotten-export) The symbol "FieldAttrSet" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:170:7 - (ae-forgotten-export) The symbol "RuntimeField" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:21:23 - (ae-forgotten-export) The symbol "datatableToCSV" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "FieldFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "DurationFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:49:26 - (ae-forgotten-export) The symbol "HistogramFormat" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:81:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:81:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:198:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:198:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:200:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:201:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:210:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:211:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:212:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:216:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:217:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:221:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:224:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:225:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/plugin.ts:81:74 - (ae-forgotten-export) The symbol "DataEnhancements" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:38:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:38:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:155:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:155:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:157:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:158:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:167:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:168:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:169:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:173:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:174:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:178:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:181:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:182:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/plugin.ts:87:88 - (ae-forgotten-export) The symbol "DataEnhancements" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/plugin.ts:110:7 - (ae-forgotten-export) The symbol "FieldFormatsSetup" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/plugin.ts:117:14 - (ae-forgotten-export) The symbol "FieldFormatsStart" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/search/types.ts:120:5 - (ae-forgotten-export) The symbol "ISearchStartSearchSource" needs to be exported by the entry point index.d.ts
// (No @packageDocumentation comment for this package)
diff --git a/src/plugins/data/server/ui_settings.ts b/src/plugins/data/server/ui_settings.ts
index 0723c4b2d85c2..360529ad5a735 100644
--- a/src/plugins/data/server/ui_settings.ts
+++ b/src/plugins/data/server/ui_settings.ts
@@ -9,8 +9,6 @@
import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { UiSettingsParams } from 'kibana/server';
-// @ts-ignore untyped module
-import numeralLanguages from '@elastic/numeral/languages';
import { DEFAULT_QUERY_LANGUAGE, UI_SETTINGS } from '../common';
const luceneQueryLanguageLabel = i18n.translate('data.advancedSettings.searchQueryLanguageLucene', {
@@ -33,15 +31,6 @@ const requestPreferenceOptionLabels = {
}),
};
-// We add the `en` key manually here, since that's not a real numeral locale, but the
-// default fallback in case the locale is not found.
-const numeralLanguageIds = [
- 'en',
- ...numeralLanguages.map((numeralLanguage: any) => {
- return numeralLanguage.id;
- }),
-];
-
export function getUiSettings(): Record> {
return {
[UI_SETTINGS.META_FIELDS]: {
@@ -341,192 +330,6 @@ export function getUiSettings(): Record> {
}),
schema: schema.number(),
},
- [UI_SETTINGS.SHORT_DOTS_ENABLE]: {
- name: i18n.translate('data.advancedSettings.shortenFieldsTitle', {
- defaultMessage: 'Shorten fields',
- }),
- value: false,
- description: i18n.translate('data.advancedSettings.shortenFieldsText', {
- defaultMessage: 'Shorten long fields, for example, instead of foo.bar.baz, show f.b.baz',
- }),
- schema: schema.boolean(),
- },
- [UI_SETTINGS.FORMAT_DEFAULT_TYPE_MAP]: {
- name: i18n.translate('data.advancedSettings.format.defaultTypeMapTitle', {
- defaultMessage: 'Field type format name',
- }),
- value: `{
- "ip": { "id": "ip", "params": {} },
- "date": { "id": "date", "params": {} },
- "date_nanos": { "id": "date_nanos", "params": {}, "es": true },
- "number": { "id": "number", "params": {} },
- "boolean": { "id": "boolean", "params": {} },
- "histogram": { "id": "histogram", "params": {} },
- "_source": { "id": "_source", "params": {} },
- "_default_": { "id": "string", "params": {} }
-}`,
- type: 'json',
- description: i18n.translate('data.advancedSettings.format.defaultTypeMapText', {
- defaultMessage:
- 'Map of the format name to use by default for each field type. ' +
- '{defaultFormat} is used if the field type is not mentioned explicitly',
- values: {
- defaultFormat: '"_default_"',
- },
- }),
- schema: schema.object({
- ip: schema.object({
- id: schema.string(),
- params: schema.object({}),
- }),
- date: schema.object({
- id: schema.string(),
- params: schema.object({}),
- }),
- date_nanos: schema.object({
- id: schema.string(),
- params: schema.object({}),
- es: schema.boolean(),
- }),
- number: schema.object({
- id: schema.string(),
- params: schema.object({}),
- }),
- boolean: schema.object({
- id: schema.string(),
- params: schema.object({}),
- }),
- histogram: schema.object({
- id: schema.string(),
- params: schema.object({}),
- }),
- _source: schema.object({
- id: schema.string(),
- params: schema.object({}),
- }),
- _default_: schema.object({
- id: schema.string(),
- params: schema.object({}),
- }),
- }),
- },
- [UI_SETTINGS.FORMAT_NUMBER_DEFAULT_PATTERN]: {
- name: i18n.translate('data.advancedSettings.format.numberFormatTitle', {
- defaultMessage: 'Number format',
- }),
- value: '0,0.[000]',
- type: 'string',
- description: i18n.translate('data.advancedSettings.format.numberFormatText', {
- defaultMessage: 'Default {numeralFormatLink} for the "number" format',
- description:
- 'Part of composite text: data.advancedSettings.format.numberFormatText + ' +
- 'data.advancedSettings.format.numberFormat.numeralFormatLinkText',
- values: {
- numeralFormatLink:
- '' +
- i18n.translate('data.advancedSettings.format.numberFormat.numeralFormatLinkText', {
- defaultMessage: 'numeral format',
- }) +
- '',
- },
- }),
- schema: schema.string(),
- },
- [UI_SETTINGS.FORMAT_PERCENT_DEFAULT_PATTERN]: {
- name: i18n.translate('data.advancedSettings.format.percentFormatTitle', {
- defaultMessage: 'Percent format',
- }),
- value: '0,0.[000]%',
- type: 'string',
- description: i18n.translate('data.advancedSettings.format.percentFormatText', {
- defaultMessage: 'Default {numeralFormatLink} for the "percent" format',
- description:
- 'Part of composite text: data.advancedSettings.format.percentFormatText + ' +
- 'data.advancedSettings.format.percentFormat.numeralFormatLinkText',
- values: {
- numeralFormatLink:
- '' +
- i18n.translate('data.advancedSettings.format.percentFormat.numeralFormatLinkText', {
- defaultMessage: 'numeral format',
- }) +
- '',
- },
- }),
- schema: schema.string(),
- },
- [UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN]: {
- name: i18n.translate('data.advancedSettings.format.bytesFormatTitle', {
- defaultMessage: 'Bytes format',
- }),
- value: '0,0.[0]b',
- type: 'string',
- description: i18n.translate('data.advancedSettings.format.bytesFormatText', {
- defaultMessage: 'Default {numeralFormatLink} for the "bytes" format',
- description:
- 'Part of composite text: data.advancedSettings.format.bytesFormatText + ' +
- 'data.advancedSettings.format.bytesFormat.numeralFormatLinkText',
- values: {
- numeralFormatLink:
- '' +
- i18n.translate('data.advancedSettings.format.bytesFormat.numeralFormatLinkText', {
- defaultMessage: 'numeral format',
- }) +
- '',
- },
- }),
- schema: schema.string(),
- },
- [UI_SETTINGS.FORMAT_CURRENCY_DEFAULT_PATTERN]: {
- name: i18n.translate('data.advancedSettings.format.currencyFormatTitle', {
- defaultMessage: 'Currency format',
- }),
- value: '($0,0.[00])',
- type: 'string',
- description: i18n.translate('data.advancedSettings.format.currencyFormatText', {
- defaultMessage: 'Default {numeralFormatLink} for the "currency" format',
- description:
- 'Part of composite text: data.advancedSettings.format.currencyFormatText + ' +
- 'data.advancedSettings.format.currencyFormat.numeralFormatLinkText',
- values: {
- numeralFormatLink:
- '' +
- i18n.translate('data.advancedSettings.format.currencyFormat.numeralFormatLinkText', {
- defaultMessage: 'numeral format',
- }) +
- '',
- },
- }),
- schema: schema.string(),
- },
- [UI_SETTINGS.FORMAT_NUMBER_DEFAULT_LOCALE]: {
- name: i18n.translate('data.advancedSettings.format.formattingLocaleTitle', {
- defaultMessage: 'Formatting locale',
- }),
- value: 'en',
- type: 'select',
- options: numeralLanguageIds,
- optionLabels: Object.fromEntries(
- numeralLanguages.map((language: Record) => [language.id, language.name])
- ),
- description: i18n.translate('data.advancedSettings.format.formattingLocaleText', {
- defaultMessage: `{numeralLanguageLink} locale`,
- description:
- 'Part of composite text: data.advancedSettings.format.formattingLocale.numeralLanguageLinkText + ' +
- 'data.advancedSettings.format.formattingLocaleText',
- values: {
- numeralLanguageLink:
- '' +
- i18n.translate(
- 'data.advancedSettings.format.formattingLocale.numeralLanguageLinkText',
- {
- defaultMessage: 'Numeral language',
- }
- ) +
- '',
- },
- }),
- schema: schema.string(),
- },
[UI_SETTINGS.TIMEPICKER_REFRESH_INTERVAL_DEFAULTS]: {
name: i18n.translate('data.advancedSettings.timepicker.refreshIntervalDefaultsTitle', {
defaultMessage: 'Time filter refresh interval',
diff --git a/src/plugins/data/tsconfig.json b/src/plugins/data/tsconfig.json
index 9c95878af631e..6e4e89f7538fd 100644
--- a/src/plugins/data/tsconfig.json
+++ b/src/plugins/data/tsconfig.json
@@ -23,6 +23,7 @@
{ "path": "../inspector/tsconfig.json" },
{ "path": "../usage_collection/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
- { "path": "../kibana_react/tsconfig.json" }
+ { "path": "../kibana_react/tsconfig.json" },
+ { "path": "../field_formats/tsconfig.json" }
]
}
diff --git a/src/plugins/discover/kibana.json b/src/plugins/discover/kibana.json
index 04469e0ef4276..f612e0ec2cc8d 100644
--- a/src/plugins/discover/kibana.json
+++ b/src/plugins/discover/kibana.json
@@ -16,7 +16,7 @@
"indexPatternFieldEditor"
],
"optionalPlugins": ["home", "share", "usageCollection"],
- "requiredBundles": ["kibanaUtils", "home", "kibanaReact"],
+ "requiredBundles": ["kibanaUtils", "home", "kibanaReact", "fieldFormats"],
"owner": {
"name": "Kibana App",
"githubTeam": "kibana-app"
diff --git a/src/plugins/discover/public/application/angular/doc_table/components/table_header.ts b/src/plugins/discover/public/application/angular/doc_table/components/table_header.ts
index 5e3a025d8c7ba..0f6c86df0db64 100644
--- a/src/plugins/discover/public/application/angular/doc_table/components/table_header.ts
+++ b/src/plugins/discover/public/application/angular/doc_table/components/table_header.ts
@@ -9,7 +9,7 @@
import { TableHeader } from './table_header/table_header';
import { getServices } from '../../../../kibana_services';
import { SORT_DEFAULT_ORDER_SETTING, DOC_HIDE_TIME_COLUMN_SETTING } from '../../../../../common';
-import { UI_SETTINGS } from '../../../../../../data/public';
+import { FORMATS_UI_SETTINGS } from '../../../../../../field_formats/common';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function createTableHeaderDirective(reactDirective: any) {
@@ -30,7 +30,7 @@ export function createTableHeaderDirective(reactDirective: any) {
{ restrict: 'A' },
{
hideTimeColumn: config.get(DOC_HIDE_TIME_COLUMN_SETTING, false),
- isShortDots: config.get(UI_SETTINGS.SHORT_DOTS_ENABLE),
+ isShortDots: config.get(FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE),
defaultSortOrder: config.get(SORT_DEFAULT_ORDER_SETTING, 'desc'),
}
);
diff --git a/src/plugins/discover/public/application/angular/helpers/row_formatter.test.ts b/src/plugins/discover/public/application/angular/helpers/row_formatter.test.ts
index 80fb8a570f78b..6b356446850e6 100644
--- a/src/plugins/discover/public/application/angular/helpers/row_formatter.test.ts
+++ b/src/plugins/discover/public/application/angular/helpers/row_formatter.test.ts
@@ -9,7 +9,7 @@
import { formatRow, formatTopLevelObject } from './row_formatter';
import { stubbedSavedObjectIndexPattern } from '../../../__mocks__/stubbed_saved_object_index_pattern';
import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns';
-import { fieldFormatsMock } from '../../../../../data/common/field_formats/mocks';
+import { fieldFormatsMock } from '../../../../../field_formats/common/mocks';
import { setServices } from '../../../kibana_services';
import { DiscoverServices } from '../../../build_services';
diff --git a/src/plugins/discover/public/application/components/source_viewer/__snapshots__/source_viewer.test.tsx.snap b/src/plugins/discover/public/application/components/source_viewer/__snapshots__/source_viewer.test.tsx.snap
index 5f6dabc26659f..dfded530c6983 100644
--- a/src/plugins/discover/public/application/components/source_viewer/__snapshots__/source_viewer.test.tsx.snap
+++ b/src/plugins/discover/public/application/components/source_viewer/__snapshots__/source_viewer.test.tsx.snap
@@ -167,6 +167,7 @@ exports[`Source Viewer component renders error state 1`] = `
>
{
const config: Record = {};
- config[UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN] = '0,0.[000]b';
+ config[FORMATS_UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN] = '0,0.[000]b';
const getConfig = (key: string) => config[key];
diff --git a/src/plugins/data/common/field_formats/converters/bytes.ts b/src/plugins/field_formats/common/converters/bytes.ts
similarity index 91%
rename from src/plugins/data/common/field_formats/converters/bytes.ts
rename to src/plugins/field_formats/common/converters/bytes.ts
index 840a59f3d3092..829063aa07d02 100644
--- a/src/plugins/data/common/field_formats/converters/bytes.ts
+++ b/src/plugins/field_formats/common/converters/bytes.ts
@@ -12,7 +12,7 @@ import { FIELD_FORMAT_IDS } from '../types';
export class BytesFormat extends NumeralFormat {
static id = FIELD_FORMAT_IDS.BYTES;
- static title = i18n.translate('data.fieldFormats.bytes.title', {
+ static title = i18n.translate('fieldFormats.bytes.title', {
defaultMessage: 'Bytes',
});
diff --git a/src/plugins/data/common/field_formats/converters/color.test.ts b/src/plugins/field_formats/common/converters/color.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/color.test.ts
rename to src/plugins/field_formats/common/converters/color.test.ts
diff --git a/src/plugins/data/common/field_formats/converters/color.tsx b/src/plugins/field_formats/common/converters/color.tsx
similarity index 97%
rename from src/plugins/data/common/field_formats/converters/color.tsx
rename to src/plugins/field_formats/common/converters/color.tsx
index f653c6a4f82a2..d3a6964619cae 100644
--- a/src/plugins/data/common/field_formats/converters/color.tsx
+++ b/src/plugins/field_formats/common/converters/color.tsx
@@ -18,7 +18,7 @@ import { DEFAULT_CONVERTER_COLOR } from '../constants/color_default';
export class ColorFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.COLOR;
- static title = i18n.translate('data.fieldFormats.color.title', {
+ static title = i18n.translate('fieldFormats.color.title', {
defaultMessage: 'Color',
});
static fieldType = [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.STRING];
diff --git a/src/plugins/data/common/field_formats/converters/custom.ts b/src/plugins/field_formats/common/converters/custom.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/custom.ts
rename to src/plugins/field_formats/common/converters/custom.ts
diff --git a/src/plugins/data/common/field_formats/converters/date_nanos_shared.test.ts b/src/plugins/field_formats/common/converters/date_nanos_shared.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/date_nanos_shared.test.ts
rename to src/plugins/field_formats/common/converters/date_nanos_shared.test.ts
diff --git a/src/plugins/data/common/field_formats/converters/date_nanos_shared.ts b/src/plugins/field_formats/common/converters/date_nanos_shared.ts
similarity index 96%
rename from src/plugins/data/common/field_formats/converters/date_nanos_shared.ts
rename to src/plugins/field_formats/common/converters/date_nanos_shared.ts
index d058d0c6a6574..1d226c936a977 100644
--- a/src/plugins/data/common/field_formats/converters/date_nanos_shared.ts
+++ b/src/plugins/field_formats/common/converters/date_nanos_shared.ts
@@ -8,8 +8,9 @@
import { i18n } from '@kbn/i18n';
import { memoize, noop } from 'lodash';
+import { KBN_FIELD_TYPES } from '@kbn/field-types';
import moment, { Moment } from 'moment';
-import { FieldFormat, FIELD_FORMAT_IDS, KBN_FIELD_TYPES } from '../../';
+import { FieldFormat, FIELD_FORMAT_IDS } from '../';
import { TextContextTypeConvert } from '../types';
/**
@@ -59,7 +60,7 @@ export function formatWithNanos(
export class DateNanosFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.DATE_NANOS;
- static title = i18n.translate('data.fieldFormats.date_nanos.title', {
+ static title = i18n.translate('fieldFormats.date_nanos.title', {
defaultMessage: 'Date nanos',
});
static fieldType = KBN_FIELD_TYPES.DATE;
diff --git a/src/plugins/data/common/field_formats/converters/duration.test.ts b/src/plugins/field_formats/common/converters/duration.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/duration.test.ts
rename to src/plugins/field_formats/common/converters/duration.test.ts
diff --git a/src/plugins/data/common/field_formats/converters/duration.ts b/src/plugins/field_formats/common/converters/duration.ts
similarity index 74%
rename from src/plugins/data/common/field_formats/converters/duration.ts
rename to src/plugins/field_formats/common/converters/duration.ts
index 926f907af8fe9..a92a6756b335c 100644
--- a/src/plugins/data/common/field_formats/converters/duration.ts
+++ b/src/plugins/field_formats/common/converters/duration.ts
@@ -21,76 +21,76 @@ const HUMAN_FRIENDLY = 'humanize';
const HUMAN_FRIENDLY_PRECISE = 'humanizePrecise';
const DEFAULT_OUTPUT_PRECISION = 2;
const DEFAULT_INPUT_FORMAT = {
- text: i18n.translate('data.fieldFormats.duration.inputFormats.seconds', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.seconds', {
defaultMessage: 'Seconds',
}),
kind: 'seconds',
};
const inputFormats = [
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.picoseconds', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.picoseconds', {
defaultMessage: 'Picoseconds',
}),
kind: 'picoseconds',
},
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.nanoseconds', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.nanoseconds', {
defaultMessage: 'Nanoseconds',
}),
kind: 'nanoseconds',
},
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.microseconds', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.microseconds', {
defaultMessage: 'Microseconds',
}),
kind: 'microseconds',
},
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.milliseconds', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.milliseconds', {
defaultMessage: 'Milliseconds',
}),
kind: 'milliseconds',
},
{ ...DEFAULT_INPUT_FORMAT },
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.minutes', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.minutes', {
defaultMessage: 'Minutes',
}),
kind: 'minutes',
},
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.hours', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.hours', {
defaultMessage: 'Hours',
}),
kind: 'hours',
},
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.days', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.days', {
defaultMessage: 'Days',
}),
kind: 'days',
},
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.weeks', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.weeks', {
defaultMessage: 'Weeks',
}),
kind: 'weeks',
},
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.months', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.months', {
defaultMessage: 'Months',
}),
kind: 'months',
},
{
- text: i18n.translate('data.fieldFormats.duration.inputFormats.years', {
+ text: i18n.translate('fieldFormats.duration.inputFormats.years', {
defaultMessage: 'Years',
}),
kind: 'years',
},
];
const DEFAULT_OUTPUT_FORMAT = {
- text: i18n.translate('data.fieldFormats.duration.outputFormats.humanize.approximate', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.humanize.approximate', {
defaultMessage: 'Human-readable (approximate)',
}),
method: 'humanize',
@@ -98,79 +98,79 @@ const DEFAULT_OUTPUT_FORMAT = {
const outputFormats = [
{ ...DEFAULT_OUTPUT_FORMAT },
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.humanize.precise', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.humanize.precise', {
defaultMessage: 'Human-readable (precise)',
}),
method: 'humanizePrecise',
},
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.asMilliseconds', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.asMilliseconds', {
defaultMessage: 'Milliseconds',
}),
- shortText: i18n.translate('data.fieldFormats.duration.outputFormats.asMilliseconds.short', {
+ shortText: i18n.translate('fieldFormats.duration.outputFormats.asMilliseconds.short', {
defaultMessage: 'ms',
}),
method: 'asMilliseconds',
},
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.asSeconds', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.asSeconds', {
defaultMessage: 'Seconds',
}),
- shortText: i18n.translate('data.fieldFormats.duration.outputFormats.asSeconds.short', {
+ shortText: i18n.translate('fieldFormats.duration.outputFormats.asSeconds.short', {
defaultMessage: 's',
}),
method: 'asSeconds',
},
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.asMinutes', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.asMinutes', {
defaultMessage: 'Minutes',
}),
- shortText: i18n.translate('data.fieldFormats.duration.outputFormats.asMinutes.short', {
+ shortText: i18n.translate('fieldFormats.duration.outputFormats.asMinutes.short', {
defaultMessage: 'min',
}),
method: 'asMinutes',
},
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.asHours', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.asHours', {
defaultMessage: 'Hours',
}),
- shortText: i18n.translate('data.fieldFormats.duration.outputFormats.asHours.short', {
+ shortText: i18n.translate('fieldFormats.duration.outputFormats.asHours.short', {
defaultMessage: 'h',
}),
method: 'asHours',
},
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.asDays', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.asDays', {
defaultMessage: 'Days',
}),
- shortText: i18n.translate('data.fieldFormats.duration.outputFormats.asDays.short', {
+ shortText: i18n.translate('fieldFormats.duration.outputFormats.asDays.short', {
defaultMessage: 'd',
}),
method: 'asDays',
},
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.asWeeks', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.asWeeks', {
defaultMessage: 'Weeks',
}),
- shortText: i18n.translate('data.fieldFormats.duration.outputFormats.asWeeks.short', {
+ shortText: i18n.translate('fieldFormats.duration.outputFormats.asWeeks.short', {
defaultMessage: 'w',
}),
method: 'asWeeks',
},
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.asMonths', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.asMonths', {
defaultMessage: 'Months',
}),
- shortText: i18n.translate('data.fieldFormats.duration.outputFormats.asMonths.short', {
+ shortText: i18n.translate('fieldFormats.duration.outputFormats.asMonths.short', {
defaultMessage: 'mon',
}),
method: 'asMonths',
},
{
- text: i18n.translate('data.fieldFormats.duration.outputFormats.asYears', {
+ text: i18n.translate('fieldFormats.duration.outputFormats.asYears', {
defaultMessage: 'Years',
}),
- shortText: i18n.translate('data.fieldFormats.duration.outputFormats.asYears.short', {
+ shortText: i18n.translate('fieldFormats.duration.outputFormats.asYears.short', {
defaultMessage: 'y',
}),
method: 'asYears',
@@ -210,7 +210,7 @@ function formatInputHumanPrecise(
export class DurationFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.DURATION;
- static title = i18n.translate('data.fieldFormats.duration.title', {
+ static title = i18n.translate('fieldFormats.duration.title', {
defaultMessage: 'Duration',
});
static fieldType = KBN_FIELD_TYPES.NUMBER;
@@ -250,7 +250,7 @@ export class DurationFormat extends FieldFormat {
const prefix =
val < 0 && human
- ? i18n.translate('data.fieldFormats.duration.negativeLabel', {
+ ? i18n.translate('fieldFormats.duration.negativeLabel', {
defaultMessage: 'minus',
}) + ' '
: '';
diff --git a/src/plugins/data/common/field_formats/converters/histogram.ts b/src/plugins/field_formats/common/converters/histogram.ts
similarity index 95%
rename from src/plugins/data/common/field_formats/converters/histogram.ts
rename to src/plugins/field_formats/common/converters/histogram.ts
index 0812dcc795dc9..586d42ffa7a31 100644
--- a/src/plugins/data/common/field_formats/converters/histogram.ts
+++ b/src/plugins/field_formats/common/converters/histogram.ts
@@ -17,7 +17,7 @@ import { PercentFormat } from './percent';
export class HistogramFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.HISTOGRAM;
static fieldType = KBN_FIELD_TYPES.HISTOGRAM;
- static title = i18n.translate('data.fieldFormats.histogram.title', {
+ static title = i18n.translate('fieldFormats.histogram.title', {
defaultMessage: 'Histogram',
});
diff --git a/src/plugins/data/common/field_formats/converters/index.ts b/src/plugins/field_formats/common/converters/index.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/index.ts
rename to src/plugins/field_formats/common/converters/index.ts
diff --git a/src/plugins/data/common/field_formats/converters/ip.test.ts b/src/plugins/field_formats/common/converters/ip.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/ip.test.ts
rename to src/plugins/field_formats/common/converters/ip.test.ts
diff --git a/src/plugins/data/common/field_formats/converters/ip.ts b/src/plugins/field_formats/common/converters/ip.ts
similarity index 94%
rename from src/plugins/data/common/field_formats/converters/ip.ts
rename to src/plugins/field_formats/common/converters/ip.ts
index 76fe4404e2418..b981eca5db441 100644
--- a/src/plugins/data/common/field_formats/converters/ip.ts
+++ b/src/plugins/field_formats/common/converters/ip.ts
@@ -13,7 +13,7 @@ import { TextContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
export class IpFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.IP;
- static title = i18n.translate('data.fieldFormats.ip.title', {
+ static title = i18n.translate('fieldFormats.ip.title', {
defaultMessage: 'IP address',
});
static fieldType = KBN_FIELD_TYPES.IP;
diff --git a/src/plugins/data/common/field_formats/converters/number.test.ts b/src/plugins/field_formats/common/converters/number.test.ts
similarity index 85%
rename from src/plugins/data/common/field_formats/converters/number.test.ts
rename to src/plugins/field_formats/common/converters/number.test.ts
index 837031b59dc5c..da849fae1e6ab 100644
--- a/src/plugins/data/common/field_formats/converters/number.test.ts
+++ b/src/plugins/field_formats/common/converters/number.test.ts
@@ -7,12 +7,12 @@
*/
import { NumberFormat } from './number';
-import { UI_SETTINGS } from '../../constants';
+import { FORMATS_UI_SETTINGS } from '../constants/ui_settings';
describe('NumberFormat', () => {
const config: Record = {};
- config[UI_SETTINGS.FORMAT_NUMBER_DEFAULT_PATTERN] = '0,0.[000]';
+ config[FORMATS_UI_SETTINGS.FORMAT_NUMBER_DEFAULT_PATTERN] = '0,0.[000]';
const getConfig = (key: string) => config[key];
diff --git a/src/plugins/data/common/field_formats/converters/number.ts b/src/plugins/field_formats/common/converters/number.ts
similarity index 91%
rename from src/plugins/data/common/field_formats/converters/number.ts
rename to src/plugins/field_formats/common/converters/number.ts
index c8c98d010dc61..36470cbd14874 100644
--- a/src/plugins/data/common/field_formats/converters/number.ts
+++ b/src/plugins/field_formats/common/converters/number.ts
@@ -12,7 +12,7 @@ import { FIELD_FORMAT_IDS } from '../types';
export class NumberFormat extends NumeralFormat {
static id = FIELD_FORMAT_IDS.NUMBER;
- static title = i18n.translate('data.fieldFormats.number.title', {
+ static title = i18n.translate('fieldFormats.number.title', {
defaultMessage: 'Number',
});
diff --git a/src/plugins/data/common/field_formats/converters/numeral.ts b/src/plugins/field_formats/common/converters/numeral.ts
similarity index 90%
rename from src/plugins/data/common/field_formats/converters/numeral.ts
rename to src/plugins/field_formats/common/converters/numeral.ts
index 9d8b7ba1c369d..7f11b6377836d 100644
--- a/src/plugins/data/common/field_formats/converters/numeral.ts
+++ b/src/plugins/field_formats/common/converters/numeral.ts
@@ -13,7 +13,7 @@ import numeralLanguages from '@elastic/numeral/languages';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { FieldFormat } from '../field_format';
import { TextContextTypeConvert } from '../types';
-import { UI_SETTINGS } from '../../constants';
+import { FORMATS_UI_SETTINGS } from '../constants/ui_settings';
const numeralInst = numeral();
@@ -42,7 +42,7 @@ export abstract class NumeralFormat extends FieldFormat {
const previousLocale = numeral.language();
const defaultLocale =
- (this.getConfig && this.getConfig(UI_SETTINGS.FORMAT_NUMBER_DEFAULT_LOCALE)) || 'en';
+ (this.getConfig && this.getConfig(FORMATS_UI_SETTINGS.FORMAT_NUMBER_DEFAULT_LOCALE)) || 'en';
numeral.language(defaultLocale);
const formatted = numeralInst.set(val).format(this.param('pattern'));
diff --git a/src/plugins/data/common/field_formats/converters/percent.test.ts b/src/plugins/field_formats/common/converters/percent.test.ts
similarity index 85%
rename from src/plugins/data/common/field_formats/converters/percent.test.ts
rename to src/plugins/field_formats/common/converters/percent.test.ts
index 77f4274759ba3..d01acf571f9d9 100644
--- a/src/plugins/data/common/field_formats/converters/percent.test.ts
+++ b/src/plugins/field_formats/common/converters/percent.test.ts
@@ -7,12 +7,12 @@
*/
import { PercentFormat } from './percent';
-import { UI_SETTINGS } from '../../constants';
+import { FORMATS_UI_SETTINGS } from '../constants/ui_settings';
describe('PercentFormat', () => {
const config: Record = {};
- config[UI_SETTINGS.FORMAT_PERCENT_DEFAULT_PATTERN] = '0,0.[000]%';
+ config[FORMATS_UI_SETTINGS.FORMAT_PERCENT_DEFAULT_PATTERN] = '0,0.[000]%';
const getConfig = (key: string) => config[key];
diff --git a/src/plugins/data/common/field_formats/converters/percent.ts b/src/plugins/field_formats/common/converters/percent.ts
similarity index 82%
rename from src/plugins/data/common/field_formats/converters/percent.ts
rename to src/plugins/field_formats/common/converters/percent.ts
index a402975c672e2..3fd70c8ce74a8 100644
--- a/src/plugins/data/common/field_formats/converters/percent.ts
+++ b/src/plugins/field_formats/common/converters/percent.ts
@@ -9,11 +9,11 @@
import { i18n } from '@kbn/i18n';
import { NumeralFormat } from './numeral';
import { TextContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
-import { UI_SETTINGS } from '../../constants';
+import { FORMATS_UI_SETTINGS } from '../constants/ui_settings';
export class PercentFormat extends NumeralFormat {
static id = FIELD_FORMAT_IDS.PERCENT;
- static title = i18n.translate('data.fieldFormats.percent.title', {
+ static title = i18n.translate('fieldFormats.percent.title', {
defaultMessage: 'Percentage',
});
@@ -22,7 +22,7 @@ export class PercentFormat extends NumeralFormat {
allowsNumericalAggregations = true;
getParamDefaults = () => ({
- pattern: this.getConfig!(UI_SETTINGS.FORMAT_PERCENT_DEFAULT_PATTERN),
+ pattern: this.getConfig!(FORMATS_UI_SETTINGS.FORMAT_PERCENT_DEFAULT_PATTERN),
fractional: true,
});
diff --git a/src/plugins/data/common/field_formats/converters/relative_date.test.ts b/src/plugins/field_formats/common/converters/relative_date.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/relative_date.test.ts
rename to src/plugins/field_formats/common/converters/relative_date.test.ts
diff --git a/src/plugins/data/common/field_formats/converters/relative_date.ts b/src/plugins/field_formats/common/converters/relative_date.ts
similarity index 93%
rename from src/plugins/data/common/field_formats/converters/relative_date.ts
rename to src/plugins/field_formats/common/converters/relative_date.ts
index c54e32452f267..6111cbf838b79 100644
--- a/src/plugins/data/common/field_formats/converters/relative_date.ts
+++ b/src/plugins/field_formats/common/converters/relative_date.ts
@@ -14,7 +14,7 @@ import { TextContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
export class RelativeDateFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.RELATIVE_DATE;
- static title = i18n.translate('data.fieldFormats.relative_date.title', {
+ static title = i18n.translate('fieldFormats.relative_date.title', {
defaultMessage: 'Relative date',
});
static fieldType = KBN_FIELD_TYPES.DATE;
diff --git a/src/plugins/data/common/field_formats/converters/source.test.ts b/src/plugins/field_formats/common/converters/source.test.ts
similarity index 87%
rename from src/plugins/data/common/field_formats/converters/source.test.ts
rename to src/plugins/field_formats/common/converters/source.test.ts
index 655cf315a05a4..726f2c31e7825 100644
--- a/src/plugins/data/common/field_formats/converters/source.test.ts
+++ b/src/plugins/field_formats/common/converters/source.test.ts
@@ -9,7 +9,21 @@
import { SourceFormat } from './source';
import { HtmlContextTypeConvert } from '../types';
import { HTML_CONTEXT_TYPE } from '../content_types';
-import { stubIndexPatternWithFields } from '../../index_patterns/index_pattern.stub';
+
+export const stubIndexPatternWithFields = {
+ id: '1234',
+ title: 'logstash-*',
+ fields: [
+ {
+ name: 'response',
+ type: 'number',
+ esTypes: ['integer'],
+ aggregatable: true,
+ filterable: true,
+ searchable: true,
+ },
+ ],
+};
describe('Source Format', () => {
let convertHtml: Function;
diff --git a/src/plugins/data/common/field_formats/converters/source.tsx b/src/plugins/field_formats/common/converters/source.tsx
similarity index 92%
rename from src/plugins/data/common/field_formats/converters/source.tsx
rename to src/plugins/field_formats/common/converters/source.tsx
index de77736503f86..b3ed90329d6d4 100644
--- a/src/plugins/data/common/field_formats/converters/source.tsx
+++ b/src/plugins/field_formats/common/converters/source.tsx
@@ -6,14 +6,14 @@
* Side Public License, v 1.
*/
+import { KBN_FIELD_TYPES } from '@kbn/field-types';
import React, { Fragment } from 'react';
import ReactDOM from 'react-dom/server';
import { escape, keys } from 'lodash';
-import { KBN_FIELD_TYPES } from '@kbn/field-types';
-import { shortenDottedString } from '../../utils';
+import { shortenDottedString } from '../utils';
import { FieldFormat } from '../field_format';
import { TextContextTypeConvert, HtmlContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
-import { UI_SETTINGS } from '../../constants';
+import { FORMATS_UI_SETTINGS } from '../constants/ui_settings';
interface Props {
defPairs: Array<[string, string]>;
@@ -55,7 +55,7 @@ export class SourceFormat extends FieldFormat {
const formatted = indexPattern.formatHit(hit);
const highlightPairs: any[] = [];
const sourcePairs: any[] = [];
- const isShortDots = this.getConfig!(UI_SETTINGS.SHORT_DOTS_ENABLE);
+ const isShortDots = this.getConfig!(FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE);
keys(formatted).forEach((key) => {
const pairs = highlights[key] ? highlightPairs : sourcePairs;
diff --git a/src/plugins/data/common/field_formats/converters/static_lookup.ts b/src/plugins/field_formats/common/converters/static_lookup.ts
similarity index 95%
rename from src/plugins/data/common/field_formats/converters/static_lookup.ts
rename to src/plugins/field_formats/common/converters/static_lookup.ts
index 63d3506dda0bb..ba5b38ba8b24f 100644
--- a/src/plugins/data/common/field_formats/converters/static_lookup.ts
+++ b/src/plugins/field_formats/common/converters/static_lookup.ts
@@ -23,7 +23,7 @@ function convertLookupEntriesToMap(lookupEntries: any[]) {
export class StaticLookupFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.STATIC_LOOKUP;
- static title = i18n.translate('data.fieldFormats.static_lookup.title', {
+ static title = i18n.translate('fieldFormats.static_lookup.title', {
defaultMessage: 'Static lookup',
});
static fieldType = [
diff --git a/src/plugins/data/common/field_formats/converters/string.test.ts b/src/plugins/field_formats/common/converters/string.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/string.test.ts
rename to src/plugins/field_formats/common/converters/string.test.ts
diff --git a/src/plugins/data/common/field_formats/converters/string.ts b/src/plugins/field_formats/common/converters/string.ts
similarity index 80%
rename from src/plugins/data/common/field_formats/converters/string.ts
rename to src/plugins/field_formats/common/converters/string.ts
index c6aba38cf376d..149da871761e2 100644
--- a/src/plugins/data/common/field_formats/converters/string.ts
+++ b/src/plugins/field_formats/common/converters/string.ts
@@ -9,55 +9,54 @@
import { escape } from 'lodash';
import { i18n } from '@kbn/i18n';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
-import { asPrettyString, getHighlightHtml } from '../utils';
+import { asPrettyString, getHighlightHtml, shortenDottedString } from '../utils';
import { FieldFormat } from '../field_format';
import { TextContextTypeConvert, FIELD_FORMAT_IDS, HtmlContextTypeConvert } from '../types';
-import { shortenDottedString } from '../../utils';
-const emptyLabel = i18n.translate('data.fieldFormats.string.emptyLabel', {
+const emptyLabel = i18n.translate('fieldFormats.string.emptyLabel', {
defaultMessage: '(empty)',
});
const TRANSFORM_OPTIONS = [
{
kind: false,
- text: i18n.translate('data.fieldFormats.string.transformOptions.none', {
+ text: i18n.translate('fieldFormats.string.transformOptions.none', {
defaultMessage: '- None -',
}),
},
{
kind: 'lower',
- text: i18n.translate('data.fieldFormats.string.transformOptions.lower', {
+ text: i18n.translate('fieldFormats.string.transformOptions.lower', {
defaultMessage: 'Lower Case',
}),
},
{
kind: 'upper',
- text: i18n.translate('data.fieldFormats.string.transformOptions.upper', {
+ text: i18n.translate('fieldFormats.string.transformOptions.upper', {
defaultMessage: 'Upper Case',
}),
},
{
kind: 'title',
- text: i18n.translate('data.fieldFormats.string.transformOptions.title', {
+ text: i18n.translate('fieldFormats.string.transformOptions.title', {
defaultMessage: 'Title Case',
}),
},
{
kind: 'short',
- text: i18n.translate('data.fieldFormats.string.transformOptions.short', {
+ text: i18n.translate('fieldFormats.string.transformOptions.short', {
defaultMessage: 'Short Dots',
}),
},
{
kind: 'base64',
- text: i18n.translate('data.fieldFormats.string.transformOptions.base64', {
+ text: i18n.translate('fieldFormats.string.transformOptions.base64', {
defaultMessage: 'Base64 Decode',
}),
},
{
kind: 'urlparam',
- text: i18n.translate('data.fieldFormats.string.transformOptions.url', {
+ text: i18n.translate('fieldFormats.string.transformOptions.url', {
defaultMessage: 'URL Param Decode',
}),
},
@@ -66,7 +65,7 @@ const DEFAULT_TRANSFORM_OPTION = false;
export class StringFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.STRING;
- static title = i18n.translate('data.fieldFormats.string.title', {
+ static title = i18n.translate('fieldFormats.string.title', {
defaultMessage: 'String',
});
static fieldType = [
diff --git a/src/plugins/data/common/field_formats/converters/truncate.test.ts b/src/plugins/field_formats/common/converters/truncate.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/truncate.test.ts
rename to src/plugins/field_formats/common/converters/truncate.test.ts
diff --git a/src/plugins/data/common/field_formats/converters/truncate.ts b/src/plugins/field_formats/common/converters/truncate.ts
similarity index 93%
rename from src/plugins/data/common/field_formats/converters/truncate.ts
rename to src/plugins/field_formats/common/converters/truncate.ts
index 4c68a4c056b82..fd8bbcbc46541 100644
--- a/src/plugins/data/common/field_formats/converters/truncate.ts
+++ b/src/plugins/field_formats/common/converters/truncate.ts
@@ -16,7 +16,7 @@ const omission = '...';
export class TruncateFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.TRUNCATE;
- static title = i18n.translate('data.fieldFormats.truncated_string.title', {
+ static title = i18n.translate('fieldFormats.truncated_string.title', {
defaultMessage: 'Truncated string',
});
static fieldType = KBN_FIELD_TYPES.STRING;
diff --git a/src/plugins/data/common/field_formats/converters/url.test.ts b/src/plugins/field_formats/common/converters/url.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/converters/url.test.ts
rename to src/plugins/field_formats/common/converters/url.test.ts
diff --git a/src/plugins/data/common/field_formats/converters/url.ts b/src/plugins/field_formats/common/converters/url.ts
similarity index 95%
rename from src/plugins/data/common/field_formats/converters/url.ts
rename to src/plugins/field_formats/common/converters/url.ts
index 3e808d90f0409..07d9ed4cd535e 100644
--- a/src/plugins/data/common/field_formats/converters/url.ts
+++ b/src/plugins/field_formats/common/converters/url.ts
@@ -24,19 +24,19 @@ const allowedUrlSchemes = ['http://', 'https://'];
const URL_TYPES = [
{
kind: 'a',
- text: i18n.translate('data.fieldFormats.url.types.link', {
+ text: i18n.translate('fieldFormats.url.types.link', {
defaultMessage: 'Link',
}),
},
{
kind: 'img',
- text: i18n.translate('data.fieldFormats.url.types.img', {
+ text: i18n.translate('fieldFormats.url.types.img', {
defaultMessage: 'Image',
}),
},
{
kind: 'audio',
- text: i18n.translate('data.fieldFormats.url.types.audio', {
+ text: i18n.translate('fieldFormats.url.types.audio', {
defaultMessage: 'Audio',
}),
},
@@ -45,7 +45,7 @@ const DEFAULT_URL_TYPE = 'a';
export class UrlFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.URL;
- static title = i18n.translate('data.fieldFormats.url.title', {
+ static title = i18n.translate('fieldFormats.url.title', {
defaultMessage: 'Url',
});
static fieldType = [
diff --git a/src/plugins/data/common/field_formats/errors.ts b/src/plugins/field_formats/common/errors.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/errors.ts
rename to src/plugins/field_formats/common/errors.ts
diff --git a/src/plugins/data/common/field_formats/field_format.test.ts b/src/plugins/field_formats/common/field_format.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/field_format.test.ts
rename to src/plugins/field_formats/common/field_format.test.ts
diff --git a/src/plugins/data/common/field_formats/field_format.ts b/src/plugins/field_formats/common/field_format.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/field_format.ts
rename to src/plugins/field_formats/common/field_format.ts
diff --git a/src/plugins/data/common/field_formats/field_formats_registry.test.ts b/src/plugins/field_formats/common/field_formats_registry.test.ts
similarity index 99%
rename from src/plugins/data/common/field_formats/field_formats_registry.test.ts
rename to src/plugins/field_formats/common/field_formats_registry.test.ts
index 86e44b69c05bf..e94efc88be20f 100644
--- a/src/plugins/data/common/field_formats/field_formats_registry.test.ts
+++ b/src/plugins/field_formats/common/field_formats_registry.test.ts
@@ -9,7 +9,7 @@
import { FieldFormatsRegistry } from './field_formats_registry';
import { BoolFormat, PercentFormat, StringFormat } from './converters';
import { FieldFormatsGetConfigFn, FieldFormatInstanceType } from './types';
-import { KBN_FIELD_TYPES } from '../../common';
+import { KBN_FIELD_TYPES } from '@kbn/field-types';
const getValueOfPrivateField = (instance: any, field: string) => instance[field];
diff --git a/src/plugins/data/common/field_formats/field_formats_registry.ts b/src/plugins/field_formats/common/field_formats_registry.ts
similarity index 96%
rename from src/plugins/data/common/field_formats/field_formats_registry.ts
rename to src/plugins/field_formats/common/field_formats_registry.ts
index 9e96f5cc1a6bd..675ec897c2b70 100644
--- a/src/plugins/data/common/field_formats/field_formats_registry.ts
+++ b/src/plugins/field_formats/common/field_formats_registry.ts
@@ -17,13 +17,13 @@ import {
FieldFormatInstanceType,
FieldFormatId,
IFieldFormatMetaParams,
+ SerializedFieldFormat,
+ FormatFactory,
} from './types';
import { baseFormatters } from './constants/base_formatters';
import { FieldFormat } from './field_format';
-import { FormatFactory } from './utils';
-import { UI_SETTINGS } from '../constants';
-import { FieldFormatNotFoundError } from '../field_formats';
-import { SerializedFieldFormat } from '../../../expressions/common/types';
+import { FORMATS_UI_SETTINGS } from '../common/constants/ui_settings';
+import { FieldFormatNotFoundError } from './errors';
export class FieldFormatsRegistry {
protected fieldFormats: Map = new Map();
@@ -53,7 +53,7 @@ export class FieldFormatsRegistry {
metaParamsOptions: Record = {},
defaultFieldConverters: FieldFormatInstanceType[] = baseFormatters
) {
- const defaultTypeMap = getConfig(UI_SETTINGS.FORMAT_DEFAULT_TYPE_MAP);
+ const defaultTypeMap = getConfig(FORMATS_UI_SETTINGS.FORMAT_DEFAULT_TYPE_MAP);
this.register(defaultFieldConverters);
this.parseDefaultTypeMap(defaultTypeMap);
this.getConfig = getConfig;
diff --git a/src/plugins/data/common/field_formats/index.ts b/src/plugins/field_formats/common/index.ts
similarity index 90%
rename from src/plugins/data/common/field_formats/index.ts
rename to src/plugins/field_formats/common/index.ts
index a3d763196e11f..f2395eef29c54 100644
--- a/src/plugins/data/common/field_formats/index.ts
+++ b/src/plugins/field_formats/common/index.ts
@@ -33,6 +33,7 @@ export {
export { getHighlightRequest } from './utils';
export { DEFAULT_CONVERTER_COLOR } from './constants/color_default';
+export { FORMATS_UI_SETTINGS } from './constants/ui_settings';
export { FIELD_FORMAT_IDS } from './types';
export { HTML_CONTEXT_TYPE, TEXT_CONTEXT_TYPE } from './content_types';
@@ -41,7 +42,9 @@ export {
FieldFormatsContentType,
FieldFormatConfig,
FieldFormatId,
- // Used in data plugin only
+ SerializedFieldFormat,
+ FormatFactory,
+ // Used in field format plugin only
FieldFormatInstanceType,
IFieldFormat,
FieldFormatsStartCommon,
diff --git a/src/plugins/data/common/field_formats/mocks.ts b/src/plugins/field_formats/common/mocks.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/mocks.ts
rename to src/plugins/field_formats/common/mocks.ts
diff --git a/src/plugins/data/common/field_formats/types.ts b/src/plugins/field_formats/common/types.ts
similarity index 73%
rename from src/plugins/data/common/field_formats/types.ts
rename to src/plugins/field_formats/common/types.ts
index c09106751815f..9c9112f45373b 100644
--- a/src/plugins/data/common/field_formats/types.ts
+++ b/src/plugins/field_formats/common/types.ts
@@ -6,7 +6,6 @@
* Side Public License, v 1.
*/
-import { GetConfigFn } from '../types';
import { FieldFormat } from './field_format';
import { FieldFormatsRegistry } from './field_formats_registry';
@@ -65,7 +64,17 @@ export interface FieldFormatConfig {
es?: boolean;
}
-export type FieldFormatsGetConfigFn = GetConfigFn;
+/**
+ * If a service is being shared on both the client and the server, and
+ * the client code requires synchronous access to uiSettings, both client
+ * and server should wrap the core uiSettings services in a function
+ * matching this signature.
+ *
+ * This matches the signature of the public `core.uiSettings.get`, and
+ * should only be used in scenarios where async access to uiSettings is
+ * not possible.
+ */
+export type FieldFormatsGetConfigFn = (key: string, defaultOverride?: T) => T;
export type IFieldFormat = FieldFormat;
@@ -96,3 +105,17 @@ export interface IFieldFormatMetaParams {
}
export type FieldFormatsStartCommon = Omit;
+
+/**
+ * JSON representation of a field formatter configuration.
+ * Is used to carry information about how to format data in
+ * a data table as part of the column definition.
+ *
+ * @public
+ */
+export interface SerializedFieldFormat> {
+ id?: string;
+ params?: TParams;
+}
+
+export type FormatFactory = (mapping?: SerializedFieldFormat) => IFieldFormat;
diff --git a/src/plugins/data/common/field_formats/utils/as_pretty_string.test.ts b/src/plugins/field_formats/common/utils/as_pretty_string.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/as_pretty_string.test.ts
rename to src/plugins/field_formats/common/utils/as_pretty_string.test.ts
diff --git a/src/plugins/data/common/field_formats/utils/as_pretty_string.ts b/src/plugins/field_formats/common/utils/as_pretty_string.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/as_pretty_string.ts
rename to src/plugins/field_formats/common/utils/as_pretty_string.ts
diff --git a/src/plugins/data/common/field_formats/utils/highlight/highlight_html.test.ts b/src/plugins/field_formats/common/utils/highlight/highlight_html.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/highlight/highlight_html.test.ts
rename to src/plugins/field_formats/common/utils/highlight/highlight_html.test.ts
diff --git a/src/plugins/data/common/field_formats/utils/highlight/highlight_html.ts b/src/plugins/field_formats/common/utils/highlight/highlight_html.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/highlight/highlight_html.ts
rename to src/plugins/field_formats/common/utils/highlight/highlight_html.ts
diff --git a/src/plugins/data/common/field_formats/utils/highlight/highlight_request.test.ts b/src/plugins/field_formats/common/utils/highlight/highlight_request.test.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/highlight/highlight_request.test.ts
rename to src/plugins/field_formats/common/utils/highlight/highlight_request.test.ts
diff --git a/src/plugins/data/common/field_formats/utils/highlight/highlight_request.ts b/src/plugins/field_formats/common/utils/highlight/highlight_request.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/highlight/highlight_request.ts
rename to src/plugins/field_formats/common/utils/highlight/highlight_request.ts
diff --git a/src/plugins/data/common/field_formats/utils/highlight/highlight_tags.ts b/src/plugins/field_formats/common/utils/highlight/highlight_tags.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/highlight/highlight_tags.ts
rename to src/plugins/field_formats/common/utils/highlight/highlight_tags.ts
diff --git a/src/plugins/data/common/field_formats/utils/highlight/html_tags.ts b/src/plugins/field_formats/common/utils/highlight/html_tags.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/highlight/html_tags.ts
rename to src/plugins/field_formats/common/utils/highlight/html_tags.ts
diff --git a/src/plugins/data/common/field_formats/utils/highlight/index.ts b/src/plugins/field_formats/common/utils/highlight/index.ts
similarity index 100%
rename from src/plugins/data/common/field_formats/utils/highlight/index.ts
rename to src/plugins/field_formats/common/utils/highlight/index.ts
diff --git a/src/plugins/data/common/field_formats/utils/index.ts b/src/plugins/field_formats/common/utils/index.ts
similarity index 70%
rename from src/plugins/data/common/field_formats/utils/index.ts
rename to src/plugins/field_formats/common/utils/index.ts
index 5771c0166075d..3cfa0241c6f41 100644
--- a/src/plugins/data/common/field_formats/utils/index.ts
+++ b/src/plugins/field_formats/common/utils/index.ts
@@ -6,10 +6,6 @@
* Side Public License, v 1.
*/
-import { SerializedFieldFormat } from '../../../../expressions/common/types';
-import { IFieldFormat } from '../index';
-
export { asPrettyString } from './as_pretty_string';
export { getHighlightHtml, getHighlightRequest } from './highlight';
-
-export type FormatFactory = (mapping?: SerializedFieldFormat) => IFieldFormat;
+export { shortenDottedString } from './shorten_dotted_string';
diff --git a/src/plugins/field_formats/common/utils/shorten_dotted_string.test.ts b/src/plugins/field_formats/common/utils/shorten_dotted_string.test.ts
new file mode 100644
index 0000000000000..33a44925982ec
--- /dev/null
+++ b/src/plugins/field_formats/common/utils/shorten_dotted_string.test.ts
@@ -0,0 +1,23 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { shortenDottedString } from './shorten_dotted_string';
+
+describe('shortenDottedString', () => {
+ test('should convert a dot.notated.string into a short string', () => {
+ expect(shortenDottedString('dot.notated.string')).toBe('d.n.string');
+ });
+
+ test('should ignore non-string values', () => {
+ const obj = { key: 'val' };
+
+ expect(shortenDottedString(true)).toBe(true);
+ expect(shortenDottedString(123)).toBe(123);
+ expect(shortenDottedString(obj)).toBe(obj);
+ });
+});
diff --git a/src/plugins/field_formats/common/utils/shorten_dotted_string.ts b/src/plugins/field_formats/common/utils/shorten_dotted_string.ts
new file mode 100644
index 0000000000000..53f7471913dc3
--- /dev/null
+++ b/src/plugins/field_formats/common/utils/shorten_dotted_string.ts
@@ -0,0 +1,19 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+const DOT_PREFIX_RE = /(.).+?\./g;
+
+/**
+ * Convert a dot.notated.string into a short
+ * version (d.n.string)
+ *
+ * @return {any}
+ */
+export function shortenDottedString(input: any) {
+ return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.');
+}
diff --git a/src/plugins/field_formats/jest.config.js b/src/plugins/field_formats/jest.config.js
new file mode 100644
index 0000000000000..ea20fcfec6d09
--- /dev/null
+++ b/src/plugins/field_formats/jest.config.js
@@ -0,0 +1,13 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+module.exports = {
+ preset: '@kbn/test',
+ rootDir: '../../..',
+ roots: ['/src/plugins/field_formats'],
+};
diff --git a/src/plugins/field_formats/kibana.json b/src/plugins/field_formats/kibana.json
new file mode 100755
index 0000000000000..ee5529697851d
--- /dev/null
+++ b/src/plugins/field_formats/kibana.json
@@ -0,0 +1,15 @@
+{
+ "id": "fieldFormats",
+ "version": "1.0.0",
+ "kibanaVersion": "kibana",
+ "server": true,
+ "ui": true,
+ "extraPublicDirs": ["common"],
+ "requiredPlugins": [],
+ "optionalPlugins": [],
+ "owner": {
+ "name": "App Services",
+ "githubTeam": "kibana-app-services"
+ },
+ "description": "Index pattern fields and ambiguous values formatters"
+}
diff --git a/src/plugins/field_formats/public/index.scss b/src/plugins/field_formats/public/index.scss
new file mode 100644
index 0000000000000..7928d81b1f565
--- /dev/null
+++ b/src/plugins/field_formats/public/index.scss
@@ -0,0 +1 @@
+@import './lib/converters/index';
diff --git a/src/plugins/field_formats/public/index.ts b/src/plugins/field_formats/public/index.ts
new file mode 100755
index 0000000000000..f765513fb4c4c
--- /dev/null
+++ b/src/plugins/field_formats/public/index.ts
@@ -0,0 +1,15 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { FieldFormatsPlugin } from './plugin';
+export { DateFormat, DateNanosFormat } from './lib/converters';
+
+export function plugin() {
+ return new FieldFormatsPlugin();
+}
+export { FieldFormatsSetup, FieldFormatsStart } from './plugin';
diff --git a/src/plugins/data/public/field_formats/constants.ts b/src/plugins/field_formats/public/lib/constants.ts
similarity index 100%
rename from src/plugins/data/public/field_formats/constants.ts
rename to src/plugins/field_formats/public/lib/constants.ts
diff --git a/src/plugins/data/public/field_formats/converters/_index.scss b/src/plugins/field_formats/public/lib/converters/_index.scss
similarity index 100%
rename from src/plugins/data/public/field_formats/converters/_index.scss
rename to src/plugins/field_formats/public/lib/converters/_index.scss
diff --git a/src/plugins/data/public/field_formats/converters/_string.scss b/src/plugins/field_formats/public/lib/converters/_string.scss
similarity index 100%
rename from src/plugins/data/public/field_formats/converters/_string.scss
rename to src/plugins/field_formats/public/lib/converters/_string.scss
diff --git a/src/plugins/data/public/field_formats/converters/date.test.ts b/src/plugins/field_formats/public/lib/converters/date.test.ts
similarity index 100%
rename from src/plugins/data/public/field_formats/converters/date.test.ts
rename to src/plugins/field_formats/public/lib/converters/date.test.ts
diff --git a/src/plugins/data/public/field_formats/converters/date.ts b/src/plugins/field_formats/public/lib/converters/date.ts
similarity index 87%
rename from src/plugins/data/public/field_formats/converters/date.ts
rename to src/plugins/field_formats/public/lib/converters/date.ts
index 1d74e6095427d..acc051afd6b1d 100644
--- a/src/plugins/data/public/field_formats/converters/date.ts
+++ b/src/plugins/field_formats/public/lib/converters/date.ts
@@ -9,12 +9,13 @@
import { i18n } from '@kbn/i18n';
import { memoize, noop } from 'lodash';
import moment from 'moment';
-import { FieldFormat, KBN_FIELD_TYPES, FIELD_FORMAT_IDS } from '../../../common';
-import { TextContextTypeConvert } from '../../../common/field_formats/types';
+import { KBN_FIELD_TYPES } from '@kbn/field-types';
+import { FieldFormat, FIELD_FORMAT_IDS } from '../../../common';
+import { TextContextTypeConvert } from '../../../common/types';
export class DateFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.DATE;
- static title = i18n.translate('data.fieldFormats.date.title', {
+ static title = i18n.translate('fieldFormats.date.title', {
defaultMessage: 'Date',
});
static fieldType = KBN_FIELD_TYPES.DATE;
diff --git a/src/plugins/data/public/field_formats/converters/date_nanos.ts b/src/plugins/field_formats/public/lib/converters/date_nanos.ts
similarity index 79%
rename from src/plugins/data/public/field_formats/converters/date_nanos.ts
rename to src/plugins/field_formats/public/lib/converters/date_nanos.ts
index f94d0e47a8ed4..c2e0b3f929067 100644
--- a/src/plugins/data/public/field_formats/converters/date_nanos.ts
+++ b/src/plugins/field_formats/public/lib/converters/date_nanos.ts
@@ -6,4 +6,4 @@
* Side Public License, v 1.
*/
-export { DateNanosFormat } from '../../../common/field_formats/converters/date_nanos_shared';
+export { DateNanosFormat } from '../../../common/converters/date_nanos_shared';
diff --git a/src/plugins/data/public/field_formats/converters/index.ts b/src/plugins/field_formats/public/lib/converters/index.ts
similarity index 100%
rename from src/plugins/data/public/field_formats/converters/index.ts
rename to src/plugins/field_formats/public/lib/converters/index.ts
diff --git a/src/plugins/data/public/field_formats/index.ts b/src/plugins/field_formats/public/lib/index.ts
similarity index 82%
rename from src/plugins/data/public/field_formats/index.ts
rename to src/plugins/field_formats/public/lib/index.ts
index 8b8b00b2b8746..83a2dc60d8d95 100644
--- a/src/plugins/data/public/field_formats/index.ts
+++ b/src/plugins/field_formats/public/lib/index.ts
@@ -6,6 +6,5 @@
* Side Public License, v 1.
*/
-export { FieldFormatsService, FieldFormatsSetup, FieldFormatsStart } from './field_formats_service';
export { DateFormat, DateNanosFormat } from './converters';
export { baseFormattersPublic } from './constants';
diff --git a/src/plugins/data/public/field_formats/mocks.ts b/src/plugins/field_formats/public/mocks.ts
similarity index 56%
rename from src/plugins/data/public/field_formats/mocks.ts
rename to src/plugins/field_formats/public/mocks.ts
index 883af75939220..53f8cf3a17494 100644
--- a/src/plugins/data/public/field_formats/mocks.ts
+++ b/src/plugins/field_formats/public/mocks.ts
@@ -6,17 +6,26 @@
* Side Public License, v 1.
*/
-import type { PublicMethodsOf } from '@kbn/utility-types';
-import { FieldFormatsStart, FieldFormatsSetup, FieldFormatsService } from '.';
-import { fieldFormatsMock } from '../../common/field_formats/mocks';
+import { CoreSetup } from 'src/core/public';
+import { baseFormattersPublic } from './lib/constants';
+import { FieldFormatsRegistry } from '../common';
+import type { FieldFormatsStart, FieldFormatsSetup } from '.';
+import { fieldFormatsMock } from '../common/mocks';
-type FieldFormatsServiceClientContract = PublicMethodsOf;
+export const getFieldFormatsRegistry = (core: CoreSetup) => {
+ const fieldFormatsRegistry = new FieldFormatsRegistry();
+ const getConfig = core.uiSettings.get.bind(core.uiSettings);
+
+ fieldFormatsRegistry.init(getConfig, {}, baseFormattersPublic);
+
+ return fieldFormatsRegistry;
+};
const createSetupContractMock = () => fieldFormatsMock as FieldFormatsSetup;
const createStartContractMock = () => fieldFormatsMock as FieldFormatsStart;
const createMock = () => {
- const mocked: jest.Mocked = {
+ const mocked: jest.Mocked<{ start: () => FieldFormatsStart; setup: () => FieldFormatsSetup }> = {
setup: jest.fn().mockReturnValue(createSetupContractMock()),
start: jest.fn().mockReturnValue(createStartContractMock()),
};
diff --git a/src/plugins/data/public/field_formats/field_formats_service.test.ts b/src/plugins/field_formats/public/plugin.test.ts
similarity index 51%
rename from src/plugins/data/public/field_formats/field_formats_service.test.ts
rename to src/plugins/field_formats/public/plugin.test.ts
index 06d007b2aff00..808413667918d 100644
--- a/src/plugins/data/public/field_formats/field_formats_service.test.ts
+++ b/src/plugins/field_formats/public/plugin.test.ts
@@ -6,18 +6,18 @@
* Side Public License, v 1.
*/
-import { FieldFormatsService } from './field_formats_service';
-import { coreMock } from '../../../../../src/core/public/mocks';
-import { DateFormat } from './converters/date';
+import { coreMock } from '../../../../src/core/public/mocks';
+import { DateFormat } from './lib/converters/date';
+import { FieldFormatsPlugin } from './plugin';
-describe('FieldFormatService', () => {
+describe('FieldFormatsPublic', () => {
test('DateFormat is public version', () => {
const mockCore = coreMock.createSetup();
- const service = new FieldFormatsService();
- service.setup(mockCore);
- const fieldFormatsRegistry = service.start();
- const DateFormatFromRegsitry = fieldFormatsRegistry.getTypeWithoutMetaParams('date');
+ const plugin = new FieldFormatsPlugin();
+ plugin.setup(mockCore);
+ const fieldFormatsRegistry = plugin.start();
+ const DateFormatFromRegistry = fieldFormatsRegistry.getTypeWithoutMetaParams('date');
- expect(DateFormatFromRegsitry).toEqual(DateFormat);
+ expect(DateFormatFromRegistry).toEqual(DateFormat);
});
});
diff --git a/src/plugins/data/public/field_formats/field_formats_service.ts b/src/plugins/field_formats/public/plugin.ts
old mode 100644
new mode 100755
similarity index 73%
rename from src/plugins/data/public/field_formats/field_formats_service.ts
rename to src/plugins/field_formats/public/plugin.ts
index 041d0d7dd0e1c..0e90aa9b48c8e
--- a/src/plugins/data/public/field_formats/field_formats_service.ts
+++ b/src/plugins/field_formats/public/plugin.ts
@@ -6,17 +6,18 @@
* Side Public License, v 1.
*/
-import { CoreSetup } from 'src/core/public';
-import { FieldFormatsRegistry, UI_SETTINGS } from '../../common';
-import { FormatFactory } from '../../common/field_formats/utils';
-import { baseFormattersPublic } from './constants';
+import { CoreSetup, Plugin } from '../../../core/public';
+import { FieldFormatsRegistry, FORMATS_UI_SETTINGS } from '../common';
+import { baseFormattersPublic } from './lib';
+import { FormatFactory } from '../common/types';
+import './index.scss';
-export class FieldFormatsService {
+export class FieldFormatsPlugin implements Plugin {
private readonly fieldFormatsRegistry: FieldFormatsRegistry = new FieldFormatsRegistry();
- public setup(core: CoreSetup) {
+ public setup(core: CoreSetup): FieldFormatsSetup {
core.uiSettings.getUpdate$().subscribe(({ key, newValue }) => {
- if (key === UI_SETTINGS.FORMAT_DEFAULT_TYPE_MAP) {
+ if (key === FORMATS_UI_SETTINGS.FORMAT_DEFAULT_TYPE_MAP) {
this.fieldFormatsRegistry.parseDefaultTypeMap(newValue);
}
});
@@ -41,6 +42,8 @@ export class FieldFormatsService {
public start() {
return this.fieldFormatsRegistry as FieldFormatsStart;
}
+
+ public stop() {}
}
/** @public */
diff --git a/src/plugins/field_formats/server/index.ts b/src/plugins/field_formats/server/index.ts
new file mode 100755
index 0000000000000..44de8fde558ec
--- /dev/null
+++ b/src/plugins/field_formats/server/index.ts
@@ -0,0 +1,17 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { PluginInitializerContext } from '../../../core/server';
+import { FieldFormatsPlugin } from './plugin';
+export { DateFormat, DateNanosFormat } from './lib/converters';
+
+export function plugin(initializerContext: PluginInitializerContext) {
+ return new FieldFormatsPlugin(initializerContext);
+}
+
+export { FieldFormatsSetup, FieldFormatsStart } from './types';
diff --git a/src/plugins/data/server/field_formats/converters/date_nanos_server.test.ts b/src/plugins/field_formats/server/lib/converters/date_nanos_server.test.ts
similarity index 97%
rename from src/plugins/data/server/field_formats/converters/date_nanos_server.test.ts
rename to src/plugins/field_formats/server/lib/converters/date_nanos_server.test.ts
index 3353f4a959b7e..86f0b2a7dc875 100644
--- a/src/plugins/data/server/field_formats/converters/date_nanos_server.test.ts
+++ b/src/plugins/field_formats/server/lib/converters/date_nanos_server.test.ts
@@ -7,7 +7,7 @@
*/
import { DateNanosFormat } from './date_nanos_server';
-import { FieldFormatsGetConfigFn } from 'src/plugins/data/common';
+import { FieldFormatsGetConfigFn } from '../../../common';
describe('Date Nanos Format: Server side edition', () => {
let convert: Function;
diff --git a/src/plugins/data/server/field_formats/converters/date_nanos_server.ts b/src/plugins/field_formats/server/lib/converters/date_nanos_server.ts
similarity index 94%
rename from src/plugins/data/server/field_formats/converters/date_nanos_server.ts
rename to src/plugins/field_formats/server/lib/converters/date_nanos_server.ts
index 655c76d328f47..d47475f6274fa 100644
--- a/src/plugins/data/server/field_formats/converters/date_nanos_server.ts
+++ b/src/plugins/field_formats/server/lib/converters/date_nanos_server.ts
@@ -12,8 +12,8 @@ import {
analysePatternForFract,
DateNanosFormat,
formatWithNanos,
-} from '../../../common/field_formats/converters/date_nanos_shared';
-import { TextContextTypeConvert } from '../../../common/field_formats/types';
+} from '../../../common/converters/date_nanos_shared';
+import { TextContextTypeConvert } from '../../../common/types';
class DateNanosFormatServer extends DateNanosFormat {
textConvert: TextContextTypeConvert = (val) => {
diff --git a/src/plugins/data/server/field_formats/converters/date_server.ts b/src/plugins/field_formats/server/lib/converters/date_server.ts
similarity index 90%
rename from src/plugins/data/server/field_formats/converters/date_server.ts
rename to src/plugins/field_formats/server/lib/converters/date_server.ts
index a86f3c894c543..bf2151db0072c 100644
--- a/src/plugins/data/server/field_formats/converters/date_server.ts
+++ b/src/plugins/field_formats/server/lib/converters/date_server.ts
@@ -9,20 +9,13 @@
import { i18n } from '@kbn/i18n';
import { memoize, noop } from 'lodash';
import moment from 'moment-timezone';
-import {
- FieldFormat,
- KBN_FIELD_TYPES,
- FIELD_FORMAT_IDS,
- FieldFormatsGetConfigFn,
-} from '../../../common';
-import {
- IFieldFormatMetaParams,
- TextContextTypeConvert,
-} from '../../../common/field_formats/types';
+import { KBN_FIELD_TYPES } from '@kbn/field-types';
+import { FieldFormat, FIELD_FORMAT_IDS, FieldFormatsGetConfigFn } from '../../../common';
+import { IFieldFormatMetaParams, TextContextTypeConvert } from '../../../common/types';
export class DateFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.DATE;
- static title = i18n.translate('data.fieldFormats.date.title', {
+ static title = i18n.translate('fieldFormats.date.title', {
defaultMessage: 'Date',
});
static fieldType = KBN_FIELD_TYPES.DATE;
diff --git a/src/plugins/data/server/field_formats/converters/index.ts b/src/plugins/field_formats/server/lib/converters/index.ts
similarity index 100%
rename from src/plugins/data/server/field_formats/converters/index.ts
rename to src/plugins/field_formats/server/lib/converters/index.ts
diff --git a/src/plugins/data/server/field_formats/mocks.ts b/src/plugins/field_formats/server/mocks.ts
similarity index 100%
rename from src/plugins/data/server/field_formats/mocks.ts
rename to src/plugins/field_formats/server/mocks.ts
diff --git a/src/plugins/data/server/field_formats/field_formats_service.test.ts b/src/plugins/field_formats/server/plugin.test.ts
similarity index 58%
rename from src/plugins/data/server/field_formats/field_formats_service.test.ts
rename to src/plugins/field_formats/server/plugin.test.ts
index 0bfa9f89117e8..266d724ce5e22 100644
--- a/src/plugins/data/server/field_formats/field_formats_service.test.ts
+++ b/src/plugins/field_formats/server/plugin.test.ts
@@ -6,16 +6,16 @@
* Side Public License, v 1.
*/
-import { FieldFormatsService } from './field_formats_service';
-import { DateFormat } from './converters/date_server';
-import { coreMock } from '../../../../core/server/mocks';
+import { DateFormat } from './lib/converters/date_server';
+import { coreMock } from '../../../core/server/mocks';
+import { FieldFormatsPlugin } from './plugin';
-describe('FieldFormatService', () => {
+describe('FieldFormats registry server plugin', () => {
test('DateFormat is server version', async () => {
- const service = new FieldFormatsService();
- const fieldFormatsService = await service.start();
+ const plugin = new FieldFormatsPlugin(coreMock.createPluginInitializerContext());
+ const pluginStart = await plugin.start(coreMock.createStart());
const uiSettings = coreMock.createStart().uiSettings.asScopedToClient({} as any);
- const fieldFormatsRegistry = await fieldFormatsService.fieldFormatServiceFactory(uiSettings);
+ const fieldFormatsRegistry = await pluginStart.fieldFormatServiceFactory(uiSettings);
const DateFormatFromRegsitry = fieldFormatsRegistry.getTypeWithoutMetaParams('date');
expect(DateFormatFromRegsitry).toEqual(DateFormat);
diff --git a/src/plugins/data/server/field_formats/field_formats_service.ts b/src/plugins/field_formats/server/plugin.ts
old mode 100644
new mode 100755
similarity index 60%
rename from src/plugins/data/server/field_formats/field_formats_service.ts
rename to src/plugins/field_formats/server/plugin.ts
index fa94e5dcef9cf..e2c64807433a9
--- a/src/plugins/data/server/field_formats/field_formats_service.ts
+++ b/src/plugins/field_formats/server/plugin.ts
@@ -8,28 +8,36 @@
import { has } from 'lodash';
import {
- FieldFormatsRegistry,
- FieldFormatInstanceType,
- baseFormatters,
-} from '../../common/field_formats';
-import { IUiSettingsClient } from '../../../../core/server';
-import { DateFormat, DateNanosFormat } from './converters';
-
-export class FieldFormatsService {
- private readonly fieldFormatClasses: FieldFormatInstanceType[] = [
+ PluginInitializerContext,
+ CoreSetup,
+ CoreStart,
+ Plugin,
+ IUiSettingsClient,
+} from '../../../core/server';
+import { FieldFormatsStart, FieldFormatsSetup } from './types';
+import { DateFormat, DateNanosFormat } from './lib/converters';
+import { baseFormatters, FieldFormatInstanceType, FieldFormatsRegistry } from '../common';
+import { getUiSettings } from './ui_settings';
+
+export class FieldFormatsPlugin implements Plugin {
+ private readonly fieldFormats: FieldFormatInstanceType[] = [
DateFormat,
DateNanosFormat,
...baseFormatters,
];
- public setup() {
+ constructor(initializerContext: PluginInitializerContext) {}
+
+ public setup(core: CoreSetup) {
+ core.uiSettings.register(getUiSettings());
+
return {
register: (customFieldFormat: FieldFormatInstanceType) =>
- this.fieldFormatClasses.push(customFieldFormat),
+ this.fieldFormats.push(customFieldFormat),
};
}
- public start() {
+ public start(core: CoreStart) {
return {
fieldFormatServiceFactory: async (uiSettings: IUiSettingsClient) => {
const fieldFormatsRegistry = new FieldFormatsRegistry();
@@ -43,16 +51,12 @@ export class FieldFormatsService {
}
});
- fieldFormatsRegistry.init((key: string) => uiConfigs[key], {}, this.fieldFormatClasses);
+ fieldFormatsRegistry.init((key: string) => uiConfigs[key], {}, this.fieldFormats);
return fieldFormatsRegistry;
},
};
}
-}
-/** @public */
-export type FieldFormatsSetup = ReturnType;
-
-/** @public */
-export type FieldFormatsStart = ReturnType;
+ public stop() {}
+}
diff --git a/src/plugins/field_formats/server/types.ts b/src/plugins/field_formats/server/types.ts
new file mode 100755
index 0000000000000..eaf9c9ffdc390
--- /dev/null
+++ b/src/plugins/field_formats/server/types.ts
@@ -0,0 +1,26 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { FieldFormatInstanceType, FieldFormatsRegistry } from '../common';
+import { IUiSettingsClient } from '../../../core/server';
+
+export interface FieldFormatsSetup {
+ /**
+ * Register a server side field formatter
+ * @param fieldFormat {@link FieldFormatInstanceType}
+ */
+ register: (fieldFormat: FieldFormatInstanceType) => void;
+}
+
+export interface FieldFormatsStart {
+ /**
+ * Create a field format registry
+ * @param uiSettings - {@link IUiSettingsClient}
+ */
+ fieldFormatServiceFactory: (uiSettings: IUiSettingsClient) => Promise;
+}
diff --git a/src/plugins/field_formats/server/ui_settings.ts b/src/plugins/field_formats/server/ui_settings.ts
new file mode 100644
index 0000000000000..f24ddc60e1f97
--- /dev/null
+++ b/src/plugins/field_formats/server/ui_settings.ts
@@ -0,0 +1,226 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { i18n } from '@kbn/i18n';
+import { schema } from '@kbn/config-schema';
+import { UiSettingsParams } from 'kibana/server';
+// @ts-ignore untyped module
+import numeralLanguages from '@elastic/numeral/languages';
+import { FORMATS_UI_SETTINGS } from '../common';
+
+// We add the `en` key manually here, since that's not a real numeral locale, but the
+// default fallback in case the locale is not found.
+const numeralLanguageIds = [
+ 'en',
+ ...numeralLanguages.map((numeralLanguage: any) => {
+ return numeralLanguage.id;
+ }),
+];
+
+export function getUiSettings(): Record> {
+ return {
+ [FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE]: {
+ name: i18n.translate('fieldFormats.advancedSettings.shortenFieldsTitle', {
+ defaultMessage: 'Shorten fields',
+ }),
+ value: false,
+ description: i18n.translate('fieldFormats.advancedSettings.shortenFieldsText', {
+ defaultMessage: 'Shorten long fields, for example, instead of foo.bar.baz, show f.b.baz',
+ }),
+ schema: schema.boolean(),
+ },
+ [FORMATS_UI_SETTINGS.FORMAT_DEFAULT_TYPE_MAP]: {
+ name: i18n.translate('fieldFormats.advancedSettings.format.defaultTypeMapTitle', {
+ defaultMessage: 'Field type format name',
+ }),
+ value: `{
+ "ip": { "id": "ip", "params": {} },
+ "date": { "id": "date", "params": {} },
+ "date_nanos": { "id": "date_nanos", "params": {}, "es": true },
+ "number": { "id": "number", "params": {} },
+ "boolean": { "id": "boolean", "params": {} },
+ "histogram": { "id": "histogram", "params": {} },
+ "_source": { "id": "_source", "params": {} },
+ "_default_": { "id": "string", "params": {} }
+}`,
+ type: 'json',
+ description: i18n.translate('fieldFormats.advancedSettings.format.defaultTypeMapText', {
+ defaultMessage:
+ 'Map of the format name to use by default for each field type. ' +
+ '{defaultFormat} is used if the field type is not mentioned explicitly',
+ values: {
+ defaultFormat: '"_default_"',
+ },
+ }),
+ schema: schema.object({
+ ip: schema.object({
+ id: schema.string(),
+ params: schema.object({}),
+ }),
+ date: schema.object({
+ id: schema.string(),
+ params: schema.object({}),
+ }),
+ date_nanos: schema.object({
+ id: schema.string(),
+ params: schema.object({}),
+ es: schema.boolean(),
+ }),
+ number: schema.object({
+ id: schema.string(),
+ params: schema.object({}),
+ }),
+ boolean: schema.object({
+ id: schema.string(),
+ params: schema.object({}),
+ }),
+ histogram: schema.object({
+ id: schema.string(),
+ params: schema.object({}),
+ }),
+ _source: schema.object({
+ id: schema.string(),
+ params: schema.object({}),
+ }),
+ _default_: schema.object({
+ id: schema.string(),
+ params: schema.object({}),
+ }),
+ }),
+ },
+ [FORMATS_UI_SETTINGS.FORMAT_NUMBER_DEFAULT_PATTERN]: {
+ name: i18n.translate('fieldFormats.advancedSettings.format.numberFormatTitle', {
+ defaultMessage: 'Number format',
+ }),
+ value: '0,0.[000]',
+ type: 'string',
+ description: i18n.translate('fieldFormats.advancedSettings.format.numberFormatText', {
+ defaultMessage: 'Default {numeralFormatLink} for the "number" format',
+ description:
+ 'Part of composite text: fieldFormats.advancedSettings.format.numberFormatText + ' +
+ 'fieldFormats.advancedSettings.format.numberFormat.numeralFormatLinkText',
+ values: {
+ numeralFormatLink:
+ '' +
+ i18n.translate(
+ 'fieldFormats.advancedSettings.format.numberFormat.numeralFormatLinkText',
+ {
+ defaultMessage: 'numeral format',
+ }
+ ) +
+ '',
+ },
+ }),
+ schema: schema.string(),
+ },
+ [FORMATS_UI_SETTINGS.FORMAT_PERCENT_DEFAULT_PATTERN]: {
+ name: i18n.translate('fieldFormats.advancedSettings.format.percentFormatTitle', {
+ defaultMessage: 'Percent format',
+ }),
+ value: '0,0.[000]%',
+ type: 'string',
+ description: i18n.translate('fieldFormats.advancedSettings.format.percentFormatText', {
+ defaultMessage: 'Default {numeralFormatLink} for the "percent" format',
+ description:
+ 'Part of composite text: fieldFormats.advancedSettings.format.percentFormatText + ' +
+ 'fieldFormats.advancedSettings.format.percentFormat.numeralFormatLinkText',
+ values: {
+ numeralFormatLink:
+ '' +
+ i18n.translate(
+ 'fieldFormats.advancedSettings.format.percentFormat.numeralFormatLinkText',
+ {
+ defaultMessage: 'numeral format',
+ }
+ ) +
+ '',
+ },
+ }),
+ schema: schema.string(),
+ },
+ [FORMATS_UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN]: {
+ name: i18n.translate('fieldFormats.advancedSettings.format.bytesFormatTitle', {
+ defaultMessage: 'Bytes format',
+ }),
+ value: '0,0.[0]b',
+ type: 'string',
+ description: i18n.translate('fieldFormats.advancedSettings.format.bytesFormatText', {
+ defaultMessage: 'Default {numeralFormatLink} for the "bytes" format',
+ description:
+ 'Part of composite text: fieldFormats.advancedSettings.format.bytesFormatText + ' +
+ 'fieldFormats.advancedSettings.format.bytesFormat.numeralFormatLinkText',
+ values: {
+ numeralFormatLink:
+ '' +
+ i18n.translate(
+ 'fieldFormats.advancedSettings.format.bytesFormat.numeralFormatLinkText',
+ {
+ defaultMessage: 'numeral format',
+ }
+ ) +
+ '',
+ },
+ }),
+ schema: schema.string(),
+ },
+ [FORMATS_UI_SETTINGS.FORMAT_CURRENCY_DEFAULT_PATTERN]: {
+ name: i18n.translate('fieldFormats.advancedSettings.format.currencyFormatTitle', {
+ defaultMessage: 'Currency format',
+ }),
+ value: '($0,0.[00])',
+ type: 'string',
+ description: i18n.translate('fieldFormats.advancedSettings.format.currencyFormatText', {
+ defaultMessage: 'Default {numeralFormatLink} for the "currency" format',
+ description:
+ 'Part of composite text: fieldFormats.advancedSettings.format.currencyFormatText + ' +
+ 'fieldFormats.advancedSettings.format.currencyFormat.numeralFormatLinkText',
+ values: {
+ numeralFormatLink:
+ '' +
+ i18n.translate(
+ 'fieldFormats.advancedSettings.format.currencyFormat.numeralFormatLinkText',
+ {
+ defaultMessage: 'numeral format',
+ }
+ ) +
+ '',
+ },
+ }),
+ schema: schema.string(),
+ },
+ [FORMATS_UI_SETTINGS.FORMAT_NUMBER_DEFAULT_LOCALE]: {
+ name: i18n.translate('fieldFormats.advancedSettings.format.formattingLocaleTitle', {
+ defaultMessage: 'Formatting locale',
+ }),
+ value: 'en',
+ type: 'select',
+ options: numeralLanguageIds,
+ optionLabels: Object.fromEntries(
+ numeralLanguages.map((language: Record) => [language.id, language.name])
+ ),
+ description: i18n.translate('fieldFormats.advancedSettings.format.formattingLocaleText', {
+ defaultMessage: `{numeralLanguageLink} locale`,
+ description:
+ 'Part of composite text: fieldFormats.advancedSettings.format.formattingLocale.numeralLanguageLinkText + ' +
+ 'fieldFormats.advancedSettings.format.formattingLocaleText',
+ values: {
+ numeralLanguageLink:
+ '' +
+ i18n.translate(
+ 'fieldFormats.advancedSettings.format.formattingLocale.numeralLanguageLinkText',
+ {
+ defaultMessage: 'Numeral language',
+ }
+ ) +
+ '',
+ },
+ }),
+ schema: schema.string(),
+ },
+ };
+}
diff --git a/src/plugins/field_formats/tsconfig.json b/src/plugins/field_formats/tsconfig.json
new file mode 100644
index 0000000000000..4382ab1051c1d
--- /dev/null
+++ b/src/plugins/field_formats/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": [
+ "common/**/*",
+ "public/**/*",
+ "server/**/*",
+ "config.ts",
+ "common/**/*.json",
+ "public/**/*.json"
+ ],
+ "references": [{ "path": "../../core/tsconfig.json" }]
+}
diff --git a/src/plugins/index_pattern_editor/README.md b/src/plugins/index_pattern_editor/README.md
new file mode 100644
index 0000000000000..3ffb589230732
--- /dev/null
+++ b/src/plugins/index_pattern_editor/README.md
@@ -0,0 +1,48 @@
+# Index pattern editor
+
+Create index patterns from within Kibana apps.
+
+## How to use
+
+You first need to add in your kibana.json the "`indexPatternEditor`" plugin as a required dependency of your plugin.
+
+You will then receive in the start contract of the indexPatternEditor plugin the following API:
+
+### `userPermissions.editIndexPattern(): boolean`
+
+Convenience method that uses the `core.application.capabilities` api to determine whether the user can create or edit the index pattern.
+
+### `openEditor(options: IndexPatternEditorProps): CloseEditor`
+
+Use this method to display the index pattern editor to create an index pattern.
+
+#### `options`
+
+`onSave: (indexPattern: IndexPattern) => void` (**required**)
+
+You must provide an `onSave` handler to be notified when an index pattern has been created/updated. This handler is called after the index pattern has been persisted as a saved object.
+
+`onCancel: () => void;` (optional)
+
+You can optionally pass an `onCancel` handler which is called when the index pattern creation flyout is closed wihtout creating an index pattern.
+
+`defaultTypeIsRollup: boolean` (optional, default false)
+
+The default index pattern type can be optionally specified as `rollup`.
+
+`requireTimestampField: boolean` (optional, default false)
+
+The editor can require a timestamp field on the index pattern.
+
+### IndexPatternEditorComponent
+
+This the React component interface equivalent to `openEditor`. It takes the same arguments -
+
+```tsx
+
+```
diff --git a/src/plugins/index_pattern_editor/jest.config.js b/src/plugins/index_pattern_editor/jest.config.js
new file mode 100644
index 0000000000000..0a018a42d06e6
--- /dev/null
+++ b/src/plugins/index_pattern_editor/jest.config.js
@@ -0,0 +1,13 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+module.exports = {
+ preset: '@kbn/test',
+ rootDir: '../../..',
+ roots: ['/src/plugins/index_pattern_editor'],
+};
diff --git a/src/plugins/index_pattern_editor/kibana.json b/src/plugins/index_pattern_editor/kibana.json
new file mode 100644
index 0000000000000..b4a1bea555616
--- /dev/null
+++ b/src/plugins/index_pattern_editor/kibana.json
@@ -0,0 +1,13 @@
+{
+ "id": "indexPatternEditor",
+ "version": "kibana",
+ "server": false,
+ "ui": true,
+ "requiredPlugins": ["data"],
+ "requiredBundles": ["kibanaReact", "esUiShared"],
+ "owner": {
+ "name": "App Services",
+ "githubTeam": "kibana-app-services"
+ },
+ "description": "This plugin provides the ability to create index patterns via a modal flyout from any kibana app"
+}
diff --git a/src/plugins/index_pattern_editor/public/components/_templates.scss b/src/plugins/index_pattern_editor/public/components/_templates.scss
new file mode 100644
index 0000000000000..5303537bddabc
--- /dev/null
+++ b/src/plugins/index_pattern_editor/public/components/_templates.scss
@@ -0,0 +1,11 @@
+%inp-empty-state-footer {
+ background: $euiColorLightestShade;
+ margin: 0 (-$euiSizeL) (-$euiSizeL);
+ padding: $euiSizeL;
+ border-radius: 0 0 $euiBorderRadius $euiBorderRadius;
+
+ // sass-lint:disable-block mixins-before-declarations
+ @include euiBreakpoint('xs', 's') {
+ text-align: center;
+ }
+}
diff --git a/src/plugins/index_pattern_editor/public/components/_variables.scss b/src/plugins/index_pattern_editor/public/components/_variables.scss
new file mode 100644
index 0000000000000..5da25a91bd77c
--- /dev/null
+++ b/src/plugins/index_pattern_editor/public/components/_variables.scss
@@ -0,0 +1 @@
+$inpEmptyStateMaxWidth: $euiSizeXXL * 19;
diff --git a/src/plugins/index_pattern_editor/public/components/advanced_params_content/advanced_params_content.tsx b/src/plugins/index_pattern_editor/public/components/advanced_params_content/advanced_params_content.tsx
new file mode 100644
index 0000000000000..ad876fed51801
--- /dev/null
+++ b/src/plugins/index_pattern_editor/public/components/advanced_params_content/advanced_params_content.tsx
@@ -0,0 +1,66 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import React from 'react';
+import { i18n } from '@kbn/i18n';
+import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
+
+import { UseField, TextField, ToggleField } from '../../shared_imports';
+import { IndexPatternConfig } from '../../types';
+
+import { AdvancedParamsSection } from './advanced_params_section';
+
+const allowHiddenAriaLabel = i18n.translate('indexPatternEditor.form.allowHiddenAriaLabel', {
+ defaultMessage: 'Allow hidden and system indices',
+});
+
+const customIndexPatternIdLabel = i18n.translate(
+ 'indexPatternEditor.form.customIndexPatternIdLabel',
+ {
+ defaultMessage: 'Custom index pattern ID',
+ }
+);
+
+interface AdvancedParamsContentProps {
+ disableAllowHidden: boolean;
+}
+
+export const AdvancedParamsContent = ({ disableAllowHidden }: AdvancedParamsContentProps) => (
+
+
+
+
+ path={'allowHidden'}
+ component={ToggleField}
+ data-test-subj="allowHiddenField"
+ componentProps={{
+ euiFieldProps: {
+ 'aria-label': allowHiddenAriaLabel,
+ disabled: disableAllowHidden,
+ },
+ }}
+ />
+
+
+
+
+
+
+ path={'id'}
+ component={TextField}
+ data-test-subj="savedObjectIdField"
+ componentProps={{
+ euiFieldProps: {
+ 'aria-label': customIndexPatternIdLabel,
+ },
+ }}
+ />
+
+
+
+);
diff --git a/src/plugins/index_pattern_editor/public/components/advanced_params_content/advanced_params_section.tsx b/src/plugins/index_pattern_editor/public/components/advanced_params_content/advanced_params_section.tsx
new file mode 100644
index 0000000000000..b313fddb8ee2d
--- /dev/null
+++ b/src/plugins/index_pattern_editor/public/components/advanced_params_content/advanced_params_section.tsx
@@ -0,0 +1,44 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import React, { useState, useCallback } from 'react';
+import { i18n } from '@kbn/i18n';
+
+import { EuiButtonEmpty, EuiSpacer } from '@elastic/eui';
+
+interface Props {
+ children: React.ReactNode;
+}
+
+export const AdvancedParamsSection = ({ children }: Props) => {
+ const [isVisible, setIsVisible] = useState(false);
+
+ const toggleIsVisible = useCallback(() => {
+ setIsVisible(!isVisible);
+ }, [isVisible]);
+
+ return (
+ <>
+
+ {isVisible
+ ? i18n.translate('indexPatternEditor.editor.form.advancedSettings.hideButtonLabel', {
+ defaultMessage: 'Hide advanced settings',
+ })
+ : i18n.translate('indexPatternEditor.editor.form.advancedSettings.showButtonLabel', {
+ defaultMessage: 'Show advanced settings',
+ })}
+
+
+
+
+ {/* We ned to wrap the children inside a "div" to have our css :first-child rule */}
+
{children}
+
+ >
+ );
+};
diff --git a/src/plugins/index_pattern_editor/public/components/advanced_params_content/index.ts b/src/plugins/index_pattern_editor/public/components/advanced_params_content/index.ts
new file mode 100644
index 0000000000000..a285004d1f45d
--- /dev/null
+++ b/src/plugins/index_pattern_editor/public/components/advanced_params_content/index.ts
@@ -0,0 +1,9 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export { AdvancedParamsContent } from './advanced_params_content';
diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/__snapshots__/empty_index_list_prompt.test.tsx.snap
similarity index 71%
rename from src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap
rename to src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/__snapshots__/empty_index_list_prompt.test.tsx.snap
index 75b8177d9dac3..a104c36e3a8a0 100644
--- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/__snapshots__/empty_state.test.tsx.snap
+++ b/src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/__snapshots__/empty_index_list_prompt.test.tsx.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`EmptyState should render normally 1`] = `
+exports[`EmptyIndexListPrompt should render normally 1`] = `
@@ -38,7 +38,7 @@ exports[`EmptyState should render normally 1`] = `
description={
}
@@ -53,7 +53,7 @@ exports[`EmptyState should render normally 1`] = `
title={
}
@@ -65,7 +65,7 @@ exports[`EmptyState should render normally 1`] = `
description={
}
@@ -80,7 +80,7 @@ exports[`EmptyState should render normally 1`] = `
title={
}
@@ -92,7 +92,7 @@ exports[`EmptyState should render normally 1`] = `
description={
}
@@ -107,7 +107,7 @@ exports[`EmptyState should render normally 1`] = `
title={
}
@@ -131,18 +131,18 @@ exports[`EmptyState should render normally 1`] = `
Object {
"description":
,
"title": ,
},
@@ -164,7 +164,7 @@ exports[`EmptyState should render normally 1`] = `
>
@@ -175,7 +175,7 @@ exports[`EmptyState should render normally 1`] = `
,
"title": ,
},
@@ -184,33 +184,33 @@ exports[`EmptyState should render normally 1`] = `
/>
+
+
+
+
+ ,
+ }
+ }
+ />
+
-
-
-
-
- ,
- }
- }
- />
-
`;
diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss b/src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.scss
similarity index 86%
rename from src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss
rename to src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.scss
index 37889b9d7c483..845ddfb3eb234 100644
--- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.scss
+++ b/src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.scss
@@ -1,5 +1,5 @@
-@import '../../../variables';
-@import '../../../templates';
+@import '../../variables';
+@import '../../templates';
.inpEmptyState {
// override EUI specificity
diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx b/src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.test.tsx
similarity index 69%
rename from src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx
rename to src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.test.tsx
index ed68d4d4ddd64..f5a996a441515 100644
--- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx
+++ b/src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.test.tsx
@@ -7,14 +7,11 @@
*/
import React from 'react';
-import { EmptyState } from '../empty_state';
+import { EmptyIndexListPrompt } from './empty_index_list_prompt';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import { findTestSubject } from '@elastic/eui/lib/test';
import { mountWithIntl } from '@kbn/test/jest';
-import { docLinksServiceMock } from '../../../../../../core/public/mocks';
-
-const docLinks = docLinksServiceMock.createStartContract();
jest.mock('react-router-dom', () => ({
useHistory: () => ({
@@ -22,14 +19,16 @@ jest.mock('react-router-dom', () => ({
}),
}));
-describe('EmptyState', () => {
+describe('EmptyIndexListPrompt', () => {
it('should render normally', () => {
const component = shallow(
- {}}
- navigateToApp={async () => {}}
- canSave={true}
+ createAnyway={() => {}}
+ closeFlyout={() => {}}
+ addDataUrl={'http://elastic.co'}
+ navigateToApp={async (appId) => {}}
+ canSaveIndexPattern={true}
/>
);
@@ -42,11 +41,13 @@ describe('EmptyState', () => {
const onRefreshHandler = sinon.stub();
const component = mountWithIntl(
- {}}
- canSave={true}
+ createAnyway={() => {}}
+ closeFlyout={() => {}}
+ addDataUrl={'http://elastic.co'}
+ navigateToApp={async (appId) => {}}
+ canSaveIndexPattern={true}
/>
);
diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.tsx
similarity index 72%
rename from src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx
rename to src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.tsx
index af49e8c36fe3b..1331eb9b7c4ac 100644
--- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx
+++ b/src/plugins/index_pattern_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.tsx
@@ -6,10 +6,9 @@
* Side Public License, v 1.
*/
-import './empty_state.scss';
+import './empty_index_list_prompt.scss';
import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
-import { DocLinksStart, ApplicationStart } from 'kibana/public';
import {
EuiPageContentHeader,
EuiPageContentHeaderSection,
@@ -26,30 +25,34 @@ import {
EuiText,
EuiFlexGroup,
} from '@elastic/eui';
-import { useHistory } from 'react-router-dom';
-import { reactRouterNavigate } from '../../../../../../plugins/kibana_react/public';
-export const EmptyState = ({
+import { ApplicationStart } from 'src/core/public';
+
+export const EmptyIndexListPrompt = ({
onRefresh,
+ closeFlyout,
+ createAnyway,
+ canSaveIndexPattern,
+ addDataUrl,
navigateToApp,
- docLinks,
- canSave,
}: {
onRefresh: () => void;
+ closeFlyout: () => void;
+ createAnyway: () => void;
+ canSaveIndexPattern: boolean;
+ addDataUrl: string;
navigateToApp: ApplicationStart['navigateToApp'];
- docLinks: DocLinksStart;
- canSave: boolean;
}) => {
- const createAnyway = (
+ const createAnywayLink = (
+ createAnyway()} data-test-subj="createAnyway">
@@ -74,7 +77,7 @@ export const EmptyState = ({
@@ -87,17 +90,20 @@ export const EmptyState = ({
navigateToApp('home', { path: '#/tutorial_directory' })}
+ onClick={() => {
+ navigateToApp('home', { path: '#/tutorial_directory' });
+ closeFlyout();
+ }}
icon={}
title={
}
description={
}
@@ -110,13 +116,13 @@ export const EmptyState = ({
icon={}
title={
}
description={
}
@@ -125,17 +131,20 @@ export const EmptyState = ({
navigateToApp('home', { path: '#/tutorial_directory/sampleData' })}
+ onClick={() => {
+ navigateToApp('home', { path: '#/tutorial_directory/sampleData' });
+ closeFlyout();
+ }}
icon={}
title={
}
description={
}
@@ -151,14 +160,14 @@ export const EmptyState = ({
{
title: (
),
description: (
-
+
@@ -173,14 +182,14 @@ export const EmptyState = ({
{
title: (
),
description: (
{' '}
@@ -191,11 +200,11 @@ export const EmptyState = ({
/>
+
+ {canSaveIndexPattern && createAnywayLink}
-