Skip to content

Commit

Permalink
Merge branch 'master' into kpm/metric-mocha-to-jest
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Jan 16, 2020
2 parents 1c53734 + 03570c2 commit 79d9ff0
Show file tree
Hide file tree
Showing 439 changed files with 4,909 additions and 1,872 deletions.
2 changes: 1 addition & 1 deletion .backportrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"upstream": "elastic/kibana",
"branches": [{ "name": "7.x", "checked": true }, "7.5", "7.4", "7.3", "7.2", "7.1", "7.0", "6.8", "6.7", "6.6", "6.5", "6.4", "6.3", "6.2", "6.1", "6.0", "5.6"],
"branches": [{ "name": "7.x", "checked": true }, "7.6", "7.5", "7.4", "7.3", "7.2", "7.1", "7.0", "6.8", "6.7", "6.6", "6.5", "6.4", "6.3", "6.2", "6.1", "6.0", "5.6"],
"labels": ["backport"]
}
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bower_components
/built_assets
/html_docs
/src/plugins/data/common/es_query/kuery/ast/_generated_/**
/src/fixtures/vislib/mock_data
src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data
/src/legacy/ui/public/angular-bootstrap
/src/legacy/ui/public/flot-charts
/test/fixtures/scenarios
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
},
},
{
files: ['src/legacy/core_plugins/kbn_vislib_vis_types/**/*.{js,ts,tsx}'],
files: ['src/legacy/core_plugins/vis_type_vislib/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
},
Expand Down
16 changes: 8 additions & 8 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,21 @@
/x-pack/test/api_integration/apis/security/ @elastic/kibana-security

# Kibana Localization
/src/dev/i18n @elastic/kibana-localization
/src/dev/i18n/ @elastic/kibana-localization

# Pulse
/packages/kbn-analytics/ @elastic/pulse
/src/legacy/core_plugins/ui_metric/ @elastic/pulse
/src/plugins/usage_collection/ @elastic/pulse
/x-pack/legacy/plugins/telemetry @elastic/pulse
/x-pack/legacy/plugins/telemetry/ @elastic/pulse

# Kibana Alerting Services
/x-pack/legacy/plugins/alerting @elastic/kibana-alerting-services
/x-pack/legacy/plugins/actions @elastic/kibana-alerting-services
/x-pack/legacy/plugins/task_manager @elastic/kibana-alerting-services
/x-pack/test/alerting_api_integration @elastic/kibana-alerting-services
/x-pack/test/plugin_api_integration/plugins/task_manager @elastic/kibana-alerting-services
/x-pack/test/plugin_api_integration/test_suites/task_manager @elastic/kibana-alerting-services
/x-pack/legacy/plugins/alerting/ @elastic/kibana-alerting-services
/x-pack/legacy/plugins/actions/ @elastic/kibana-alerting-services
/x-pack/plugins/task_manager/ @elastic/kibana-alerting-services
/x-pack/test/alerting_api_integration/ @elastic/kibana-alerting-services
/x-pack/test/plugin_api_integration/plugins/task_manager/ @elastic/kibana-alerting-services
/x-pack/test/plugin_api_integration/test_suites/task_manager/ @elastic/kibana-alerting-services
/x-pack/legacy/plugins/triggers_actions_ui/ @elastic/kibana-alerting-services
/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/ @elastic/kibana-alerting-services
/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/ @elastic/kibana-alerting-services
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"interpreter": "src/legacy/core_plugins/interpreter",
"kbn": "src/legacy/core_plugins/kibana",
"kbnDocViews": "src/legacy/core_plugins/kbn_doc_views",
"kbnVislibVisTypes": "src/legacy/core_plugins/kbn_vislib_vis_types",
"kbnVislibVisTypes": "src/legacy/core_plugins/vis_type_vislib",
"management": ["src/legacy/core_plugins/management", "src/plugins/management"],
"kibana_react": "src/legacy/core_plugins/kibana_react",
"kibana-react": "src/plugins/kibana_react",
Expand Down
2 changes: 1 addition & 1 deletion .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ files:
include:
- 'src/legacy/core_plugins/metrics/**/*.s+(a|c)ss'
- 'src/legacy/core_plugins/timelion/**/*.s+(a|c)ss'
- 'src/legacy/ui/public/vislib/**/*.s+(a|c)ss'
- 'src/legacy/core_plugins/vis_type_vislib/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/rollup/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/canvas/**/*.s+(a|c)ss'
Expand Down
Binary file modified docs/maps/images/gs_add_cloropeth_layer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/maps/images/gs_add_es_layer.png
Binary file not shown.
Binary file modified docs/maps/images/sample_data_web_logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 22 additions & 15 deletions docs/maps/maps-getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,35 @@ and lighter shades symbolize countries with less traffic.
. Click the *EMS Boundaries* data source.
. From the *Layer* dropdown menu, select *World Countries*.
. Click the *Add layer* button.
. Set *Layer name* to `Total Requests by Country`.
. Set *Layer transparency* to 0.5.
. Set *Name* to `Total Requests by Country`.
. Set *Opacity* to 50%.
. Click *Add* under *Tooltip fields*.
. In the popover, select *ISO 3166-1 alpha-2 code* and *name* and click *Add*.

