Skip to content

Commit

Permalink
Merge branch 'master' into 54012
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp authored Nov 23, 2020
2 parents d0c9625 + 0fd9efd commit 5223c4a
Show file tree
Hide file tree
Showing 184 changed files with 8,046 additions and 1,843 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
/x-pack/test/functional_basic/apps/transform/ @elastic/ml-ui

# Maps
/x-pack/plugins/maps/ @elastic/kibana-gis
#CC# /x-pack/plugins/maps/ @elastic/kibana-gis
/x-pack/test/api_integration/apis/maps/ @elastic/kibana-gis
/x-pack/test/functional/apps/maps/ @elastic/kibana-gis
/x-pack/test/functional/es_archives/maps/ @elastic/kibana-gis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

```typescript
getFieldAttrs: () => {
[x: string]: {
customLabel: string;
};
[x: string]: FieldAttrSet;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export declare class IndexPattern implements IIndexPattern
| [flattenHit](./kibana-plugin-plugins-data-public.indexpattern.flattenhit.md) | | <code>(hit: Record&lt;string, any&gt;, deep?: boolean) =&gt; Record&lt;string, any&gt;</code> | |
| [formatField](./kibana-plugin-plugins-data-public.indexpattern.formatfield.md) | | <code>FormatFieldFn</code> | |
| [formatHit](./kibana-plugin-plugins-data-public.indexpattern.formathit.md) | | <code>{</code><br/><code> (hit: Record&lt;string, any&gt;, type?: string): any;</code><br/><code> formatField: FormatFieldFn;</code><br/><code> }</code> | |
| [getFieldAttrs](./kibana-plugin-plugins-data-public.indexpattern.getfieldattrs.md) | | <code>() =&gt; {</code><br/><code> [x: string]: {</code><br/><code> customLabel: string;</code><br/><code> };</code><br/><code> }</code> | |
| [getFieldAttrs](./kibana-plugin-plugins-data-public.indexpattern.getfieldattrs.md) | | <code>() =&gt; {</code><br/><code> [x: string]: FieldAttrSet;</code><br/><code> }</code> | |
| [getOriginalSavedObjectBody](./kibana-plugin-plugins-data-public.indexpattern.getoriginalsavedobjectbody.md) | | <code>() =&gt; {</code><br/><code> fieldAttrs?: string &#124; undefined;</code><br/><code> title?: string &#124; undefined;</code><br/><code> timeFieldName?: string &#124; undefined;</code><br/><code> intervalName?: string &#124; undefined;</code><br/><code> fields?: string &#124; undefined;</code><br/><code> sourceFilters?: string &#124; undefined;</code><br/><code> fieldFormatMap?: string &#124; undefined;</code><br/><code> typeMeta?: string &#124; undefined;</code><br/><code> type?: string &#124; undefined;</code><br/><code> }</code> | Get last saved saved object fields |
| [id](./kibana-plugin-plugins-data-public.indexpattern.id.md) | | <code>string</code> | |
| [intervalName](./kibana-plugin-plugins-data-public.indexpattern.intervalname.md) | | <code>string &#124; undefined</code> | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [QueryStringInputProps](./kibana-plugin-plugins-data-public.querystringinputprops.md) &gt; [disableLanguageSwitcher](./kibana-plugin-plugins-data-public.querystringinputprops.disablelanguageswitcher.md)

## QueryStringInputProps.disableLanguageSwitcher property

<b>Signature:</b>

```typescript
disableLanguageSwitcher?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [QueryStringInputProps](./kibana-plugin-plugins-data-public.querystringinputprops.md) &gt; [iconType](./kibana-plugin-plugins-data-public.querystringinputprops.icontype.md)

## QueryStringInputProps.iconType property

<b>Signature:</b>

