Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into implement/rel…
Browse files Browse the repository at this point in the history
…ease-notes-script
  • Loading branch information
spalger committed Jun 13, 2020
2 parents 05d42dc + 04b8a49 commit 634f6e2
Show file tree
Hide file tree
Showing 29 changed files with 47,907 additions and 70,699 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@ Constructs a new instance of the `IndexPattern` class
<b>Signature:</b>

```typescript
constructor(id: string | undefined, getConfig: any, savedObjectsClient: SavedObjectsClientContract, apiClient: IIndexPatternsApiClient, patternCache: PatternCache, fieldFormats: FieldFormatsStartCommon, onNotification: OnNotification, onError: OnError);
constructor(id: string | undefined, { getConfig, savedObjectsClient, apiClient, patternCache, fieldFormats, onNotification, onError, }: IndexPatternDeps);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | <code>string &#124; undefined</code> | |
| getConfig | <code>any</code> | |
| savedObjectsClient | <code>SavedObjectsClientContract</code> | |
| apiClient | <code>IIndexPatternsApiClient</code> | |
| patternCache | <code>PatternCache</code> | |
| fieldFormats | <code>FieldFormatsStartCommon</code> | |
| onNotification | <code>OnNotification</code> | |
| onError | <code>OnError</code> | |
| { getConfig, savedObjectsClient, apiClient, patternCache, fieldFormats, onNotification, onError, } | <code>IndexPatternDeps</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export declare class IndexPattern implements IIndexPattern
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(id, getConfig, savedObjectsClient, apiClient, patternCache, fieldFormats, onNotification, onError)](./kibana-plugin-plugins-data-public.indexpattern._constructor_.md) | | Constructs a new instance of the <code>IndexPattern</code> class |
| [(constructor)(id, { getConfig, savedObjectsClient, apiClient, patternCache, fieldFormats, onNotification, onError, })](./kibana-plugin-plugins-data-public.indexpattern._constructor_.md) | | Constructs a new instance of the <code>IndexPattern</code> class |
## Properties
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-dev-utils/tooling_log/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"main": "../target/tooling_log"
}
116,613 changes: 46,614 additions & 69,999 deletions packages/kbn-pm/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/kbn-pm/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import dedent from 'dedent';
import getopts from 'getopts';
import { resolve } from 'path';
import { pickLevelFromFlags } from '@kbn/dev-utils';
import { pickLevelFromFlags } from '@kbn/dev-utils/tooling_log';

import { commands } from './commands';
import { runCommand } from './run';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/commands/bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jest.mock('../utils/link_project_executables');

import { resolve } from 'path';

import { ToolingLogCollectingWriter } from '@kbn/dev-utils';
import { ToolingLogCollectingWriter } from '@kbn/dev-utils/tooling_log';

import { absolutePathSnapshotSerializer, stripAnsiSnapshotSerializer } from '../test_helpers';
import { linkProjectExecutables } from '../utils/link_project_executables';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/utils/link_project_executables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jest.mock('./fs');

import { resolve } from 'path';

import { ToolingLogCollectingWriter } from '@kbn/dev-utils';
import { ToolingLogCollectingWriter } from '@kbn/dev-utils/tooling_log';

import { absolutePathSnapshotSerializer, stripAnsiSnapshotSerializer } from '../test_helpers';
import { linkProjectExecutables } from './link_project_executables';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
LogLevel,
parseLogLevel,
ParsedLogLevel,
} from '@kbn/dev-utils';
} from '@kbn/dev-utils/tooling_log';

class Log extends ToolingLog {
private logLevel!: ParsedLogLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import mockLogStashFields from '../../../../../fixtures/logstash_fields';
import { stubbedSavedObjectIndexPattern } from '../../../../../fixtures/stubbed_saved_object_index_pattern';
import { Field } from '../fields';

import { FieldFormatsStartCommon } from '../../field_formats';
import { fieldFormatsMock } from '../../field_formats/mocks';

jest.mock('../../field_mapping', () => {
const originalModule = jest.requireActual('../../field_mapping');
Expand Down Expand Up @@ -97,16 +97,15 @@ const apiClient = {

// helper function to create index patterns
function create(id: string, payload?: any): Promise<IndexPattern> {
const indexPattern = new IndexPattern(
id,
(cfg: any) => config.get(cfg),
savedObjectsClient as any,
const indexPattern = new IndexPattern(id, {
getConfig: (cfg: any) => config.get(cfg),
savedObjectsClient: savedObjectsClient as any,
apiClient,
patternCache,
({ getDefaultInstance: () => {}, getType: () => {} } as unknown) as FieldFormatsStartCommon,
() => {},
() => {}
);
fieldFormats: fieldFormatsMock,
onNotification: () => {},
onError: () => {},
});

setDocsourcePayload(id, payload);

Expand Down Expand Up @@ -363,31 +362,29 @@ describe('IndexPattern', () => {
},
});
// Create a normal index pattern
const pattern = new IndexPattern(
'foo',
(cfg: any) => config.get(cfg),
savedObjectsClient as any,
const pattern = new IndexPattern('foo', {
getConfig: (cfg: any) => config.get(cfg),
savedObjectsClient: savedObjectsClient as any,
apiClient,
patternCache,
({ getDefaultInstance: () => {}, getType: () => {} } as unknown) as FieldFormatsStartCommon,
() => {},
() => {}
);
fieldFormats: fieldFormatsMock,
onNotification: () => {},
onError: () => {},
});
await pattern.init();

expect(get(pattern, 'version')).toBe('fooa');

// Create the same one - we're going to handle concurrency
const samePattern = new IndexPattern(
'foo',
(cfg: any) => config.get(cfg),
savedObjectsClient as any,
const samePattern = new IndexPattern('foo', {
getConfig: (cfg: any) => config.get(cfg),
savedObjectsClient: savedObjectsClient as any,
apiClient,
patternCache,
({ getDefaultInstance: () => {}, getType: () => {} } as unknown) as FieldFormatsStartCommon,
() => {},
() => {}
);
fieldFormats: fieldFormatsMock,
onNotification: () => {},
onError: () => {},
});
await samePattern.init();

expect(get(samePattern, 'version')).toBe('fooaa');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ import { expandShorthand, FieldMappingSpec, MappingObject } from '../../field_ma
const MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS = 3;
const type = 'index-pattern';

interface IndexPatternDeps {
getConfig: any;
savedObjectsClient: SavedObjectsClientContract;
apiClient: IIndexPatternsApiClient;
patternCache: PatternCache;
fieldFormats: FieldFormatsStartCommon;
onNotification: OnNotification;
onError: OnError;
}

export class IndexPattern implements IIndexPattern {
[key: string]: any;

Expand Down Expand Up @@ -97,13 +107,15 @@ export class IndexPattern implements IIndexPattern {

constructor(
id: string | undefined,
getConfig: any,
savedObjectsClient: SavedObjectsClientContract,
apiClient: IIndexPatternsApiClient,
patternCache: PatternCache,
fieldFormats: FieldFormatsStartCommon,
onNotification: OnNotification,
onError: OnError
{
getConfig,
savedObjectsClient,
apiClient,
patternCache,
fieldFormats,
onNotification,
onError,
}: IndexPatternDeps
) {
this.id = id;
this.savedObjectsClient = savedObjectsClient;
Expand Down Expand Up @@ -400,16 +412,15 @@ export class IndexPattern implements IIndexPattern {
async create(allowOverride: boolean = false) {
const _create = async (duplicateId?: string) => {
if (duplicateId) {
const duplicatePattern = new IndexPattern(
duplicateId,
this.getConfig,
this.savedObjectsClient,
this.apiClient,
this.patternCache,
this.fieldFormats,
this.onNotification,
this.onError
);
const duplicatePattern = new IndexPattern(duplicateId, {
getConfig: this.getConfig,
savedObjectsClient: this.savedObjectsClient,
apiClient: this.apiClient,
patternCache: this.patternCache,
fieldFormats: this.fieldFormats,
onNotification: this.onNotification,
onError: this.onError,
});

await duplicatePattern.destroy();
}
Expand Down Expand Up @@ -453,16 +464,15 @@ export class IndexPattern implements IIndexPattern {
_.get(err, 'res.status') === 409 &&
saveAttempts++ < MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS
) {
const samePattern = new IndexPattern(
this.id,
this.getConfig,
this.savedObjectsClient,
this.apiClient,
this.patternCache,
this.fieldFormats,
this.onNotification,
this.onError
);
const samePattern = new IndexPattern(this.id, {
getConfig: this.getConfig,
savedObjectsClient: this.savedObjectsClient,
apiClient: this.apiClient,
patternCache: this.patternCache,
fieldFormats: this.fieldFormats,
onNotification: this.onNotification,
onError: this.onError,
});
return samePattern.init().then(() => {
// What keys changed from now and what the server returned
const updatedBody = samePattern.prepBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ describe('IndexPatterns', () => {
}) as Promise<SavedObjectsFindResponsePublic<any>>
);

indexPatterns = new IndexPatternsService(
core.uiSettings,
indexPatterns = new IndexPatternsService({
uiSettings: core.uiSettings,
savedObjectsClient,
http,
fieldFormats,
() => {},
() => {},
() => {}
);
onNotification: () => {},
onError: () => {},
onRedirectNoIndexPattern: () => {},
});
});

test('does cache gets for the same id', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export interface IndexPatternSavedObjectAttrs {
title: string;
}

interface IndexPatternsServiceDeps {
uiSettings: CoreStart['uiSettings'];
savedObjectsClient: SavedObjectsClientContract;
http: HttpStart;
fieldFormats: FieldFormatsStartCommon;
onNotification: OnNotification;
onError: OnError;
onRedirectNoIndexPattern: () => void;
}

export class IndexPatternsService {
private config: IUiSettingsClient;
private savedObjectsClient: SavedObjectsClientContract;
Expand All @@ -65,15 +75,15 @@ export class IndexPatternsService {
shortDotsEnable: boolean
) => Field;

constructor(
uiSettings: CoreStart['uiSettings'],
savedObjectsClient: SavedObjectsClientContract,
http: HttpStart,
fieldFormats: FieldFormatsStartCommon,
onNotification: OnNotification,
onError: OnError,
onRedirectNoIndexPattern: () => void
) {
constructor({
uiSettings,
savedObjectsClient,
http,
fieldFormats,
onNotification,
onError,
onRedirectNoIndexPattern,
}: IndexPatternsServiceDeps) {
this.apiClient = new IndexPatternsApiClient(http);
this.config = uiSettings;
this.savedObjectsClient = savedObjectsClient;
Expand Down Expand Up @@ -186,16 +196,15 @@ export class IndexPatternsService {
};

make = (id?: string): Promise<IndexPattern> => {
const indexPattern = new IndexPattern(
id,
(cfg: any) => this.config.get(cfg),
this.savedObjectsClient,
this.apiClient,
indexPatternCache,
this.fieldFormats,
this.onNotification,
this.onError
);
const indexPattern = new IndexPattern(id, {
getConfig: (cfg: any) => this.config.get(cfg),
savedObjectsClient: this.savedObjectsClient,
apiClient: this.apiClient,
patternCache: indexPatternCache,
fieldFormats: this.fieldFormats,
onNotification: this.onNotification,
onError: this.onError,
});

return indexPattern.init();
};
Expand Down
16 changes: 10 additions & 6 deletions src/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,21 @@ export class DataPublicPlugin implements Plugin<DataPublicPluginSetup, DataPubli
const fieldFormats = this.fieldFormatsService.start();
setFieldFormats(fieldFormats);

const indexPatterns = new IndexPatternsService(
const indexPatterns = new IndexPatternsService({
uiSettings,
savedObjects.client,
savedObjectsClient: savedObjects.client,
http,
fieldFormats,
(toastInputFields) => {
onNotification: (toastInputFields) => {
notifications.toasts.add(toastInputFields);
},
notifications.toasts.addError,
onRedirectNoIndexPattern(application.capabilities, application.navigateToApp, overlays)
);
onError: notifications.toasts.addError,
onRedirectNoIndexPattern: onRedirectNoIndexPattern(
application.capabilities,
application.navigateToApp,
overlays
),
});
setIndexPatterns(indexPatterns);

const query = this.queryService.start(savedObjects);
Expand Down
8 changes: 2 additions & 6 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -978,12 +978,8 @@ export type IMetricAggType = MetricAggType;
//
// @public (undocumented)
export class IndexPattern implements IIndexPattern {
// Warning: (ae-forgotten-export) The symbol "IIndexPatternsApiClient" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "PatternCache" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "FieldFormatsStartCommon" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "OnNotification" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "OnError" needs to be exported by the entry point index.d.ts
constructor(id: string | undefined, getConfig: any, savedObjectsClient: SavedObjectsClientContract, apiClient: IIndexPatternsApiClient, patternCache: PatternCache, fieldFormats: FieldFormatsStartCommon, onNotification: OnNotification, onError: OnError);
// Warning: (ae-forgotten-export) The symbol "IndexPatternDeps" needs to be exported by the entry point index.d.ts
constructor(id: string | undefined, { getConfig, savedObjectsClient, apiClient, patternCache, fieldFormats, onNotification, onError, }: IndexPatternDeps);
// (undocumented)
[key: string]: any;
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const alertPageTestRender = () => {

const depsStart = depsStartMock();
depsStart.data.ui.SearchBar.mockImplementation(() => <div />);
const uiSettings = new Map();

return {
store,
Expand All @@ -47,7 +48,7 @@ export const alertPageTestRender = () => {
*/
return reactTestingLibrary.render(
<Provider store={store}>
<KibanaContextProvider services={{ data: depsStart.data }}>
<KibanaContextProvider services={{ data: depsStart.data, uiSettings }}>
<I18nProvider>
<Router history={history}>
<RouteCapture>
Expand Down
Loading

0 comments on commit 634f6e2

Please sign in to comment.