Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into action-index-not-…
Browse files Browse the repository at this point in the history
…able-to-clean

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
YulNaumenko committed Apr 21, 2020
2 parents ec43002 + b7f2a01 commit 1ec3487
Show file tree
Hide file tree
Showing 305 changed files with 2,765 additions and 2,075 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/src/legacy/core_plugins/kibana/public/dev_tools/ @elastic/kibana-app
/src/legacy/core_plugins/vis_type_vislib/ @elastic/kibana-app
/src/plugins/vis_type_xy/ @elastic/kibana-app
/src/plugins/vis_type_table/ @elastic/kibana-app
/src/plugins/kibana_legacy/ @elastic/kibana-app
/src/plugins/vis_type_timelion/ @elastic/kibana-app
/src/plugins/dashboard/ @elastic/kibana-app
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"visDefaultEditor": "src/plugins/vis_default_editor",
"visTypeMarkdown": "src/plugins/vis_type_markdown",
"visTypeMetric": "src/plugins/vis_type_metric",
"visTypeTable": "src/legacy/core_plugins/vis_type_table",
"visTypeTable": "src/plugins/vis_type_table",
"visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud",
"visTypeTimeseries": ["src/legacy/core_plugins/vis_type_timeseries", "src/plugins/vis_type_timeseries"],
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
Expand Down
Binary file added docs/images/clone_panel.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/setup/production.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ server.port
Settings that must be the same:
--------
xpack.security.encryptionKey //decrypting session cookies
xpack.reporting.encryptionKey //decrypting reports stored in Elasticsearch
xpack.reporting.encryptionKey //decrypting reports
xpack.encryptedSavedObjects.encryptionKey // decrypting saved objects
--------

Separate configuration files can be used from the command line by using the `-c` flag:
Expand Down
18 changes: 18 additions & 0 deletions docs/user/dashboard.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ to the new dimensions.
* To delete a panel, open the panel menu and select *Delete from dashboard.* Deleting a panel from a
dashboard does *not* delete the saved visualization or search.

[float]
[[cloning-a-panel]]
=== Clone dashboard elements

In *Edit* mode, you can clone any panel on a dashboard.

To clone an existing panel, open the panel menu of the element you wish to clone, then select *Clone panel*.

* Cloned panels appear beside the original, and will move other panels down to make room if necessary.

* Clones support all of the original panel's functionality, including renaming, editing, and cloning.

* All cloned visualizations will appear in the visualization list.

[role="screenshot"]
image:images/clone_panel.gif[clone panel]


[float]
[[viewing-detailed-information]]
=== Inspect and edit elements
Expand Down
12 changes: 4 additions & 8 deletions examples/state_containers_examples/public/todo/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { AppMountParameters } from 'kibana/public';
import ReactDOM from 'react-dom';
import React from 'react';
import { createHashHistory, createBrowserHistory } from 'history';
import { createHashHistory } from 'history';
import { TodoAppPage } from './todo';

