Skip to content

Commit

Permalink
Merge branch 'master' into apm-rum
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Dec 17, 2019
2 parents 55b49d6 + 2b6ef5c commit 2320cf8
Show file tree
Hide file tree
Showing 104 changed files with 1,261 additions and 516 deletions.
6 changes: 5 additions & 1 deletion docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,16 @@ Rollup user interface.

`i18n.locale`:: *Default: en* Set this value to change the Kibana interface language. Valid locales are: `en`, `zh-CN`, `ja-JP`.

`xpack.actions.enabledActionTypes:`:: *Default: +[ {asterisk} ]+* Set this value
to an array of action types that are enabled. An element of `*` indicates all
action types registered are enabled. The action types provided by Kibana are:
`.server-log`, `.slack`, `.email`, `.index`, `.pagerduty`, `.webhook`.

`xpack.actions.whitelistedHosts:`:: *Default: +[ {asterisk} ]+* Set this value
to an array of host names which actions such as email, slack, pagerduty, and
webhook can connect to. An element of `*` indicates any host can be connected
to. An empty array indicates no hosts can be connected to.


include::{docdir}/settings/apm-settings.asciidoc[]
include::{docdir}/settings/dev-settings.asciidoc[]
include::{docdir}/settings/graph-settings.asciidoc[]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { SearchSourceContract } from 'ui/courier';
import { SavedObject, SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { createSavedObjectClass } from 'ui/saved_objects/saved_object';
import { extractReferences, injectReferences } from './saved_dashboard_references';
import { createDashboardEditUrl } from '../dashboard_constants';

import { esFilters, Query, RefreshInterval } from '../../../../../../plugins/data/public';

export interface SavedObjectDashboard extends SavedObject {
id?: string;
timeRestore: boolean;
timeTo?: string;
timeFrom?: string;
description?: string;
panelsJSON: string;
optionsJSON?: string;
// TODO: write a migration to rid of this, it's only around for bwc.
uiStateJSON?: string;
lastSavedTitle: string;
refreshInterval?: RefreshInterval;
searchSource: SearchSourceContract;
getQuery(): Query;
getFilters(): esFilters.Filter[];
}

// Used only by the savedDashboards service, usually no reason to change this
export function createSavedDashboardClass(services: SavedObjectKibanaServices) {
const SavedObjectClass = createSavedObjectClass(services);
class SavedDashboard extends SavedObjectClass {
// save these objects with the 'dashboard' type
public static type = 'dashboard';

// if type:dashboard has no mapping, we push this mapping into ES
public static mapping = {
title: 'text',
hits: 'integer',
description: 'text',
panelsJSON: 'text',
optionsJSON: 'text',
version: 'integer',
timeRestore: 'boolean',
timeTo: 'keyword',
timeFrom: 'keyword',
refreshInterval: {
type: 'object',
properties: {
display: { type: 'keyword' },
pause: { type: 'boolean' },
section: { type: 'integer' },
value: { type: 'integer' },
},
},
};
public static fieldOrder = ['title', 'description'];
public static searchSource = true;
public showInRecentlyAccessed = true;

constructor(id: string) {
super({
type: SavedDashboard.type,
mapping: SavedDashboard.mapping,
searchSource: SavedDashboard.searchSource,
extractReferences,
injectReferences,

// if this is null/undefined then the SavedObject will be assigned the defaults
id,

// default values that will get assigned if the doc is new
defaults: {
title: '',
hits: 0,
description: '',
panelsJSON: '[]',
optionsJSON: JSON.stringify({
// for BWC reasons we can't default dashboards that already exist without this setting to true.
useMargins: !id,
hidePanelTitles: false,
}),
version: 1,
timeRestore: false,
timeTo: undefined,
timeFrom: undefined,
refreshInterval: undefined,
},
});
this.getFullPath = () => `/app/kibana#${createDashboardEditUrl(String(this.id))}`;
}

getQuery() {
return this.searchSource!.getOwnField('query') || { query: '', language: 'kuery' };
}

getFilters() {
return this.searchSource!.getOwnField('filter') || [];
}
}

return SavedDashboard;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { extractReferences, injectReferences } from './saved_dashboard_references';
import { SavedObjectDashboard } from './saved_dashboard';

describe('extractReferences', () => {
test('extracts references from panelsJSON', () => {
Expand All @@ -38,6 +39,7 @@ describe('extractReferences', () => {
},
]),
},
references: [],
};
const updatedDoc = extractReferences(doc);

Expand Down Expand Up @@ -75,6 +77,7 @@ Object {
},
]),
},
references: [],
};
expect(() => extractReferences(doc)).toThrowErrorMatchingInlineSnapshot(
`"\\"type\\" attribute is missing from panel \\"0\\""`
Expand All @@ -93,6 +96,7 @@ Object {
},
]),
},
references: [],
};
expect(extractReferences(doc)).toMatchInlineSnapshot(`
Object {
Expand All @@ -110,7 +114,7 @@ describe('injectReferences', () => {
test('injects references into context', () => {
const context = {
id: '1',
foo: true,
title: 'test',
panelsJSON: JSON.stringify([
{
panelRefName: 'panel_0',
Expand All @@ -121,7 +125,7 @@ describe('injectReferences', () => {
title: 'Title 2',
},
]),
};
} as SavedObjectDashboard;
const references = [
{
name: 'panel_0',
Expand All @@ -138,47 +142,47 @@ describe('injectReferences', () => {

expect(context).toMatchInlineSnapshot(`
Object {
"foo": true,
"id": "1",
"panelsJSON": "[{\\"title\\":\\"Title 1\\",\\"id\\":\\"1\\",\\"type\\":\\"visualization\\"},{\\"title\\":\\"Title 2\\",\\"id\\":\\"2\\",\\"type\\":\\"visualization\\"}]",
"title": "test",
}
`);
});

test('skips when panelsJSON is missing', () => {
const context = {
id: '1',
foo: true,
};
title: 'test',
} as SavedObjectDashboard;
injectReferences(context, []);
expect(context).toMatchInlineSnapshot(`
Object {
"foo": true,
"id": "1",
"title": "test",
}
`);
});

test('skips when panelsJSON is not an array', () => {
const context = {
id: '1',
foo: true,
panelsJSON: '{}',
};
title: 'test',
} as SavedObjectDashboard;
injectReferences(context, []);
expect(context).toMatchInlineSnapshot(`
Object {
"foo": true,
"id": "1",
"panelsJSON": "{}",
"title": "test",
}
`);
});

test('skips a panel when panelRefName is missing', () => {
const context = {
id: '1',
foo: true,
title: 'test',
panelsJSON: JSON.stringify([
{
panelRefName: 'panel_0',
Expand All @@ -188,7 +192,7 @@ Object {
title: 'Title 2',
},
]),
};
} as SavedObjectDashboard;
const references = [
{
name: 'panel_0',
Expand All @@ -199,24 +203,24 @@ Object {
injectReferences(context, references);
expect(context).toMatchInlineSnapshot(`
Object {
"foo": true,
"id": "1",
"panelsJSON": "[{\\"title\\":\\"Title 1\\",\\"id\\":\\"1\\",\\"type\\":\\"visualization\\"},{\\"title\\":\\"Title 2\\"}]",
"title": "test",
}
`);
});

test(`fails when it can't find the reference in the array`, () => {
const context = {
id: '1',
foo: true,
title: 'test',
panelsJSON: JSON.stringify([
{
panelRefName: 'panel_0',
title: 'Title 1',
},
]),
};
} as SavedObjectDashboard;
expect(() => injectReferences(context, [])).toThrowErrorMatchingInlineSnapshot(
`"Could not find reference \\"panel_0\\""`
);
Expand Down
Loading

0 comments on commit 2320cf8

Please sign in to comment.