===== Join the vector layer with the sample web log index

You now have a vector layer containing the world countries.
To symbolize countries by web traffic, you'll need to augment the world country features with the count of Elasticsearch weblog documents originating from each country.
To do this, you'll create a <<terms-join, terms join>> to link the vector source *World Countries* to
To do this, you'll create a <<terms-join, term join>> to link the vector source *World Countries* to
the {es} index `kibana_sample_data_logs` on the shared key iso2 = geo.src.

. Click plus image:maps/images/gs_plus_icon.png[] to the right of *Term Joins* label.
. Click *Join --select--*
. Set *Left field* to *ISO 3166-1 alpha-2 code*.
. Set *Right source* to *kibana_sample_data_logs*.
. Set *Right field* to *geo.src*.
. Click *and use metric count*.
. Set *Custom label* to *web logs count*.

===== Set the layer style

All of the world countries are still a single color because the layer is using <<maps-vector-style-static, static styling>>.
To shade the world countries based on which country is sending the most requests, you'll need to use <<maps-vector-style-data-driven, data driven styling>>.

. Click image:maps/images/gs_link_icon.png[] to the right of *Fill color*.
. Under *Fill color*, change the selected value from *Solid* to *By value*.
. In the field select input, select *web logs count*.
. Select the grey color ramp.
. In the field select input, select *count of kibana_sample_data_logs:geo.src*.
. Under *Border color*, change the selected color to *white*.
. Click *Save & close*.
+
Your map now looks like this:
Expand Down Expand Up @@ -119,9 +124,11 @@ The layer is only visible when users zoom in the map past zoom level 9.
. Click the *Documents* data source.
. Set *Index pattern* to *kibana_sample_data_logs*.
. Click the *Add layer* button.
. Set *Layer name* to `Actual Requests`.
. Set *Zoom range for layer visibility* to the range [9, 24].
. Set *Layer transparency* to 1.
. Set *Name* to `Actual Requests`.
. Set *Visibilty* to the range [9, 24].
. Set *Opacity* to 100%.
. Click *Add* under *Tooltip fields*.
. In the popover, select *clientip*, *timestamp*, *host*, *request*, *response*, *machine.os*, *agent*, and *bytes* and click *Add*.
. Set *Fill color* to *#2200ff*.
. Click *Save & close*.
+
Expand Down Expand Up @@ -152,28 +159,28 @@ image::maps/images/grid_metrics_both.png[]
. Set *Index pattern* to *kibana_sample_data_logs*.
. Set *Show as* to *points*.
. Click the *Add layer* button.
. Set *Layer name* to `Total Requests and Bytes`.
. Set *Zoom range for layer visibility* to the range [0, 9].
. Set *Layer transparency* to 1.
. Set *Name* to `Total Requests and Bytes`.
. Set *Visibility* to the range [0, 9].
. Set *Opacity* to 100%.

===== Configure the aggregation metrics