export interface AppOptions {
Expand All @@ -35,13 +35,10 @@ export enum History {
}

export const renderApp = (
{ appBasePath, element }: AppMountParameters,
{ appBasePath, element, history: platformHistory }: AppMountParameters,
{ appInstanceId, appTitle, historyType }: AppOptions
) => {
const history =
historyType === History.Browser
? createBrowserHistory({ basename: appBasePath })
: createHashHistory();
const history = historyType === History.Browser ? platformHistory : createHashHistory();
ReactDOM.render(
<TodoAppPage
history={history}
Expand All @@ -54,8 +51,7 @@ export const renderApp = (
const currentAppUrl = stripTrailingSlash(history.createHref(history.location));
if (historyType === History.Browser) {
// browser history
const basePath = stripTrailingSlash(appBasePath);
return currentAppUrl === basePath && !history.location.search && !history.location.hash;
return currentAppUrl === '' && !history.location.search && !history.location.hash;
} else {
// hashed history
return currentAppUrl === '#' && !history.location.search;
Expand Down
10 changes: 7 additions & 3 deletions examples/state_containers_examples/public/todo/todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,20 @@ const TodoApp: React.FC<TodoAppProps> = ({ filter }) => {
return (
<>
<div>
<Link to={{ ...location, pathname: '/' }}>
<Link to={{ ...location, pathname: '/' }} data-test-subj={'filterLinkAll'}>
<EuiButton size={'s'} color={!filter ? 'primary' : 'secondary'}>
All
</EuiButton>
</Link>
<Link to={{ ...location, pathname: '/completed' }}>
<Link to={{ ...location, pathname: '/completed' }} data-test-subj={'filterLinkCompleted'}>
<EuiButton size={'s'} color={filter === 'completed' ? 'primary' : 'secondary'}>
Completed
</EuiButton>
</Link>
<Link to={{ ...location, pathname: '/not-completed' }}>
<Link
to={{ ...location, pathname: '/not-completed' }}
data-test-subj={'filterLinkNotCompleted'}
>
<EuiButton size={'s'} color={filter === 'not-completed' ? 'primary' : 'secondary'}>
Not Completed
</EuiButton>
Expand All @@ -121,6 +124,7 @@ const TodoApp: React.FC<TodoAppProps> = ({ filter }) => {
});
}}
label={todo.text}
data-test-subj={`todoCheckbox-${todo.id}`}
/>
<EuiButton
style={{ marginLeft: '8px' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { createBrowserHistory } from 'history';
import { AppMountParameters, CoreStart } from '../../../../src/core/public';
import { AppPluginDependencies } from './types';
import { StateDemoApp } from './components/app';
Expand All @@ -28,9 +27,8 @@ import { createKbnUrlStateStorage } from '../../../../src/plugins/kibana_utils/p
export const renderApp = (
{ notifications, http }: CoreStart,
{ navigation, data }: AppPluginDependencies,
{ appBasePath, element }: AppMountParameters
{ appBasePath, element, history }: AppMountParameters
) => {
const history = createBrowserHistory({ basename: appBasePath });
const kbnUrlStateStorage = createKbnUrlStateStorage({ useHash: false, history });

ReactDOM.render(
Expand Down
24 changes: 24 additions & 0 deletions packages/kbn-config-schema/src/types/object_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { schema } from '..';
import { TypeOf } from './object_type';

test('returns value by default', () => {
const type = schema.object({
Expand Down Expand Up @@ -350,3 +351,26 @@ test('unknowns = `ignore` affects only own keys', () => {
})
).toThrowErrorMatchingInlineSnapshot(`"[foo.baz]: definition for this key is missing"`);
});

test('handles optional properties', () => {
const type = schema.object({
required: schema.string(),
optional: schema.maybe(schema.string()),
});

type SchemaType = TypeOf<typeof type>;

let foo: SchemaType = {
required: 'foo',
};
foo = {
required: 'hello',
optional: undefined,
};
foo = {
required: 'hello',
optional: 'bar',
};

expect(foo).toBeDefined();
});
23 changes: 19 additions & 4 deletions packages/kbn-config-schema/src/types/object_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,26 @@ export type Props = Record<string, Type<any>>;

export type TypeOf<RT extends Type<any>> = RT['type'];

type OptionalProperties<Base extends Props> = Pick<
Base,
{
[Key in keyof Base]: undefined extends TypeOf<Base[Key]> ? Key : never;
}[keyof Base]
>;

type RequiredProperties<Base extends Props> = Pick<
Base,
{
[Key in keyof Base]: undefined extends TypeOf<Base[Key]> ? never : Key;
}[keyof Base]
>;

// Because of https://github.com/Microsoft/TypeScript/issues/14041
// this might not have perfect _rendering_ output, but it will be typed.
export type ObjectResultType<P extends Props> = Readonly<{ [K in keyof P]: TypeOf<P[K]> }>;
export type ObjectResultType<P extends Props> = Readonly<
{ [K in keyof OptionalProperties<P>]?: TypeOf<P[K]> } &
{ [K in keyof RequiredProperties<P>]: TypeOf<P[K]> }
>;

interface UnknownOptions {
/**
Expand All @@ -40,9 +57,7 @@ interface UnknownOptions {
unknowns?: 'allow' | 'ignore' | 'forbid';
}

export type ObjectTypeOptions<P extends Props = any> = TypeOptions<
{ [K in keyof P]: TypeOf<P[K]> }
> &
export type ObjectTypeOptions<P extends Props = any> = TypeOptions<ObjectResultType<P>> &
UnknownOptions;

export class ObjectType<P extends Props = any> extends Type<ObjectResultType<P>> {
Expand Down
21 changes: 21 additions & 0 deletions scripts/prettier_on_changed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.
*/

require('../src/setup_node_env/babel_register');
require('../src/dev/run_prettier_on_changed');
17 changes: 12 additions & 5 deletions src/core/server/http/router/validator/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
* under the License.
*/

import { ValidationError, Type, schema, ObjectType, isConfigSchema } from '@kbn/config-schema';
import {
ValidationError,
Type,
schema,
ObjectType,
TypeOf,
isConfigSchema,
} from '@kbn/config-schema';
import { Stream } from 'stream';
import { RouteValidationError } from './validator_error';

Expand Down Expand Up @@ -85,7 +92,7 @@ type RouteValidationResultType<T extends RouteValidationSpec<any> | undefined> =
T extends RouteValidationFunction<any>
? ReturnType<T>['value']
: T extends Type<any>
? ReturnType<T['validate']>
? TypeOf<T>
: undefined
>;

Expand Down Expand Up @@ -170,23 +177,23 @@ export class RouteValidator<P = {}, Q = {}, B = {}> {
* @internal
*/
public getParams(data: unknown, namespace?: string): Readonly<P> {
return this.validate(this.config.params, this.options.unsafe?.params, data, namespace);
return this.validate(this.config.params, this.options.unsafe?.params, data, namespace) as P;
}

/**
* Get validated query params
* @internal
*/
public getQuery(data: unknown, namespace?: string): Readonly<Q> {
return this.validate(this.config.query, this.options.unsafe?.query, data, namespace);
return this.validate(this.config.query, this.options.unsafe?.query, data, namespace) as Q;
}

/**
* Get validated body
* @internal
*/
public getBody(data: unknown, namespace?: string): Readonly<B> {
return this.validate(this.config.body, this.options.unsafe?.body, data, namespace);
return this.validate(this.config.body, this.options.unsafe?.body, data, namespace) as B;
}

/**
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions src/dev/eslint/lint_files.js → src/dev/eslint/lint_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import { CLIEngine } from 'eslint';

import { createFailError } from '@kbn/dev-utils';
import { createFailError, ToolingLog } from '@kbn/dev-utils';
import { File } from '../file';
import { REPO_ROOT } from '../constants';

/**
Expand All @@ -30,7 +31,7 @@ import { REPO_ROOT } from '../constants';
* @param {Array<File>} files
* @return {undefined}
*/
export function lintFiles(log, files, { fix } = {}) {
export function lintFiles(log: ToolingLog, files: File[], { fix }: { fix?: boolean } = {}) {
const cli = new CLIEngine({
cache: true,
cwd: REPO_ROOT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/

import { CLIEngine } from 'eslint';

import { ToolingLog } from '@kbn/dev-utils';
import { File } from '../file';

/**
* Filters a list of files to only include lintable files.
*
* @param {ToolingLog} log
* @param {Array<File>} files
* @return {Array<File>}
*/
export function pickFilesToLint(log, files) {
const cli = new CLIEngine();
export function pickFilesToLint(log: ToolingLog, files: File[]) {
const cli = new CLIEngine({});

return files.filter(file => {
if (!file.isJs() && !file.isTypescript()) {
Expand Down
Loading

0 comments on commit 1ec3487

Please sign in to comment.