```typescript
iconType?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface QueryStringInputProps
| [className](./kibana-plugin-plugins-data-public.querystringinputprops.classname.md) | <code>string</code> | |
| [dataTestSubj](./kibana-plugin-plugins-data-public.querystringinputprops.datatestsubj.md) | <code>string</code> | |
| [disableAutoFocus](./kibana-plugin-plugins-data-public.querystringinputprops.disableautofocus.md) | <code>boolean</code> | |
| [disableLanguageSwitcher](./kibana-plugin-plugins-data-public.querystringinputprops.disablelanguageswitcher.md) | <code>boolean</code> | |
| [iconType](./kibana-plugin-plugins-data-public.querystringinputprops.icontype.md) | <code>string</code> | |
| [indexPatterns](./kibana-plugin-plugins-data-public.querystringinputprops.indexpatterns.md) | <code>Array&lt;IIndexPattern &#124; string&gt;</code> | |
| [isInvalid](./kibana-plugin-plugins-data-public.querystringinputprops.isinvalid.md) | <code>boolean</code> | |
| [languageSwitcherPopoverAnchorPosition](./kibana-plugin-plugins-data-public.querystringinputprops.languageswitcherpopoveranchorposition.md) | <code>PopoverAnchorPosition</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

```typescript
getFieldAttrs: () => {
[x: string]: {
customLabel: string;
};
[x: string]: FieldAttrSet;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export declare class IndexPattern implements IIndexPattern
| [flattenHit](./kibana-plugin-plugins-data-server.indexpattern.flattenhit.md) | | <code>(hit: Record&lt;string, any&gt;, deep?: boolean) =&gt; Record&lt;string, any&gt;</code> | |
| [formatField](./kibana-plugin-plugins-data-server.indexpattern.formatfield.md) | | <code>FormatFieldFn</code> | |
| [formatHit](./kibana-plugin-plugins-data-server.indexpattern.formathit.md) | | <code>{</code><br/><code> (hit: Record&lt;string, any&gt;, type?: string): any;</code><br/><code> formatField: FormatFieldFn;</code><br/><code> }</code> | |
| [getFieldAttrs](./kibana-plugin-plugins-data-server.indexpattern.getfieldattrs.md) | | <code>() =&gt; {</code><br/><code> [x: string]: {</code><br/><code> customLabel: string;</code><br/><code> };</code><br/><code> }</code> | |
| [getFieldAttrs](./kibana-plugin-plugins-data-server.indexpattern.getfieldattrs.md) | | <code>() =&gt; {</code><br/><code> [x: string]: FieldAttrSet;</code><br/><code> }</code> | |
| [getOriginalSavedObjectBody](./kibana-plugin-plugins-data-server.indexpattern.getoriginalsavedobjectbody.md) | | <code>() =&gt; {</code><br/><code> fieldAttrs?: string &#124; undefined;</code><br/><code> title?: string &#124; undefined;</code><br/><code> timeFieldName?: string &#124; undefined;</code><br/><code> intervalName?: string &#124; undefined;</code><br/><code> fields?: string &#124; undefined;</code><br/><code> sourceFilters?: string &#124; undefined;</code><br/><code> fieldFormatMap?: string &#124; undefined;</code><br/><code> typeMeta?: string &#124; undefined;</code><br/><code> type?: string &#124; undefined;</code><br/><code> }</code> | Get last saved saved object fields |
| [id](./kibana-plugin-plugins-data-server.indexpattern.id.md) | | <code>string</code> | |
| [intervalName](./kibana-plugin-plugins-data-server.indexpattern.intervalname.md) | | <code>string &#124; undefined</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import _, { each, reject } from 'lodash';
import { FieldAttrs } from '../..';
import { FieldAttrs, FieldAttrSet } from '../..';
import { DuplicateField } from '../../../../kibana_utils/common';

import { ES_FIELD_TYPES, KBN_FIELD_TYPES, IIndexPattern, IFieldType } from '../../../common';
Expand Down Expand Up @@ -135,8 +135,19 @@ export class IndexPattern implements IIndexPattern {
const newFieldAttrs = { ...this.fieldAttrs };

this.fields.forEach((field) => {
const attrs: FieldAttrSet = {};
let hasAttr = false;
if (field.customLabel) {
newFieldAttrs[field.name] = { customLabel: field.customLabel };
attrs.customLabel = field.customLabel;
hasAttr = true;
}
if (field.count) {
attrs.count = field.count;
hasAttr = true;
}

if (hasAttr) {
newFieldAttrs[field.name] = attrs;
} else {
delete newFieldAttrs[field.name];
}
Expand Down Expand Up @@ -298,7 +309,9 @@ export class IndexPattern implements IIndexPattern {
timeFieldName: this.timeFieldName,
intervalName: this.intervalName,
sourceFilters: this.sourceFilters ? JSON.stringify(this.sourceFilters) : undefined,
fields: this.fields ? JSON.stringify(this.fields) : undefined,
fields: this.fields
? JSON.stringify(this.fields.filter((field) => field.scripted))
: undefined,
fieldFormatMap,
type: this.type,
typeMeta: this.typeMeta ? JSON.stringify(this.typeMeta) : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,11 @@ describe('IndexPatterns', () => {

// Create a normal index patterns
const pattern = await indexPatterns.get('foo');

expect(pattern.version).toBe('fooa');
indexPatterns.clearCache();

// Create the same one - we're going to handle concurrency
const samePattern = await indexPatterns.get('foo');

expect(samePattern.version).toBe('fooaa');

// This will conflict because samePattern did a save (from refreshFields)
// but the resave should work fine
pattern.title = 'foo2';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,6 @@ export class IndexPatternsService {
}
};

private isFieldRefreshRequired(specs?: IndexPatternFieldMap): boolean {
if (!specs) {
return true;
}

return Object.values(specs).every((spec) => {
// See https://github.com/elastic/kibana/pull/8421
const hasFieldCaps = 'aggregatable' in spec && 'searchable' in spec;

// See https://github.com/elastic/kibana/pull/11969
const hasDocValuesFlag = 'readFromDocValues' in spec;

return !hasFieldCaps || !hasDocValuesFlag;
});
}

/**
* Get field list by providing { pattern }
* @param options
Expand Down Expand Up @@ -299,8 +283,8 @@ export class IndexPatternsService {
values: { id, title },
}),
});
throw err;
}
return fields;
};

/**
Expand All @@ -309,7 +293,11 @@ export class IndexPatternsService {
*/
fieldArrayToMap = (fields: FieldSpec[], fieldAttrs?: FieldAttrs) =>
fields.reduce<IndexPatternFieldMap>((collector, field) => {
collector[field.name] = { ...field, customLabel: fieldAttrs?.[field.name]?.customLabel };
collector[field.name] = {
...field,
customLabel: fieldAttrs?.[field.name]?.customLabel,
count: fieldAttrs?.[field.name]?.count,
};
return collector;
}, {});

Expand Down Expand Up @@ -372,25 +360,20 @@ export class IndexPatternsService {
? JSON.parse(savedObject.attributes.fieldAttrs)
: {};

const isFieldRefreshRequired = this.isFieldRefreshRequired(spec.fields);
let isSaveRequired = isFieldRefreshRequired;
try {
spec.fields = isFieldRefreshRequired
? await this.refreshFieldSpecMap(
spec.fields || {},
id,
spec.title as string,
{
pattern: title as string,
metaFields: await this.config.get(UI_SETTINGS.META_FIELDS),
type,
rollupIndex: typeMeta?.params?.rollupIndex,
},
spec.fieldAttrs
)
: spec.fields;
spec.fields = await this.refreshFieldSpecMap(
spec.fields || {},
id,
spec.title as string,
{
pattern: title as string,
metaFields: await this.config.get(UI_SETTINGS.META_FIELDS),
type,
rollupIndex: typeMeta?.params?.rollup_index,
},
spec.fieldAttrs
);
} catch (err) {
isSaveRequired = false;
if (err instanceof IndexPatternMissingIndices) {
this.onNotification({
title: (err as any).message,
Expand All @@ -412,23 +395,6 @@ export class IndexPatternsService {
: {};

const indexPattern = await this.create(spec, true);
if (isSaveRequired) {
try {
this.updateSavedObject(indexPattern);
} catch (err) {
this.onError(err, {
title: i18n.translate('data.indexPatterns.fetchFieldSaveErrorTitle', {
defaultMessage:
'Error saving after fetching fields for index pattern {title} (ID: {id})',
values: {
id: indexPattern.id,
title: indexPattern.title,
},
}),
});
}
}

indexPattern.resetOriginalSavedObjectBody();
return indexPattern;
};
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/data/common/index_patterns/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ export interface IndexPatternAttributes {
}

export interface FieldAttrs {
[key: string]: { customLabel: string };
[key: string]: FieldAttrSet;
}

export interface FieldAttrSet {
customLabel?: string;
count?: number;
}

export type OnNotification = (toastInputFields: ToastInputFields) => void;
Expand Down
9 changes: 6 additions & 3 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1151,9 +1151,7 @@ export class IndexPattern implements IIndexPattern {
};
// (undocumented)
getFieldAttrs: () => {
[x: string]: {
customLabel: string;
};
[x: string]: FieldAttrSet;
};
// (undocumented)
getFieldByName(name: string): IndexPatternField | undefined;
Expand Down Expand Up @@ -1798,6 +1796,10 @@ export interface QueryStringInputProps {
// (undocumented)
disableAutoFocus?: boolean;
// (undocumented)
disableLanguageSwitcher?: boolean;
// (undocumented)
iconType?: string;
// (undocumented)
indexPatterns: Array<IIndexPattern | string>;
// (undocumented)
isInvalid?: boolean;
Expand Down Expand Up @@ -2362,6 +2364,7 @@ export const UI_SETTINGS: {
// src/plugins/data/common/es_query/filters/phrase_filter.ts:33:3 - (ae-forgotten-export) The symbol "PhraseFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/phrases_filter.ts:31:3 - (ae-forgotten-export) The symbol "PhrasesFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:64:5 - (ae-forgotten-export) The symbol "FormatFieldFn" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:135:7 - (ae-forgotten-export) The symbol "FieldAttrSet" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/search/aggs/types.ts:113:51 - (ae-forgotten-export) The symbol "AggTypesRegistryStart" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/field_formats/field_formats_service.ts:67:3 - (ae-forgotten-export) The symbol "FormatFactory" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:66:23 - (ae-forgotten-export) The symbol "FILTERS" needs to be exported by the entry point index.d.ts
Expand Down
18 changes: 15 additions & 3 deletions src/plugins/data/public/ui/query_string_input/_query_bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
z-index: $euiZContentMenu;
resize: none !important; // When in the group, it will autosize
height: $euiFormControlHeight;
// Unlike most inputs within layout control groups, the text area still needs a border.
// These adjusts help it sit above the control groups shadow to line up correctly.
// Unlike most inputs within layout control groups, the text area still needs a border
// for multi-line content. These adjusts help it sit above the control groups
// shadow to line up correctly.
padding: $euiSizeS;
padding-top: $euiSizeS + 3px;
transform: translateY(-1px) translateX(-1px);
box-shadow: 0 0 0 1px $euiFormBorderColor;

&:not(:focus):not(:invalid) {
@include euiYScrollWithShadows;
Expand All @@ -40,6 +41,17 @@
overflow-x: auto;
overflow-y: auto;
white-space: normal;
box-shadow: 0 0 0 1px $euiFormBorderColor;
}

@include euiFormControlWithIcon($isIconOptional: true);
~ .euiFormControlLayoutIcons {
// By default form control layout icon is vertically centered, but our textarea
// can expand to be multi-line, so we position it with padding that matches
// the parent textarea padding
z-index: $euiZContentMenu + 1;
top: $euiSizeS + 3px;
bottom: unset;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { mount } from 'enzyme';
import { waitFor } from '@testing-library/dom';
import { render } from '@testing-library/react';

import { EuiTextArea } from '@elastic/eui';
import { EuiTextArea, EuiIcon } from '@elastic/eui';

import { QueryLanguageSwitcher } from './language_switcher';
import { QueryStringInput } from './';
Expand Down Expand Up @@ -172,6 +172,30 @@ describe('QueryStringInput', () => {
expect(mockCallback).toHaveBeenCalledWith({ query: '', language: 'lucene' });
});

it('Should not show the language switcher when disabled', () => {
const component = mount(
wrapQueryStringInputInContext({
query: luceneQuery,
onSubmit: noop,
indexPatterns: [stubIndexPatternWithFields],
disableLanguageSwitcher: true,
})
);
expect(component.find(QueryLanguageSwitcher).exists()).toBeFalsy();
});

it('Should show an icon when an iconType is specified', () => {
const component = mount(
wrapQueryStringInputInContext({
query: luceneQuery,
onSubmit: noop,
indexPatterns: [stubIndexPatternWithFields],
iconType: 'search',
})
);
expect(component.find(EuiIcon).exists()).toBeTruthy();
});

it('Should call onSubmit when the user hits enter inside the query bar', () => {
const mockCallback = jest.fn();

Expand Down
Loading

0 comments on commit 5223c4a

Please sign in to comment.