Skip to content

Commit

Permalink
Merge branch 'master' into lens/fix-functional
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Dec 7, 2020
2 parents e43f857 + 34be1e7 commit 7882bb6
Show file tree
Hide file tree
Showing 388 changed files with 11,919 additions and 11,041 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ indexPatterns: {
isFilterable: typeof isFilterable;
isNestedField: typeof isNestedField;
validate: typeof validateIndexPattern;
getFromSavedObject: typeof getFromSavedObject;
flattenHitWrapper: typeof flattenHitWrapper;
formatHitProvider: typeof formatHitProvider;
}
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"number": 8467,
"sha": "6cb7fec4e154faa0a4a3fee4b33dfef91b9870d9"
},
"config": {
"puppeteer_skip_chromium_download": true
},
"homepage": "https://www.elastic.co/products/kibana",
"bugs": {
"url": "http://github.com/elastic/kibana/issues"
Expand Down Expand Up @@ -266,8 +269,7 @@
"proper-lockfile": "^3.2.0",
"proxy-from-env": "1.0.0",
"puid": "1.0.7",
"puppeteer": "^2.1.1",
"puppeteer-core": "^1.19.0",
"puppeteer": "^5.5.0",
"query-string": "^6.13.2",
"raw-loader": "^3.1.0",
"re2": "^1.15.4",
Expand Down Expand Up @@ -515,7 +517,7 @@
"@types/pretty-ms": "^5.0.0",
"@types/prop-types": "^15.7.3",
"@types/proper-lockfile": "^3.0.1",
"@types/puppeteer": "^1.20.1",
"@types/puppeteer": "^5.4.1",
"@types/rbush": "^3.0.0",
"@types/reach__router": "^1.2.6",
"@types/react": "^16.9.36",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ describe('IndexPatterns', () => {
expect(indexPatterns.refreshFields).toBeCalled();
});

test('find', async () => {
const search = 'kibana*';
const size = 10;
await indexPatterns.find('kibana*', size);

expect(savedObjectsClient.find).lastCalledWith({
type: 'index-pattern',
fields: ['title'],
search,
searchFields: ['title'],
perPage: size,
});
});

test('createAndSave', async () => {
const title = 'kibana-*';
indexPatterns.createSavedObject = jest.fn();
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/plugins/data/common/index_patterns/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

export { IndexPatternMissingIndices } from './errors';
export { getTitle } from './get_title';
export { getFromSavedObject } from './get_from_saved_object';
export { isDefault } from './is_default';

export * from './types';
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ import {
ILLEGAL_CHARACTERS,
isDefault,
validateIndexPattern,
getFromSavedObject,
flattenHitWrapper,
formatHitProvider,
} from './index_patterns';
Expand All @@ -252,7 +251,6 @@ export const indexPatterns = {
isFilterable,
isNestedField,
validate: validateIndexPattern,
getFromSavedObject,
flattenHitWrapper,
formatHitProvider,
};
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/index_patterns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export {
ILLEGAL_CHARACTERS_VISIBLE,
ILLEGAL_CHARACTERS,
validateIndexPattern,
getFromSavedObject,
isDefault,
} from '../../common/index_patterns/lib';
export { flattenHitWrapper, formatHitProvider, onRedirectNoIndexPattern } from './index_patterns';
Expand Down
43 changes: 20 additions & 23 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ import { Required } from '@kbn/utility-types';
import * as Rx from 'rxjs';
import { SavedObject } from 'kibana/server';
import { SavedObject as SavedObject_2 } from 'src/core/server';
import { SavedObject as SavedObject_3 } from 'src/core/public';
import { SavedObjectReference } from 'src/core/types';
import { SavedObjectsClientContract } from 'src/core/public';
import { SavedObjectsFindResponse } from 'kibana/server';
Expand Down Expand Up @@ -1336,7 +1335,6 @@ export const indexPatterns: {
isFilterable: typeof isFilterable;
isNestedField: typeof isNestedField;
validate: typeof validateIndexPattern;
getFromSavedObject: typeof getFromSavedObject;
flattenHitWrapper: typeof flattenHitWrapper;
formatHitProvider: typeof formatHitProvider;
};
Expand Down Expand Up @@ -2436,27 +2434,26 @@ export const UI_SETTINGS: {
// src/plugins/data/public/index.ts:178:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:178:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:220:23 - (ae-forgotten-export) The symbol "datatableToCSV" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:246:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:246:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:246:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:246:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:246:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:246:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:423:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:424:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:428:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:429:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:432:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:433:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:436:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:245:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:245:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:245:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:245:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:245:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:407:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:407:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:407:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:407:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:419:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:420:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:426:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:427:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:430:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:431:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:434:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:45:5 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/search/session/session_service.ts:46:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,26 @@
* under the License.
*/
import { isEmpty } from 'lodash';
import { IUiSettingsClient, SavedObjectsClientContract } from 'src/core/public';
import { indexPatterns, IndexPatternAttributes } from '../..';
import { IndexPatternsContract } from '../..';

export async function fetchIndexPatterns(
savedObjectsClient: SavedObjectsClientContract,
indexPatternStrings: string[],
uiSettings: IUiSettingsClient
indexPatternsService: IndexPatternsContract,
indexPatternStrings: string[]
) {
if (!indexPatternStrings || isEmpty(indexPatternStrings)) {
return [];
}

const searchString = indexPatternStrings.map((string) => `"${string}"`).join(' | ');
const indexPatternsFromSavedObjects = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title', 'fields'],
search: searchString,
searchFields: ['title'],
});

const exactMatches = indexPatternsFromSavedObjects.savedObjects.filter((savedObject) => {
return indexPatternStrings.includes(savedObject.attributes.title);
});

const defaultIndex = uiSettings.get('defaultIndex');
const exactMatches = (await indexPatternsService.find(searchString)).filter((ip) =>
indexPatternStrings.includes(ip.title)
);

const allMatches =
exactMatches.length === indexPatternStrings.length
? exactMatches
: [
...exactMatches,
await savedObjectsClient.get<IndexPatternAttributes>('index-pattern', defaultIndex),
];
: [...exactMatches, await indexPatternsService.getDefault()];

return allMatches.map(indexPatterns.getFromSavedObject);
return allMatches;
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,16 @@ describe('QueryStringInput', () => {
});

it('Should accept index pattern strings and fetch the full object', () => {
const patternStrings = ['logstash-*'];
mockFetchIndexPatterns.mockClear();
mount(
wrapQueryStringInputInContext({
query: kqlQuery,
onSubmit: noop,
indexPatterns: ['logstash-*'],
indexPatterns: patternStrings,
disableAutoFocus: true,
})
);

expect(mockFetchIndexPatterns).toHaveBeenCalledWith(
startMock.savedObjects.client,
['logstash-*'],
startMock.uiSettings
);
expect(mockFetchIndexPatterns.mock.calls[0][1]).toStrictEqual(patternStrings);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ export default class QueryStringInputUI extends Component<Props, State> {
const currentAbortController = this.fetchIndexPatternsAbortController;

const objectPatternsFromStrings = (await fetchIndexPatterns(
this.services.savedObjects!.client,
stringPatterns,
this.services.uiSettings!
this.services.data.indexPatterns,
stringPatterns
)) as IIndexPattern[];

if (!currentAbortController.signal.aborted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,6 @@ describe('DocViewTable at Discover', () => {
});
}
});

(['noMappingWarning'] as const).forEach((element) => {
const elementExist = check[element];

if (typeof elementExist === 'boolean') {
const el = findTestSubject(rowComponent, element);

it(`renders ${element} for '${check._property}' correctly`, () => {
expect(el.length).toBe(elementExist ? 1 : 0);
});
}
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React, { useState } from 'react';
import { escapeRegExp } from 'lodash';
import { DocViewTableRow } from './table_row';
import { arrayContainsObjects, trimAngularSpan } from './table_helper';
import { trimAngularSpan } from './table_helper';
import { DocViewRenderProps } from '../../doc_views/doc_views_types';

const COLLAPSE_LINE_LENGTH = 350;
Expand Down Expand Up @@ -72,11 +72,7 @@ export function DocViewTable({
}
}
: undefined;
const isArrayOfObjects =
Array.isArray(flattened[field]) && arrayContainsObjects(flattened[field]);
const displayUnderscoreWarning = !mapping(field) && field.indexOf('_') === 0;
const displayNoMappingWarning =
!mapping(field) && !displayUnderscoreWarning && !isArrayOfObjects;

// Discover doesn't flatten arrays of objects, so for documents with an `object` or `nested` field that
// contains an array, Discover will only detect the top level root field. We want to detect when those
Expand Down Expand Up @@ -128,7 +124,6 @@ export function DocViewTable({
fieldMapping={mapping(field)}
fieldType={String(fieldType)}
displayUnderscoreWarning={displayUnderscoreWarning}
displayNoMappingWarning={displayNoMappingWarning}
isCollapsed={isCollapsed}
isCollapsible={isCollapsible}
isColumnActive={Array.isArray(columns) && columns.includes(field)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import { DocViewTableRowBtnFilterRemove } from './table_row_btn_filter_remove';
import { DocViewTableRowBtnToggleColumn } from './table_row_btn_toggle_column';
import { DocViewTableRowBtnCollapse } from './table_row_btn_collapse';
import { DocViewTableRowBtnFilterExists } from './table_row_btn_filter_exists';
import { DocViewTableRowIconNoMapping } from './table_row_icon_no_mapping';
import { DocViewTableRowIconUnderscore } from './table_row_icon_underscore';
import { FieldName } from '../field_name/field_name';

export interface Props {
field: string;
fieldMapping?: FieldMapping;
fieldType: string;
displayNoMappingWarning: boolean;
displayUnderscoreWarning: boolean;
isCollapsible: boolean;
isColumnActive: boolean;
Expand All @@ -48,7 +46,6 @@ export function DocViewTableRow({
field,
fieldMapping,
fieldType,
displayNoMappingWarning,
displayUnderscoreWarning,
isCollapsible,
isCollapsed,
Expand Down Expand Up @@ -80,7 +77,6 @@ export function DocViewTableRow({
<DocViewTableRowBtnCollapse onClick={onToggleCollapse} isCollapsed={isCollapsed} />
)}
{displayUnderscoreWarning && <DocViewTableRowIconUnderscore />}
{displayNoMappingWarning && <DocViewTableRowIconNoMapping />}
<div
className={valueClassName}
data-test-subj={`tableDocViewRow-${field}-value`}
Expand Down
Loading

0 comments on commit 7882bb6

Please sign in to comment.