Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into enable-yarn-prefe…
Browse files Browse the repository at this point in the history
…r-offline
  • Loading branch information
mistic committed Nov 23, 2020
2 parents 528eee9 + 3d5d99e commit df7bc2a
Show file tree
Hide file tree
Showing 117 changed files with 6,433 additions and 1,041 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
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
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
2 changes: 1 addition & 1 deletion docs/settings/alert-action-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Alerts and actions are enabled by default in {kib}, but require you configure th

. <<using-kibana-with-security,Set up {kib} to work with {stack} {security-features}>>.
. <<configuring-tls-kib-es,Set up TLS encryption between {kib} and {es}>>.
. <<general-alert-action-settings,Specify a value for `xpack.encryptedSavedObjects.encryptionKey`>>.
. If you are using an *on-premises* Elastic Stack deployment, <<general-alert-action-settings,specify a value for `xpack.encryptedSavedObjects.encryptionKey`>>.

You can configure the following settings in the `kibana.yml` file.

Expand Down
1 change: 0 additions & 1 deletion packages/kbn-config/src/__mocks__/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function getEnvOptions(options: DeepPartial<EnvOptions> = {}): EnvOptions
configs: options.configs || [],
cliArgs: {
dev: true,
open: false,
quiet: false,
silent: false,
watch: false,
Expand Down
6 changes: 0 additions & 6 deletions packages/kbn-config/src/__snapshots__/env.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/kbn-config/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export interface CliArgs {
watch: boolean;
repl: boolean;
basePath: boolean;
open: boolean;
oss: boolean;
/** @deprecated use disableOptimizer to know if the @kbn/optimizer is disabled in development */
optimize?: boolean;
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-legacy-logging/yarn.lock

This file was deleted.

1 change: 0 additions & 1 deletion src/cli/cluster/cluster_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { Worker } from './worker';

const CLI_ARGS: SomeCliArgs = {
disableOptimizer: true,
open: false,
oss: false,
quiet: false,
repl: false,
Expand Down
24 changes: 1 addition & 23 deletions src/cli/cluster/cluster_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
*/

import { resolve } from 'path';
import { format as formatUrl } from 'url';
import Fs from 'fs';

import opn from 'opn';
import { REPO_ROOT } from '@kbn/utils';
import { FSWatcher } from 'chokidar';
import * as Rx from 'rxjs';
Expand All @@ -43,7 +41,6 @@ export type SomeCliArgs = Pick<
| 'silent'
| 'repl'
| 'disableOptimizer'
| 'open'
| 'watch'
| 'oss'
| 'runExamples'
Expand All @@ -52,7 +49,7 @@ export type SomeCliArgs = Pick<
>;

const firstAllTrue = (...sources: Array<Rx.Observable<boolean>>) =>
Rx.combineLatest(...sources).pipe(
Rx.combineLatest(sources).pipe(
filter((values) => values.every((v) => v === true)),
take(1),
mapTo(undefined)
Expand Down Expand Up @@ -146,17 +143,6 @@ export class ClusterManager {
});
});

if (opts.open) {
this.setupOpen(
formatUrl({
protocol: config.get('server.ssl.enabled') ? 'https' : 'http',
hostname: config.get('server.host'),
port: config.get('server.port'),
pathname: this.basePathProxy ? this.basePathProxy.basePath : '',
})
);
}

if (opts.watch) {
const pluginPaths = config.get<string[]>('plugins.paths');
const scanDirs = [
Expand Down Expand Up @@ -208,14 +194,6 @@ export class ClusterManager {
}
}

setupOpen(openUrl: string) {
firstAllTrue(this.serverReady$, this.kbnOptimizerReady$)
.toPromise()
.then(() => {
opn(openUrl);
});
}

setupWatching(extraPaths: string[], pluginInternalDirsIgnore: string[]) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const chokidar = require('chokidar');
Expand Down
2 changes: 0 additions & 2 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export default function (program) {
if (CAN_CLUSTER) {
command
.option('--dev', 'Run the server with development mode defaults')
.option('--open', 'Open a browser window to the base url after the server is started')
.option('--ssl', 'Run the dev server using HTTPS')
.option('--dist', 'Use production assets from kbn/optimizer')
.option(
Expand Down Expand Up @@ -222,7 +221,6 @@ export default function (program) {
configs: [].concat(opts.config || []),
cliArgs: {
dev: !!opts.dev,
open: !!opts.open,
envName: unknownOptions.env ? unknownOptions.env.name : undefined,
quiet: !!opts.quiet,
silent: !!opts.silent,
Expand Down
1 change: 0 additions & 1 deletion src/core/test_helpers/kbn_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export function createRootWithSettings(
configs: [],
cliArgs: {
dev: false,
open: false,
quiet: false,
silent: false,
watch: false,
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
Loading

0 comments on commit df7bc2a

Please sign in to comment.