Skip to content

Commit

Permalink
Merge branch 'master' into dev/search/misc-integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine committed Jan 13, 2021
2 parents 8aa0a64 + 64275cd commit ced4520
Show file tree
Hide file tree
Showing 209 changed files with 1,470 additions and 625 deletions.
8 changes: 2 additions & 6 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ Content is fetched from the remote (https://feeds.elastic.co and https://feeds-s
|Create choropleth maps. Display the results of a term-aggregation as e.g. countries, zip-codes, states.
|{kib-repo}blob/{branch}/src/plugins/runtime_fields/README.mdx[runtimeFields]
|The runtime fields plugin provides types and constants for OSS and xpack runtime field related code.
|{kib-repo}blob/{branch}/src/plugins/saved_objects/README.md[savedObjects]
|The savedObjects plugin exposes utilities to manipulate saved objects on the client side.
Expand Down Expand Up @@ -491,8 +487,8 @@ Elastic.
|Welcome to the Kibana rollup plugin! This plugin provides Kibana support for Elasticsearch's rollup feature. Please refer to the Elasticsearch documentation to understand rollup indices and how to create rollup jobs.
|{kib-repo}blob/{branch}/x-pack/plugins/runtime_field_editor/README.md[runtimeFieldEditor]
|Welcome to the home of the runtime field editor!
|{kib-repo}blob/{branch}/x-pack/plugins/runtime_fields/README.md[runtimeFields]
|Welcome to the home of the runtime field editor and everything related to runtime fields!
|{kib-repo}blob/{branch}/x-pack/plugins/saved_objects_tagging/README.md[savedObjectsTagging]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [ExecutionContext](./kibana-plugin-plugins-expressions-public.executioncontext.md) &gt; [isSyncColorsEnabled](./kibana-plugin-plugins-expressions-public.executioncontext.issynccolorsenabled.md)

## ExecutionContext.isSyncColorsEnabled property

Returns the state (true\|false) of the sync colors across panels switch.

<b>Signature:</b>

```typescript
isSyncColorsEnabled?: () => boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ExecutionContext<InspectorAdapters extends Adapters = Adapters,
| [getSearchContext](./kibana-plugin-plugins-expressions-public.executioncontext.getsearchcontext.md) | <code>() =&gt; ExecutionContextSearch</code> | Get search context of the expression. |
| [getSearchSessionId](./kibana-plugin-plugins-expressions-public.executioncontext.getsearchsessionid.md) | <code>() =&gt; string &#124; undefined</code> | Search context in which expression should operate. |
| [inspectorAdapters](./kibana-plugin-plugins-expressions-public.executioncontext.inspectoradapters.md) | <code>InspectorAdapters</code> | Adapters for <code>inspector</code> plugin. |
| [isSyncColorsEnabled](./kibana-plugin-plugins-expressions-public.executioncontext.issynccolorsenabled.md) | <code>() =&gt; boolean</code> | Returns the state (true\|false) of the sync colors across panels switch. |
| [types](./kibana-plugin-plugins-expressions-public.executioncontext.types.md) | <code>Record&lt;string, ExpressionType&gt;</code> | A map of available expression types. |
| [variables](./kibana-plugin-plugins-expressions-public.executioncontext.variables.md) | <code>Record&lt;string, unknown&gt;</code> | Context variables that can be consumed using <code>var</code> and <code>var_set</code> functions. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) &gt; [ExecutionContext](./kibana-plugin-plugins-expressions-server.executioncontext.md) &gt; [isSyncColorsEnabled](./kibana-plugin-plugins-expressions-server.executioncontext.issynccolorsenabled.md)

## ExecutionContext.isSyncColorsEnabled property

Returns the state (true\|false) of the sync colors across panels switch.

<b>Signature:</b>

```typescript
isSyncColorsEnabled?: () => boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ExecutionContext<InspectorAdapters extends Adapters = Adapters,
| [getSearchContext](./kibana-plugin-plugins-expressions-server.executioncontext.getsearchcontext.md) | <code>() =&gt; ExecutionContextSearch</code> | Get search context of the expression. |
| [getSearchSessionId](./kibana-plugin-plugins-expressions-server.executioncontext.getsearchsessionid.md) | <code>() =&gt; string &#124; undefined</code> | Search context in which expression should operate. |
| [inspectorAdapters](./kibana-plugin-plugins-expressions-server.executioncontext.inspectoradapters.md) | <code>InspectorAdapters</code> | Adapters for <code>inspector</code> plugin. |
| [isSyncColorsEnabled](./kibana-plugin-plugins-expressions-server.executioncontext.issynccolorsenabled.md) | <code>() =&gt; boolean</code> | Returns the state (true\|false) of the sync colors across panels switch. |
| [types](./kibana-plugin-plugins-expressions-server.executioncontext.types.md) | <code>Record&lt;string, ExpressionType&gt;</code> | A map of available expression types. |
| [variables](./kibana-plugin-plugins-expressions-server.executioncontext.variables.md) | <code>Record&lt;string, unknown&gt;</code> | Context variables that can be consumed using <code>var</code> and <code>var_set</code> functions. |

3 changes: 1 addition & 2 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ pageLoadAssetSize:
visualizations: 295025
visualize: 57431
watcher: 43598
runtimeFields: 10000
runtimeFields: 41752
stackAlerts: 29684
presentationUtil: 28545
runtimeFieldEditor: 46986
spacesOss: 18817
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export * from './constants';
export * from './types';
require('../src/setup_node_env');
require('../src/dev/run_licenses_csv_report');
128 changes: 128 additions & 0 deletions src/dev/run_licenses_csv_report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* 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 { writeFileSync } from 'fs';
import { resolve } from 'path';
import { isNull, isUndefined } from 'lodash';

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

import { getInstalledPackages } from './npm';
import { engines } from '../../package';
import { LICENSE_OVERRIDES } from './license_checker';

const allDoubleQuoteRE = /"/g;

function escapeValue(value) {
if (isNull(value)) {
return;
}

return `"${value.replace(allDoubleQuoteRE, '""')}"`;
}

function formatCsvValues(fields, values) {
return fields
.map((field) => {
const value = values[field];

if (isNull(value) || isUndefined(value)) {
return null;
}

return value.toString();
})
.map(escapeValue)
.join(',');
}

run(
async ({ log, flags }) => {
const fields = ['name', 'version', 'url', 'license', 'sourceURL'];

const file = flags.csv;
const directory = flags.directory;
const dev = flags.dev;

const root = resolve(__dirname, '..', '..');
const packages = await getInstalledPackages({
directory: directory ? resolve(directory) : root,
licenseOverrides: LICENSE_OVERRIDES,
dev,
});

packages.unshift(
{
name: 'Node.js',
version: engines.node,
repository: 'https://nodejs.org',
licenses: ['MIT'],
},
{
name: 'Red Hat Universal Base Image minimal',
version: '8',
repository:
'https://catalog.redhat.com/software/containers/ubi8/ubi-minimal/5c359a62bed8bd75a2c3fba8',
licenses: [
'Custom;https://www.redhat.com/licenses/EULA_Red_Hat_Universal_Base_Image_English_20190422.pdf',
],
sourceURL: 'https://oss-dependencies.elastic.co/redhat/ubi/ubi-minimal-8-source.tar.gz',
}
);

const csv = packages
.map((pkg) => {
const data = {
name: pkg.name,
version: pkg.version,
url: pkg.repository || `https://www.npmjs.com/package/${pkg.name}`,
license: pkg.licenses.join(','),
sourceURL: pkg.sourceURL,
};

return formatCsvValues(fields, data);
})
.join('\n');

if (file) {
writeFileSync(file, `${fields.join(',')}\n${csv}`);
log.success(`wrote to ${file}`);
} else {
log.success(csv);
log.debug('\nspecify "--csv [filepath]" to write the data to a specific file');
}
},
{
description: `
Report of 3rd party dependencies
`,
flags: {
boolean: ['dev'],
string: ['csv', 'directory'],
default: {
dev: false,
},
help: `
--dev Include development dependencies
--csv Write csv report to file
--directory Directory to check for licenses
`,
},
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function EditorUI({ initialTextValue }: EditorProps) {

if (textareaElement) {
textareaElement.setAttribute('id', inputId);
textareaElement.setAttribute('data-test-subj', 'console-textarea');
}

const readQueryParams = () => {
Expand Down Expand Up @@ -204,7 +205,7 @@ function EditorUI({ initialTextValue }: EditorProps) {
}, [sendCurrentRequestToES, openDocumentation]);

return (
<div style={abs} className="conApp">
<div style={abs} data-test-subj="console-application" className="conApp">
<div className="conApp__editor">
<ul className="conApp__autoComplete" id="autocomplete" />
<EuiFlexGroup
Expand Down
37 changes: 33 additions & 4 deletions src/plugins/dashboard/public/application/dashboard_state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import { createBrowserHistory } from 'history';
import { getSavedDashboardMock } from './test_helpers';
import { DashboardContainer, DashboardContainerInput } from '.';
import { DashboardContainer, DashboardContainerInput, DashboardPanelState } from '.';
import { DashboardStateManager } from './dashboard_state_manager';
import { DashboardContainerServices } from './embeddable/dashboard_container';

import { ViewMode } from '../services/embeddable';
import { EmbeddableInput, ViewMode } from '../services/embeddable';
import { createKbnUrlStateStorage } from '../services/kibana_utils';
import { InputTimeRange, TimefilterContract, TimeRange } from '../services/data';

Expand Down Expand Up @@ -134,6 +134,11 @@ describe('DashboardState', function () {

const dashboardContainer = initDashboardContainer({
expandedPanelId: 'theCoolestPanelOnThisDashboard',
panels: {
theCoolestPanelOnThisDashboard: {
explicitInput: { id: 'theCoolestPanelOnThisDashboard' },
} as DashboardPanelState<EmbeddableInput>,
},
});

dashboardState.handleDashboardContainerChanges(dashboardContainer);
Expand All @@ -149,15 +154,39 @@ describe('DashboardState', function () {

const dashboardContainer = initDashboardContainer({
expandedPanelId: 'theCoolestPanelOnThisDashboard',
panels: {
theCoolestPanelOnThisDashboard: {
explicitInput: { id: 'theCoolestPanelOnThisDashboard' },
} as DashboardPanelState<EmbeddableInput>,
},
});

dashboardState.handleDashboardContainerChanges(dashboardContainer);
dashboardState.handleDashboardContainerChanges(dashboardContainer);
expect(dashboardState.setExpandedPanelId).toHaveBeenCalledTimes(1);
});

test('expandedPanelId is set to undefined if panel does not exist in input', () => {
dashboardState.setExpandedPanelId = jest
.fn()
.mockImplementation(dashboardState.setExpandedPanelId);
const dashboardContainer = initDashboardContainer({
expandedPanelId: 'theCoolestPanelOnThisDashboard',
panels: {
theCoolestPanelOnThisDashboard: {
explicitInput: { id: 'theCoolestPanelOnThisDashboard' },
} as DashboardPanelState<EmbeddableInput>,
},
});

dashboardState.handleDashboardContainerChanges(dashboardContainer);
expect(dashboardState.setExpandedPanelId).toHaveBeenCalledWith(
'theCoolestPanelOnThisDashboard'
);

dashboardContainer.updateInput({ expandedPanelId: 'woah it changed' });
dashboardContainer.updateInput({ expandedPanelId: 'theLeastCoolPanelOnThisDashboard' });
dashboardState.handleDashboardContainerChanges(dashboardContainer);
expect(dashboardState.setExpandedPanelId).toHaveBeenCalledTimes(2);
expect(dashboardState.setExpandedPanelId).toHaveBeenCalledWith(undefined);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export class DashboardStateManager {
const savedDashboardPanelMap: { [key: string]: SavedDashboardPanel } = {};

const input = dashboardContainer.getInput();

this.getPanels().forEach((savedDashboardPanel) => {
if (input.panels[savedDashboardPanel.panelIndex] !== undefined) {
savedDashboardPanelMap[savedDashboardPanel.panelIndex] = savedDashboardPanel;
Expand All @@ -234,11 +235,16 @@ export class DashboardStateManager {

const convertedPanelStateMap: { [key: string]: SavedDashboardPanel } = {};

let expandedPanelValid = false;
Object.values(input.panels).forEach((panelState) => {
if (savedDashboardPanelMap[panelState.explicitInput.id] === undefined) {
dirty = true;
}

if (panelState.explicitInput.id === input.expandedPanelId) {
expandedPanelValid = true;
}

convertedPanelStateMap[panelState.explicitInput.id] = convertPanelStateToSavedDashboardPanel(
panelState,
this.kibanaVersion
Expand Down Expand Up @@ -272,8 +278,10 @@ export class DashboardStateManager {
this.setFullScreenMode(input.isFullScreenMode);
}

if (input.expandedPanelId !== this.getExpandedPanelId()) {
if (expandedPanelValid && input.expandedPanelId !== this.getExpandedPanelId()) {
this.setExpandedPanelId(input.expandedPanelId);
} else if (!expandedPanelValid && this.getExpandedPanelId()) {
this.setExpandedPanelId(undefined);
}

if (!_.isEqual(input.query, this.getQuery())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { ViewMode, EmbeddableChildPanel } from '../../../services/embeddable';
import { DASHBOARD_GRID_COLUMN_COUNT, DASHBOARD_GRID_HEIGHT } from '../dashboard_constants';
import { DashboardPanelState } from '../types';
import { withKibana } from '../../../services/kibana_react';
import { DashboardContainerInput } from '../dashboard_container';
import { DashboardContainer, DashboardReactContextValue } from '../dashboard_container';

let lastValidGridSize = 0;
Expand Down Expand Up @@ -177,18 +176,17 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> {
isLayoutInvalid,
});

this.subscription = this.props.container
.getInput$()
.subscribe((input: DashboardContainerInput) => {
if (this.mounted) {
this.setState({
panels: input.panels,
viewMode: input.viewMode,
useMargins: input.useMargins,
expandedPanelId: input.expandedPanelId,
});
}
});
this.subscription = this.props.container.getInput$().subscribe(() => {
const { panels, viewMode, useMargins, expandedPanelId } = this.props.container.getInput();
if (this.mounted) {
this.setState({
panels,
viewMode,
useMargins,
expandedPanelId,
});
}
});
}

public componentWillUnmount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,7 @@ describe('agg_expression_functions', () => {
json: '{ "foo": true }',
});

expect(actual.value.params.json).toEqual({ foo: true });

expect(() => {
fn({
json: '/// intentionally malformed json ///',
});
}).toThrowErrorMatchingInlineSnapshot(`"Unable to parse json argument string"`);
expect(actual.value.params.json).toEqual('{ "foo": true }');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export const aggDateHistogram = (): FunctionDefinition => ({
...rest,
timeRange: getParsedValue(args, 'timeRange'),
extended_bounds: getParsedValue(args, 'extended_bounds'),
json: getParsedValue(args, 'json'),
},
},
};
Expand Down
Loading

0 comments on commit ced4520

Please sign in to comment.