Skip to content

Commit 5d6dbf0

Browse files
Expose NP FieldFormats service to server side (#55419)
* Expose NP FieldFormats service to server side * fix CI * fix PR comments * fix PR comments * fix CI * getFieldFormatsRegistry -> getFieldFormatRegistry * fix CI * memoize - add resolve cache function * fix Jest * move IFieldFormatMetaParams to types.ts * FieldFormatRegistry -> FieldFormatsRegistry * update src/core/MIGRATION.md * update public contract Co-authored-by: Elastic Machine <[email protected]>
1 parent 9301531 commit 5d6dbf0

File tree

70 files changed

+525
-741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+525
-741
lines changed

.eslintrc.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ module.exports = {
244244
{
245245
target: [
246246
'(src|x-pack)/plugins/**/*',
247-
'!(src|x-pack)/plugins/*/server/**/*',
247+
'!(src|x-pack)/plugins/**/server/**/*',
248248

249249
'src/legacy/core_plugins/**/*',
250-
'!src/legacy/core_plugins/*/server/**/*',
251-
'!src/legacy/core_plugins/*/index.{js,ts,tsx}',
250+
'!src/legacy/core_plugins/**/server/**/*',
251+
'!src/legacy/core_plugins/**/index.{js,ts,tsx}',
252252

253253
'x-pack/legacy/plugins/**/*',
254-
'!x-pack/legacy/plugins/*/server/**/*',
255-
'!x-pack/legacy/plugins/*/index.{js,ts,tsx}',
254+
'!x-pack/legacy/plugins/**/server/**/*',
255+
'!x-pack/legacy/plugins/**/index.{js,ts,tsx}',
256256

257257
'examples/**/*',
258258
'!examples/**/server/**/*',

src/core/MIGRATION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,8 +1231,8 @@ This table shows where these uiExports have moved to in the New Platform. In mos
12311231
| `docViews` | | |
12321232
| `embeddableActions` | | Should be an API on the embeddables plugin. |
12331233
| `embeddableFactories` | | Should be an API on the embeddables plugin. |
1234-
| `fieldFormatEditors` | | |
1235-
| `fieldFormats` | | |
1234+
| `fieldFormatEditors` | | |
1235+
| `fieldFormats` | [`plugins.data.fieldFormats`](./src/plugins/data/public/field_formats) | |
12361236
| `hacks` | n/a | Just run the code in your plugin's `start` method. |
12371237
| `home` | [`plugins.home.featureCatalogue.register`](./src/plugins/home/public/feature_catalogue) | Must add `home` as a dependency in your kibana.json. |
12381238
| `indexManagement` | | Should be an API on the indexManagement plugin. |

src/legacy/core_plugins/kibana/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { migrations } from './migrations';
2525
import { importApi } from './server/routes/api/import';
2626
import { exportApi } from './server/routes/api/export';
2727
import { managementApi } from './server/routes/api/management';
28-
import { registerFieldFormats } from './server/field_formats/register';
2928
import * as systemApi from './server/lib/system_api';
3029
import mappings from './mappings.json';
3130
import { getUiSettingDefaults } from './ui_setting_defaults';
@@ -331,7 +330,6 @@ export default function(kibana) {
331330
importApi(server);
332331
exportApi(server);
333332
managementApi(server);
334-
registerFieldFormats(server);
335333
registerCspCollector(usageCollection, server);
336334
server.expose('systemApi', systemApi);
337335
server.injectUiAppVars('kibana', () => injectVars(server));

src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_component.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { isColorDark } from '@elastic/eui';
2424

2525
import { getHeatmapColors, getFormat, Vis } from '../legacy_imports';
2626
import { MetricVisValue } from './metric_vis_value';
27-
import { FieldFormat, ContentType } from '../../../../../plugins/data/public';
27+
import { fieldFormats } from '../../../../../plugins/data/public';
2828
import { Context } from '../metric_vis_fn';
2929
import { KibanaDatatable } from '../../../../../plugins/expressions/public';
3030
import { VisParams, MetricVisMetric } from '../types';
@@ -100,9 +100,9 @@ export class MetricVisComponent extends Component<MetricVisComponentProps> {
100100
}
101101

102102
private getFormattedValue = (
103-
fieldFormatter: FieldFormat,
103+
fieldFormatter: fieldFormats.FieldFormat,
104104
value: any,
105-
format: ContentType = 'text'
105+
format: fieldFormats.ContentType = 'text'
106106
) => {
107107
if (isNaN(value)) return '-';
108108
return fieldFormatter.convert(value, format);
@@ -119,7 +119,7 @@ export class MetricVisComponent extends Component<MetricVisComponentProps> {
119119
const metrics: MetricVisMetric[] = [];
120120

121121
let bucketColumnId: string;
122-
let bucketFormatter: FieldFormat;
122+
let bucketFormatter: fieldFormats.FieldFormat;
123123

124124
if (dimensions.bucket) {
125125
bucketColumnId = table.columns[dimensions.bucket.accessor].id;

src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { npStart } from 'ui/new_platform';
2424
import getStubIndexPattern from 'fixtures/stubbed_logstash_index_pattern';
2525

2626
import { Vis } from '../../visualizations/public';
27-
import { UrlFormat } from '../../../../plugins/data/public';
27+
import { fieldFormats } from '../../../../plugins/data/public';
2828
import {
2929
setup as visualizationsSetup,
3030
start as visualizationsStart,
@@ -39,7 +39,7 @@ describe('metric_vis - createMetricVisTypeDefinition', () => {
3939
beforeAll(() => {
4040
visualizationsSetup.types.createReactVisualization(metricVisTypeDefinition);
4141
(npStart.plugins.data.fieldFormats.getType as jest.Mock).mockImplementation(() => {
42-
return UrlFormat;
42+
return fieldFormats.UrlFormat;
4343
});
4444
});
4545

src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/vis.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { calculateLabel } from '../../../../common/calculate_label';
2626
import { isSortable } from './is_sortable';
2727
import { EuiToolTip, EuiIcon } from '@elastic/eui';
2828
import { replaceVars } from '../../lib/replace_vars';
29-
import { FIELD_FORMAT_IDS } from '../../../../../../../plugins/data/public';
29+
import { fieldFormats } from '../../../../../../../plugins/data/public';
3030
import { FormattedMessage } from '@kbn/i18n/react';
3131

3232
import { METRIC_TYPES } from '../../../../common/metric_types';
@@ -49,8 +49,8 @@ export class TableVis extends Component {
4949
constructor(props) {
5050
super(props);
5151

52-
const fieldFormats = npStart.plugins.data.fieldFormats;
53-
const DateFormat = fieldFormats.getType(FIELD_FORMAT_IDS.DATE);
52+
const fieldFormatsService = npStart.plugins.data.fieldFormats;
53+
const DateFormat = fieldFormatsService.getType(fieldFormats.FIELD_FORMAT_IDS.DATE);
5454

5555
this.dateFormatter = new DateFormat({}, this.props.getConfig);
5656
}

src/legacy/ui/field_formats/index.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/legacy/ui/field_formats/mixin/field_formats_mixin.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/legacy/ui/field_formats/mixin/field_formats_service.test.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/legacy/ui/field_formats/mixin/field_formats_service.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)