Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use NP registry instead of ui/registry/field_formats #48108

Merged
merged 83 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
3fdc72c
Create Field Format Provider
Oct 14, 2019
d78831c
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 15, 2019
8ed3a08
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 18, 2019
9145cf1
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 21, 2019
c8648ad
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 23, 2019
d087d58
Pass Field Format as a start dependency
Oct 23, 2019
75d9d79
Register utils in the new field formats
Oct 23, 2019
da2fb9a
Fix types issue
Oct 23, 2019
c2bb98c
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 24, 2019
95a3b88
Make FieldFormats instance as a service
Oct 24, 2019
0fe1044
Exclude importing of register.js
Oct 24, 2019
5728d15
Remove uiExports/fieldFormats imports
Oct 24, 2019
66c66ef
Migrate some dependencies to new Field Format
Oct 24, 2019
ccd5570
Migrate field format to new instance
Oct 24, 2019
8ebce14
Fix type errors
Oct 24, 2019
72220cb
Fix Jest tests
Oct 24, 2019
1c8f5e1
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 25, 2019
4bdb7e7
Move from getFieldFormat to npSetup
Oct 25, 2019
c4a4fbb
Fix types errors
Oct 28, 2019
02e13a3
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 28, 2019
e7e9ed8
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 28, 2019
213ac00
Fix reviews
Oct 28, 2019
22e7965
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 29, 2019
c83cd96
Fix types errors
Oct 29, 2019
695e9ea
Fix types
Oct 29, 2019
efcb371
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
alexwizp Oct 30, 2019
046cd2b
fix CI
alexwizp Oct 30, 2019
af5f903
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 30, 2019
c39d283
Bind getConfig to FieldFormatRegisty
Oct 30, 2019
a0ae304
Mock FieldFormat in FieldItem
Oct 30, 2019
96b55d8
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 30, 2019
62c56da
Fix DataPanel tests
Oct 30, 2019
4a0ea4c
Fix DataPanel tests
Oct 30, 2019
0d5b0c6
Fix Jest tests
Oct 30, 2019
9e2f6a0
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Oct 31, 2019
fa8c0bf
Create a fieldFormats mock for mocha tests
Oct 31, 2019
dcc96f6
fix CI
alexwizp Oct 31, 2019
5fe68c7
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
alexwizp Oct 31, 2019
3982e39
fix CI
alexwizp Nov 1, 2019
14dfb80
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 1, 2019
020c0b2
Mock fieldFormatsRegistry in all visualizations
Nov 1, 2019
60bdf2a
Merge branch 'use-np-registry-field-formats' of github.com:Avinar-24/…
Nov 1, 2019
37cd814
Fix 'should create scripted field' functional test
Nov 1, 2019
7664308
Change FieldFormat.from return type
Nov 1, 2019
e8f4920
Fix reviews
Nov 1, 2019
8a24e34
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 4, 2019
49c5f6d
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 4, 2019
781f5f5
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 5, 2019
1a4edb3
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 6, 2019
93ef80b
Fix mocha test
Nov 6, 2019
0ffcf1a
Fix mocha tests
Nov 6, 2019
9e287e2
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 11, 2019
c247c2f
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 11, 2019
2dcdfa5
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 11, 2019
f09e006
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 12, 2019
e3b3992
Merge branch 'master' into use-np-registry-field-formats
elasticmachine Nov 12, 2019
0a42ba4
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 13, 2019
398aa70
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 13, 2019
07ef6fa
Merge branch 'master' into use-np-registry-field-formats
Nov 14, 2019
7aac597
Encapsulate FieldFormatRegistry
Nov 14, 2019
05d09eb
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 15, 2019
69877c5
Pretty field_item.tsx
Nov 15, 2019
64345b0
Fix reviews
Nov 15, 2019
e958b4b
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
alexwizp Nov 16, 2019
59e9536
Fix PR comments
alexwizp Nov 16, 2019
8aedb77
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
alexwizp Nov 18, 2019
aff9a0d
Fix CI
alexwizp Nov 18, 2019
3bc61f4
Replace any by a specific type
Nov 18, 2019
f934c08
Fix mocha tests
Nov 18, 2019
cf70c5d
Remove config from url converter
Nov 18, 2019
59a4f1d
Expand Field Format ID type for creating custom converters
Nov 19, 2019
721931f
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 19, 2019
54b22e4
Fix a jest test
Nov 19, 2019
f8ba121
Merge branch 'master' into use-np-registry-field-formats
Nov 19, 2019
856744f
Update migration doc
Nov 19, 2019
7aab80d
Add quote and semicolon
Nov 19, 2019
5940ae6
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 19, 2019
466608e
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 19, 2019
5506c57
Merge branch 'master' into use-np-registry-field-formats
elasticmachine Nov 20, 2019
bc6ad8a
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 20, 2019
331518d
Fix types errors which doesn't relate to the aim of PR
Nov 20, 2019
dca6f91
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 20, 2019
f7ae0bf
Merge remote-tracking branch 'upstream/master' into use-np-registry-f…
Nov 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/developer/plugin/development-uiexports.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ An aggregate list of available UiExport types:
| Type | Purpose
| hacks | Any module that should be included in every application
| visTypes | Modules that register providers with the `ui/registry/vis_types` registry.
| fieldFormats | Modules that register providers with the `ui/registry/field_formats` registry.
| inspectorViews | Modules that register custom inspector views via the `viewRegistry` in `ui/inspector`.
| chromeNavControls | Modules that register providers with the `ui/registry/chrome_nav_controls` registry.
| navbarExtensions | Modules that register providers with the `ui/registry/navbar_extensions` registry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
* under the License.
*/