. Click plus image:maps/images/gs_plus_icon.png[] to the right of *Metrics* label.
. Click *Add metric* under of *Metrics* label.
. Select *Sum* in the aggregation select.
. Select *bytes* in the field select.

===== Set the layer style

. In *Layer style*, change *Symbol size*:
.. Set *Min size* to 1.
.. Set *Min size* to 7.
.. Set *Max size* to 25.
.. In the field select, select *sum of bytes*.
.. Change the field select from *count* to *sum of bytes*.
. Click *Save & close* button.
+
Your map now looks like this between zoom levels 0 and 9:
+
[role="screenshot"]
image::maps/images/gs_add_es_layer.png[]
image::maps/images/sample_data_web_logs.png[]

[role="xpack"]
[[maps-save]]
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"kbn:bootstrap": "yarn build:types && node scripts/register_git_hook",
"spec_to_console": "node scripts/spec_to_console",
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
"storybook": "node scripts/storybook",
"cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html"
},
"repository": {
Expand Down Expand Up @@ -460,10 +461,13 @@
"postcss-url": "^8.0.0",
"prettier": "^1.19.1",
"proxyquire": "1.8.0",
"react-popper-tooltip": "^2.10.1",
"react-textarea-autosize": "^7.1.2",
"regenerate": "^1.4.0",
"sass-lint": "^1.12.1",
"selenium-webdriver": "^4.0.0-alpha.5",
"simple-git": "1.116.0",
"simplebar-react": "^2.1.0",
"sinon": "^7.4.2",
"strip-ansi": "^3.0.1",
"supertest": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

export { withProcRunner } from './proc_runner';
export { withProcRunner, ProcRunner } from './proc_runner';
export {
ToolingLog,
ToolingLogTextWriter,
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-dev-utils/src/proc_runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
*/

export { withProcRunner } from './with_proc_runner';
export { ProcRunner } from './proc_runner';
13 changes: 9 additions & 4 deletions packages/kbn-dev-utils/src/run/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import exitHook from 'exit-hook';
import { pickLevelFromFlags, ToolingLog } from '../tooling_log';
import { createFlagError, isFailError } from './fail';
import { Flags, getFlags, getHelp } from './flags';
import { ProcRunner, withProcRunner } from '../proc_runner';

type CleanupTask = () => void;
type RunFn = (args: {
log: ToolingLog;
flags: Flags;
procRunner: ProcRunner;
addCleanupTask: (task: CleanupTask) => void;
}) => Promise<void> | void;

Expand Down Expand Up @@ -102,10 +104,13 @@ export async function run(fn: RunFn, options: Options = {}) {
}

try {
await fn({
log,
flags,
addCleanupTask: (task: CleanupTask) => cleanupTasks.push(task),
await withProcRunner(log, async procRunner => {
await fn({
log,
flags,
procRunner,
addCleanupTask: (task: CleanupTask) => cleanupTasks.push(task),
});
});
} finally {
doCleanup();
Expand Down
15 changes: 11 additions & 4 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4489,6 +4489,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = __webpack_require__(36);
var proc_runner_1 = __webpack_require__(37);
exports.withProcRunner = proc_runner_1.withProcRunner;
exports.ProcRunner = proc_runner_1.ProcRunner;
var tooling_log_1 = __webpack_require__(415);
exports.ToolingLog = tooling_log_1.ToolingLog;
exports.ToolingLogTextWriter = tooling_log_1.ToolingLogTextWriter;
Expand Down Expand Up @@ -4761,6 +4762,8 @@ function __importDefault(mod) {
Object.defineProperty(exports, "__esModule", { value: true });
var with_proc_runner_1 = __webpack_require__(38);
exports.withProcRunner = with_proc_runner_1.withProcRunner;
var proc_runner_1 = __webpack_require__(39);
exports.ProcRunner = proc_runner_1.ProcRunner;


/***/ }),
Expand Down Expand Up @@ -37069,6 +37072,7 @@ const exit_hook_1 = tslib_1.__importDefault(__webpack_require__(348));
const tooling_log_1 = __webpack_require__(415);
const fail_1 = __webpack_require__(425);
const flags_1 = __webpack_require__(426);
const proc_runner_1 = __webpack_require__(37);
async function run(fn, options = {}) {
var _a;
const flags = flags_1.getFlags(process.argv.slice(2), options);
Expand Down Expand Up @@ -37118,10 +37122,13 @@ async function run(fn, options = {}) {
throw fail_1.createFlagError(`Unknown flag(s) "${flags.unexpected.join('", "')}"`);
}
try {
await fn({
log,
flags,
addCleanupTask: (task) => cleanupTasks.push(task),
await proc_runner_1.withProcRunner(log, async (procRunner) => {
await fn({
log,
flags,
procRunner,
addCleanupTask: (task) => cleanupTasks.push(task),
});
});
}
finally {
Expand Down
33 changes: 33 additions & 0 deletions packages/kbn-storybook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Kibana Storybook

This package provides ability to add [Storybook](https://storybook.js.org/) to any Kibana plugin.

- [Setup Instructions](#setup-instructions)


## Setup Instructions

1. Add `storybook.js` launcher file to your plugin. For example, create a file at
`src/plugins/<plugin>/scripts/storybook.js`, with the following contents:

```js
import { join } from 'path';

// eslint-disable-next-line
require('@kbn/storybook').runStorybookCli({
name: '<plugin>',
storyGlobs: [join(__dirname, '..', 'public', 'components', '**', '*.examples.tsx')],
});
```
2. Add your plugin alias to `src/dev/storybook/aliases.ts` config.
3. Create sample Storybook stories. For example, in your plugin create create a file at
`src/plugins/<plugin>/public/components/hello_world/__examples__/hello_world.examples.tsx` with
the following contents:

```jsx
import * as React from 'react';
import { storiesOf } from '@storybook/react';

storiesOf('Hello world', module).add('default', () => <div>Hello world!</div>);
```
4. Launch Storybook with `yarn storybook <plugin>`.
86 changes: 86 additions & 0 deletions packages/kbn-storybook/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* 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.
*/

const fs = require('fs');
const { join } = require('path');
const Rx = require('rxjs');
const { first } = require('rxjs/operators');
const storybook = require('@storybook/react/standalone');
const { run } = require('@kbn/dev-utils');
const { generateStorybookEntry } = require('./lib/storybook_entry');
const { REPO_ROOT, CURRENT_CONFIG } = require('./lib/constants');
const { buildDll } = require('./lib/dll');

exports.runStorybookCli = config => {
const { name, storyGlobs } = config;
run(
async ({ flags, log, procRunner }) => {
log.debug('Global config:\n', require('./lib/constants'));

const currentConfig = JSON.stringify(config, null, 2);
const currentConfigDir = join(CURRENT_CONFIG, '..');
await fs.promises.mkdir(currentConfigDir, { recursive: true });
log.debug('Writing currentConfig:\n', CURRENT_CONFIG + '\n', currentConfig);
await fs.promises.writeFile(CURRENT_CONFIG, `exports.currentConfig = ${currentConfig};`);

await buildDll({
rebuildDll: flags.rebuildDll,
log,
procRunner,
});

// Build sass and continue when initial build complete
await procRunner.run('watch sass', {
cmd: process.execPath,
args: ['scripts/build_sass', '--watch'],
cwd: REPO_ROOT,
wait: /scss bundles created/,
});

const subj = new Rx.ReplaySubject(1);
generateStorybookEntry({ log, storyGlobs }).subscribe(subj);

await subj.pipe(first()).toPromise();

await Promise.all([
// route errors
subj.toPromise(),

new Promise(() => {
// storybook never completes, so neither will this promise
const configDir = join(__dirname, 'storybook_config');
log.debug('Config dir:', configDir);
storybook({
mode: 'dev',
port: 9001,
configDir,
});
}),
]);
},
{
flags: {
boolean: ['rebuildDll'],
},
description: `
Run the storybook examples for ${name}
`,
}
);
};
Loading

0 comments on commit 79d9ff0

Please sign in to comment.