Skip to content

Commit b05b7bd

Browse files
Merge branch 'master' into ML-apiDoc-gen
2 parents ab83920 + cf87efb commit b05b7bd

File tree

346 files changed

+10481
-5837
lines changed

Some content is hidden

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

346 files changed

+10481
-5837
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"test:karma": "grunt test:karma",
4444
"test:karma:debug": "grunt test:karmaDebug",
4545
"test:jest": "node scripts/jest",
46+
"test:jest_integration": "node scripts/jest_integration",
4647
"test:mocha": "node scripts/mocha",
4748
"test:mocha:coverage": "grunt test:mochaCoverage",
4849
"test:ftr": "node scripts/functional_tests",

src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ <h1 class="euiScreenReaderOnly">{{screenTitle}}</h1>
140140
position="'top'"
141141
></icon-tip>
142142
<span
143+
data-test-subj="discoverIntervalSelectScaledToDesc"
143144
i18n-id="kbn.discover.scaledToDescription"
144145
i18n-default-message="Scaled to {bucketIntervalDescription}"
145146
i18n-values="{

src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -675,17 +675,6 @@ function discoverController(
675675
}
676676
});
677677

678-
$scope.$watch('vis.aggs', function() {
679-
// no timefield, no vis, nothing to update
680-
if (!getTimeField() || !$scope.vis) return;
681-
682-
const buckets = $scope.vis.data.aggs.byTypeName('buckets');
683-
684-
if (buckets && buckets.length === 1) {
685-
$scope.bucketInterval = buckets[0].buckets.getInterval();
686-
}
687-
});
688-
689678
$scope.$watchMulti(
690679
['rows', 'fetchStatus'],
691680
(function updateResultState() {
@@ -891,6 +880,9 @@ function discoverController(
891880
tabifiedData,
892881
getDimensions($scope.vis.data.aggs.aggs, $scope.timeRange)
893882
);
883+
if ($scope.vis.data.aggs.aggs[1]) {
884+
$scope.bucketInterval = $scope.vis.data.aggs.aggs[1].buckets.getInterval();
885+
}
894886
}
895887

896888
$scope.hits = resp.hits.total;

src/legacy/ui/public/new_platform/new_platform.karma_mock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ export const npStart = {
453453
createAggConfigs: (indexPattern, configStates = []) => {
454454
return new AggConfigs(indexPattern, configStates, {
455455
typesRegistry: aggTypesRegistry.start(),
456+
fieldFormats: getFieldFormatsRegistry(mockCoreStart),
456457
});
457458
},
458459
types: aggTypesRegistry.start(),

src/plugins/data/public/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class DataPublicPlugin implements Plugin<DataPublicPluginSetup, DataPubli
155155
const query = this.queryService.start(savedObjects);
156156
setQueryService(query);
157157

158-
const search = this.searchService.start(core, indexPatterns);
158+
const search = this.searchService.start(core, { fieldFormats, indexPatterns });
159159
setSearchService(search);
160160

161161
uiActions.attachAction(APPLY_FILTER_TRIGGER, uiActions.getAction(ACTION_GLOBAL_APPLY_FILTER));

src/plugins/data/public/search/aggs/agg_config.test.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ import { AggTypesRegistryStart } from './agg_types_registry';
2626
import { mockDataServices, mockAggTypesRegistry } from './test_helpers';
2727
import { Field as IndexPatternField, IndexPattern } from '../../index_patterns';
2828
import { stubIndexPatternWithFields } from '../../../public/stubs';
29+
import { fieldFormatsServiceMock } from '../../field_formats/mocks';
2930

3031
describe('AggConfig', () => {
3132
let indexPattern: IndexPattern;
3233
let typesRegistry: AggTypesRegistryStart;
34+
const fieldFormats = fieldFormatsServiceMock.createStartContract();
3335

3436
beforeEach(() => {
3537
jest.restoreAllMocks();
@@ -40,7 +42,7 @@ describe('AggConfig', () => {
4042

4143
describe('#toDsl', () => {
4244
it('calls #write()', () => {
43-
const ac = new AggConfigs(indexPattern, [], { typesRegistry });
45+
const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats });
4446
const configStates = {
4547
enabled: true,
4648
type: 'date_histogram',
@@ -55,7 +57,7 @@ describe('AggConfig', () => {
5557
});
5658

5759
it('uses the type name as the agg name', () => {
58-
const ac = new AggConfigs(indexPattern, [], { typesRegistry });
60+
const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats });
5961
const configStates = {
6062
enabled: true,
6163
type: 'date_histogram',
@@ -70,7 +72,7 @@ describe('AggConfig', () => {
7072
});
7173

7274
it('uses the params from #write() output as the agg params', () => {
73-
const ac = new AggConfigs(indexPattern, [], { typesRegistry });
75+
const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats });
7476
const configStates = {
7577
enabled: true,
7678
type: 'date_histogram',
@@ -100,7 +102,7 @@ describe('AggConfig', () => {
100102
params: {},
101103
},
102104
];
103-
const ac = new AggConfigs(indexPattern, configStates, { typesRegistry });
105+
const ac = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats });
104106

105107
const histoConfig = ac.byName('date_histogram')[0];
106108
const avgConfig = ac.byName('avg')[0];
@@ -210,8 +212,8 @@ describe('AggConfig', () => {
210212

211213
testsIdentical.forEach((configState, index) => {
212214
it(`identical aggregations (${index})`, () => {
213-
const ac1 = new AggConfigs(indexPattern, configState, { typesRegistry });
214-
const ac2 = new AggConfigs(indexPattern, configState, { typesRegistry });
215+
const ac1 = new AggConfigs(indexPattern, configState, { typesRegistry, fieldFormats });
216+
const ac2 = new AggConfigs(indexPattern, configState, { typesRegistry, fieldFormats });
215217
expect(ac1.jsonDataEquals(ac2.aggs)).toBe(true);
216218
});
217219
});
@@ -251,8 +253,8 @@ describe('AggConfig', () => {
251253

252254
testsIdenticalDifferentOrder.forEach((test, index) => {
253255
it(`identical aggregations (${index}) - init json is in different order`, () => {
254-
const ac1 = new AggConfigs(indexPattern, test.config1, { typesRegistry });
255-
const ac2 = new AggConfigs(indexPattern, test.config2, { typesRegistry });
256+
const ac1 = new AggConfigs(indexPattern, test.config1, { typesRegistry, fieldFormats });
257+
const ac2 = new AggConfigs(indexPattern, test.config2, { typesRegistry, fieldFormats });
256258
expect(ac1.jsonDataEquals(ac2.aggs)).toBe(true);
257259
});
258260
});
@@ -316,16 +318,16 @@ describe('AggConfig', () => {
316318

317319
testsDifferent.forEach((test, index) => {
318320
it(`different aggregations (${index})`, () => {
319-
const ac1 = new AggConfigs(indexPattern, test.config1, { typesRegistry });
320-
const ac2 = new AggConfigs(indexPattern, test.config2, { typesRegistry });
321+
const ac1 = new AggConfigs(indexPattern, test.config1, { typesRegistry, fieldFormats });
322+
const ac2 = new AggConfigs(indexPattern, test.config2, { typesRegistry, fieldFormats });
321323
expect(ac1.jsonDataEquals(ac2.aggs)).toBe(false);
322324
});
323325
});
324326
});
325327

326328
describe('#toJSON', () => {
327329
it('includes the aggs id, params, type and schema', () => {
328-
const ac = new AggConfigs(indexPattern, [], { typesRegistry });
330+
const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats });
329331
const configStates = {
330332
enabled: true,
331333
type: 'date_histogram',
@@ -356,8 +358,8 @@ describe('AggConfig', () => {
356358
params: {},
357359
},
358360
];
359-
const ac1 = new AggConfigs(indexPattern, configStates, { typesRegistry });
360-
const ac2 = new AggConfigs(indexPattern, configStates, { typesRegistry });
361+
const ac1 = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats });
362+
const ac2 = new AggConfigs(indexPattern, configStates, { typesRegistry, fieldFormats });
361363

362364
// this relies on the assumption that js-engines consistently loop over properties in insertion order.
363365
// most likely the case, but strictly speaking not guaranteed by the JS and JSON specifications.
@@ -369,7 +371,7 @@ describe('AggConfig', () => {
369371
let aggConfig: AggConfig;
370372

371373
beforeEach(() => {
372-
const ac = new AggConfigs(indexPattern, [], { typesRegistry });
374+
const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats });
373375
aggConfig = ac.createAggConfig({ type: 'count' } as CreateAggConfigParams);
374376
});
375377

@@ -398,7 +400,7 @@ describe('AggConfig', () => {
398400

399401
describe('#fieldFormatter - custom getFormat handler', () => {
400402
it('returns formatter from getFormat handler', () => {
401-
const ac = new AggConfigs(indexPattern, [], { typesRegistry });
403+
const ac = new AggConfigs(indexPattern, [], { typesRegistry, fieldFormats });
402404
const configStates = {
403405
enabled: true,
404406
type: 'count',
@@ -439,7 +441,7 @@ describe('AggConfig', () => {
439441
},
440442
},
441443
};
442-
const ac = new AggConfigs(indexPattern, [configStates], { typesRegistry });
444+
const ac = new AggConfigs(indexPattern, [configStates], { typesRegistry, fieldFormats });
443445
aggConfig = ac.createAggConfig(configStates);
444446
});
445447

src/plugins/data/public/search/aggs/agg_config.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { IAggConfigs } from './agg_configs';
2525
import { FetchOptions } from '../fetch';
2626
import { ISearchSource } from '../search_source';
2727
import { FieldFormatsContentType, KBN_FIELD_TYPES } from '../../../common';
28-
import { getFieldFormats } from '../../../public/services';
28+
import { FieldFormatsStart } from '../../field_formats';
2929

3030
export interface AggConfigOptions {
3131
type: IAggType;
@@ -35,6 +35,10 @@ export interface AggConfigOptions {
3535
schema?: string;
3636
}
3737

38+
export interface AggConfigDependencies {
39+
fieldFormats: FieldFormatsStart;
40+
}
41+
3842
/**
3943
* @name AggConfig
4044
*
@@ -93,8 +97,13 @@ export class AggConfig {
9397
private __type: IAggType;
9498
private __typeDecorations: any;
9599
private subAggs: AggConfig[] = [];
100+
private readonly fieldFormats: FieldFormatsStart;
96101

97-
constructor(aggConfigs: IAggConfigs, opts: AggConfigOptions) {
102+
constructor(
103+
aggConfigs: IAggConfigs,
104+
opts: AggConfigOptions,
105+
{ fieldFormats }: AggConfigDependencies
106+
) {
98107
this.aggConfigs = aggConfigs;
99108
this.id = String(opts.id || AggConfig.nextId(aggConfigs.aggs as any));
100109
this.enabled = typeof opts.enabled === 'boolean' ? opts.enabled : true;
@@ -115,6 +124,8 @@ export class AggConfig {
115124

116125
// @ts-ignore
117126
this.__type = this.__type;
127+
128+
this.fieldFormats = fieldFormats;
118129
}
119130

120131
/**
@@ -341,12 +352,10 @@ export class AggConfig {
341352
}
342353

343354
fieldOwnFormatter(contentType?: FieldFormatsContentType, defaultFormat?: any) {
344-
const fieldFormatsService = getFieldFormats();
345-
346355
const field = this.getField();
347356
let format = field && field.format;
348357
if (!format) format = defaultFormat;
349-
if (!format) format = fieldFormatsService.getDefaultInstance(KBN_FIELD_TYPES.STRING);
358+
if (!format) format = this.fieldFormats.getDefaultInstance(KBN_FIELD_TYPES.STRING);
350359
return format.getConverterFor(contentType);
351360
}
352361

0 commit comments

Comments
 (0)