// @ts-ignore
import { fieldFormats } from 'ui/registry/field_formats';
import { i18n } from '@kbn/i18n';
// @ts-ignore
import { ObjDefine } from './obj_define';
import { FieldFormat } from '../../../../../../plugins/data/common/field_formats';
import { FieldFormat } from '../../../../../../plugins/data/public';
// @ts-ignore
import { shortenDottedString } from '../../../../../core_plugins/kibana/common/utils/shorten_dotted_string';
import { IndexPattern } from '../index_patterns';
import { getNotifications } from '../services';
import { getNotifications, getFieldFormats } from '../services';

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

Expand Down Expand Up @@ -120,6 +118,8 @@ export class Field implements FieldType {

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

format =
indexPattern.fieldFormatMap[spec.name] ||
fieldFormats.getDefaultInstance(spec.type, spec.esTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ import mockLogStashFields from '../../../../../../fixtures/logstash_fields';

import { stubbedSavedObjectIndexPattern } from '../../../../../../fixtures/stubbed_saved_object_index_pattern';
import { Field } from '../index_patterns_service';
import { setNotifications } from '../services';
import { setNotifications, setFieldFormats } from '../services';

// Temporary disable eslint, will be removed after moving to new platform folder
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { notificationServiceMock } from '../../../../../../core/public/notifications/notifications_service.mock';
import { FieldFormatRegisty } from '../../../../../../plugins/data/public';

jest.mock('ui/registry/field_formats', () => ({
fieldFormats: {
getDefaultInstance: jest.fn(),
},
}));
jest.mock('ui/new_platform');

jest.mock('../../../../../../plugins/kibana_utils/public', () => {
const originalModule = jest.requireActual('../../../../../../plugins/kibana_utils/public');
Expand Down Expand Up @@ -142,6 +139,9 @@ describe('IndexPattern', () => {
// create an indexPattern instance for each test
beforeEach(() => {
setNotifications(notifications);
setFieldFormats(({
getDefaultInstance: jest.fn(),
} as unknown) as FieldFormatRegisty);

return create(indexPatternId).then((pattern: IndexPattern) => {
indexPattern = pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import _, { each, reject } from 'lodash';
import { i18n } from '@kbn/i18n';
// @ts-ignore
import { fieldFormats } from 'ui/registry/field_formats';
import { SavedObjectsClientContract } from 'src/core/public';
import {
DuplicateField,
Expand All @@ -37,8 +35,8 @@ import { createFieldsFetcher } from './_fields_fetcher';
import { formatHitProvider } from './format_hit';
import { flattenHitWrapper } from './flatten_hit';
import { IIndexPatternsApiClient } from './index_patterns_api_client';
import { ES_FIELD_TYPES } from '../../../../../../plugins/data/common';
import { getNotifications } from '../services';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '../../../../../../plugins/data/common';
gospodarsky marked this conversation as resolved.
Show resolved Hide resolved
import { getNotifications, getFieldFormats } from '../services';

const MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS = 3;
const type = 'index-pattern';
Expand Down Expand Up @@ -117,7 +115,10 @@ export class IndexPattern implements StaticIndexPattern {
this.fields = new FieldList(this, [], this.shortDotsEnable);
this.fieldsFetcher = createFieldsFetcher(this, apiClient, this.getConfig('metaFields'));
this.flattenHit = flattenHitWrapper(this, this.getConfig('metaFields'));
this.formatHit = formatHitProvider(this, fieldFormats.getDefaultInstance('string'));
this.formatHit = formatHitProvider(
this,
getFieldFormats().getDefaultInstance(KBN_FIELD_TYPES.STRING)
);
this.formatField = this.formatHit.formatField;
}

Expand All @@ -128,12 +129,14 @@ export class IndexPattern implements StaticIndexPattern {
}

private deserializeFieldFormatMap(mapping: any) {
const FieldFormat = fieldFormats.getType(mapping.id);
const FieldFormat = getFieldFormats().getType(mapping.id);

return FieldFormat && new FieldFormat(mapping.params, this.getConfig);
}

private initFields(input?: any) {
const newValue = input || this.fields;

this.fields = new FieldList(this, newValue, this.shortDotsEnable);
}

Expand Down Expand Up @@ -454,6 +457,7 @@ export class IndexPattern implements StaticIndexPattern {
const { toasts } = getNotifications();

toasts.addDanger(message);

throw err;
}

Expand Down Expand Up @@ -495,6 +499,7 @@ export class IndexPattern implements StaticIndexPattern {

if (err instanceof IndexPatternMissingIndices) {
toasts.addDanger((err as any).message);

return [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ jest.mock('../errors', () => ({
IndexPatternMissingIndices: jest.fn(),
}));

jest.mock('ui/registry/field_formats', () => ({
fieldFormats: {
getDefaultInstance: jest.fn(),
},
}));

jest.mock('./index_pattern', () => {
class IndexPattern {
init = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {
UiSettingsClientContract,
HttpServiceBase,
} from 'src/core/public';
// @ts-ignore
import { fieldFormats } from 'ui/registry/field_formats';

import { createIndexPatternCache } from './_pattern_cache';
import { IndexPattern } from './index_pattern';
Expand All @@ -34,8 +32,6 @@ import { IndexPatternsApiClient } from './index_patterns_api_client';
const indexPatternCache = createIndexPatternCache();

export class IndexPatterns {
fieldFormats: fieldFormats;

private config: UiSettingsClientContract;
private savedObjectsClient: SavedObjectsClientContract;
private savedObjectsCache?: Array<SimpleSavedObject<Record<string, any>>> | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import {
HttpServiceBase,
NotificationsStart,
} from 'src/core/public';
import { FieldFormatRegisty } from '../../../../../plugins/data/public';
import { Field, FieldList, FieldListInterface, FieldType } from './fields';
import { createFlattenHitWrapper } from './index_patterns';
import { createIndexPatternSelect } from './components';
import { setNotifications } from './services';
import { setNotifications, setFieldFormats } from './services';

import {
formatHitProvider,
Expand All @@ -40,6 +41,7 @@ export interface IndexPatternDependencies {
savedObjectsClient: SavedObjectsClientContract;
http: HttpServiceBase;
notifications: NotificationsStart;
fieldFormats: FieldFormatRegisty;
}

/**
Expand All @@ -64,8 +66,15 @@ export class IndexPatternsService {
return this.setupApi;
}

public start({ uiSettings, savedObjectsClient, http, notifications }: IndexPatternDependencies) {
public start({
uiSettings,
savedObjectsClient,
http,
notifications,
fieldFormats,
}: IndexPatternDependencies) {
setNotifications(notifications);
setFieldFormats(fieldFormats);

return {
...this.setupApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@

import { NotificationsStart } from 'src/core/public';
import { createGetterSetter } from '../../../../../plugins/kibana_utils/public';
import { FieldFormatRegisty } from '../../../../../plugins/data/public';

export const [getNotifications, setNotifications] = createGetterSetter<NotificationsStart>(
'Notifications'
);

export const [getFieldFormats, setFieldFormats] = createGetterSetter<FieldFormatRegisty>(
'FieldFormats'
);
1 change: 1 addition & 0 deletions src/legacy/core_plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class DataPlugin implements Plugin<DataSetup, DataStart, {}, DataPluginSt
savedObjectsClient: savedObjects.client,
http,
notifications,
fieldFormats: data.fieldFormats,
});

initLegacyModule(indexPatternsService.indexPatterns);
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export default function (kibana) {
hacks: [
'plugins/kibana/dev_tools/hacks/hide_empty_tools',
],
fieldFormats: ['plugins/kibana/field_formats/register'],
savedObjectTypes: [
'plugins/kibana/visualize/saved_visualizations/saved_visualization_register',
'plugins/kibana/discover/saved_searches/saved_search_register',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ import { DashboardAppState } from './types';
import { TimeRange } from 'src/plugins/data/public';
import { ViewMode } from 'src/plugins/embeddable/public';
import { InputTimeRange } from 'ui/timefilter';

jest.mock('ui/registry/field_formats', () => ({
fieldFormats: {
getDefaultInstance: jest.fn(),
},
}));

import { dataPluginMock } from '../../../../core_plugins/data/public/mocks';

const dataSetupMock = dataPluginMock.createSetup();

describe('DashboardState', function() {
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import 'uiExports/visTypes';
import 'uiExports/visEditorTypes';
import 'uiExports/visualize';
import 'uiExports/savedObjectTypes';
import 'uiExports/fieldFormats';
import 'uiExports/fieldFormatEditors';
import 'uiExports/navbarExtensions';
import 'uiExports/contextMenuActions';
Expand Down
Loading