From 354d7cc43103f5219be7cf36462abb440a2f2761 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Fri, 16 Nov 2018 13:41:08 -0800 Subject: [PATCH 01/95] [ML] Add checkbox to enable model plot in Advanced job wizard (#25468) * Move cardinality success check to utils * enableModelPlot checkbox base added * Run cardinality check on add/update fields * Handle changes made via json * only run cardinality check if model plot enabled * Handle model plot enabled via EditJSON tab * show message on cardinality check error * multi-metric + pop: show message on cardinality check error * add test for callout component * Fix flexitem overflow in IE11 --- .../jobs/new_job/advanced/_advanced.scss | 4 + .../advanced/detectors_list_directive.js | 4 + .../enable_model_plot_callout.test.js | 22 +++ .../enable_model_plot_callout_directive.js | 22 +++ .../enable_model_plot_callout_view.js | 39 ++++++ .../enable_model_plot_callout/index.js | 8 ++ .../ml/public/jobs/new_job/advanced/index.js | 1 + .../public/jobs/new_job/advanced/new_job.html | 28 ++++ .../new_job/advanced/new_job_controller.js | 126 +++++++++++++++++- .../enable_model_plot_checkbox_directive.js | 39 ++---- .../jobs/new_job/utils/new_job_utils.js | 41 ++++++ .../ml/server/routes/job_validation.js | 4 +- 12 files changed, 305 insertions(+), 33 deletions(-) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout.test.js create mode 100644 x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout_directive.js create mode 100644 x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout_view.js create mode 100644 x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/index.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/_advanced.scss b/x-pack/plugins/ml/public/jobs/new_job/advanced/_advanced.scss index 8a3783b1f7d10..1b0c67a44c3af 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/advanced/_advanced.scss +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/_advanced.scss @@ -1,6 +1,10 @@ .ml-new-job { display: block; } +// Required to prevent overflow of flex item in IE11 +.ml-new-job-callout { + width: 100%; +} // SASSTODO: Proper calcs. This looks too brittle to touch quickly .detector { diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/detectors_list_directive.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/detectors_list_directive.js index 0d1badddc5e16..b8e35ddce8414 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/advanced/detectors_list_directive.js +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/detectors_list_directive.js @@ -31,6 +31,7 @@ module.directive('mlJobDetectorsList', function ($modal) { fields: '=mlFields', catFieldNameSelected: '=mlCatFieldNameSelected', editMode: '=mlEditMode', + onUpdate: '=mlOnDetectorsUpdate' }, template, controller: function ($scope) { @@ -42,11 +43,14 @@ module.directive('mlJobDetectorsList', function ($modal) { } else { $scope.detectors.push(dtr); } + + $scope.onUpdate(); } }; $scope.removeDetector = function (index) { $scope.detectors.splice(index, 1); + $scope.onUpdate(); }; $scope.editDetector = function (index) { diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout.test.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout.test.js new file mode 100644 index 0000000000000..6c9b597f1ebf2 --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout.test.js @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { mount } from 'enzyme'; +import { EnableModelPlotCallout } from './enable_model_plot_callout_view.js'; + +const message = 'Test message'; + +describe('EnableModelPlotCallout', () => { + + test('Callout is rendered correctly with message', () => { + const wrapper = mount(); + const calloutText = wrapper.find('EuiText'); + + expect(calloutText.text()).toBe(message); + }); + +}); diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout_directive.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout_directive.js new file mode 100644 index 0000000000000..d1a4b6bb6314f --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout_directive.js @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import 'ngreact'; + +import { uiModules } from 'ui/modules'; +const module = uiModules.get('apps/ml', ['react']); + +import { EnableModelPlotCallout } from './enable_model_plot_callout_view.js'; + +module.directive('mlEnableModelPlotCallout', function (reactDirective) { + return reactDirective( + EnableModelPlotCallout, + undefined, + { restrict: 'E' } + ); +}); diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout_view.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout_view.js new file mode 100644 index 0000000000000..4b69c0e61fb2e --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/enable_model_plot_callout_view.js @@ -0,0 +1,39 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import PropTypes from 'prop-types'; +import React, { Fragment } from 'react'; + +import { + EuiCallOut, + EuiFlexGroup, + EuiFlexItem, +} from '@elastic/eui'; + + +export const EnableModelPlotCallout = ({ message }) => ( + + + + +

+ {message} +

+
+
+
+
+); + +EnableModelPlotCallout.propTypes = { + message: PropTypes.string.isRequired, +}; diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/index.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/index.js new file mode 100644 index 0000000000000..195c9129e0eea --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/enable_model_plot_callout/index.js @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + +import './enable_model_plot_callout_directive.js'; diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/index.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/index.js index 376ca85b394a5..94cefd62d076f 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/advanced/index.js +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/index.js @@ -12,3 +12,4 @@ import './save_status_modal'; import './field_select_directive'; import 'plugins/ml/components/job_group_select'; import 'plugins/ml/jobs/components/job_timepicker_modal'; +import './enable_model_plot_callout'; diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/new_job.html b/x-pack/plugins/ml/public/jobs/new_job/advanced/new_job.html index 59e4ec2bfa624..89ebace8bc93b 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/advanced/new_job.html +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/new_job.html @@ -238,6 +238,7 @@

{{ui.pageTitle}}

ml-fields="fields" ml-cat-field-name-selected="(job.analysis_config.categorization_field_name?true:false)" ml-edit-mode="'NEW'" + ml-on-detectors-update="onDetectorsUpdate" >
{{ ( ui.validation.tabs[1].checks.detectors.message || "At least one detector should be configured" ) }} @@ -275,6 +276,33 @@

{{ui.pageTitle}}

{{ ( ui.validation.tabs[1].checks.influencers.message || "At least one influencer should be selected" ) }}
+ +
+ +
+ +
+ + +
+
diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/new_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/new_job_controller.js index 802b88b321c37..3624c63d3a948 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/advanced/new_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/new_job_controller.js @@ -18,7 +18,12 @@ import { checkFullLicense } from 'plugins/ml/license/check_license'; import { checkCreateJobsPrivilege } from 'plugins/ml/privilege/check_privilege'; import template from './new_job.html'; import saveStatusTemplate from 'plugins/ml/jobs/new_job/advanced/save_status_modal/save_status_modal.html'; -import { createSearchItems, createJobForSaving } from 'plugins/ml/jobs/new_job/utils/new_job_utils'; +import { + createSearchItems, + createJobForSaving, + checkCardinalitySuccess, + getMinimalValidJob, +} from 'plugins/ml/jobs/new_job/utils/new_job_utils'; import { loadIndexPatterns, loadCurrentIndexPattern, loadCurrentSavedSearch, timeBasedIndexCheck } from 'plugins/ml/util/index_utils'; import { ML_JOB_FIELD_TYPES, ES_FIELD_TYPES } from 'plugins/ml/../common/constants/field_types'; import { ALLOWED_DATA_UNITS } from 'plugins/ml/../common/constants/validation'; @@ -114,6 +119,8 @@ module.controller('MlNewJob', const mlConfirm = mlConfirmModalService; msgs.clear(); const jobDefaults = newJobDefaults(); + // For keeping a copy of the detectors for comparison + const currentConfigs = { detectors: [], model_plot_config: { enabled: false } }; $scope.job = {}; $scope.mode = MODE.NEW; @@ -156,6 +163,15 @@ module.controller('MlNewJob', $scope.ui.validation.tabs[tab].valid = valid; } }, + cardinalityValidator: { + status: 0, message: '', STATUS: { + FAILED: -1, + NOT_RUNNING: 0, + RUNNING: 1, + FINISHED: 2, + WARNING: 3, + } + }, jsonText: '', changeTab: changeTab, influencers: [], @@ -181,6 +197,7 @@ module.controller('MlNewJob', types: {}, isDatafeed: true, useDedicatedIndex: false, + enableModelPlot: false, modelMemoryLimit: '', modelMemoryLimitDefault: jobDefaults.anomaly_detectors.model_memory_limit, @@ -282,9 +299,37 @@ module.controller('MlNewJob', }); } + function checkForConfigUpdates() { + const { STATUS } = $scope.ui.cardinalityValidator; + // Check if enable model plot was set/has changed and update if it has. + const jobModelPlotValue = $scope.job.model_plot_config ? $scope.job.model_plot_config : { enabled: false }; + const modelPlotSettingsEqual = _.isEqual(currentConfigs.model_plot_config, jobModelPlotValue); + + if (!modelPlotSettingsEqual) { + // Update currentConfigs. + currentConfigs.model_plot_config.enabled = jobModelPlotValue.enabled; + // Update ui portion so checkbox is checked + $scope.ui.enableModelPlot = jobModelPlotValue.enabled; + } + + if ($scope.ui.enableModelPlot === true) { + const unchanged = _.isEqual(currentConfigs.detectors, $scope.job.analysis_config.detectors); + // if detectors changed OR model plot was just toggled on run cardinality + if (!unchanged || !modelPlotSettingsEqual) { + runValidateCardinality(); + } + } else { + $scope.ui.cardinalityValidator.status = STATUS.FINISHED; + $scope.ui.cardinalityValidator.message = ''; + } + } + function changeTab(tab) { $scope.ui.currentTab = tab.index; - if (tab.index === 4) { + // Selecting Analysis Configuration tab + if (tab.index === 1) { + checkForConfigUpdates(); + } else if (tab.index === 4) { createJSONText(); } else if (tab.index === 5) { if ($scope.ui.dataLocation === 'ES') { @@ -651,6 +696,83 @@ module.controller('MlNewJob', } }; + function runValidateCardinality() { + const { STATUS } = $scope.ui.cardinalityValidator; + $scope.ui.cardinalityValidator.status = $scope.ui.cardinalityValidator.STATUS.RUNNING; + + const tempJob = mlJobService.cloneJob($scope.job); + _.merge(tempJob, getMinimalValidJob()); + + ml.validateCardinality(tempJob) + .then((response) => { + const validationResult = checkCardinalitySuccess(response); + + if (validationResult.success === true) { + $scope.ui.cardinalityValidator.status = STATUS.FINISHED; + $scope.ui.cardinalityValidator.message = ''; + } else { + $scope.ui.cardinalityValidator.message = `Creating model plots is resource intensive and not recommended + where the cardinality of the selected fields is greater than 100. Estimated cardinality + for this job is ${validationResult.highCardinality}. + If you enable model plot with this configuration + we recommend you select a dedicated results index on the Job Details tab.`; + + $scope.ui.cardinalityValidator.status = STATUS.WARNING; + } + }) + .catch((error) => { + console.log('Cardinality check error:', error); + $scope.ui.cardinalityValidator.message = `An error occurred validating the configuration + for running the job with model plot enabled. + Creating model plots can be resource intensive and not recommended where the cardinality of the selected fields is high. + You may want to select a dedicated results index on the Job Details tab.`; + + $scope.ui.cardinalityValidator.status = STATUS.FAILED; + }); + } + + $scope.onDetectorsUpdate = function () { + const { STATUS } = $scope.ui.cardinalityValidator; + + if ($scope.ui.enableModelPlot === true) { + // Update currentConfigs since config changed + currentConfigs.detectors = _.cloneDeep($scope.job.analysis_config.detectors); + + if ($scope.job.analysis_config.detectors.length === 0) { + $scope.ui.cardinalityValidator.status = STATUS.FINISHED; + $scope.ui.cardinalityValidator.message = ''; + } else { + runValidateCardinality(); + } + } + }; + + $scope.setModelPlotEnabled = function () { + const { STATUS } = $scope.ui.cardinalityValidator; + + if ($scope.ui.enableModelPlot === true) { + // Start keeping track of the config in case of changes from Edit JSON tab requiring another cardinality check + currentConfigs.detectors = _.cloneDeep($scope.job.analysis_config.detectors); + + $scope.job.model_plot_config = { + enabled: true + }; + + currentConfigs.model_plot_config.enabled = true; + // return early if there's nothing to run a check on yet. + if ($scope.job.analysis_config.detectors.length === 0) { + return; + } + + runValidateCardinality(); + } else { + currentConfigs.model_plot_config.enabled = false; + $scope.ui.cardinalityValidator.status = STATUS.FINISHED; + $scope.ui.cardinalityValidator.message = ''; + delete $scope.job.model_plot_config; + } + }; + // function called by field-select components to set // properties in the analysis_config $scope.setAnalysisConfigProperty = function (value, field) { diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/components/enable_model_plot_checkbox/enable_model_plot_checkbox_directive.js b/x-pack/plugins/ml/public/jobs/new_job/simple/components/enable_model_plot_checkbox/enable_model_plot_checkbox_directive.js index e153c695994bd..4664b451d29ec 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/components/enable_model_plot_checkbox/enable_model_plot_checkbox_directive.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/components/enable_model_plot_checkbox/enable_model_plot_checkbox_directive.js @@ -9,6 +9,7 @@ import ReactDOM from 'react-dom'; import { EnableModelPlotCheckbox } from './enable_model_plot_checkbox_view.js'; import { ml } from '../../../../../services/ml_api_service'; +import { checkCardinalitySuccess } from '../../../utils/new_job_utils'; import { uiModules } from 'ui/modules'; const module = uiModules.get('apps/ml'); @@ -34,33 +35,12 @@ module.directive('mlEnableModelPlotCheckbox', function () { function errorHandler(error) { console.log('Cardinality could not be validated', error); $scope.ui.cardinalityValidator.status = STATUS.FAILED; - $scope.ui.cardinalityValidator.message = 'Cardinality could not be validated'; - } - - // Only model plot cardinality relevant - // format:[{id:"cardinality_model_plot_high",modelPlotCardinality:11405}, {id:"cardinality_partition_field",fieldName:"clientip"}] - function checkCardinalitySuccess(data) { - const response = { - success: true, - }; - // There were no fields to run cardinality on. - if (Array.isArray(data) && data.length === 0) { - return response; - } - - for (let i = 0; i < data.length; i++) { - if (data[i].id === 'success_cardinality') { - break; - } - - if (data[i].id === 'cardinality_model_plot_high') { - response.success = false; - response.highCardinality = data[i].modelPlotCardinality; - break; - } - } - - return response; + $scope.ui.cardinalityValidator.message = `An error occurred validating the configuration + for running the job with model plot enabled. + Creating model plots can be resource intensive and not recommended where the cardinality of the selected fields is high. + You may want to select a dedicated results index on the Job Details tab.`; + // Go ahead and check the dedicated index box for them + $scope.formConfig.useDedicatedIndex = true; } function validateCardinality() { @@ -131,7 +111,10 @@ module.directive('mlEnableModelPlotCheckbox', function () { $scope.formConfig.enableModelPlot === false) ); const validatorRunning = ($scope.ui.cardinalityValidator.status === STATUS.RUNNING); - const warningStatus = ($scope.ui.cardinalityValidator.status === STATUS.WARNING && $scope.ui.formValid === true); + const warningStatus = ( + ($scope.ui.cardinalityValidator.status === STATUS.WARNING || + $scope.ui.cardinalityValidator.status === STATUS.FAILED) && + $scope.ui.formValid === true); const checkboxText = (validatorRunning) ? 'Validating cardinality...' : 'Enable model plot'; const props = { diff --git a/x-pack/plugins/ml/public/jobs/new_job/utils/new_job_utils.js b/x-pack/plugins/ml/public/jobs/new_job/utils/new_job_utils.js index cf55e0d43e1a8..f4b5e2a2c5597 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/utils/new_job_utils.js +++ b/x-pack/plugins/ml/public/jobs/new_job/utils/new_job_utils.js @@ -115,3 +115,44 @@ export function focusOnResultsLink(linkId, $timeout) { $(`#${linkId}`).focus(); }, 0); } + +// Only model plot cardinality relevant +// format:[{id:"cardinality_model_plot_high",modelPlotCardinality:11405}, {id:"cardinality_partition_field",fieldName:"clientip"}] +export function checkCardinalitySuccess(data) { + const response = { + success: true, + }; + // There were no fields to run cardinality on. + if (Array.isArray(data) && data.length === 0) { + return response; + } + + for (let i = 0; i < data.length; i++) { + if (data[i].id === 'success_cardinality') { + break; + } + + if (data[i].id === 'cardinality_model_plot_high') { + response.success = false; + response.highCardinality = data[i].modelPlotCardinality; + break; + } + } + + return response; +} + +// Ensure validation endpoints are given job with expected minimum fields +export function getMinimalValidJob() { + return { + analysis_config: { + bucket_span: '15m', + detectors: [], + influencers: [] + }, + data_description: { time_field: '@timestamp' }, + datafeed_config: { + indices: [] + } + }; +} diff --git a/x-pack/plugins/ml/server/routes/job_validation.js b/x-pack/plugins/ml/server/routes/job_validation.js index 2096169e232d2..73e3a8685bb8f 100644 --- a/x-pack/plugins/ml/server/routes/job_validation.js +++ b/x-pack/plugins/ml/server/routes/job_validation.js @@ -85,9 +85,7 @@ export function jobValidationRoutes(server, commonRouteConfig) { const callWithRequest = callWithRequestFactory(server, request); return validateCardinality(callWithRequest, request.payload) .then(reply) - .catch((resp) => { - reply(wrapError(resp)); - }); + .catch(resp => wrapError(resp)); }, config: { ...commonRouteConfig From df8514fa09842f01d0890fb7d65dbd339423f116 Mon Sep 17 00:00:00 2001 From: Spencer Date: Fri, 16 Nov 2018 15:11:43 -0800 Subject: [PATCH 02/95] [kbn/es] add `--download` flag to snapshot command to warm the cache (#25830) In order to pre-fetch Elasticsearch snapshots and avoid timeouts during download in images, this adds a `--download` option to the `es snapshot` command. --- packages/kbn-es/src/cli_commands/snapshot.js | 11 +++++- packages/kbn-es/src/cluster.js | 24 +++++++++++- packages/kbn-es/src/install/index.js | 1 + packages/kbn-es/src/install/snapshot.js | 41 +++++++++++++++++--- 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/packages/kbn-es/src/cli_commands/snapshot.js b/packages/kbn-es/src/cli_commands/snapshot.js index 0a585e92cfd74..c01a4fa08ec59 100644 --- a/packages/kbn-es/src/cli_commands/snapshot.js +++ b/packages/kbn-es/src/cli_commands/snapshot.js @@ -35,6 +35,7 @@ exports.help = (defaults = {}) => { --install-path Installation path, defaults to 'source' within base-path --password Sets password for elastic user [default: ${password}] -E Additional key=value settings to pass to Elasticsearch + --download-only Download the snapshot but don't actually start it Example: @@ -51,10 +52,16 @@ exports.run = async (defaults = {}) => { esArgs: 'E', }, + boolean: ['download-only'], + default: defaults, }); const cluster = new Cluster(); - const { installPath } = await cluster.installSnapshot(options); - await cluster.run(installPath, { esArgs: options.esArgs }); + if (options['download-only']) { + await cluster.downloadSnapshot(options); + } else { + const { installPath } = await cluster.installSnapshot(options); + await cluster.run(installPath, { esArgs: options.esArgs }); + } }; diff --git a/packages/kbn-es/src/cluster.js b/packages/kbn-es/src/cluster.js index f14be3582f71a..50f3c5db2d8ca 100644 --- a/packages/kbn-es/src/cluster.js +++ b/packages/kbn-es/src/cluster.js @@ -19,7 +19,7 @@ const execa = require('execa'); const chalk = require('chalk'); -const { installSnapshot, installSource, installArchive } = require('./install'); +const { downloadSnapshot, installSnapshot, installSource, installArchive } = require('./install'); const { ES_BIN } = require('./paths'); const { log: defaultLog, parseEsLog, extractConfigFiles } = require('./utils'); const { createCliError } = require('./errors'); @@ -50,6 +50,28 @@ exports.Cluster = class Cluster { return { installPath }; } + /** + * Download ES from a snapshot + * + * @param {Object} options + * @property {Array} options.installPath + * @property {Array} options.sourcePath + * @returns {Promise<{installPath}>} + */ + async downloadSnapshot(options = {}) { + this._log.info(chalk.bold('Downloading snapshot')); + this._log.indent(4); + + const { installPath } = await downloadSnapshot({ + log: this._log, + ...options, + }); + + this._log.indent(-4); + + return { installPath }; + } + /** * Download and installs ES from a snapshot * diff --git a/packages/kbn-es/src/install/index.js b/packages/kbn-es/src/install/index.js index 69de1004e4e72..e2b3f692b2203 100644 --- a/packages/kbn-es/src/install/index.js +++ b/packages/kbn-es/src/install/index.js @@ -19,4 +19,5 @@ exports.installArchive = require('./archive').installArchive; exports.installSnapshot = require('./snapshot').installSnapshot; +exports.downloadSnapshot = require('./snapshot').downloadSnapshot; exports.installSource = require('./source').installSource; diff --git a/packages/kbn-es/src/install/snapshot.js b/packages/kbn-es/src/install/snapshot.js index de1a635b7f9f6..39da7432923a6 100644 --- a/packages/kbn-es/src/install/snapshot.js +++ b/packages/kbn-es/src/install/snapshot.js @@ -28,19 +28,17 @@ const { installArchive } = require('./archive'); const { log: defaultLog, cache } = require('../utils'); /** - * Installs ES from snapshot + * Download an ES snapshot * * @param {Object} options * @property {('oss'|'basic'|'trial')} options.license - * @property {String} options.password * @property {String} options.version * @property {String} options.basePath * @property {String} options.installPath * @property {ToolingLog} options.log */ -exports.installSnapshot = async function installSnapshot({ +exports.downloadSnapshot = async function installSnapshot({ license = 'basic', - password = 'password', version, basePath = BASE_PATH, installPath = path.resolve(basePath, version), @@ -56,7 +54,40 @@ exports.installSnapshot = async function installSnapshot({ log.info('license: %s', chalk.bold(license)); await downloadFile(url, dest, log); - return await installArchive(dest, { + + return { + downloadPath: dest, + }; +}; + +/** + * Installs ES from snapshot + * + * @param {Object} options + * @property {('oss'|'basic'|'trial')} options.license + * @property {String} options.password + * @property {String} options.version + * @property {String} options.basePath + * @property {String} options.installPath + * @property {ToolingLog} options.log + */ +exports.installSnapshot = async function installSnapshot({ + license = 'basic', + password = 'password', + version, + basePath = BASE_PATH, + installPath = path.resolve(basePath, version), + log = defaultLog, +}) { + const { downloadPath } = await exports.downloadSnapshot({ + license, + version, + basePath, + installPath, + log, + }); + + return await installArchive(downloadPath, { license, password, basePath, From f7832a514cffc22326e2d7b7b48b0857ca73b213 Mon Sep 17 00:00:00 2001 From: Spencer Date: Fri, 16 Nov 2018 15:48:07 -0800 Subject: [PATCH 03/95] [ftr] add ability to get included/excluded test counts (#25760) ## Summary This pr adds a `--test-stats` flag to the functional test runner that will allow extracting information from a specific config/tags combo about how many tests will run and how many are excluded. This is necessary as part of https://github.com/elastic/kibana/pull/22359 so we can effectively ignore specific configs (avoiding starting es and kibana) when there aren't any tests that will be run. ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. ~~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~~ ~~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~~ ~~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~~ ~~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~~ ~~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~~ ### For maintainers ~~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ ~~- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ --- src/functional_test_runner/cli.js | 13 +++- .../functional_test_runner.js | 70 ++++++++++++++++--- .../lib/create_provider_collection.js | 50 ------------- src/functional_test_runner/lib/index.js | 2 +- .../lib/mocha/filter_suites_by_tags.js | 14 ++++ 5 files changed, 88 insertions(+), 61 deletions(-) delete mode 100644 src/functional_test_runner/lib/create_provider_collection.js diff --git a/src/functional_test_runner/cli.js b/src/functional_test_runner/cli.js index 6998a1b8bfb7a..9414dcfe1cfd9 100644 --- a/src/functional_test_runner/cli.js +++ b/src/functional_test_runner/cli.js @@ -48,6 +48,7 @@ cmd .option('--exclude [file]', 'Path to a test file that should not be loaded', collectExcludePaths(), []) .option('--include-tag [tag]', 'A tag to be included, pass multiple times for multiple tags', collectIncludeTags(), []) .option('--exclude-tag [tag]', 'A tag to be excluded, pass multiple times for multiple tags', collectExcludeTags(), []) + .option('--test-stats', 'Print the number of tests (included and excluded) to STDERR', false) .option('--verbose', 'Log everything', false) .option('--quiet', 'Only log errors', false) .option('--silent', 'Log nothing', false) @@ -86,8 +87,16 @@ const functionalTestRunner = createFunctionalTestRunner({ async function run() { try { - const failureCount = await functionalTestRunner.run(); - process.exitCode = failureCount ? 1 : 0; + if (cmd.testStats) { + process.stderr.write(JSON.stringify( + await functionalTestRunner.getTestStats(), + null, + 2 + ) + '\n'); + } else { + const failureCount = await functionalTestRunner.run(); + process.exitCode = failureCount ? 1 : 0; + } } catch (err) { await teardown(err); } finally { diff --git a/src/functional_test_runner/functional_test_runner.js b/src/functional_test_runner/functional_test_runner.js index 65d347fbee450..d32ad172d99b3 100644 --- a/src/functional_test_runner/functional_test_runner.js +++ b/src/functional_test_runner/functional_test_runner.js @@ -20,7 +20,8 @@ import { createLifecycle, readConfigFile, - createProviderCollection, + ProviderCollection, + readProviderSpec, setupMocha, runTests, } from './lib'; @@ -36,8 +37,61 @@ export function createFunctionalTestRunner({ log, configFile, configOverrides }) log.verbose('ending %j lifecycle phase', name); }); + class FunctionalTestRunner { async run() { + return await this._run(async (config, coreProviders) => { + const providers = new ProviderCollection(log, [ + ...coreProviders, + ...readProviderSpec('Service', config.get('services')), + ...readProviderSpec('PageObject', config.get('pageObjects')) + ]); + + await providers.loadAll(); + + const mocha = await setupMocha(lifecycle, log, config, providers); + await lifecycle.trigger('beforeTests'); + log.info('Starting tests'); + + return await runTests(lifecycle, log, mocha); + }); + } + + async getTestStats() { + return await this._run(async (config, coreProviders) => { + // replace the function of a provider so that it returns a promise-like object which + // never "resolves", essentially disabling all the services while still allowing us + // to load the test files and populate the mocha suites + const stubProvider = provider => ({ + ...provider, + fn: () => ({ + then: () => {} + }) + }); + + const providers = new ProviderCollection(log, [ + ...coreProviders, + ...readProviderSpec('Service', config.get('services')), + ...readProviderSpec('PageObject', config.get('pageObjects')) + ].map(stubProvider)); + + const mocha = await setupMocha(lifecycle, log, config, providers); + + const countTests = suite => ( + suite.suites.reduce( + (sum, suite) => sum + countTests(suite), + suite.tests.length + ) + ); + + return { + tests: countTests(mocha.suite), + excludedTests: mocha.excludedTests.length + }; + }); + } + + async _run(handler) { let runErrorOccurred = false; try { @@ -49,14 +103,14 @@ export function createFunctionalTestRunner({ log, configFile, configOverrides }) return; } - const providers = createProviderCollection(lifecycle, log, config); - await providers.loadAll(); - - const mocha = await setupMocha(lifecycle, log, config, providers); - await lifecycle.trigger('beforeTests'); - log.info('Starting tests'); - return await runTests(lifecycle, log, mocha); + // base level services that functional_test_runner exposes + const coreProviders = readProviderSpec('Service', { + lifecycle: () => lifecycle, + log: () => log, + config: () => config, + }); + return await handler(config, coreProviders); } catch (runError) { runErrorOccurred = true; throw runError; diff --git a/src/functional_test_runner/lib/create_provider_collection.js b/src/functional_test_runner/lib/create_provider_collection.js deleted file mode 100644 index e91f473290ec3..0000000000000 --- a/src/functional_test_runner/lib/create_provider_collection.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 { - ProviderCollection, - readProviderSpec -} from './providers'; - -/** - * Create a ProviderCollection that includes the Service - * providers and PageObject providers from config, as well - * providers for the default services, lifecycle, log, and - * config - * - * @param {Lifecycle} lifecycle - * @param {ToolingLog} log - * @param {Config} config [description] - * @return {ProviderCollection} - */ -export function createProviderCollection(lifecycle, log, config) { - return new ProviderCollection(log, [ - ...readProviderSpec('Service', { - // base level services that functional_test_runner exposes - lifecycle: () => lifecycle, - log: () => log, - config: () => config, - - ...config.get('services'), - }), - ...readProviderSpec('PageObject', { - ...config.get('pageObjects') - }) - ]); -} diff --git a/src/functional_test_runner/lib/index.js b/src/functional_test_runner/lib/index.js index 1a933447bb0fb..e1f93d8ac627c 100644 --- a/src/functional_test_runner/lib/index.js +++ b/src/functional_test_runner/lib/index.js @@ -19,5 +19,5 @@ export { createLifecycle } from './lifecycle'; export { readConfigFile } from './config'; -export { createProviderCollection } from './create_provider_collection'; export { setupMocha, runTests } from './mocha'; +export { readProviderSpec, ProviderCollection } from './providers'; diff --git a/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js b/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js index fd15f936c7625..597be9bab32a2 100644 --- a/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js +++ b/src/functional_test_runner/lib/mocha/filter_suites_by_tags.js @@ -28,6 +28,14 @@ * @param options.exclude an array of tags that will be used to exclude suites from the run */ export function filterSuitesByTags({ log, mocha, include, exclude }) { + mocha.excludedTests = []; + // collect all the tests from some suite, including it's children + const collectTests = (suite) => + suite.suites.reduce( + (acc, s) => acc.concat(collectTests(s)), + suite.tests + ); + // if include tags were provided, filter the tree once to // only include branches that are included at some point if (include.length) { @@ -47,14 +55,18 @@ export function filterSuitesByTags({ log, mocha, include, exclude }) { continue; } + // this suite has an included child but is not included // itself, so strip out its tests and recurse to filter // out child suites which are not included if (isChildIncluded(child)) { + mocha.excludedTests = mocha.excludedTests.concat(child.tests); child.tests = []; parentSuite.suites.push(child); recurse(child); continue; + } else { + mocha.excludedTests = mocha.excludedTests.concat(collectTests(child)); } } }(mocha.suite)); @@ -78,6 +90,8 @@ export function filterSuitesByTags({ log, mocha, include, exclude }) { if (isNotExcluded(child)) { parentSuite.suites.push(child); recurse(child); + } else { + mocha.excludedTests = mocha.excludedTests.concat(collectTests(child)); } } }(mocha.suite)); From b0d11e5607d2f950e418987cc54243e0a8e7e11b Mon Sep 17 00:00:00 2001 From: Spencer Date: Fri, 16 Nov 2018 16:30:55 -0800 Subject: [PATCH 04/95] [kbn/test] add support for using test groups (#25776) --- packages/kbn-dev-utils/index.d.ts | 1 + packages/kbn-dev-utils/src/index.js | 1 + .../serializers/absolute_path_serializer.d.ts | 22 ++++++ .../serializers/absolute_path_serializer.js} | 31 ++------ .../kbn-dev-utils/src/serializers/index.d.ts | 20 +++++ .../kbn-dev-utils/src/serializers/index.js | 20 +++++ .../run_tests/__snapshots__/args.test.js.snap | 31 +++++--- .../run_tests/__snapshots__/cli.test.js.snap | 1 + .../functional_tests/cli/run_tests/args.js | 10 ++- .../cli/run_tests/args.test.js | 3 + .../cli/run_tests/cli.test.js | 4 +- .../__snapshots__/args.test.js.snap | 32 ++------ .../cli/start_servers/args.js | 4 +- .../cli/start_servers/args.test.js | 25 +++--- .../cli/start_servers/cli.test.js | 4 +- .../src/functional_tests/lib/fun_ftr.js | 69 +++++++++++++++++ .../src/functional_tests/lib/index.js | 2 +- .../kbn-test/src/functional_tests/tasks.js | 77 +++++++++++-------- 18 files changed, 248 insertions(+), 109 deletions(-) create mode 100644 packages/kbn-dev-utils/src/serializers/absolute_path_serializer.d.ts rename packages/{kbn-test/src/functional_tests/lib/run_ftr.js => kbn-dev-utils/src/serializers/absolute_path_serializer.js} (55%) create mode 100644 packages/kbn-dev-utils/src/serializers/index.d.ts create mode 100644 packages/kbn-dev-utils/src/serializers/index.js create mode 100644 packages/kbn-test/src/functional_tests/lib/fun_ftr.js diff --git a/packages/kbn-dev-utils/index.d.ts b/packages/kbn-dev-utils/index.d.ts index 9d8fd8889b7e5..dceadb9496f3b 100644 --- a/packages/kbn-dev-utils/index.d.ts +++ b/packages/kbn-dev-utils/index.d.ts @@ -18,3 +18,4 @@ */ export * from './src/tooling_log'; +export * from './src/serializers'; diff --git a/packages/kbn-dev-utils/src/index.js b/packages/kbn-dev-utils/src/index.js index 4e2d1b62a92f7..82492e568f4b5 100644 --- a/packages/kbn-dev-utils/src/index.js +++ b/packages/kbn-dev-utils/src/index.js @@ -19,3 +19,4 @@ export { withProcRunner } from './proc_runner'; export { ToolingLog, ToolingLogTextWriter, pickLevelFromFlags } from './tooling_log'; +export { createAbsolutePathSerializer } from './serializers'; diff --git a/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.d.ts b/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.d.ts new file mode 100644 index 0000000000000..66e94571a2300 --- /dev/null +++ b/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.d.ts @@ -0,0 +1,22 @@ +/* + * 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. + */ + +export function createAbsolutePathSerializer( + rootPath: string +): { print(...args: any[]): string; test(value: any): boolean }; diff --git a/packages/kbn-test/src/functional_tests/lib/run_ftr.js b/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.js similarity index 55% rename from packages/kbn-test/src/functional_tests/lib/run_ftr.js rename to packages/kbn-dev-utils/src/serializers/absolute_path_serializer.js index 779286212f5c7..d944772048eb9 100644 --- a/packages/kbn-test/src/functional_tests/lib/run_ftr.js +++ b/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.js @@ -17,30 +17,9 @@ * under the License. */ -import { createFunctionalTestRunner } from '../../../../../src/functional_test_runner'; -import { CliError } from './run_cli'; - -export async function runFtr({ - configPath, - options: { log, bail, grep, updateBaselines, suiteTags }, -}) { - const ftr = createFunctionalTestRunner({ - log, - configFile: configPath, - configOverrides: { - mochaOpts: { - bail: !!bail, - grep, - }, - updateBaselines, - suiteTags, - }, - }); - - const failureCount = await ftr.run(); - if (failureCount > 0) { - throw new CliError( - `${failureCount} functional test ${failureCount === 1 ? 'failure' : 'failures'}` - ); - } +export function createAbsolutePathSerializer(rootPath) { + return { + print: value => value.replace(rootPath, '').replace(/\\/g, '/'), + test: value => typeof value === 'string' && value.startsWith(rootPath), + }; } diff --git a/packages/kbn-dev-utils/src/serializers/index.d.ts b/packages/kbn-dev-utils/src/serializers/index.d.ts new file mode 100644 index 0000000000000..3b49e243058df --- /dev/null +++ b/packages/kbn-dev-utils/src/serializers/index.d.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export { createAbsolutePathSerializer } from './absolute_path_serializer'; diff --git a/packages/kbn-dev-utils/src/serializers/index.js b/packages/kbn-dev-utils/src/serializers/index.js new file mode 100644 index 0000000000000..3b49e243058df --- /dev/null +++ b/packages/kbn-dev-utils/src/serializers/index.js @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export { createAbsolutePathSerializer } from './absolute_path_serializer'; diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap b/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap index 93d129213ff02..c55b8abf6c78c 100644 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap +++ b/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/args.test.js.snap @@ -18,6 +18,7 @@ Options: --updateBaselines Replace baseline screenshots with whatever is generated from the test. --include-tag Tags that suites must include to be run, can be included multiple times. --exclude-tag Tags that suites must NOT include to be run, can be included multiple times. + --assert-none-excluded Exit with 1/0 based on if any test is excluded with the current set of tags. --verbose Log everything. --debug Run in debug mode. --quiet Only log errors. @@ -26,8 +27,9 @@ Options: exports[`process options for run tests CLI accepts boolean value for updateBaselines 1`] = ` Object { + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "extraKbnOpts": undefined, @@ -41,8 +43,9 @@ Object { exports[`process options for run tests CLI accepts debug option 1`] = ` Object { + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "debug": true, @@ -56,9 +59,10 @@ Object { exports[`process options for run tests CLI accepts empty config value if default passed 1`] = ` Object { + "assertNoneExcluded": false, "config": "", "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "extraKbnOpts": undefined, @@ -74,8 +78,9 @@ Object { "_": Object { "server.foo": "bar", }, + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "extraKbnOpts": Object { @@ -90,8 +95,9 @@ Object { exports[`process options for run tests CLI accepts quiet option 1`] = ` Object { + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "extraKbnOpts": undefined, @@ -105,8 +111,9 @@ Object { exports[`process options for run tests CLI accepts silent option 1`] = ` Object { + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "extraKbnOpts": undefined, @@ -120,8 +127,9 @@ Object { exports[`process options for run tests CLI accepts source value for esFrom 1`] = ` Object { + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "esFrom": "source", @@ -135,8 +143,9 @@ Object { exports[`process options for run tests CLI accepts string value for kibana-install-dir 1`] = ` Object { + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "extraKbnOpts": undefined, @@ -150,8 +159,9 @@ Object { exports[`process options for run tests CLI accepts value for grep 1`] = ` Object { + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "extraKbnOpts": undefined, @@ -165,8 +175,9 @@ Object { exports[`process options for run tests CLI accepts verbose option 1`] = ` Object { + "assertNoneExcluded": false, "configs": Array [ - "foo", + /foo, ], "createLogger": [Function], "extraKbnOpts": undefined, diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap b/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap index 6d4b35f754b42..e9f3dfac56746 100644 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap +++ b/packages/kbn-test/src/functional_tests/cli/run_tests/__snapshots__/cli.test.js.snap @@ -18,6 +18,7 @@ Options: --updateBaselines Replace baseline screenshots with whatever is generated from the test. --include-tag Tags that suites must include to be run, can be included multiple times. --exclude-tag Tags that suites must NOT include to be run, can be included multiple times. + --assert-none-excluded Exit with 1/0 based on if any test is excluded with the current set of tags. --verbose Log everything. --debug Run in debug mode. --quiet Only log errors. diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/args.js b/packages/kbn-test/src/functional_tests/cli/run_tests/args.js index 6aa1e1aa5c31b..eb7809b91cebc 100644 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/args.js +++ b/packages/kbn-test/src/functional_tests/cli/run_tests/args.js @@ -17,6 +17,8 @@ * under the License. */ +import { resolve } from 'path'; + import dedent from 'dedent'; import { ToolingLog, pickLevelFromFlags } from '@kbn/dev-utils'; @@ -52,6 +54,9 @@ const options = { arg: '', desc: 'Tags that suites must NOT include to be run, can be included multiple times.', }, + 'assert-none-excluded': { + desc: 'Exit with 1/0 based on if any test is excluded with the current set of tags.', + }, verbose: { desc: 'Log everything.' }, debug: { desc: 'Run in debug mode.' }, quiet: { desc: 'Only log errors.' }, @@ -113,6 +118,9 @@ export function processOptions(userOptions, defaultConfigPaths) { delete userOptions['include-tag']; delete userOptions['exclude-tag']; + userOptions.assertNoneExcluded = !!userOptions['assert-none-excluded']; + delete userOptions['assert-none-excluded']; + function createLogger() { return new ToolingLog({ level: pickLevelFromFlags(userOptions), @@ -122,7 +130,7 @@ export function processOptions(userOptions, defaultConfigPaths) { return { ...userOptions, - configs, + configs: configs.map(c => resolve(c)), createLogger, extraKbnOpts: userOptions._, }; diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js b/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js index 2e0c2fb44022d..a6d5bf72ffc85 100644 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js +++ b/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js @@ -18,6 +18,9 @@ */ import { displayHelp, processOptions } from './args'; +import { createAbsolutePathSerializer } from '@kbn/dev-utils'; + +expect.addSnapshotSerializer(createAbsolutePathSerializer(process.cwd())); describe('display help for run tests CLI', () => { it('displays as expected', () => { diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js b/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js index 7e2e6c5a40e78..90caaf2cc6ce4 100644 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js +++ b/packages/kbn-test/src/functional_tests/cli/run_tests/cli.test.js @@ -17,6 +17,8 @@ * under the License. */ +import { Writable } from 'stream'; + import { runTestsCli } from './cli'; import { checkMockConsoleLogSnapshot } from '../../test_helpers'; @@ -36,7 +38,7 @@ describe('run tests CLI', () => { const processMock = { exit: exitMock, argv: argvMock, - stdout: { on: jest.fn(), once: jest.fn(), emit: jest.fn() }, + stdout: new Writable(), cwd: jest.fn(), }; diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/args.test.js.snap b/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/args.test.js.snap index 50da9f6836883..106ddcb00faf6 100644 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/args.test.js.snap +++ b/packages/kbn-test/src/functional_tests/cli/start_servers/__snapshots__/args.test.js.snap @@ -21,9 +21,7 @@ Options: exports[`process options for start servers CLI accepts debug option 1`] = ` Object { - "config": Array [ - "foo", - ], + "config": /foo, "createLogger": [Function], "debug": true, "esFrom": "snapshot", @@ -33,9 +31,7 @@ Object { exports[`process options for start servers CLI accepts empty config value if default passed 1`] = ` Object { - "config": Array [ - "foo", - ], + "config": /foo, "createLogger": [Function], "esFrom": "snapshot", "extraKbnOpts": undefined, @@ -47,9 +43,7 @@ Object { "_": Object { "server.foo": "bar", }, - "config": Array [ - "foo", - ], + "config": /foo, "createLogger": [Function], "esFrom": "snapshot", "extraKbnOpts": Object { @@ -60,9 +54,7 @@ Object { exports[`process options for start servers CLI accepts quiet option 1`] = ` Object { - "config": Array [ - "foo", - ], + "config": /foo, "createLogger": [Function], "esFrom": "snapshot", "extraKbnOpts": undefined, @@ -72,9 +64,7 @@ Object { exports[`process options for start servers CLI accepts silent option 1`] = ` Object { - "config": Array [ - "foo", - ], + "config": /foo, "createLogger": [Function], "esFrom": "snapshot", "extraKbnOpts": undefined, @@ -84,9 +74,7 @@ Object { exports[`process options for start servers CLI accepts source value for esFrom 1`] = ` Object { - "config": Array [ - "foo", - ], + "config": /foo, "createLogger": [Function], "esFrom": "source", "extraKbnOpts": undefined, @@ -95,9 +83,7 @@ Object { exports[`process options for start servers CLI accepts string value for kibana-install-dir 1`] = ` Object { - "config": Array [ - "foo", - ], + "config": /foo, "createLogger": [Function], "esFrom": "snapshot", "extraKbnOpts": undefined, @@ -107,9 +93,7 @@ Object { exports[`process options for start servers CLI accepts verbose option 1`] = ` Object { - "config": Array [ - "foo", - ], + "config": /foo, "createLogger": [Function], "esFrom": "snapshot", "extraKbnOpts": undefined, diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/args.js b/packages/kbn-test/src/functional_tests/cli/start_servers/args.js index 170de1942232b..026c23ab46f37 100644 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/args.js +++ b/packages/kbn-test/src/functional_tests/cli/start_servers/args.js @@ -17,6 +17,8 @@ * under the License. */ +import { resolve } from 'path'; + import dedent from 'dedent'; import { ToolingLog, pickLevelFromFlags } from '@kbn/dev-utils'; @@ -97,7 +99,7 @@ export function processOptions(userOptions, defaultConfigPath) { return { ...userOptions, - config, + config: resolve(config), createLogger, extraKbnOpts: userOptions._, }; diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js b/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js index 22c06b6ae3231..bc2b958d793fd 100644 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js +++ b/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js @@ -18,6 +18,9 @@ */ import { displayHelp, processOptions } from './args'; +import { createAbsolutePathSerializer } from '@kbn/dev-utils'; + +expect.addSnapshotSerializer(createAbsolutePathSerializer(process.cwd())); describe('display help for start servers CLI', () => { it('displays as expected', () => { @@ -39,60 +42,60 @@ describe('process options for start servers CLI', () => { }); it('accepts empty config value if default passed', () => { - const options = processOptions({ config: '' }, ['foo']); + const options = processOptions({ config: '' }, 'foo'); expect(options).toMatchSnapshot(); }); it('rejects invalid option', () => { expect(() => { - processOptions({ bail: true }, ['foo']); + processOptions({ bail: true }, 'foo'); }).toThrow('functional_tests_server: invalid option [bail]'); }); it('accepts string value for kibana-install-dir', () => { - const options = processOptions({ 'kibana-install-dir': 'foo' }, ['foo']); + const options = processOptions({ 'kibana-install-dir': 'foo' }, 'foo'); expect(options).toMatchSnapshot(); }); it('rejects boolean value for kibana-install-dir', () => { expect(() => { - processOptions({ 'kibana-install-dir': true }, ['foo']); + processOptions({ 'kibana-install-dir': true }, 'foo'); }).toThrow('functional_tests_server: invalid argument [true] to option [kibana-install-dir]'); }); it('accepts source value for esFrom', () => { - const options = processOptions({ esFrom: 'source' }, ['foo']); + const options = processOptions({ esFrom: 'source' }, 'foo'); expect(options).toMatchSnapshot(); }); it('accepts debug option', () => { - const options = processOptions({ debug: true }, ['foo']); + const options = processOptions({ debug: true }, 'foo'); expect(options).toMatchSnapshot(); }); it('accepts silent option', () => { - const options = processOptions({ silent: true }, ['foo']); + const options = processOptions({ silent: true }, 'foo'); expect(options).toMatchSnapshot(); }); it('accepts quiet option', () => { - const options = processOptions({ quiet: true }, ['foo']); + const options = processOptions({ quiet: true }, 'foo'); expect(options).toMatchSnapshot(); }); it('accepts verbose option', () => { - const options = processOptions({ verbose: true }, ['foo']); + const options = processOptions({ verbose: true }, 'foo'); expect(options).toMatchSnapshot(); }); it('accepts extra server options', () => { - const options = processOptions({ _: { 'server.foo': 'bar' } }, ['foo']); + const options = processOptions({ _: { 'server.foo': 'bar' } }, 'foo'); expect(options).toMatchSnapshot(); }); it('rejects invalid options even if valid options exist', () => { expect(() => { - processOptions({ debug: true, aintnothang: true, bail: true }, ['foo']); + processOptions({ debug: true, aintnothang: true, bail: true }, 'foo'); }).toThrow('functional_tests_server: invalid option [aintnothang]'); }); }); diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/cli.test.js b/packages/kbn-test/src/functional_tests/cli/start_servers/cli.test.js index 43bab5a4afe89..5a195c813f390 100644 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/cli.test.js +++ b/packages/kbn-test/src/functional_tests/cli/start_servers/cli.test.js @@ -17,6 +17,8 @@ * under the License. */ +import { Writable } from 'stream'; + import { startServersCli } from './cli'; import { checkMockConsoleLogSnapshot } from '../../test_helpers'; @@ -36,7 +38,7 @@ describe('start servers CLI', () => { const processMock = { exit: exitMock, argv: argvMock, - stdout: { on: jest.fn(), once: jest.fn(), emit: jest.fn() }, + stdout: new Writable(), cwd: jest.fn(), }; diff --git a/packages/kbn-test/src/functional_tests/lib/fun_ftr.js b/packages/kbn-test/src/functional_tests/lib/fun_ftr.js new file mode 100644 index 0000000000000..e3dbe6cef6d8a --- /dev/null +++ b/packages/kbn-test/src/functional_tests/lib/fun_ftr.js @@ -0,0 +1,69 @@ +/* + * 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 * as FunctionalTestRunner from '../../../../../src/functional_test_runner'; +import { CliError } from './run_cli'; + +function createFtr({ configPath, options: { log, bail, grep, updateBaselines, suiteTags } }) { + return FunctionalTestRunner.createFunctionalTestRunner({ + log, + configFile: configPath, + configOverrides: { + mochaOpts: { + bail: !!bail, + grep, + }, + updateBaselines, + suiteTags, + }, + }); +} + +export async function assertNoneExcluded({ configPath, options }) { + const ftr = createFtr({ configPath, options }); + + const stats = await ftr.getTestStats(); + if (stats.excludedTests > 0) { + throw new CliError(` + ${stats.excludedTests} tests in the ${configPath} config + are excluded when filtering by the tags run on CI. Make sure that all suites are + tagged with one of the following tags, or extend the list of tags in test/scripts/jenkins_xpack.sh + + ${JSON.stringify(options.suiteTags)} + + `); + } +} + +export async function runFtr({ configPath, options }) { + const ftr = createFtr({ configPath, options }); + + const failureCount = await ftr.run(); + if (failureCount > 0) { + throw new CliError( + `${failureCount} functional test ${failureCount === 1 ? 'failure' : 'failures'}` + ); + } +} + +export async function hasTests({ configPath, options }) { + const ftr = createFtr({ configPath, options }); + const stats = await ftr.getTestStats(); + return stats.tests > 0; +} diff --git a/packages/kbn-test/src/functional_tests/lib/index.js b/packages/kbn-test/src/functional_tests/lib/index.js index d66f641c10f68..886a77ba6e2e4 100644 --- a/packages/kbn-test/src/functional_tests/lib/index.js +++ b/packages/kbn-test/src/functional_tests/lib/index.js @@ -19,6 +19,6 @@ export { runKibanaServer } from './run_kibana_server'; export { runElasticsearch } from './run_elasticsearch'; -export { runFtr } from './run_ftr'; +export { runFtr, hasTests, assertNoneExcluded } from './fun_ftr'; export { KIBANA_ROOT, KIBANA_FTR_SCRIPT, FUNCTIONAL_CONFIG_PATH, API_CONFIG_PATH } from './paths'; export { runCli } from './run_cli'; diff --git a/packages/kbn-test/src/functional_tests/tasks.js b/packages/kbn-test/src/functional_tests/tasks.js index 0cdcc77161a60..b7f22836ab769 100644 --- a/packages/kbn-test/src/functional_tests/tasks.js +++ b/packages/kbn-test/src/functional_tests/tasks.js @@ -17,12 +17,19 @@ * under the License. */ -import { relative, resolve } from 'path'; +import { relative } from 'path'; import * as Rx from 'rxjs'; import { startWith, switchMap, take } from 'rxjs/operators'; import { withProcRunner } from '@kbn/dev-utils'; -import { runElasticsearch, runKibanaServer, runFtr, KIBANA_FTR_SCRIPT } from './lib'; +import { + runElasticsearch, + runKibanaServer, + runFtr, + assertNoneExcluded, + hasTests, + KIBANA_FTR_SCRIPT, +} from './lib'; import { readConfigFile } from '../../../../src/functional_test_runner/lib'; @@ -38,37 +45,63 @@ in another terminal session by running this command from this directory: /** * Run servers and tests for each config * @param {object} options Optional - * @property {string[]} configPaths Array of paths to configs - * @property {function} options.createLogger Optional logger creation function + * @property {string[]} options.configs Array of paths to configs + * @property {function} options.log An instance of the ToolingLog * @property {string} options.installDir Optional installation dir from which to run Kibana * @property {boolean} options.bail Whether to exit test run at the first failure * @property {string} options.esFrom Optionally run from source instead of snapshot */ export async function runTests(options) { for (const configPath of options.configs) { - await runSingleConfig(resolve(process.cwd(), configPath), options); + const log = options.createLogger(); + const opts = { + ...options, + log, + }; + + log.info('Running', configPath); + log.indent(2); + + if (options.assertNoneExcluded) { + await assertNoneExcluded({ configPath, options: opts }); + continue; + } + + if (!(await hasTests({ configPath, options: opts }))) { + log.info('Skipping', configPath, 'since all tests are excluded'); + continue; + } + + await withProcRunner(log, async procs => { + const config = await readConfigFile(log, configPath); + + const es = await runElasticsearch({ config, options: opts }); + await runKibanaServer({ procs, config, options: opts }); + await runFtr({ configPath, options: opts }); + + await procs.stop('kibana'); + await es.cleanup(); + }); } } /** * Start only servers using single config * @param {object} options Optional - * @property {string} options.configPath Path to a config file - * @property {function} options.createLogger Optional logger creation function + * @property {string} options.config Path to a config file + * @property {function} options.log An instance of the ToolingLog * @property {string} options.installDir Optional installation dir from which to run Kibana * @property {string} options.esFrom Optionally run from source instead of snapshot */ export async function startServers(options) { - const { config: configOption, createLogger } = options; - const configPath = resolve(process.cwd(), configOption); - const log = createLogger(); + const log = options.createLogger(); const opts = { ...options, log, }; await withProcRunner(log, async procs => { - const config = await readConfigFile(log, configPath); + const config = await readConfigFile(log, options.config); const es = await runElasticsearch({ config, options: opts }); await runKibanaServer({ @@ -100,25 +133,3 @@ async function silence(milliseconds, { log }) { ) .toPromise(); } - -/* - * Start servers and run tests for single config - */ -async function runSingleConfig(configPath, options) { - const log = options.createLogger(); - const opts = { - ...options, - log, - }; - - await withProcRunner(log, async procs => { - const config = await readConfigFile(log, configPath); - - const es = await runElasticsearch({ config, options: opts }); - await runKibanaServer({ procs, config, options: opts }); - await runFtr({ configPath, options: opts }); - - await procs.stop('kibana'); - await es.cleanup(); - }); -} From 01033c2732d1000a0743da0b705b84f5a44abf58 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 16 Nov 2018 16:40:14 -0800 Subject: [PATCH 05/95] build bootstrap cache into ci image --- .ci/packer_cache.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.ci/packer_cache.sh b/.ci/packer_cache.sh index 97168ff0262d1..05298b494f3d8 100755 --- a/.ci/packer_cache.sh +++ b/.ci/packer_cache.sh @@ -1,3 +1,21 @@ #!/usr/bin/env bash +# run setup script that gives us node, yarn, and bootstraps the project source "src/dev/ci_setup/setup.sh"; + +# run the build for both oss and default distributions to warm the babel and optimizer caches +node scripts/build; + +# cache es snapshots +node scripts/es snapshot --download-only; + +# archive cacheable directories +mkdir -p "$HOME/.kibana/bootstrap_cache" +tar -cf "$HOME/.kibana/bootstrap_cache/master.tar" \ + node_modules \ + packages/*/node_modules \ + x-pack/node_modules \ + x-pack/plugins/*/node_modules \ + optimize \ + data \ + .es; From 6bebea468792a24892fcbd1dc18cd6be2627002d Mon Sep 17 00:00:00 2001 From: Jason Rhodes Date: Fri, 16 Nov 2018 21:25:35 -0500 Subject: [PATCH 06/95] Fix agent status lookup (#25557) * Updates service overview to only do agent status check once * TS support added for EmptyMessage and those who import it * Fixed up tests * Finishes TS and test updates for agent check fix * Fixing up tests * Fixed linting error * Updated broken tests * Re-typed the service list response, camelCase throughout * Fixes broken test after data change * Makes initial data type more specific * Moves service list item TS interface back into server lib file --- .../ErrorGroupDetails/Distribution/index.js | 2 +- .../ServiceList/__test__/List.test.js | 50 +- .../__test__/__snapshots__/List.test.js.snap | 768 +++--------------- .../ServiceList/{index.js => index.tsx} | 44 +- .../__test__/ServiceOverview.test.js | 61 +- .../app/ServiceOverview/{view.js => view.tsx} | 55 +- .../components/app/TraceOverview/view.tsx | 2 +- .../TransactionDetails/Distribution/index.tsx | 2 +- .../app/TransactionDetails/view.tsx | 2 +- .../public/components/shared/EmptyMessage.tsx | 17 +- .../components/shared/Stacktrace/index.js | 2 +- .../plugins/apm/public/services/rest/apm.ts | 4 +- .../{serviceList.js => serviceList.tsx} | 20 +- .../apm/server/lib/services/get_services.ts | 26 +- 14 files changed, 262 insertions(+), 793 deletions(-) rename x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/{index.js => index.tsx} (65%) rename x-pack/plugins/apm/public/components/app/ServiceOverview/{view.js => view.tsx} (51%) rename x-pack/plugins/apm/public/store/reactReduxRequest/{serviceList.js => serviceList.tsx} (59%) diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.js b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.js index e90ea54069b3d..cd5e32eb1caae 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.js +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.js @@ -6,7 +6,7 @@ import React from 'react'; import Histogram from '../../../shared/charts/Histogram'; -import EmptyMessage from '../../../shared/EmptyMessage'; +import { EmptyMessage } from '../../../shared/EmptyMessage'; import { HeaderSmall } from '../../../shared/UIComponents'; export function getFormattedBuckets(buckets, bucketSize) { diff --git a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/List.test.js b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/List.test.js index d8ecffa2f18b5..dbeb321a18319 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/List.test.js +++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/List.test.js @@ -5,16 +5,10 @@ */ import React from 'react'; -import { mount } from 'enzyme'; - -import { MemoryRouter } from 'react-router-dom'; -import { ServiceList } from '../index'; +import { shallow } from 'enzyme'; +import { ServiceList, SERVICE_COLUMNS } from '../index'; import props from './props.json'; -import { - mountWithRouterAndStore, - mockMoment, - toJson -} from '../../../../../utils/testHelpers'; +import { mockMoment } from '../../../../../utils/testHelpers'; describe('ErrorGroupOverview -> List', () => { beforeAll(() => { @@ -22,24 +16,32 @@ describe('ErrorGroupOverview -> List', () => { }); it('should render empty state', () => { - const storeState = {}; - const wrapper = mount( - - - , - storeState - ); - - expect(toJson(wrapper)).toMatchSnapshot(); + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); }); it('should render with data', () => { - const storeState = { location: {} }; - const wrapper = mountWithRouterAndStore( - , - storeState - ); + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + }); - expect(toJson(wrapper)).toMatchSnapshot(); + it('should render columns correctly', () => { + const service = { + serviceName: 'opbeans-python', + agentName: 'python', + transactionsPerMinute: 86.93333333333334, + errorsPerMinute: 12.6, + avgResponseTime: 91535.42944785276 + }; + const renderedColumns = SERVICE_COLUMNS.map(c => + c.render(service[c.field], service) + ); + expect(renderedColumns[0]).toMatchSnapshot(); + expect(renderedColumns.slice(1)).toEqual([ + 'python', + '92 ms', + '86.9 tpm', + '12.6 err.' + ]); }); }); diff --git a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/__snapshots__/List.test.js.snap b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/__snapshots__/List.test.js.snap index 4fed4bb054679..35b87eaf6eff6 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/__snapshots__/List.test.js.snap +++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/__snapshots__/List.test.js.snap @@ -1,649 +1,133 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ErrorGroupOverview -> List should render empty state 1`] = ` -
List should render columns correctly 1`] = ` + -
-
-
-
-
- -
-
-
-
- - - - - - - - - - - - - - - - -
- Below is a table of - 0 - items. -
- - - - - - - - - -
-
- - No items found - -
-
-
-
-
-
-
-
- -
-
-
-
+ + opbeans-python + + `; -exports[`ErrorGroupOverview -> List should render with data 1`] = ` -.c0 { - font-size: 16px; - max-width: 100%; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} +exports[`ErrorGroupOverview -> List should render empty state 1`] = ` + +`; -
-
-
-
-
-
- -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Below is a table of - 2 - items. -
- - - - - - - - - -
- - -
- nodejs -
-
-
- N/A -
-
-
- 0 tpm -
-
-
- 46.1 err. -
-
- - -
- python -
-
-
- 92 ms -
-
-
- 86.9 tpm -
-
-
- 12.6 err. -
-
-
-
-
-
-
-
- -
-
-
-
+exports[`ErrorGroupOverview -> List should render with data 1`] = ` + `; diff --git a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.js b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx similarity index 65% rename from x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.js rename to x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx index 76317a51fa6f2..5ac5530540466 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.js +++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx @@ -4,16 +4,21 @@ * you may not use this file except in compliance with the Elastic License. */ +import { EuiToolTip } from '@elastic/eui'; import React from 'react'; -import PropTypes from 'prop-types'; import styled from 'styled-components'; -import { RelativeLink } from '../../../../utils/url'; +import { IServiceListItem } from 'x-pack/plugins/apm/server/lib/services/get_services'; import { fontSizes, truncate } from '../../../../style/variables'; -import TooltipOverlay from '../../../shared/TooltipOverlay'; -import { asMillis, asDecimal } from '../../../../utils/formatters'; +import { asDecimal, asMillis } from '../../../../utils/formatters'; +import { RelativeLink } from '../../../../utils/url'; import { ManagedTable } from '../../../shared/ManagedTable'; -function formatNumber(value) { +interface Props { + items: IServiceListItem[]; + noItemsMessage?: React.ReactNode; +} + +function formatNumber(value: number) { if (value === 0) { return '0'; } else if (value <= 0.1) { @@ -23,7 +28,7 @@ function formatNumber(value) { } } -function formatString(value) { +function formatString(value?: string | null) { return value || 'N/A'; } @@ -32,50 +37,50 @@ const AppLink = styled(RelativeLink)` ${truncate('100%')}; `; -const SERVICE_COLUMNS = [ +export const SERVICE_COLUMNS = [ { field: 'serviceName', name: 'Name', width: '50%', sortable: true, - render: serviceName => ( - + render: (serviceName: string) => ( + {formatString(serviceName)} - + ) }, { field: 'agentName', name: 'Agent', sortable: true, - render: agentName => formatString(agentName) + render: (agentName: string) => formatString(agentName) }, { field: 'avgResponseTime', name: 'Avg. response time', sortable: true, dataType: 'number', - render: value => asMillis(value) + render: (value: number) => asMillis(value) }, { field: 'transactionsPerMinute', name: 'Trans. per minute', sortable: true, dataType: 'number', - render: value => `${formatNumber(value)} tpm` + render: (value: number) => `${formatNumber(value)} tpm` }, { field: 'errorsPerMinute', name: 'Errors per minute', sortable: true, dataType: 'number', - render: value => `${formatNumber(value)} err.` + render: (value: number) => `${formatNumber(value)} err.` } ]; -export function ServiceList({ items, noItemsMessage }) { +export function ServiceList({ items = [], noItemsMessage }: Props) { return ( ); } - -ServiceList.propTypes = { - noItemsMessage: PropTypes.node, - items: PropTypes.array -}; - -ServiceList.defaultProps = { - items: [] -}; diff --git a/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.js b/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.js index 8ef92b829be9c..2f93eb0b2f1f0 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.js +++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.js @@ -13,11 +13,21 @@ import * as apmRestServices from '../../../../services/rest/apm'; jest.mock('../../../../services/rest/apm'); describe('Service Overview -> View', () => { + let mockAgentStatus; let wrapper; let instance; beforeEach(() => { - wrapper = shallow(); + mockAgentStatus = { + dataFound: true + }; + + // eslint-disable-next-line import/namespace + apmRestServices.loadAgentStatus = jest.fn(() => + Promise.resolve(mockAgentStatus) + ); + + wrapper = shallow(); instance = wrapper.instance(); }); @@ -40,53 +50,10 @@ describe('Service Overview -> View', () => { expect(List.props).toMatchSnapshot(); }); - describe('checking for historical data', () => { - let mockAgentStatus; - - beforeEach(() => { - mockAgentStatus = { - dataFound: true - }; - // eslint-disable-next-line import/namespace - apmRestServices.loadAgentStatus = jest.fn(() => - Promise.resolve(mockAgentStatus) - ); - }); - - it('should happen if service list status is success and data is empty', async () => { - const props = { - serviceList: { - status: STATUS.SUCCESS, - data: [] - } - }; - await instance.checkForHistoricalData(props); - expect(apmRestServices.loadAgentStatus).toHaveBeenCalledTimes(1); - }); - - it('should not happen if sevice list status is not success', async () => { - const props = { - serviceList: { - status: STATUS.FAILURE, - data: [] - } - }; - await instance.checkForHistoricalData(props); - expect(apmRestServices.loadAgentStatus).not.toHaveBeenCalled(); - }); - - it('should not happen if service list data is not empty', async () => { - const props = { - serviceList: { - status: STATUS.SUCCESS, - data: [1, 2, 3] - } - }; - await instance.checkForHistoricalData(props); - expect(apmRestServices.loadAgentStatus).not.toHaveBeenCalled(); - }); + it('should check for historical data once', () => {}); - it('should leave historical data state as true if data is found', async () => { + describe('checking for historical data', () => { + it('should set historical data to true if data is found', async () => { const props = { serviceList: { status: STATUS.SUCCESS, diff --git a/x-pack/plugins/apm/public/components/app/ServiceOverview/view.js b/x-pack/plugins/apm/public/components/app/ServiceOverview/view.tsx similarity index 51% rename from x-pack/plugins/apm/public/components/app/ServiceOverview/view.js rename to x-pack/plugins/apm/public/components/app/ServiceOverview/view.tsx index 9e0759bb735a1..2bd9373b94c3c 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceOverview/view.js +++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/view.tsx @@ -4,40 +4,39 @@ * you may not use this file except in compliance with the Elastic License. */ +import { EuiSpacer } from '@elastic/eui'; import React, { Component } from 'react'; -import { STATUS } from '../../../constants'; -import { isEmpty } from 'lodash'; +import { RRRRenderResponse } from 'react-redux-request'; +import { IUrlParams } from 'x-pack/plugins/apm/public/store/urlParams'; +import { IServiceListItem } from 'x-pack/plugins/apm/server/lib/services/get_services'; import { loadAgentStatus } from '../../../services/rest/apm'; -import { ServiceList } from './ServiceList'; -import { EuiSpacer } from '@elastic/eui'; import { ServiceListRequest } from '../../../store/reactReduxRequest/serviceList'; -import EmptyMessage from '../../shared/EmptyMessage'; +import { EmptyMessage } from '../../shared/EmptyMessage'; import { SetupInstructionsLink } from '../../shared/SetupInstructionsLink'; +import { ServiceList } from './ServiceList'; -export class ServiceOverview extends Component { - state = { - historicalDataFound: true - }; +interface Props { + urlParams: IUrlParams; + serviceList: RRRRenderResponse; +} - async checkForHistoricalData({ serviceList }) { - if (serviceList.status === STATUS.SUCCESS && isEmpty(serviceList.data)) { - const result = await loadAgentStatus(); - if (!result.dataFound) { - this.setState({ historicalDataFound: false }); - } - } - } +interface State { + historicalDataFound: boolean; +} + +export class ServiceOverview extends Component { + public state = { historicalDataFound: true }; - componentDidMount() { - this.checkForHistoricalData(this.props); + public async checkForHistoricalData() { + const result = await loadAgentStatus(); + this.setState({ historicalDataFound: result.dataFound }); } - componentDidUpdate() { - // QUESTION: Do we want to check on ANY update, or only if serviceList status/data have changed? - this.checkForHistoricalData(this.props); + public componentDidMount() { + this.checkForHistoricalData(); } - render() { + public render() { const { urlParams } = this.props; const { historicalDataFound } = this.state; @@ -54,13 +53,19 @@ export class ServiceOverview extends Component { /> ); + // Render method here uses this.props.serviceList instead of received "data" from RRR + // to make it easier to test -- mapStateToProps uses the RRR selector so the data + // is the same either way return (
( - + render={() => ( + )} />
diff --git a/x-pack/plugins/apm/public/components/app/TraceOverview/view.tsx b/x-pack/plugins/apm/public/components/app/TraceOverview/view.tsx index 3d14db033bd41..b0c8cba467055 100644 --- a/x-pack/plugins/apm/public/components/app/TraceOverview/view.tsx +++ b/x-pack/plugins/apm/public/components/app/TraceOverview/view.tsx @@ -10,7 +10,7 @@ import { RRRRenderResponse } from 'react-redux-request'; import { ITransactionGroup } from '../../../../typings/TransactionGroup'; // @ts-ignore import { TraceListRequest } from '../../../store/reactReduxRequest/traceList'; -import EmptyMessage from '../../shared/EmptyMessage'; +import { EmptyMessage } from '../../shared/EmptyMessage'; import { TraceList } from './TraceList'; interface Props { diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx index f7321df130660..90439a4194179 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx @@ -14,7 +14,7 @@ import { getTimeFormatter, timeUnit } from '../../../../utils/formatters'; import { fromQuery, history, toQuery } from '../../../../utils/url'; // @ts-ignore import Histogram from '../../../shared/charts/Histogram'; -import EmptyMessage from '../../../shared/EmptyMessage'; +import { EmptyMessage } from '../../../shared/EmptyMessage'; interface IChartPoint { sample?: IBucket['sample']; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/view.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/view.tsx index 97dcc67da090b..2f7c5a64a37cd 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/view.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/view.tsx @@ -15,7 +15,7 @@ import { WaterfallRequest } from '../../../store/reactReduxRequest/waterfall'; import { IUrlParams } from '../../../store/urlParams'; // @ts-ignore import TransactionCharts from '../../shared/charts/TransactionCharts'; -import EmptyMessage from '../../shared/EmptyMessage'; +import { EmptyMessage } from '../../shared/EmptyMessage'; // @ts-ignore import { KueryBar } from '../../shared/KueryBar'; // @ts-ignore diff --git a/x-pack/plugins/apm/public/components/shared/EmptyMessage.tsx b/x-pack/plugins/apm/public/components/shared/EmptyMessage.tsx index 274d063555d14..33a0c012c16b8 100644 --- a/x-pack/plugins/apm/public/components/shared/EmptyMessage.tsx +++ b/x-pack/plugins/apm/public/components/shared/EmptyMessage.tsx @@ -4,14 +4,20 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiEmptyPrompt } from '@elastic/eui'; +import { EuiEmptyPrompt, EuiEmptyPromptProps } from '@elastic/eui'; import React from 'react'; -function EmptyMessage({ +interface Props { + heading?: string; + subheading?: EuiEmptyPromptProps['body']; + hideSubheading?: boolean; +} + +const EmptyMessage: React.SFC = ({ heading = 'No data found.', subheading = 'Try another time range or reset the search filter.', hideSubheading = false -}) { +}) => { return ( ); -} +}; -// tslint:disable-next-line:no-default-export -export default EmptyMessage; +export { EmptyMessage }; diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/index.js b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.js index 0bec4149914d4..b7a7f5f567f7b 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/index.js +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.js @@ -10,7 +10,7 @@ import { isEmpty, get } from 'lodash'; import CodePreview from '../../shared/CodePreview'; import { Ellipsis } from '../../shared/Icons'; import { units, px } from '../../../style/variables'; -import EmptyMessage from '../../shared/EmptyMessage'; +import { EmptyMessage } from '../../shared/EmptyMessage'; import { EuiLink, EuiTitle } from '@elastic/eui'; const LibraryFrameToggle = styled.div` diff --git a/x-pack/plugins/apm/public/services/rest/apm.ts b/x-pack/plugins/apm/public/services/rest/apm.ts index 3a390492f8c72..d065be4fa28a2 100644 --- a/x-pack/plugins/apm/public/services/rest/apm.ts +++ b/x-pack/plugins/apm/public/services/rest/apm.ts @@ -7,7 +7,7 @@ // @ts-ignore import { camelizeKeys } from 'humps'; import { ServiceResponse } from 'x-pack/plugins/apm/server/lib/services/get_service'; -import { ServiceListItemResponse } from 'x-pack/plugins/apm/server/lib/services/get_services'; +import { IServiceListItem } from 'x-pack/plugins/apm/server/lib/services/get_services'; import { IDistributionResponse } from 'x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution'; import { Span } from 'x-pack/plugins/apm/typings/Span'; import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; @@ -58,7 +58,7 @@ export async function loadServiceList({ start, end, kuery -}: IUrlParams): Promise { +}: IUrlParams): Promise { return callApi({ pathname: `/api/apm/services`, query: { diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/serviceList.js b/x-pack/plugins/apm/public/store/reactReduxRequest/serviceList.tsx similarity index 59% rename from x-pack/plugins/apm/public/store/reactReduxRequest/serviceList.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/serviceList.tsx index 10175d3c507bb..ef5e59649b767 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/serviceList.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/serviceList.tsx @@ -5,19 +5,31 @@ */ import React from 'react'; +import { Request, RRRRender, RRRRenderResponse } from 'react-redux-request'; +import { IServiceListItem } from 'x-pack/plugins/apm/server/lib/services/get_services'; import { loadServiceList } from '../../services/rest/apm'; -import { Request } from 'react-redux-request'; +import { IReduxState } from '../rootReducer'; +import { IUrlParams } from '../urlParams'; +// @ts-ignore import { createInitialDataSelector } from './helpers'; const ID = 'serviceList'; -const INITIAL_DATA = []; +const INITIAL_DATA: IServiceListItem[] = []; const withInitialData = createInitialDataSelector(INITIAL_DATA); -export function getServiceList(state) { +export function getServiceList( + state: IReduxState +): RRRRenderResponse { return withInitialData(state.reactReduxRequest[ID]); } -export function ServiceListRequest({ urlParams, render }) { +export function ServiceListRequest({ + urlParams, + render +}: { + urlParams: IUrlParams; + render: RRRRender; +}) { const { start, end, kuery } = urlParams; if (!(start && end)) { diff --git a/x-pack/plugins/apm/server/lib/services/get_services.ts b/x-pack/plugins/apm/server/lib/services/get_services.ts index eeb39c256e8a3..6d2019e64c1db 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services.ts @@ -14,17 +14,15 @@ import { } from '../../../common/constants'; import { Setup } from '../helpers/setup_request'; -export interface ServiceListItemResponse { - service_name: string; - agent_name: string | undefined; - transactions_per_minute: number; - errors_per_minute: number; - avg_response_time: number; +export interface IServiceListItem { + serviceName: string; + agentName: string | undefined; + transactionsPerMinute: number; + errorsPerMinute: number; + avgResponseTime: number; } -export async function getServices( - setup: Setup -): Promise { +export async function getServices(setup: Setup): Promise { const { start, end, esFilterQuery, client, config } = setup; const params = { @@ -118,11 +116,11 @@ export async function getServices( const errorsPerMinute = totalErrors / deltaAsMinutes; return { - service_name: bucket.key, - agent_name: oc(bucket).agents.buckets[0].key(), - transactions_per_minute: transactionsPerMinute, - errors_per_minute: errorsPerMinute, - avg_response_time: bucket.avg.value + serviceName: bucket.key, + agentName: oc(bucket).agents.buckets[0].key(), + transactionsPerMinute, + errorsPerMinute, + avgResponseTime: bucket.avg.value }; }); } From d188597496a6ada0538dbf1d8780c724ee21c9f7 Mon Sep 17 00:00:00 2001 From: Jason Rhodes Date: Fri, 16 Nov 2018 21:43:58 -0500 Subject: [PATCH 07/95] Swallows errors on ml lookups that we know might fail (#25783) * Swallows errors on ml lookups that we know can fail * Adjusts when we swallow ml lookup errors, fixes async test --- .../__test__/get_anomaly_aggs.test.ts | 27 +++++++++++++++++++ .../get_anomaly_aggs.js | 9 ++++--- .../get_avg_response_time_anomalies.js | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts new file mode 100644 index 0000000000000..7ded075a7ae65 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// @ts-ignore +import { getAnomalyAggs } from '../get_anomaly_aggs'; + +test('getAnomalyAggs should swallow HTTP errors', () => { + const httpError = new Error('anomaly lookup failed') as any; + httpError.statusCode = 418; + const failClient = jest.fn(() => Promise.reject(httpError)); + + return expect(getAnomalyAggs({ client: failClient })).resolves.toEqual(null); +}); + +test('getAnomalyAggs should throw other errors', () => { + const otherError = new Error('anomaly lookup ASPLODED') as any; + const failClient = jest.fn(() => Promise.reject(otherError)); + + return expect( + getAnomalyAggs({ + client: failClient + }) + ).rejects.toThrow(otherError); +}); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs.js index 86fb84fd88871..cae78df06f725 100644 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs.js +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs.js @@ -62,10 +62,13 @@ export async function getAnomalyAggs({ try { const resp = await client('search', params); return resp.aggregations; - } catch (e) { - if (e.statusCode === 404) { + } catch (err) { + if ('statusCode' in err) { + // swallow HTTP errors because there are lots of reasons + // the ml index lookup may fail, and we're ok with that return null; } - throw e; + + throw err; } } diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_avg_response_time_anomalies.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_avg_response_time_anomalies.js index c6d411eb91884..3e950d919b6cc 100644 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_avg_response_time_anomalies.js +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_avg_response_time_anomalies.js @@ -34,7 +34,7 @@ export async function getAvgResponseTimeAnomalies({ if (!aggs) { return { - message: 'ml index does not exist' + message: 'Error reading machine learning index' }; } From 2ba0162d9fd3a82627ad57f6028d2045fb536b8a Mon Sep 17 00:00:00 2001 From: spalger Date: Sat, 17 Nov 2018 00:25:52 -0800 Subject: [PATCH 08/95] [ftr] only stub custom providers --- .../functional_test_runner.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/functional_test_runner/functional_test_runner.js b/src/functional_test_runner/functional_test_runner.js index d32ad172d99b3..e7edb63777c1b 100644 --- a/src/functional_test_runner/functional_test_runner.js +++ b/src/functional_test_runner/functional_test_runner.js @@ -59,15 +59,19 @@ export function createFunctionalTestRunner({ log, configFile, configOverrides }) async getTestStats() { return await this._run(async (config, coreProviders) => { - // replace the function of a provider so that it returns a promise-like object which - // never "resolves", essentially disabling all the services while still allowing us - // to load the test files and populate the mocha suites - const stubProvider = provider => ({ - ...provider, - fn: () => ({ - then: () => {} - }) - }); + // replace the function of custom service providers so that they return + // promise-like objects which never resolve, essentially disabling them + // allowing us to load the test files and populate the mocha suites + const stubProvider = provider => ( + coreProviders.includes(provider) + ? provider + : { + ...provider, + fn: () => ({ + then: () => {} + }) + } + ); const providers = new ProviderCollection(log, [ ...coreProviders, From 85a6ec5977e95396cdf598d7cfdec93cd63e8d49 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Sat, 17 Nov 2018 10:21:52 +0000 Subject: [PATCH 09/95] [ML] Fixes fill of minor markers in Single Metric Viewer (#25816) --- .../ml/public/timeseriesexplorer/_timeseriesexplorer.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss b/x-pack/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss index 7b5b74ce1005f..b4d58fbf8bda4 100644 --- a/x-pack/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss +++ b/x-pack/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss @@ -170,7 +170,7 @@ fill: $mchColorMajor; } - .anomaly-marker-value.minor { + .anomaly-marker.minor { fill: $mchColorMinor; } From d319bd3c421663028d98588b1f8ee452463a2602 Mon Sep 17 00:00:00 2001 From: spalger Date: Sun, 18 Nov 2018 15:25:22 -0800 Subject: [PATCH 10/95] [ci] skip build in packer_cache.sh, run optimizer instead, avoid timeout --- .ci/packer_cache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/packer_cache.sh b/.ci/packer_cache.sh index 05298b494f3d8..df35196294a81 100755 --- a/.ci/packer_cache.sh +++ b/.ci/packer_cache.sh @@ -3,12 +3,12 @@ # run setup script that gives us node, yarn, and bootstraps the project source "src/dev/ci_setup/setup.sh"; -# run the build for both oss and default distributions to warm the babel and optimizer caches -node scripts/build; - # cache es snapshots node scripts/es snapshot --download-only; +# run the optimizer to warn the babel and cache-loader caches +node scripts/kibana --logging.json=false --optimize; + # archive cacheable directories mkdir -p "$HOME/.kibana/bootstrap_cache" tar -cf "$HOME/.kibana/bootstrap_cache/master.tar" \ From cf4996ee3b9942e0c2ad0dbf2891d80a026b01de Mon Sep 17 00:00:00 2001 From: Marco Vettorello <1421091+markov00@users.noreply.github.com> Date: Mon, 19 Nov 2018 11:46:45 +0100 Subject: [PATCH 11/95] Fix vertical scroll on long legends (#23806) * Fix vertical scroll on long legends * Fix IE11 global visualize vertical bar --- src/ui/public/vislib/styles/_legend.less | 1 + src/ui/public/visualize/components/visualization.less | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/public/vislib/styles/_legend.less b/src/ui/public/vislib/styles/_legend.less index 92a5965452e9a..20fd0c42a429e 100644 --- a/src/ui/public/vislib/styles/_legend.less +++ b/src/ui/public/vislib/styles/_legend.less @@ -17,6 +17,7 @@ visualize-legend { overflow: hidden; flex-direction: row; padding-top: 5px; + height: 100%; .vislib-container--legend-left & { flex-direction: row-reverse; diff --git a/src/ui/public/visualize/components/visualization.less b/src/ui/public/visualize/components/visualization.less index 5ff9117a3313e..5bff1334c66f5 100644 --- a/src/ui/public/visualize/components/visualization.less +++ b/src/ui/public/visualize/components/visualization.less @@ -3,7 +3,7 @@ .visualize { display: flex; flex: 1 1 100%; - overflow-x: hidden; + overflow: hidden; } .visualization { @@ -15,7 +15,6 @@ position: relative; padding: 8px 8px 8px 8px; flex: 1 1 100%; - .k4tip { white-space: pre-line; } From 43fdd0f51a946919388480e198d69034997e893d Mon Sep 17 00:00:00 2001 From: Nox911 Date: Mon, 19 Nov 2018 13:50:56 +0300 Subject: [PATCH 12/95] Feature/translate monitoring elasticsearch and kibana (part_ 1) (#24717) * Translate monitoring-elasticsearch * Fix eslint errors * Fix errors and add provider * Fix issues * Fix issues * Add empty line at the end of the file * Update tests and enzyme_helpers * Update snapshots * Fix issues * Change FormattedMessage to intl.formatMessage for title attributes * Fix issues * Fix unit test --- .../components/elasticsearch/ccr/ccr.js | 83 +++++++++++--- .../components/elasticsearch/ccr/ccr.test.js | 4 +- .../__snapshots__/ccr_shard.test.js.snap | 14 ++- .../elasticsearch/ccr_shard/ccr_shard.js | 35 ++++-- .../elasticsearch/ccr_shard/ccr_shard.test.js | 6 +- .../elasticsearch/ccr_shard/status.js | 30 ++++-- .../elasticsearch/cluster_status/index.js | 40 +++++-- .../index_detail_status/index.js | 40 +++++-- .../elasticsearch/indices/indices.js | 102 +++++++++++++++--- .../indices/system_indices_checkbox.js | 8 +- .../ml_job_listing/status_icon.js | 13 ++- .../elasticsearch/node/status_icon.js | 13 ++- .../elasticsearch/node_detail_status/index.js | 41 +++++-- .../nodes/__tests__/cells.test.js | 8 +- .../components/elasticsearch/nodes/cells.js | 6 +- .../components/elasticsearch/nodes/nodes.js | 74 +++++++++++-- .../elasticsearch/shard_activity/progress.js | 8 +- .../shard_activity/recovery_index.js | 17 ++- .../shard_activity/shard_activity.js | 94 +++++++++++++--- .../elasticsearch/shard_activity/snapshot.js | 10 +- .../shard_activity/source_tooltip.js | 20 +++- .../shard_activity/total_time.js | 15 ++- .../components/elasticsearch/status_icon.js | 15 ++- .../components/kibana/cluster_status/index.js | 30 ++++-- .../components/kibana/detail_status/index.js | 20 +++- .../public/components/kibana/status_icon.js | 14 ++- .../elasticsearch/cluster_status/index.js | 3 +- .../elasticsearch/index_summary/index.js | 3 +- .../elasticsearch/node_summary/index.js | 3 +- .../directives/kibana/cluster_status/index.js | 3 +- .../public/directives/kibana/summary/index.js | 3 +- .../public/views/elasticsearch/ccr/index.js | 5 +- .../views/elasticsearch/ccr/shard/index.js | 3 +- 33 files changed, 647 insertions(+), 136 deletions(-) diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.js b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.js index f05496d9adeb7..3ddbe31bcd373 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.js @@ -18,12 +18,13 @@ import { } from '@elastic/eui'; import './ccr.css'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; function toSeconds(ms) { return Math.floor(ms / 1000) + 's'; } -export class Ccr extends Component { +class CcrUI extends Component { constructor(props) { super(props); this.state = { @@ -32,6 +33,7 @@ export class Ccr extends Component { } toggleShards(index, shards) { + const { intl } = this.props; const itemIdToExpandedRowMap = { ...this.state.itemIdToExpandedRowMap }; @@ -54,7 +56,10 @@ export class Ccr extends Component { columns={[ { field: 'shardId', - name: 'Shard', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.shardsTable.shardColumnTitle', + defaultMessage: 'Shard' + }), render: shardId => { return ( @@ -68,7 +73,10 @@ export class Ccr extends Component { }, { field: 'syncLagOps', - name: 'Sync Lag (ops)', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.shardsTable.syncLagOpsColumnTitle', + defaultMessage: 'Sync Lag (ops)' + }), render: (syncLagOps, data) => ( {syncLagOps} @@ -78,9 +86,25 @@ export class Ccr extends Component { type="iInCircle" content={( - Leader lag: {data.syncLagOpsLeader} + + +
- Follower lag: {data.syncLagOpsFollower} + + +
)} position="right" @@ -90,16 +114,25 @@ export class Ccr extends Component { }, { field: 'syncLagTime', - name: 'Last fetch time', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.shardsTable.lastFetchTimeColumnTitle', + defaultMessage: 'Last fetch time' + }), render: syncLagTime => {toSeconds(syncLagTime)} }, { field: 'opsSynced', - name: 'Ops synced' + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.shardsTable.opsSyncedColumnTitle', + defaultMessage: 'Ops synced' + }), }, { field: 'error', - name: 'Error', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.shardsTable.errorColumnTitle', + defaultMessage: 'Error' + }), render: error => ( {error} @@ -116,7 +149,7 @@ export class Ccr extends Component { } renderTable() { - const { data } = this.props; + const { data, intl } = this.props; const items = data; let pagination = { @@ -141,7 +174,10 @@ export class Ccr extends Component { columns={[ { field: 'index', - name: 'Index', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.ccrListingTable.indexColumnTitle', + defaultMessage: 'Index' + }), sortable: true, render: (index, { shards }) => { const expanded = !!this.state.itemIdToExpandedRowMap[index]; @@ -157,28 +193,43 @@ export class Ccr extends Component { { field: 'follows', sortable: true, - name: 'Follows' + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.ccrListingTable.followsColumnTitle', + defaultMessage: 'Follows' + }), }, { field: 'syncLagOps', sortable: true, - name: 'Sync Lag (ops)', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.ccrListingTable.syncLagOpsColumnTitle', + defaultMessage: 'Sync Lag (ops)' + }), }, { field: 'syncLagTime', sortable: true, - name: 'Last fetch time', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.ccrListingTable.lastFetchTimeColumnTitle', + defaultMessage: 'Last fetch time' + }), render: syncLagTime => {toSeconds(syncLagTime)} }, { field: 'opsSynced', sortable: true, - name: 'Ops synced' + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.ccrListingTable.opsSyncedColumnTitle', + defaultMessage: 'Ops synced' + }), }, { field: 'error', sortable: true, - name: 'Error', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccr.ccrListingTable.errorColumnTitle', + defaultMessage: 'Error' + }), render: error => ( {error} @@ -209,3 +260,5 @@ export class Ccr extends Component { ); } } + +export const Ccr = injectI18n(CcrUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.test.js b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.test.js index 8df42974c6633..838d3fcb5c6c4 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.test.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from '../../../../../../test_utils/enzyme_helpers'; import { Ccr } from './ccr'; describe('Ccr', () => { @@ -67,7 +67,7 @@ describe('Ccr', () => { } ]; - const component = shallow(); + const component = shallowWithIntl(); expect(component).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/__snapshots__/ccr_shard.test.js.snap b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/__snapshots__/ccr_shard.test.js.snap index 70051f82611c5..aa5059ed84e16 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/__snapshots__/ccr_shard.test.js.snap +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/__snapshots__/ccr_shard.test.js.snap @@ -16,7 +16,11 @@ exports[`CcrShard that is renders an exception properly 1`] = ` color="danger" component="span" > - Errors + @@ -63,7 +67,7 @@ exports[`CcrShard that it renders normally 1`] = ` -

- Advanced +

} diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/ccr_shard.js b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/ccr_shard.js index 552b00dbeb8f3..872bfd94ca8fc 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/ccr_shard.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/ccr_shard.js @@ -22,8 +22,9 @@ import { import { MonitoringTimeseriesContainer } from '../../chart'; import { Status } from './status'; import { formatDateTimeLocal } from '../../../../common/formatting'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; -export class CcrShard extends PureComponent { +class CcrShardUI extends PureComponent { renderCharts() { const { metrics } = this.props; const seriesToShow = [ @@ -49,14 +50,19 @@ export class CcrShard extends PureComponent { } renderErrors() { - const { stat } = this.props; + const { stat, intl } = this.props; if (stat.read_exceptions && stat.read_exceptions.length > 0) { return (

- Errors + + +

@@ -64,11 +70,17 @@ export class CcrShard extends PureComponent { items={stat.read_exceptions} columns={[ { - name: 'Type', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccrShard.errorsTable.typeColumnTitle', + defaultMessage: 'Type' + }), field: 'exception.type' }, { - name: 'Reason', + name: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccrShard.errorsTable.reasonColumnTitle', + defaultMessage: 'Reason' + }), field: 'exception.reason', width: '75%' } @@ -88,7 +100,16 @@ export class CcrShard extends PureComponent { return (

Advanced

} + buttonContent={( + +

+ +

+
+ )} paddingSize="l" > @@ -123,3 +144,5 @@ export class CcrShard extends PureComponent { ); } } + +export const CcrShard = injectI18n(CcrShardUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/ccr_shard.test.js b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/ccr_shard.test.js index 40a0f32931d3e..cbd1ce79a383c 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/ccr_shard.test.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/ccr_shard.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from '../../../../../../test_utils/enzyme_helpers'; import { CcrShard } from './ccr_shard'; describe('CcrShard', () => { @@ -45,7 +45,7 @@ describe('CcrShard', () => { }; test('that it renders normally', () => { - const component = shallow(); + const component = shallowWithIntl(); expect(component).toMatchSnapshot(); }); @@ -63,7 +63,7 @@ describe('CcrShard', () => { } }; - const component = shallow(); + const component = shallowWithIntl(); expect(component.find('EuiPanel').get(0)).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/status.js b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/status.js index 969f6fe2fc45e..89da6c6d4fac3 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/status.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/status.js @@ -7,8 +7,9 @@ import React from 'react'; import { SummaryStatus } from '../../summary_status'; import { formatMetric } from '../../../lib/format_number'; +import { injectI18n } from '@kbn/i18n/react'; -export function Status({ stat, formattedLeader, oldestStat }) { +function StatusUI({ stat, formattedLeader, oldestStat, intl }) { const { follower_index: followerIndex, shard_id: shardId, @@ -23,27 +24,42 @@ export function Status({ stat, formattedLeader, oldestStat }) { const metrics = [ { - label: 'Follower Index', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccrShard.status.followerIndexLabel', + defaultMessage: 'Follower Index', + }), value: followerIndex, dataTestSubj: 'followerIndex' }, { - label: 'Shard Id', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccrShard.status.shardIdLabel', + defaultMessage: 'Shard Id', + }), value: shardId, dataTestSubj: 'shardId' }, { - label: 'Leader Index', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccrShard.status.leaderIndexLabel', + defaultMessage: 'Leader Index', + }), value: formattedLeader, dataTestSubj: 'leaderIndex' }, { - label: 'Ops Synced', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccrShard.status.opsSyncedLabel', + defaultMessage: 'Ops Synced', + }), value: formatMetric(operationsReceived - oldestOperationsReceived, 'int_commas'), dataTestSubj: 'operationsReceived' }, { - label: 'Failed Fetches', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.ccrShard.status.failedFetchesLabel', + defaultMessage: 'Failed Fetches', + }), value: formatMetric(failedFetches - oldestFailedFetches, 'int_commas'), dataTestSubj: 'failedFetches' }, @@ -56,3 +72,5 @@ export function Status({ stat, formattedLeader, oldestStat }) { /> ); } + +export const Status = injectI18n(StatusUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/cluster_status/index.js b/x-pack/plugins/monitoring/public/components/elasticsearch/cluster_status/index.js index 9fc2ba4c1e8e3..a7d007e4d22f1 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/cluster_status/index.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/cluster_status/index.js @@ -8,8 +8,9 @@ import React from 'react'; import { SummaryStatus } from '../../summary_status'; import { ElasticsearchStatusIcon } from '../status_icon'; import { formatMetric } from '../../../lib/format_number'; +import { injectI18n } from '@kbn/i18n/react'; -export function ClusterStatus({ stats }) { +function ClusterStatusUI({ stats, intl }) { const { dataSize, nodesCount, @@ -24,37 +25,58 @@ export function ClusterStatus({ stats }) { const metrics = [ { - label: 'Nodes', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.clusterStatus.nodesLabel', + defaultMessage: 'Nodes', + }), value: nodesCount, dataTestSubj: 'nodesCount' }, { - label: 'Indices', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.clusterStatus.indicesLabel', + defaultMessage: 'Indices', + }), value: indicesCount, dataTestSubj: 'indicesCount' }, { - label: 'Memory', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.clusterStatus.memoryLabel', + defaultMessage: 'Memory', + }), value: formatMetric(memUsed, 'byte') + ' / ' + formatMetric(memMax, 'byte'), dataTestSubj: 'memory' }, { - label: 'Total Shards', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.clusterStatus.totalShardsLabel', + defaultMessage: 'Total Shards', + }), value: totalShards, dataTestSubj: 'totalShards' }, { - label: 'Unassigned Shards', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.clusterStatus.unassignedShardsLabel', + defaultMessage: 'Unassigned Shards', + }), value: unassignedShards, dataTestSubj: 'unassignedShards' }, { - label: 'Documents', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.clusterStatus.documentsLabel', + defaultMessage: 'Documents', + }), value: formatMetric(documentCount, 'int_commas'), dataTestSubj: 'documentCount' }, { - label: 'Data', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.clusterStatus.dataLabel', + defaultMessage: 'Data', + }), value: formatMetric(dataSize, 'byte'), dataTestSubj: 'dataSize' } @@ -73,3 +95,5 @@ export function ClusterStatus({ stats }) { /> ); } + +export const ClusterStatus = injectI18n(ClusterStatusUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/index_detail_status/index.js b/x-pack/plugins/monitoring/public/components/elasticsearch/index_detail_status/index.js index 2eb378b298085..55e65608b81f7 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/index_detail_status/index.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/index_detail_status/index.js @@ -8,8 +8,9 @@ import React, { Fragment } from 'react'; import { SummaryStatus } from '../../summary_status'; import { ElasticsearchStatusIcon } from '../status_icon'; import { formatMetric } from '../../../lib/format_number'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; -export function IndexDetailStatus({ stats }) { +function IndexDetailStatusUI({ stats, intl }) { const { dataSize, documents: documentCount, @@ -20,27 +21,42 @@ export function IndexDetailStatus({ stats }) { const metrics = [ { - label: 'Total', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.indexDetailStatus.totalTitle', + defaultMessage: 'Total', + }), value: formatMetric(dataSize.total, '0.0 b'), dataTestSubj: 'dataSize' }, { - label: 'Primaries', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.indexDetailStatus.primariesTitle', + defaultMessage: 'Primaries', + }), value: formatMetric(dataSize.primaries, '0.0 b'), dataTestSubj: 'dataSizePrimaries' }, { - label: 'Documents', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.indexDetailStatus.documentsTitle', + defaultMessage: 'Documents', + }), value: formatMetric(documentCount, '0.[0]a'), dataTestSubj: 'documentCount' }, { - label: 'Total Shards', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.indexDetailStatus.totalShardsTitle', + defaultMessage: 'Total Shards', + }), value: formatMetric(totalShards, 'int_commas'), dataTestSubj: 'totalShards' }, { - label: 'Unassigned Shards', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.indexDetailStatus.unassignedShardsTitle', + defaultMessage: 'Unassigned Shards', + }), value: formatMetric(unassignedShards, 'int_commas'), dataTestSubj: 'unassignedShards' } @@ -48,7 +64,15 @@ export function IndexDetailStatus({ stats }) { const IconComponent = ({ status }) => ( - Health: + + ) + }} + /> ); @@ -61,3 +85,5 @@ export function IndexDetailStatus({ stats }) { /> ); } + +export const IndexDetailStatus = injectI18n(IndexDetailStatusUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/indices/indices.js b/x-pack/plugins/monitoring/public/components/elasticsearch/indices/indices.js index bd497142ad846..ba41ea8fb82d6 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/indices/indices.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/indices/indices.js @@ -15,18 +15,57 @@ import { MonitoringTable } from '../../table'; import { EuiLink } from '@elastic/eui'; import { KuiTableRowCell, KuiTableRow } from '@kbn/ui-framework/components'; import { SystemIndicesCheckbox } from './system_indices_checkbox'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; const filterFields = ['name', 'status']; const columns = [ - { title: 'Name', sortKey: 'name', secondarySortOrder: SORT_ASCENDING }, - { title: 'Status', sortKey: 'status_sort', sortOrder: SORT_DESCENDING }, // default sort: red, then yellow, then green - { title: 'Document Count', sortKey: 'doc_count' }, - { title: 'Data', sortKey: 'data_size' }, - { title: 'Index Rate', sortKey: 'index_rate' }, - { title: 'Search Rate', sortKey: 'search_rate' }, - { title: 'Unassigned Shards', sortKey: 'unassigned_shards' } + { + title: i18n.translate('xpack.monitoring.elasticsearch.indices.nameTitle', { + defaultMessage: 'Name', + }), + sortKey: 'name', + secondarySortOrder: SORT_ASCENDING + }, + { + title: i18n.translate('xpack.monitoring.elasticsearch.indices.statusTitle', { + defaultMessage: 'Status', + }), + sortKey: 'status_sort', + sortOrder: SORT_DESCENDING // default sort: red, then yellow, then green + }, + { + title: i18n.translate('xpack.monitoring.elasticsearch.indices.documentCountTitle', { + defaultMessage: 'Document Count', + }), + sortKey: 'doc_count' + }, + { + title: i18n.translate('xpack.monitoring.elasticsearch.indices.dataTitle', { + defaultMessage: 'Data', + }), + sortKey: 'data_size' + }, + { + title: i18n.translate('xpack.monitoring.elasticsearch.indices.indexRateTitle', { + defaultMessage: 'Index Rate', + }), + sortKey: 'index_rate' + }, + { + title: i18n.translate('xpack.monitoring.elasticsearch.indices.searchRateTitle', { + defaultMessage: 'Search Rate', + }), + sortKey: 'search_rate' + }, + { + title: i18n.translate('xpack.monitoring.elasticsearch.indices.unassignedShardsTitle', { + defaultMessage: 'Unassigned Shards', + }), + sortKey: 'unassigned_shards' + } ]; -const IndexRow = ({ status, ...props }) => ( +const IndexRow = injectI18n(({ status, ...props }) => ( ( -
+
  {capitalize(status)}
@@ -58,26 +103,45 @@ const IndexRow = ({ status, ...props }) => ( {formatMetric(get(props, 'unassigned_shards'), '0')} -); +)); const getNoDataMessage = filterText => { + const howToShowSystemIndicesDescription = ( + + ); if (filterText) { return (

- There are no indices that match your selection with the filter [{filterText.trim()}]. - Try changing the filter or the time range selection. +

- If you are looking for system indices (e.g., .kibana), try checking ‘Show system indices’. + {howToShowSystemIndicesDescription}

); } return (
-

There are no indices that match your selections. Try changing the time range selection.

-

If you are looking for system indices (e.g., .kibana), try checking ‘Show system indices’.

+

+ +

+

+ {howToShowSystemIndicesDescription} +

); }; @@ -90,7 +154,7 @@ const renderToolBarSection = ({ showSystemIndices, toggleShowSystemIndices, ...p /> ); -export function ElasticsearchIndices({ clusterStatus, indices, ...props }) { +function ElasticsearchIndicesUI({ clusterStatus, indices, intl, ...props }) { return ( @@ -102,7 +166,10 @@ export function ElasticsearchIndices({ clusterStatus, indices, ...props }) { sortKey={props.sortKey} sortOrder={props.sortOrder} onNewState={props.onNewState} - placeholder="Filter Indices..." + placeholder={intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.indices.monitoringTablePlaceholder', + defaultMessage: 'Filter Indices…', + })} filterFields={filterFields} renderToolBarSections={renderToolBarSection} columns={columns} @@ -115,3 +182,4 @@ export function ElasticsearchIndices({ clusterStatus, indices, ...props }) { ); } +export const ElasticsearchIndices = injectI18n(ElasticsearchIndicesUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/indices/system_indices_checkbox.js b/x-pack/plugins/monitoring/public/components/elasticsearch/indices/system_indices_checkbox.js index 4620d144f24bc..4d341f00b4c93 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/indices/system_indices_checkbox.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/indices/system_indices_checkbox.js @@ -13,6 +13,7 @@ import { EuiSwitch, } from '@elastic/eui'; import { TABLE_ACTION_RESET_PAGING } from '../../../../common/constants'; +import { FormattedMessage } from '@kbn/i18n/react'; export class SystemIndicesCheckbox extends React.Component { constructor(props) { @@ -31,7 +32,12 @@ export class SystemIndicesCheckbox extends React.Component { + )} onChange={this.toggleShowSystemIndices} checked={this.state.showSystemIndices} /> diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/ml_job_listing/status_icon.js b/x-pack/plugins/monitoring/public/components/elasticsearch/ml_job_listing/status_icon.js index 58063a35434bd..110cfc9f06e2a 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/ml_job_listing/status_icon.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/ml_job_listing/status_icon.js @@ -6,8 +6,9 @@ import React from 'react'; import { StatusIcon } from 'plugins/monitoring/components/status_icon'; +import { injectI18n } from '@kbn/i18n/react'; -export function MachineLearningJobStatusIcon({ status }) { +export function MachineLearningJobStatusIconUI({ status, intl }) { const type = (() => { const statusKey = status.toUpperCase(); @@ -24,6 +25,14 @@ export function MachineLearningJobStatusIcon({ status }) { })(); return ( - + ); } + +export const MachineLearningJobStatusIcon = injectI18n(MachineLearningJobStatusIconUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/node/status_icon.js b/x-pack/plugins/monitoring/public/components/elasticsearch/node/status_icon.js index 5a7ed469eba35..73d9abcf59904 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/node/status_icon.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/node/status_icon.js @@ -6,11 +6,20 @@ import React from 'react'; import { StatusIcon } from '../../status_icon'; +import { injectI18n } from '@kbn/i18n/react'; -export function NodeStatusIcon({ isOnline, status }) { +export function NodeStatusIconUI({ isOnline, status, intl }) { const type = isOnline ? StatusIcon.TYPES.GREEN : StatusIcon.TYPES.GRAY; return ( - + ); } + +export const NodeStatusIcon = injectI18n(NodeStatusIconUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js b/x-pack/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js index 099114baa253c..a901a36c7325a 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js @@ -8,8 +8,9 @@ import React, { Fragment } from 'react'; import { SummaryStatus } from '../../summary_status'; import { NodeStatusIcon } from '../node'; import { formatMetric } from '../../../lib/format_number'; +import { injectI18n } from '@kbn/i18n/react'; -export function NodeDetailStatus({ stats }) { +function NodeDetailStatusUI({ stats, intl }) { const { transport_address: transportAddress, usedHeap, @@ -29,37 +30,59 @@ export function NodeDetailStatus({ stats }) { dataTestSubj: 'transportAddress' }, { - label: 'JVM Heap', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.nodeDetailStatus.jvmHeapLabel', + defaultMessage: '{javaVirtualMachine} Heap' }, { + javaVirtualMachine: 'JVM' + }), value: formatMetric(usedHeap, '0,0.[00]', '%', { prependSpace: false }), dataTestSubj: 'jvmHeap' }, { - label: 'Free Disk Space', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.nodeDetailStatus.freeDiskSpaceLabel', + defaultMessage: 'Free Disk Space', + }), value: formatMetric(freeSpace, '0.0 b'), dataTestSubj: 'freeDiskSpace' }, { - label: 'Documents', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.nodeDetailStatus.documentsLabel', + defaultMessage: 'Documents', + }), value: formatMetric(documents, '0.[0]a'), dataTestSubj: 'documentCount' }, { - label: 'Data', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.nodeDetailStatus.dataLabel', + defaultMessage: 'Data', + }), value: formatMetric(dataSize, '0.0 b'), dataTestSubj: 'dataSize' }, { - label: 'Indices', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.nodeDetailStatus.indicesLabel', + defaultMessage: 'Indices', + }), value: formatMetric(indexCount, 'int_commas'), dataTestSubj: 'indicesCount' }, { - label: 'Shards', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.nodeDetailStatus.shardsLabel', + defaultMessage: 'Shards', + }), value: formatMetric(totalShards, 'int_commas'), dataTestSubj: 'shardsCount' }, { - label: 'Type', + label: intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.nodeDetailStatus.typeLabel', + defaultMessage: 'Type', + }), value: nodeTypeLabel, dataTestSubj: 'nodeType' } @@ -81,3 +104,5 @@ export function NodeDetailStatus({ stats }) { /> ); } + +export const NodeDetailStatus = injectI18n(NodeDetailStatusUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/cells.test.js b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/cells.test.js index 39a7b2e62307a..bdd453bb976cf 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/cells.test.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/cells.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { render } from 'enzyme'; +import { renderWithIntl } from '../../../../../../../test_utils/enzyme_helpers'; import { MetricCell } from '../cells'; describe('Node Listing Metric Cell', () => { @@ -28,7 +28,7 @@ describe('Node Listing Metric Cell', () => { summary: { minVal: 0, maxVal: 2, lastVal: 0, slope: -1 } } }; - expect(render()).toMatchSnapshot(); + expect(renderWithIntl()).toMatchSnapshot(); }); it('should format a non-percentage metric', () => { @@ -55,11 +55,11 @@ describe('Node Listing Metric Cell', () => { } } }; - expect(render()).toMatchSnapshot(); + expect(renderWithIntl()).toMatchSnapshot(); }); it('should format N/A as the metric for an offline node', () => { const props = { isOnline: false }; - expect(render()).toMatchSnapshot(); + expect(renderWithIntl()).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.js b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.js index a6faa0433351f..8fb336a8fc85e 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.js @@ -8,12 +8,16 @@ import React from 'react'; import { get } from 'lodash'; import { formatMetric } from '../../../lib/format_number'; import { KuiTableRowCell } from '@kbn/ui-framework/components'; +import { FormattedMessage } from '@kbn/i18n/react'; function OfflineCell() { return (
- N/A +
); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/nodes.js b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/nodes.js index 7129f7c09dc8e..9f05ccf50ed15 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/nodes.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/nodes.js @@ -14,25 +14,72 @@ import { MonitoringTable } from '../../table'; import { MetricCell, OfflineCell } from './cells'; import { EuiLink, EuiToolTip } from '@elastic/eui'; import { KuiTableRowCell, KuiTableRow } from '@kbn/ui-framework/components'; +import { i18n } from '@kbn/i18n'; +import { injectI18n } from '@kbn/i18n/react'; const filterFields = ['name']; const getColumns = showCgroupMetricsElasticsearch => { const cols = []; - cols.push({ title: 'Name', sortKey: 'name', sortOrder: SORT_ASCENDING }); - cols.push({ title: 'Status', sortKey: 'isOnline' }); + cols.push({ + title: i18n.translate('xpack.monitoring.elasticsearch.nodes.nameColumnTitle', { + defaultMessage: 'Name', + }), + sortKey: 'name', + sortOrder: SORT_ASCENDING + }); + cols.push({ + title: i18n.translate('xpack.monitoring.elasticsearch.nodes.statusColumnTitle', { + defaultMessage: 'Status', + }), + sortKey: 'isOnline' + }); + const cpuUsageColumnTitle = i18n.translate('xpack.monitoring.elasticsearch.nodes.cpuUsageColumnTitle', { + defaultMessage: 'CPU Usage', + }); if (showCgroupMetricsElasticsearch) { - cols.push({ title: 'CPU Usage', sortKey: 'node_cgroup_quota' }); cols.push({ - title: 'CPU Throttling', + title: cpuUsageColumnTitle, + sortKey: 'node_cgroup_quota' + }); + cols.push({ + title: i18n.translate('xpack.monitoring.elasticsearch.nodes.cpuThrottlingColumnTitle', { + defaultMessage: 'CPU Throttling', + }), sortKey: 'node_cgroup_throttled' }); } else { - cols.push({ title: 'CPU Usage', sortKey: 'node_cpu_utilization' }); - cols.push({ title: 'Load Average', sortKey: 'node_load_average' }); + cols.push({ + title: cpuUsageColumnTitle, + sortKey: 'node_cpu_utilization' + }); + cols.push({ + title: i18n.translate('xpack.monitoring.elasticsearch.nodes.loadAverageColumnTitle', { + defaultMessage: 'Load Average', + }), + sortKey: 'node_load_average' + }); } - cols.push({ title: 'JVM Memory', sortKey: 'node_jvm_mem_percent' }); - cols.push({ title: 'Disk Free Space', sortKey: 'node_free_space' }); - cols.push({ title: 'Shards', sortKey: 'shardCount' }); + cols.push({ + title: i18n.translate('xpack.monitoring.elasticsearch.nodes.jvmMemoryColumnTitle', { + defaultMessage: '{javaVirtualMachine} Memory', + values: { + javaVirtualMachine: 'JVM' + } + }), + sortKey: 'node_jvm_mem_percent' + }); + cols.push({ + title: i18n.translate('xpack.monitoring.elasticsearch.nodes.diskFreeSpaceColumnTitle', { + defaultMessage: 'Disk Free Space', + }), + sortKey: 'node_free_space' + }); + cols.push({ + title: i18n.translate('xpack.monitoring.elasticsearch.nodes.shardsColumnTitle', { + defaultMessage: 'Shards', + }), + sortKey: 'shardCount' + }); return cols; }; @@ -154,7 +201,7 @@ const nodeRowFactory = showCgroupMetricsElasticsearch => { }; }; -export function ElasticsearchNodes({ clusterStatus, nodes, showCgroupMetricsElasticsearch, ...props }) { +function ElasticsearchNodesUI({ clusterStatus, nodes, showCgroupMetricsElasticsearch, intl, ...props }) { const columns = getColumns(showCgroupMetricsElasticsearch); return ( @@ -169,7 +216,10 @@ export function ElasticsearchNodes({ clusterStatus, nodes, showCgroupMetricsElas sortKey={props.sortKey} sortOrder={props.sortOrder} onNewState={props.onNewState} - placeholder="Filter Nodes..." + placeholder={intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.nodes.monitoringTablePlaceholder', + defaultMessage: 'Filter Nodes…', + })} filterFields={filterFields} columns={columns} rowComponent={nodeRowFactory(showCgroupMetricsElasticsearch)} @@ -177,3 +227,5 @@ export function ElasticsearchNodes({ clusterStatus, nodes, showCgroupMetricsElas
); } + +export const ElasticsearchNodes = injectI18n(ElasticsearchNodesUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/progress.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/progress.js index c014b41785e03..b40938ba3a96a 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/progress.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/progress.js @@ -5,6 +5,7 @@ */ import React, { Fragment } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; export const FilesProgress = ({ filesPercent, filesDone, filesTotal }) => { return ( @@ -30,6 +31,11 @@ export const TranslogProgress = ({ hasTranslog, translogPercent, translogDone, t {translogPercent}
{translogDone} / {translogTotal} - ) : 'n/a'; + ) : ( + + ); }; diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/recovery_index.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/recovery_index.js index f33401f06d655..45c1a432a491d 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/recovery_index.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/recovery_index.js @@ -7,6 +7,7 @@ import React, { Fragment } from 'react'; import { EuiLink } from '@elastic/eui'; import { Snapshot } from './snapshot'; +import { FormattedMessage } from '@kbn/i18n/react'; export const RecoveryIndex = (props) => { const { name, shard, relocationType } = props; @@ -14,8 +15,20 @@ export const RecoveryIndex = (props) => { return ( {name}
- Shard: {shard}
- Recovery type: {relocationType} +
+
diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/shard_activity.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/shard_activity.js index eec1e8ec49542..b41424bc6620f 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/shard_activity.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/shard_activity.js @@ -18,15 +18,52 @@ import { TotalTime } from './total_time'; import { SourceDestination } from './source_destination'; import { FilesProgress, BytesProgress, TranslogProgress } from './progress'; import { parseProps } from './parse_props'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; const columns = [ - { title: 'Index', sortKey: null }, - { title: 'Stage', sortKey: null }, - { title: 'Total Time', sortKey: null }, - { title: 'Source / Destination', sortKey: null }, - { title: 'Files', sortKey: null }, - { title: 'Bytes', sortKey: null }, - { title: 'Translog', sortKey: null } + { + title: i18n.translate('xpack.monitoring.kibana.shardActivity.indexTitle', { + defaultMessage: 'Index' + }), + sortKey: null + }, + { + title: i18n.translate('xpack.monitoring.kibana.shardActivity.stageTitle', { + defaultMessage: 'Stage' + }), + sortKey: null + }, + { + title: i18n.translate('xpack.monitoring.kibana.shardActivity.totalTimeTitle', { + defaultMessage: 'Total Time' + }), + sortKey: null + }, + { + title: i18n.translate('xpack.monitoring.kibana.shardActivity.sourceDestinationTitle', { + defaultMessage: 'Source / Destination' + }), + sortKey: null + }, + { + title: i18n.translate('xpack.monitoring.kibana.shardActivity.filesTitle', { + defaultMessage: 'Files' + }), + sortKey: null + }, + { + title: i18n.translate('xpack.monitoring.kibana.shardActivity.bytesTitle', { + defaultMessage: 'Bytes' + }), + sortKey: null + }, + { + title: i18n.translate('xpack.monitoring.kibana.shardActivity.translogTitle', { + defaultMessage: 'Translog' + }), + sortKey: null + } ]; const ActivityRow = props => ( @@ -57,7 +94,12 @@ const ToggleCompletedSwitch = ({ toggleHistory, showHistory }) => ( + )} onChange={toggleHistory} checked={showHistory} /> @@ -65,7 +107,7 @@ const ToggleCompletedSwitch = ({ toggleHistory, showHistory }) => ( ); -export class ShardActivity extends React.Component { +class ShardActivityUI extends React.Component { constructor(props) { super(props); this.getNoDataMessage = this.getNoDataMessage.bind(this); @@ -73,12 +115,31 @@ export class ShardActivity extends React.Component { getNoDataMessage() { if (this.props.showShardActivityHistory) { - return 'There are no historical shard activity records for the selected time range.'; + return this.props.intl.formatMessage({ + id: 'xpack.monitoring.elasticsearch.shardActivity.noDataMessage', + defaultMessage: 'There are no historical shard activity records for the selected time range.' + }); } return ( - There are no active shard recoveries for this cluster.
- Try viewing completed recoveries. +
+ + + + ) + }} + />
); } @@ -102,7 +163,12 @@ export class ShardActivity extends React.Component { -

Shard Activity

+

+ +

@@ -120,3 +186,5 @@ export class ShardActivity extends React.Component { ); } } + +export const ShardActivity = injectI18n(ShardActivityUI); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/snapshot.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/snapshot.js index be7b5daece091..ece2fae9b7a7a 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/snapshot.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/snapshot.js @@ -5,11 +5,19 @@ */ import React, { Fragment } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; export const Snapshot = ({ isSnapshot, repo, snapshot }) => { return isSnapshot ? ( - Repo: {repo} / Snapshot: {snapshot} + ) : null; }; diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/source_tooltip.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/source_tooltip.js index 440cf56fde33f..0325d077cab82 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/source_tooltip.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/source_tooltip.js @@ -7,6 +7,7 @@ import React, { Fragment } from 'react'; import { EuiLink } from '@elastic/eui'; import { Tooltip } from 'plugins/monitoring/components/tooltip'; +import { FormattedMessage } from '@kbn/i18n/react'; export const SourceTooltip = ({ isCopiedFromPrimary, sourceTransportAddress, children }) => { if (!sourceTransportAddress) { @@ -17,7 +18,24 @@ export const SourceTooltip = ({ isCopiedFromPrimary, sourceTransportAddress, chi {sourceTransportAddress}
- Copied from { isCopiedFromPrimary ? 'primary' : 'replica' } shard + + ) : ( + + ), + }} + />
); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/total_time.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/total_time.js index c55531dfdee7c..a456646218f06 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/total_time.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/total_time.js @@ -7,10 +7,23 @@ import React from 'react'; import { EuiLink } from '@elastic/eui'; import { Tooltip } from 'plugins/monitoring/components/tooltip'; +import { FormattedMessage } from '@kbn/i18n/react'; export const TotalTime = ({ startTime, totalTime }) => { return ( - + + } + placement="bottom" + trigger="hover" + > {totalTime} ); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/status_icon.js b/x-pack/plugins/monitoring/public/components/elasticsearch/status_icon.js index 623fbbfde30a6..0015071d08228 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/status_icon.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/status_icon.js @@ -6,14 +6,25 @@ import React from 'react'; import { StatusIcon } from '../status_icon'; +import { injectI18n } from '@kbn/i18n/react'; -export function ElasticsearchStatusIcon({ status }) { +function ElasticsearchStatusIconUI({ intl, status }) { const type = (() => { const statusKey = status.toUpperCase(); return StatusIcon.TYPES[statusKey] || StatusIcon.TYPES.GRAY; })(); return ( - + ); } + +export const ElasticsearchStatusIcon = injectI18n(ElasticsearchStatusIconUI); diff --git a/x-pack/plugins/monitoring/public/components/kibana/cluster_status/index.js b/x-pack/plugins/monitoring/public/components/kibana/cluster_status/index.js index 20fa1fcbdee00..28b2dbbc87ca6 100644 --- a/x-pack/plugins/monitoring/public/components/kibana/cluster_status/index.js +++ b/x-pack/plugins/monitoring/public/components/kibana/cluster_status/index.js @@ -8,8 +8,9 @@ import React from 'react'; import { SummaryStatus } from '../../summary_status'; import { KibanaStatusIcon } from '../status_icon'; import { formatMetric } from '../../../lib/format_number'; +import { injectI18n } from '@kbn/i18n/react'; -export function ClusterStatus({ stats }) { +function ClusterStatusUI({ stats, intl }) { const { concurrent_connections: connections, count: instances, @@ -22,27 +23,42 @@ export function ClusterStatus({ stats }) { const metrics = [ { - label: 'Instances', + label: intl.formatMessage({ + id: 'xpack.monitoring.kibana.clusterStatus.instancesLabel', + defaultMessage: 'Instances' + }), value: instances, dataTestSubj: 'instances' }, { - label: 'Memory', + label: intl.formatMessage({ + id: 'xpack.monitoring.kibana.clusterStatus.memoryLabel', + defaultMessage: 'Memory' + }), value: formatMetric(memSize, 'byte') + ' / ' + formatMetric(memLimit, 'byte'), dataTestSubj: 'memory' }, { - label: 'Requests', + label: intl.formatMessage({ + id: 'xpack.monitoring.kibana.clusterStatus.requestsLabel', + defaultMessage: 'Requests' + }), value: requests, dataTestSubj: 'requests' }, { - label: 'Connections', + label: intl.formatMessage({ + id: 'xpack.monitoring.kibana.clusterStatus.connectionsLabel', + defaultMessage: 'Connections' + }), value: connections, dataTestSubj: 'connections' }, { - label: 'Max. Response Time', + label: intl.formatMessage({ + id: 'xpack.monitoring.kibana.clusterStatus.maxResponseTimeLabel', + defaultMessage: 'Max. Response Time' + }), value: formatMetric(maxResponseTime, '0', 'ms'), dataTestSubj: 'maxResponseTime' } @@ -61,3 +77,5 @@ export function ClusterStatus({ stats }) { /> ); } + +export const ClusterStatus = injectI18n(ClusterStatusUI); diff --git a/x-pack/plugins/monitoring/public/components/kibana/detail_status/index.js b/x-pack/plugins/monitoring/public/components/kibana/detail_status/index.js index bffe4082a2b62..b8b4cd2ce498b 100644 --- a/x-pack/plugins/monitoring/public/components/kibana/detail_status/index.js +++ b/x-pack/plugins/monitoring/public/components/kibana/detail_status/index.js @@ -8,8 +8,9 @@ import React from 'react'; import { SummaryStatus } from '../../summary_status'; import { KibanaStatusIcon } from '../status_icon'; import { formatMetric } from '../../../lib/format_number'; +import { injectI18n } from '@kbn/i18n/react'; -export function DetailStatus({ stats }) { +function DetailStatusUI({ stats, intl }) { const { transport_address: transportAddress, os_memory_free: osFreeMemory, @@ -24,17 +25,26 @@ export function DetailStatus({ stats }) { dataTestSubj: 'transportAddress' }, { - label: 'OS Free Memory', + label: intl.formatMessage({ + id: 'xpack.monitoring.kibana.detailStatus.osFreeMemoryLabel', + defaultMessage: 'OS Free Memory' + }), value: formatMetric(osFreeMemory, 'byte'), dataTestSubj: 'osFreeMemory' }, { - label: 'Version', + label: intl.formatMessage({ + id: 'xpack.monitoring.kibana.detailStatus.versionLabel', + defaultMessage: 'Version' + }), value: version, dataTestSubj: 'version' }, { - label: 'Uptime', + label: intl.formatMessage({ + id: 'xpack.monitoring.kibana.detailStatus.uptimeLabel', + defaultMessage: 'Uptime' + }), value: formatMetric(uptime, 'time_since'), dataTestSubj: 'uptime' } @@ -53,3 +63,5 @@ export function DetailStatus({ stats }) { /> ); } + +export const DetailStatus = injectI18n(DetailStatusUI); diff --git a/x-pack/plugins/monitoring/public/components/kibana/status_icon.js b/x-pack/plugins/monitoring/public/components/kibana/status_icon.js index a9fa9e163289f..6ce9f2dc5bea6 100644 --- a/x-pack/plugins/monitoring/public/components/kibana/status_icon.js +++ b/x-pack/plugins/monitoring/public/components/kibana/status_icon.js @@ -6,8 +6,9 @@ import React from 'react'; import { StatusIcon } from 'plugins/monitoring/components/status_icon'; +import { injectI18n } from '@kbn/i18n/react'; -export function KibanaStatusIcon({ status, availability = true }) { +function KibanaStatusIconUI({ status, availability = true, intl }) { const type = (() => { if (!availability) { return StatusIcon.TYPES.GRAY; @@ -18,6 +19,15 @@ export function KibanaStatusIcon({ status, availability = true }) { })(); return ( - + ); } + +export const KibanaStatusIcon = injectI18n(KibanaStatusIconUI); diff --git a/x-pack/plugins/monitoring/public/directives/elasticsearch/cluster_status/index.js b/x-pack/plugins/monitoring/public/directives/elasticsearch/cluster_status/index.js index 0be64b18406a8..7f0d5a665c334 100644 --- a/x-pack/plugins/monitoring/public/directives/elasticsearch/cluster_status/index.js +++ b/x-pack/plugins/monitoring/public/directives/elasticsearch/cluster_status/index.js @@ -8,6 +8,7 @@ import React from 'react'; import { render } from 'react-dom'; import { uiModules } from 'ui/modules'; import { ClusterStatus } from 'plugins/monitoring/components/elasticsearch/cluster_status'; +import { I18nProvider } from '@kbn/i18n/react'; const uiModule = uiModules.get('monitoring/directives', []); uiModule.directive('monitoringClusterStatusElasticsearch', () => { @@ -18,7 +19,7 @@ uiModule.directive('monitoringClusterStatusElasticsearch', () => { }, link(scope, $el) { scope.$watch('status', status => { - render(, $el[0]); + render(, $el[0]); }); } }; diff --git a/x-pack/plugins/monitoring/public/directives/elasticsearch/index_summary/index.js b/x-pack/plugins/monitoring/public/directives/elasticsearch/index_summary/index.js index e1fa222a0ee80..24e48609c4781 100644 --- a/x-pack/plugins/monitoring/public/directives/elasticsearch/index_summary/index.js +++ b/x-pack/plugins/monitoring/public/directives/elasticsearch/index_summary/index.js @@ -8,6 +8,7 @@ import React from 'react'; import { render } from 'react-dom'; import { uiModules } from 'ui/modules'; import { IndexDetailStatus } from 'plugins/monitoring/components/elasticsearch/index_detail_status'; +import { I18nProvider } from '@kbn/i18n/react'; const uiModule = uiModules.get('monitoring/directives', []); uiModule.directive('monitoringIndexSummary', () => { @@ -16,7 +17,7 @@ uiModule.directive('monitoringIndexSummary', () => { scope: { summary: '=' }, link(scope, $el) { scope.$watch('summary', summary => { - render(, $el[0]); + render(, $el[0]); }); } }; diff --git a/x-pack/plugins/monitoring/public/directives/elasticsearch/node_summary/index.js b/x-pack/plugins/monitoring/public/directives/elasticsearch/node_summary/index.js index 638e2423233ef..81a8a55f58b0a 100644 --- a/x-pack/plugins/monitoring/public/directives/elasticsearch/node_summary/index.js +++ b/x-pack/plugins/monitoring/public/directives/elasticsearch/node_summary/index.js @@ -8,6 +8,7 @@ import React from 'react'; import { render } from 'react-dom'; import { uiModules } from 'ui/modules'; import { NodeDetailStatus } from 'plugins/monitoring/components/elasticsearch/node_detail_status'; +import { I18nProvider } from '@kbn/i18n/react'; const uiModule = uiModules.get('monitoring/directives', []); uiModule.directive('monitoringNodeSummary', () => { @@ -18,7 +19,7 @@ uiModule.directive('monitoringNodeSummary', () => { }, link(scope, $el) { scope.$watch('node', node => { - render(, $el[0]); + render(, $el[0]); }); } }; diff --git a/x-pack/plugins/monitoring/public/directives/kibana/cluster_status/index.js b/x-pack/plugins/monitoring/public/directives/kibana/cluster_status/index.js index 1582966b5951d..1fd57f1b5c2c4 100644 --- a/x-pack/plugins/monitoring/public/directives/kibana/cluster_status/index.js +++ b/x-pack/plugins/monitoring/public/directives/kibana/cluster_status/index.js @@ -8,6 +8,7 @@ import React from 'react'; import { render } from 'react-dom'; import { uiModules } from 'ui/modules'; import { ClusterStatus } from 'plugins/monitoring/components/kibana/cluster_status'; +import { I18nProvider } from '@kbn/i18n/react'; const uiModule = uiModules.get('monitoring/directives', []); uiModule.directive('monitoringClusterStatusKibana', () => { @@ -18,7 +19,7 @@ uiModule.directive('monitoringClusterStatusKibana', () => { }, link(scope, $el) { scope.$watch('status', status => { - render(, $el[0]); + render(, $el[0]); }); }, }; diff --git a/x-pack/plugins/monitoring/public/directives/kibana/summary/index.js b/x-pack/plugins/monitoring/public/directives/kibana/summary/index.js index 1077ed579420a..521fc37a650ce 100644 --- a/x-pack/plugins/monitoring/public/directives/kibana/summary/index.js +++ b/x-pack/plugins/monitoring/public/directives/kibana/summary/index.js @@ -8,6 +8,7 @@ import React from 'react'; import { render } from 'react-dom'; import { uiModules } from 'ui/modules'; import { DetailStatus } from 'plugins/monitoring/components/kibana/detail_status'; +import { I18nProvider } from '@kbn/i18n/react'; const uiModule = uiModules.get('monitoring/directives', []); uiModule.directive('monitoringKibanaSummary', () => { @@ -18,7 +19,7 @@ uiModule.directive('monitoringKibanaSummary', () => { }, link(scope, $el) { scope.$watch('kibana', kibana => { - render(, $el[0]); + render(, $el[0]); }); } }; diff --git a/x-pack/plugins/monitoring/public/views/elasticsearch/ccr/index.js b/x-pack/plugins/monitoring/public/views/elasticsearch/ccr/index.js index a2404273d38e1..d4f52621f3723 100644 --- a/x-pack/plugins/monitoring/public/views/elasticsearch/ccr/index.js +++ b/x-pack/plugins/monitoring/public/views/elasticsearch/ccr/index.js @@ -11,6 +11,7 @@ import { routeInitProvider } from 'plugins/monitoring/lib/route_init'; import template from './index.html'; import { Ccr } from '../../../components/elasticsearch/ccr'; import { MonitoringViewBaseController } from '../../base_controller'; +import { I18nProvider } from '@kbn/i18n/react'; uiRoutes.when('/elasticsearch/ccr', { template, @@ -40,7 +41,9 @@ uiRoutes.when('/elasticsearch/ccr', { this.renderReact = ({ data }) => { super.renderReact( - + + + ); }; } diff --git a/x-pack/plugins/monitoring/public/views/elasticsearch/ccr/shard/index.js b/x-pack/plugins/monitoring/public/views/elasticsearch/ccr/shard/index.js index ddf67ac09e79c..554aaaea31969 100644 --- a/x-pack/plugins/monitoring/public/views/elasticsearch/ccr/shard/index.js +++ b/x-pack/plugins/monitoring/public/views/elasticsearch/ccr/shard/index.js @@ -12,6 +12,7 @@ import { routeInitProvider } from 'plugins/monitoring/lib/route_init'; import template from './index.html'; import { MonitoringViewBaseController } from '../../../base_controller'; import { CcrShard } from '../../../../components/elasticsearch/ccr_shard'; +import { I18nProvider } from '@kbn/i18n/react'; uiRoutes.when('/elasticsearch/ccr/:index/shard/:shardId', { template, @@ -49,7 +50,7 @@ uiRoutes.when('/elasticsearch/ccr/:index/shard/:shardId', { this.renderReact = (props) => { super.renderReact( - + ); }; } From 2257e06c7d4c5ec0ed2c9ae8b6cf50cff3893dbe Mon Sep 17 00:00:00 2001 From: Leanid Shutau Date: Mon, 19 Nov 2018 14:35:06 +0300 Subject: [PATCH 13/95] [I18n] Translate Timelion - top navigation menu (#25801) --- src/core_plugins/timelion/public/app.js | 42 ++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/core_plugins/timelion/public/app.js b/src/core_plugins/timelion/public/app.js index 036b53ad826c2..210db2191e4b3 100644 --- a/src/core_plugins/timelion/public/app.js +++ b/src/core_plugins/timelion/public/app.js @@ -114,29 +114,37 @@ app.controller('timelion', function ( const savedSheet = $route.current.locals.savedSheet; $scope.topNavMenu = [{ - key: 'new', - description: i18n('timelion.topNavMenu.newDescription', { + key: i18n('timelion.topNavMenu.newSheetButtonLabel', { + defaultMessage: 'new', + }), + description: i18n('timelion.topNavMenu.newSheetButtonAriaLabel', { defaultMessage: 'New Sheet', }), run: function () { kbnUrl.change('/'); }, testId: 'timelionNewButton', }, { - key: 'add', - description: i18n('timelion.topNavMenu.addDescription', { + key: i18n('timelion.topNavMenu.addChartButtonLabel', { + defaultMessage: 'add', + }), + description: i18n('timelion.topNavMenu.addChartButtonAriaLabel', { defaultMessage: 'Add a chart', }), run: function () { $scope.newCell(); }, testId: 'timelionAddChartButton', }, { - key: 'save', - description: i18n('timelion.topNavMenu.saveDescription', { + key: i18n('timelion.topNavMenu.saveSheetButtonLabel', { + defaultMessage: 'save', + }), + description: i18n('timelion.topNavMenu.saveSheetButtonAriaLabel', { defaultMessage: 'Save Sheet', }), template: require('plugins/timelion/partials/save_sheet.html'), testId: 'timelionSaveButton', }, { - key: 'delete', - description: i18n('timelion.topNavMenu.deleteDescription', { + key: i18n('timelion.topNavMenu.deleteSheetButtonLabel', { + defaultMessage: 'delete', + }), + description: i18n('timelion.topNavMenu.deleteSheetButtonAriaLabel', { defaultMessage: 'Delete current sheet', }), disableButton: function () { @@ -177,22 +185,28 @@ app.controller('timelion', function ( }, testId: 'timelionDeleteButton', }, { - key: 'open', - description: i18n('timelion.topNavMenu.openDescription', { + key: i18n('timelion.topNavMenu.openSheetButtonLabel', { + defaultMessage: 'open', + }), + description: i18n('timelion.topNavMenu.openSheetButtonAriaLabel', { defaultMessage: 'Open Sheet', }), template: require('plugins/timelion/partials/load_sheet.html'), testId: 'timelionOpenButton', }, { - key: 'options', - description: i18n('timelion.topNavMenu.optionsDescription', { + key: i18n('timelion.topNavMenu.optionsButtonLabel', { + defaultMessage: 'options', + }), + description: i18n('timelion.topNavMenu.optionsButtonAriaLabel', { defaultMessage: 'Options', }), template: require('plugins/timelion/partials/sheet_options.html'), testId: 'timelionOptionsButton', }, { - key: 'help', - description: i18n('timelion.topNavMenu.helpDescription', { + key: i18n('timelion.topNavMenu.helpButtonLabel', { + defaultMessage: 'help', + }), + description: i18n('timelion.topNavMenu.helpButtonAriaLabel', { defaultMessage: 'Help', }), template: '', From 0c6e619237dee015d13a1b8584c26070ec1288db Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 19 Nov 2018 05:14:38 -0800 Subject: [PATCH 14/95] [Monitoring] Adding security note about first-time setup (#25823) * Adding security note * Mention the built-in superuser role * Making edits per review feedback --- docs/settings/monitoring-settings.asciidoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/settings/monitoring-settings.asciidoc b/docs/settings/monitoring-settings.asciidoc index 52d07d03db2e6..1a84e40069c10 100644 --- a/docs/settings/monitoring-settings.asciidoc +++ b/docs/settings/monitoring-settings.asciidoc @@ -6,8 +6,11 @@ ++++ By default, the Monitoring application is enabled, but data collection -is disabled. When you first start {kib} monitoring, you will be prompted to -enable data collection. +is disabled. When you first start {kib} monitoring, you are prompted to +enable data collection. If you are using {security}, you must be +signed in as a user with the `cluster:manage` privilege to enable +data collection. The built-in `superuser` role has this privilege and the +built-in `elastic` user has this role. You can adjust how monitoring data is collected from {kib} and displayed in {kib} by configuring settings in the From 7e30709be51d0f675a265f7bcfdfb166a49f97dd Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Mon, 19 Nov 2018 14:08:06 +0000 Subject: [PATCH 15/95] [ML] Use ml as a prefix for the ML SCSS variables (#25858) --- x-pack/plugins/ml/public/_app.scss | 14 ++++++------- x-pack/plugins/ml/public/_variables.scss | 20 +++++++++---------- .../anomalies_table/_anomalies_table.scss | 10 +++++----- .../influencers_list/_influencers_list.scss | 16 +++++++-------- .../explorer_charts/_explorer_chart.scss | 8 ++++---- .../job_filter_bar/_job_filter_bar.scss | 4 ++-- .../job_filter_bar/job_filter_bar.js | 2 +- .../_timeseriesexplorer.scss | 8 ++++---- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/x-pack/plugins/ml/public/_app.scss b/x-pack/plugins/ml/public/_app.scss index 5022d08553405..6dfae7a8921f3 100644 --- a/x-pack/plugins/ml/public/_app.scss +++ b/x-pack/plugins/ml/public/_app.scss @@ -1,4 +1,4 @@ -// ML has app specific coloring for it's various warning levels. +// ML has app specific coloring for it's various warning levels. // These are used almost everywhere. .ml-icon-severity-critical, @@ -10,21 +10,21 @@ } .ml-icon-severity-critical { - color: $mchColorCriticalText; + color: $mlColorCriticalText; } .ml-icon-severity-major { - color: $mchColorMajorText; + color: $mlColorMajorText; } .ml-icon-severity-minor { - color: $mchColorMinorText; + color: $mlColorMinorText; } .ml-icon-severity-warning { - color: $mchColorWarningText; + color: $mlColorWarningText; } .ml-icon-severity-unknown { - color: $mchColorUnknownText; -} \ No newline at end of file + color: $mlColorUnknownText; +} diff --git a/x-pack/plugins/ml/public/_variables.scss b/x-pack/plugins/ml/public/_variables.scss index 37c8ffbc6e2ad..159a1ffd45dd5 100644 --- a/x-pack/plugins/ml/public/_variables.scss +++ b/x-pack/plugins/ml/public/_variables.scss @@ -1,11 +1,11 @@ -$mchColorCritical: #fe5050; -$mchColorMajor: #fba740; -$mchColorMinor: #fdec25; -$mchColorWarning: #8bc8fb; -$mchColorUnknown: #c0c0c0; +$mlColorCritical: #fe5050; +$mlColorMajor: #fba740; +$mlColorMinor: #fdec25; +$mlColorWarning: #8bc8fb; +$mlColorUnknown: #c0c0c0; -$mchColorCriticalText: makeHighContrastColor($mchColorCritical, $euiColorEmptyShade); -$mchColorMajorText: makeHighContrastColor($mchColorMajor, $euiColorEmptyShade); -$mchColorMinorText: makeHighContrastColor($mchColorMinor, $euiColorEmptyShade); -$mchColorWarningText: makeHighContrastColor($mchColorWarning, $euiColorEmptyShade); -$mchColorUnknownText: $euiColorDarkShade; \ No newline at end of file +$mlColorCriticalText: makeHighContrastColor($mlColorCritical, $euiColorEmptyShade); +$mlColorMajorText: makeHighContrastColor($mlColorMajor, $euiColorEmptyShade); +$mlColorMinorText: makeHighContrastColor($mlColorMinor, $euiColorEmptyShade); +$mlColorWarningText: makeHighContrastColor($mlColorWarning, $euiColorEmptyShade); +$mlColorUnknownText: $euiColorDarkShade; diff --git a/x-pack/plugins/ml/public/components/anomalies_table/_anomalies_table.scss b/x-pack/plugins/ml/public/components/anomalies_table/_anomalies_table.scss index dd5d3d597f5c9..cfcf57a96a9bc 100644 --- a/x-pack/plugins/ml/public/components/anomalies_table/_anomalies_table.scss +++ b/x-pack/plugins/ml/public/components/anomalies_table/_anomalies_table.scss @@ -12,31 +12,31 @@ // SASSTODO: Should only be three options, logic moved to the JS, where EuiIcon accepts a color .ml-icon-severity-critical { .euiIcon { - fill: $mchColorCriticalText; + fill: $mlColorCriticalText; } } .ml-icon-severity-major { .euiIcon { - fill: $mchColorMajorText; + fill: $mlColorMajorText; } } .ml-icon-severity-minor { .euiIcon { - fill: $mchColorMinorText; + fill: $mlColorMinorText; } } .ml-icon-severity-warning { .euiIcon { - fill: $mchColorWarningText; + fill: $mlColorWarningText; } } .ml-icon-severity-unknown { .euiIcon { - fill: $mchColorUnknownText; + fill: $mlColorUnknownText; } } diff --git a/x-pack/plugins/ml/public/components/influencers_list/_influencers_list.scss b/x-pack/plugins/ml/public/components/influencers_list/_influencers_list.scss index c3e3bee2ab9a7..b632b98b75b7c 100644 --- a/x-pack/plugins/ml/public/components/influencers_list/_influencers_list.scss +++ b/x-pack/plugins/ml/public/components/influencers_list/_influencers_list.scss @@ -40,37 +40,37 @@ // SASSTODO: This range of color is too large, needs to be rewritten and variablized .progress.critical { .progress-bar { - background-color: $mchColorCritical; + background-color: $mlColorCritical; } .score-label { - border-color: $mchColorCritical; + border-color: $mlColorCritical; } } .progress.major { .progress-bar { - background-color: $mchColorMajor; + background-color: $mlColorMajor; } .score-label { - border-color: $mchColorMajor; + border-color: $mlColorMajor; } } .progress.minor { .progress-bar { - background-color: $mchColorMinor; + background-color: $mlColorMinor; } .score-label { - border-color: $mchColorMinor; + border-color: $mlColorMinor; } } .progress.warning { .progress-bar { - background-color: $mchColorWarning; + background-color: $mlColorWarning; } .score-label { - border-color: $mchColorWarning; + border-color: $mlColorWarning; } } diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/_explorer_chart.scss b/x-pack/plugins/ml/public/explorer/explorer_charts/_explorer_chart.scss index f354ed1ccf5ec..4808d47fccd4f 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/_explorer_chart.scss +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/_explorer_chart.scss @@ -85,19 +85,19 @@ } .anomaly-marker.critical { - fill: $mchColorCritical; + fill: $mlColorCritical; } .anomaly-marker.major { - fill: $mchColorMajor; + fill: $mlColorMajor; } .anomaly-marker.minor { - fill: $mchColorMinor; + fill: $mlColorMinor; } .anomaly-marker.warning { - fill: $mchColorWarning; + fill: $mlColorWarning; } .anomaly-marker.low { diff --git a/x-pack/plugins/ml/public/jobs/jobs_list/components/job_filter_bar/_job_filter_bar.scss b/x-pack/plugins/ml/public/jobs/jobs_list/components/job_filter_bar/_job_filter_bar.scss index c6e6689a01ac1..92c3ae53cbeee 100644 --- a/x-pack/plugins/ml/public/jobs/jobs_list/components/job_filter_bar/_job_filter_bar.scss +++ b/x-pack/plugins/ml/public/jobs/jobs_list/components/job_filter_bar/_job_filter_bar.scss @@ -1,4 +1,4 @@ -.mchJobFilterBar { +.mlJobFilterBar { // SASSTODO: Dangerou EUI overwrites .euiFilterGroup { .euiPopover .euiPanel { @@ -20,4 +20,4 @@ } } } -} \ No newline at end of file +} diff --git a/x-pack/plugins/ml/public/jobs/jobs_list/components/job_filter_bar/job_filter_bar.js b/x-pack/plugins/ml/public/jobs/jobs_list/components/job_filter_bar/job_filter_bar.js index 99c7e2487e5f7..189af8900df6d 100644 --- a/x-pack/plugins/ml/public/jobs/jobs_list/components/job_filter_bar/job_filter_bar.js +++ b/x-pack/plugins/ml/public/jobs/jobs_list/components/job_filter_bar/job_filter_bar.js @@ -130,7 +130,7 @@ export class JobFilterBar extends Component { }} filters={filters} onChange={this.onChange} - className="mchJobFilterBar" + className="mlJobFilterBar" /> { this.renderError() || ''} diff --git a/x-pack/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss b/x-pack/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss index b4d58fbf8bda4..8e2d89f447be0 100644 --- a/x-pack/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss +++ b/x-pack/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss @@ -163,19 +163,19 @@ } .anomaly-marker.critical { - fill: $mchColorCritical; + fill: $mlColorCritical; } .anomaly-marker.major { - fill: $mchColorMajor; + fill: $mlColorMajor; } .anomaly-marker.minor { - fill: $mchColorMinor; + fill: $mlColorMinor; } .anomaly-marker.warning { - fill: $mchColorWarning; + fill: $mlColorWarning; } .anomaly-marker.low { From a5e096ecf681c30155d4104a177c5321ef760a55 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Mon, 19 Nov 2018 16:28:01 +0100 Subject: [PATCH 16/95] Remove lab stage for visualizations (#25702) * Remove lab stage for visualizations * Fix typo Co-Authored-By: timroes * Remove dead code --- .../development-create-visualization.asciidoc | 4 ++-- .../input_control_vis/public/register_vis.js | 2 +- .../embeddable/visualize_embeddable_factory.js | 2 +- .../visualize/listing/visualize_listing.js | 2 +- .../kibana/public/visualize/wizard/wizard.js | 6 ++---- src/core_plugins/kibana/ui_setting_defaults.js | 5 +++-- src/core_plugins/vega/public/vega_type.js | 2 +- src/ui/public/directives/saved_object_finder.js | 2 +- .../components/saved_object_finder.js | 2 +- src/ui/public/vis/vis_types/base_vis_type.js | 4 +--- .../apps/visualize/_experimental_vis.js | 17 ----------------- test/functional/page_objects/visualize_page.js | 4 ---- 12 files changed, 14 insertions(+), 38 deletions(-) diff --git a/docs/development/visualize/development-create-visualization.asciidoc b/docs/development/visualize/development-create-visualization.asciidoc index 56ed620e148c5..94e06df60ed6f 100644 --- a/docs/development/visualize/development-create-visualization.asciidoc +++ b/docs/development/visualize/development-create-visualization.asciidoc @@ -71,8 +71,8 @@ The list of common parameters: - *options.showQueryBar*: show or hide query bar (defaults to true) - *options.showFilterBar*: show or hide filter bar (defaults to true) - *options.showIndexSelection*: show or hide index selection (defaults to true) -- *stage*: Set this to "experimental" or "labs" to mark your visualization as experimental. -Labs visualizations can also be disabled from the advanced settings. (defaults to "production") +- *stage*: Set this to "experimental" to mark your visualization as experimental. +Experimental visualizations can also be disabled from the advanced settings. (defaults to "production") - *feedbackMessage*: You can provide a message (which can contain HTML), that will be appended to the experimental notification in visualize, if your visualization is experimental or in lab mode. diff --git a/src/core_plugins/input_control_vis/public/register_vis.js b/src/core_plugins/input_control_vis/public/register_vis.js index 859ed40d9ed1a..c975c4bb1afa4 100644 --- a/src/core_plugins/input_control_vis/public/register_vis.js +++ b/src/core_plugins/input_control_vis/public/register_vis.js @@ -41,7 +41,7 @@ function InputControlVisProvider(Private) { defaultMessage: 'Create interactive controls for easy dashboard manipulation.' }), category: CATEGORY.OTHER, - stage: 'lab', + stage: 'experimental', requiresUpdateStatus: [Status.PARAMS, Status.TIME], feedbackMessage: defaultFeedbackMessage, visualization: VisController, diff --git a/src/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.js b/src/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.js index 97a45005bcb1a..3bbc21beee682 100644 --- a/src/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.js +++ b/src/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.js @@ -53,7 +53,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory { .then(([loader, savedObject]) => { const isLabsEnabled = this._config.get('visualize:enableLabs'); - if (!isLabsEnabled && savedObject.vis.type.stage === 'lab') { + if (!isLabsEnabled && savedObject.vis.type.stage === 'experimental') { return new Embeddable({ metadata: { title: savedObject.title, diff --git a/src/core_plugins/kibana/public/visualize/listing/visualize_listing.js b/src/core_plugins/kibana/public/visualize/listing/visualize_listing.js index a6f839a8481c1..997023064f6b6 100644 --- a/src/core_plugins/kibana/public/visualize/listing/visualize_listing.js +++ b/src/core_plugins/kibana/public/visualize/listing/visualize_listing.js @@ -52,7 +52,7 @@ export function VisualizeListingController($injector) { this.totalItems = result.total; this.showLimitError = result.total > config.get('savedObjects:listingLimit'); this.listingLimit = config.get('savedObjects:listingLimit'); - return result.hits.filter(result => (isLabsEnabled || result.type.stage !== 'lab')); + return result.hits.filter(result => (isLabsEnabled || result.type.stage !== 'experimental')); }); }; diff --git a/src/core_plugins/kibana/public/visualize/wizard/wizard.js b/src/core_plugins/kibana/public/visualize/wizard/wizard.js index 218561a7003a6..c5ba3753d0c93 100644 --- a/src/core_plugins/kibana/public/visualize/wizard/wizard.js +++ b/src/core_plugins/kibana/public/visualize/wizard/wizard.js @@ -75,7 +75,7 @@ module.controller('VisualizeWizardStep1', function ($scope, $route, kbnUrl, Priv return; } - if (!isLabsEnabled && visType.stage === 'lab') { + if (!isLabsEnabled && visType.stage === 'experimental') { return; } @@ -158,9 +158,7 @@ module.controller('VisualizeWizardStep1', function ($scope, $route, kbnUrl, Priv //to not clutter the tooltip, just only notify if labs or experimental. //labs is more important in this regard. let prefix = ''; - if (type.stage === 'lab') { - prefix = '(Lab)'; - } else if (type.stage === 'experimental') { + if (type.stage === 'experimental') { prefix = '(Experimental)'; } return `${prefix} ${type.description}`; diff --git a/src/core_plugins/kibana/ui_setting_defaults.js b/src/core_plugins/kibana/ui_setting_defaults.js index f86477a89e46d..3b43d99550313 100644 --- a/src/core_plugins/kibana/ui_setting_defaults.js +++ b/src/core_plugins/kibana/ui_setting_defaults.js @@ -218,9 +218,10 @@ export function getUiSettingDefaults() { description: `Never show more than this many bars in date histograms, scale values if needed`, }, 'visualize:enableLabs': { - name: 'Enable labs', + name: 'Enable experimental visualizations', value: true, - description: `Enable lab visualizations in Visualize.`, + description: `Allows users to create, view, and edit experimental visualizations. If disabled, + only visualizations that are considered production-ready are available to the user.`, category: ['visualization'], }, 'visualization:tileMap:maxPrecision': { diff --git a/src/core_plugins/vega/public/vega_type.js b/src/core_plugins/vega/public/vega_type.js index e96fba000b4c0..f17852cab9045 100644 --- a/src/core_plugins/vega/public/vega_type.js +++ b/src/core_plugins/vega/public/vega_type.js @@ -65,7 +65,7 @@ VisTypesRegistryProvider.register((Private) => { showQueryBar: true, showFilterBar: true, }, - stage: 'lab', + stage: 'experimental', feedbackMessage: defaultFeedbackMessage, }); }); diff --git a/src/ui/public/directives/saved_object_finder.js b/src/ui/public/directives/saved_object_finder.js index ad9905047f0b6..0b107dc085f2d 100644 --- a/src/ui/public/directives/saved_object_finder.js +++ b/src/ui/public/directives/saved_object_finder.js @@ -286,7 +286,7 @@ module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Pr self.service.find(filter) .then(function (hits) { - hits.hits = hits.hits.filter((hit) => (isLabsEnabled || _.get(hit, 'type.stage') !== 'lab')); + hits.hits = hits.hits.filter((hit) => (isLabsEnabled || _.get(hit, 'type.stage') !== 'experimental')); hits.total = hits.hits.length; // ensure that we don't display old results diff --git a/src/ui/public/saved_objects/components/saved_object_finder.js b/src/ui/public/saved_objects/components/saved_object_finder.js index fd8819449d21d..e8e61b4ec67d4 100644 --- a/src/ui/public/saved_objects/components/saved_object_finder.js +++ b/src/ui/public/saved_objects/components/saved_object_finder.js @@ -120,7 +120,7 @@ export class SavedObjectFinder extends React.Component { resp.savedObjects = resp.savedObjects.filter(savedObject => { const typeName = JSON.parse(savedObject.attributes.visState).type; const visType = this.props.visTypes.byName[typeName]; - return visType.stage !== 'lab'; + return visType.stage !== 'experimental'; }); } diff --git a/src/ui/public/vis/vis_types/base_vis_type.js b/src/ui/public/vis/vis_types/base_vis_type.js index b26651845573d..3b360b75df3e1 100644 --- a/src/ui/public/vis/vis_types/base_vis_type.js +++ b/src/ui/public/vis/vis_types/base_vis_type.js @@ -78,9 +78,7 @@ export function BaseVisTypeProvider(Private) { } shouldMarkAsExperimentalInUI() { - //we are not making a distinction in the UI if a plugin is experimental and/or labs. - //we just want to indicate it is special. the current flask icon is sufficient for that. - return this.stage === 'experimental' || this.stage === 'lab'; + return this.stage === 'experimental'; } get schemas() { diff --git a/test/functional/apps/visualize/_experimental_vis.js b/test/functional/apps/visualize/_experimental_vis.js index fa63297eba17f..6cce432fd2c31 100644 --- a/test/functional/apps/visualize/_experimental_vis.js +++ b/test/functional/apps/visualize/_experimental_vis.js @@ -50,23 +50,6 @@ export default ({ getService, getPageObjects }) => { expect(await info.getVisibleText()).to.contain('experimental'); }); - it('should show an notification when creating lab visualizations', async () => { - // Try to find a lab visualization. - const labTypes = await PageObjects.visualize.getLabTypeLinks(); - if (labTypes.length === 0) { - log.info('No lab visualization found. Skipping this test.'); - return; - } - - // Create a new visualization - await labTypes[0].click(); - // Select a index-pattern/search if this vis requires it - await PageObjects.visualize.selectVisSourceIfRequired(); - // Check that the experimental banner is there and state that this is experimental - const info = await PageObjects.visualize.getExperimentalInfo(); - expect(await info.getVisibleText()).to.contain('experimental'); - }); - it('should not show that notification for stable visualizations', async () => { await PageObjects.visualize.clickAreaChart(); await PageObjects.visualize.clickNewSearch(); diff --git a/test/functional/page_objects/visualize_page.js b/test/functional/page_objects/visualize_page.js index 11baa13e524a8..de930ee9bee8e 100644 --- a/test/functional/page_objects/visualize_page.js +++ b/test/functional/page_objects/visualize_page.js @@ -194,10 +194,6 @@ export function VisualizePageProvider({ getService, getPageObjects }) { } } - async getLabTypeLinks() { - return await remote.findAllByPartialLinkText('(Lab)'); - } - async getExperimentalTypeLinks() { return await remote.findAllByPartialLinkText('(Experimental)'); } From cc07aa29d5c59efd116cd523c8ea5999dabe4258 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Mon, 19 Nov 2018 16:22:42 +0000 Subject: [PATCH 17/95] [ML] Edits to fields used in auditbeat module configurations (#25866) --- .../modules/auditbeat_process_docker/manifest.json | 2 +- .../visualization/ml_auditbeat_hosts_event_volume.json | 2 +- .../modules/auditbeat_process_hosts/manifest.json | 2 +- .../ml/hosts_high_count_events.json | 8 ++++---- .../ml/hosts_suspicious_process_activity.json | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_docker/manifest.json b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_docker/manifest.json index 5aade8ad0a93f..7f6806739499f 100644 --- a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_docker/manifest.json +++ b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_docker/manifest.json @@ -10,7 +10,7 @@ "must": [ { "exists": { - "field": "auditd" + "field": "auditd.summary" } }, { diff --git a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/kibana/visualization/ml_auditbeat_hosts_event_volume.json b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/kibana/visualization/ml_auditbeat_hosts_event_volume.json index 71ccdaeb8c882..83ee6bc38897e 100644 --- a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/kibana/visualization/ml_auditbeat_hosts_event_volume.json +++ b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/kibana/visualization/ml_auditbeat_hosts_event_volume.json @@ -1,6 +1,6 @@ { "title": "ML Auditbeat Hosts: Event Volume", - "visState": "{\"title\":\"ML Auditbeat Hosts: Event Volume\",\"type\":\"line\",\"params\":{\"type\":\"line\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"line\",\"mode\":\"normal\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"beat.hostname\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"1\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\"}}]}", + "visState": "{\"title\":\"ML Auditbeat Hosts: Event Volume\",\"type\":\"line\",\"params\":{\"type\":\"line\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"line\",\"mode\":\"normal\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"beat.name\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"1\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\"}}]}", "uiStateJSON": "{}", "description": "", "savedSearchId": "ml_auditbeat_hosts_events", diff --git a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/manifest.json b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/manifest.json index ac667e3f525b5..f60b8e514ea63 100644 --- a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/manifest.json +++ b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/manifest.json @@ -10,7 +10,7 @@ "must": [ { "exists": { - "field": "auditd" + "field": "auditd.summary" } } ], diff --git a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/ml/hosts_high_count_events.json b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/ml/hosts_high_count_events.json index 81abf4db3569f..6ec1f172e751d 100644 --- a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/ml/hosts_high_count_events.json +++ b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/ml/hosts_high_count_events.json @@ -6,13 +6,13 @@ "bucket_span": "1h", "detectors": [ { - "detector_description": "high_count partitionfield=\"beat.hostname\"", + "detector_description": "high_count partitionfield=\"beat.name\"", "function": "high_count", - "partition_field_name": "beat.hostname" + "partition_field_name": "beat.name" } ], "influencers": [ - "beat.hostname", + "beat.name", "process.exe" ] }, @@ -29,7 +29,7 @@ { "url_name": "Host Events", "time_range": "1h", - "url_value": "kibana#/dashboard/ml_auditbeat_hosts_audit_events?_g=(time:(from:'$earliest$',mode:absolute,to:'$latest$'))&_a=(filters:!(),query:(language:lucene,query:'beat.hostname:\"$beat.hostname$\"'))" + "url_value": "kibana#/dashboard/ml_auditbeat_hosts_audit_events?_g=(time:(from:'$earliest$',mode:absolute,to:'$latest$'))&_a=(filters:!(),query:(language:lucene,query:'beat.name:\"$beat.name$\"'))" } ] } diff --git a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/ml/hosts_suspicious_process_activity.json b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/ml/hosts_suspicious_process_activity.json index 7ef2aafe964a4..1464165393cc2 100644 --- a/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/ml/hosts_suspicious_process_activity.json +++ b/x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_hosts/ml/hosts_suspicious_process_activity.json @@ -13,7 +13,7 @@ ], "influencers": [ "process.exe", - "beat.hostname" + "beat.name" ] }, "analysis_limits": { @@ -28,7 +28,7 @@ { "url_name": "Host Events", "time_range": "1h", - "url_value": "kibana#/dashboard/ml_auditbeat_hosts_audit_events?_g=(time:(from:'$earliest$',mode:absolute,to:'$latest$'))&_a=(filters:!(),query:(language:lucene,query:'beat.hostname:\"$beat.hostname$\" AND process.exe:\"$process.exe$\"'))" + "url_value": "kibana#/dashboard/ml_auditbeat_hosts_audit_events?_g=(time:(from:'$earliest$',mode:absolute,to:'$latest$'))&_a=(filters:!(),query:(language:lucene,query:'beat.name:\"$beat.name$\" AND process.exe:\"$process.exe$\"'))" } ] } From 1d7d60360b133f257cf8e4293b857641c212139b Mon Sep 17 00:00:00 2001 From: Catherine Liu Date: Mon, 19 Nov 2018 11:24:34 -0700 Subject: [PATCH 18/95] Fixes loading component (#25819) * Removes redux selectors from loading component. Fixes how loading accesses page background color * Fixed props --- .../uis/arguments/image_upload/index.js | 5 +---- .../public/components/element_content/element_content.js | 4 ++-- .../canvas/public/components/element_content/index.js | 7 +++++++ x-pack/plugins/canvas/public/components/loading/index.js | 9 ++------- .../plugins/canvas/public/components/loading/loading.js | 3 ++- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/image_upload/index.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/image_upload/index.js index d5540d050227f..5027dbbf3f566 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/image_upload/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/image_upload/index.js @@ -16,10 +16,7 @@ import { EuiButton, EuiFieldText, } from '@elastic/eui'; - -// TODO: (clintandrewhall) This is a quick fix for #25342 -- we should figure out how to use the overall component. -import { Loading } from '../../../../public/components/loading/loading'; - +import { Loading } from '../../../../public/components/loading'; import { FileUpload } from '../../../../public/components/file_upload'; import { elasticOutline } from '../../../lib/elastic_outline'; import { resolveFromArgs } from '../../../../common/lib/resolve_dataurl'; diff --git a/x-pack/plugins/canvas/public/components/element_content/element_content.js b/x-pack/plugins/canvas/public/components/element_content/element_content.js index 8eba2aa2ba438..4a62f219b2ba5 100644 --- a/x-pack/plugins/canvas/public/components/element_content/element_content.js +++ b/x-pack/plugins/canvas/public/components/element_content/element_content.js @@ -23,8 +23,7 @@ const branches = [ // no renderable or renderable config value, render loading branch(({ renderable, state }) => { return !state || !renderable; - }, renderComponent(Loading)), - + }, renderComponent(({ backgroundColor }) => )), // renderable is available, but no matching element is found, render invalid branch(({ renderable, renderFunction }) => { return renderable && getType(renderable) !== 'render' && !renderFunction; @@ -90,4 +89,5 @@ ElementContent.propTypes = { onComplete: PropTypes.func.isRequired, // local, not passed through }).isRequired, state: PropTypes.string, + backgroundColor: PropTypes.string, }; diff --git a/x-pack/plugins/canvas/public/components/element_content/index.js b/x-pack/plugins/canvas/public/components/element_content/index.js index 969e96a994a3b..9a1e943df4e7f 100644 --- a/x-pack/plugins/canvas/public/components/element_content/index.js +++ b/x-pack/plugins/canvas/public/components/element_content/index.js @@ -5,12 +5,19 @@ */ import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; import { compose, withProps } from 'recompose'; import { get } from 'lodash'; import { renderFunctionsRegistry } from '../../lib/render_functions_registry'; +import { getSelectedPage, getPageById } from '../../state/selectors/workpad'; import { ElementContent as Component } from './element_content'; +const mapStateToProps = state => ({ + backgroundColor: getPageById(state, getSelectedPage(state)).style.background, +}); + export const ElementContent = compose( + connect(mapStateToProps), withProps(({ renderable }) => ({ renderFunction: renderFunctionsRegistry.get(get(renderable, 'as')), })) diff --git a/x-pack/plugins/canvas/public/components/loading/index.js b/x-pack/plugins/canvas/public/components/loading/index.js index 9216cb55d83c2..81fedf3287184 100644 --- a/x-pack/plugins/canvas/public/components/loading/index.js +++ b/x-pack/plugins/canvas/public/components/loading/index.js @@ -4,12 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { connect } from 'react-redux'; -import { getSelectedPage, getPageById } from '../../state/selectors/workpad'; +import { pure } from 'recompose'; import { Loading as Component } from './loading'; -const mapStateToProps = state => ({ - backgroundColor: getPageById(state, getSelectedPage(state)).style.background, -}); - -export const Loading = connect(mapStateToProps)(Component); +export const Loading = pure(Component); diff --git a/x-pack/plugins/canvas/public/components/loading/loading.js b/x-pack/plugins/canvas/public/components/loading/loading.js index 6b108a7606e8a..7a4b2083d7e4c 100644 --- a/x-pack/plugins/canvas/public/components/loading/loading.js +++ b/x-pack/plugins/canvas/public/components/loading/loading.js @@ -41,11 +41,12 @@ export const Loading = ({ animated, text, backgroundColor }) => { Loading.propTypes = { animated: PropTypes.bool, - text: PropTypes.string, backgroundColor: PropTypes.string, + text: PropTypes.string, }; Loading.defaultProps = { animated: false, + backgroundColor: '#000000', text: '', }; From 708638899fbc4bc6444d194f0d02db9faf56640f Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 19 Nov 2018 12:41:01 -0700 Subject: [PATCH 19/95] Feat: Support url params (#25828) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/elastic/kibana/issues/23046 Switch to a hash history manager that supports pushState and replaceState. This makes the "basepath" part of the hash's concern, so anything before the hash no longer matters. This also allows undoing a bunch of hacky fixes. This also allows the `urlparam` function to work again! ヽ(;▽;)ノ ![screenshot 2018-11-16 12 51 14 1](https://user-images.githubusercontent.com/404731/48645245-508a1300-e9a2-11e8-8959-1ede474b78dd.jpg) --- x-pack/package.json | 3 ++- .../canvas/public/lib/history_provider.js | 23 +++---------------- yarn.lock | 5 ++++ 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/x-pack/package.json b/x-pack/package.json index 249cc08c8b900..562bce88b34eb 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -175,6 +175,7 @@ "handlebars": "^4.0.10", "hapi-auth-cookie": "^9.0.0", "history": "4.7.2", + "history-extra": "^4.0.2", "humps": "2.0.1", "icalendar": "0.7.1", "inline-style": "^2.0.0", @@ -269,4 +270,4 @@ "engines": { "yarn": "^1.6.0" } -} \ No newline at end of file +} diff --git a/x-pack/plugins/canvas/public/lib/history_provider.js b/x-pack/plugins/canvas/public/lib/history_provider.js index 9b7f907ceeedf..65a5acc78526d 100644 --- a/x-pack/plugins/canvas/public/lib/history_provider.js +++ b/x-pack/plugins/canvas/public/lib/history_provider.js @@ -4,11 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import chrome from 'ui/chrome'; import lzString from 'lz-string'; -import { createBrowserHistory, createMemoryHistory, parsePath, createPath } from 'history'; -import { get } from 'lodash'; -import { APP_ROUTE } from '../../common/lib/constants'; +import { createMemoryHistory, parsePath, createPath } from 'history'; +import createHashStateHistory from 'history-extra'; import { getWindow } from './get_window'; function wrapHistoryInstance(history) { @@ -132,17 +130,7 @@ const instances = new WeakMap(); const getHistoryInstance = win => { // if no window object, use memory module if (typeof win === 'undefined' || !win.history) return createMemoryHistory(); - - const basePath = chrome.getBasePath(); - const basename = `${basePath}${APP_ROUTE}#/`; - - // hacky fix for initial page load so basename matches with the hash - if (win.location.hash === '') win.history.replaceState({}, '', `${basename}`); - - // if window object, create browser instance - return createBrowserHistory({ - basename, - }); + return createHashStateHistory(); }; export const historyProvider = (win = getWindow()) => { @@ -150,11 +138,6 @@ export const historyProvider = (win = getWindow()) => { const instance = instances.get(win); if (instance) return instance; - // temporary fix for search params before the hash; remove them via location redirect - // they can't be preserved given this upstream issue https://github.com/ReactTraining/history/issues/564 - if (get(win, 'location.search', '').length > 0) - win.location = `${chrome.getBasePath()}${APP_ROUTE}${win.location.hash}`; - // create and cache wrapped history instance const historyInstance = getHistoryInstance(win); const wrappedInstance = wrapHistoryInstance(historyInstance); diff --git a/yarn.lock b/yarn.lock index 7aa4417df69e4..020634c9425b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10595,6 +10595,11 @@ highlight.js@^9.12.0, highlight.js@~9.12.0: resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.12.0.tgz#e6d9dbe57cbefe60751f02af336195870c90c01e" integrity sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4= +history-extra@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/history-extra/-/history-extra-4.0.2.tgz#67b512c196e0a521be1d8ac83513f00ca761d9f3" + integrity sha512-Nia8vzQHyQcxKQUt5/vxZegurkG2K23TplaWLk1V6EWTuNdZMJUJ78anwGkBcHuLBia8TFUct/R/QDlgRUA42A== + history@4.7.2, history@^4.7.2: version "4.7.2" resolved "https://registry.yarnpkg.com/history/-/history-4.7.2.tgz#22b5c7f31633c5b8021c7f4a8a954ac139ee8d5b" From 0958e1d1d9bee1938df3c7f6110b08a79653544f Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 19 Nov 2018 13:22:04 -0700 Subject: [PATCH 20/95] add comment about docvalue for date fields in getComputedFields (#25725) --- src/ui/public/index_patterns/_get_computed_fields.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ui/public/index_patterns/_get_computed_fields.js b/src/ui/public/index_patterns/_get_computed_fields.js index 527ca74821eb3..422165b890324 100644 --- a/src/ui/public/index_patterns/_get_computed_fields.js +++ b/src/ui/public/index_patterns/_get_computed_fields.js @@ -18,13 +18,15 @@ */ import _ from 'lodash'; -// Takes a hit, merges it with any stored/scripted fields, and with the metaFields -// returns a flattened version + export function getComputedFields() { const self = this; const scriptFields = {}; let docvalueFields = []; + // Date value returned in "_source" could be in any number of formats + // Use a docvalue for each date field to ensure standardized formats when working with date fields + // indexPattern.flattenHit will override "_source" values when the same field is also defined in "fields" docvalueFields = _.reject(self.fields.byType.date, 'scripted') .map((dateField) => { return { From a5076b5172f1f394a257b0e3736b4385f5f07923 Mon Sep 17 00:00:00 2001 From: Caroline Horn <549577+cchaos@users.noreply.github.com> Date: Mon, 19 Nov 2018 16:05:52 -0500 Subject: [PATCH 21/95] Vis public UI LESS to SASS (#25333) --- .../kibana/public/dashboard/_index.scss | 7 +- .../dashboard/panel/_dashboard_panel.scss | 2 +- src/core_plugins/kibana/public/index.scss | 5 +- .../region_map/public/tooltip.html | 4 +- .../tile_map/public/editors/_tooltip.html | 4 +- src/fixtures/vislib/_vis_fixture.js | 2 +- src/ui/public/_index.scss | 5 + .../agg_response/hierarchical/_tooltip.html | 8 +- .../agg_response/point_series/_tooltip.html | 4 +- src/ui/public/styles/table.less | 4 - src/ui/public/styles/variables/for-theme.less | 36 -- src/ui/public/vis/_index.scss | 5 +- src/ui/public/vis/components/_index.scss | 1 + .../public/vis/components/tooltip/_index.scss | 1 + .../vis/components/tooltip/_tooltip.scss | 66 ++++ .../public/vis/components/tooltip/tooltip.js | 6 +- src/ui/public/vis/editors/_index.scss | 2 + .../public/vis/editors/default/_default.scss | 2 +- src/ui/public/vis/map/_leaflet_overrides.scss | 13 +- src/ui/public/vis/vis_types/_index.scss | 2 + .../vis/vis_types/_vislib_vis_legend.scss | 112 ++++++ .../vis/vis_types/_vislib_vis_type.scss | 26 ++ .../vis/vis_types/vislib_vis_legend.html | 20 +- .../public/vis/vis_types/vislib_vis_type.js | 14 +- src/ui/public/vislib/__tests__/index.js | 1 - .../public/vislib/__tests__/lib/axis/axis.js | 2 +- .../public/vislib/__tests__/lib/axis_title.js | 6 +- .../vislib/__tests__/lib/chart_title.js | 2 +- .../vislib/__tests__/lib/layout/layout.js | 20 +- .../lib/layout/splits/column_chart/splits.js | 26 +- .../lib/layout/splits/gauge_chart/splits.js | 16 +- .../public/vislib/__tests__/lib/vis_config.js | 2 +- src/ui/public/vislib/__tests__/lib/x_axis.js | 2 +- src/ui/public/vislib/__tests__/vis.js | 4 +- .../__tests__/visualizations/gauge_chart.js | 4 +- .../__tests__/visualizations/pie_chart.js | 4 +- src/ui/public/vislib/_index.scss | 3 + src/ui/public/vislib/_variables.scss | 5 + src/ui/public/vislib/lib/_alerts.scss | 55 +++ src/ui/public/vislib/lib/_handler.scss | 21 ++ src/ui/public/vislib/lib/_index.scss | 4 + src/ui/public/vislib/lib/alerts.js | 16 +- src/ui/public/vislib/lib/axis/axis.js | 4 +- src/ui/public/vislib/lib/axis/axis_config.js | 4 +- src/ui/public/vislib/lib/handler.js | 2 +- src/ui/public/vislib/lib/layout/_index.scss | 1 + src/ui/public/vislib/lib/layout/_layout.scss | 332 ++++++++++++++++++ src/ui/public/vislib/lib/layout/layout.js | 6 +- .../layout/splits/column_chart/chart_split.js | 16 +- .../splits/column_chart/chart_title_split.js | 10 +- .../splits/column_chart/x_axis_split.js | 6 +- .../splits/column_chart/y_axis_split.js | 6 +- .../layout/splits/gauge_chart/chart_split.js | 8 +- .../splits/gauge_chart/chart_title_split.js | 8 +- .../layout/splits/pie_chart/chart_split.js | 8 +- .../splits/pie_chart/chart_title_split.js | 8 +- .../vislib/lib/layout/types/column_layout.js | 40 +-- .../vislib/lib/layout/types/gauge_layout.js | 12 +- .../vislib/lib/layout/types/pie_layout.js | 10 +- .../vislib/partials/touchdown.tmpl.html | 10 +- src/ui/public/vislib/styles/_alerts.less | 61 ---- src/ui/public/vislib/styles/_error.less | 10 - src/ui/public/vislib/styles/_layout.less | 272 -------------- src/ui/public/vislib/styles/_legend.less | 153 -------- src/ui/public/vislib/styles/_svg.less | 114 ------ src/ui/public/vislib/styles/_tooltip.less | 82 ----- src/ui/public/vislib/styles/main.less | 8 - src/ui/public/vislib/vis.js | 3 +- src/ui/public/vislib/vislib.js | 1 - .../visualizations/point_series/area_chart.js | 2 +- src/ui/public/visualize/_index.scss | 1 + .../visualization_noresults.test.js.snap | 2 +- .../visualization_requesterror.test.js.snap | 4 +- .../public/visualize/components/_index.scss | 1 + ...visualization.less => _visualization.scss} | 45 +-- .../visualize/components/visualization.tsx | 2 - .../components/visualization_chart.test.js | 4 +- .../components/visualization_chart.tsx | 4 +- .../components/visualization_noresults.tsx | 2 +- .../components/visualization_requesterror.tsx | 4 +- test/functional/page_objects/discover_page.js | 6 +- .../page_objects/point_series_page.js | 2 +- .../functional/page_objects/visualize_page.js | 12 +- .../plugins/ml/public/explorer/_explorer.scss | 5 +- .../plugins/ml/public/explorer/explorer.html | 2 +- .../common/layouts/preserve_layout.css | 4 +- .../export_types/common/layouts/print.css | 4 +- 87 files changed, 864 insertions(+), 981 deletions(-) create mode 100644 src/ui/public/_index.scss create mode 100644 src/ui/public/vis/components/_index.scss create mode 100644 src/ui/public/vis/components/tooltip/_index.scss create mode 100644 src/ui/public/vis/components/tooltip/_tooltip.scss create mode 100644 src/ui/public/vis/editors/_index.scss create mode 100644 src/ui/public/vis/vis_types/_index.scss create mode 100644 src/ui/public/vis/vis_types/_vislib_vis_legend.scss create mode 100644 src/ui/public/vis/vis_types/_vislib_vis_type.scss create mode 100644 src/ui/public/vislib/_index.scss create mode 100644 src/ui/public/vislib/_variables.scss create mode 100644 src/ui/public/vislib/lib/_alerts.scss create mode 100644 src/ui/public/vislib/lib/_handler.scss create mode 100644 src/ui/public/vislib/lib/_index.scss create mode 100644 src/ui/public/vislib/lib/layout/_index.scss create mode 100644 src/ui/public/vislib/lib/layout/_layout.scss delete mode 100644 src/ui/public/vislib/styles/_alerts.less delete mode 100644 src/ui/public/vislib/styles/_error.less delete mode 100644 src/ui/public/vislib/styles/_layout.less delete mode 100644 src/ui/public/vislib/styles/_legend.less delete mode 100644 src/ui/public/vislib/styles/_svg.less delete mode 100644 src/ui/public/vislib/styles/_tooltip.less delete mode 100644 src/ui/public/vislib/styles/main.less create mode 100644 src/ui/public/visualize/_index.scss create mode 100644 src/ui/public/visualize/components/_index.scss rename src/ui/public/visualize/components/{visualization.less => _visualization.scss} (56%) diff --git a/src/core_plugins/kibana/public/dashboard/_index.scss b/src/core_plugins/kibana/public/dashboard/_index.scss index de00e0d670d22..98e918e507d92 100644 --- a/src/core_plugins/kibana/public/dashboard/_index.scss +++ b/src/core_plugins/kibana/public/dashboard/_index.scss @@ -41,8 +41,7 @@ @import 'panel/index'; @import 'viewport/index'; - // Vis imports -- will have some duplicate styling - // because they will be imported via ui/public as well - // (without .theme-[] prefix) - @import 'src/ui/public/vis/map/index'; + // Vis imports + @import 'src/ui/public/vis/index'; + @import 'src/ui/public/vislib/index'; } diff --git a/src/core_plugins/kibana/public/dashboard/panel/_dashboard_panel.scss b/src/core_plugins/kibana/public/dashboard/panel/_dashboard_panel.scss index 6efb9d4f25b0d..70a4b0e76a669 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/_dashboard_panel.scss +++ b/src/core_plugins/kibana/public/dashboard/panel/_dashboard_panel.scss @@ -35,7 +35,7 @@ @include euiScrollBar; /* 3 */ } - .visualization .vis-container { + .visualization .visChart__container { overflow: visible; /* 2 */ } } diff --git a/src/core_plugins/kibana/public/index.scss b/src/core_plugins/kibana/public/index.scss index 390694b0a52c2..b415106ede3bf 100644 --- a/src/core_plugins/kibana/public/index.scss +++ b/src/core_plugins/kibana/public/index.scss @@ -1,6 +1,7 @@ @import 'ui/public/styles/styling_constants'; -@import 'ui/public/query_bar/index'; +// Public UI styles +@import 'ui/public/index'; // Context styles @import './context/index'; @@ -16,6 +17,8 @@ // Visualize styles @import './visualize/index'; +// Has to come after visualize because of some +// bad cascading in the Editor layout @import 'ui/public/vis/index'; // Management styles diff --git a/src/core_plugins/region_map/public/tooltip.html b/src/core_plugins/region_map/public/tooltip.html index b0d07cb80e4b3..0d57120c80a98 100644 --- a/src/core_plugins/region_map/public/tooltip.html +++ b/src/core_plugins/region_map/public/tooltip.html @@ -1,8 +1,8 @@ - - + +
{{detail.label}}{{detail.value}}{{detail.label}}{{detail.value}}
diff --git a/src/core_plugins/tile_map/public/editors/_tooltip.html b/src/core_plugins/tile_map/public/editors/_tooltip.html index c05a261ed6e43..9df5b94a21eda 100644 --- a/src/core_plugins/tile_map/public/editors/_tooltip.html +++ b/src/core_plugins/tile_map/public/editors/_tooltip.html @@ -1,8 +1,8 @@ - - + +
{{detail.label}}{{detail.value}}{{detail.label}}{{detail.value}}
diff --git a/src/fixtures/vislib/_vis_fixture.js b/src/fixtures/vislib/_vis_fixture.js index 056e0a2141a62..c61d21a305d24 100644 --- a/src/fixtures/vislib/_vis_fixture.js +++ b/src/fixtures/vislib/_vis_fixture.js @@ -41,7 +41,7 @@ const visHeight = $visCanvas.height(); $visCanvas.new = function () { count += 1; if (count > 1) $visCanvas.height(visHeight * count); - return $('
').addClass('visualize-chart').appendTo($visCanvas); + return $('
').addClass('visChart').appendTo($visCanvas); }; afterEach(function () { diff --git a/src/ui/public/_index.scss b/src/ui/public/_index.scss new file mode 100644 index 0000000000000..828c9b6860d80 --- /dev/null +++ b/src/ui/public/_index.scss @@ -0,0 +1,5 @@ +@import './query_bar/index'; +// Can't import vis folder here because of cascading issues, it's imported in core_plugins/kibana +// @import './vis/index'; +@import './vislib/index'; +@import './visualize/index'; diff --git a/src/ui/public/agg_response/hierarchical/_tooltip.html b/src/ui/public/agg_response/hierarchical/_tooltip.html index 6688d9270910f..de59cf871d46f 100644 --- a/src/ui/public/agg_response/hierarchical/_tooltip.html +++ b/src/ui/public/agg_response/hierarchical/_tooltip.html @@ -1,15 +1,15 @@ - +
- + - + - + diff --git a/src/ui/public/agg_response/point_series/_tooltip.html b/src/ui/public/agg_response/point_series/_tooltip.html index 2384fab317f2b..d6054594ec776 100644 --- a/src/ui/public/agg_response/point_series/_tooltip.html +++ b/src/ui/public/agg_response/point_series/_tooltip.html @@ -1,8 +1,8 @@
field value {{metricCol.label}}
{{row.field}}{{row.bucket}}{{row.bucket}} {{row.metric}}
- - + diff --git a/src/ui/public/styles/table.less b/src/ui/public/styles/table.less index 30db0c0da8e89..37dc2f27b4083 100644 --- a/src/ui/public/styles/table.less +++ b/src/ui/public/styles/table.less @@ -79,8 +79,4 @@ table { } } } - - .slice { - stroke: #272727; - } } diff --git a/src/ui/public/styles/variables/for-theme.less b/src/ui/public/styles/variables/for-theme.less index 935e8851db9af..5275cd582a752 100644 --- a/src/ui/public/styles/variables/for-theme.less +++ b/src/ui/public/styles/variables/for-theme.less @@ -193,32 +193,7 @@ @alert-color: @white; -// Truncate ==================================================================== -@truncate-color: @body-bg; - - -// Typeahead =================================================================== -@typeahead-items-border: @globalColorLightGray; -@typeahead-items-color: @text-color; -@typeahead-items-bg: @body-bg; - -@typeahead-item-color: @text-color; -@typeahead-item-border: @globalColorLightGray; -@typeahead-item-bg: @body-bg; -@typeahead-item-active-bg: @globalColorBlue; - - -// Alerts ====================================================================== -@alert-vis-alert-color: @white; -@alert-vis-alert-border: @white; - - -// Legend ====================================================================== -@legend-item-color: #666; - // Tooltip ===================================================================== -@tooltip-space: 8px; -@tooltip-space-tight: @tooltip-space / 2; @tooltip-bg: fadeout(darken(@globalColorBlue, 30%), 10%); @tooltip-color: @globalColorWhite; @@ -227,17 +202,6 @@ @tooltip-bold: 600; - -// Svg ========================================================================= -@svg-axis-color: #ddd; -@svg-tick-text-color: #848e96; -@svg-brush-color: @white; -@svg-endzone-bg: @black; - -@vis-axis-title-color: #848e96; -@vis-chart-title-color: #848e96; - - // Saved Object Finder ========================================================= @saved-object-finder-link-color: @link-color; @saved-object-finder-icon-color: darken(@saved-object-finder-link-color, 10%); diff --git a/src/ui/public/vis/_index.scss b/src/ui/public/vis/_index.scss index df72751181ac7..4fb07557977d3 100644 --- a/src/ui/public/vis/_index.scss +++ b/src/ui/public/vis/_index.scss @@ -1,3 +1,4 @@ -@import './editors/components/index'; -@import './editors/default/index'; +@import './components/index'; +@import './editors/index'; @import './map/index'; +@import './vis_types/index'; diff --git a/src/ui/public/vis/components/_index.scss b/src/ui/public/vis/components/_index.scss new file mode 100644 index 0000000000000..0d79aa9c458ac --- /dev/null +++ b/src/ui/public/vis/components/_index.scss @@ -0,0 +1 @@ +@import './tooltip/index'; diff --git a/src/ui/public/vis/components/tooltip/_index.scss b/src/ui/public/vis/components/tooltip/_index.scss new file mode 100644 index 0000000000000..f4e7075ff7b4f --- /dev/null +++ b/src/ui/public/vis/components/tooltip/_index.scss @@ -0,0 +1 @@ +@import './tooltip'; diff --git a/src/ui/public/vis/components/tooltip/_tooltip.scss b/src/ui/public/vis/components/tooltip/_tooltip.scss new file mode 100644 index 0000000000000..28b8e485e15ff --- /dev/null +++ b/src/ui/public/vis/components/tooltip/_tooltip.scss @@ -0,0 +1,66 @@ +// EUITODO: Use EuiTooltip or create a tooltip mixin +.visTooltip, +.visTooltip__sizingClone { + @include euiBottomShadow($color: $euiColorFullShade); + @include euiFontSizeXS; + visibility: hidden; + pointer-events: none; + position: fixed; + z-index: $euiZLevel9; + background-color: tintOrShade($euiColorFullShade, 25%, 90%); + color: $euiColorGhost; + border-radius: $euiBorderRadius; + max-width: $euiSizeXL * 10; + overflow: hidden; + overflow-wrap: break-word; + + > :last-child { + margin-bottom: $euiSizeS; + } + + > * { + margin: $euiSizeS $euiSizeS 0; + } + + table { + td, + th { + padding: $euiSizeXS; + } + } +} + +.visTooltip__header { + margin: 0 0 $euiSizeS 0; + padding: $euiSizeXS $euiSizeS; + display: flex; + align-items: center; + + &:last-child { + margin-bottom: 0; + } + + + * { + margin-top: $euiSizeS; + } +} + +.visTooltip__headerIcon { + flex: 0 0 auto; + padding-right: $euiSizeS; +} + +.visTooltip__headerText { + flex: 1 1 100%; +} + +.visTooltip__label { + // max-width: $euiSizeXL * 3; + font-weight: $euiFontWeightMedium; + color: shade($euiColorGhost, 20%); +} + +.visTooltip__sizingClone { + top: -500px; + left: -500px; +} diff --git a/src/ui/public/vis/components/tooltip/tooltip.js b/src/ui/public/vis/components/tooltip/tooltip.js index 15f2d9b6caaf8..6008d5cf7961a 100644 --- a/src/ui/public/vis/components/tooltip/tooltip.js +++ b/src/ui/public/vis/components/tooltip/tooltip.js @@ -44,9 +44,9 @@ export function Tooltip(id, el, formatter, events) { this.order = 100; // higher ordered contents are rendered below the others this.formatter = formatter; this.events = events; - this.containerClass = 'vis-wrapper'; - this.tooltipClass = 'vis-tooltip'; - this.tooltipSizerClass = 'vis-tooltip-sizing-clone'; + this.containerClass = 'visWrapper'; + this.tooltipClass = 'visTooltip'; + this.tooltipSizerClass = 'visTooltip__sizingClone'; this.showCondition = _.constant(true); this.binder = new Binder(); diff --git a/src/ui/public/vis/editors/_index.scss b/src/ui/public/vis/editors/_index.scss new file mode 100644 index 0000000000000..da6e0bd8837e8 --- /dev/null +++ b/src/ui/public/vis/editors/_index.scss @@ -0,0 +1,2 @@ +@import './components/index'; +@import './default/index'; diff --git a/src/ui/public/vis/editors/default/_default.scss b/src/ui/public/vis/editors/default/_default.scss index b1de3b8343e21..40fca7d444625 100644 --- a/src/ui/public/vis/editors/default/_default.scss +++ b/src/ui/public/vis/editors/default/_default.scss @@ -106,7 +106,7 @@ flex: 1 1 100%; } - .visualize-chart { + .visChart { position: relative; } } diff --git a/src/ui/public/vis/map/_leaflet_overrides.scss b/src/ui/public/vis/map/_leaflet_overrides.scss index e54c2dd092a4e..c2c33b1c26f6b 100644 --- a/src/ui/public/vis/map/_leaflet_overrides.scss +++ b/src/ui/public/vis/map/_leaflet_overrides.scss @@ -18,6 +18,13 @@ $visMapLeafletSprite: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/s min-height: 1px !important; } +.leaflet-clickable { + &:hover { + stroke-width: $euiSizeS; + stroke-opacity: 0.8; + } +} + /** * 1. Since Leaflet is an external library, we also have to provide EUI variables * to non-override colors for darkmode. @@ -56,7 +63,7 @@ $visMapLeafletSprite: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/s padding: 0; background: $temp-euiTooltipBackground; color: $temp-euiTooltipText; - border-radius: $euiBorderRadius; + border-radius: $euiBorderRadius !important; // Override all positions the popup might be at } .leaflet-popup { @@ -82,10 +89,6 @@ $visMapLeafletSprite: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/s table { td,th { padding: $euiSizeXS; - - &.row-bucket { - word-break: break-all; - } } } } diff --git a/src/ui/public/vis/vis_types/_index.scss b/src/ui/public/vis/vis_types/_index.scss new file mode 100644 index 0000000000000..9d86383ec40b2 --- /dev/null +++ b/src/ui/public/vis/vis_types/_index.scss @@ -0,0 +1,2 @@ +@import './vislib_vis_type'; +@import './vislib_vis_legend'; diff --git a/src/ui/public/vis/vis_types/_vislib_vis_legend.scss b/src/ui/public/vis/vis_types/_vislib_vis_legend.scss new file mode 100644 index 0000000000000..4b2d9508dd535 --- /dev/null +++ b/src/ui/public/vis/vis_types/_vislib_vis_legend.scss @@ -0,0 +1,112 @@ +@import '../../vislib/variables'; + +// NOTE: Some of the styles attempt to align with the TSVB legend + +.visLegend__toggle { + align-self: flex-start; + // Override .kuiCollapseButton + color: $visValueColor !important; +} + +.visLegend { + @include euiFontSizeXS; + display: flex; + flex-direction: row; + padding: $euiSizeXS 0; + overflow: auto; + min-height: 0; + height: 100%; + overflow: hidden; + + // flex-direction re-aligns toggle button + .visLib--legend-left & { + flex-direction: row-reverse; + } + + .visLib--legend-right & { + flex-direction: row; + } + + .visLib--legend-top & { + flex-direction: column-reverse; + width: 100%; + padding-left: $euiSizeL; + + } + .visLib--legend-bottom & { + flex-direction: column; + width: 100%; + padding-left: $euiSizeL; + } + + .visLegend__list { + width: 150px; // Must be a hard-coded width for the chart to get its correct dimensions + flex: 1 1 auto; + flex-direction: column; + min-height: 0; + overflow-x: hidden; + overflow-y: auto; + + .visLib--legend-top &, + .visLib--legend-bottom & { + width: auto; + overflow-y: hidden; + + .visLegend__value { + display: inline-block; + } + } + + &.hidden { + visibility: hidden; + } + } +} + +.visLegend__value { + cursor: pointer; + padding: $euiSizeXS; + display: flex; + + > * { + max-width: 100%; + } + + &.disabled { + opacity: 0.5; + } +} + +.visLegend__valueTitle { + color: $visTextColor; + + &:hover { + text-decoration: underline; + } +} + +.visLegend__valueTitle--truncate { + @include euiTextTruncate; +} + +.visLegend__valueTitle--full { + word-break: break-all; +} + +.visLegend__valueDetails { + border-bottom: 1px solid $euiColorLightShade; + padding-bottom: $euiSizeXS; +} + +.visLegend__valueColorPicker { + width: $euiSizeM * 10; + margin: auto; + + .visLegend__valueColorPickerDot { + margin: $euiSizeXS / 2; + + &:hover { + transform: scale(1.4); + } + } +} diff --git a/src/ui/public/vis/vis_types/_vislib_vis_type.scss b/src/ui/public/vis/vis_types/_vislib_vis_type.scss new file mode 100644 index 0000000000000..c1f369d3e3536 --- /dev/null +++ b/src/ui/public/vis/vis_types/_vislib_vis_type.scss @@ -0,0 +1,26 @@ +.visLib { + flex: 1 1 0; + display: flex; + flex-direction: row; + overflow: auto; + + &.visLib--legend-left { + flex-direction: row-reverse; + } + &.visLib--legend-right { + flex-direction: row; + } + &.visLib--legend-top { + flex-direction: column-reverse; + } + &.visLib--legend-bottom { + flex-direction: column; + } +} + +.visLib__chart { + display: flex; + flex: 1 1 auto; + min-height: 0; + min-width: 0; +} diff --git a/src/ui/public/vis/vis_types/vislib_vis_legend.html b/src/ui/public/vis/vis_types/vislib_vis_legend.html index 4faa4836145fc..bfc464e8d8040 100644 --- a/src/ui/public/vis/vis_types/vislib_vis_legend.html +++ b/src/ui/public/vis/vis_types/vislib_vis_legend.html @@ -1,8 +1,8 @@ -
+
-
    +
    • -
      +
      -
      +
      -
      +
      diff --git a/src/ui/public/vis/vis_types/vislib_vis_type.js b/src/ui/public/vis/vis_types/vislib_vis_type.js index 39213dd58c851..15a3f69eda87c 100644 --- a/src/ui/public/vis/vis_types/vislib_vis_type.js +++ b/src/ui/public/vis/vis_types/vislib_vis_type.js @@ -38,10 +38,10 @@ export function VislibVisTypeProvider(Private, $rootScope, $timeout, $compile) { const BaseVisType = Private(BaseVisTypeProvider); const legendClassName = { - top: 'vislib-container--legend-top', - bottom: 'vislib-container--legend-bottom', - left: 'vislib-container--legend-left', - right: 'vislib-container--legend-right', + top: 'visLib--legend-top', + bottom: 'visLib--legend-bottom', + left: 'visLib--legend-left', + right: 'visLib--legend-right', }; class VislibVisController { @@ -51,11 +51,11 @@ export function VislibVisTypeProvider(Private, $rootScope, $timeout, $compile) { this.$scope = null; this.container = document.createElement('div'); - this.container.className = 'vislib-container'; + this.container.className = 'visLib'; this.el.appendChild(this.container); this.chartEl = document.createElement('div'); - this.chartEl.className = 'vislib-chart'; + this.chartEl.className = 'visLib__chart'; this.container.appendChild(this.chartEl); } @@ -72,7 +72,7 @@ export function VislibVisTypeProvider(Private, $rootScope, $timeout, $compile) { if (this.vis.params.addLegend) { $(this.container).attr('class', (i, cls) => { - return cls.replace(/vislib-container--legend-\S+/g, ''); + return cls.replace(/visLib--legend-\S+/g, ''); }).addClass(legendClassName[this.vis.params.legendPosition]); this.$scope = $rootScope.$new(); diff --git a/src/ui/public/vislib/__tests__/index.js b/src/ui/public/vislib/__tests__/index.js index dbdd17028aee7..cfed27d817063 100644 --- a/src/ui/public/vislib/__tests__/index.js +++ b/src/ui/public/vislib/__tests__/index.js @@ -21,7 +21,6 @@ import _ from 'lodash'; import expect from 'expect.js'; import ngMock from 'ng_mock'; -import '../styles/main.less'; import VislibProvider from '..'; describe('Vislib Index Test Suite', function () { diff --git a/src/ui/public/vislib/__tests__/lib/axis/axis.js b/src/ui/public/vislib/__tests__/lib/axis/axis.js index 0f5d2281bec58..52add55f50430 100644 --- a/src/ui/public/vislib/__tests__/lib/axis/axis.js +++ b/src/ui/public/vislib/__tests__/lib/axis/axis.js @@ -109,7 +109,7 @@ describe('Vislib Axis Class Test Suite', function () { VisConfig = Private(VislibVisConfigProvider); el = d3.select('body').append('div') - .attr('class', 'x-axis-wrapper') + .attr('class', 'visAxis--x') .style('height', '40px'); fixture = el.append('div') diff --git a/src/ui/public/vislib/__tests__/lib/axis_title.js b/src/ui/public/vislib/__tests__/lib/axis_title.js index 9bd9cc91537f0..0541261c089ad 100644 --- a/src/ui/public/vislib/__tests__/lib/axis_title.js +++ b/src/ui/public/vislib/__tests__/lib/axis_title.js @@ -107,17 +107,17 @@ describe('Vislib AxisTitle Class Test Suite', function () { PersistedState = $injector.get('PersistedState'); el = d3.select('body').append('div') - .attr('class', 'vis-wrapper'); + .attr('class', 'visWrapper'); el.append('div') - .attr('class', 'axis-wrapper-bottom') + .attr('class', 'visAxis__column--bottom') .append('div') .attr('class', 'axis-title y-axis-title') .style('height', '20px') .style('width', '20px'); el.append('div') - .attr('class', 'axis-wrapper-left') + .attr('class', 'visAxis__column--left') .append('div') .attr('class', 'axis-title x-axis-title') .style('height', '20px') diff --git a/src/ui/public/vislib/__tests__/lib/chart_title.js b/src/ui/public/vislib/__tests__/lib/chart_title.js index 5955c19a02fc4..e88896d70872d 100644 --- a/src/ui/public/vislib/__tests__/lib/chart_title.js +++ b/src/ui/public/vislib/__tests__/lib/chart_title.js @@ -97,7 +97,7 @@ describe('Vislib ChartTitle Class Test Suite', function () { persistedState = new ($injector.get('PersistedState'))(); el = d3.select('body').append('div') - .attr('class', 'vis-wrapper') + .attr('class', 'visWrapper') .datum(data); el.append('div') diff --git a/src/ui/public/vislib/__tests__/lib/layout/layout.js b/src/ui/public/vislib/__tests__/lib/layout/layout.js index 8406cf3bf03c9..149f2e87cc302 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/layout.js +++ b/src/ui/public/vislib/__tests__/lib/layout/layout.js @@ -73,16 +73,16 @@ dateHistogramArray.forEach(function (data, i) { describe('createLayout Method', function () { it('should append all the divs', function () { - expect($(vis.el).find('.vis-wrapper').length).to.be(1); - expect($(vis.el).find('.y-axis-col-wrapper').length).to.be(2); - expect($(vis.el).find('.vis-col-wrapper').length).to.be(1); - expect($(vis.el).find('.y-axis-col').length).to.be(2); + expect($(vis.el).find('.visWrapper').length).to.be(1); + expect($(vis.el).find('.visAxis--y').length).to.be(2); + expect($(vis.el).find('.visWrapper__column').length).to.be(1); + expect($(vis.el).find('.visAxis__column--y').length).to.be(2); expect($(vis.el).find('.y-axis-title').length).to.be.above(0); - expect($(vis.el).find('.y-axis-div-wrapper').length).to.be(2); - expect($(vis.el).find('.y-axis-spacer-block').length).to.be(4); - expect($(vis.el).find('.chart-wrapper').length).to.be(numberOfCharts); - expect($(vis.el).find('.x-axis-wrapper').length).to.be(2); - expect($(vis.el).find('.x-axis-div-wrapper').length).to.be(2); + expect($(vis.el).find('.visAxis__splitAxes--y').length).to.be(2); + expect($(vis.el).find('.visAxis__spacer--y').length).to.be(4); + expect($(vis.el).find('.visWrapper__chart').length).to.be(numberOfCharts); + expect($(vis.el).find('.visAxis--x').length).to.be(2); + expect($(vis.el).find('.visAxis__splitAxes--x').length).to.be(2); expect($(vis.el).find('.x-axis-title').length).to.be.above(0); }); }); @@ -147,7 +147,7 @@ dateHistogramArray.forEach(function (data, i) { describe('appendElem Method', function () { beforeEach(function () { vis.handler.layout.appendElem(vis.el, 'svg', 'column'); - vis.handler.layout.appendElem('.visualize-chart', 'div', 'test'); + vis.handler.layout.appendElem('.visChart', 'div', 'test'); }); it('should append DOM element to el with a class name', function () { diff --git a/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js b/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js index 4b8f242517ed3..185597f1ac3c1 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js +++ b/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js @@ -186,7 +186,7 @@ describe('Vislib Split Function Test Suite', function () { }); it('should add the correct class name', function () { - expect(!!$('.chart-wrapper-row').length).to.be(true); + expect(!!$('.visWrapper__splitCharts--row').length).to.be(true); }); }); @@ -196,20 +196,20 @@ describe('Vislib Split Function Test Suite', function () { let fixture; beforeEach(ngMock.inject(function () { - visEl = el.append('div').attr('class', 'vis-wrapper'); - visEl.append('div').attr('class', 'x-axis-chart-title'); - visEl.append('div').attr('class', 'y-axis-chart-title'); - visEl.select('.x-axis-chart-title').call(chartTitleSplit); - visEl.select('.y-axis-chart-title').call(chartTitleSplit); + visEl = el.append('div').attr('class', 'visWrapper'); + visEl.append('div').attr('class', 'visAxis__splitTitles--x'); + visEl.append('div').attr('class', 'visAxis__splitTitles--y'); + visEl.select('.visAxis__splitTitles--x').call(chartTitleSplit); + visEl.select('.visAxis__splitTitles--y').call(chartTitleSplit); newEl = d3.select('body').append('div') - .attr('class', 'vis-wrapper') + .attr('class', 'visWrapper') .datum({ series: [] }); - newEl.append('div').attr('class', 'x-axis-chart-title'); - newEl.append('div').attr('class', 'y-axis-chart-title'); - newEl.select('.x-axis-chart-title').call(chartTitleSplit); - newEl.select('.y-axis-chart-title').call(chartTitleSplit); + newEl.append('div').attr('class', 'visAxis__splitTitles--x'); + newEl.append('div').attr('class', 'visAxis__splitTitles--y'); + newEl.select('.visAxis__splitTitles--x').call(chartTitleSplit); + newEl.select('.visAxis__splitTitles--y').call(chartTitleSplit); fixture = newEl.selectAll(this.childNodes)[0].length; })); @@ -223,8 +223,8 @@ describe('Vislib Split Function Test Suite', function () { }); it('should remove the correct div', function () { - expect($('.y-axis-chart-title').length).to.be(1); - expect($('.x-axis-chart-title').length).to.be(0); + expect($('.visAxis__splitTitles--y').length).to.be(1); + expect($('.visAxis__splitTitles--x').length).to.be(0); }); it('should remove all chart title divs when only one chart is rendered', function () { diff --git a/src/ui/public/vislib/__tests__/lib/layout/splits/gauge_chart/splits.js b/src/ui/public/vislib/__tests__/lib/layout/splits/gauge_chart/splits.js index cb849bc6bf601..2fe0cc2b7fbea 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/splits/gauge_chart/splits.js +++ b/src/ui/public/vislib/__tests__/lib/layout/splits/gauge_chart/splits.js @@ -180,7 +180,7 @@ describe('Vislib Gauge Split Function Test Suite', function () { }); it('should add the correct class name', function () { - expect(!!$('.chart-wrapper-row').length).to.be(true); + expect(!!$('.visWrapper__splitCharts--row').length).to.be(true); }); }); @@ -188,11 +188,11 @@ describe('Vislib Gauge Split Function Test Suite', function () { let visEl; beforeEach(ngMock.inject(function () { - visEl = el.append('div').attr('class', 'vis-wrapper'); - visEl.append('div').attr('class', 'x-axis-chart-title'); - visEl.append('div').attr('class', 'y-axis-chart-title'); - visEl.select('.x-axis-chart-title').call(chartTitleSplit); - visEl.select('.y-axis-chart-title').call(chartTitleSplit); + visEl = el.append('div').attr('class', 'visWrapper'); + visEl.append('div').attr('class', 'visAxis__splitTitles--x'); + visEl.append('div').attr('class', 'visAxis__splitTitles--y'); + visEl.select('.visAxis__splitTitles--x').call(chartTitleSplit); + visEl.select('.visAxis__splitTitles--y').call(chartTitleSplit); })); @@ -201,8 +201,8 @@ describe('Vislib Gauge Split Function Test Suite', function () { }); it('should append the correct number of divs', function () { - expect($('.x-axis-chart-title .chart-title').length).to.be(2); - expect($('.y-axis-chart-title .chart-title').length).to.be(2); + expect($('.visAxis__splitTitles--x .chart-title').length).to.be(2); + expect($('.visAxis__splitTitles--y .chart-title').length).to.be(2); }); diff --git a/src/ui/public/vislib/__tests__/lib/vis_config.js b/src/ui/public/vislib/__tests__/lib/vis_config.js index 66f3651883e25..510263b37bce5 100644 --- a/src/ui/public/vislib/__tests__/lib/vis_config.js +++ b/src/ui/public/vislib/__tests__/lib/vis_config.js @@ -90,7 +90,7 @@ describe('Vislib VisConfig Class Test Suite', function () { const VisConfig = Private(VislibVisConfigProvider); const PersistedState = $injector.get('PersistedState'); el = d3.select('body').append('div') - .attr('class', 'vis-wrapper') + .attr('class', 'visWrapper') .node(); visConfig = new VisConfig({ diff --git a/src/ui/public/vislib/__tests__/lib/x_axis.js b/src/ui/public/vislib/__tests__/lib/x_axis.js index 183e1b7fc1163..ca8c64039aa7a 100644 --- a/src/ui/public/vislib/__tests__/lib/x_axis.js +++ b/src/ui/public/vislib/__tests__/lib/x_axis.js @@ -102,7 +102,7 @@ describe('Vislib xAxis Class Test Suite', function () { VisConfig = Private(VislibVisConfigProvider); el = d3.select('body').append('div') - .attr('class', 'x-axis-wrapper') + .attr('class', 'visAxis--x') .style('height', '40px'); fixture = el.append('div') diff --git a/src/ui/public/vislib/__tests__/vis.js b/src/ui/public/vislib/__tests__/vis.js index 9f996a82d2c39..acacf59fbfcdf 100644 --- a/src/ui/public/vislib/__tests__/vis.js +++ b/src/ui/public/vislib/__tests__/vis.js @@ -105,11 +105,11 @@ dataArray.forEach(function (data, i) { }); it('should remove all DOM elements from el', function () { - expect($(secondVis.el).find('.vis-wrapper').length).to.be(0); + expect($(secondVis.el).find('.visWrapper').length).to.be(0); }); it('should not remove visualizations that have not been destroyed', function () { - expect($(vis.el).find('.vis-wrapper').length).to.be(1); + expect($(vis.el).find('.visWrapper').length).to.be(1); }); }); diff --git a/src/ui/public/vislib/__tests__/visualizations/gauge_chart.js b/src/ui/public/vislib/__tests__/visualizations/gauge_chart.js index 50fea1597eb10..09d64beb95db3 100644 --- a/src/ui/public/vislib/__tests__/visualizations/gauge_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/gauge_chart.js @@ -77,7 +77,7 @@ describe('Vislib Gauge Chart Test Suite', function () { const config = _.defaultsDeep({}, opts, visLibParams); if (vis) { vis.destroy(); - $('.visualize-chart').remove(); + $('.visChart').remove(); } vis = vislibVis(config); persistedState = new PersistedState(); @@ -95,7 +95,7 @@ describe('Vislib Gauge Chart Test Suite', function () { afterEach(function () { vis.destroy(); - $('.visualize-chart').remove(); + $('.visChart').remove(); }); it('creates meter gauge', function () { diff --git a/src/ui/public/vislib/__tests__/visualizations/pie_chart.js b/src/ui/public/vislib/__tests__/visualizations/pie_chart.js index e8100b1b7fab4..db3593f997cad 100644 --- a/src/ui/public/vislib/__tests__/visualizations/pie_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/pie_chart.js @@ -143,8 +143,8 @@ describe('No global chart settings', function () { }); it('should render chart titles for all charts', function () { - expect($(chart1.el).find('.y-axis-chart-title').length).to.be(1); - expect($(chart2.el).find('.x-axis-chart-title').length).to.be(1); + expect($(chart1.el).find('.visAxis__splitTitles--y').length).to.be(1); + expect($(chart2.el).find('.visAxis__splitTitles--x').length).to.be(1); }); describe('_validatePieData method', function () { diff --git a/src/ui/public/vislib/_index.scss b/src/ui/public/vislib/_index.scss new file mode 100644 index 0000000000000..f8045b7cf5d35 --- /dev/null +++ b/src/ui/public/vislib/_index.scss @@ -0,0 +1,3 @@ +@import './variables'; + +@import './lib/index'; diff --git a/src/ui/public/vislib/_variables.scss b/src/ui/public/vislib/_variables.scss new file mode 100644 index 0000000000000..58f70eb4848e5 --- /dev/null +++ b/src/ui/public/vislib/_variables.scss @@ -0,0 +1,5 @@ +// TODO: Use the same styles for TSVB and Vislib vis' +$visLineColor: transparentize($euiColorFullShade,0.8); +$visTextColor: transparentize($euiColorFullShade,0.6); +$visValueColor: transparentize($euiColorFullShade,0.3); +$visHoverBackgroundColor: transparentize($euiColorFullShade,0.9); diff --git a/src/ui/public/vislib/lib/_alerts.scss b/src/ui/public/vislib/lib/_alerts.scss new file mode 100644 index 0000000000000..e99fcf6f52b74 --- /dev/null +++ b/src/ui/public/vislib/lib/_alerts.scss @@ -0,0 +1,55 @@ + +.visAlerts__tray { + position: absolute; + bottom: ($euiSizeXS+1px); + left: 0; + right: 0; + list-style: none; + padding: 0; + + transition-property: opacity; + transition-delay: $euiAnimSpeedExtraFast; + transition-duration: $euiAnimSpeedExtraFast; +} + +.visAlerts__icon { + margin: 0; + padding: 0 $euiSizeS; + flex: 0 0 auto; + align-self: center; +} + +.visAlerts__text { + flex: 1 1 auto; + margin: 0; + padding: 0; +} + +.visAlerts__close { + cursor: pointer; +} + +.visAlert { + margin: 0 $euiSizeS $euiSizeS; + padding: $euiSizeXS $euiSizeS $euiSizeXS $euiSizeXS; + display: flex; +} + +// Modifier naming and colors. +$visAlertTypes: ( + info: $euiColorPrimary, + success: $euiColorSecondary, + warning: $euiColorWarning, + danger: $euiColorDanger, +); + +// Create button modifiders based upon the map. +@each $name, $color in $visAlertTypes { + .visAlert--#{$name} { + $backgroundColor: tintOrShade($color, 90%, 70%); + $textColor: makeHighContrastColor($color, $backgroundColor); + + background-color: $backgroundColor; + color: $textColor; + } +} diff --git a/src/ui/public/vislib/lib/_handler.scss b/src/ui/public/vislib/lib/_handler.scss new file mode 100644 index 0000000000000..8d9a9e35f7e0e --- /dev/null +++ b/src/ui/public/vislib/lib/_handler.scss @@ -0,0 +1,21 @@ +.visError { + flex: 1 1 0; + display: flex; + align-items: center; + justify-content: center; + + // From ML + .top { align-self: flex-start; } + .bottom { align-self: flex-end; } + + p { + margin-top: 15%; + @include euiFontSizeL; + } +} + +// Prevent large request errors from overflowing the container +.visError--request { + max-width: 100%; + max-height: 100%; +} diff --git a/src/ui/public/vislib/lib/_index.scss b/src/ui/public/vislib/lib/_index.scss new file mode 100644 index 0000000000000..b19c2dfb153b9 --- /dev/null +++ b/src/ui/public/vislib/lib/_index.scss @@ -0,0 +1,4 @@ +@import './alerts'; +@import './handler'; +@import './layout/index'; + diff --git a/src/ui/public/vislib/lib/alerts.js b/src/ui/public/vislib/lib/alerts.js index 9ec6dcd4d7319..5f6b360d43d58 100644 --- a/src/ui/public/vislib/lib/alerts.js +++ b/src/ui/public/vislib/lib/alerts.js @@ -49,12 +49,12 @@ export function VislibLibAlertsProvider() { const icon = alertDef.icon || type; const msg = alertDef.msg; // alert container - const $icon = $('').addClass('vis-alerts-icon fa fa-' + icon); - const $text = $('

      ').addClass('vis-alerts-text').text(msg); + const $icon = $('').addClass('visAlerts__icon fa fa-' + icon); + const $text = $('

      ').addClass('visAlerts__text').text(msg); const $closeIcon = $('').addClass('fa fa-close'); - const $closeDiv = $('

      ').addClass('vis-alerts-close').append($closeIcon); + const $closeDiv = $('
      ').addClass('visAlerts__close').append($closeIcon); - const $alert = $('
      ').addClass('vis-alert vis-alert-' + type).append([$icon, $text, $closeDiv]); + const $alert = $('
      ').addClass('visAlert visAlert--' + type).append([$icon, $text, $closeDiv]); $closeDiv.on('click', () => { $alert.remove(); }); @@ -67,9 +67,9 @@ export function VislibLibAlertsProvider() { const alerts = this.alerts; const vis = this.vis; - $(vis.el).find('.vis-alerts').append($('
      ').addClass('vis-alerts-tray')); + $(vis.el).find('.visWrapper__alerts').append($('
      ').addClass('visAlerts__tray')); if (!alerts.size()) return; - $(vis.el).find('.vis-alerts-tray').append(alerts.value()); + $(vis.el).find('.visAlerts__tray').append(alerts.value()); } // shows new alert @@ -81,13 +81,13 @@ export function VislibLibAlertsProvider() { }; if (this.alertDefs.find(alertDef => alertDef.msg === alert.msg)) return; this.alertDefs.push(alert); - $(vis.el).find('.vis-alerts-tray').append( + $(vis.el).find('.visAlerts__tray').append( this._addAlert(alert) ); } destroy() { - $(this.vis.el).find('.vis-alerts').remove(); + $(this.vis.el).find('.visWrapper__alerts').remove(); } } diff --git a/src/ui/public/vislib/lib/axis/axis.js b/src/ui/public/vislib/lib/axis/axis.js index 87d98aae37ac0..16c4f0f662c15 100644 --- a/src/ui/public/vislib/lib/axis/axis.js +++ b/src/ui/public/vislib/lib/axis/axis.js @@ -164,8 +164,8 @@ export function VislibLibAxisProvider(Private) { .attr('transform', 'translate(1,0)'); } if (config.get('type') === 'value') { - const spacerNodes = $(chartEl).find(`.y-axis-spacer-block-${position}`); - const elHeight = $(chartEl).find(`.axis-wrapper-${position}`).height(); + const spacerNodes = $(chartEl).find(`.visAxis__spacer--y-${position}`); + const elHeight = $(chartEl).find(`.visAxis__column--${position}`).height(); spacerNodes.height(elHeight); } } else { diff --git a/src/ui/public/vislib/lib/axis/axis_config.js b/src/ui/public/vislib/lib/axis/axis_config.js index e2729d393885b..61e155879095b 100644 --- a/src/ui/public/vislib/lib/axis/axis_config.js +++ b/src/ui/public/vislib/lib/axis/axis_config.js @@ -26,7 +26,7 @@ export function VislibLibAxisConfigProvider() { const defaults = { show: true, type: 'value', - elSelector: '.axis-wrapper-{pos} .axis-div', + elSelector: '.visAxis__column--{pos} .axis-div', position: 'left', scale: { type: 'linear', @@ -61,7 +61,7 @@ export function VislibLibAxisConfigProvider() { }, title: { text: '', - elSelector: '.axis-wrapper-{pos} .axis-div', + elSelector: '.visAxis__column--{pos} .axis-div', } }; diff --git a/src/ui/public/vislib/lib/handler.js b/src/ui/public/vislib/lib/handler.js index d1cd971b322d1..acc5ac71e9293 100644 --- a/src/ui/public/vislib/lib/handler.js +++ b/src/ui/public/vislib/lib/handler.js @@ -217,7 +217,7 @@ export function VisHandlerProvider(Private) { .append('div') // class name needs `chart` in it for the polling checkSize function // to continuously call render on resize - .attr('class', 'visualize-error chart error') + .attr('class', 'visError chart error') .attr('data-test-subj', 'visLibVisualizeError'); div.append('h4').text(markdownIt.renderInline(message)); diff --git a/src/ui/public/vislib/lib/layout/_index.scss b/src/ui/public/vislib/lib/layout/_index.scss new file mode 100644 index 0000000000000..0820684ccbcf9 --- /dev/null +++ b/src/ui/public/vislib/lib/layout/_index.scss @@ -0,0 +1 @@ +@import './layout'; diff --git a/src/ui/public/vislib/lib/layout/_layout.scss b/src/ui/public/vislib/lib/layout/_layout.scss new file mode 100644 index 0000000000000..d23bf3afc2522 --- /dev/null +++ b/src/ui/public/vislib/lib/layout/_layout.scss @@ -0,0 +1,332 @@ +// Typical layout +// .visWrapper +// .visAxis--y +// .visAxis__spacer--y.visAxis__spacer--y-[position] +// .visAxis__column--y.visAxis__column--[position] +// .visAxis__splitTitles--y +// .visAxis__splitAxes--y +// .visAxis__spacer--y.visAxis__spacer--y-[position] +// .visWrapper__column +// .visAxis--x.visAxis__column--[position] +// .visAxis__splitAxes--x +// .visWrapper__chart +// .visWrapper__alerts +// .visAxis--x.visAxis__column--[position] +// .visAxis__splitAxes--x +// .visAxis__splitTitles--x +// .visAxis--y +// .visAxis__spacer--y.visAxis__spacer--y-[position] +// .visAxis__column--y.visAxis__column--[position] +// .visAxis__splitAxes--y +// .visAxis__spacer--y.visAxis__spacer--y-[position] + +// +// LAYOUT ONLY +// Numbers in here are brittle +// + +.visWrapper { + display: flex; + flex: 1 1 100%; + flex-direction: row; + min-height: 0; + min-width: 0; + overflow: hidden; + padding: ($euiSizeS + 2px) 0; +} + +.visWrapper__column { + display: flex; + flex: 1 0 0px; + flex-direction: column; + min-height: 0; + min-width: 0; +} + +.visWrapper__splitCharts--column { + display: flex; + flex: 1 0 20px; + flex-direction: row; + min-height: 0; + min-width: 0; + + .visWrapper__chart { + margin-top: 0px; + margin-bottom: 0px; + } +} + +.visWrapper__splitCharts--row { + display: flex; + flex-direction: column; + flex: 1 1 100%; + min-height: 0; + min-width: 0; + + .visWrapper__chart { + margin-left: 0px; + margin-right: 0px; + } +} + +.visWrapper__chart { + display: flex; + flex: 1 0 0px; + overflow: visible; + margin: 5px; + min-height: 0; + min-width: 0; +} + +.visWrapper__alerts { + position: relative; +} + +// General Axes + +.visAxis__column--top .axis-div svg { + margin-bottom: -5px; +} + +// Y Axes + +.visAxis--x, +.visAxis--y { + display: flex; + flex-direction: column; + min-height: 0; + min-width: 0; +} + +.visAxis--x { + overflow: visible; +} + +.visAxis__spacer--y { + min-height: 0px; +} + +.visAxis__column--y { + display: flex; + flex-direction: row; + flex: 1 0 ($euiSizeXL + $euiSizeXS); + min-height: 0; + min-width: 0; +} + +.visAxis__splitTitles--y { + display: flex; + flex-direction: column; + min-height: $euiSizeM; + min-width: 0; +} + +.visAxis__splitTitles--x { + display: flex; + flex-direction: row; + min-height: 1px; + max-height: $euiSize; + min-width: $euiSize; +} + +.visAxis__splitAxes--x, +.visAxis__splitAxes--y { + display: flex; + flex-direction: column; + min-height: ($euiSize + $euiSizeXS); + min-width: 0; +} + +.visAxis__splitAxes--x { + flex-direction: row; + min-height: 0; +} + + +// +// STYLE +// + +// BEM NOTE: These selectors could not be renamed. +// Most come from an external libray, others are too general for +// search and replace. The SVG itself doesn't have a class, nor +// could it be easily found to apply to all chart types. +// At least wrapping selectors inside .visWrapper will narrow scope. + + +.visWrapper { + svg { + overflow: visible; + } + + // SVG Element Default Styling + rect { + opacity: 1; + + &:hover { + opacity: 0.8; + } + } + + circle { + opacity: 0; + + &:hover { + opacity: 1; + stroke-width: $euiSizeS; + stroke-opacity: 0.8; + } + } + + .label-line { + fill: none; + stroke-width: 2px; + stroke: $visLineColor; + } + + .label-text { + @include fontSize($euiFontSizeXS); + font-weight: $euiFontWeightRegular; + } + + .y-axis-div { + flex: 1 1 $euiSizeL; + min-width: 1px; + min-height: $euiSizeM; + margin: ($euiSizeXS + 1px) 0; + } + + .x-axis-div { + min-height: 0px; + min-width: 1px; + margin: 0px ($euiSizeXS + 1px); + width: 100%; + + svg { + float: left; /* for some reason svg wont get positioned in top left corner of container div without this */ + } + } + + .tick text { + @include fontSize($euiFontSizeXS - 1px); + fill: $visValueColor; + } + + .axis-title text { + @include fontSize($euiFontSizeXS); + font-weight: $euiFontWeightBold; + fill: $visTextColor; + } + + .y-axis-title { + min-height: ($euiSizeM + 2px); + min-width: 1px; + } + + .x-axis-title { + min-width: $euiSize; + } + + .chart-title { + flex: 1 1 100%; + min-height: ($euiSizeM + 2px); + min-width: ($euiSizeM + 2px); + + text { + @include fontSize($euiFontSizeXS - 1px); + fill: $visTextColor; + } + } + + .chart { + flex: 1 1 100%; + min-height: 0; + min-width: 0; + overflow: visible; + + > svg { + display: block; + } + } + + .chart-row, + .chart-column { + flex: 1 1 auto; + min-height: 0; + min-width: 0; + } + + // Needs to come after .y-axis-div + .visWrapper__chart--first { + margin-top: 0px; + margin-left: 0px + } + + .visWrapper__chart--last { + margin-bottom: 0px; + margin-right: 0px; + } + + .axis { + shape-rendering: crispEdges; + stroke-width: 1px; + + line, path { + stroke: $euiBorderColor; + fill: none; + shape-rendering: crispEdges; + } + } + + .chart-label, + .label-text, + .chart-text { + fill: $visValueColor; + } + + /* Brush Styling */ + .brush .extent { + shape-rendering: crispEdges; + fill: $visHoverBackgroundColor; + } + + .visAreaChart__overlapArea { + opacity: 0.8; + } + + .series > path, + .series > rect { + fill-opacity: 0.8; + stroke-opacity: 1; + stroke-width: 0; + } + + .blur_shape { + opacity: 0.3 !important; + } + + .slice { + stroke-width: $euiSizeXS/2; + stroke: $euiColorEmptyShade; + + &:hover { + opacity: 0.8 + } + } + + .line { + circle { + opacity: 1; + + &:hover { + stroke-width: $euiSizeS; + stroke-opacity: 0.8; + } + } + } + + .endzone { + pointer-events: none; + fill: $visHoverBackgroundColor; + } +} diff --git a/src/ui/public/vislib/lib/layout/layout.js b/src/ui/public/vislib/lib/layout/layout.js index 9e6083caedb6a..73b1dd6e4b362 100644 --- a/src/ui/public/vislib/lib/layout/layout.js +++ b/src/ui/public/vislib/lib/layout/layout.js @@ -90,7 +90,7 @@ export function VislibLibLayoutLayoutProvider(Private) { const position = axis.axisConfig.get('position'); const chartTitle = new ChartTitle(visConfig); - const axisWrapperElement = $(this.el).find(`.axis-wrapper-${position}`); + const axisWrapperElement = $(this.el).find(`.visAxis__column--${position}`); axisWrapperElement.css('visibility', 'hidden'); axis.render(); @@ -103,10 +103,10 @@ export function VislibLibLayoutLayoutProvider(Private) { if (axis.axisConfig.isHorizontal()) { - const spacerNodes = $(this.el).find(`.y-axis-spacer-block-${position}`); + const spacerNodes = $(this.el).find(`.visAxis__spacer--y-${position}`); spacerNodes.height(`${height}px`); } else { - axisWrapperElement.find('.y-axis-div-wrapper').width(`${width}px`); + axisWrapperElement.find('.visAxis__splitAxes--y').width(`${width}px`); } } diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js index c6c77fb14be0f..0c14ff8ed761a 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js @@ -21,7 +21,7 @@ import d3 from 'd3'; export function VislibLibLayoutSplitsColumnChartChartSplitProvider() { /* - * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. + * Adds div DOM elements to the `.visWrapper__chart` element based on the data layout. * For example, if the data has rows, it returns the same number of * `.chart` elements as row objects. */ @@ -30,14 +30,14 @@ export function VislibLibLayoutSplitsColumnChartChartSplitProvider() { const div = d3.select(this) .attr('class', function () { if (data.rows) { - return 'chart-wrapper-row'; + return 'visWrapper__splitCharts--row'; } else if (data.columns) { - return 'chart-wrapper-column'; + return 'visWrapper__splitCharts--column'; } else { if (parent) { - return 'chart-first chart-last chart-wrapper'; + return 'visWrapper__chart--first visWrapper__chart--last visWrapper__chart'; } - return this.className + ' chart-wrapper'; + return this.className + ' visWrapper__chart'; } }); let divClass = ''; @@ -65,12 +65,12 @@ export function VislibLibLayoutSplitsColumnChartChartSplitProvider() { if (fullDivClass !== 'chart') { if (chartsNumber > 1) { if (i === 0) { - fullDivClass += ' chart-first'; + fullDivClass += ' visWrapper__chart--first'; } else if (i === chartsNumber - 1) { - fullDivClass += ' chart-last'; + fullDivClass += ' visWrapper__chart--last'; } } else { - fullDivClass += ' chart-first chart-last'; + fullDivClass += ' visWrapper__chart--first visWrapper__chart--last'; } } return fullDivClass; diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js index c930589b471bf..fc6f261ced1ca 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js @@ -22,8 +22,8 @@ import $ from 'jquery'; export function VislibLibLayoutSplitsColumnChartChartTitleSplitProvider() { /* - * Adds div DOM elements to either the `.y-axis-chart-title` element or the - * `.x-axis-chart-title` element based on the data layout. + * Adds div DOM elements to either the `.visAxis__splitTitles--y` element or the + * `.visAxis__splitTitles--x` element based on the data layout. * For example, if the data has rows, it returns the same number of * `.chart-title` elements as row objects. * if not data.rows or data.columns, return no chart titles @@ -31,7 +31,7 @@ export function VislibLibLayoutSplitsColumnChartChartTitleSplitProvider() { return function (selection) { selection.each(function (data) { const div = d3.select(this); - const parent = $(this).parents('.vis-wrapper'); + const parent = $(this).parents('.visWrapper'); if (!data.series) { div.selectAll('.chart-title') @@ -43,9 +43,9 @@ export function VislibLibLayoutSplitsColumnChartChartTitleSplitProvider() { .attr('class', 'chart-title'); if (data.rows) { - parent.find('.x-axis-chart-title').remove(); + parent.find('.visAxis__splitTitles--x').remove(); } else { - parent.find('.y-axis-chart-title').remove(); + parent.find('.visAxis__splitTitles--y').remove(); } return div; diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js index 77053ceca0f0c..a57e25fad3377 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js @@ -22,7 +22,7 @@ import d3 from 'd3'; export function VislibLibLayoutSplitsColumnChartXAxisSplitProvider() { /* - * Adds div DOM elements to the `.x-axis-div-wrapper` element based on the data layout. + * Adds div DOM elements to the `.visAxis__splitAxes--x` element based on the data layout. * For example, if the data has rows, it returns the same number of * `.x-axis-div` elements as row objects. */ @@ -42,10 +42,10 @@ export function VislibLibLayoutSplitsColumnChartXAxisSplitProvider() { .attr('class', (d, i) => { let divClass = ''; if (i === 0) { - divClass += ' chart-first'; + divClass += ' visWrapper__chart--first'; } if (i === columns - 1) { - divClass += ' chart-last'; + divClass += ' visWrapper__chart--last'; } return 'x-axis-div axis-div' + divClass; }); diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js index 78f300100ab2d..354a51dcc5fee 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js @@ -21,7 +21,7 @@ import d3 from 'd3'; export function VislibLibLayoutSplitsColumnChartYAxisSplitProvider() { /* - * Adds div DOM elements to the `.y-axis-div-wrapper` element based on the data layout. + * Adds div DOM elements to the `.visAxis__splitAxes--y` element based on the data layout. * For example, if the data has rows, it returns the same number of * `.y-axis-div` elements as row objects. */ @@ -44,10 +44,10 @@ export function VislibLibLayoutSplitsColumnChartYAxisSplitProvider() { .attr('class', (d, i) => { let divClass = ''; if (i === 0) { - divClass += ' chart-first'; + divClass += ' visWrapper__chart--first'; } if (i === rows - 1) { - divClass += ' chart-last'; + divClass += ' visWrapper__chart--last'; } return 'y-axis-div axis-div' + divClass; }); diff --git a/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js b/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js index f00906c651742..906483966dc22 100644 --- a/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js +++ b/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js @@ -23,7 +23,7 @@ import d3 from 'd3'; export default function ChartSplitFactory() { /* - * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. + * Adds div DOM elements to the `.visWrapper__chart` element based on the data layout. * For example, if the data has rows, it returns the same number of * `.chart` elements as row objects. */ @@ -33,11 +33,11 @@ export default function ChartSplitFactory() { const div = d3.select(this) .attr('class', function () { if (data.rows) { - return 'chart-wrapper-row'; + return 'visWrapper__splitCharts--row'; } else if (data.columns) { - return 'chart-wrapper-column'; + return 'visWrapper__splitCharts--column'; } else { - return 'chart-wrapper'; + return 'visWrapper__chart'; } }); let divClass; diff --git a/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js b/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js index 616d2f1f72dfc..ad30bf91e9f00 100644 --- a/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js +++ b/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js @@ -23,8 +23,8 @@ import d3 from 'd3'; export default function ChartTitleSplitFactory() { /* - * Adds div DOM elements to either the `.y-axis-chart-title` element or the - * `.x-axis-chart-title` element based on the data layout. + * Adds div DOM elements to either the `.visAxis__splitTitles--y` element or the + * `.visAxis__splitTitles--x` element based on the data layout. * For example, if the data has rows, it returns the same number of * `.chart-title` elements as row objects. * if not data.rows or data.columns, return no chart titles @@ -45,9 +45,9 @@ export default function ChartTitleSplitFactory() { .attr('class', 'chart-title'); if (data.rows) { - d3.select(parent).select('.x-axis-chart-title').remove(); + d3.select(parent).select('.visAxis__splitTitles--x').remove(); } else { - d3.select(parent).select('.y-axis-chart-title').remove(); + d3.select(parent).select('.visAxis__splitTitles--y').remove(); } return div; diff --git a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js index 3cb4a1740659b..7839c205c1804 100644 --- a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js +++ b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js @@ -21,7 +21,7 @@ import d3 from 'd3'; export function VislibLibLayoutSplitsPieChartChartSplitProvider() { /* - * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. + * Adds div DOM elements to the `.visWrapper__chart` element based on the data layout. * For example, if the data has rows, it returns the same number of * `.chart` elements as row objects. */ @@ -31,11 +31,11 @@ export function VislibLibLayoutSplitsPieChartChartSplitProvider() { const div = d3.select(this) .attr('class', function () { if (data.rows) { - return 'chart-wrapper-row'; + return 'visWrapper__splitCharts--row'; } else if (data.columns) { - return 'chart-wrapper-column'; + return 'visWrapper__splitCharts--column'; } else { - return 'chart-wrapper'; + return 'visWrapper__chart'; } }); let divClass; diff --git a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js index c94a4b9b9fa03..c22dafd620cec 100644 --- a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js +++ b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js @@ -21,8 +21,8 @@ import d3 from 'd3'; export function VislibLibLayoutSplitsPieChartChartTitleSplitProvider() { /* - * Adds div DOM elements to either the `.y-axis-chart-title` element or the - * `.x-axis-chart-title` element based on the data layout. + * Adds div DOM elements to either the `.visAxis__splitTitles--y` element or the + * `.visAxis__splitTitles--x` element based on the data layout. * For example, if the data has rows, it returns the same number of * `.chart-title` elements as row objects. * if not data.rows or data.columns, return no chart titles @@ -43,9 +43,9 @@ export function VislibLibLayoutSplitsPieChartChartTitleSplitProvider() { .attr('class', 'chart-title'); if (data.rows) { - d3.select(parent).select('.x-axis-chart-title').remove(); + d3.select(parent).select('.visAxis__splitTitles--x').remove(); } else { - d3.select(parent).select('.y-axis-chart-title').remove(); + d3.select(parent).select('.visAxis__splitTitles--y').remove(); } return div; diff --git a/src/ui/public/vislib/lib/layout/types/column_layout.js b/src/ui/public/vislib/lib/layout/types/column_layout.js index 849f011d02423..fdac468708360 100644 --- a/src/ui/public/vislib/lib/layout/types/column_layout.js +++ b/src/ui/public/vislib/lib/layout/types/column_layout.js @@ -54,75 +54,75 @@ export function VislibLibLayoutTypesColumnLayoutProvider(Private) { { parent: el, type: 'div', - class: 'vis-wrapper', + class: 'visWrapper', datum: data, children: [ { type: 'div', - class: 'y-axis-col-wrapper', + class: 'visAxis--y', children: [ { type: 'div', - class: 'y-axis-spacer-block y-axis-spacer-block-top' + class: 'visAxis__spacer--y visAxis__spacer--y-top' }, { type: 'div', - class: 'y-axis-col axis-wrapper-left', + class: 'visAxis__column--y visAxis__column--left', children: [ { type: 'div', - class: 'y-axis-chart-title', + class: 'visAxis__splitTitles--y', splits: chartTitleSplit }, { type: 'div', - class: 'y-axis-div-wrapper', + class: 'visAxis__splitAxes--y', splits: yAxisSplit } ] }, { type: 'div', - class: 'y-axis-spacer-block y-axis-spacer-block-bottom' + class: 'visAxis__spacer--y visAxis__spacer--y-bottom' } ] }, { type: 'div', - class: 'vis-col-wrapper', + class: 'visWrapper__column', children: [ { type: 'div', - class: 'x-axis-wrapper axis-wrapper-top', + class: 'visAxis--x visAxis__column--top', children: [ { type: 'div', - class: 'x-axis-div-wrapper', + class: 'visAxis__splitAxes--x', splits: xAxisSplit } ] }, { type: 'div', - class: 'chart-wrapper', + class: 'visWrapper__chart', splits: chartSplit }, { type: 'div', - class: 'vis-alerts' + class: 'visWrapper__alerts' }, { type: 'div', - class: 'x-axis-wrapper axis-wrapper-bottom', + class: 'visAxis--x visAxis__column--bottom', children: [ { type: 'div', - class: 'x-axis-div-wrapper', + class: 'visAxis__splitAxes--x', splits: xAxisSplit }, { type: 'div', - class: 'x-axis-chart-title', + class: 'visAxis__splitTitles--x', splits: chartTitleSplit } ] @@ -131,26 +131,26 @@ export function VislibLibLayoutTypesColumnLayoutProvider(Private) { }, { type: 'div', - class: 'y-axis-col-wrapper', + class: 'visAxis--y', children: [ { type: 'div', - class: 'y-axis-spacer-block y-axis-spacer-block-top' + class: 'visAxis__spacer--y visAxis__spacer--y-top' }, { type: 'div', - class: 'y-axis-col axis-wrapper-right', + class: 'visAxis__column--y visAxis__column--right', children: [ { type: 'div', - class: 'y-axis-div-wrapper', + class: 'visAxis__splitAxes--y', splits: yAxisSplit } ] }, { type: 'div', - class: 'y-axis-spacer-block y-axis-spacer-block-bottom' + class: 'visAxis__spacer--y visAxis__spacer--y-bottom' } ] } diff --git a/src/ui/public/vislib/lib/layout/types/gauge_layout.js b/src/ui/public/vislib/lib/layout/types/gauge_layout.js index 1e1b7d104b999..745dcd65b1582 100644 --- a/src/ui/public/vislib/lib/layout/types/gauge_layout.js +++ b/src/ui/public/vislib/lib/layout/types/gauge_layout.js @@ -49,30 +49,30 @@ export function GaugeLayoutProvider(Private) { { parent: el, type: 'div', - class: 'vis-wrapper', + class: 'visWrapper', datum: data, children: [ { type: 'div', - class: 'y-axis-chart-title', + class: 'visAxis__splitTitles--y', //splits: chartTitleSplit }, { type: 'div', - class: 'vis-col-wrapper', + class: 'visWrapper__column', children: [ { type: 'div', - class: 'chart-wrapper', + class: 'visWrapper__chart', splits: chartSplit }, { type: 'div', - class: 'vis-alerts' + class: 'visWrapper__alerts' }, { type: 'div', - class: 'x-axis-chart-title', + class: 'visAxis__splitTitles--x', //splits: chartTitleSplit } ] diff --git a/src/ui/public/vislib/lib/layout/types/pie_layout.js b/src/ui/public/vislib/lib/layout/types/pie_layout.js index 0cf4548d361bb..2fe0ad31bc31d 100644 --- a/src/ui/public/vislib/lib/layout/types/pie_layout.js +++ b/src/ui/public/vislib/lib/layout/types/pie_layout.js @@ -50,26 +50,26 @@ export function VislibLibLayoutTypesPieLayoutProvider(Private) { { parent: el, type: 'div', - class: 'vis-wrapper', + class: 'visWrapper', datum: data, children: [ { type: 'div', - class: 'y-axis-chart-title', + class: 'visAxis__splitTitles--y', splits: chartTitleSplit }, { type: 'div', - class: 'vis-col-wrapper', + class: 'visWrapper__column', children: [ { type: 'div', - class: 'chart-wrapper', + class: 'visWrapper__chart', splits: chartSplit }, { type: 'div', - class: 'x-axis-chart-title', + class: 'visAxis__splitTitles--x', splits: chartTitleSplit } ] diff --git a/src/ui/public/vislib/partials/touchdown.tmpl.html b/src/ui/public/vislib/partials/touchdown.tmpl.html index 102a5dce3ca2a..ee95eef68f3b2 100644 --- a/src/ui/public/vislib/partials/touchdown.tmpl.html +++ b/src/ui/public/vislib/partials/touchdown.tmpl.html @@ -1,7 +1,7 @@ -

      - - +

      + + <%= wholeBucket ? 'Part of this bucket' : 'This area' %> - may contain partial data.
      The selected time range does not fully cover it. + may contain partial data. The selected time range does not fully cover it.
      -

      \ No newline at end of file +

      diff --git a/src/ui/public/vislib/styles/_alerts.less b/src/ui/public/vislib/styles/_alerts.less deleted file mode 100644 index c450e09afe6d7..0000000000000 --- a/src/ui/public/vislib/styles/_alerts.less +++ /dev/null @@ -1,61 +0,0 @@ -@import "~ui/styles/variables"; - -.vis-alerts { - position: relative; -} - - .vis-alerts-tray { - position: absolute; - bottom: 5px; - left: 0px; - right: 0px; - list-style: none; - padding: 0; - - transition-property: opacity; - transition-delay: 50ms; - transition-duration: 50ms; - } - - .vis-alerts-icon { - margin: 0; - padding: 0 10px; - flex: 0 0 auto; - align-self: center; - } - - .vis-alerts-text { - flex: 1 1 auto; - margin: 0; - padding: 0; - } - - .vis-alerts-close { - cursor: pointer; - } - - .vis-alert { - margin: 0 10px 10px; - padding: 5px 10px 5px 5px; - color: @alert-vis-alert-color; - border-radius: @alert-border-radius; - border: 1px solid; - border-color: @alert-vis-alert-border; - display: flex; - } - - .vis-alert-success { - .alert-variant(fade(@alert-success-bg, 75%); @alert-success-border; @alert-success-text); - } - - .vis-alert-info { - .alert-variant(fade(@alert-info-bg, 75%); @alert-info-border; @alert-info-text); - } - - .vis-alert-warning { - .alert-variant(fade(@alert-warning-bg, 75%); @alert-warning-border; @alert-warning-text); - } - - .vis-alert-danger { - .alert-variant(fade(@alert-danger-bg, 75%); @alert-danger-border; @alert-danger-text); - } diff --git a/src/ui/public/vislib/styles/_error.less b/src/ui/public/vislib/styles/_error.less deleted file mode 100644 index cac25a20142eb..0000000000000 --- a/src/ui/public/vislib/styles/_error.less +++ /dev/null @@ -1,10 +0,0 @@ -.error { - flex: 1 1 100%; - text-align: center; - - p { - margin-top: 15%; - font-size: 18px; - text-wrap: wrap; - } -} diff --git a/src/ui/public/vislib/styles/_layout.less b/src/ui/public/vislib/styles/_layout.less deleted file mode 100644 index 3b4bd639746a9..0000000000000 --- a/src/ui/public/vislib/styles/_layout.less +++ /dev/null @@ -1,272 +0,0 @@ -.vislib-container { - flex: 1 1 0; /* 1 */ - display: flex; - flex-direction: row; - overflow: auto; - - &.vislib-container--legend-left { - flex-direction: row-reverse; - } - &.vislib-container--legend-right { - flex-direction: row; - } - &.vislib-container--legend-top { - flex-direction: column-reverse; - } - &.vislib-container--legend-bottom { - flex-direction: column; - } -} - -.vislib-chart { - display: flex; - flex: 1 1 auto; - min-height: 0; - min-width: 0; -} - -.visualize-chart { - display: flex; - flex: 1 1 auto; - min-height: 0; - min-width: 0; -} - -.vis-wrapper { - display: flex; - flex: 1 1 100%; - flex-direction: row; - min-height: 0; - min-width: 0; - overflow: hidden; - padding: 10px 0; -} - -.vis-wrapper svg { - overflow: visible; -} - -/* SVG Element Default Styling */ -.vis-wrapper { - rect { - opacity: 1; - - &:hover { - opacity: @vis-hover-opacity; - } - } - - circle { - opacity: 0; - - &:hover { - opacity: 1; - stroke-width: 10px; - stroke-opacity: @vis-hover-opacity; - } - } -} - -/* YAxis logic */ -.y-axis-col-wrapper { - display: flex; - flex-direction: column; - min-height: 0; - min-width: 0; -} - -.y-axis-col { - display: flex; - flex-direction: row; - flex: 1 0 36px; - min-height: 0; - min-width: 0; -} - -.y-axis-spacer-block { - min-height: 0px; -} - -.y-axis-div-wrapper { - display: flex; - flex-direction: column; - min-height: 20px; - min-width: 0; -} - -.y-axis-div { - flex: 1 1 25px; - min-width: 1px; - min-height: 14px; - margin: 5px 0px; -} - -.y-axis-title { - min-height: 14px; - min-width: 1px; -} - -.y-axis-chart-title { - display: flex; - flex-direction: column; - min-height: 14px; - min-width: 0; -} - -.y-axis-title text, .x-axis-title text { - font-size: 9pt; - fill: @vis-axis-title-color; - font-weight: bold; -} - -.chart-title { - flex: 1 1 100%; - min-height: 14px; - min-width: 14px; -} - -.chart-title text { - font-size: 11px; - fill: @vis-chart-title-color; -} - -.vis-col-wrapper { - display: flex; - flex: 1 0 0px; - flex-direction: column; - min-height: 0; - min-width: 0; -} - -.chart-wrapper { - display: flex; - flex: 1 0 0px; - overflow: visible; - margin: 5px; - min-height: 0; - min-width: 0; -} - -.chart-wrapper-row .chart-wrapper { - margin-left: 0px; - margin-right: 0px; -} - -.chart-wrapper-column .chart-wrapper { - margin-top: 0px; - margin-bottom: 0px; -} - -.chart-wrapper-column { - display: flex; - flex: 1 0 20px; - flex-direction: row; - min-height: 0; - min-width: 0; -} - -.chart-wrapper-row { - display: flex; - flex-direction: column; - flex: 1 1 100%; - min-height: 0; - min-width: 0; -} - -.chart { - flex: 1 1 100%; - min-height: 0; - min-width: 0; - - > svg { - display: block; - } - - overflow: visible; -} - -.chart-row { - flex: 1 1 auto; - min-height: 0; - min-width: 0; -} - -.chart-column { - flex: 1 1 auto; - min-height: 0; - min-width: 0; -} - -.x-axis-wrapper { - display: flex; - flex-direction: column; - min-height: 0px; - min-width: 0; - overflow: visible; -} - -.x-axis-div-wrapper { - display: flex; - flex-direction: row; - min-height: 0px; - min-width: 0; -} - -.x-axis-chart-title { - display: flex; - flex-direction: row; - min-height: 1px; - max-height: 15px; - min-width: 20px; -} - -.x-axis-title { - min-width: 20px; -} - -.x-axis-div { - min-height: 0px; - min-width: 1px; - margin: 0px 5px; - width: 100%; -} - -.x-axis-div svg { - float: left; /* for some reason svg wont get positioned in top left corner of container div without this */ -} - -.axis-wrapper-top .axis-div svg { - margin-bottom: -5px; -} - -.chart-first { - margin-top: 0px; - margin-left: 0px -} -.chart-last { - margin-bottom: 0px; - margin-right: 0px; -} - -.label-line { - opacity: .3; - stroke: black; - stroke-width: 2px; - fill: none; -} - -.label-text { - font-size: 130%; - font-weight: normal; -} - -// SASSTODO: Make sure these colors convert to theme variables -.tab-dashboard.theme-dark { - .y-axis-title text, .x-axis-title text { - fill: @gray10; - } - - .chart-title text { - fill: @gray10; - } -} diff --git a/src/ui/public/vislib/styles/_legend.less b/src/ui/public/vislib/styles/_legend.less deleted file mode 100644 index 20fd0c42a429e..0000000000000 --- a/src/ui/public/vislib/styles/_legend.less +++ /dev/null @@ -1,153 +0,0 @@ -@import "~ui/styles/mixins"; -@import "~ui/styles/variables"; - -visualize-legend { - display: flex; - flex-direction: row; -} - -.legend-collapse-button { - align-self: flex-start; -} - -.legend-col-wrapper { - .flex-parent(0, 0, auto); - z-index: 10; - min-height: 0; - overflow: hidden; - flex-direction: row; - padding-top: 5px; - height: 100%; - - .vislib-container--legend-left & { - flex-direction: row-reverse; - } - .vislib-container--legend-right & { - flex-direction: row; - } - .vislib-container--legend-top & { - flex-direction: column-reverse; - width: 100%; - padding-left: 25px; - } - .vislib-container--legend-bottom & { - flex-direction: column; - width: 100%; - padding-left: 25px; - } - - .header { - cursor: pointer; - width: 15px; - } - - .legend-ul { - width: 150px; - flex: 1 1 auto; - overflow-x: hidden; - overflow-y: auto; - color: @legend-item-color; - list-style-type: none; - padding: 0; - margin-bottom: 0; - visibility: visible; - min-height: 0; - font-size: 12px; - line-height: 13px; - text-align: left; - - flex-direction: column; - - .vislib-container--legend-top &, - .vislib-container--legend-bottom & { - width: auto; - overflow-y: hidden; - - .legend-value { - display: inline-block; - } - } - } - - .legend-ul.hidden { - visibility: hidden; - } -} - -.legend-value { - &:hover { - cursor: pointer; - } -} - - .legend-value-title { - padding: 3px; - - &:hover { - background-color: @sidebar-hover-bg; - } - } - - .legend-value-truncate { - overflow-x: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - - .legend-value-full { - white-space: normal; - word-break: break-all; - background-color: @sidebar-hover-bg; - } - - .legend-value-details { - border-bottom: 1px solid @sidebar-bg; - } - - .legend-value-color-picker { - width: 130px; - margin: auto; - - .dot { - line-height: 14px; - margin: 2px; - font-size: 14px; - } - - .dot:hover { - margin: 0px; - font-size: 18px - } - } - -// SASSTODO: Make sure these colors convert to theme variables -.tab-dashboard.theme-dark { - .legend { - background-color: #272727; - } - - .legend-col-wrapper { - - .legend-ul { - border-left-color: @gray7; - color: @gray10; - } - - } - - .legend-value-title { - padding: 3px; - - &:hover { - background-color: darken(@gray7, 5%); - } - } - - .legend-value-full { - background-color: @gray3; - } - - .legend-value-details { - border-bottom: 1px solid @gray7; - } -} diff --git a/src/ui/public/vislib/styles/_svg.less b/src/ui/public/vislib/styles/_svg.less deleted file mode 100644 index 41a2fa8c9c78f..0000000000000 --- a/src/ui/public/vislib/styles/_svg.less +++ /dev/null @@ -1,114 +0,0 @@ -@import (reference) "~ui/styles/variables"; - -/* Axis Styles */ -.axis { - shape-rendering: crispEdges; - stroke-width: 1px; - - line, path { - stroke: @svg-axis-color; - fill: none; - shape-rendering: crispEdges; - } -} - -.tick text { - font-size: 8pt; - fill: @svg-tick-text-color; -} - -.chart-text { - fill: @svg-tick-text-color; -} - -.label-line { - stroke: @svg-tick-text-color; -} - -.label-text { - fill: @svg-tick-text-color; -} - -/* Brush Styling */ -.brush .extent { - stroke: @svg-brush-color; - fill-opacity: .125; - shape-rendering: crispEdges; -} - -@vis-hover-opacity: 0.8; - - -.overlap_area { - opacity: 0.8; -} - -.series > path, -.series > rect { - fill-opacity: 0.8; - stroke-opacity: 1; - stroke-width: 0; -} - -.blur_shape { - opacity: 0.3 !important; -} - - -.slice { - stroke: white; - stroke-width: 2px; - &:hover { - opacity: @vis-hover-opacity; - } -} - -.leaflet-clickable { - &:hover { - stroke-width: 10px; - stroke-opacity: @vis-hover-opacity; - } -} - -/* Visualization Styling */ -.line { - circle { - opacity: 1; - - &:hover { - stroke-width: 10px; - stroke-opacity: @vis-hover-opacity; - } - } -} - -.endzone { - opacity: 0.05; - fill: @svg-endzone-bg; - pointer-events: none; -} - -// SASSTODO: Make sure these colors convert to theme variables -.tab-dashboard.theme-dark { - .axis { - line, path { - stroke: @gray8; - } - } - - .tick text { - fill: @gray10; - } - - .chart-label { - fill: @gray10; - } - - .brush .extent { - stroke: @white; - } - - .endzone { - fill: @white; - } -} diff --git a/src/ui/public/vislib/styles/_tooltip.less b/src/ui/public/vislib/styles/_tooltip.less deleted file mode 100644 index 059f18cd0c2b5..0000000000000 --- a/src/ui/public/vislib/styles/_tooltip.less +++ /dev/null @@ -1,82 +0,0 @@ -@import (reference) "~ui/styles/variables"; - -.vis-tooltip, -.vis-tooltip-sizing-clone { - visibility: hidden; - line-height: 1.1; - font-size: @font-size-base; - font-weight: normal; - background: @tooltip-bg !important; - color: @tooltip-color !important; - border-radius: 4px; - position: fixed; - z-index: 120; - word-wrap: break-word; - max-width: 40%; - overflow: hidden; - pointer-events: none; - - > :last-child { - margin-bottom: @tooltip-space; - } - - > * { - margin: @tooltip-space @tooltip-space 0; - } - - .bsTooltip-label { - font-family: @font-family-sans-serif; - color: tint(@globalColorBlue, 40%); - font-weight: normal; - - th { - font-weight: @tooltip-bold; - } - } - - .bsTooltip-value { - font-family: @font-family-sans-serif; - } - - table { - td,th { - padding: @tooltip-space-tight; - - &.row-bucket { - word-break: break-all; - } - } - } -} - -.vis-tooltip-header { - margin: 0 0 @tooltip-space 0; - padding: @tooltip-space-tight @tooltip-space; - display: flex; - align-items: center; - line-height: 1.5; - - &:last-child { - margin-bottom: 0; - } - - + * { - margin-top: @tooltip-space; - } -} - - .vis-tooltip-header-icon { - flex: 0 0 auto; - padding-right: @tooltip-space; - } - - .vis-tooltip-header-text { - flex: 1 1 200px; - } - -.vis-tooltip-sizing-clone { - visibility: hidden; - position: fixed; - top: -500px; - left: -500px; -} diff --git a/src/ui/public/vislib/styles/main.less b/src/ui/public/vislib/styles/main.less deleted file mode 100644 index 3c1c25ab908fe..0000000000000 --- a/src/ui/public/vislib/styles/main.less +++ /dev/null @@ -1,8 +0,0 @@ -@import (reference) "~ui/styles/variables"; - -@import "./_error"; -@import "./_layout"; -@import "./_legend"; -@import "./_svg"; -@import "./_tooltip"; -@import "./_alerts"; diff --git a/src/ui/public/vislib/vis.js b/src/ui/public/vislib/vis.js index b64bdc93f9bbf..311c329658994 100644 --- a/src/ui/public/vislib/vis.js +++ b/src/ui/public/vislib/vis.js @@ -21,7 +21,6 @@ import _ from 'lodash'; import d3 from 'd3'; import { KbnError } from '../errors'; import { EventsProvider } from '../events'; -import './styles/main.less'; import { VislibVisConfigProvider } from './lib/vis_config'; import { VisHandlerProvider } from './lib/handler'; @@ -105,7 +104,7 @@ export function VislibVisProvider(Private) { * @method destroy */ destroy() { - const selection = d3.select(this.el).select('.vis-wrapper'); + const selection = d3.select(this.el).select('.visWrapper'); if (this.handler) this._runOnHandler('destroy'); diff --git a/src/ui/public/vislib/vislib.js b/src/ui/public/vislib/vislib.js index f8b6faa841a2d..ce53fb598dafb 100644 --- a/src/ui/public/vislib/vislib.js +++ b/src/ui/public/vislib/vislib.js @@ -23,7 +23,6 @@ import './lib/types'; import './lib/layout/layout_types'; import './lib/data'; import './visualizations/vis_types'; -import './styles/main.less'; import { VislibVisProvider } from './vis'; // prefetched for faster optimization runs diff --git a/src/ui/public/vislib/visualizations/point_series/area_chart.js b/src/ui/public/vislib/visualizations/point_series/area_chart.js index a8b3bd1bf1a79..bbc13c2ff8b8f 100644 --- a/src/ui/public/vislib/visualizations/point_series/area_chart.js +++ b/src/ui/public/vislib/visualizations/point_series/area_chart.js @@ -100,7 +100,7 @@ export function VislibVisualizationsAreaChartProvider(Private) { .attr('data-label', data.label) .style('fill', () => color(data.label)) .style('stroke', () => color(data.label)) - .classed('overlap_area', function () { + .classed('visAreaChart__overlapArea', function () { return isOverlapping; }) .attr('clip-path', 'url(#' + this.baseChart.clipPathId + ')'); diff --git a/src/ui/public/visualize/_index.scss b/src/ui/public/visualize/_index.scss new file mode 100644 index 0000000000000..192091fb04e3c --- /dev/null +++ b/src/ui/public/visualize/_index.scss @@ -0,0 +1 @@ +@import './components/index'; diff --git a/src/ui/public/visualize/components/__snapshots__/visualization_noresults.test.js.snap b/src/ui/public/visualize/components/__snapshots__/visualization_noresults.test.js.snap index 332d75e727a22..e499f1c841046 100644 --- a/src/ui/public/visualize/components/__snapshots__/visualization_noresults.test.js.snap +++ b/src/ui/public/visualize/components/__snapshots__/visualization_noresults.test.js.snap @@ -2,7 +2,7 @@ exports[`VisualizationNoResults should render according to snapshot 1`] = `
      ', () => { const wrapper = mount(); jest.runAllTimers(); await renderPromise; - expect(wrapper.find('.visualize-chart').text()).toMatch(/markdown/); + expect(wrapper.find('.visChart').text()).toMatch(/markdown/); }); it('should re-render on param change', async () => { @@ -96,7 +96,7 @@ describe('', () => { jest.runAllTimers(); await renderPromise; - expect(wrapper.find('.visualize-chart').text()).toBe('new text'); + expect(wrapper.find('.visChart').text()).toBe('new text'); expect(renderComplete).toHaveBeenCalledTimes(2); }); }); diff --git a/src/ui/public/visualize/components/visualization_chart.tsx b/src/ui/public/visualize/components/visualization_chart.tsx index 91587fcc945fc..a2c63cd08de63 100644 --- a/src/ui/public/visualize/components/visualization_chart.tsx +++ b/src/ui/public/visualize/components/visualization_chart.tsx @@ -87,13 +87,13 @@ class VisualizationChart extends React.Component { public render() { return ( -
      +
      {this.props.vis.type.title} visualization, not yet accessible
      diff --git a/src/ui/public/visualize/components/visualization_noresults.tsx b/src/ui/public/visualize/components/visualization_noresults.tsx index 74194a5a291b0..48628e99cfcff 100644 --- a/src/ui/public/visualize/components/visualization_noresults.tsx +++ b/src/ui/public/visualize/components/visualization_noresults.tsx @@ -29,7 +29,7 @@ export class VisualizationNoResults extends React.Component +
      -
      +

      No {{swimlaneViewByFieldName}} influencers found

      diff --git a/x-pack/plugins/reporting/export_types/common/layouts/preserve_layout.css b/x-pack/plugins/reporting/export_types/common/layouts/preserve_layout.css index b449300a7079e..eab5d4dfac767 100644 --- a/x-pack/plugins/reporting/export_types/common/layouts/preserve_layout.css +++ b/x-pack/plugins/reporting/export_types/common/layouts/preserve_layout.css @@ -86,7 +86,7 @@ visualize-app .visEditor__canvas { */ /* hide unusable controls */ -.visualize .legend-collapse-button, +.visualize .visLegend__toggle, .visualize .agg-table-controls/* export raw, export formatted, etc. */ , .visualize .leaflet-container .leaflet-top.leaflet-left/* tilemap controls */ , .visualize paginate-controls /* page numbers */ { @@ -94,7 +94,7 @@ visualize-app .visEditor__canvas { } /* slightly increate legend text size for readability */ -.visualize visualize-legend .legend-value-title { +.visualize visualize-legend .visLegend__valueTitle { font-size: 1.2em; } diff --git a/x-pack/plugins/reporting/export_types/common/layouts/print.css b/x-pack/plugins/reporting/export_types/common/layouts/print.css index e8b2410260bf0..6e977fa7b5c98 100644 --- a/x-pack/plugins/reporting/export_types/common/layouts/print.css +++ b/x-pack/plugins/reporting/export_types/common/layouts/print.css @@ -85,7 +85,7 @@ visualize-app .visEditor__canvas { */ /* hide unusable controls */ -.visualize .legend-collapse-button, +.visualize .visLegend__toggle, .visualize .agg-table-controls/* export raw, export formatted, etc. */, .visualize .leaflet-container .leaflet-top.leaflet-left/* tilemap controls */, .visualize paginate-controls { @@ -93,7 +93,7 @@ visualize-app .visEditor__canvas { } /* slightly increate legend text size for readability */ -.visualize visualize-legend .legend-value-title { +.visualize visualize-legend .visLegend__valueTitle { font-size: 1.2em; } From 6436aff952fcdeea259e1faea57e8132543a64ea Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 19 Nov 2018 13:26:23 -0800 Subject: [PATCH 22/95] [ci/packer] remove optimize cache, it doesn't really help --- .ci/packer_cache.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.ci/packer_cache.sh b/.ci/packer_cache.sh index df35196294a81..85cefec469a75 100755 --- a/.ci/packer_cache.sh +++ b/.ci/packer_cache.sh @@ -6,9 +6,6 @@ source "src/dev/ci_setup/setup.sh"; # cache es snapshots node scripts/es snapshot --download-only; -# run the optimizer to warn the babel and cache-loader caches -node scripts/kibana --logging.json=false --optimize; - # archive cacheable directories mkdir -p "$HOME/.kibana/bootstrap_cache" tar -cf "$HOME/.kibana/bootstrap_cache/master.tar" \ @@ -16,6 +13,4 @@ tar -cf "$HOME/.kibana/bootstrap_cache/master.tar" \ packages/*/node_modules \ x-pack/node_modules \ x-pack/plugins/*/node_modules \ - optimize \ - data \ .es; From a3ecbde2def63d90e1e14f8923ec7188804da03f Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Mon, 19 Nov 2018 16:24:25 -0600 Subject: [PATCH 23/95] Swap jstimezonedetect with moment.tz.guess (#21800) * Swap stimezonedetect with moment.tz.guess * fix yarn.lock * fix merge --- package.json | 1 - src/ui/public/agg_types/buckets/date_histogram.js | 5 ++--- src/ui/public/vis/lib/timezone.js | 5 ++--- x-pack/package.json | 1 - .../services/timezone/xpack_watcher_timezone_service.js | 5 ++--- yarn.lock | 5 ----- 6 files changed, 6 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index bb04bc804fcc8..b0555fad091e1 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,6 @@ "js-yaml": "3.4.1", "json-stringify-pretty-compact": "1.0.4", "json-stringify-safe": "5.0.1", - "jstimezonedetect": "1.0.5", "leaflet": "1.0.3", "leaflet-draw": "0.4.10", "leaflet-responsive-popup": "0.2.0", diff --git a/src/ui/public/agg_types/buckets/date_histogram.js b/src/ui/public/agg_types/buckets/date_histogram.js index 78c926e9cdfcf..d430c87bdd2fd 100644 --- a/src/ui/public/agg_types/buckets/date_histogram.js +++ b/src/ui/public/agg_types/buckets/date_histogram.js @@ -17,10 +17,9 @@ * under the License. */ -import { jstz as tzDetect } from 'jstimezonedetect'; import _ from 'lodash'; import chrome from '../../chrome'; -import moment from 'moment'; +import moment from 'moment-timezone'; import '../../filters/field_type'; import '../../validate_date_interval'; import { BucketAggType } from './_bucket_agg_type'; @@ -32,7 +31,7 @@ import { timefilter } from '../../timefilter'; import dropPartialTemplate from '../controls/drop_partials.html'; const config = chrome.getUiSettingsClient(); -const detectedTimezone = tzDetect.determine().name(); +const detectedTimezone = moment.tz.guess(); const tzOffset = moment().format('Z'); function getInterval(agg) { diff --git a/src/ui/public/vis/lib/timezone.js b/src/ui/public/vis/lib/timezone.js index 473be70aa791d..670e47da849e8 100644 --- a/src/ui/public/vis/lib/timezone.js +++ b/src/ui/public/vis/lib/timezone.js @@ -17,14 +17,13 @@ * under the License. */ -const tzDetect = require('jstimezonedetect').jstz; -import moment from 'moment'; +import moment from 'moment-timezone'; export function timezoneProvider(config) { return function () { if (config.isDefault('dateFormat:tz')) { - const detectedTimezone = tzDetect.determine().name(); + const detectedTimezone = moment.tz.guess(); if (detectedTimezone) return detectedTimezone; else return moment().format('Z'); } else { diff --git a/x-pack/package.json b/x-pack/package.json index 562bce88b34eb..02a59ea7ff3bc 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -184,7 +184,6 @@ "joi": "^13.5.2", "jquery": "^3.3.1", "jsonwebtoken": "^8.3.0", - "jstimezonedetect": "1.0.5", "lodash": "npm:@elastic/lodash@3.10.1-kibana1", "lodash.clone": "^4.5.0", "lodash.keyby": "^4.6.0", diff --git a/x-pack/plugins/watcher/public/services/timezone/xpack_watcher_timezone_service.js b/x-pack/plugins/watcher/public/services/timezone/xpack_watcher_timezone_service.js index 8f57c83082147..7f93427fdcc69 100644 --- a/x-pack/plugins/watcher/public/services/timezone/xpack_watcher_timezone_service.js +++ b/x-pack/plugins/watcher/public/services/timezone/xpack_watcher_timezone_service.js @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { jstz as tzDetect } from 'jstimezonedetect'; -import moment from 'moment'; +import moment from 'moment-timezone'; export class XpackWatcherTimezoneService { constructor(config) { @@ -19,7 +18,7 @@ export class XpackWatcherTimezoneService { return this.config.get(DATE_FORMAT_CONFIG_KEY); } - const detectedTimezone = tzDetect.determine().name(); + const detectedTimezone = moment.tz.guess(); if (detectedTimezone) { return detectedTimezone; } diff --git a/yarn.lock b/yarn.lock index 020634c9425b6..e12b32d3a855a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12718,11 +12718,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -jstimezonedetect@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/jstimezonedetect/-/jstimezonedetect-1.0.5.tgz#93d035cd20e8c7d64eb1375cf5aa7a10a024466a" - integrity sha1-k9A1zSDox9ZOsTdc9ap6EKAkRmo= - jstransformer-ejs@^0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/jstransformer-ejs/-/jstransformer-ejs-0.0.3.tgz#04d9201469274fcf260f1e7efd732d487fa234b6" From 992daf5fed416177a61b73d798e882401788d323 Mon Sep 17 00:00:00 2001 From: Spencer Date: Mon, 19 Nov 2018 15:15:40 -0800 Subject: [PATCH 24/95] [kbn/pm] Implement --prefer-offline flag (#25840) * [kbn/pm/bootstrap] add support for --prefer-offline * [ci] try to use offline cache of modules * [yarn] set yarn-offline-mirror directory --- packages/kbn-pm/dist/index.js | 6 +++--- packages/kbn-pm/src/cli.ts | 1 + packages/kbn-pm/src/commands/bootstrap.ts | 6 ++++-- src/dev/ci_setup/setup.sh | 7 ++++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 93c0e111f0d38..56a18caef6407 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -11064,7 +11064,8 @@ let run = exports.run = (() => { e: 'exclude', h: 'help', i: 'include' - } + }, + boolean: ['prefer-offline', 'frozen-lockfile'] }); const args = options._; if (options.help || args.length === 0) { @@ -12199,8 +12200,7 @@ const BootstrapCommand = exports.BootstrapCommand = { batchByWorkspace: true }); const batchedProjects = (0, _projects.topologicallyBatchProjects)(projects, projectGraph); - const frozenLockfile = options['frozen-lockfile'] === true; - const extraArgs = frozenLockfile ? ['--frozen-lockfile'] : []; + const extraArgs = [...(options['frozen-lockfile'] === true ? ['--frozen-lockfile'] : []), ...(options['prefer-offline'] === true ? ['--prefer-offline'] : [])]; _log.log.write(_chalk2.default.bold('\nRunning installs in topological order:')); for (const batch of batchedProjectsByWorkspace) { for (const project of batch) { diff --git a/packages/kbn-pm/src/cli.ts b/packages/kbn-pm/src/cli.ts index 07383f89b8165..d7e3aafd13fce 100644 --- a/packages/kbn-pm/src/cli.ts +++ b/packages/kbn-pm/src/cli.ts @@ -65,6 +65,7 @@ export async function run(argv: string[]) { h: 'help', i: 'include', }, + boolean: ['prefer-offline', 'frozen-lockfile'], }); const args = options._; diff --git a/packages/kbn-pm/src/commands/bootstrap.ts b/packages/kbn-pm/src/commands/bootstrap.ts index 2469e4cca1cb1..be4b9da7bf516 100644 --- a/packages/kbn-pm/src/commands/bootstrap.ts +++ b/packages/kbn-pm/src/commands/bootstrap.ts @@ -35,8 +35,10 @@ export const BootstrapCommand: ICommand = { }); const batchedProjects = topologicallyBatchProjects(projects, projectGraph); - const frozenLockfile = options['frozen-lockfile'] === true; - const extraArgs = frozenLockfile ? ['--frozen-lockfile'] : []; + const extraArgs = [ + ...(options['frozen-lockfile'] === true ? ['--frozen-lockfile'] : []), + ...(options['prefer-offline'] === true ? ['--prefer-offline'] : []), + ]; log.write(chalk.bold('\nRunning installs in topological order:')); diff --git a/src/dev/ci_setup/setup.sh b/src/dev/ci_setup/setup.sh index 5a8738018b681..71f8b10513e5e 100755 --- a/src/dev/ci_setup/setup.sh +++ b/src/dev/ci_setup/setup.sh @@ -84,6 +84,11 @@ hash -r yarnVersion="$(node -e "console.log(String(require('./package.json').engines.yarn || '').replace(/^[^\d]+/,''))")" npm install -g yarn@^${yarnVersion} +### +### setup yarn offline cache +### +yarn config set yarn-offline-mirror "$cacheDir/yarn-offline-cache" + ### ### "install" yarn into this shell ### @@ -95,7 +100,7 @@ hash -r ### install dependencies ### echo " -- installing node.js dependencies" -yarn kbn bootstrap +yarn kbn bootstrap --prefer-offline ### ### verify no git modifications From 7baea1d737f31c8adac86121313013b597d6600a Mon Sep 17 00:00:00 2001 From: pavel06081991 Date: Tue, 20 Nov 2018 10:19:20 +0300 Subject: [PATCH 25/95] Feature/dashboard translations (#24328) add dashboard translations --- .../exit_full_screen_button.test.js.snap | 2 +- .../components/exit_full_screen_button.js | 25 ++- .../exit_full_screen_button.test.js | 20 +-- .../public/dashboard/dashboard_app.html | 63 ++++++- .../kibana/public/dashboard/dashboard_app.js | 39 +++- .../dashboard/dashboard_state_manager.js | 5 +- .../public/dashboard/dashboard_strings.js | 22 ++- .../__snapshots__/dashboard_grid.test.js.snap | 4 +- .../public/dashboard/grid/dashboard_grid.js | 12 +- .../dashboard/grid/dashboard_grid.test.js | 12 +- .../grid/dashboard_grid_container.test.js | 6 +- .../kibana/public/dashboard/index.js | 32 +++- .../dashboard_listing.test.js.snap | 167 ++++++++++++----- .../dashboard/listing/dashboard_listing.js | 169 +++++++++++++++--- .../listing/dashboard_listing.test.js | 14 +- .../public/dashboard/panel/dashboard_panel.js | 17 +- .../dashboard/panel/dashboard_panel.test.js | 6 +- .../panel/dashboard_panel_container.js | 6 +- .../panel/dashboard_panel_container.test.js | 4 +- .../get_customize_panel_action.tsx | 9 +- .../panel_actions/get_edit_panel_action.tsx | 5 +- .../get_inspector_panel_action.tsx | 5 +- .../panel_actions/get_remove_panel_action.tsx | 5 +- .../get_toggle_expand_panel_action.tsx | 9 +- .../panel/panel_header/panel_header.tsx | 22 ++- .../panel_header_container.test.tsx | 5 +- .../panel/panel_header/panel_options_menu.tsx | 17 +- .../panel_options_menu_container.ts | 5 +- .../panel_header/panel_options_menu_form.tsx | 29 ++- .../public/dashboard/panel/panel_utils.js | 19 +- .../saved_dashboard/saved_dashboard.js | 4 +- .../saved_dashboard/saved_dashboards.js | 5 +- .../__snapshots__/add_panel.test.js.snap | 12 +- .../__snapshots__/clone_modal.test.js.snap | 24 ++- .../__snapshots__/save_modal.test.js.snap | 24 ++- .../public/dashboard/top_nav/add_panel.js | 46 ++++- .../dashboard/top_nav/add_panel.test.js | 4 +- .../public/dashboard/top_nav/clone_modal.js | 49 ++++- .../dashboard/top_nav/clone_modal.test.js | 8 +- .../dashboard/top_nav/get_top_nav_config.js | 65 +++++-- .../public/dashboard/top_nav/options.js | 22 ++- .../public/dashboard/top_nav/save_modal.js | 22 ++- .../dashboard/top_nav/save_modal.test.js | 4 +- .../dashboard/top_nav/show_add_panel.js | 15 +- .../dashboard/top_nav/show_clone_modal.js | 13 +- .../dashboard/top_nav/show_options_popover.js | 35 ++-- .../viewport/dashboard_viewport_provider.js | 5 +- .../show_saved_object_save_modal.js | 4 +- tsconfig.json | 5 +- 49 files changed, 860 insertions(+), 261 deletions(-) diff --git a/src/core_plugins/kibana/public/dashboard/components/__snapshots__/exit_full_screen_button.test.js.snap b/src/core_plugins/kibana/public/dashboard/components/__snapshots__/exit_full_screen_button.test.js.snap index e41e0bf21420d..2fe29dd29a59b 100644 --- a/src/core_plugins/kibana/public/dashboard/components/__snapshots__/exit_full_screen_button.test.js.snap +++ b/src/core_plugins/kibana/public/dashboard/components/__snapshots__/exit_full_screen_button.test.js.snap @@ -28,7 +28,7 @@ exports[`is rendered 1`] = ` class="dshExitFullScreenButton__text" data-test-subj="exitFullScreenModeText" > - Exit full screen + Exit full screen diff --git a/src/core_plugins/kibana/public/dashboard/components/exit_full_screen_button.js b/src/core_plugins/kibana/public/dashboard/components/exit_full_screen_button.js index 1d95ff0d09aac..d24d3a81017ae 100644 --- a/src/core_plugins/kibana/public/dashboard/components/exit_full_screen_button.js +++ b/src/core_plugins/kibana/public/dashboard/components/exit_full_screen_button.js @@ -20,6 +20,7 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import chrome from 'ui/chrome'; +import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; import { KuiButton, @@ -30,7 +31,7 @@ import { EuiScreenReaderOnly, } from '@elastic/eui'; -export class ExitFullScreenButton extends PureComponent { +class ExitFullScreenButtonUi extends PureComponent { onKeyDown = (e) => { if (e.keyCode === keyCodes.ESCAPE) { @@ -49,11 +50,16 @@ export class ExitFullScreenButton extends PureComponent { } render() { + const { intl } = this.props; + return (

      - In full screen mode, press ESC to exit. +

      - Exit full screen + +
      @@ -76,6 +89,8 @@ export class ExitFullScreenButton extends PureComponent { } } -ExitFullScreenButton.propTypes = { +ExitFullScreenButtonUi.propTypes = { onExitFullScreenMode: PropTypes.func.isRequired, }; + +export const ExitFullScreenButton = injectI18n(ExitFullScreenButtonUi); diff --git a/src/core_plugins/kibana/public/dashboard/components/exit_full_screen_button.test.js b/src/core_plugins/kibana/public/dashboard/components/exit_full_screen_button.test.js index 0fb74f1a29ff9..80a52584cf9ba 100644 --- a/src/core_plugins/kibana/public/dashboard/components/exit_full_screen_button.test.js +++ b/src/core_plugins/kibana/public/dashboard/components/exit_full_screen_button.test.js @@ -24,7 +24,7 @@ jest.mock('ui/chrome', }), { virtual: true }); import React from 'react'; -import { render, mount } from 'enzyme'; +import { mountWithIntl, renderWithIntl } from 'test_utils/enzyme_helpers'; import sinon from 'sinon'; import chrome from 'ui/chrome'; @@ -36,8 +36,8 @@ import { keyCodes } from '@elastic/eui'; test('is rendered', () => { - const component = render( - {}}/> + const component = renderWithIntl( + {}}/> ); expect(component) @@ -48,8 +48,8 @@ describe('onExitFullScreenMode', () => { test('is called when the button is pressed', () => { const onExitHandler = sinon.stub(); - const component = mount( - + const component = mountWithIntl( + ); component.find('button').simulate('click'); @@ -60,7 +60,7 @@ describe('onExitFullScreenMode', () => { test('is called when the ESC key is pressed', () => { const onExitHandler = sinon.stub(); - mount(); + mountWithIntl(); const escapeKeyEvent = new KeyboardEvent('keydown', { keyCode: keyCodes.ESCAPE }); document.dispatchEvent(escapeKeyEvent); @@ -73,8 +73,8 @@ describe('chrome.setVisible', () => { test('is called with false when the component is rendered', () => { chrome.setVisible = sinon.stub(); - const component = mount( - {}} /> + const component = mountWithIntl( + {}} /> ); component.find('button').simulate('click'); @@ -84,8 +84,8 @@ describe('chrome.setVisible', () => { }); test('is called with true the component is unmounted', () => { - const component = mount( - {}} /> + const component = mountWithIntl( + {}} /> ); chrome.setVisible = sinon.stub(); diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_app.html b/src/core_plugins/kibana/public/dashboard/dashboard_app.html index cc020f33e3dba..18c40bda026f4 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_app.html +++ b/src/core_plugins/kibana/public/dashboard/dashboard_app.html @@ -15,7 +15,12 @@ aria-level="1" ng-if="showPluginBreadcrumbs">
      - Dashboard +
      {{ getDashTitle() }} @@ -46,22 +51,64 @@ ng-show="getShouldShowEditHelp()" class="dshStartScreen" > -

      - This dashboard is empty. Let’s fill it up! +

      -

      - Click the Add button in the menu bar above to add a visualization to the dashboard.
      If you haven't set up any visualizations yet, visit the Visualize app to create your first visualization. +

      + + +

      -

      - This dashboard is empty. Let’s fill it up! +

      - Click the Edit button in the menu bar above to start working on your new dashboard. + + +

      diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_app.js b/src/core_plugins/kibana/public/dashboard/dashboard_app.js index 13f6c1006c956..3a1fd54a24de0 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_app.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard_app.js @@ -56,7 +56,6 @@ import { timefilter } from 'ui/timefilter'; import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing'; import { DashboardViewportProvider } from './viewport/dashboard_viewport_provider'; -import { i18n } from '@kbn/i18n'; const app = uiModules.get('app/dashboard', [ 'elasticsearch', @@ -90,7 +89,8 @@ app.directive('dashboardApp', function ($injector) { getAppState, dashboardConfig, localStorage, - breadcrumbState + breadcrumbState, + i18n, ) { const filterManager = Private(FilterManagerProvider); const filterBar = Private(FilterBarQueryFilterProvider); @@ -184,7 +184,7 @@ app.directive('dashboardApp', function ($injector) { const updateBreadcrumbs = () => { breadcrumbState.set([ { - text: i18n.translate('kbn.dashboard.dashboardAppBreadcrumbsTitle', { + text: i18n('kbn.dashboard.dashboardAppBreadcrumbsTitle', { defaultMessage: 'Dashboard', }), href: $scope.landingPageUrl() @@ -273,14 +273,22 @@ app.directive('dashboardApp', function ($injector) { } confirmModal( - `Once you discard your changes, there's no getting them back.`, + i18n('kbn.dashboard.changeViewModeConfirmModal.discardChangesDescription', + { defaultMessage: `Once you discard your changes, there's no getting them back.` } + ), { onConfirm: revertChangesAndExitEditMode, onCancel: _.noop, - confirmButtonText: 'Discard changes', - cancelButtonText: 'Continue editing', + confirmButtonText: i18n('kbn.dashboard.changeViewModeConfirmModal.confirmButtonLabel', + { defaultMessage: 'Discard changes' } + ), + cancelButtonText: i18n('kbn.dashboard.changeViewModeConfirmModal.cancelButtonLabel', + { defaultMessage: 'Continue editing' } + ), defaultFocusedButton: ConfirmationButtonTypes.CANCEL, - title: 'Discard changes to dashboard?' + title: i18n('kbn.dashboard.changeViewModeConfirmModal.discardChangesTitle', + { defaultMessage: 'Discard changes to dashboard?' } + ) } ); }; @@ -302,7 +310,12 @@ app.directive('dashboardApp', function ($injector) { .then(function (id) { if (id) { toastNotifications.addSuccess({ - title: `Dashboard '${dash.title}' was saved`, + title: i18n('kbn.dashboard.dashboardWasSavedSuccessMessage', + { + defaultMessage: `Dashboard '{dashTitle}' was saved`, + values: { dashTitle: dash.title }, + }, + ), 'data-test-subj': 'saveDashboardSuccess', }); @@ -316,7 +329,15 @@ app.directive('dashboardApp', function ($injector) { return { id }; }).catch((error) => { toastNotifications.addDanger({ - title: `Dashboard '${dash.title}' was not saved. Error: ${error.message}`, + title: i18n('kbn.dashboard.dashboardWasNotSavedDangerMessage', + { + defaultMessage: `Dashboard '{dashTitle}' was not saved. Error: {errorMessage}`, + values: { + dashTitle: dash.title, + errorMessage: error.message, + }, + }, + ), 'data-test-subj': 'saveDashboardFailure', }); return { error }; diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_state_manager.js b/src/core_plugins/kibana/public/dashboard/dashboard_state_manager.js index a9a9372318592..aea6ba3b96426 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_state_manager.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard_state_manager.js @@ -17,6 +17,7 @@ * under the License. */ +import { i18n } from '@kbn/i18n'; import _ from 'lodash'; import moment from 'moment'; @@ -550,7 +551,9 @@ export class DashboardStateManager { */ syncTimefilterWithDashboard(timeFilter, quickTimeRanges) { if (!this.getIsTimeSavedWithDashboard()) { - throw new Error('The time is not saved with this dashboard so should not be synced.'); + throw new Error(i18n.translate('kbn.dashboard.stateManager.timeNotSavedWithDashboardErrorMessage', { + defaultMessage: 'The time is not saved with this dashboard so should not be synced.', + })); } let mode; diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_strings.js b/src/core_plugins/kibana/public/dashboard/dashboard_strings.js index 7dffc94c9e97d..a0d2af3e9c00a 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_strings.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard_strings.js @@ -17,6 +17,7 @@ * under the License. */ +import { i18n } from '@kbn/i18n'; import { DashboardViewMode } from './dashboard_view_mode'; /** @@ -28,10 +29,21 @@ import { DashboardViewMode } from './dashboard_view_mode'; */ export function getDashboardTitle(title, viewMode, isDirty) { const isEditMode = viewMode === DashboardViewMode.EDIT; - const unsavedSuffix = isEditMode && isDirty - ? ' (unsaved)' - : ''; + let displayTitle; - const displayTitle = `${title}${unsavedSuffix}`; - return isEditMode ? 'Editing ' + displayTitle : displayTitle; + if (isEditMode && isDirty) { + displayTitle = i18n.translate('kbn.dashboard.strings.dashboardUnsavedEditTitle', { + defaultMessage: 'Editing {title} (unsaved)', + values: { title }, + }); + } else if (isEditMode) { + displayTitle = i18n.translate('kbn.dashboard.strings.dashboardEditTitle', { + defaultMessage: 'Editing {title}', + values: { title }, + }); + } else { + displayTitle = title; + } + + return displayTitle; } diff --git a/src/core_plugins/kibana/public/dashboard/grid/__snapshots__/dashboard_grid.test.js.snap b/src/core_plugins/kibana/public/dashboard/grid/__snapshots__/dashboard_grid.test.js.snap index a098c22af2363..806e11c557a02 100644 --- a/src/core_plugins/kibana/public/dashboard/grid/__snapshots__/dashboard_grid.test.js.snap +++ b/src/core_plugins/kibana/public/dashboard/grid/__snapshots__/dashboard_grid.test.js.snap @@ -33,7 +33,7 @@ exports[`renders DashboardGrid 1`] = ` } } > - - { }); test('renders DashboardGrid', () => { - const component = shallow(); + const component = shallowWithIntl(); expect(component).toMatchSnapshot(); - const panelElements = component.find('Connect(DashboardPanel)'); + const panelElements = component.find('Connect(InjectIntl(DashboardPanelUi))'); expect(panelElements.length).toBe(2); }); test('renders DashboardGrid with no visualizations', () => { - const component = shallow(); + const component = shallowWithIntl(); expect(component).toMatchSnapshot(); }); test('adjusts z-index of focused panel to be higher than siblings', () => { - const component = shallow(); - const panelElements = component.find('Connect(DashboardPanel)'); + const component = shallowWithIntl(); + const panelElements = component.find('Connect(InjectIntl(DashboardPanelUi))'); panelElements.first().prop('onPanelFocused')('1'); const [gridItem1, gridItem2] = component.update().findWhere(el => el.key() === '1' || el.key() === '2'); expect(gridItem1.props.style.zIndex).toEqual('2'); diff --git a/src/core_plugins/kibana/public/dashboard/grid/dashboard_grid_container.test.js b/src/core_plugins/kibana/public/dashboard/grid/dashboard_grid_container.test.js index 1a7e3db048683..12d5d42c811ff 100644 --- a/src/core_plugins/kibana/public/dashboard/grid/dashboard_grid_container.test.js +++ b/src/core_plugins/kibana/public/dashboard/grid/dashboard_grid_container.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { Provider } from 'react-redux'; import _ from 'lodash'; import sizeMe from 'react-sizeme'; @@ -94,7 +94,7 @@ test('loads old panel data in the right order', () => { store.dispatch(updatePanels(panelData)); store.dispatch(updateUseMargins(false)); - const grid = mount(); + const grid = mountWithIntl(); const panels = store.getState().dashboard.panels; expect(Object.keys(panels).length).toBe(16); @@ -130,7 +130,7 @@ test('loads old panel data in the right order with margins', () => { store.dispatch(updatePanels(panelData)); store.dispatch(updateUseMargins(true)); - const grid = mount(); + const grid = mountWithIntl(); const panels = store.getState().dashboard.panels; expect(Object.keys(panels).length).toBe(16); diff --git a/src/core_plugins/kibana/public/dashboard/index.js b/src/core_plugins/kibana/public/dashboard/index.js index 3c302ec41bb67..a2965219d68bc 100644 --- a/src/core_plugins/kibana/public/dashboard/index.js +++ b/src/core_plugins/kibana/public/dashboard/index.js @@ -17,6 +17,7 @@ * under the License. */ +import { injectI18nProvider } from '@kbn/i18n/react'; import './dashboard_app'; import './saved_dashboard/saved_dashboards'; import './dashboard_config'; @@ -34,7 +35,6 @@ import { recentlyAccessed } from 'ui/persisted_log'; import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry'; import { DashboardListing, EMPTY_FILTER } from './listing/dashboard_listing'; import { uiModules } from 'ui/modules'; -import { i18n } from '@kbn/i18n'; const app = uiModules.get('app/dashboard', [ 'ngRoute', @@ -42,16 +42,22 @@ const app = uiModules.get('app/dashboard', [ ]); app.directive('dashboardListing', function (reactDirective) { - return reactDirective(DashboardListing); + return reactDirective(injectI18nProvider(DashboardListing)); }); +function createNewDashboardCtrl($scope, i18n) { + $scope.visitVisualizeAppLinkText = i18n('kbn.dashboard.visitVisualizeAppLinkText', { + defaultMessage: 'visit the Visualize app', + }); +} + uiRoutes .defaults(/dashboard/, { requireDefaultIndex: true }) .when(DashboardConstants.LANDING_PAGE_PATH, { template: dashboardListingTemplate, - controller($injector, $location, $scope, Private, config, breadcrumbState) { + controller($injector, $location, $scope, Private, config, breadcrumbState, i18n) { const services = Private(SavedObjectRegistryProvider).byLoaderPropertiesName; const dashboardConfig = $injector.get('dashboardConfig'); @@ -65,7 +71,7 @@ uiRoutes $scope.hideWriteControls = dashboardConfig.getHideWriteControls(); $scope.initialFilter = ($location.search()).filter || EMPTY_FILTER; breadcrumbState.set([{ - text: i18n.translate('kbn.dashboard.dashboardBreadcrumbsTitle', { + text: i18n('kbn.dashboard.dashboardBreadcrumbsTitle', { defaultMessage: 'Dashboards', }), }]); @@ -98,6 +104,7 @@ uiRoutes }) .when(DashboardConstants.CREATE_NEW_DASHBOARD_URL, { template: dashboardTemplate, + controller: createNewDashboardCtrl, resolve: { dash: function (savedDashboards, redirectWhenMissing) { return savedDashboards.get() @@ -109,8 +116,9 @@ uiRoutes }) .when(createDashboardEditUrl(':id'), { template: dashboardTemplate, + controller: createNewDashboardCtrl, resolve: { - dash: function (savedDashboards, Notifier, $route, $location, redirectWhenMissing, kbnUrl, AppState) { + dash: function (savedDashboards, Notifier, $route, $location, redirectWhenMissing, kbnUrl, AppState, i18n) { const id = $route.current.params.id; return savedDashboards.get(id) @@ -131,7 +139,9 @@ uiRoutes if (error instanceof SavedObjectNotFound && id === 'create') { // Note "new AppState" is necessary so the state in the url is preserved through the redirect. kbnUrl.redirect(DashboardConstants.CREATE_NEW_DASHBOARD_URL, {}, new AppState()); - toastNotifications.addWarning('The url "dashboard/create" was removed in 6.0. Please update your bookmarks.'); + toastNotifications.addWarning(i18n('kbn.dashboard.urlWasRemovedInSixZeroWarningMessage', + { defaultMessage: 'The url "dashboard/create" was removed in 6.0. Please update your bookmarks.' } + )); } else { throw error; } @@ -143,11 +153,15 @@ uiRoutes } }); -FeatureCatalogueRegistryProvider.register(() => { +FeatureCatalogueRegistryProvider.register((i18n) => { return { id: 'dashboard', - title: 'Dashboard', - description: 'Display and share a collection of visualizations and saved searches.', + title: i18n('kbn.dashboard.featureCatalogue.dashboardTitle', { + defaultMessage: 'Dashboard', + }), + description: i18n('kbn.dashboard.featureCatalogue.dashboardDescription', { + defaultMessage: 'Display and share a collection of visualizations and saved searches.', + }), icon: 'dashboardApp', path: `/app/kibana#${DashboardConstants.LANDING_PAGE_PATH}`, showOnHomePage: true, diff --git a/src/core_plugins/kibana/public/dashboard/listing/__snapshots__/dashboard_listing.test.js.snap b/src/core_plugins/kibana/public/dashboard/listing/__snapshots__/dashboard_listing.test.js.snap index cd45b2ae64b10..e350b43c4028f 100644 --- a/src/core_plugins/kibana/public/dashboard/listing/__snapshots__/dashboard_listing.test.js.snap +++ b/src/core_plugins/kibana/public/dashboard/listing/__snapshots__/dashboard_listing.test.js.snap @@ -22,7 +22,11 @@ exports[`after fetch hideWriteControls 1`] = ` color="subdued" component="span" > - Looks like you don't have any dashboards. + @@ -64,7 +68,11 @@ exports[`after fetch initialFilter 1`] = ` textTransform="none" >

      - Dashboards +

      @@ -80,7 +88,11 @@ exports[`after fetch initialFilter 1`] = ` iconSide="left" type="button" > - Create new dashboard + @@ -108,7 +120,7 @@ exports[`after fetch initialFilter 1`] = ` incremental={false} isLoading={false} onChange={[Function]} - placeholder="Search..." + placeholder="Search…" value="my dashboard" /> @@ -157,7 +169,13 @@ exports[`after fetch initialFilter 1`] = ` ] } loading={false} - noItemsMessage="No dashboards matched your search." + noItemsMessage={ + + } onChange={[Function]} pagination={ Object { @@ -210,24 +228,42 @@ exports[`after fetch renders call to action when no dashboards exist 1`] = ` iconType="plusInCircle" type="button" > - Create new dashboard + } body={

      - You can combine data views from any Kibana app into one dashboard and see everything in one place. +

      - New to Kibana? - - Install some sample data - - to take a test drive. + + + , + } + } + />

      } @@ -235,7 +271,11 @@ exports[`after fetch renders call to action when no dashboards exist 1`] = ` iconType="dashboardApp" title={

      - Create your first dashboard +

      } /> @@ -278,7 +318,11 @@ exports[`after fetch renders table rows 1`] = ` textTransform="none" >

      - Dashboards +

      @@ -294,7 +338,11 @@ exports[`after fetch renders table rows 1`] = ` iconSide="left" type="button" > - Create new dashboard + @@ -322,7 +370,7 @@ exports[`after fetch renders table rows 1`] = ` incremental={false} isLoading={false} onChange={[Function]} - placeholder="Search..." + placeholder="Search…" value="" /> @@ -371,7 +419,13 @@ exports[`after fetch renders table rows 1`] = ` ] } loading={false} - noItemsMessage="No dashboards matched your search." + noItemsMessage={ + + } onChange={[Function]} pagination={ Object { @@ -432,7 +486,11 @@ exports[`after fetch renders warning when listingLimit is exceeded 1`] = ` textTransform="none" >

      - Dashboards +

      @@ -448,7 +506,11 @@ exports[`after fetch renders warning when listingLimit is exceeded 1`] = ` iconSide="left" type="button" > - Create new dashboard + @@ -460,26 +522,39 @@ exports[`after fetch renders warning when listingLimit is exceeded 1`] = ` color="warning" iconType="help" size="m" - title="Listing limit exceeded" + title={ + + } >

      - You have - 2 - dashboards, but your - - listingLimit - - setting prevents the table below from displaying more than - 1 - . You can change this setting under - - Advanced Settings - - . + + + , + "listingLimitText": + listingLimit + , + "listingLimitValue": 1, + "totalDashboards": 2, + } + } + />

      @@ -556,7 +631,13 @@ exports[`after fetch renders warning when listingLimit is exceeded 1`] = ` ] } loading={false} - noItemsMessage="No dashboards matched your search." + noItemsMessage={ + + } onChange={[Function]} pagination={ Object { diff --git a/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.js b/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.js index 2a2aef320880a..b7af6a616ba26 100644 --- a/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.js +++ b/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.js @@ -19,6 +19,7 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; +import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; import _ from 'lodash'; import { toastNotifications } from 'ui/notify'; import { @@ -49,7 +50,7 @@ export const EMPTY_FILTER = ''; // and not supporting server-side paging. // This component does not try to tackle these problems (yet) and is just feature matching the legacy component // TODO support server side sorting/paging once title and description are sortable on the server. -export class DashboardListing extends React.Component { +class DashboardListingUi extends React.Component { constructor(props) { super(props); @@ -111,7 +112,12 @@ export class DashboardListing extends React.Component { await this.props.delete(this.state.selectedIds); } catch (error) { toastNotifications.addDanger({ - title: `Unable to delete dashboard(s)`, + title: ( + + ), text: `${error}`, }); } @@ -194,14 +200,34 @@ export class DashboardListing extends React.Component { return ( + } onCancel={this.closeDeleteModal} onConfirm={this.deleteSelectedItems} - cancelButtonText="Cancel" - confirmButtonText="Delete" + cancelButtonText={ + + } + confirmButtonText={ + + } defaultFocusedButton="cancel" > -

      {`You can't recover deleted dashboards.`}

      +

      + +

      ); @@ -212,14 +238,38 @@ export class DashboardListing extends React.Component { return ( + } color="warning" iconType="help" >

      - You have {this.state.totalDashboards} dashboards, - but your listingLimit setting prevents the table below from displaying more than {this.props.listingLimit}. - You can change this setting under Advanced Settings. + + listingLimit + + ), + advancedSettingsLink: ( + + + + ) + }} + />

      @@ -233,7 +283,12 @@ export class DashboardListing extends React.Component { return ''; } - return 'No dashboards matched your search.'; + return ( + + ); } renderNoItemsMessage() { @@ -243,7 +298,10 @@ export class DashboardListing extends React.Component {

      - {`Looks like you don't have any dashboards.`} +

      @@ -254,14 +312,37 @@ export class DashboardListing extends React.Component {
      Create your first dashboard} + title={ +

      + +

      + } body={

      - You can combine data views from any Kibana app into one dashboard and see everything in one place. +

      - New to Kibana? Install some sample data to take a test drive. + + + + ), + }} + />

      } @@ -272,7 +353,10 @@ export class DashboardListing extends React.Component { iconType="plusInCircle" data-test-subj="createDashboardPromptButton" > - Create new dashboard + } /> @@ -282,6 +366,7 @@ export class DashboardListing extends React.Component { } renderSearchBar() { + const { intl } = this.props; let deleteBtn; if (this.state.selectedIds.length > 0) { deleteBtn = ( @@ -292,7 +377,10 @@ export class DashboardListing extends React.Component { data-test-subj="deleteSelectedDashboards" key="delete" > - Delete selected + ); @@ -303,8 +391,14 @@ export class DashboardListing extends React.Component { {deleteBtn} { @@ -320,10 +414,14 @@ export class DashboardListing extends React.Component { } renderTable() { + const { intl } = this.props; const tableColumns = [ { field: 'title', - name: 'Title', + name: intl.formatMessage({ + id: 'kbn.dashboard.listing.table.titleColumnName', + defaultMessage: 'Title', + }), sortable: true, render: (field, record) => ( { @@ -351,7 +455,10 @@ export class DashboardListing extends React.Component { - Edit + ); } @@ -413,7 +520,10 @@ export class DashboardListing extends React.Component { href={`#${DashboardConstants.CREATE_NEW_DASHBOARD_URL}`} data-test-subj="newDashboardLink" > - Create new dashboard + ); @@ -426,7 +536,10 @@ export class DashboardListing extends React.Component {

      - Dashboards +

      @@ -471,7 +584,7 @@ export class DashboardListing extends React.Component { } } -DashboardListing.propTypes = { +DashboardListingUi.propTypes = { find: PropTypes.func.isRequired, delete: PropTypes.func.isRequired, listingLimit: PropTypes.number.isRequired, @@ -479,6 +592,8 @@ DashboardListing.propTypes = { initialFilter: PropTypes.string, }; -DashboardListing.defaultProps = { +DashboardListingUi.defaultProps = { initialFilter: EMPTY_FILTER, }; + +export const DashboardListing = injectI18n(DashboardListingUi); diff --git a/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.test.js b/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.test.js index e1a95b65982a6..9fcb0c6bab90b 100644 --- a/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.test.js +++ b/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.test.js @@ -36,7 +36,7 @@ jest.mock('lodash', }), { virtual: true }); import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { DashboardListing, @@ -58,7 +58,7 @@ const find = (num) => { }; test('renders empty page in before initial fetch to avoid flickering', () => { - const component = shallow( {}} listingLimit={1000} @@ -69,7 +69,7 @@ test('renders empty page in before initial fetch to avoid flickering', () => { describe('after fetch', () => { test('initialFilter', async () => { - const component = shallow( {}} listingLimit={1000} @@ -86,7 +86,7 @@ describe('after fetch', () => { }); test('renders table rows', async () => { - const component = shallow( {}} listingLimit={1000} @@ -102,7 +102,7 @@ describe('after fetch', () => { }); test('renders call to action when no dashboards exist', async () => { - const component = shallow( {}} listingLimit={1} @@ -118,7 +118,7 @@ describe('after fetch', () => { }); test('hideWriteControls', async () => { - const component = shallow( {}} listingLimit={1} @@ -134,7 +134,7 @@ describe('after fetch', () => { }); test('renders warning when listingLimit is exceeded', async () => { - const component = shallow( {}} listingLimit={1} diff --git a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.js b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.js index 684fe6c54a223..1ec58d1971541 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.js +++ b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.js @@ -19,6 +19,7 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; import classNames from 'classnames'; import _ from 'lodash'; @@ -29,11 +30,14 @@ import { EuiPanel, } from '@elastic/eui'; -export class DashboardPanel extends React.Component { +class DashboardPanelUi extends React.Component { constructor(props) { super(props); this.state = { - error: props.embeddableFactory ? null : `No factory found for embeddable`, + error: props.embeddableFactory ? null : props.intl.formatMessage({ + id: 'kbn.dashboard.panel.noEmbeddableFactoryErrorMessage', + defaultMessage: 'No factory found for embeddable', + }), }; this.mounted = false; @@ -100,7 +104,10 @@ export class DashboardPanel extends React.Component { className="panel-content" ref={panelElement => this.panelElement = panelElement} > - {!this.props.initialized && 'loading...'} + {!this.props.initialized && }
      ); } @@ -151,7 +158,7 @@ export class DashboardPanel extends React.Component { } } -DashboardPanel.propTypes = { +DashboardPanelUi.propTypes = { viewOnlyMode: PropTypes.bool.isRequired, onPanelFocused: PropTypes.func, onPanelBlurred: PropTypes.func, @@ -179,3 +186,5 @@ DashboardPanel.propTypes = { panelIndex: PropTypes.string, }).isRequired, }; + +export const DashboardPanel = injectI18n(DashboardPanelUi); diff --git a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.test.js b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.test.js index 5f142a8b1e338..eb8258f43833b 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.test.js +++ b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.test.js @@ -19,7 +19,7 @@ import React from 'react'; import _ from 'lodash'; -import { mount } from 'enzyme'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { DashboardPanel } from './dashboard_panel'; import { DashboardViewMode } from '../dashboard_view_mode'; import { PanelError } from '../panel/panel_error'; @@ -62,7 +62,7 @@ beforeAll(() => { }); test('DashboardPanel matches snapshot', () => { - const component = mount(); + const component = mountWithIntl(); expect(takeMountedSnapshot(component)).toMatchSnapshot(); }); @@ -71,7 +71,7 @@ test('renders an error when error prop is passed', () => { error: 'Simulated error' }); - const component = mount(); + const component = mountWithIntl(); const panelError = component.find(PanelError); expect(panelError.length).toBe(1); }); diff --git a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel_container.js b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel_container.js index 1b62a93f2cfb8..556c81d32f8d2 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel_container.js +++ b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel_container.js @@ -19,6 +19,7 @@ import { connect } from 'react-redux'; import PropTypes from 'prop-types'; +import { i18n } from '@kbn/i18n'; import { DashboardPanel } from './dashboard_panel'; import { DashboardViewMode } from '../dashboard_view_mode'; @@ -40,7 +41,10 @@ const mapStateToProps = ({ dashboard }, { embeddableFactory, panelId }) => { let error = null; if (!embeddableFactory) { const panelType = getPanelType(dashboard, panelId); - error = `No embeddable factory found for panel type ${panelType}`; + error = i18n.translate('kbn.dashboard.panel.noFoundEmbeddableFactoryErrorMessage', { + defaultMessage: 'No embeddable factory found for panel type {panelType}', + values: { panelType }, + }); } else { error = (embeddable && getEmbeddableError(dashboard, panelId)) || ''; } diff --git a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel_container.test.js b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel_container.test.js index 2af88510b7152..cb532f1a48e38 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel_container.test.js +++ b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel_container.test.js @@ -19,7 +19,7 @@ import React from 'react'; import _ from 'lodash'; -import { mount } from 'enzyme'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { DashboardPanelContainer } from './dashboard_panel_container'; import { DashboardViewMode } from '../dashboard_view_mode'; import { PanelError } from '../panel/panel_error'; @@ -52,7 +52,7 @@ test('renders an error when embeddableFactory.create throws an error', (done) => throw new Error('simulated error'); }); }; - const component = mount(); + const component = mountWithIntl(); setTimeout(() => { component.update(); const panelError = component.find(PanelError); diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_customize_panel_action.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_customize_panel_action.tsx index f7cd97666b5c3..dd059c47475c3 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_customize_panel_action.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_customize_panel_action.tsx @@ -18,6 +18,7 @@ */ import { EuiIcon } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import React from 'react'; import { ContextMenuAction, ContextMenuPanel } from 'ui/embeddable'; import { DashboardViewMode } from '../../../dashboard_view_mode'; @@ -36,7 +37,9 @@ export function getCustomizePanelAction({ }): ContextMenuAction { return new ContextMenuAction( { - displayName: 'Customize panel', + displayName: i18n.translate('kbn.dashboard.panel.customizePanel.displayName', { + defaultMessage: 'Customize panel', + }), id: 'customizePanel', parentPanelId: 'mainMenu', }, @@ -44,7 +47,9 @@ export function getCustomizePanelAction({ childContextMenuPanel: new ContextMenuPanel( { id: 'panelSubOptionsMenu', - title: 'Customize panel', + title: i18n.translate('kbn.dashboard.panel.customizePanelTitle', { + defaultMessage: 'Customize panel', + }), }, { getContent: () => ( diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_edit_panel_action.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_edit_panel_action.tsx index 88bc0001a9ac1..f4413fc5539e7 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_edit_panel_action.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_edit_panel_action.tsx @@ -20,6 +20,7 @@ import React from 'react'; import { EuiIcon } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import { ContextMenuAction } from 'ui/embeddable'; import { DashboardViewMode } from '../../../dashboard_view_mode'; @@ -31,7 +32,9 @@ import { DashboardViewMode } from '../../../dashboard_view_mode'; export function getEditPanelAction() { return new ContextMenuAction( { - displayName: 'Edit visualization', + displayName: i18n.translate('kbn.dashboard.panel.editPanel.displayName', { + defaultMessage: 'Edit visualization', + }), id: 'editPanel', parentPanelId: 'mainMenu', }, diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_inspector_panel_action.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_inspector_panel_action.tsx index 2739e2859a429..01f6da6421109 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_inspector_panel_action.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_inspector_panel_action.tsx @@ -20,6 +20,7 @@ import React from 'react'; import { EuiIcon } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import { ContextMenuAction } from 'ui/embeddable'; import { Inspector } from 'ui/inspector'; @@ -41,7 +42,9 @@ export function getInspectorPanelAction({ return new ContextMenuAction( { id: 'openInspector', - displayName: 'Inspect', + displayName: i18n.translate('kbn.dashboard.panel.inspectorPanel.displayName', { + defaultMessage: 'Inspect', + }), parentPanelId: 'mainMenu', }, { diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_remove_panel_action.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_remove_panel_action.tsx index fce94f24b16ce..47718a5f21b31 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_remove_panel_action.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_remove_panel_action.tsx @@ -18,6 +18,7 @@ */ import { EuiIcon } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import React from 'react'; import { ContextMenuAction } from 'ui/embeddable'; @@ -31,7 +32,9 @@ import { DashboardViewMode } from '../../../dashboard_view_mode'; export function getRemovePanelAction(onDeletePanel: () => void) { return new ContextMenuAction( { - displayName: 'Delete from dashboard', + displayName: i18n.translate('kbn.dashboard.panel.removePanel.displayName', { + defaultMessage: 'Delete from dashboard', + }), id: 'deletePanel', parentPanelId: 'mainMenu', }, diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_toggle_expand_panel_action.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_toggle_expand_panel_action.tsx index 27dca29c01ba6..80d43347b308c 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_toggle_expand_panel_action.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_actions/get_toggle_expand_panel_action.tsx @@ -18,6 +18,7 @@ */ import { EuiIcon } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import React from 'react'; import { ContextMenuAction } from 'ui/embeddable'; @@ -37,7 +38,13 @@ export function getToggleExpandPanelAction({ }) { return new ContextMenuAction( { - displayName: isExpanded ? 'Minimize' : 'Full screen', + displayName: isExpanded + ? i18n.translate('kbn.dashboard.panel.toggleExpandPanel.expandedDisplayName', { + defaultMessage: 'Minimize', + }) + : i18n.translate('kbn.dashboard.panel.toggleExpandPanel.notExpandedDisplayName', { + defaultMessage: 'Full screen', + }), id: 'togglePanel', parentPanelId: 'mainMenu', }, diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header.tsx index c0acd5a672a65..9e9e59d79aa97 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header.tsx @@ -17,6 +17,7 @@ * under the License. */ +import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React from 'react'; import { Embeddable } from 'ui/embeddable'; import { PanelId } from '../../selectors'; @@ -30,13 +31,18 @@ export interface PanelHeaderProps { hidePanelTitles: boolean; } -export function PanelHeader({ +interface PanelHeaderUiProps extends PanelHeaderProps { + intl: InjectedIntl; +} + +function PanelHeaderUi({ title, panelId, embeddable, isViewOnlyMode, hidePanelTitles, -}: PanelHeaderProps) { + intl, +}: PanelHeaderUiProps) { if (isViewOnlyMode && (!title || hidePanelTitles)) { return (
      @@ -56,7 +62,15 @@ export function PanelHeader({ data-test-subj="dashboardPanelTitle" className="dshPanel__title" title={title} - aria-label={`Dashboard panel: ${title}`} + aria-label={intl.formatMessage( + { + id: 'kbn.dashboard.panel.dashboardPanelAriaLabel', + defaultMessage: 'Dashboard panel: {title}', + }, + { + title, + } + )} > {hidePanelTitles ? '' : title} @@ -67,3 +81,5 @@ export function PanelHeader({
      ); } + +export const PanelHeader = injectI18n(PanelHeaderUi); diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header_container.test.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header_container.test.tsx index 998c1f6dc3ffc..f395b17207be5 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header_container.test.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header_container.test.tsx @@ -17,10 +17,11 @@ * under the License. */ -import { mount, ReactWrapper } from 'enzyme'; +import { ReactWrapper } from 'enzyme'; import _ from 'lodash'; import React from 'react'; import { Provider } from 'react-redux'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; // TODO: remove this when EUI supports types for this. // @ts-ignore: implicit any for JS file @@ -77,7 +78,7 @@ afterAll(() => { }); test('Panel header shows embeddable title when nothing is set on the panel', () => { - component = mount( + component = mountWithIntl( diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu.tsx index 983a235a719f2..25efd58d059e1 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu.tsx @@ -17,6 +17,7 @@ * under the License. */ +import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React from 'react'; import { @@ -34,19 +35,27 @@ export interface PanelOptionsMenuProps { isViewMode: boolean; } -export function PanelOptionsMenu({ +interface PanelOptionsMenuUiProps extends PanelOptionsMenuProps { + intl: InjectedIntl; +} + +function PanelOptionsMenuUi({ toggleContextMenu, isPopoverOpen, closeContextMenu, panels, isViewMode, -}: PanelOptionsMenuProps) { + intl, +}: PanelOptionsMenuUiProps) { const button = ( @@ -70,3 +79,5 @@ export function PanelOptionsMenu({ ); } + +export const PanelOptionsMenu = injectI18n(PanelOptionsMenuUi); diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_container.ts b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_container.ts index 294a7dd2661ce..478c59847fe3a 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_container.ts +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_container.ts @@ -18,6 +18,7 @@ */ import { EuiContextMenuPanelDescriptor } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import { connect } from 'react-redux'; import { buildEuiContextMenuPanels, @@ -167,7 +168,9 @@ const mergeProps = ( // every panel, every time any state changes. if (isPopoverOpen) { const contextMenuPanel = new ContextMenuPanel({ - title: 'Options', + title: i18n.translate('kbn.dashboard.panel.optionsMenu.optionsContextMenuTitle', { + defaultMessage: 'Options', + }), id: 'mainMenu', }); diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_form.tsx b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_form.tsx index 4b7b4a3a1341c..c80ab00a46b77 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_form.tsx +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_form.tsx @@ -20,6 +20,7 @@ import React, { ChangeEvent, KeyboardEvent } from 'react'; import { EuiButtonEmpty, EuiFieldText, EuiFormRow, keyCodes } from '@elastic/eui'; +import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; export interface PanelOptionsMenuFormProps { title?: string; @@ -28,12 +29,17 @@ export interface PanelOptionsMenuFormProps { onClose: () => void; } -export function PanelOptionsMenuForm({ +interface PanelOptionsMenuFormUiProps extends PanelOptionsMenuFormProps { + intl: InjectedIntl; +} + +function PanelOptionsMenuFormUi({ title, onReset, onUpdatePanelTitle, onClose, -}: PanelOptionsMenuFormProps) { + intl, +}: PanelOptionsMenuFormUiProps) { function onInputChange(event: ChangeEvent) { onUpdatePanelTitle(event.target.value); } @@ -46,7 +52,12 @@ export function PanelOptionsMenuForm({ return (
      - + - Reset title +
      ); } + +export const PanelOptionsMenuForm = injectI18n(PanelOptionsMenuFormUi); diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_utils.js b/src/core_plugins/kibana/public/dashboard/panel/panel_utils.js index c5b60f1018bb3..aec24998f17b7 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_utils.js +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_utils.js @@ -18,6 +18,7 @@ */ import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; import { DEFAULT_PANEL_WIDTH, DEFAULT_PANEL_HEIGHT } from '../dashboard_constants'; import chrome from 'ui/chrome'; @@ -31,7 +32,10 @@ export class PanelUtils { static convertPanelDataPre_6_1(panel) { // eslint-disable-line camelcase ['col', 'row'].forEach(key => { if (!_.has(panel, key)) { - throw new Error(`Unable to migrate panel data for "6.1.0" backwards compatibility, panel does not contain expected field: ${key}`); + throw new Error(i18n.translate('kbn.dashboard.panel.unableToMigratePanelDataForSixOneZeroErrorMessage', { + defaultMessage: 'Unable to migrate panel data for "6.1.0" backwards compatibility, panel does not contain expected field: {key}', + values: { key }, + })); } }); @@ -59,7 +63,10 @@ export class PanelUtils { static convertPanelDataPre_6_3(panel, useMargins) { // eslint-disable-line camelcase ['w', 'x', 'h', 'y'].forEach(key => { if (!_.has(panel.gridData, key)) { - throw new Error(`Unable to migrate panel data for "6.3.0" backwards compatibility, panel does not contain expected field: ${key}`); + throw new Error(i18n.translate('kbn.dashboard.panel.unableToMigratePanelDataForSixThreeZeroErrorMessage', { + defaultMessage: 'Unable to migrate panel data for "6.3.0" backwards compatibility, panel does not contain expected field: {key}', + values: { key }, + })); } }); @@ -78,7 +85,13 @@ export class PanelUtils { static parseVersion(version = '6.0.0') { const versionSplit = version.split('.'); if (versionSplit.length < 3) { - throw new Error(`Invalid version, ${version}, expected ..`); + throw new Error(i18n.translate('kbn.dashboard.panel.invalidVersionErrorMessage', { + defaultMessage: 'Invalid version, {version}, expected {semver}', + values: { + version, + semver: '..', + }, + })); } return { major: parseInt(versionSplit[0], 10), diff --git a/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.js b/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.js index cf82b8274b633..04773be6e428b 100644 --- a/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.js +++ b/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.js @@ -26,7 +26,7 @@ import { SavedObjectProvider } from 'ui/courier'; const module = uiModules.get('app/dashboard'); // Used only by the savedDashboards service, usually no reason to change this -module.factory('SavedDashboard', function (Private, config) { +module.factory('SavedDashboard', function (Private, config, i18n) { // SavedDashboard constructor. Usually you'd interact with an instance of this. // ID is option, without it one will be generated on save. const SavedObject = Private(SavedObjectProvider); @@ -43,7 +43,7 @@ module.factory('SavedDashboard', function (Private, config) { // default values that will get assigned if the doc is new defaults: { - title: 'New Dashboard', + title: i18n('kbn.dashboard.savedDashboard.newDashboardTitle', { defaultMessage: 'New Dashboard' }), hits: 0, description: '', panelsJSON: '[]', diff --git a/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboards.js b/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboards.js index a4563b71a26fa..c4ab8b9a96e37 100644 --- a/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboards.js +++ b/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboards.js @@ -17,6 +17,7 @@ * under the License. */ +import { i18n } from '@kbn/i18n'; import './saved_dashboard'; import { uiModules } from 'ui/modules'; import { SavedObjectLoader } from 'ui/courier/saved_object/saved_object_loader'; @@ -29,7 +30,9 @@ const module = uiModules.get('app/dashboard'); // edited by the object editor. savedObjectManagementRegistry.register({ service: 'savedDashboards', - title: 'dashboards' + title: i18n.translate('kbn.dashboard.savedDashboardsTitle', { + defaultMessage: 'dashboards', + }), }); // This is the only thing that gets injected into controllers diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/add_panel.test.js.snap b/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/add_panel.test.js.snap index d976372dd2bf3..4f96414b427ce 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/add_panel.test.js.snap +++ b/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/add_panel.test.js.snap @@ -16,7 +16,11 @@ exports[`render 1`] = ` textTransform="none" >

      - Add Panels +

      - Add new Visualization + } key="visSavedObjectFinder" diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/clone_modal.test.js.snap b/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/clone_modal.test.js.snap index 80fb7a7ed275c..92e8f07ea0da4 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/clone_modal.test.js.snap +++ b/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/clone_modal.test.js.snap @@ -10,7 +10,11 @@ exports[`renders DashboardCloneModal 1`] = ` > - Clone Dashboard + @@ -19,7 +23,11 @@ exports[`renders DashboardCloneModal 1`] = ` size="m" >

      - Please enter a new name for your dashboard. +

      - Cancel + - Confirm Clone + diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/save_modal.test.js.snap b/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/save_modal.test.js.snap index 2112aee0763cb..aae42c0b98ce0 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/save_modal.test.js.snap +++ b/src/core_plugins/kibana/public/dashboard/top_nav/__snapshots__/save_modal.test.js.snap @@ -11,7 +11,13 @@ exports[`renders DashboardSaveModal 1`] = ` describedByIds={Array []} fullWidth={false} hasEmptyLabelSpace={false} - label="Description" + label={ + + } > + } + label={ + + } > - Add new Visualization + ); const tabs = [{ id: VIS_TAB_ID, - name: 'Visualization', + name: props.intl.formatMessage({ + id: 'kbn.dashboard.topNav.addPanel.visualizationTabName', + defaultMessage: 'Visualization', + }), dataTestSubj: 'addVisualizationTab', toastDataTestSubj: 'addVisualizationToDashboardSuccess', savedObjectFinder: ( @@ -59,20 +66,29 @@ export class DashboardAddPanel extends React.Component { callToActionButton={addNewVisBtn} onChoose={this.onAddPanel} visTypes={this.props.visTypes} - noItemsMessage="No matching visualizations found." + noItemsMessage={props.intl.formatMessage({ + id: 'kbn.dashboard.topNav.addPanel.visSavedObjectFinder.noMatchingVisualizationsMessage', + defaultMessage: 'No matching visualizations found.', + })} savedObjectType="visualization" /> ) }, { id: SAVED_SEARCH_TAB_ID, - name: 'Saved Search', + name: props.intl.formatMessage({ + id: 'kbn.dashboard.topNav.addPanel.savedSearchTabName', + defaultMessage: 'Saved Search', + }), dataTestSubj: 'addSavedSearchTab', toastDataTestSubj: 'addSavedSearchToDashboardSuccess', savedObjectFinder: ( ) @@ -115,7 +131,12 @@ export class DashboardAddPanel extends React.Component { } this.lastToast = toastNotifications.addSuccess({ - title: `${this.state.selectedTab.name} was added to your dashboard`, + title: this.props.intl.formatMessage({ + id: 'kbn.dashboard.topNav.addPanel.selectedTabAddedToDashboardSuccessMessageTitle', + defaultMessage: '{selectedTabName} was added to your dashboard', + }, { + selectedTabName: this.state.selectedTab.name, + }), 'data-test-subj': this.state.selectedTab.toastDataTestSubj, }); } @@ -131,7 +152,12 @@ export class DashboardAddPanel extends React.Component { -

      Add Panels

      +

      + +

      @@ -148,9 +174,11 @@ export class DashboardAddPanel extends React.Component { } } -DashboardAddPanel.propTypes = { +DashboardAddPanelUi.propTypes = { onClose: PropTypes.func.isRequired, visTypes: PropTypes.object.isRequired, addNewPanel: PropTypes.func.isRequired, addNewVis: PropTypes.func.isRequired, }; + +export const DashboardAddPanel = injectI18n(DashboardAddPanelUi); diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/add_panel.test.js b/src/core_plugins/kibana/public/dashboard/top_nav/add_panel.test.js index 9c17980f7b9cd..3f233eed6b100 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/add_panel.test.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/add_panel.test.js @@ -19,7 +19,7 @@ import React from 'react'; import sinon from 'sinon'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { DashboardAddPanel, @@ -38,7 +38,7 @@ beforeEach(() => { }); test('render', () => { - const component = shallow( {}} diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.js b/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.js index 5bab97387a14f..507eb2b6db34e 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.js @@ -19,6 +19,7 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; +import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; import { EuiButton, @@ -34,7 +35,7 @@ import { EuiCallOut, } from '@elastic/eui'; -export class DashboardCloneModal extends React.Component { +class DashboardCloneModalUi extends React.Component { constructor(props) { super(props); @@ -90,12 +91,30 @@ export class DashboardCloneModal extends React.Component { return (

      - Click Confirm Clone to clone the dashboard with the duplicate title. + + + + ), + }} + />

      @@ -113,14 +132,20 @@ export class DashboardCloneModal extends React.Component { > - Clone Dashboard +

      - Please enter a new name for your dashboard. +

      @@ -143,7 +168,10 @@ export class DashboardCloneModal extends React.Component { data-test-subj="cloneCancelButton" onClick={this.props.onClose} > - Cancel + - Confirm Clone + @@ -161,8 +192,10 @@ export class DashboardCloneModal extends React.Component { } } -DashboardCloneModal.propTypes = { +DashboardCloneModalUi.propTypes = { onClone: PropTypes.func, onClose: PropTypes.func, title: PropTypes.string }; + +export const DashboardCloneModal = injectI18n(DashboardCloneModalUi); diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.test.js b/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.test.js index c8154fe3bdd6b..3dfaa26b79826 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.test.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.test.js @@ -19,7 +19,7 @@ import React from 'react'; import sinon from 'sinon'; -import { mount, shallow } from 'enzyme'; +import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { findTestSubject, } from '@elastic/eui/lib/test'; @@ -37,9 +37,9 @@ beforeEach(() => { onClose = sinon.spy(); }); -function createComponent(creationMethod = mount) { +function createComponent(creationMethod = mountWithIntl) { component = creationMethod( - { - createComponent(shallow); + createComponent(shallowWithIntl); expect(component).toMatchSnapshot(); // eslint-disable-line }); diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/get_top_nav_config.js b/src/core_plugins/kibana/public/dashboard/top_nav/get_top_nav_config.js index c0ac1cb2702b2..969ff3f631de5 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/get_top_nav_config.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/get_top_nav_config.js @@ -17,6 +17,7 @@ * under the License. */ +import { i18n } from '@kbn/i18n'; import { DashboardViewMode } from '../dashboard_view_mode'; import { TopNavIds } from './top_nav_ids'; @@ -57,8 +58,12 @@ export function getTopNavConfig(dashboardMode, actions, hideWriteControls) { function getFullScreenConfig(action) { return { - key: 'full screen', - description: 'Full Screen Mode', + key: i18n.translate('kbn.dashboard.topNave.fullScreenButtonAriaLabel', { + defaultMessage: 'full screen', + }), + description: i18n.translate('kbn.dashboard.topNave.fullScreenConfigDescription', { + defaultMessage: 'Full Screen Mode', + }), testId: 'dashboardFullScreenMode', run: action }; @@ -69,8 +74,12 @@ function getFullScreenConfig(action) { */ function getEditConfig(action) { return { - key: 'edit', - description: 'Switch to edit mode', + key: i18n.translate('kbn.dashboard.topNave.editButtonAriaLabel', { + defaultMessage: 'edit', + }), + description: i18n.translate('kbn.dashboard.topNave.editConfigDescription', { + defaultMessage: 'Switch to edit mode', + }), testId: 'dashboardEditMode', run: action }; @@ -81,8 +90,12 @@ function getEditConfig(action) { */ function getSaveConfig(action) { return { - key: TopNavIds.SAVE, - description: 'Save your dashboard', + key: i18n.translate('kbn.dashboard.topNave.saveButtonAriaLabel', { + defaultMessage: 'save', + }), + description: i18n.translate('kbn.dashboard.topNave.saveConfigDescription', { + defaultMessage: 'Save your dashboard', + }), testId: 'dashboardSaveMenuItem', run: action }; @@ -93,8 +106,12 @@ function getSaveConfig(action) { */ function getViewConfig(action) { return { - key: 'cancel', - description: 'Cancel editing and switch to view-only mode', + key: i18n.translate('kbn.dashboard.topNave.cancelButtonAriaLabel', { + defaultMessage: 'cancel', + }), + description: i18n.translate('kbn.dashboard.topNave.viewConfigDescription', { + defaultMessage: 'Cancel editing and switch to view-only mode', + }), testId: 'dashboardViewOnlyMode', run: action }; @@ -105,8 +122,12 @@ function getViewConfig(action) { */ function getCloneConfig(action) { return { - key: TopNavIds.CLONE, - description: 'Create a copy of your dashboard', + key: i18n.translate('kbn.dashboard.topNave.cloneButtonAriaLabel', { + defaultMessage: 'clone', + }), + description: i18n.translate('kbn.dashboard.topNave.cloneConfigDescription', { + defaultMessage: 'Create a copy of your dashboard', + }), testId: 'dashboardClone', run: action }; @@ -117,8 +138,12 @@ function getCloneConfig(action) { */ function getAddConfig(action) { return { - key: TopNavIds.ADD, - description: 'Add a panel to the dashboard', + key: i18n.translate('kbn.dashboard.topNave.addButtonAriaLabel', { + defaultMessage: 'add', + }), + description: i18n.translate('kbn.dashboard.topNave.addConfigDescription', { + defaultMessage: 'Add a panel to the dashboard', + }), testId: 'dashboardAddPanelButton', run: action }; @@ -129,8 +154,12 @@ function getAddConfig(action) { */ function getShareConfig(action) { return { - key: TopNavIds.SHARE, - description: 'Share Dashboard', + key: i18n.translate('kbn.dashboard.topNave.shareButtonAriaLabel', { + defaultMessage: 'share', + }), + description: i18n.translate('kbn.dashboard.topNave.shareConfigDescription', { + defaultMessage: 'Share Dashboard', + }), testId: 'shareTopNavButton', run: action, }; @@ -141,8 +170,12 @@ function getShareConfig(action) { */ function getOptionsConfig(action) { return { - key: TopNavIds.OPTIONS, - description: 'Options', + key: i18n.translate('kbn.dashboard.topNave.optionsButtonAriaLabel', { + defaultMessage: 'options', + }), + description: i18n.translate('kbn.dashboard.topNave.optionsConfigDescription', { + defaultMessage: 'Options', + }), testId: 'dashboardOptionsButton', run: action, }; diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/options.js b/src/core_plugins/kibana/public/dashboard/top_nav/options.js index 6c42c2d26a25e..62c3b65374db4 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/options.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/options.js @@ -19,6 +19,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; +import { injectI18n } from '@kbn/i18n/react'; import { EuiForm, @@ -26,7 +27,7 @@ import { EuiSwitch, } from '@elastic/eui'; -export class OptionsMenu extends Component { +class OptionsMenuUi extends Component { state = { darkTheme: this.props.darkTheme, @@ -60,7 +61,10 @@ export class OptionsMenu extends Component { } > } + helpText={} > { - const component = shallow( {}} onClose={() => {}} title="dash title" diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/show_add_panel.js b/src/core_plugins/kibana/public/dashboard/top_nav/show_add_panel.js index 00719a850aca4..d4d8b1a0e4040 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/show_add_panel.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/show_add_panel.js @@ -17,6 +17,7 @@ * under the License. */ +import { I18nProvider } from '@kbn/i18n/react'; import { DashboardAddPanel } from './add_panel'; import React from 'react'; import ReactDOM from 'react-dom'; @@ -43,12 +44,14 @@ export function showAddPanel(addNewPanel, addNewVis, visTypes) { document.body.appendChild(container); const element = ( - + + + ); ReactDOM.render(element, container); } diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/show_clone_modal.js b/src/core_plugins/kibana/public/dashboard/top_nav/show_clone_modal.js index d75c3da660e9f..08163a9a35956 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/show_clone_modal.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/show_clone_modal.js @@ -17,9 +17,11 @@ * under the License. */ +import { I18nProvider } from '@kbn/i18n/react'; import { DashboardCloneModal } from './clone_modal'; import React from 'react'; import ReactDOM from 'react-dom'; +import { i18n } from '@kbn/i18n'; export function showCloneModal(onClone, title) { const container = document.createElement('div'); @@ -37,7 +39,16 @@ export function showCloneModal(onClone, title) { }; document.body.appendChild(container); const element = ( - + + + ); ReactDOM.render(element, container); } diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/show_options_popover.js b/src/core_plugins/kibana/public/dashboard/top_nav/show_options_popover.js index 2d2dd83b4c34e..cf6fba6316e76 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/show_options_popover.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/show_options_popover.js @@ -19,6 +19,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; +import { I18nProvider } from '@kbn/i18n/react'; import { OptionsMenu } from './options'; @@ -53,22 +54,24 @@ export function showOptionsPopover({ document.body.appendChild(container); const element = ( - - - + + + + + ); ReactDOM.render(element, container); } diff --git a/src/core_plugins/kibana/public/dashboard/viewport/dashboard_viewport_provider.js b/src/core_plugins/kibana/public/dashboard/viewport/dashboard_viewport_provider.js index a219f763dac28..95b66cc1c4c59 100644 --- a/src/core_plugins/kibana/public/dashboard/viewport/dashboard_viewport_provider.js +++ b/src/core_plugins/kibana/public/dashboard/viewport/dashboard_viewport_provider.js @@ -19,6 +19,7 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { I18nProvider } from '@kbn/i18n/react'; import { store } from '../../store'; import { Provider } from 'react-redux'; import { DashboardViewportContainer } from './dashboard_viewport_container'; @@ -26,7 +27,9 @@ import { DashboardViewportContainer } from './dashboard_viewport_container'; export function DashboardViewportProvider(props) { return ( - + + + ); } diff --git a/src/ui/public/saved_objects/show_saved_object_save_modal.js b/src/ui/public/saved_objects/show_saved_object_save_modal.js index f53f819c697f5..5cb1681c08282 100644 --- a/src/ui/public/saved_objects/show_saved_object_save_modal.js +++ b/src/ui/public/saved_objects/show_saved_object_save_modal.js @@ -19,6 +19,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; +import { I18nProvider } from '@kbn/i18n/react'; export function showSaveModal(saveModal) { const container = document.createElement('div'); @@ -44,5 +45,6 @@ export function showSaveModal(saveModal) { onClose: closeModal } ); - ReactDOM.render(element, container); + + ReactDOM.render({element}, container); } diff --git a/tsconfig.json b/tsconfig.json index 0ca1bef98f432..6eedfa53b2619 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,9 @@ "paths": { "ui/*": [ "src/ui/public/*" + ], + "test_utils/*": [ + "src/test_utils/public/*" ] }, // Support .tsx files and transform JSX into calls to React.createElement @@ -54,4 +57,4 @@ // the tsconfig.json file for public files correctly. // "src/**/public/**/*" ] -} \ No newline at end of file +} From cf64825ff2f125881755f05e04c0bfce0a887ebb Mon Sep 17 00:00:00 2001 From: tibmt Date: Tue, 20 Nov 2018 10:22:10 +0300 Subject: [PATCH 26/95] Translate security/roles component (#23984) Translate security/roles component --- .../collapsible_panel.test.tsx.snap | 6 +- .../components/collapsible_panel.test.tsx | 8 +- .../components/collapsible_panel.tsx | 15 +- .../components/delete_role_button.test.tsx | 8 +- .../components/delete_role_button.tsx | 41 +- .../edit_role/components/edit_role_page.tsx | 109 +++++- .../elasticsearch_privileges.test.tsx.snap | 365 ++++++++++-------- .../index_privilege_form.test.tsx.snap | 40 +- .../es/elasticsearch_privileges.test.tsx | 14 +- .../es/elasticsearch_privileges.tsx | 75 +++- .../es/index_privilege_form.test.tsx | 24 +- .../privileges/es/index_privilege_form.tsx | 53 ++- .../privileges/es/index_privileges.test.tsx | 6 +- .../impacted_spaces_flyout.test.tsx.snap | 6 +- .../kibana_privileges.test.tsx.snap | 96 ++--- .../privilege_callout_warning.test.tsx.snap | 176 ++++++++- .../privilege_space_form.test.tsx.snap | 16 +- .../simple_privilege_form.test.tsx.snap | 12 +- .../space_aware_privilege_form.test.tsx.snap | 223 +++++++++-- .../kibana/impacted_spaces_flyout.test.tsx | 26 +- .../kibana/impacted_spaces_flyout.tsx | 34 +- .../privileges/kibana/kibana_privileges.tsx | 9 +- .../kibana/privilege_callout_warning.test.tsx | 4 +- .../kibana/privilege_callout_warning.tsx | 100 ++++- .../kibana/privilege_space_form.test.tsx | 4 +- .../kibana/privilege_space_form.tsx | 15 +- .../kibana/privilege_space_table.tsx | 39 +- .../kibana/simple_privilege_form.test.tsx | 10 +- .../kibana/simple_privilege_form.tsx | 22 +- .../space_aware_privilege_form.test.tsx | 24 +- .../kibana/space_aware_privilege_form.tsx | 119 +++++- .../components/reserved_role_badge.tsx | 10 +- .../views/management/edit_role/index.js | 32 +- .../__snapshots__/validate_role.test.ts.snap | 2 +- .../management/edit_role/lib/validate_role.ts | 63 ++- .../public/views/management/management.js | 16 +- .../public/views/management/roles.html | 89 +++-- .../security/public/views/management/roles.js | 53 ++- 38 files changed, 1486 insertions(+), 478 deletions(-) diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/__snapshots__/collapsible_panel.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/__snapshots__/collapsible_panel.test.tsx.snap index 3b3587c7ff524..a940a55b3754b 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/__snapshots__/collapsible_panel.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/__snapshots__/collapsible_panel.test.tsx.snap @@ -43,7 +43,11 @@ exports[`it renders without blowing up 1`] = ` onClick={[Function]} type="button" > - hide + diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/collapsible_panel.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/collapsible_panel.test.tsx index 86f1e73b78e1b..b1e23cb43983e 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/collapsible_panel.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/collapsible_panel.test.tsx @@ -5,12 +5,12 @@ */ import { EuiLink } from '@elastic/eui'; -import { mount, shallow } from 'enzyme'; import React from 'react'; +import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { CollapsiblePanel } from './collapsible_panel'; test('it renders without blowing up', () => { - const wrapper = shallow( + const wrapper = shallowWithIntl(

      child

      @@ -20,7 +20,7 @@ test('it renders without blowing up', () => { }); test('it renders children by default', () => { - const wrapper = mount( + const wrapper = mountWithIntl(

      child 1

      child 2

      @@ -32,7 +32,7 @@ test('it renders children by default', () => { }); test('it hides children when the "hide" link is clicked', () => { - const wrapper = mount( + const wrapper = mountWithIntl(

      child 1

      child 2

      diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/collapsible_panel.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/collapsible_panel.tsx index f8271d4d83d2a..1a2907b790c9c 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/collapsible_panel.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/collapsible_panel.tsx @@ -13,6 +13,7 @@ import { EuiSpacer, EuiTitle, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; interface Props { @@ -55,7 +56,19 @@ export class CollapsiblePanel extends Component { - {this.state.collapsed ? 'show' : 'hide'} + + {this.state.collapsed ? ( + + ) : ( + + )} + ); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/delete_role_button.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/delete_role_button.test.tsx index 8a78748b46232..cc16866c88355 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/delete_role_button.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/delete_role_button.test.tsx @@ -9,20 +9,20 @@ import { // @ts-ignore EuiConfirmModal, } from '@elastic/eui'; -import { mount, shallow } from 'enzyme'; import React from 'react'; +import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { DeleteRoleButton } from './delete_role_button'; test('it renders without crashing', () => { const deleteHandler = jest.fn(); - const wrapper = shallow(); + const wrapper = shallowWithIntl(); expect(wrapper.find(EuiButtonEmpty)).toHaveLength(1); expect(deleteHandler).toHaveBeenCalledTimes(0); }); test('it shows a confirmation dialog when clicked', () => { const deleteHandler = jest.fn(); - const wrapper = mount(); + const wrapper = mountWithIntl(); wrapper.find(EuiButtonEmpty).simulate('click'); @@ -33,7 +33,7 @@ test('it shows a confirmation dialog when clicked', () => { test('it renders nothing when canDelete is false', () => { const deleteHandler = jest.fn(); - const wrapper = shallow(); + const wrapper = shallowWithIntl(); expect(wrapper.find('*')).toHaveLength(0); expect(deleteHandler).toHaveBeenCalledTimes(0); }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/delete_role_button.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/delete_role_button.tsx index 28b3107a96c42..22820edd73c98 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/delete_role_button.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/delete_role_button.tsx @@ -11,6 +11,7 @@ import { // @ts-ignore EuiOverlayMask, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; interface Props { @@ -35,7 +36,10 @@ export class DeleteRoleButton extends Component { return ( - Delete role + {this.maybeShowModal()} @@ -49,15 +53,40 @@ export class DeleteRoleButton extends Component { return ( + } onCancel={this.closeModal} onConfirm={this.onConfirmDelete} - cancelButtonText={"No, don't delete"} - confirmButtonText={'Yes, delete role'} + cancelButtonText={ + + } + confirmButtonText={ + + } buttonColor={'danger'} > -

      Are you sure you want to delete this role?

      -

      This action cannot be undone!

      +

      + +

      +

      + +

      ); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx index 98f8bbcf10873..a3b6b58d09d06 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + import { EuiButton, EuiButtonEmpty, @@ -19,6 +20,7 @@ import { EuiText, EuiTitle, } from '@elastic/eui'; +import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import { get } from 'lodash'; import React, { ChangeEvent, Component, Fragment, HTMLProps } from 'react'; import { toastNotifications } from 'ui/notify'; @@ -47,6 +49,7 @@ interface Props { spaces?: Space[]; spacesEnabled: boolean; userProfile: UserProfile; + intl: InjectedIntl; } interface State { @@ -54,7 +57,7 @@ interface State { formError: RoleValidationResult | null; } -export class EditRolePage extends Component { +class EditRolePageUI extends Component { private validator: RoleValidator; constructor(props: Props) { @@ -67,9 +70,17 @@ export class EditRolePage extends Component { } public render() { - const description = this.props.spacesEnabled - ? `Set privileges on your Elasticsearch data and control access to your Kibana spaces.` - : `Set privileges on your Elasticsearch data and control access to Kibana.`; + const description = this.props.spacesEnabled ? ( + + ) : ( + + ); return ( @@ -86,7 +97,10 @@ export class EditRolePage extends Component {

      - Reserved roles are built-in and cannot be removed or modified. +

      @@ -115,12 +129,27 @@ export class EditRolePage extends Component { tabIndex: 0, }; if (isReservedRole(this.props.role)) { - titleText = 'Viewing role'; + titleText = ( + + ); props['aria-describedby'] = 'reservedRoleDescription'; } else if (this.editingExistingRole()) { - titleText = 'Edit role'; + titleText = ( + + ); } else { - titleText = 'Create role'; + titleText = ( + + ); } return ( @@ -148,11 +177,21 @@ export class EditRolePage extends Component { return ( + } helpText={ - !isReservedRole(this.props.role) && this.editingExistingRole() - ? "A role's name cannot be changed once it has been created." - : undefined + !isReservedRole(this.props.role) && this.editingExistingRole() ? ( + + ) : ( + undefined + ) } {...this.validator.validateRoleName(this.state.role)} > @@ -225,10 +264,27 @@ export class EditRolePage extends Component { public getFormButtons = () => { if (isReservedRole(this.props.role)) { - return Return to role list; + return ( + + + + ); } - const saveText = this.editingExistingRole() ? 'Update role' : 'Create role'; + const saveText = this.editingExistingRole() ? ( + + ) : ( + + ); return ( @@ -244,7 +300,10 @@ export class EditRolePage extends Component { - Cancel + @@ -274,7 +333,7 @@ export class EditRolePage extends Component { formError: null, }); - const { httpClient } = this.props; + const { httpClient, intl } = this.props; const role = { ...this.state.role, @@ -287,7 +346,12 @@ export class EditRolePage extends Component { saveRole(httpClient, role) .then(() => { - toastNotifications.addSuccess('Saved role'); + toastNotifications.addSuccess( + intl.formatMessage({ + id: 'xpack.security.management.editRole.roleSuccessfullySavedNotificationMessage', + defaultMessage: 'Saved role', + }) + ); this.backToRoleList(); }) .catch((error: any) => { @@ -297,11 +361,16 @@ export class EditRolePage extends Component { }; public handleDeleteRole = () => { - const { httpClient, role } = this.props; + const { httpClient, role, intl } = this.props; deleteRole(httpClient, role.name) .then(() => { - toastNotifications.addSuccess('Deleted role'); + toastNotifications.addSuccess( + intl.formatMessage({ + id: 'xpack.security.management.editRole.roleSuccessfullyDeletedNotificationMessage', + defaultMessage: 'Deleted role', + }) + ); this.backToRoleList(); }) .catch((error: any) => { @@ -313,3 +382,5 @@ export class EditRolePage extends Component { window.location.hash = ROLES_PATH; }; } + +export const EditRolePage = injectI18n(EditRolePageUI); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/__snapshots__/elasticsearch_privileges.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/__snapshots__/elasticsearch_privileges.test.tsx.snap index 416cec99b3271..02d44c23ac5c3 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/__snapshots__/elasticsearch_privileges.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/__snapshots__/elasticsearch_privileges.test.tsx.snap @@ -1,181 +1,220 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`it renders without crashing 1`] = ` - - - - Manage the actions this role can perform against your cluster. - - - Learn more - -

      - } - fullWidth={false} - gutterSize="l" - title={ + + + + + + + + +

      + } + fullWidth={false} + gutterSize="l" + title={ +

      + +

      + } + titleSize="xs" + > + + + +
      + + + + + + +

      + } + fullWidth={false} + gutterSize="l" + title={ +

      + +

      + } + titleSize="xs" + > + + + +
      + +

      - Cluster privileges +

      - } - titleSize="xs" - > - + + - - -
      - - - Allow requests to be submitted on the behalf of other users. - + - Learn more +

      - } - fullWidth={false} - gutterSize="l" - title={ -

      - Run As privileges -

      - } - titleSize="xs" - > - - - -
      - - -

      - Index privileges -

      -
      - - -

      - Control access to the data in your cluster. - - - Learn more - -

      -
      - + - - - Add index privilege - -
      -
      + /> + + + + +
      + + `; diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/__snapshots__/index_privilege_form.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/__snapshots__/index_privilege_form.test.tsx.snap index c55876b87186b..54446baa76a6f 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/__snapshots__/index_privilege_form.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/__snapshots__/index_privilege_form.test.tsx.snap @@ -39,7 +39,13 @@ exports[`it renders without crashing 1`] = ` fullWidth={true} hasEmptyLabelSpace={false} isInvalid={false} - label="Indices" + label={ + + } > + } > + } + label={ + + } > + } onChange={[Function]} value={false} /> diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/elasticsearch_privileges.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/elasticsearch_privileges.test.tsx index 3a948801102a5..b58cab2197fe4 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/elasticsearch_privileges.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/elasticsearch_privileges.test.tsx @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mount, shallow } from 'enzyme'; import React from 'react'; +import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { RoleValidator } from '../../../lib/validate_role'; import { ClusterPrivileges } from './cluster_privileges'; import { ElasticsearchPrivileges } from './elasticsearch_privileges'; @@ -34,7 +34,9 @@ test('it renders without crashing', () => { allowFieldLevelSecurity: true, validator: new RoleValidator(), }; - const wrapper = shallow(); + const wrapper = shallowWithIntl( + + ); expect(wrapper).toMatchSnapshot(); }); @@ -61,7 +63,9 @@ test('it renders ClusterPrivileges', () => { allowFieldLevelSecurity: true, validator: new RoleValidator(), }; - const wrapper = mount(); + const wrapper = mountWithIntl( + + ); expect(wrapper.find(ClusterPrivileges)).toHaveLength(1); }); @@ -88,6 +92,8 @@ test('it renders IndexPrivileges', () => { allowFieldLevelSecurity: true, validator: new RoleValidator(), }; - const wrapper = mount(); + const wrapper = mountWithIntl( + + ); expect(wrapper.find(IndexPrivileges)).toHaveLength(1); }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/elasticsearch_privileges.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/elasticsearch_privileges.tsx index 2625ff9879d3f..d2caf24053815 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/elasticsearch_privileges.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/elasticsearch_privileges.tsx @@ -16,6 +16,7 @@ import { EuiText, EuiTitle, } from '@elastic/eui'; +import { FormattedMessage, I18nProvider, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; import { Role } from '../../../../../../../common/model/role'; // @ts-ignore @@ -36,14 +37,17 @@ interface Props { indexPatterns: string[]; allowDocumentLevelSecurity: boolean; allowFieldLevelSecurity: boolean; + intl: InjectedIntl; } -export class ElasticsearchPrivileges extends Component { +class ElasticsearchPrivilegesUI extends Component { public render() { return ( - - {this.getForm()} - + + + {this.getForm()} + + ); } @@ -56,6 +60,7 @@ export class ElasticsearchPrivileges extends Component { indexPatterns, allowDocumentLevelSecurity, allowFieldLevelSecurity, + intl, } = this.props; const indexProps = { @@ -71,10 +76,20 @@ export class ElasticsearchPrivileges extends Component { return ( Cluster privileges} + title={ +

      + +

      + } description={

      - Manage the actions this role can perform against your cluster.{' '} + {this.learnMore(documentationLinks.esClusterPrivileges)}

      } @@ -87,17 +102,35 @@ export class ElasticsearchPrivileges extends Component { Run As privileges} + title={ +

      + +

      + } description={

      - Allow requests to be submitted on the behalf of other users.{' '} + {this.learnMore(documentationLinks.esRunAsPrivileges)}

      } > ({ id: username, label: username, @@ -113,12 +146,20 @@ export class ElasticsearchPrivileges extends Component { -

      Index privileges

      +

      + +

      - Control access to the data in your cluster.{' '} + {this.learnMore(documentationLinks.esIndicesPrivileges)}

      @@ -129,7 +170,10 @@ export class ElasticsearchPrivileges extends Component { {this.props.editable && ( - Add index privilege + )}
      @@ -138,7 +182,10 @@ export class ElasticsearchPrivileges extends Component { public learnMore = (href: string) => ( - Learn more + ); @@ -189,3 +236,5 @@ export class ElasticsearchPrivileges extends Component { this.props.onChange(role); }; } + +export const ElasticsearchPrivileges = injectI18n(ElasticsearchPrivilegesUI); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/index_privilege_form.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/index_privilege_form.test.tsx index 2d68676694304..dd3092293d3bc 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/index_privilege_form.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/index_privilege_form.test.tsx @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ import { EuiButtonIcon, EuiSwitch, EuiTextArea } from '@elastic/eui'; -import { mount, shallow } from 'enzyme'; import React from 'react'; +import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { RoleValidator } from '../../../lib/validate_role'; import { IndexPrivilegeForm } from './index_privilege_form'; @@ -31,7 +31,7 @@ test('it renders without crashing', () => { onDelete: jest.fn(), }; - const wrapper = shallow(); + const wrapper = shallowWithIntl(); expect(wrapper).toMatchSnapshot(); }); @@ -62,7 +62,7 @@ describe('delete button', () => { ...props, allowDelete: false, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find(EuiButtonIcon)).toHaveLength(0); }); @@ -71,7 +71,7 @@ describe('delete button', () => { ...props, allowDelete: true, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find(EuiButtonIcon)).toHaveLength(1); }); @@ -80,7 +80,7 @@ describe('delete button', () => { ...props, allowDelete: true, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); wrapper.find(EuiButtonIcon).simulate('click'); expect(testProps.onDelete).toHaveBeenCalledTimes(1); }); @@ -114,7 +114,7 @@ describe(`document level security`, () => { allowDocumentLevelSecurity: false, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find(EuiSwitch)).toHaveLength(0); expect(wrapper.find(EuiTextArea)).toHaveLength(0); }); @@ -128,7 +128,7 @@ describe(`document level security`, () => { }, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find(EuiSwitch)).toHaveLength(1); expect(wrapper.find(EuiTextArea)).toHaveLength(0); }); @@ -138,7 +138,7 @@ describe(`document level security`, () => { ...props, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find(EuiSwitch)).toHaveLength(1); expect(wrapper.find(EuiTextArea)).toHaveLength(1); }); @@ -172,7 +172,7 @@ describe('field level security', () => { allowFieldLevelSecurity: false, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find('.indexPrivilegeForm__grantedFieldsRow')).toHaveLength(0); }); @@ -181,7 +181,7 @@ describe('field level security', () => { ...props, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find('div.indexPrivilegeForm__grantedFieldsRow')).toHaveLength(1); }); @@ -196,7 +196,7 @@ describe('field level security', () => { }, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find('div.indexPrivilegeForm__grantedFieldsRow')).toHaveLength(1); expect(wrapper.find('.euiFormHelpText')).toHaveLength(1); }); @@ -206,7 +206,7 @@ describe('field level security', () => { ...props, }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find('div.indexPrivilegeForm__grantedFieldsRow')).toHaveLength(1); expect(wrapper.find('.euiFormHelpText')).toHaveLength(0); }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/index_privilege_form.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/index_privilege_form.tsx index 6f1416ab43552..42834afa888ee 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/index_privilege_form.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/es/index_privilege_form.tsx @@ -15,6 +15,7 @@ import { EuiSwitch, EuiTextArea, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import React, { ChangeEvent, Component, Fragment } from 'react'; import { IndexPrivilege } from '../../../../../../../common/model/index_privilege'; // @ts-ignore @@ -81,7 +82,12 @@ export class IndexPrivilegeForm extends Component { + } fullWidth={true} {...this.props.validator.validateIndexPrivilege(this.props.indexPrivilege)} > @@ -96,7 +102,15 @@ export class IndexPrivilegeForm extends Component { - + + } + fullWidth={true} + > { return ( + } fullWidth={true} className="indexPrivilegeForm__grantedFieldsRow" helpText={ - !isReservedRole && grant.length === 0 - ? 'If no fields are granted, then users assigned to this role will not be able to see any data for this index.' - : undefined + !isReservedRole && grant.length === 0 ? ( + + ) : ( + undefined + ) } > @@ -170,7 +194,12 @@ export class IndexPrivilegeForm extends Component { + } // @ts-ignore compressed={true} // @ts-ignore @@ -181,7 +210,15 @@ export class IndexPrivilegeForm extends Component { )} {this.state.queryExpanded && ( - + + } + fullWidth={true} + > { allowFieldLevelSecurity: true, validator: new RoleValidator(), }; - const wrapper = shallow(); + const wrapper = shallowWithIntl(); expect(wrapper).toMatchSnapshot(); }); @@ -65,6 +65,6 @@ test('it renders a IndexPrivilegeForm for each privilege on the role', () => { allowFieldLevelSecurity: true, validator: new RoleValidator(), }; - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find(IndexPrivilegeForm)).toHaveLength(1); }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/impacted_spaces_flyout.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/impacted_spaces_flyout.test.tsx.snap index c67cde88bb444..c749a49bce110 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/impacted_spaces_flyout.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/impacted_spaces_flyout.test.tsx.snap @@ -10,7 +10,11 @@ exports[` renders without crashing 1`] = ` onClick={[Function]} type="button" > - View summary of spaces privileges +
      diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap index 50ef26bbe56ac..82d0190ad54cc 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap @@ -1,56 +1,58 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` renders without crashing 1`] = ` - - + + - + /> + + `; diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/privilege_callout_warning.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/privilege_callout_warning.test.tsx.snap index 53f3fc716d65e..bdce226863ef3 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/privilege_callout_warning.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/privilege_callout_warning.test.tsx.snap @@ -3,13 +3,101 @@ exports[`PrivilegeCalloutWarning renders without crashing 1`] = ` + } >
      - Minimum privilege is too high to customize individual spaces + + Minimum privilege is too high to customize individual spaces +

      - Setting the minimum privilege to - - all - - grants full access to all spaces. To customize privileges for individual spaces, the minimum privilege must be either - - read - - or - - none - - . + + + , + "noneText": + + , + "readText": + + , + } + } + > + Setting the minimum privilege to + + + all + + + grants full access to all + spaces. To customize privileges for individual spaces, the minimum privilege must be + either + + + read + + + or + + + none + + + . +

      diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/privilege_space_form.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/privilege_space_form.test.tsx.snap index c24b2d596ff22..a435e7c43ceb1 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/privilege_space_form.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/privilege_space_form.test.tsx.snap @@ -19,7 +19,13 @@ exports[` renders without crashing 1`] = ` fullWidth={false} hasEmptyLabelSpace={false} isInvalid={false} - label="Spaces" + label={ + + } > renders without crashing 1`] = ` fullWidth={false} hasEmptyLabelSpace={false} isInvalid={false} - label="Privilege" + label={ + + } > renders without crashing 1`] = ` - Specifies the Kibana privilege for this role. +

      } fullWidth={false} gutterSize="l" title={

      - Kibana privileges +

      } titleSize="xs" diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/space_aware_privilege_form.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/space_aware_privilege_form.test.tsx.snap index c032aec950064..da21290b11e24 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/space_aware_privilege_form.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/space_aware_privilege_form.test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` hides the space table if there are no existing space privileges 1`] = ` - hides the space table if there are no existin }, ] } -/> +> + + `; exports[` renders without crashing 1`] = ` @@ -47,14 +169,22 @@ exports[` renders without crashing 1`] = ` - Specify the minimum actions users can perform in your spaces. +

      } fullWidth={false} gutterSize="l" title={

      - Minimum privileges for all spaces +

      } titleSize="xs" @@ -89,7 +219,11 @@ exports[` renders without crashing 1`] = ` textTransform="none" >

      - Higher privileges for individual spaces +

      renders without crashing 1`] = ` size="s" >

      - Grant more privileges on a per space basis. For example, if the privileges are - - - read - - for all spaces, you can set the privileges to - - all - - - for an individual space. + + + , + "read": + + , + } + } + />

      - renders without crashing 1`] = ` size="s" type="button" > - Add space privilege + - with user profile disabling "manageSpaces" re size="m" title={

      - Insufficient Privileges +

      } >

      - You are not authorized to view all available spaces. +

      - Please ensure your account has all privileges granted by the - - - kibana_user - - role, and try again. + + + , + } + } + />

      `; diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx index 721fcffeb5b1c..8a103ff493165 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx @@ -52,16 +52,24 @@ const buildProps = (customProps = {}) => { describe('', () => { it('renders without crashing', () => { - expect(shallowWithIntl()).toMatchSnapshot(); + expect( + shallowWithIntl( + + ) + ).toMatchSnapshot(); }); it('does not immediately show the flyout', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + + ); expect(wrapper.find(EuiFlyout)).toHaveLength(0); }); it('shows the flyout after clicking the link', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + + ); wrapper.find(EuiLink).simulate('click'); expect(wrapper.find(EuiFlyout)).toHaveLength(1); }); @@ -82,7 +90,9 @@ describe('', () => { }, }); - const wrapper = shallowWithIntl(); + const wrapper = shallowWithIntl( + + ); wrapper.find(EuiLink).simulate('click'); const table = wrapper.find(PrivilegeSpaceTable); @@ -112,7 +122,9 @@ describe('', () => { }, }); - const wrapper = shallowWithIntl(); + const wrapper = shallowWithIntl( + + ); wrapper.find(EuiLink).simulate('click'); const table = wrapper.find(PrivilegeSpaceTable); @@ -141,7 +153,9 @@ describe('', () => { }, }); - const wrapper = shallowWithIntl(); + const wrapper = shallowWithIntl( + + ); wrapper.find(EuiLink).simulate('click'); const table = wrapper.find(PrivilegeSpaceTable); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx index 1636bf14a484a..f811912e6148f 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx @@ -12,6 +12,7 @@ import { EuiLink, EuiTitle, } from '@elastic/eui'; +import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; import { PrivilegeSpaceTable } from './privilege_space_table'; @@ -26,13 +27,14 @@ interface Props { role: Role; spaces: Space[]; userProfile: UserProfile; + intl: InjectedIntl; } interface State { showImpactedSpaces: boolean; } -export class ImpactedSpacesFlyout extends Component { +class ImpactedSpacesFlyoutUI extends Component { constructor(props: Props) { super(props); this.state = { @@ -46,7 +48,10 @@ export class ImpactedSpacesFlyout extends Component {
      - View summary of spaces privileges +
      {flyout} @@ -61,13 +66,23 @@ export class ImpactedSpacesFlyout extends Component { }; public getHighestPrivilege(...privileges: KibanaPrivilege[]): KibanaPrivilege { + const { intl } = this.props; if (privileges.indexOf('all') >= 0) { - return 'all'; + return intl.formatMessage({ + id: 'xpack.security.management.editRoles.impactedSpacesFlyout.allLabel', + defaultMessage: 'all', + }) as KibanaPrivilege; } if (privileges.indexOf('read') >= 0) { - return 'read'; + return intl.formatMessage({ + id: 'xpack.security.management.editRoles.impactedSpacesFlyout.readLabel', + defaultMessage: 'read', + }) as KibanaPrivilege; } - return 'none'; + return intl.formatMessage({ + id: 'xpack.security.management.editRoles.impactedSpacesFlyout.noneLabel', + defaultMessage: 'none', + }) as KibanaPrivilege; } public getFlyout = () => { @@ -106,7 +121,12 @@ export class ImpactedSpacesFlyout extends Component { > -

      Summary of space privileges

      +

      + +

      @@ -125,3 +145,5 @@ export class ImpactedSpacesFlyout extends Component { ); }; } + +export const ImpactedSpacesFlyout = injectI18n(ImpactedSpacesFlyoutUI); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx index 80d848b5893d5..12783ecd150bf 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { I18nProvider } from '@kbn/i18n/react'; import React, { Component } from 'react'; import { Space } from '../../../../../../../../spaces/common/model/space'; import { UserProfile } from '../../../../../../../../xpack_main/public/services/user_profile'; @@ -28,9 +29,11 @@ interface Props { export class KibanaPrivileges extends Component { public render() { return ( - - {this.getForm()} - + + + {this.getForm()} + + ); } diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_callout_warning.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_callout_warning.test.tsx index 1e8d3f3c39158..4ee2640ed1c9e 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_callout_warning.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_callout_warning.test.tsx @@ -4,14 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mount } from 'enzyme'; import React from 'react'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { PrivilegeCalloutWarning } from './privilege_callout_warning'; describe('PrivilegeCalloutWarning', () => { it('renders without crashing', () => { expect( - mount() + mountWithIntl() ).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_callout_warning.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_callout_warning.tsx index 0b5666f391573..ed24e61e5f1fd 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_callout_warning.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_callout_warning.tsx @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { EuiCallOut } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component } from 'react'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { NO_PRIVILEGE_VALUE } from '../../../lib/constants'; @@ -33,11 +34,19 @@ export class PrivilegeCalloutWarning extends Component { + } >

      - This role always grants full access to all spaces. To customize privileges for - individual spaces, you must create a new role. +

      ); @@ -46,12 +55,46 @@ export class PrivilegeCalloutWarning extends Component { + } >

      - Setting the minimum privilege to all grants full access to all - spaces. To customize privileges for individual spaces, the minimum privilege must be - either read or none. + + + + ), + readText: ( + + + + ), + noneText: ( + + + + ), + }} + />

      ); @@ -64,11 +107,19 @@ export class PrivilegeCalloutWarning extends Component { + } >

      - This role always grants read access to all spaces. To customize privileges for - individual spaces, you must create a new role. +

      ); @@ -79,7 +130,20 @@ export class PrivilegeCalloutWarning extends Component { iconType="iInCircle" title={ - The minimal possible privilege is read. + + + + ), + }} + /> } /> @@ -92,11 +156,19 @@ export class PrivilegeCalloutWarning extends Component { + } >

      - This role never grants access to any spaces within Kibana. To customize privileges for - individual spaces, you must create a new role. +

      ); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_space_form.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_space_form.test.tsx index 95494567446b7..800c628b17243 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_space_form.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_space_form.test.tsx @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallow } from 'enzyme'; import React from 'react'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { RoleValidator } from '../../../lib/validate_role'; import { PrivilegeSpaceForm } from './privilege_space_form'; @@ -40,6 +40,6 @@ const buildProps = (customProps = {}) => { describe('', () => { it('renders without crashing', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallowWithIntl()).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_space_form.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_space_form.tsx index cf7bcf8287b9d..4907a5b41a53c 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_space_form.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/privilege_space_form.tsx @@ -5,6 +5,7 @@ */ import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component } from 'react'; import { Space } from '../../../../../../../../spaces/common/model/space'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; @@ -41,7 +42,12 @@ export class PrivilegeSpaceForm extends Component { + } {...validator.validateSelectedSpaces(selectedSpaceIds, selectedPrivilege)} > { + } {...validator.validateSelectedPrivilege(selectedSpaceIds, selectedPrivilege)} > void; readonly?: boolean; + intl: InjectedIntl; } interface State { @@ -35,13 +37,13 @@ interface DeletedSpace extends Space { deleted: boolean; } -export class PrivilegeSpaceTable extends Component { +class PrivilegeSpaceTableUI extends Component { public state = { searchTerm: '', }; public render() { - const { role, spaces, availablePrivileges, spacePrivileges } = this.props; + const { role, spaces, availablePrivileges, spacePrivileges, intl } = this.props; const { searchTerm } = this.state; @@ -74,7 +76,10 @@ export class PrivilegeSpaceTable extends Component { search={{ box: { incremental: true, - placeholder: 'Filter', + placeholder: intl.formatMessage({ + id: 'xpack.security.management.editRoles.privilegeSpaceTable.filterPlaceholder', + defaultMessage: 'Filter', + }), }, onChange: (search: any) => { this.setState({ @@ -88,6 +93,7 @@ export class PrivilegeSpaceTable extends Component { } public getTableColumns = (role: Role, availablePrivileges: KibanaPrivilege[] = []) => { + const { intl } = this.props; const columns: any[] = [ { field: 'space', @@ -103,11 +109,22 @@ export class PrivilegeSpaceTable extends Component { }, { field: 'space', - name: 'Space', + name: intl.formatMessage({ + id: 'xpack.security.management.editRoles.privilegeSpaceTable.spaceName', + defaultMessage: 'Space', + }), width: this.props.readonly ? '75%' : '50%', render: (space: Space | DeletedSpace) => { if ('deleted' in space) { - return {space.id} (deleted); + return ( + + + + ); } else { return {space.name}; } @@ -115,7 +132,10 @@ export class PrivilegeSpaceTable extends Component { }, { field: 'privilege', - name: 'Privilege', + name: intl.formatMessage({ + id: 'xpack.security.management.editRoles.privilegeSpaceTable.privilegeName', + defaultMessage: 'Privilege', + }), width: this.props.readonly ? '25%' : undefined, render: (privilege: KibanaPrivilege, record: any) => { if (this.props.readonly || record.space.deleted) { @@ -137,7 +157,10 @@ export class PrivilegeSpaceTable extends Component { ]; if (!this.props.readonly) { columns.push({ - name: 'Actions', + name: intl.formatMessage({ + id: 'xpack.security.management.editRoles.privilegeSpaceTable.actionsName', + defaultMessage: 'Actions', + }), actions: [ { render: (record: any) => { @@ -182,3 +205,5 @@ export class PrivilegeSpaceTable extends Component { } }; } + +export const PrivilegeSpaceTable = injectI18n(PrivilegeSpaceTableUI); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_form.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_form.test.tsx index d6ecbdb705b74..00221e2cd144f 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_form.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_form.test.tsx @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mount, shallow } from 'enzyme'; import React from 'react'; +import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { PrivilegeSelector } from './privilege_selector'; import { SimplePrivilegeForm } from './simple_privilege_form'; @@ -32,12 +32,12 @@ const buildProps = (customProps?: any) => { describe('', () => { it('renders without crashing', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallowWithIntl()).toMatchSnapshot(); }); it('displays "none" when no privilege is selected', () => { const props = buildProps(); - const wrapper = shallow(); + const wrapper = shallowWithIntl(); const selector = wrapper.find(PrivilegeSelector); expect(selector.props()).toMatchObject({ value: 'none', @@ -53,7 +53,7 @@ describe('', () => { }, }, }); - const wrapper = shallow(); + const wrapper = shallowWithIntl(); const selector = wrapper.find(PrivilegeSelector); expect(selector.props()).toMatchObject({ value: 'read', @@ -62,7 +62,7 @@ describe('', () => { it('fires its onChange callback when the privilege changes', () => { const props = buildProps(); - const wrapper = mount(); + const wrapper = mountWithIntl(); const selector = wrapper.find(PrivilegeSelector).find('select'); selector.simulate('change', { target: { value: 'all' } }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_form.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_form.tsx index 71b881c4a85ef..ceec0d2124889 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_form.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_form.tsx @@ -9,6 +9,7 @@ import { EuiDescribedFormGroup, EuiFormRow, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../../../common/model/role'; @@ -35,11 +36,28 @@ export class SimplePrivilegeForm extends Component { ? (assignedPrivileges.global[0] as KibanaPrivilege) : NO_PRIVILEGE_VALUE; - const description =

      Specifies the Kibana privilege for this role.

      ; + const description = ( +

      + +

      + ); return ( - Kibana privileges} description={description}> + + + + } + description={description} + > { describe('', () => { it('renders without crashing', () => { - expect(shallow()).toMatchSnapshot(); + expect( + shallowWithIntl() + ).toMatchSnapshot(); }); it('shows the space table if exisitng space privileges are declared', () => { @@ -66,7 +68,7 @@ describe('', () => { }, }); - const wrapper = mount(); + const wrapper = mountWithIntl(); const table = wrapper.find(PrivilegeSpaceTable); expect(table).toHaveLength(1); @@ -75,7 +77,7 @@ describe('', () => { it('hides the space table if there are no existing space privileges', () => { const props = buildProps(); - const wrapper = mount(); + const wrapper = mountWithIntl(); const table = wrapper.find(PrivilegeSpaceTable); expect(table).toMatchSnapshot(); @@ -96,7 +98,7 @@ describe('', () => { }, }); - const wrapper = mount(); + const wrapper = mountWithIntl(); expect(wrapper.find(PrivilegeSpaceForm)).toHaveLength(0); wrapper.find('button[data-test-subj="addSpacePrivilegeButton"]').simulate('click'); @@ -120,7 +122,7 @@ describe('', () => { }, }); - const wrapper = mount(); + const wrapper = mountWithIntl(); const warning = wrapper.find(PrivilegeCalloutWarning); expect(warning.props()).toMatchObject({ @@ -151,7 +153,7 @@ describe('', () => { }, }); - const wrapper = mount(); + const wrapper = mountWithIntl(); const warning = wrapper.find(PrivilegeCalloutWarning); expect(warning.props()).toMatchObject({ @@ -174,7 +176,7 @@ describe('', () => { }, }); - const wrapper = mount(); + const wrapper = mountWithIntl(); const table = wrapper.find(PrivilegeSpaceTable); expect(table).toHaveLength(1); @@ -200,7 +202,7 @@ describe('', () => { }, }); - const wrapper = mount(); + const wrapper = mountWithIntl(); const warning = wrapper.find(PrivilegeCalloutWarning); expect(warning).toHaveLength(0); @@ -221,7 +223,7 @@ describe('', () => { }, }); - const wrapper = mount(); + const wrapper = mountWithIntl(); const table = wrapper.find(PrivilegeSpaceTable); expect(table).toHaveLength(1); @@ -244,7 +246,7 @@ describe('', () => { }, }); - const wrapper = shallow(); + const wrapper = shallowWithIntl(); expect(wrapper).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx index 6928d46565e66..cd4bdb2f41b44 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx @@ -16,6 +16,7 @@ import { EuiText, EuiTitle, } from '@elastic/eui'; +import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; import { Space } from '../../../../../../../../spaces/common/model/space'; import { UserProfile } from '../../../../../../../../xpack_main/public/services/user_profile'; @@ -40,6 +41,7 @@ interface Props { editable: boolean; validator: RoleValidator; userProfile: UserProfile; + intl: InjectedIntl; } interface PrivilegeForm { @@ -56,7 +58,7 @@ interface State { privilegeForms: PrivilegeForm[]; } -export class SpaceAwarePrivilegeForm extends Component { +class SpaceAwarePrivilegeFormUI extends Component { constructor(props: Props) { super(props); const { role } = props; @@ -73,15 +75,44 @@ export class SpaceAwarePrivilegeForm extends Component { } public render() { - const { kibanaAppPrivileges, role, userProfile } = this.props; + const { kibanaAppPrivileges, role, userProfile, intl } = this.props; if (!userProfile.hasCapability('manageSpaces')) { return ( - Insufficient Privileges

      } iconType="alert" color="danger"> -

      You are not authorized to view all available spaces.

      + + +

      + } + iconType="alert" + color="danger" + >

      - Please ensure your account has all privileges granted by the{' '} - kibana_user role, and try again. + +

      +

      + + + + ), + }} + />

      ); @@ -92,21 +123,46 @@ export class SpaceAwarePrivilegeForm extends Component { const basePrivilege = assignedPrivileges.global.length > 0 ? assignedPrivileges.global[0] : NO_PRIVILEGE_VALUE; - const description =

      Specify the minimum actions users can perform in your spaces.

      ; + const description = ( +

      + +

      + ); let helptext; if (basePrivilege === NO_PRIVILEGE_VALUE) { - helptext = 'No access to spaces'; + helptext = intl.formatMessage({ + id: 'xpack.security.management.editRoles.spaceAwarePrivilegeForm.noAccessToSpacesHelpText', + defaultMessage: 'No access to spaces', + }); } else if (basePrivilege === 'all') { - helptext = 'View, edit, and share objects and apps within all spaces'; + helptext = intl.formatMessage({ + id: + 'xpack.security.management.editRoles.spaceAwarePrivilegeForm.viewEditShareAppsWithinAllSpacesHelpText', + defaultMessage: 'View, edit, and share objects and apps within all spaces', + }); } else if (basePrivilege === 'read') { - helptext = 'View objects and apps within all spaces'; + helptext = intl.formatMessage({ + id: + 'xpack.security.management.editRoles.spaceAwarePrivilegeForm.viewObjectsAndAppsWithinAllSpacesHelpText', + defaultMessage: 'View objects and apps within all spaces', + }); } return ( Minimum privileges for all spaces} + title={ +

      + +

      + } description={description} > @@ -147,7 +203,12 @@ export class SpaceAwarePrivilegeForm extends Component { return ( -

      Higher privileges for individual spaces

      +

      + +

      { color={'subdued'} >

      - Grant more privileges on a per space basis. For example, if the privileges are{' '} - read for all spaces, you can set the privileges to all{' '} - for an individual space. + + + + ), + all: ( + + + + ), + }} + />

      @@ -200,7 +282,10 @@ export class SpaceAwarePrivilegeForm extends Component { iconType={'plusInCircle'} onClick={this.addSpacePrivilege} > - Add space privilege +
      )} @@ -367,3 +452,5 @@ export class SpaceAwarePrivilegeForm extends Component { this.props.onChange(role); }; } + +export const SpaceAwarePrivilegeForm = injectI18n(SpaceAwarePrivilegeFormUI); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/reserved_role_badge.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/reserved_role_badge.tsx index 2966c78d2d92a..77f6bc85cf073 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/reserved_role_badge.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/reserved_role_badge.tsx @@ -7,6 +7,7 @@ import React from 'react'; import { EuiIcon, EuiToolTip } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import { Role } from '../../../../../common/model/role'; import { isReservedRole } from '../../../../lib/role'; @@ -19,7 +20,14 @@ export const ReservedRoleBadge = (props: Props) => { if (isReservedRole(role)) { return ( - + + } + > ); diff --git a/x-pack/plugins/security/public/views/management/edit_role/index.js b/x-pack/plugins/security/public/views/management/edit_role/index.js index 4d2e83a6f8072..2377542834ed7 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/index.js +++ b/x-pack/plugins/security/public/views/management/edit_role/index.js @@ -28,6 +28,7 @@ import { EditRolePage } from './components'; import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; import { KibanaAppPrivileges } from '../../../../common/model/kibana_privilege'; +import { I18nProvider } from '@kbn/i18n/react'; routes.when(`${EDIT_ROLES_PATH}/:name?`, { template, @@ -126,20 +127,23 @@ routes.when(`${EDIT_ROLES_PATH}/:name?`, { $scope.$$postDigest(() => { const domNode = document.getElementById('editRoleReactRoot'); - render(, domNode); + render( + + + , domNode); // unmount react on controller destroy $scope.$on('$destroy', () => { diff --git a/x-pack/plugins/security/public/views/management/edit_role/lib/__snapshots__/validate_role.test.ts.snap b/x-pack/plugins/security/public/views/management/edit_role/lib/__snapshots__/validate_role.test.ts.snap index 1f4837b07d0b9..faf1f4704ce0d 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/lib/__snapshots__/validate_role.test.ts.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/lib/__snapshots__/validate_role.test.ts.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`validateIndexPrivileges it throws when indices is not an array 1`] = `"Expected role.elasticsearch.indices to be an array"`; +exports[`validateIndexPrivileges it throws when indices is not an array 1`] = `"Expected \\"role.elasticsearch.indices\\" to be an array"`; diff --git a/x-pack/plugins/security/public/views/management/edit_role/lib/validate_role.ts b/x-pack/plugins/security/public/views/management/edit_role/lib/validate_role.ts index f4ada14fde8ef..133d901b6e166 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/lib/validate_role.ts +++ b/x-pack/plugins/security/public/views/management/edit_role/lib/validate_role.ts @@ -10,6 +10,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { IndexPrivilege } from '../../../../../common/model/index_privilege'; import { KibanaPrivilege } from '../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../common/model/role'; @@ -52,14 +53,34 @@ export class RoleValidator { } if (!role.name) { - return invalid(`Please provide a role name`); + return invalid( + i18n.translate( + 'xpack.security.management.editRoles.validateRole.provideRoleNameWarningMessage', + { + defaultMessage: 'Please provide a role name', + } + ) + ); } if (role.name.length > 1024) { - return invalid(`Name must not exceed 1024 characters`); + return invalid( + i18n.translate( + 'xpack.security.management.editRoles.validateRole.nameLengthWarningMessage', + { + defaultMessage: 'Name must not exceed 1024 characters', + } + ) + ); } if (!role.name.match(/^[a-zA-Z_][a-zA-Z0-9_@\-\$\.]*$/)) { return invalid( - `Name must begin with a letter or underscore and contain only letters, underscores, and numbers.` + i18n.translate( + 'xpack.security.management.editRoles.validateRole.nameAllowedCharactersWarningMessage', + { + defaultMessage: + 'Name must begin with a letter or underscore and contain only letters, underscores, and numbers.', + } + ) ); } return valid(); @@ -71,7 +92,14 @@ export class RoleValidator { } if (!Array.isArray(role.elasticsearch.indices)) { - throw new TypeError(`Expected role.elasticsearch.indices to be an array`); + throw new TypeError( + i18n.translate('xpack.security.management.editRoles.validateRole.indicesTypeErrorMessage', { + defaultMessage: 'Expected {elasticIndices} to be an array', + values: { + elasticIndices: '"role.elasticsearch.indices"', + }, + }) + ); } const areIndicesValid = @@ -91,7 +119,14 @@ export class RoleValidator { } if (indexPrivilege.names.length && !indexPrivilege.privileges.length) { - return invalid(`At least one privilege is required`); + return invalid( + i18n.translate( + 'xpack.security.management.editRoles.validateRole.onePrivilegeRequiredWarningMessage', + { + defaultMessage: 'At least one privilege is required', + } + ) + ); } return valid(); } @@ -112,7 +147,14 @@ export class RoleValidator { if (Array.isArray(spaceIds) && spaceIds.length > 0) { return valid(); } - return invalid('At least one space is required'); + return invalid( + i18n.translate( + 'xpack.security.management.editRoles.validateRole.oneSpaceRequiredWarningMessage', + { + defaultMessage: 'At least one space is required', + } + ) + ); } public validateSelectedPrivilege( @@ -131,7 +173,14 @@ export class RoleValidator { if (privilege) { return valid(); } - return invalid('Privilege is required'); + return invalid( + i18n.translate( + 'xpack.security.management.editRoles.validateRole.privilegeRequiredWarningMessage', + { + defaultMessage: 'Privilege is required', + } + ) + ); } public setInProgressSpacePrivileges(inProgressSpacePrivileges: any[]) { diff --git a/x-pack/plugins/security/public/views/management/management.js b/x-pack/plugins/security/public/views/management/management.js index a193280c1e8c5..7911d3a48bd1c 100644 --- a/x-pack/plugins/security/public/views/management/management.js +++ b/x-pack/plugins/security/public/views/management/management.js @@ -16,6 +16,7 @@ import '../../services/shield_user'; import { ROLES_PATH, USERS_PATH } from './management_urls'; import { management } from 'ui/management'; +import { i18n } from '@kbn/i18n'; routes.defaults(/\/management/, { resolve: { @@ -29,7 +30,10 @@ routes.defaults(/\/management/, { function ensureSecurityRegistered() { const registerSecurity = () => management.register('security', { - display: 'Security', + display: i18n.translate( + 'xpack.security.management.securityTitle', { + defaultMessage: 'Security', + }), order: 10, icon: 'securityApp', }); @@ -41,7 +45,10 @@ routes.defaults(/\/management/, { security.register('users', { name: 'securityUsersLink', order: 10, - display: 'Users', + display: i18n.translate( + 'xpack.security.management.usersTitle', { + defaultMessage: 'Users', + }), url: `#${USERS_PATH}`, }); } @@ -50,7 +57,10 @@ routes.defaults(/\/management/, { security.register('roles', { name: 'securityRolesLink', order: 20, - display: 'Roles', + display: i18n.translate( + 'xpack.security.management.rolesTitle', { + defaultMessage: 'Roles', + }), url: `#${ROLES_PATH}`, }); } diff --git a/x-pack/plugins/security/public/views/management/roles.html b/x-pack/plugins/security/public/views/management/roles.html index 941ab6ed331b2..a7b77228c0376 100644 --- a/x-pack/plugins/security/public/views/management/roles.html +++ b/x-pack/plugins/security/public/views/management/roles.html @@ -3,15 +3,19 @@
      - - You do not have permission to manage roles. - +
      -
      - Please contact your administrator. -
      +
      @@ -30,7 +34,7 @@ aria-label="Filter" ng-model="query" > -
      +
      @@ -42,7 +46,10 @@ > - Delete + @@ -54,7 +61,11 @@ ng-if="!selectedRoles.length" data-test-subj="createRoleButton" > - Create role + +
      @@ -65,8 +76,23 @@
      -
      - No matching roles found. +
      + + +
      @@ -97,7 +123,10 @@ aria-label="{{sort.reverse ? 'Sort role ascending' : 'Sort role descending'}}" > - Role +
@@ -151,9 +184,13 @@ class="kuiBadge kuiBadge--default" tooltip="This role is currently disabled. You may only view or delete it." aria-label="This role is currently disabled. You may only view or delete it." + i18n-id="xpack.security.management.roles.disableTitle" + i18n-default-message="{icon} Disabled" + i18n-values="{ + icon: '' + }" > - Disabled @@ -175,9 +212,13 @@
-
- {{ selectedRoles.length }} roles selected -
+
diff --git a/x-pack/plugins/security/public/views/management/roles.js b/x-pack/plugins/security/public/views/management/roles.js index c60b9905ea68f..98e08af55ea96 100644 --- a/x-pack/plugins/security/public/views/management/roles.js +++ b/x-pack/plugins/security/public/views/management/roles.js @@ -19,25 +19,34 @@ routes.when(ROLES_PATH, { resolve: { roles(ShieldRole, kbnUrl, Promise, Private) { // $promise is used here because the result is an ngResource, not a promise itself - return ShieldRole.query().$promise - .catch(checkLicenseError(kbnUrl, Promise, Private)) + return ShieldRole.query() + .$promise.catch(checkLicenseError(kbnUrl, Promise, Private)) .catch(_.identity); // Return the error if there is one - } + }, }, - controller($scope, $route, $q, confirmModal) { + controller($scope, $route, $q, confirmModal, i18n) { $scope.roles = $route.current.locals.roles; $scope.forbidden = !_.isArray($scope.roles); $scope.selectedRoles = []; $scope.sort = { orderBy: 'name', reverse: false }; $scope.editRolesHref = `#${EDIT_ROLES_PATH}`; - $scope.getEditRoleHref = (role) => `#${EDIT_ROLES_PATH}/${role}`; + $scope.getEditRoleHref = role => `#${EDIT_ROLES_PATH}/${role}`; $scope.deleteRoles = () => { const doDelete = () => { - $q.all($scope.selectedRoles.map((role) => role.$delete())) - .then(() => toastNotifications.addSuccess(`Deleted ${$scope.selectedRoles.length > 1 ? 'roles' : 'role'}`)) + $q.all($scope.selectedRoles.map(role => role.$delete())) + .then(() => + toastNotifications.addSuccess( + i18n('xpack.security.management.roles.deleteRoleTitle', { + defaultMessage: 'Deleted {value, plural, one {role} other {roles}}', + values: { + value: $scope.selectedRoles.length, + }, + }) + ) + ) .then(() => { - $scope.selectedRoles.map((role) => { + $scope.selectedRoles.map(role => { const i = $scope.roles.indexOf(role); $scope.roles.splice(i, 1); }); @@ -45,12 +54,17 @@ routes.when(ROLES_PATH, { }); }; const confirmModalOptions = { - confirmButtonText: 'Delete role(s)', - onConfirm: doDelete + confirmButtonText: i18n('xpack.security.management.roles.deleteRoleConfirmButtonLabel', { + defaultMessage: 'Delete role(s)', + }), + onConfirm: doDelete, }; - confirmModal(` - Are you sure you want to delete the selected role(s)? This action is irreversible!`, - confirmModalOptions + confirmModal( + i18n('xpack.security.management.roles.deletingRolesWarningMessage', { + defaultMessage: + 'Are you sure you want to delete the selected role(s)? This action is irreversible!', + }), + confirmModalOptions ); }; @@ -83,7 +97,16 @@ routes.when(ROLES_PATH, { $scope.toggleSort = toggleSort; function getActionableRoles() { - return $scope.roles.filter((role) => !role.metadata._reserved); + return $scope.roles.filter(role => !role.metadata._reserved); } - } + + $scope.reversedTooltip = i18n('xpack.security.management.roles.reversedTooltip', { + defaultMessage: 'Reserved roles are built-in and cannot be removed or modified. Only the password may be changed.', + }); + + $scope.reversedAriaLabel = i18n('xpack.security.management.roles.reversedAriaLabel', { + defaultMessage: 'Reserved roles are built-in and cannot be removed or modified. Only the password may be changed.', + }); + + }, }); From 0d310d3353df05bf749acb7828452b05c41ffe5c Mon Sep 17 00:00:00 2001 From: Maryia Lapata Date: Tue, 20 Nov 2018 11:51:17 +0300 Subject: [PATCH 27/95] [Tools] Exclude ts type files from i18n_check (#25799) --- src/dev/i18n/extract_default_translations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/i18n/extract_default_translations.js b/src/dev/i18n/extract_default_translations.js index 275e051ff8ca5..9860e53109304 100644 --- a/src/dev/i18n/extract_default_translations.js +++ b/src/dev/i18n/extract_default_translations.js @@ -93,7 +93,7 @@ export async function extractMessagesFromPathToMap(inputPath, targetMap) { const entries = await globAsync('*.{js,jsx,pug,ts,tsx,html,hbs,handlebars}', { cwd: inputPath, matchBase: true, - ignore: ['**/node_modules/**', '**/__tests__/**', '**/*.test.{js,jsx,ts,tsx}'], + ignore: ['**/node_modules/**', '**/__tests__/**', '**/*.test.{js,jsx,ts,tsx}', '**/*.d.ts'], }); const { htmlEntries, codeEntries, pugEntries, hbsEntries } = entries.reduce( From 43b1d00128c91e5f40d0336558f2ab7472f2f46a Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Tue, 20 Nov 2018 09:56:50 +0100 Subject: [PATCH 28/95] move canvas interpreter to OSS (#25711) --- .eslintignore | 3 +- package.json | 3 +- packages/kbn-interpreter/.babelrc | 3 + .../common/interpreter/cast.js | 22 +++- .../common/interpreter/create_error.js | 26 +++++ .../common/interpreter/interpret.js | 25 ++++- .../common/interpreter/socket_interpret.js | 22 +++- packages/kbn-interpreter/common/lib/arg.js | 37 +++++++ .../kbn-interpreter/common/lib/arg.test.js | 35 ++++++ .../common/lib/ast.from_expression.test.js | 60 ++++++----- .../kbn-interpreter}/common/lib/ast.js | 24 ++++- .../common/lib/ast.to_expression.test.js | 85 +++++++++------ .../kbn-interpreter}/common/lib/fn.js | 19 +++- .../common/lib/functions_registry.js | 29 +++++ .../common/lib/get_by_alias.js | 33 ++++++ .../common/lib/get_by_alias.test.js | 86 +++++++++++++++ .../kbn-interpreter/common/lib/get_type.js | 28 +++++ .../kbn-interpreter}/common/lib/grammar.js | 0 .../kbn-interpreter}/common/lib/grammar.peg | 0 .../common/lib/paths_registry.js | 65 ++++++++++++ .../common/lib/paths_registry.test.js | 92 ++++++++++++++++ .../kbn-interpreter}/common/lib/registry.js | 22 +++- .../common/lib/registry.test.js | 71 +++++++------ .../kbn-interpreter/common/lib/serialize.js | 37 +++++++ .../kbn-interpreter}/common/lib/type.js | 27 +++-- .../common/lib/types_registry.js | 29 +++++ packages/kbn-interpreter/package.json | 10 ++ .../plugin_src/functions/common/clog.js | 27 +++++ .../plugin_src/functions/common/index.js | 24 +++++ .../plugin_src/functions/common/register.js | 23 ++++ .../plugin_src/types/boolean.js | 42 ++++++++ .../plugin_src}/types/datatable.js | 22 +++- .../kbn-interpreter/plugin_src/types/error.js | 35 ++++++ .../plugin_src/types/filter.js | 33 ++++++ .../kbn-interpreter/plugin_src/types/image.js | 31 ++++++ .../kbn-interpreter/plugin_src/types/index.js | 46 ++++++++ .../kbn-interpreter/plugin_src/types/null.js | 25 +++++ .../plugin_src/types/number.js | 42 ++++++++ .../plugin_src/types/pointseries.js | 44 ++++++++ .../plugin_src/types/register.js | 24 +++++ .../plugin_src/types/render.js | 29 +++++ .../kbn-interpreter/plugin_src/types/shape.js | 31 ++++++ .../plugin_src/types/string.js | 41 +++++++ .../kbn-interpreter/plugin_src/types/style.js | 31 ++++++ .../public/browser_registries.js | 83 +++++++++++++++ .../kbn-interpreter/public/create_handlers.js | 24 +++++ .../kbn-interpreter/public}/interpreter.js | 29 +++-- .../kbn-interpreter}/public/socket.js | 21 +++- .../server/get_plugin_paths.js | 55 ++++++++++ .../server/server_registries.js | 78 ++++++++++++++ packages/kbn-interpreter/tasks/build.js | 40 +++++++ .../kbn-interpreter/tasks/webpack.plugins.js | 100 ++++++++++++++++++ .../interpreter/common/constants.js | 21 ++++ src/core_plugins/interpreter/index.js | 41 +++++++ src/core_plugins/interpreter/init.js | 41 +++++++ src/core_plugins/interpreter/package.json | 4 + src/core_plugins/interpreter/plugin_paths.js | 27 +++++ .../public/load_browser_plugins.js | 30 ++++++ .../server/lib/__tests__/create_handlers.js | 21 +++- .../server/lib/create_handlers.js | 24 ++++- .../interpreter/server/lib/feature_check.js | 26 +++++ .../server/lib/get_plugin_stream.js | 37 +++++++ .../interpreter/server/lib/get_request.js | 44 ++++++++ .../server/lib/route_expression/browser.js | 19 +++- .../server/lib/route_expression/index.js | 22 +++- .../server/lib/route_expression/server.js | 40 +++++++ .../lib/route_expression/thread/babeled.js | 32 ++++++ .../lib/route_expression/thread/index.js | 19 +++- .../lib/route_expression/thread/polyfill.js | 31 ++++++ .../lib/route_expression/thread/worker.js | 28 +++-- .../interpreter/server/routes/index.js | 28 +++++ .../interpreter/server/routes/plugins.js | 35 ++++++ .../interpreter}/server/routes/socket.js | 31 ++++-- .../interpreter/server/routes/translate.js | 48 +++++++++ src/optimize/base_optimizer.js | 5 +- src/setup_node_env/babel_register/register.js | 2 +- .../create_or_upgrade_integration.js | 2 +- x-pack/package.json | 1 + .../__tests__/fixtures/function_specs.js | 2 +- .../canvas_plugin_src/functions/common/as.js | 2 +- .../functions/common/clog.js | 14 --- .../functions/common/index.js | 2 - .../functions/common/mapColumn.js | 2 +- .../common/plot/get_flot_axis_config.js | 2 +- .../functions/common/staticColumn.js | 2 +- .../renderers/dropdown_filter/index.js | 2 +- .../components/time_filter/time_filter.js | 2 +- .../renderers/time_filter/index.js | 2 +- .../canvas/canvas_plugin_src/types/boolean.js | 29 ----- .../canvas/canvas_plugin_src/types/error.js | 22 ---- .../canvas/canvas_plugin_src/types/filter.js | 20 ---- .../canvas/canvas_plugin_src/types/image.js | 18 ---- .../canvas/canvas_plugin_src/types/index.js | 33 ------ .../canvas/canvas_plugin_src/types/null.js | 12 --- .../canvas/canvas_plugin_src/types/number.js | 29 ----- .../canvas_plugin_src/types/pointseries.js | 31 ------ .../canvas_plugin_src/types/register.js | 10 -- .../canvas/canvas_plugin_src/types/render.js | 16 --- .../canvas/canvas_plugin_src/types/shape.js | 18 ---- .../canvas/canvas_plugin_src/types/string.js | 28 ----- .../canvas/canvas_plugin_src/types/style.js | 18 ---- .../uis/arguments/datacolumn/index.js | 2 +- .../uis/arguments/palette.js | 2 +- x-pack/plugins/canvas/common/functions/to.js | 2 +- .../canvas/common/interpreter/create_error.js | 13 --- .../canvas/common/lib/__tests__/arg.js | 23 ---- .../common/lib/__tests__/get_by_alias.js | 74 ------------- x-pack/plugins/canvas/common/lib/arg.js | 24 ----- .../plugins/canvas/common/lib/autocomplete.js | 4 +- .../canvas/common/lib/functions_registry.js | 16 --- .../plugins/canvas/common/lib/get_by_alias.js | 20 ---- x-pack/plugins/canvas/common/lib/get_type.js | 15 --- x-pack/plugins/canvas/common/lib/index.js | 11 -- x-pack/plugins/canvas/common/lib/serialize.js | 24 ----- .../canvas/common/lib/types_registry.js | 16 --- x-pack/plugins/canvas/index.js | 5 + x-pack/plugins/canvas/init.js | 6 +- x-pack/plugins/canvas/plugin_paths.js | 21 ++++ .../canvas/public/components/app/index.js | 31 +++++- .../components/arg_form/advanced_failure.js | 2 +- .../datasource/datasource_preview/index.js | 2 +- .../element_content/element_content.js | 2 +- .../public/components/expression/index.js | 2 +- .../components/function_form_list/index.js | 4 +- .../public/expression_types/arg_type.js | 2 +- .../public/expression_types/datasource.js | 2 +- .../public/expression_types/function_form.js | 2 +- .../canvas/public/expression_types/model.js | 2 +- .../public/expression_types/transform.js | 2 +- .../canvas/public/expression_types/view.js | 2 +- .../canvas/public/functions/filters.js | 6 +- .../plugins/canvas/public/lib/arg_helpers.js | 2 +- .../canvas/public/lib/browser_registries.js | 74 ------------- .../canvas/public/lib/create_handlers.js | 11 -- .../canvas/public/lib/elements_registry.js | 2 +- .../canvas/public/lib/function_definitions.js | 2 +- .../canvas/public/lib/functions_registry.js | 2 +- .../public/lib/parse_single_function_chain.js | 2 +- .../public/lib/render_functions_registry.js | 2 +- .../canvas/public/lib/run_interpreter.js | 6 +- .../canvas/public/lib/transitions_registry.js | 2 +- .../canvas/public/lib/types_registry.js | 2 +- .../canvas/public/state/actions/elements.js | 4 +- .../canvas/public/state/selectors/workpad.js | 2 +- .../canvas/server/lib/feature_check.js | 13 --- .../canvas/server/lib/get_plugin_paths.js | 83 --------------- .../canvas/server/lib/get_plugin_stream.js | 24 ----- .../plugins/canvas/server/lib/get_request.js | 30 ------ .../plugins/canvas/server/lib/plugin_paths.js | 20 ---- .../server/lib/route_expression/server.js | 27 ----- .../lib/route_expression/thread/babeled.js | 19 ---- .../lib/route_expression/thread/polyfill.js | 18 ---- .../canvas/server/lib/server_registries.js | 55 ---------- x-pack/plugins/canvas/server/routes/index.js | 6 -- .../plugins/canvas/server/routes/plugins.js | 25 ----- .../plugins/canvas/server/routes/translate.js | 34 ------ .../plugins/canvas/server/usage/collector.js | 2 +- .../canvas/tasks/helpers/webpack.plugins.js | 1 - 158 files changed, 2455 insertions(+), 1202 deletions(-) create mode 100644 packages/kbn-interpreter/.babelrc rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/interpreter/cast.js (53%) create mode 100644 packages/kbn-interpreter/common/interpreter/create_error.js rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/interpreter/interpret.js (88%) rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/interpreter/socket_interpret.js (72%) create mode 100644 packages/kbn-interpreter/common/lib/arg.js create mode 100644 packages/kbn-interpreter/common/lib/arg.test.js rename x-pack/plugins/canvas/common/lib/__tests__/ast.from_expression.js => packages/kbn-interpreter/common/lib/ast.from_expression.test.js (59%) rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/lib/ast.js (81%) rename x-pack/plugins/canvas/common/lib/__tests__/ast.to_expression.js => packages/kbn-interpreter/common/lib/ast.to_expression.test.js (83%) rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/lib/fn.js (54%) create mode 100644 packages/kbn-interpreter/common/lib/functions_registry.js create mode 100644 packages/kbn-interpreter/common/lib/get_by_alias.js create mode 100644 packages/kbn-interpreter/common/lib/get_by_alias.test.js create mode 100644 packages/kbn-interpreter/common/lib/get_type.js rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/lib/grammar.js (100%) rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/lib/grammar.peg (100%) create mode 100644 packages/kbn-interpreter/common/lib/paths_registry.js create mode 100644 packages/kbn-interpreter/common/lib/paths_registry.test.js rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/lib/registry.js (56%) rename x-pack/plugins/canvas/common/lib/__tests__/registry.js => packages/kbn-interpreter/common/lib/registry.test.js (60%) create mode 100644 packages/kbn-interpreter/common/lib/serialize.js rename {x-pack/plugins/canvas => packages/kbn-interpreter}/common/lib/type.js (61%) create mode 100644 packages/kbn-interpreter/common/lib/types_registry.js create mode 100644 packages/kbn-interpreter/package.json create mode 100644 packages/kbn-interpreter/plugin_src/functions/common/clog.js create mode 100644 packages/kbn-interpreter/plugin_src/functions/common/index.js create mode 100644 packages/kbn-interpreter/plugin_src/functions/common/register.js create mode 100644 packages/kbn-interpreter/plugin_src/types/boolean.js rename {x-pack/plugins/canvas/canvas_plugin_src => packages/kbn-interpreter/plugin_src}/types/datatable.js (63%) create mode 100644 packages/kbn-interpreter/plugin_src/types/error.js create mode 100644 packages/kbn-interpreter/plugin_src/types/filter.js create mode 100644 packages/kbn-interpreter/plugin_src/types/image.js create mode 100644 packages/kbn-interpreter/plugin_src/types/index.js create mode 100644 packages/kbn-interpreter/plugin_src/types/null.js create mode 100644 packages/kbn-interpreter/plugin_src/types/number.js create mode 100644 packages/kbn-interpreter/plugin_src/types/pointseries.js create mode 100644 packages/kbn-interpreter/plugin_src/types/register.js create mode 100644 packages/kbn-interpreter/plugin_src/types/render.js create mode 100644 packages/kbn-interpreter/plugin_src/types/shape.js create mode 100644 packages/kbn-interpreter/plugin_src/types/string.js create mode 100644 packages/kbn-interpreter/plugin_src/types/style.js create mode 100644 packages/kbn-interpreter/public/browser_registries.js create mode 100644 packages/kbn-interpreter/public/create_handlers.js rename {x-pack/plugins/canvas/public/lib => packages/kbn-interpreter/public}/interpreter.js (55%) rename {x-pack/plugins/canvas => packages/kbn-interpreter}/public/socket.js (64%) create mode 100644 packages/kbn-interpreter/server/get_plugin_paths.js create mode 100644 packages/kbn-interpreter/server/server_registries.js create mode 100644 packages/kbn-interpreter/tasks/build.js create mode 100644 packages/kbn-interpreter/tasks/webpack.plugins.js create mode 100644 src/core_plugins/interpreter/common/constants.js create mode 100644 src/core_plugins/interpreter/index.js create mode 100644 src/core_plugins/interpreter/init.js create mode 100644 src/core_plugins/interpreter/package.json create mode 100644 src/core_plugins/interpreter/plugin_paths.js create mode 100644 src/core_plugins/interpreter/public/load_browser_plugins.js rename {x-pack/plugins/canvas => src/core_plugins/interpreter}/server/lib/__tests__/create_handlers.js (83%) rename {x-pack/plugins/canvas => src/core_plugins/interpreter}/server/lib/create_handlers.js (58%) create mode 100644 src/core_plugins/interpreter/server/lib/feature_check.js create mode 100644 src/core_plugins/interpreter/server/lib/get_plugin_stream.js create mode 100644 src/core_plugins/interpreter/server/lib/get_request.js rename {x-pack/plugins/canvas => src/core_plugins/interpreter}/server/lib/route_expression/browser.js (65%) rename {x-pack/plugins/canvas => src/core_plugins/interpreter}/server/lib/route_expression/index.js (51%) create mode 100644 src/core_plugins/interpreter/server/lib/route_expression/server.js create mode 100644 src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js rename {x-pack/plugins/canvas => src/core_plugins/interpreter}/server/lib/route_expression/thread/index.js (78%) create mode 100644 src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js rename {x-pack/plugins/canvas => src/core_plugins/interpreter}/server/lib/route_expression/thread/worker.js (62%) create mode 100644 src/core_plugins/interpreter/server/routes/index.js create mode 100644 src/core_plugins/interpreter/server/routes/plugins.js rename {x-pack/plugins/canvas => src/core_plugins/interpreter}/server/routes/socket.js (68%) create mode 100644 src/core_plugins/interpreter/server/routes/translate.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/functions/common/clog.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/boolean.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/error.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/filter.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/image.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/index.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/null.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/number.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/pointseries.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/register.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/render.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/shape.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/string.js delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/style.js delete mode 100644 x-pack/plugins/canvas/common/interpreter/create_error.js delete mode 100644 x-pack/plugins/canvas/common/lib/__tests__/arg.js delete mode 100644 x-pack/plugins/canvas/common/lib/__tests__/get_by_alias.js delete mode 100644 x-pack/plugins/canvas/common/lib/arg.js delete mode 100644 x-pack/plugins/canvas/common/lib/functions_registry.js delete mode 100644 x-pack/plugins/canvas/common/lib/get_by_alias.js delete mode 100644 x-pack/plugins/canvas/common/lib/get_type.js delete mode 100644 x-pack/plugins/canvas/common/lib/serialize.js delete mode 100644 x-pack/plugins/canvas/common/lib/types_registry.js create mode 100644 x-pack/plugins/canvas/plugin_paths.js delete mode 100644 x-pack/plugins/canvas/public/lib/browser_registries.js delete mode 100644 x-pack/plugins/canvas/public/lib/create_handlers.js delete mode 100644 x-pack/plugins/canvas/server/lib/feature_check.js delete mode 100644 x-pack/plugins/canvas/server/lib/get_plugin_paths.js delete mode 100644 x-pack/plugins/canvas/server/lib/get_plugin_stream.js delete mode 100644 x-pack/plugins/canvas/server/lib/get_request.js delete mode 100644 x-pack/plugins/canvas/server/lib/plugin_paths.js delete mode 100644 x-pack/plugins/canvas/server/lib/route_expression/server.js delete mode 100644 x-pack/plugins/canvas/server/lib/route_expression/thread/babeled.js delete mode 100644 x-pack/plugins/canvas/server/lib/route_expression/thread/polyfill.js delete mode 100644 x-pack/plugins/canvas/server/lib/server_registries.js delete mode 100644 x-pack/plugins/canvas/server/routes/plugins.js delete mode 100644 x-pack/plugins/canvas/server/routes/translate.js diff --git a/.eslintignore b/.eslintignore index f697ad004caab..50901af5b9eea 100644 --- a/.eslintignore +++ b/.eslintignore @@ -27,7 +27,8 @@ bower_components /x-pack/coverage /x-pack/build /x-pack/plugins/**/__tests__/fixtures/** -/x-pack/plugins/canvas/common/lib/grammar.js +/packages/kbn-interpreter/common/lib/grammar.js +/packages/kbn-interpreter/plugin /x-pack/plugins/canvas/canvas_plugin /x-pack/plugins/canvas/canvas_plugin_src/lib/flot-charts **/*.js.snap diff --git a/package.json b/package.json index b0555fad091e1..d4f63df304f9a 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "@kbn/pm": "1.0.0", "@kbn/test-subj-selector": "0.2.1", "@kbn/ui-framework": "1.0.0", + "@kbn/interpreter": "1.0.0", "JSONStream": "1.1.1", "abortcontroller-polyfill": "^1.1.9", "angular": "1.6.9", @@ -383,4 +384,4 @@ "node": "8.11.4", "yarn": "^1.10.1" } -} \ No newline at end of file +} diff --git a/packages/kbn-interpreter/.babelrc b/packages/kbn-interpreter/.babelrc new file mode 100644 index 0000000000000..dc6a77bbe0bcd --- /dev/null +++ b/packages/kbn-interpreter/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["@kbn/babel-preset/webpack_preset"] +} diff --git a/x-pack/plugins/canvas/common/interpreter/cast.js b/packages/kbn-interpreter/common/interpreter/cast.js similarity index 53% rename from x-pack/plugins/canvas/common/interpreter/cast.js rename to packages/kbn-interpreter/common/interpreter/cast.js index 7e559afcba40e..cc257a7dc55e0 100644 --- a/x-pack/plugins/canvas/common/interpreter/cast.js +++ b/packages/kbn-interpreter/common/interpreter/cast.js @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 { getType } from '../lib/get_type'; @@ -19,8 +32,9 @@ export function castProvider(types) { for (let i = 0; i < toTypeNames.length; i++) { // First check if the current type can cast to this type - if (fromTypeDef && fromTypeDef.castsTo(toTypeNames[i])) + if (fromTypeDef && fromTypeDef.castsTo(toTypeNames[i])) { return fromTypeDef.to(node, toTypeNames[i], types); + } // If that isn't possible, check if this type can cast from the current type const toTypeDef = types[toTypeNames[i]]; diff --git a/packages/kbn-interpreter/common/interpreter/create_error.js b/packages/kbn-interpreter/common/interpreter/create_error.js new file mode 100644 index 0000000000000..2740358b1c960 --- /dev/null +++ b/packages/kbn-interpreter/common/interpreter/create_error.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export const createError = err => ({ + type: 'error', + error: { + stack: process.env.NODE_ENV === 'production' ? undefined : err.stack, + message: typeof err === 'string' ? err : err.message, + }, +}); diff --git a/x-pack/plugins/canvas/common/interpreter/interpret.js b/packages/kbn-interpreter/common/interpreter/interpret.js similarity index 88% rename from x-pack/plugins/canvas/common/interpreter/interpret.js rename to packages/kbn-interpreter/common/interpreter/interpret.js index ff7a2547f236f..d2a786cd3c85d 100644 --- a/x-pack/plugins/canvas/common/interpreter/interpret.js +++ b/packages/kbn-interpreter/common/interpreter/interpret.js @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 clone from 'lodash.clone'; @@ -112,8 +125,9 @@ export function interpretProvider(config) { (argAsts, argAst, argName) => { const argDef = getByAlias(argDefs, argName); // TODO: Implement a system to allow for undeclared arguments - if (!argDef) + if (!argDef) { throw new Error(`Unknown argument '${argName}' passed to function '${fnDef.name}'`); + } argAsts[argDef.name] = (argAsts[argDef.name] || []).concat(argAst); return argAsts; @@ -142,8 +156,9 @@ export function interpretProvider(config) { const argAstsWithDefaults = reduce( argDefs, (argAsts, argDef, argName) => { - if (typeof argAsts[argName] === 'undefined' && typeof argDef.default !== 'undefined') + if (typeof argAsts[argName] === 'undefined' && typeof argDef.default !== 'undefined') { argAsts[argName] = [fromExpression(argDef.default, 'argument')]; + } return argAsts; }, diff --git a/x-pack/plugins/canvas/common/interpreter/socket_interpret.js b/packages/kbn-interpreter/common/interpreter/socket_interpret.js similarity index 72% rename from x-pack/plugins/canvas/common/interpreter/socket_interpret.js rename to packages/kbn-interpreter/common/interpreter/socket_interpret.js index c8d5acf4fdd52..1ea95e0f5f6f1 100644 --- a/x-pack/plugins/canvas/common/interpreter/socket_interpret.js +++ b/packages/kbn-interpreter/common/interpreter/socket_interpret.js @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 uuid from 'uuid/v4'; @@ -40,8 +53,9 @@ export function socketInterpreterProvider({ // Get the list of functions that are known elsewhere return Promise.resolve(referableFunctions).then(referableFunctionMap => { // Check if the not-found function is in the list of alternatives, if not, throw - if (!getByAlias(referableFunctionMap, functionName)) + if (!getByAlias(referableFunctionMap, functionName)) { throw new Error(`Function not found: ${functionName}`); + } // set a unique message ID so the code knows what response to process const id = uuid(); diff --git a/packages/kbn-interpreter/common/lib/arg.js b/packages/kbn-interpreter/common/lib/arg.js new file mode 100644 index 0000000000000..0aa2b52e35acb --- /dev/null +++ b/packages/kbn-interpreter/common/lib/arg.js @@ -0,0 +1,37 @@ +/* + * 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 { includes } from 'lodash'; + +export function Arg(config) { + if (config.name === '_') throw Error('Arg names must not be _. Use it in aliases instead.'); + this.name = config.name; + this.required = config.required || false; + this.help = config.help || ''; + this.types = config.types || []; + this.default = config.default; + this.aliases = config.aliases || []; + this.multi = config.multi == null ? false : config.multi; + this.resolve = config.resolve == null ? true : config.resolve; + this.options = config.options || []; + this.accepts = type => { + if (!this.types.length) return true; + return includes(config.types, type); + }; +} diff --git a/packages/kbn-interpreter/common/lib/arg.test.js b/packages/kbn-interpreter/common/lib/arg.test.js new file mode 100644 index 0000000000000..2edd65cd4af49 --- /dev/null +++ b/packages/kbn-interpreter/common/lib/arg.test.js @@ -0,0 +1,35 @@ +/* + * 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 { Arg } from './arg'; + +describe('Arg', () => { + it('sets required to false by default', () => { + const isOptional = new Arg({ + name: 'optional_me', + }); + expect(isOptional.required).toBe(false); + + const isRequired = new Arg({ + name: 'require_me', + required: true, + }); + expect(isRequired.required).toBe(true); + }); +}); diff --git a/x-pack/plugins/canvas/common/lib/__tests__/ast.from_expression.js b/packages/kbn-interpreter/common/lib/ast.from_expression.test.js similarity index 59% rename from x-pack/plugins/canvas/common/lib/__tests__/ast.from_expression.js rename to packages/kbn-interpreter/common/lib/ast.from_expression.test.js index 631973247dc6c..c144770f94c54 100644 --- a/x-pack/plugins/canvas/common/lib/__tests__/ast.from_expression.js +++ b/packages/kbn-interpreter/common/lib/ast.from_expression.test.js @@ -1,35 +1,47 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 expect from 'expect.js'; -import { fromExpression } from '../ast'; -import { getType } from '../../lib/get_type'; +import { fromExpression } from './ast'; +import { getType } from './get_type'; describe('ast fromExpression', () => { describe('invalid expression', () => { it('throws when empty', () => { const check = () => fromExpression(''); - expect(check).to.throwException(/Unable to parse expression/i); + expect(check).toThrowError(/Unable to parse expression/i); }); it('throws with invalid expression', () => { const check = () => fromExpression('wat!'); - expect(check).to.throwException(/Unable to parse expression/i); + expect(check).toThrowError(/Unable to parse expression/i); }); }); describe('single item expression', () => { it('is a chain', () => { const expression = 'whatever'; - expect(fromExpression(expression)).to.have.property('chain'); + expect(fromExpression(expression)).toHaveProperty('chain'); }); it('is a value', () => { const expression = '"hello"'; - expect(fromExpression(expression, 'argument')).to.equal('hello'); + expect(fromExpression(expression, 'argument')).toBe('hello'); }); describe('function without arguments', () => { @@ -44,15 +56,15 @@ describe('ast fromExpression', () => { }); it('is a function ', () => { - expect(getType(block)).to.equal('function'); + expect(getType(block)).toBe('function'); }); it('is csv function', () => { - expect(block.function).to.equal('csv'); + expect(block.function).toBe('csv'); }); it('has no arguments', () => { - expect(block.arguments).to.eql({}); + expect(block.arguments).toEqual({}); }); }); @@ -68,17 +80,17 @@ describe('ast fromExpression', () => { }); it('has arguemnts properties', () => { - expect(block.arguments).not.to.eql({}); + expect(block.arguments).not.toEqual({}); }); it('has index argument with string value', () => { - expect(block.arguments).to.have.property('index'); - expect(block.arguments.index).to.eql(['logstash-*']); + expect(block.arguments).toHaveProperty('index'); + expect(block.arguments.index).toEqual(['logstash-*']); }); it('has oranges argument with string value', () => { - expect(block.arguments).to.have.property('oranges'); - expect(block.arguments.oranges).to.eql(['bananas']); + expect(block.arguments).toHaveProperty('oranges'); + expect(block.arguments.oranges).toEqual(['bananas']); }); }); @@ -94,12 +106,12 @@ describe('ast fromExpression', () => { }); it('is expression type', () => { - expect(block.arguments).to.have.property('exampleFunction'); - expect(block.arguments.exampleFunction[0]).to.have.property('type', 'expression'); + expect(block.arguments).toHaveProperty('exampleFunction'); + expect(block.arguments.exampleFunction[0]).toHaveProperty('type'); }); it('has expected shape', () => { - expect(block.arguments.exampleFunction).to.eql([ + expect(block.arguments.exampleFunction).toEqual([ { type: 'expression', chain: [ @@ -128,12 +140,12 @@ describe('ast fromExpression', () => { }); it('is expression type', () => { - expect(block.arguments).to.have.property('examplePartial'); - expect(block.arguments.examplePartial[0]).to.have.property('type', 'expression'); + expect(block.arguments).toHaveProperty('examplePartial'); + expect(block.arguments.examplePartial[0]).toHaveProperty('type'); }); it('has expected shape', () => { - expect(block.arguments.examplePartial).to.eql([ + expect(block.arguments.examplePartial).toEqual([ { type: 'expression', chain: [ diff --git a/x-pack/plugins/canvas/common/lib/ast.js b/packages/kbn-interpreter/common/lib/ast.js similarity index 81% rename from x-pack/plugins/canvas/common/lib/ast.js rename to packages/kbn-interpreter/common/lib/ast.js index b31848944e9db..61cfe94ac955c 100644 --- a/x-pack/plugins/canvas/common/lib/ast.js +++ b/packages/kbn-interpreter/common/lib/ast.js @@ -1,10 +1,23 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 { getType } from '../lib/get_type'; +import { getType } from './get_type'; import { parse } from './grammar'; function getArgumentString(arg, argKey, level = 0) { @@ -48,8 +61,9 @@ function getExpressionArgs(block, level = 0) { const lineLength = acc.split('\n').pop().length; // if arg values are too long, move it to the next line - if (level === 0 && lineLength + argString.length > MAX_LINE_LENGTH) + if (level === 0 && lineLength + argString.length > MAX_LINE_LENGTH) { return `${acc}\n ${argString}`; + } // append arg values to existing arg values if (lineLength > 0) return `${acc} ${argString}`; diff --git a/x-pack/plugins/canvas/common/lib/__tests__/ast.to_expression.js b/packages/kbn-interpreter/common/lib/ast.to_expression.test.js similarity index 83% rename from x-pack/plugins/canvas/common/lib/__tests__/ast.to_expression.js rename to packages/kbn-interpreter/common/lib/ast.to_expression.test.js index 4b5985832e6ab..455b12f583f30 100644 --- a/x-pack/plugins/canvas/common/lib/__tests__/ast.to_expression.js +++ b/packages/kbn-interpreter/common/lib/ast.to_expression.test.js @@ -1,18 +1,39 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 expect from 'expect.js'; -import { toExpression } from '../ast'; +import { toExpression } from './ast'; describe('ast toExpression', () => { describe('single expression', () => { + it('throws if no type included', () => { + const errMsg = 'Objects must have a type property'; + const astObject = { hello: 'world' }; + expect(() => toExpression(astObject)).toThrowError(errMsg); + }); + it('throws if not correct type', () => { const errMsg = 'Expression must be an expression or argument function'; - const astObject = { hello: 'world' }; - expect(() => toExpression(astObject)).to.throwException(errMsg); + const astObject = { + type: 'hi', + hello: 'world', + }; + expect(() => toExpression(astObject)).toThrowError(errMsg); }); it('throws if expression without chain', () => { @@ -21,7 +42,7 @@ describe('ast toExpression', () => { type: 'expression', hello: 'world', }; - expect(() => toExpression(astObject)).to.throwException(errMsg); + expect(() => toExpression(astObject)).toThrowError(errMsg); }); it('throws if arguments type is invalid', () => { @@ -29,7 +50,7 @@ describe('ast toExpression', () => { const invalidTypes = [null, []]; function validate(obj) { - expect(() => toExpression(obj)).to.throwException(errMsg); + expect(() => toExpression(obj)).toThrowError(errMsg); } for (let i = 0; i < invalidTypes.length; i++) { @@ -56,12 +77,12 @@ describe('ast toExpression', () => { function: 'pointseries', arguments: null, }; - expect(() => toExpression(astObject)).to.throwException(errMsg); + expect(() => toExpression(astObject)).toThrowError(errMsg); }); it('throws on invalid argument type', () => { const argType = '__invalid__wat__'; - const errMsg = `invalid argument type: ${argType}`; + const errMsg = `Invalid argument type in AST: ${argType}`; const astObject = { type: 'expression', chain: [ @@ -80,7 +101,7 @@ describe('ast toExpression', () => { ], }; - expect(() => toExpression(astObject)).to.throwException(errMsg); + expect(() => toExpression(astObject)).toThrowError(errMsg); }); it('throws on expressions without chains', () => { @@ -104,7 +125,7 @@ describe('ast toExpression', () => { ], }; - expect(() => toExpression(astObject)).to.throwException(errMsg); + expect(() => toExpression(astObject)).toThrowError(errMsg); }); it('throws on nameless functions and partials', () => { @@ -120,7 +141,7 @@ describe('ast toExpression', () => { ], }; - expect(() => toExpression(astObject)).to.throwException(errMsg); + expect(() => toExpression(astObject)).toThrowError(errMsg); }); it('single expression', () => { @@ -136,7 +157,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('csv'); + expect(expression).toBe('csv'); }); it('single expression with string argument', () => { @@ -154,7 +175,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('csv input="stuff\nthings"'); + expect(expression).toBe('csv input="stuff\nthings"'); }); it('single expression string value with a backslash', () => { @@ -172,7 +193,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('csv input="slash \\\\\\\\ slash"'); + expect(expression).toBe('csv input="slash \\\\\\\\ slash"'); }); it('single expression string value with a double quote', () => { @@ -190,7 +211,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('csv input="stuff\nthings\n\\"such\\""'); + expect(expression).toBe('csv input="stuff\nthings\n\\"such\\""'); }); it('single expression with number argument', () => { @@ -208,7 +229,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('series input=1234'); + expect(expression).toBe('series input=1234'); }); it('single expression with boolean argument', () => { @@ -226,7 +247,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('series input=true'); + expect(expression).toBe('series input=true'); }); it('single expression with null argument', () => { @@ -244,7 +265,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('series input=null'); + expect(expression).toBe('series input=null'); }); it('single expression with multiple arguments', () => { @@ -263,7 +284,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('csv input="stuff\nthings" separator="\\\\n"'); + expect(expression).toBe('csv input="stuff\nthings" separator="\\\\n"'); }); it('single expression with multiple and repeated arguments', () => { @@ -282,12 +303,12 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal( + expect(expression).toBe( 'csv input="stuff\nthings" input="more,things\nmore,stuff" separator="\\\\n"' ); }); - it('single expression with expression argument', () => { + it('single expression with `getcalc` expression argument', () => { const astObj = { type: 'expression', chain: [ @@ -314,10 +335,10 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('csv calc={getcalc} input="stuff\nthings"'); + expect(expression).toBe('csv calc={getcalc} input="stuff\nthings"'); }); - it('single expression with expression argument', () => { + it('single expression with `partcalc` expression argument', () => { const astObj = { type: 'expression', chain: [ @@ -344,7 +365,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('csv calc={partcalc} input="stuff\nthings"'); + expect(expression).toBe('csv calc={partcalc} input="stuff\nthings"'); }); it('single expression with expression arguments, with arguments', () => { @@ -390,7 +411,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal( + expect(expression).toBe( 'csv sep={partcalc type="comma"} input="stuff\nthings" break={setBreak type="newline"}' ); }); @@ -468,7 +489,7 @@ describe('ast toExpression', () => { '2016,honda,fit,15890,', '2016,honda,civic,18640"\n| line x={distinct f="year"} y={sum f="price"} colors={distinct f="model"}', ]; - expect(expression).to.equal(expected.join('\n')); + expect(expression).toBe(expected.join('\n')); }); it('three chained expressions', () => { @@ -563,7 +584,7 @@ describe('ast toExpression', () => { '2016,honda,civic,18640"\n| pointseries x={distinct f="year"} y={sum f="price"} ' + 'colors={distinct f="model"}\n| line pallette={getColorPallette name="elastic"}', ]; - expect(expression).to.equal(expected.join('\n')); + expect(expression).toBe(expected.join('\n')); }); }); @@ -583,7 +604,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('list "one" "two" "three"'); + expect(expression).toBe('list "one" "two" "three"'); }); it('named and unnamed', () => { @@ -603,7 +624,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).to.equal('both named="example" another="item" "one" "two" "three"'); + expect(expression).toBe('both named="example" another="item" "one" "two" "three"'); }); }); }); diff --git a/x-pack/plugins/canvas/common/lib/fn.js b/packages/kbn-interpreter/common/lib/fn.js similarity index 54% rename from x-pack/plugins/canvas/common/lib/fn.js rename to packages/kbn-interpreter/common/lib/fn.js index 70948c76579b3..c6b2fcbe67799 100644 --- a/x-pack/plugins/canvas/common/lib/fn.js +++ b/packages/kbn-interpreter/common/lib/fn.js @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 { mapValues, includes } from 'lodash'; diff --git a/packages/kbn-interpreter/common/lib/functions_registry.js b/packages/kbn-interpreter/common/lib/functions_registry.js new file mode 100644 index 0000000000000..1c71707d84722 --- /dev/null +++ b/packages/kbn-interpreter/common/lib/functions_registry.js @@ -0,0 +1,29 @@ +/* + * 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 { Registry } from './registry'; +import { Fn } from './fn'; + +class FunctionsRegistry extends Registry { + wrapper(obj) { + return new Fn(obj); + } +} + +export const functionsRegistry = new FunctionsRegistry(); diff --git a/packages/kbn-interpreter/common/lib/get_by_alias.js b/packages/kbn-interpreter/common/lib/get_by_alias.js new file mode 100644 index 0000000000000..d7bb1bbf9e79d --- /dev/null +++ b/packages/kbn-interpreter/common/lib/get_by_alias.js @@ -0,0 +1,33 @@ +/* + * 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. + */ + +/** + * This is used for looking up function/argument definitions. It looks through + * the given object/array for a case-insensitive match, which could be either the + * `name` itself, or something under the `aliases` property. + */ +export function getByAlias(specs, name) { + const lowerCaseName = name.toLowerCase(); + return Object.values(specs).find(({ name, aliases }) => { + if (name.toLowerCase() === lowerCaseName) return true; + return (aliases || []).some(alias => { + return alias.toLowerCase() === lowerCaseName; + }); + }); +} diff --git a/packages/kbn-interpreter/common/lib/get_by_alias.test.js b/packages/kbn-interpreter/common/lib/get_by_alias.test.js new file mode 100644 index 0000000000000..9cfc37fd8f304 --- /dev/null +++ b/packages/kbn-interpreter/common/lib/get_by_alias.test.js @@ -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. + */ + +import { getByAlias } from './get_by_alias'; + +describe('getByAlias', () => { + const fnsObject = { + foo: { name: 'foo', aliases: ['f'] }, + bar: { name: 'bar', aliases: ['b'] }, + }; + + const fnsArray = [{ name: 'foo', aliases: ['f'] }, { name: 'bar', aliases: ['b'] }]; + + it('returns the function by name', () => { + expect(getByAlias(fnsObject, 'foo')).toBe(fnsObject.foo); + expect(getByAlias(fnsObject, 'bar')).toBe(fnsObject.bar); + expect(getByAlias(fnsArray, 'foo')).toBe(fnsArray[0]); + expect(getByAlias(fnsArray, 'bar')).toBe(fnsArray[1]); + }); + + it('returns the function by alias', () => { + expect(getByAlias(fnsObject, 'f')).toBe(fnsObject.foo); + expect(getByAlias(fnsObject, 'b')).toBe(fnsObject.bar); + expect(getByAlias(fnsArray, 'f')).toBe(fnsArray[0]); + expect(getByAlias(fnsArray, 'b')).toBe(fnsArray[1]); + }); + + it('returns the function by case-insensitive name', () => { + expect(getByAlias(fnsObject, 'FOO')).toBe(fnsObject.foo); + expect(getByAlias(fnsObject, 'BAR')).toBe(fnsObject.bar); + expect(getByAlias(fnsArray, 'FOO')).toBe(fnsArray[0]); + expect(getByAlias(fnsArray, 'BAR')).toBe(fnsArray[1]); + }); + + it('returns the function by case-insensitive alias', () => { + expect(getByAlias(fnsObject, 'F')).toBe(fnsObject.foo); + expect(getByAlias(fnsObject, 'B')).toBe(fnsObject.bar); + expect(getByAlias(fnsArray, 'F')).toBe(fnsArray[0]); + expect(getByAlias(fnsArray, 'B')).toBe(fnsArray[1]); + }); + + it('handles empty strings', () => { + const emptyStringFnsObject = { '': { name: '' } }; + const emptyStringAliasFnsObject = { foo: { name: 'foo', aliases: [''] } }; + expect(getByAlias(emptyStringFnsObject, '')).toBe(emptyStringFnsObject['']); + expect(getByAlias(emptyStringAliasFnsObject, '')).toBe(emptyStringAliasFnsObject.foo); + + const emptyStringFnsArray = [{ name: '' }]; + const emptyStringAliasFnsArray = [{ name: 'foo', aliases: [''] }]; + expect(getByAlias(emptyStringFnsArray, '')).toBe(emptyStringFnsArray[0]); + expect(getByAlias(emptyStringAliasFnsArray, '')).toBe(emptyStringAliasFnsArray[0]); + }); + + it('handles "undefined" strings', () => { + const undefinedFnsObject = { undefined: { name: 'undefined' } }; + const undefinedAliasFnsObject = { foo: { name: 'undefined', aliases: ['undefined'] } }; + expect(getByAlias(undefinedFnsObject, 'undefined')).toBe(undefinedFnsObject.undefined); + expect(getByAlias(undefinedAliasFnsObject, 'undefined')).toBe(undefinedAliasFnsObject.foo); + + const emptyStringFnsArray = [{ name: 'undefined' }]; + const emptyStringAliasFnsArray = [{ name: 'foo', aliases: ['undefined'] }]; + expect(getByAlias(emptyStringFnsArray, 'undefined')).toBe(emptyStringFnsArray[0]); + expect(getByAlias(emptyStringAliasFnsArray, 'undefined')).toBe(emptyStringAliasFnsArray[0]); + }); + + it('returns undefined if not found', () => { + expect(getByAlias(fnsObject, 'baz')).toBe(undefined); + expect(getByAlias(fnsArray, 'baz')).toBe(undefined); + }); +}); diff --git a/packages/kbn-interpreter/common/lib/get_type.js b/packages/kbn-interpreter/common/lib/get_type.js new file mode 100644 index 0000000000000..ac440acf8da5d --- /dev/null +++ b/packages/kbn-interpreter/common/lib/get_type.js @@ -0,0 +1,28 @@ +/* + * 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. + */ + +export function getType(node) { + if (node == null) return 'null'; + if (typeof node === 'object') { + if (!node.type) throw new Error('Objects must have a type property'); + return node.type; + } + + return typeof node; +} diff --git a/x-pack/plugins/canvas/common/lib/grammar.js b/packages/kbn-interpreter/common/lib/grammar.js similarity index 100% rename from x-pack/plugins/canvas/common/lib/grammar.js rename to packages/kbn-interpreter/common/lib/grammar.js diff --git a/x-pack/plugins/canvas/common/lib/grammar.peg b/packages/kbn-interpreter/common/lib/grammar.peg similarity index 100% rename from x-pack/plugins/canvas/common/lib/grammar.peg rename to packages/kbn-interpreter/common/lib/grammar.peg diff --git a/packages/kbn-interpreter/common/lib/paths_registry.js b/packages/kbn-interpreter/common/lib/paths_registry.js new file mode 100644 index 0000000000000..3ad2b5dddf82e --- /dev/null +++ b/packages/kbn-interpreter/common/lib/paths_registry.js @@ -0,0 +1,65 @@ +/* + * 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. + */ + +class PathsRegistry { + + constructor() { + this.paths = new Map(); + } + + register = (type, paths) => { + if (!type) { + throw new Error(`Register requires a type`); + } + const lowerCaseType = type.toLowerCase(); + + const pathArray = Array.isArray(paths) ? paths : [paths]; + if (!this.paths.has(lowerCaseType)) { + this.paths.set(lowerCaseType, []); + } + + pathArray.forEach(p => { + this.paths.get(lowerCaseType).push(p); + }); + }; + + registerAll = (paths) => { + Object.keys(paths).forEach(type => { + this.register(type, paths[type]); + }); + }; + + toArray = () => { + return [...this.paths.values()]; + }; + + get = (type) => { + if (!type) { + return []; + } + const lowerCaseType = type.toLowerCase(); + return this.paths.has(lowerCaseType) ? this.paths.get(lowerCaseType) : []; + }; + + reset = () => { + this.paths.clear(); + }; +} + +export const pathsRegistry = new PathsRegistry(); diff --git a/packages/kbn-interpreter/common/lib/paths_registry.test.js b/packages/kbn-interpreter/common/lib/paths_registry.test.js new file mode 100644 index 0000000000000..ad2b9d949deb3 --- /dev/null +++ b/packages/kbn-interpreter/common/lib/paths_registry.test.js @@ -0,0 +1,92 @@ +/* + * 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. + */ + +describe('pathsRegistry', () => { + let registry; + beforeEach(() => { + jest.resetModules(); + registry = require('./paths_registry').pathsRegistry; + }); + + const paths = { + foo: 'bar', + sometype: [ + 'Here', + 'be', + 'more', + 'paths!' + ], + anothertype: ['with just one lonely path'] + }; + + it('throws when no type is provided', () => { + const check = () => registry.register(null, paths.foo); + expect(check).toThrowError(/requires a type/); + }); + + it('accepts paths as a string', () => { + registry.register('foo', paths.foo); + expect(registry.get('foo')).toEqual([paths.foo]); + }); + + it('accepts paths as an array', () => { + registry.register('sometype', paths.sometype); + expect(registry.get('sometype')).toEqual(paths.sometype); + }); + + it('ignores case when setting items', () => { + registry.register('FOO', paths.foo); + expect(registry.get('foo')).toEqual([paths.foo]); + }); + + it('gets items by lookup property', () => { + registry.register('sometype', paths.sometype); + expect(registry.get('sometype')).toEqual(paths.sometype); + }); + + it('can register an object of `type: path` key-value pairs', () => { + registry.registerAll(paths); + expect(registry.get('foo')).toEqual([paths.foo]); + expect(registry.get('sometype')).toEqual(paths.sometype); + expect(registry.get('anothertype')).toEqual(paths.anothertype); + }); + + it('ignores case when getting items', () => { + registry.registerAll(paths); + expect(registry.get('FOO')).toEqual([paths.foo]); + expect(registry.get('SOmEType')).toEqual(paths.sometype); + expect(registry.get('anoThertYPE')).toEqual(paths.anothertype); + }); + + it('returns an empty array with no match', () => { + expect(registry.get('@@nope_nope')).toEqual([]); + }); + + it('returns an array of all path values', () => { + registry.registerAll(paths); + expect(registry.toArray()).toEqual([[paths.foo], paths.sometype, paths.anothertype]); + }); + + it('resets the registry', () => { + registry.registerAll(paths); + expect(registry.get('sometype')).toEqual(paths.sometype); + registry.reset(); + expect(registry.get('sometype')).toEqual([]); + }); +}); \ No newline at end of file diff --git a/x-pack/plugins/canvas/common/lib/registry.js b/packages/kbn-interpreter/common/lib/registry.js similarity index 56% rename from x-pack/plugins/canvas/common/lib/registry.js rename to packages/kbn-interpreter/common/lib/registry.js index accabae4bc5eb..9882f3abde723 100644 --- a/x-pack/plugins/canvas/common/lib/registry.js +++ b/packages/kbn-interpreter/common/lib/registry.js @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 clone from 'lodash.clone'; @@ -22,8 +35,9 @@ export class Registry { const obj = fn(); - if (typeof obj !== 'object' || !obj[this._prop]) + if (typeof obj !== 'object' || !obj[this._prop]) { throw new Error(`Registered functions must return an object with a ${this._prop} property`); + } this._indexed[obj[this._prop].toLowerCase()] = this.wrapper(obj); } diff --git a/x-pack/plugins/canvas/common/lib/__tests__/registry.js b/packages/kbn-interpreter/common/lib/registry.test.js similarity index 60% rename from x-pack/plugins/canvas/common/lib/__tests__/registry.js rename to packages/kbn-interpreter/common/lib/registry.test.js index fd19bf0300417..dbeeb16dc1ff0 100644 --- a/x-pack/plugins/canvas/common/lib/__tests__/registry.js +++ b/packages/kbn-interpreter/common/lib/registry.test.js @@ -1,51 +1,63 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 expect from 'expect.js'; -import { Registry } from '../registry'; +import { Registry } from './registry'; function validateRegistry(registry, elements) { it('gets items by lookup property', () => { - expect(registry.get('__test2')).to.eql(elements[1]()); + expect(registry.get('__test2')).toEqual(elements[1]()); }); it('ignores case when getting items', () => { - expect(registry.get('__TeSt2')).to.eql(elements[1]()); - expect(registry.get('__tESt2')).to.eql(elements[1]()); + expect(registry.get('__TeSt2')).toEqual(elements[1]()); + expect(registry.get('__tESt2')).toEqual(elements[1]()); }); it('gets a shallow clone', () => { - expect(registry.get('__test2')).to.not.equal(elements[1]()); + expect(registry.get('__test2')).not.toBe(elements[1]()); }); it('is null with no match', () => { - expect(registry.get('@@nope_nope')).to.be(null); + expect(registry.get('@@nope_nope')).toBe(null); }); it('returns shallow clone of the whole registry via toJS', () => { const regAsJs = registry.toJS(); - expect(regAsJs).to.eql({ + expect(regAsJs).toEqual({ __test1: elements[0](), __test2: elements[1](), }); - expect(regAsJs.__test1).to.eql(elements[0]()); - expect(regAsJs.__test1).to.not.equal(elements[0]()); + expect(regAsJs.__test1).toEqual(elements[0]()); + expect(regAsJs.__test1).not.toBe(elements[0]()); }); it('returns shallow clone array via toArray', () => { const regAsArray = registry.toArray(); - expect(regAsArray).to.be.an(Array); - expect(regAsArray[0]).to.eql(elements[0]()); - expect(regAsArray[0]).to.not.equal(elements[0]()); + expect(regAsArray).toBeInstanceOf(Array); + expect(regAsArray[0]).toEqual(elements[0]()); + expect(regAsArray[0]).not.toBe(elements[0]()); }); it('resets the registry', () => { - expect(registry.get('__test2')).to.eql(elements[1]()); + expect(registry.get('__test2')).toEqual(elements[1]()); registry.reset(); - expect(registry.get('__test2')).to.equal(null); + expect(registry.get('__test2')).toBe(null); }); } @@ -70,12 +82,12 @@ describe('Registry', () => { validateRegistry(registry, elements); it('has a prop of name', () => { - expect(registry.getProp()).to.equal('name'); + expect(registry.getProp()).toBe('name'); }); it('throws when object is missing the lookup prop', () => { const check = () => registry.register(() => ({ hello: 'world' })); - expect(check).to.throwException(/object with a name property/i); + expect(check).toThrowError(/object with a name property/); }); }); @@ -99,12 +111,12 @@ describe('Registry', () => { validateRegistry(registry, elements); it('has a prop of type', () => { - expect(registry.getProp()).to.equal('type'); + expect(registry.getProp()).toBe('type'); }); it('throws when object is missing the lookup prop', () => { const check = () => registry.register(() => ({ hello: 'world' })); - expect(check).to.throwException(/object with a type property/i); + expect(check).toThrowError(/object with a type property/); }); }); @@ -137,9 +149,8 @@ describe('Registry', () => { registry.register(elements[1]); it('contains wrapped elements', () => { - // test for the custom prop on the returned elements - expect(registry.get(elements[0]().name)).to.have.property('__CUSTOM_PROP__', 1); - expect(registry.get(elements[1]().name)).to.have.property('__CUSTOM_PROP__', 2); + expect(registry.get(elements[0]().name)).toHaveProperty('__CUSTOM_PROP__'); + expect(registry.get(elements[1]().name)).toHaveProperty('__CUSTOM_PROP__'); }); }); @@ -171,20 +182,18 @@ describe('Registry', () => { }); it('get contains the full prototype', () => { - expect(thing().baseFunc).to.be.a('function'); - expect(registry.get(name).baseFunc).to.be.a('function'); + expect(typeof thing().baseFunc).toBe('function'); + expect(typeof registry.get(name).baseFunc).toBe('function'); }); it('toJS contains the full prototype', () => { const val = registry.toJS(); - expect(val[name].baseFunc).to.be.a('function'); + expect(typeof val[name].baseFunc).toBe('function'); }); }); describe('throws when lookup prop is not a string', () => { const check = () => new Registry(2); - expect(check).to.throwException(e => { - expect(e.message).to.be('Registry property name must be a string'); - }); + expect(check).toThrowError(/must be a string/); }); }); diff --git a/packages/kbn-interpreter/common/lib/serialize.js b/packages/kbn-interpreter/common/lib/serialize.js new file mode 100644 index 0000000000000..2f881db3c77e0 --- /dev/null +++ b/packages/kbn-interpreter/common/lib/serialize.js @@ -0,0 +1,37 @@ +/* + * 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 { get, identity } from 'lodash'; +import { getType } from './get_type'; + +export function serializeProvider(types) { + return { + serialize: provider('serialize'), + deserialize: provider('deserialize'), + }; + + function provider(key) { + return context => { + const type = getType(context); + const typeDef = types[type]; + const fn = get(typeDef, key) || identity; + return fn(context); + }; + } +} diff --git a/x-pack/plugins/canvas/common/lib/type.js b/packages/kbn-interpreter/common/lib/type.js similarity index 61% rename from x-pack/plugins/canvas/common/lib/type.js rename to packages/kbn-interpreter/common/lib/type.js index d917750e3848e..356b82bf91cbd 100644 --- a/x-pack/plugins/canvas/common/lib/type.js +++ b/packages/kbn-interpreter/common/lib/type.js @@ -1,12 +1,25 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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. */ // All types must be universal and be castable on the client or on the server import { get } from 'lodash'; -import { getType } from '../lib/get_type'; +import { getType } from './get_type'; // TODO: Currently all casting functions must be syncronous. @@ -35,10 +48,12 @@ export function Type(config) { this.to = (node, toTypeName, types) => { const typeName = getType(node); - if (typeName !== this.name) + if (typeName !== this.name) { throw new Error(`Can not cast object of type '${typeName}' using '${this.name}'`); - else if (!this.castsTo(toTypeName)) + } + else if (!this.castsTo(toTypeName)) { throw new Error(`Can not cast '${typeName}' to '${toTypeName}'`); + } return getToFn(toTypeName)(node, types); }; diff --git a/packages/kbn-interpreter/common/lib/types_registry.js b/packages/kbn-interpreter/common/lib/types_registry.js new file mode 100644 index 0000000000000..97e28875d7e20 --- /dev/null +++ b/packages/kbn-interpreter/common/lib/types_registry.js @@ -0,0 +1,29 @@ +/* + * 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 { Registry } from './registry'; +import { Type } from './type'; + +class TypesRegistry extends Registry { + wrapper(obj) { + return new Type(obj); + } +} + +export const typesRegistry = new TypesRegistry(); diff --git a/packages/kbn-interpreter/package.json b/packages/kbn-interpreter/package.json new file mode 100644 index 0000000000000..0178b9e2cfe32 --- /dev/null +++ b/packages/kbn-interpreter/package.json @@ -0,0 +1,10 @@ +{ + "name": "@kbn/interpreter", + "version": "1.0.0", + "license": "Apache-2.0", + "scripts": { + "build": "node tasks/build.js", + "canvas:peg": "pegjs common/lib/grammar.peg", + "kbn:bootstrap": "yarn build" + } +} diff --git a/packages/kbn-interpreter/plugin_src/functions/common/clog.js b/packages/kbn-interpreter/plugin_src/functions/common/clog.js new file mode 100644 index 0000000000000..634d166f5f0bb --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/functions/common/clog.js @@ -0,0 +1,27 @@ +/* + * 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. + */ + +export const clog = () => ({ + name: 'clog', + help: 'Outputs the context to the console', + fn: context => { + console.log(context); //eslint-disable-line no-console + return context; + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/functions/common/index.js b/packages/kbn-interpreter/plugin_src/functions/common/index.js new file mode 100644 index 0000000000000..2f5f91181faec --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/functions/common/index.js @@ -0,0 +1,24 @@ +/* + * 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 { clog } from './clog'; + +export const commonFunctions = [ + clog, +]; diff --git a/packages/kbn-interpreter/plugin_src/functions/common/register.js b/packages/kbn-interpreter/plugin_src/functions/common/register.js new file mode 100644 index 0000000000000..8b146b8f849c3 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/functions/common/register.js @@ -0,0 +1,23 @@ +/* + * 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 { commonFunctions } from './index'; + +// eslint-disable-next-line no-undef +commonFunctions.forEach(canvas.register); diff --git a/packages/kbn-interpreter/plugin_src/types/boolean.js b/packages/kbn-interpreter/plugin_src/types/boolean.js new file mode 100644 index 0000000000000..cc5f0a79e39a8 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/boolean.js @@ -0,0 +1,42 @@ +/* + * 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. + */ + +export const boolean = () => ({ + name: 'boolean', + from: { + null: () => false, + number: n => Boolean(n), + string: s => Boolean(s), + }, + to: { + render: value => { + const text = `${value}`; + return { + type: 'render', + as: 'text', + value: { text }, + }; + }, + datatable: value => ({ + type: 'datatable', + columns: [{ name: 'value', type: 'boolean' }], + rows: [{ value }], + }), + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/datatable.js b/packages/kbn-interpreter/plugin_src/types/datatable.js similarity index 63% rename from x-pack/plugins/canvas/canvas_plugin_src/types/datatable.js rename to packages/kbn-interpreter/plugin_src/types/datatable.js index cfe75605f1ebf..92bd2c9b1b59e 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/datatable.js +++ b/packages/kbn-interpreter/plugin_src/types/datatable.js @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 { map, zipObject } from 'lodash'; @@ -10,8 +23,9 @@ export const datatable = () => ({ name: 'datatable', validate: datatable => { // TODO: Check columns types. Only string, boolean, number, date, allowed for now. - if (!datatable.columns) + if (!datatable.columns) { throw new Error('datatable must have a columns array, even if it is empty'); + } if (!datatable.rows) throw new Error('datatable must have a rows array, even if it is empty'); }, diff --git a/packages/kbn-interpreter/plugin_src/types/error.js b/packages/kbn-interpreter/plugin_src/types/error.js new file mode 100644 index 0000000000000..1415a065d810e --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/error.js @@ -0,0 +1,35 @@ +/* + * 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. + */ + +export const error = () => ({ + name: 'error', + to: { + render: input => { + const { error, info } = input; + return { + type: 'render', + as: 'error', + value: { + error, + info, + }, + }; + }, + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/filter.js b/packages/kbn-interpreter/plugin_src/types/filter.js new file mode 100644 index 0000000000000..484050671b2f9 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/filter.js @@ -0,0 +1,33 @@ +/* + * 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. + */ + +export const filter = () => ({ + name: 'filter', + from: { + null: () => { + return { + type: 'filter', + // Any meta data you wish to pass along. + meta: {}, + // And filters. If you need an "or", create a filter type for it. + and: [], + }; + }, + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/image.js b/packages/kbn-interpreter/plugin_src/types/image.js new file mode 100644 index 0000000000000..7666451145f5d --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/image.js @@ -0,0 +1,31 @@ +/* + * 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. + */ + +export const image = () => ({ + name: 'image', + to: { + render: input => { + return { + type: 'render', + as: 'image', + value: input, + }; + }, + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/index.js b/packages/kbn-interpreter/plugin_src/types/index.js new file mode 100644 index 0000000000000..1ae5f874835c3 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/index.js @@ -0,0 +1,46 @@ +/* + * 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 { boolean } from './boolean'; +import { datatable } from './datatable'; +import { error } from './error'; +import { filter } from './filter'; +import { image } from './image'; +import { nullType } from './null'; +import { number } from './number'; +import { pointseries } from './pointseries'; +import { render } from './render'; +import { shape } from './shape'; +import { string } from './string'; +import { style } from './style'; + +export const typeSpecs = [ + boolean, + datatable, + error, + filter, + image, + number, + nullType, + pointseries, + render, + shape, + string, + style, +]; diff --git a/packages/kbn-interpreter/plugin_src/types/null.js b/packages/kbn-interpreter/plugin_src/types/null.js new file mode 100644 index 0000000000000..2789ce330ac6c --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/null.js @@ -0,0 +1,25 @@ +/* + * 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. + */ + +export const nullType = () => ({ + name: 'null', + from: { + '*': () => null, + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/number.js b/packages/kbn-interpreter/plugin_src/types/number.js new file mode 100644 index 0000000000000..8f8f31ea8a2fb --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/number.js @@ -0,0 +1,42 @@ +/* + * 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. + */ + +export const number = () => ({ + name: 'number', + from: { + null: () => 0, + boolean: b => Number(b), + string: n => Number(n), + }, + to: { + render: value => { + const text = `${value}`; + return { + type: 'render', + as: 'text', + value: { text }, + }; + }, + datatable: value => ({ + type: 'datatable', + columns: [{ name: 'value', type: 'number' }], + rows: [{ value }], + }), + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/pointseries.js b/packages/kbn-interpreter/plugin_src/types/pointseries.js new file mode 100644 index 0000000000000..2275ea9e04094 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/pointseries.js @@ -0,0 +1,44 @@ +/* + * 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. + */ + +export const pointseries = () => ({ + name: 'pointseries', + from: { + null: () => { + return { + type: 'pointseries', + rows: [], + columns: [], + }; + }, + }, + to: { + render: (pointseries, types) => { + const datatable = types.datatable.from(pointseries, types); + return { + type: 'render', + as: 'table', + value: { + datatable, + showHeader: true, + }, + }; + }, + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/register.js b/packages/kbn-interpreter/plugin_src/types/register.js new file mode 100644 index 0000000000000..17b03f0229672 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/register.js @@ -0,0 +1,24 @@ +/* + * 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 'babel-polyfill'; +import { typeSpecs } from './index'; + +// eslint-disable-next-line no-undef +typeSpecs.forEach(canvas.register); diff --git a/packages/kbn-interpreter/plugin_src/types/render.js b/packages/kbn-interpreter/plugin_src/types/render.js new file mode 100644 index 0000000000000..99ce3ca7d1cd7 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/render.js @@ -0,0 +1,29 @@ +/* + * 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. + */ + +export const render = () => ({ + name: 'render', + from: { + '*': v => ({ + type: 'render', + as: 'debug', + value: v, + }), + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/shape.js b/packages/kbn-interpreter/plugin_src/types/shape.js new file mode 100644 index 0000000000000..1ed7a111268d1 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/shape.js @@ -0,0 +1,31 @@ +/* + * 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. + */ + +export const shape = () => ({ + name: 'shape', + to: { + render: input => { + return { + type: 'render', + as: 'shape', + value: input, + }; + }, + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/string.js b/packages/kbn-interpreter/plugin_src/types/string.js new file mode 100644 index 0000000000000..90e6b17cc9dcf --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/string.js @@ -0,0 +1,41 @@ +/* + * 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. + */ + +export const string = () => ({ + name: 'string', + from: { + null: () => '', + boolean: b => String(b), + number: n => String(n), + }, + to: { + render: text => { + return { + type: 'render', + as: 'text', + value: { text }, + }; + }, + datatable: value => ({ + type: 'datatable', + columns: [{ name: 'value', type: 'string' }], + rows: [{ value }], + }), + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/style.js b/packages/kbn-interpreter/plugin_src/types/style.js new file mode 100644 index 0000000000000..97057b415a475 --- /dev/null +++ b/packages/kbn-interpreter/plugin_src/types/style.js @@ -0,0 +1,31 @@ +/* + * 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. + */ + +export const style = () => ({ + name: 'style', + from: { + null: () => { + return { + type: 'style', + spec: {}, + css: '', + }; + }, + }, +}); diff --git a/packages/kbn-interpreter/public/browser_registries.js b/packages/kbn-interpreter/public/browser_registries.js new file mode 100644 index 0000000000000..778a0b03a7624 --- /dev/null +++ b/packages/kbn-interpreter/public/browser_registries.js @@ -0,0 +1,83 @@ +/* + * 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 chrome from 'ui/chrome'; +import $script from 'scriptjs'; + +let resolvePromise = null; +let called = false; + +let populatePromise = new Promise(_resolve => { + resolvePromise = _resolve; +}); + +export const getBrowserRegistries = () => { + return populatePromise; +}; + +const loadBrowserRegistries = (registries) => { + const remainingTypes = Object.keys(registries); + const populatedTypes = {}; + + return new Promise(resolve => { + function loadType() { + if (!remainingTypes.length) { + resolve(populatedTypes); + return; + } + const type = remainingTypes.pop(); + window.canvas = window.canvas || {}; + window.canvas.register = d => registries[type].register(d); + + // Load plugins one at a time because each needs a different loader function + // $script will only load each of these once, we so can call this as many times as we need? + const pluginPath = chrome.addBasePath(`/api/canvas/plugins?type=${type}`); + $script(pluginPath, () => { + populatedTypes[type] = registries[type]; + loadType(); + }); + } + + loadType(); + }); +}; + +export const populateBrowserRegistries = (registries) => { + if (called) { + const oldPromise = populatePromise; + let newResolve; + populatePromise = new Promise(_resolve => { + newResolve = _resolve; + }); + oldPromise.then(oldTypes => { + loadBrowserRegistries(registries).then(newTypes => { + newResolve({ + ...oldTypes, + ...newTypes, + }); + }); + }); + return populatePromise; + } + called = true; + loadBrowserRegistries(registries).then(registries => { + resolvePromise(registries); + }); + return populatePromise; +}; diff --git a/packages/kbn-interpreter/public/create_handlers.js b/packages/kbn-interpreter/public/create_handlers.js new file mode 100644 index 0000000000000..3446a945ae76e --- /dev/null +++ b/packages/kbn-interpreter/public/create_handlers.js @@ -0,0 +1,24 @@ +/* + * 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. + */ + +export function createHandlers(/*socket*/) { + return { + environment: 'client', + }; +} diff --git a/x-pack/plugins/canvas/public/lib/interpreter.js b/packages/kbn-interpreter/public/interpreter.js similarity index 55% rename from x-pack/plugins/canvas/public/lib/interpreter.js rename to packages/kbn-interpreter/public/interpreter.js index 36878871b8b15..5c1e199bce363 100644 --- a/x-pack/plugins/canvas/public/lib/interpreter.js +++ b/packages/kbn-interpreter/public/interpreter.js @@ -1,15 +1,28 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 { socketInterpreterProvider } from '../../common/interpreter/socket_interpret'; -import { serializeProvider } from '../../common/lib/serialize'; -import { getSocket } from '../socket'; -import { typesRegistry } from '../../common/lib/types_registry'; +import { socketInterpreterProvider } from '../common/interpreter/socket_interpret'; +import { serializeProvider } from '../common/lib/serialize'; +import { getSocket } from './socket'; +import { typesRegistry } from '../common/lib/types_registry'; import { createHandlers } from './create_handlers'; -import { functionsRegistry } from './functions_registry'; +import { functionsRegistry } from '../common/lib/functions_registry'; import { getBrowserRegistries } from './browser_registries'; let socket; diff --git a/x-pack/plugins/canvas/public/socket.js b/packages/kbn-interpreter/public/socket.js similarity index 64% rename from x-pack/plugins/canvas/public/socket.js rename to packages/kbn-interpreter/public/socket.js index 92deedd488c06..9143f0018377b 100644 --- a/x-pack/plugins/canvas/public/socket.js +++ b/packages/kbn-interpreter/public/socket.js @@ -1,12 +1,25 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 io from 'socket.io-client'; import { functionsRegistry } from '../common/lib/functions_registry'; -import { getBrowserRegistries } from './lib/browser_registries'; +import { getBrowserRegistries } from './browser_registries'; const SOCKET_CONNECTION_TIMEOUT = 5000; // timeout in ms let socket; diff --git a/packages/kbn-interpreter/server/get_plugin_paths.js b/packages/kbn-interpreter/server/get_plugin_paths.js new file mode 100644 index 0000000000000..f6520563c912f --- /dev/null +++ b/packages/kbn-interpreter/server/get_plugin_paths.js @@ -0,0 +1,55 @@ +/* + * 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 fs from 'fs'; +import { resolve } from 'path'; +import { promisify } from 'util'; +import { flatten } from 'lodash'; +import { pathsRegistry } from '../common/lib/paths_registry'; + +const lstat = promisify(fs.lstat); +const readdir = promisify(fs.readdir); + +const isDirectory = path => + lstat(path) + .then(stat => stat.isDirectory()) + .catch(() => false); + +export const getPluginPaths = type => { + const typePaths = pathsRegistry.get(type); + if (!typePaths) { + throw new Error(`Unknown type: ${type}`); + } + + return Promise.all(typePaths.map(async path => { + const isDir = await isDirectory(path); + if (!isDir) { + return; + } + // Get the full path of all js files in the directory + return readdir(path).then(files => { + return files.reduce((acc, file) => { + if (file.endsWith('.js')) { + acc.push(resolve(path, file)); + } + return acc; + }, []); + }).catch(); + })).then(flatten); +}; diff --git a/packages/kbn-interpreter/server/server_registries.js b/packages/kbn-interpreter/server/server_registries.js new file mode 100644 index 0000000000000..3fbb957673e63 --- /dev/null +++ b/packages/kbn-interpreter/server/server_registries.js @@ -0,0 +1,78 @@ +/* + * 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 { typesRegistry } from '../common/lib/types_registry'; +import { functionsRegistry as serverFunctions } from '../common/lib/functions_registry'; +import { getPluginPaths } from './get_plugin_paths'; + +const registries = { + serverFunctions: serverFunctions, + commonFunctions: serverFunctions, + types: typesRegistry, +}; + +let resolve = null; +let called = false; + +const populatePromise = new Promise(_resolve => { + resolve = _resolve; +}); + +export const getServerRegistries = () => { + return populatePromise; +}; + +export const populateServerRegistries = types => { + if (called) { + console.log('function should only be called once per process'); + return populatePromise; + } + called = true; + if (!types || !types.length) throw new Error('types is required'); + + const remainingTypes = types; + const populatedTypes = {}; + + const globalKeys = Object.keys(global); + + const loadType = () => { + const type = remainingTypes.pop(); + getPluginPaths(type).then(paths => { + global.canvas = global.canvas || {}; + global.canvas.register = d => registries[type].register(d); + + paths.forEach(path => { + require(path); + }); + + Object.keys(global).forEach(key => { + if (!globalKeys.includes(key)) { + delete global[key]; + } + }); + + populatedTypes[type] = registries[type]; + if (remainingTypes.length) loadType(); + else resolve(populatedTypes); + }); + }; + + if (remainingTypes.length) loadType(); + return populatePromise; +}; diff --git a/packages/kbn-interpreter/tasks/build.js b/packages/kbn-interpreter/tasks/build.js new file mode 100644 index 0000000000000..37776e8d74cca --- /dev/null +++ b/packages/kbn-interpreter/tasks/build.js @@ -0,0 +1,40 @@ +/* + * 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 webpack = require('webpack'); +const webpackConfig = require('./webpack.plugins'); + +const devtool = 'inline-cheap-module-source-map'; + +const onComplete = function (done) { + return function (err, stats) { + if (err) { + done && done(err); + } else { + const seconds = ((stats.endTime - stats.startTime) / 1000).toFixed(2); + console.log(`Plugins built in ${seconds} seconds`); + done && done(); + } + }; +}; + +webpack({ ...webpackConfig, devtool }, onComplete(function () { + console.log('all done'); +})); + diff --git a/packages/kbn-interpreter/tasks/webpack.plugins.js b/packages/kbn-interpreter/tasks/webpack.plugins.js new file mode 100644 index 0000000000000..8b16edc5ad462 --- /dev/null +++ b/packages/kbn-interpreter/tasks/webpack.plugins.js @@ -0,0 +1,100 @@ +/* + * 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 path = require('path'); + +const sourceDir = path.resolve(__dirname, '../plugin_src'); +const buildDir = path.resolve(__dirname, '../plugin'); + +module.exports = { + entry: { + 'types/all': path.join(sourceDir, 'types/register.js'), + 'functions/common/all': path.join(sourceDir, 'functions/common/register.js'), + }, + target: 'webworker', + + output: { + path: buildDir, + filename: '[name].js', // Need long paths here. + libraryTarget: 'umd', + }, + + resolve: { + extensions: ['.js', '.json'], + mainFields: ['browser', 'main'], + }, + + plugins: [ + function loaderFailHandler() { + // bails on error, including loader errors + // see https://github.com/webpack/webpack/issues/708, which does not fix loader errors + let isWatch = true; + + this.plugin('run', function (compiler, callback) { + isWatch = false; + callback.call(compiler); + }); + + this.plugin('done', function (stats) { + if (!stats.hasErrors()) { + return; + } + const errorMessage = stats.toString('errors-only'); + if (isWatch) { + console.error(errorMessage); + } + else { + throw new Error(errorMessage); + } + }); + }, + ], + + module: { + rules: [ + { + test: /\.js$/, + exclude: [/node_modules/], + loaders: 'babel-loader', + options: { + babelrc: false, + presets: [require.resolve('@kbn/babel-preset/webpack_preset')], + }, + }, + { + test: /\.(png|jpg|gif|jpeg|svg)$/, + loaders: ['url-loader'], + }, + { + test: /\.(css|scss)$/, + loaders: ['style-loader', 'css-loader', 'sass-loader'], + }, + ], + }, + + node: { + // Don't replace built-in globals + __filename: false, + __dirname: false, + }, + + watchOptions: { + ignored: [/node_modules/], + }, +}; diff --git a/src/core_plugins/interpreter/common/constants.js b/src/core_plugins/interpreter/common/constants.js new file mode 100644 index 0000000000000..a5751ee72e826 --- /dev/null +++ b/src/core_plugins/interpreter/common/constants.js @@ -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. + */ + +export const SECURITY_AUTH_MESSAGE = 'Authentication failed'; +export const API_ROUTE = '/api/canvas'; diff --git a/src/core_plugins/interpreter/index.js b/src/core_plugins/interpreter/index.js new file mode 100644 index 0000000000000..273c8b8c37957 --- /dev/null +++ b/src/core_plugins/interpreter/index.js @@ -0,0 +1,41 @@ +/* + * 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 { resolve } from 'path'; +import init from './init'; +import { pathsRegistry } from '@kbn/interpreter/common/lib/paths_registry'; +import { pluginPaths } from './plugin_paths'; + +export default function (kibana) { + return new kibana.Plugin({ + id: 'interpreter', + require: ['kibana', 'elasticsearch'], + publicDir: resolve(__dirname, 'public'), + uiExports: { + hacks: [ + 'plugins/interpreter/load_browser_plugins.js', + ], + }, + preInit: () => { + pathsRegistry.registerAll(pluginPaths); + }, + init, + }); +} + diff --git a/src/core_plugins/interpreter/init.js b/src/core_plugins/interpreter/init.js new file mode 100644 index 0000000000000..58385973ac930 --- /dev/null +++ b/src/core_plugins/interpreter/init.js @@ -0,0 +1,41 @@ +/* + * 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 { routes } from './server/routes'; +import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; +import { populateServerRegistries } from '@kbn/interpreter/server/server_registries'; + +export default function (server /*options*/) { + server.injectUiAppVars('canvas', () => { + const config = server.config(); + const basePath = config.get('server.basePath'); + const reportingBrowserType = config.get('xpack.reporting.capture.browser.type'); + + return { + kbnIndex: config.get('kibana.index'), + esShardTimeout: config.get('elasticsearch.shardTimeout'), + esApiVersion: config.get('elasticsearch.apiVersion'), + serverFunctions: functionsRegistry.toArray(), + basePath, + reportingBrowserType, + }; + }); + + populateServerRegistries(['serverFunctions', 'types']).then(() => routes(server)); +} diff --git a/src/core_plugins/interpreter/package.json b/src/core_plugins/interpreter/package.json new file mode 100644 index 0000000000000..3265dadd7fbfc --- /dev/null +++ b/src/core_plugins/interpreter/package.json @@ -0,0 +1,4 @@ +{ + "name": "interpreter", + "version": "kibana" +} diff --git a/src/core_plugins/interpreter/plugin_paths.js b/src/core_plugins/interpreter/plugin_paths.js new file mode 100644 index 0000000000000..ca44ce1a1f7b2 --- /dev/null +++ b/src/core_plugins/interpreter/plugin_paths.js @@ -0,0 +1,27 @@ +/* + * 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 { resolve } from 'path'; + +const dir = resolve(__dirname, '..', '..', '..'); + +export const pluginPaths = { + commonFunctions: resolve(dir, 'node_modules/@kbn/interpreter/plugin/functions/common'), + types: resolve(dir, 'node_modules/@kbn/interpreter/plugin/types'), +}; diff --git a/src/core_plugins/interpreter/public/load_browser_plugins.js b/src/core_plugins/interpreter/public/load_browser_plugins.js new file mode 100644 index 0000000000000..6322e8e340e45 --- /dev/null +++ b/src/core_plugins/interpreter/public/load_browser_plugins.js @@ -0,0 +1,30 @@ +/* + * 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 { populateBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; +import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; +import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; + +const types = { + commonFunctions: functionsRegistry, + browserFunctions: functionsRegistry, + types: typesRegistry +}; + +populateBrowserRegistries(types); diff --git a/x-pack/plugins/canvas/server/lib/__tests__/create_handlers.js b/src/core_plugins/interpreter/server/lib/__tests__/create_handlers.js similarity index 83% rename from x-pack/plugins/canvas/server/lib/__tests__/create_handlers.js rename to src/core_plugins/interpreter/server/lib/__tests__/create_handlers.js index 9dbe0e413a1af..9afe458c444a7 100644 --- a/x-pack/plugins/canvas/server/lib/__tests__/create_handlers.js +++ b/src/core_plugins/interpreter/server/lib/__tests__/create_handlers.js @@ -1,12 +1,25 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 expect from 'expect.js'; import { createHandlers } from '../create_handlers'; -import { SECURITY_AUTH_MESSAGE } from '../../../common/lib/constants'; +import { SECURITY_AUTH_MESSAGE } from '../../../common/constants'; let securityMode = 'pass'; let isSecurityAvailable = true; diff --git a/x-pack/plugins/canvas/server/lib/create_handlers.js b/src/core_plugins/interpreter/server/lib/create_handlers.js similarity index 58% rename from x-pack/plugins/canvas/server/lib/create_handlers.js rename to src/core_plugins/interpreter/server/lib/create_handlers.js index f42f8fbe1a59d..9c4dcd112c928 100644 --- a/x-pack/plugins/canvas/server/lib/create_handlers.js +++ b/src/core_plugins/interpreter/server/lib/create_handlers.js @@ -1,12 +1,25 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 boom from 'boom'; -import { SECURITY_AUTH_MESSAGE } from '../../common/lib/constants'; import { isSecurityEnabled } from './feature_check'; +import { SECURITY_AUTH_MESSAGE } from '../../common/constants'; export const createHandlers = (request, server) => { const { callWithRequest } = server.plugins.elasticsearch.getCluster('data'); @@ -24,8 +37,9 @@ export const createHandlers = (request, server) => { if (isSecurityEnabled(server)) { try { const authenticationResult = await server.plugins.security.authenticate(request); - if (!authenticationResult.succeeded()) + if (!authenticationResult.succeeded()) { throw boom.unauthorized(authenticationResult.error); + } } catch (e) { // if authenticate throws, show error in development if (process.env.NODE_ENV !== 'production') { diff --git a/src/core_plugins/interpreter/server/lib/feature_check.js b/src/core_plugins/interpreter/server/lib/feature_check.js new file mode 100644 index 0000000000000..9f7a8993fa3ff --- /dev/null +++ b/src/core_plugins/interpreter/server/lib/feature_check.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// TODO: replace this when we use the method exposed by security https://github.com/elastic/kibana/pull/24616 +export const isSecurityEnabled = server => { + const kibanaSecurity = server.plugins.security; + const esSecurity = server.plugins.xpack_main.info.feature('security'); + + return kibanaSecurity && esSecurity.isAvailable() && esSecurity.isEnabled(); +}; diff --git a/src/core_plugins/interpreter/server/lib/get_plugin_stream.js b/src/core_plugins/interpreter/server/lib/get_plugin_stream.js new file mode 100644 index 0000000000000..d685d365d31a4 --- /dev/null +++ b/src/core_plugins/interpreter/server/lib/get_plugin_stream.js @@ -0,0 +1,37 @@ +/* + * 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 fs from 'fs'; +import ss from 'stream-stream'; +import { getPluginPaths } from '@kbn/interpreter/server/get_plugin_paths'; + +export const getPluginStream = type => { + const stream = ss({ + separator: '\n', + }); + + getPluginPaths(type).then(files => { + files.forEach(file => { + stream.write(fs.createReadStream(file)); + }); + stream.end(); + }); + + return stream; +}; diff --git a/src/core_plugins/interpreter/server/lib/get_request.js b/src/core_plugins/interpreter/server/lib/get_request.js new file mode 100644 index 0000000000000..2b29b05fd07aa --- /dev/null +++ b/src/core_plugins/interpreter/server/lib/get_request.js @@ -0,0 +1,44 @@ +/* + * 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 boom from 'boom'; +import { API_ROUTE } from '../../common/constants'; + +export function getRequest(server, { headers }) { + const url = `${API_ROUTE}/ping`; + + return server + .inject({ + method: 'POST', + url, + headers, + }) + .then(res => { + if (res.statusCode !== 200) { + if (process.env.NODE_ENV !== 'production') { + console.error( + new Error(`Auth request failed: [${res.statusCode}] ${res.result.message}`) + ); + } + throw boom.unauthorized('Failed to authenticate socket connection'); + } + + return res.request; + }); +} diff --git a/x-pack/plugins/canvas/server/lib/route_expression/browser.js b/src/core_plugins/interpreter/server/lib/route_expression/browser.js similarity index 65% rename from x-pack/plugins/canvas/server/lib/route_expression/browser.js rename to src/core_plugins/interpreter/server/lib/route_expression/browser.js index feae107873ac6..0fe27f4d27c68 100644 --- a/x-pack/plugins/canvas/server/lib/route_expression/browser.js +++ b/src/core_plugins/interpreter/server/lib/route_expression/browser.js @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 uuid from 'uuid/v4'; diff --git a/x-pack/plugins/canvas/server/lib/route_expression/index.js b/src/core_plugins/interpreter/server/lib/route_expression/index.js similarity index 51% rename from x-pack/plugins/canvas/server/lib/route_expression/index.js rename to src/core_plugins/interpreter/server/lib/route_expression/index.js index 3533b55687246..1b3556e051d2d 100644 --- a/x-pack/plugins/canvas/server/lib/route_expression/index.js +++ b/src/core_plugins/interpreter/server/lib/route_expression/index.js @@ -1,9 +1,23 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 { createError } from '../../../common/interpreter/create_error'; + +import { createError } from '@kbn/interpreter/common/interpreter/create_error'; export const routeExpressionProvider = environments => { async function routeExpression(ast, context = null) { diff --git a/src/core_plugins/interpreter/server/lib/route_expression/server.js b/src/core_plugins/interpreter/server/lib/route_expression/server.js new file mode 100644 index 0000000000000..50a80a1e0275a --- /dev/null +++ b/src/core_plugins/interpreter/server/lib/route_expression/server.js @@ -0,0 +1,40 @@ +/* + * 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 { getServerRegistries } from '@kbn/interpreter/server/server_registries'; +import { interpretProvider } from '@kbn/interpreter/common/interpreter/interpret'; +import { createHandlers } from '../create_handlers'; + +export const server = async ({ onFunctionNotFound, server, request }) => { + const { serverFunctions, types } = await getServerRegistries(['serverFunctions', 'types']); + + return { + interpret: (ast, context) => { + const interpret = interpretProvider({ + types: types.toJS(), + functions: serverFunctions.toJS(), + handlers: createHandlers(request, server), + onFunctionNotFound, + }); + + return interpret(ast, context); + }, + getFunctions: () => Object.keys(serverFunctions.toJS()), + }; +}; diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js b/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js new file mode 100644 index 0000000000000..2a19ef81d135e --- /dev/null +++ b/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js @@ -0,0 +1,32 @@ +/* + * 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('babel-register')({ + ignore: [ + // stolen from kibana/src/setup_node_env/babel_register/register.js + // ignore paths matching `/node_modules/{a}/{b}`, unless `a` + // is `x-pack` and `b` is not `node_modules` + /\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, + ], + babelrc: false, + presets: [require.resolve('@kbn/babel-preset/node_preset')], +}); + +require('./polyfill'); +require('./worker'); diff --git a/x-pack/plugins/canvas/server/lib/route_expression/thread/index.js b/src/core_plugins/interpreter/server/lib/route_expression/thread/index.js similarity index 78% rename from x-pack/plugins/canvas/server/lib/route_expression/thread/index.js rename to src/core_plugins/interpreter/server/lib/route_expression/thread/index.js index d3748db02f65c..ff476793325e9 100644 --- a/x-pack/plugins/canvas/server/lib/route_expression/thread/index.js +++ b/src/core_plugins/interpreter/server/lib/route_expression/thread/index.js @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 { fork } from 'child_process'; diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js b/src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js new file mode 100644 index 0000000000000..476777b4bc693 --- /dev/null +++ b/src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js @@ -0,0 +1,31 @@ +/* + * 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. + */ + +// taken from kibana/src/setup_node_env/babel_register/polyfill.js +// ... +// `babel-preset-env` looks for and rewrites the following import +// statement into a list of import statements based on the polyfills +// necessary for our target environment (the current version of node) +// but since it does that during compilation, `import 'babel-polyfill'` +// must be in a file that is loaded with `require()` AFTER `babel-register` +// is configured. +// +// This is why we have this single statement in it's own file and require +// it from ./babeled.js +import 'babel-polyfill'; diff --git a/x-pack/plugins/canvas/server/lib/route_expression/thread/worker.js b/src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js similarity index 62% rename from x-pack/plugins/canvas/server/lib/route_expression/thread/worker.js rename to src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js index d81df410f7af7..5159679bb9f4f 100644 --- a/x-pack/plugins/canvas/server/lib/route_expression/thread/worker.js +++ b/src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js @@ -1,13 +1,26 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 uuid from 'uuid/v4'; -import { populateServerRegistries } from '../../server_registries'; -import { interpretProvider } from '../../../../common/interpreter/interpret'; -import { serializeProvider } from '../../../../common/lib/serialize'; +import { populateServerRegistries } from '@kbn/interpreter/server/server_registries'; +import { interpretProvider } from '@kbn/interpreter/common/interpreter/interpret'; +import { serializeProvider } from '@kbn/interpreter/common/lib/serialize'; // We actually DO need populateServerRegistries here since this is a different node process const pluginsReady = populateServerRegistries(['commonFunctions', 'types']); @@ -44,8 +57,9 @@ process.on('message', msg => { }, }); - if (type === 'getFunctions') + if (type === 'getFunctions') { process.send({ type: 'functionList', value: Object.keys(commonFunctions.toJS()) }); + } if (type === 'msgSuccess') { heap[id].resolve(deserialize(value)); diff --git a/src/core_plugins/interpreter/server/routes/index.js b/src/core_plugins/interpreter/server/routes/index.js new file mode 100644 index 0000000000000..f78baf4ad496d --- /dev/null +++ b/src/core_plugins/interpreter/server/routes/index.js @@ -0,0 +1,28 @@ +/* + * 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 { socketApi } from './socket'; +import { translate } from './translate'; +import { plugins } from './plugins'; + +export function routes(server) { + plugins(server); + socketApi(server); + translate(server); +} diff --git a/src/core_plugins/interpreter/server/routes/plugins.js b/src/core_plugins/interpreter/server/routes/plugins.js new file mode 100644 index 0000000000000..3d8c8614cc107 --- /dev/null +++ b/src/core_plugins/interpreter/server/routes/plugins.js @@ -0,0 +1,35 @@ +/* + * 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 { getPluginStream } from '../lib/get_plugin_stream'; + +export function plugins(server) { + server.route({ + method: 'GET', + path: '/api/canvas/plugins', + handler: function (request) { + const { type } = request.query; + + return getPluginStream(type); + }, + config: { + auth: false, + }, + }); +} diff --git a/x-pack/plugins/canvas/server/routes/socket.js b/src/core_plugins/interpreter/server/routes/socket.js similarity index 68% rename from x-pack/plugins/canvas/server/routes/socket.js rename to src/core_plugins/interpreter/server/routes/socket.js index 8e06c25769d4c..daf16ec7a4432 100644 --- a/x-pack/plugins/canvas/server/routes/socket.js +++ b/src/core_plugins/interpreter/server/routes/socket.js @@ -1,19 +1,32 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 socket from 'socket.io'; -import { serializeProvider } from '../../common/lib/serialize'; -import { typesRegistry } from '../../common/lib/types_registry'; -import { getServerRegistries } from '../lib/server_registries'; -import { routeExpressionProvider } from '../lib/route_expression'; +import { serializeProvider } from '@kbn/interpreter/common/lib/serialize'; +import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; +import { getServerRegistries } from '@kbn/interpreter/server/server_registries'; +import { routeExpressionProvider } from '../lib/route_expression/index'; import { browser } from '../lib/route_expression/browser'; -import { thread } from '../lib/route_expression/thread'; +import { thread } from '../lib/route_expression/thread/index'; import { server as serverEnv } from '../lib/route_expression/server'; import { getRequest } from '../lib/get_request'; -import { API_ROUTE } from '../../common/lib/constants'; +import { API_ROUTE } from '../../common/constants'; async function getModifiedRequest(server, socket) { try { diff --git a/src/core_plugins/interpreter/server/routes/translate.js b/src/core_plugins/interpreter/server/routes/translate.js new file mode 100644 index 0000000000000..865c0da3e0617 --- /dev/null +++ b/src/core_plugins/interpreter/server/routes/translate.js @@ -0,0 +1,48 @@ +/* + * 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 { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; + +export function translate(server) { + /* + Get AST from expression + */ + server.route({ + method: 'GET', + path: '/api/canvas/ast', + handler: function (request, h) { + if (!request.query.expression) { + return h.response({ error: '"expression" query is required' }).code(400); + } + return fromExpression(request.query.expression); + }, + }); + + server.route({ + method: 'POST', + path: '/api/canvas/expression', + handler: function (request, h) { + try { + return toExpression(request.payload); + } catch (e) { + return h.response({ error: e.message }).code(400); + } + }, + }); +} diff --git a/src/optimize/base_optimizer.js b/src/optimize/base_optimizer.js index b0fe947f56920..1bf29fbac1d9d 100644 --- a/src/optimize/base_optimizer.js +++ b/src/optimize/base_optimizer.js @@ -150,8 +150,9 @@ export default class BaseOptimizer { }, { test, - include: /[\/\\]node_modules[\/\\]x-pack[\/\\]/, - exclude: /[\/\\]node_modules[\/\\]x-pack[\/\\](.+?[\/\\])*node_modules[\/\\]/, + include: /[\/\\]node_modules[\/\\](x-pack|@kbn[\/\\]interpreter)[\/\\]/, + exclude: /[\/\\]node_modules[\/\\](x-pack|@kbn[\/\\]interpreter)[\/\\]node_modules[\/\\]/, + } ]; }; diff --git a/src/setup_node_env/babel_register/register.js b/src/setup_node_env/babel_register/register.js index 2d909636a02a8..12690eab8f02c 100644 --- a/src/setup_node_env/babel_register/register.js +++ b/src/setup_node_env/babel_register/register.js @@ -39,7 +39,7 @@ var ignore = [ // ignore paths matching `/node_modules/{a}/{b}`, unless `a` // is `x-pack` and `b` is not `node_modules` - /\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/ + /\/node_modules\/(?!(x-pack\/|@kbn\/interpreter\/)(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/ ]; if (global.__BUILT_WITH_BABEL__) { diff --git a/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_integration.js b/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_integration.js index 34415cb6aeef5..1c8ade94456d0 100644 --- a/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_integration.js +++ b/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_integration.js @@ -201,4 +201,4 @@ describe('createOrUpgradeSavedConfig()', () => { '5.4.0-rc1': true, }); }); -}); \ No newline at end of file +}); diff --git a/x-pack/package.json b/x-pack/package.json index 02a59ea7ff3bc..ec99e4858af6b 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -126,6 +126,7 @@ "@kbn/datemath": "5.0.0", "@kbn/i18n": "1.0.0", "@kbn/ui-framework": "1.0.0", + "@kbn/interpreter": "1.0.0", "@samverschueren/stream-to-observable": "^0.3.0", "@scant/router": "^0.1.0", "@slack/client": "^4.2.2", diff --git a/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js b/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js index 433b5ec64b753..6ca97f159a1d5 100644 --- a/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js +++ b/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Fn } from '../../common/lib/fn'; +import { Fn } from '@kbn/interpreter/common/lib/fn'; import { functions as browserFns } from '../../canvas_plugin_src/functions/browser'; import { functions as commonFns } from '../../canvas_plugin_src/functions/common'; import { functions as serverFns } from '../../canvas_plugin_src/functions/server/src'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js index c85cc9e0d5baf..fcda50653380c 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '../../../common/lib/get_type'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; export const asFn = () => ({ name: 'as', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clog.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clog.js deleted file mode 100644 index db4cc4179762f..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clog.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const clog = () => ({ - name: 'clog', - help: 'Outputs the context to the console', - fn: context => { - console.log(context); //eslint-disable-line no-console - return context; - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/index.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/index.js index 410dbc60db952..f20c78bb1fa07 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/index.js @@ -11,7 +11,6 @@ import { asFn } from './as'; import { axisConfig } from './axisConfig'; import { compare } from './compare'; import { containerStyle } from './containerStyle'; -import { clog } from './clog'; import { context } from './context'; import { columns } from './columns'; import { csv } from './csv'; @@ -65,7 +64,6 @@ export const functions = [ any, asFn, axisConfig, - clog, columns, compare, containerStyle, diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js index db55780205296..c02c6a2d2691b 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '../../../common/lib/get_type'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; export const mapColumn = () => ({ name: 'mapColumn', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js index 1a8ee7daf7370..ce4b9170d1710 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js @@ -5,7 +5,7 @@ */ import { get, map } from 'lodash'; -import { getType } from '../../../../common/lib/get_type'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; export const getFlotAxisConfig = (axis, argValue, { columns, ticks, font } = {}) => { if (!argValue || argValue.show === false) return { show: false }; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js index 77580be49719a..b144cf179652d 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '../../../common/lib/get_type'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; export const staticColumn = () => ({ name: 'staticColumn', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js index 863fa41a90be5..04f92bc475256 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js @@ -7,7 +7,7 @@ import ReactDOM from 'react-dom'; import React from 'react'; import { get } from 'lodash'; -import { fromExpression, toExpression } from '../../../common/lib/ast'; +import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; import { DropdownFilter } from './component'; export const dropdownFilter = () => ({ diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js index d04a8f0b54d96..7ace73bc430d5 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js @@ -7,7 +7,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { get } from 'lodash'; -import { fromExpression } from '../../../../../common/lib/ast'; +import { fromExpression } from '@kbn/interpreter/common/lib/ast'; import { TimePicker } from '../time_picker'; import { TimePickerMini } from '../time_picker_mini'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js index cdc4f563e1340..2ffc7bcf44208 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js @@ -7,7 +7,7 @@ import ReactDOM from 'react-dom'; import React from 'react'; import { get, set } from 'lodash'; -import { fromExpression, toExpression } from '../../../common/lib/ast'; +import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; import { TimeFilter } from './components/time_filter'; export const timeFilter = () => ({ diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/boolean.js b/x-pack/plugins/canvas/canvas_plugin_src/types/boolean.js deleted file mode 100644 index 697277a471fea..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/boolean.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const boolean = () => ({ - name: 'boolean', - from: { - null: () => false, - number: n => Boolean(n), - string: s => Boolean(s), - }, - to: { - render: value => { - const text = `${value}`; - return { - type: 'render', - as: 'text', - value: { text }, - }; - }, - datatable: value => ({ - type: 'datatable', - columns: [{ name: 'value', type: 'boolean' }], - rows: [{ value }], - }), - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/error.js b/x-pack/plugins/canvas/canvas_plugin_src/types/error.js deleted file mode 100644 index 51051c804db56..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/error.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const error = () => ({ - name: 'error', - to: { - render: input => { - const { error, info } = input; - return { - type: 'render', - as: 'error', - value: { - error, - info, - }, - }; - }, - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/filter.js b/x-pack/plugins/canvas/canvas_plugin_src/types/filter.js deleted file mode 100644 index 8627dd20bb89f..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/filter.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const filter = () => ({ - name: 'filter', - from: { - null: () => { - return { - type: 'filter', - // Any meta data you wish to pass along. - meta: {}, - // And filters. If you need an "or", create a filter type for it. - and: [], - }; - }, - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/image.js b/x-pack/plugins/canvas/canvas_plugin_src/types/image.js deleted file mode 100644 index f63d3f1b8b2aa..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/image.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const image = () => ({ - name: 'image', - to: { - render: input => { - return { - type: 'render', - as: 'image', - value: input, - }; - }, - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/index.js b/x-pack/plugins/canvas/canvas_plugin_src/types/index.js deleted file mode 100644 index 2e9a4fa02ef8e..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { boolean } from './boolean'; -import { datatable } from './datatable'; -import { error } from './error'; -import { filter } from './filter'; -import { image } from './image'; -import { nullType } from './null'; -import { number } from './number'; -import { pointseries } from './pointseries'; -import { render } from './render'; -import { shape } from './shape'; -import { string } from './string'; -import { style } from './style'; - -export const typeSpecs = [ - boolean, - datatable, - error, - filter, - image, - number, - nullType, - pointseries, - render, - shape, - string, - style, -]; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/null.js b/x-pack/plugins/canvas/canvas_plugin_src/types/null.js deleted file mode 100644 index 27e9cdf59b004..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/null.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const nullType = () => ({ - name: 'null', - from: { - '*': () => null, - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/number.js b/x-pack/plugins/canvas/canvas_plugin_src/types/number.js deleted file mode 100644 index 63ee587075fdd..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/number.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const number = () => ({ - name: 'number', - from: { - null: () => 0, - boolean: b => Number(b), - string: n => Number(n), - }, - to: { - render: value => { - const text = `${value}`; - return { - type: 'render', - as: 'text', - value: { text }, - }; - }, - datatable: value => ({ - type: 'datatable', - columns: [{ name: 'value', type: 'number' }], - rows: [{ value }], - }), - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/pointseries.js b/x-pack/plugins/canvas/canvas_plugin_src/types/pointseries.js deleted file mode 100644 index 1a00738620050..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/pointseries.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const pointseries = () => ({ - name: 'pointseries', - from: { - null: () => { - return { - type: 'pointseries', - rows: [], - columns: [], - }; - }, - }, - to: { - render: (pointseries, types) => { - const datatable = types.datatable.from(pointseries, types); - return { - type: 'render', - as: 'table', - value: { - datatable, - showHeader: true, - }, - }; - }, - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/register.js b/x-pack/plugins/canvas/canvas_plugin_src/types/register.js deleted file mode 100644 index e960dd0f6566a..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/register.js +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import 'babel-polyfill'; -import { typeSpecs } from './index'; - -typeSpecs.forEach(canvas.register); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/render.js b/x-pack/plugins/canvas/canvas_plugin_src/types/render.js deleted file mode 100644 index 0f261f0398816..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/render.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const render = () => ({ - name: 'render', - from: { - '*': v => ({ - type: 'render', - as: 'debug', - value: v, - }), - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/shape.js b/x-pack/plugins/canvas/canvas_plugin_src/types/shape.js deleted file mode 100644 index 1b306b7b1c391..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/shape.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const shape = () => ({ - name: 'shape', - to: { - render: input => { - return { - type: 'render', - as: 'shape', - value: input, - }; - }, - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/string.js b/x-pack/plugins/canvas/canvas_plugin_src/types/string.js deleted file mode 100644 index c8d58aaaffbca..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/string.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const string = () => ({ - name: 'string', - from: { - null: () => '', - boolean: b => String(b), - number: n => String(n), - }, - to: { - render: text => { - return { - type: 'render', - as: 'text', - value: { text }, - }; - }, - datatable: value => ({ - type: 'datatable', - columns: [{ name: 'value', type: 'string' }], - rows: [{ value }], - }), - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/style.js b/x-pack/plugins/canvas/canvas_plugin_src/types/style.js deleted file mode 100644 index 62632c03231ad..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/types/style.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const style = () => ({ - name: 'style', - from: { - null: () => { - return { - type: 'style', - spec: {}, - css: '', - }; - }, - }, -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js index 0540a14603460..64a426a84a7cd 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js @@ -9,8 +9,8 @@ import { compose, withPropsOnChange, withHandlers } from 'recompose'; import PropTypes from 'prop-types'; import { EuiSelect, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { sortBy } from 'lodash'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; import { createStatefulPropHoc } from '../../../../public/components/enhance/stateful_prop'; -import { getType } from '../../../../common/lib/get_type'; import { templateFromReactComponent } from '../../../../public/lib/template_from_react_component'; import { SimpleMathFunction } from './simple_math_function'; import { getFormObject } from './get_form_object'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js index e0f8e56df8b6f..fc0f89692f646 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js @@ -7,8 +7,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import { get } from 'lodash'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; import { PalettePicker } from '../../../public/components/palette_picker'; -import { getType } from '../../../common/lib/get_type'; import { templateFromReactComponent } from '../../../public/lib/template_from_react_component'; const PaletteArgInput = ({ onValueChange, argValue, renderError }) => { diff --git a/x-pack/plugins/canvas/common/functions/to.js b/x-pack/plugins/canvas/common/functions/to.js index 6f15569c27a11..25446b2868652 100644 --- a/x-pack/plugins/canvas/common/functions/to.js +++ b/x-pack/plugins/canvas/common/functions/to.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { castProvider } from '../interpreter/cast'; +import { castProvider } from '@kbn/interpreter/common/interpreter/cast'; export const to = () => ({ name: 'to', diff --git a/x-pack/plugins/canvas/common/interpreter/create_error.js b/x-pack/plugins/canvas/common/interpreter/create_error.js deleted file mode 100644 index 5de9819330dbd..0000000000000 --- a/x-pack/plugins/canvas/common/interpreter/create_error.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const createError = err => ({ - type: 'error', - error: { - stack: process.env.NODE_ENV === 'production' ? undefined : err.stack, - message: typeof err === 'string' ? err : err.message, - }, -}); diff --git a/x-pack/plugins/canvas/common/lib/__tests__/arg.js b/x-pack/plugins/canvas/common/lib/__tests__/arg.js deleted file mode 100644 index f8badc67175ac..0000000000000 --- a/x-pack/plugins/canvas/common/lib/__tests__/arg.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from 'expect.js'; -import { Arg } from '../arg'; - -describe('Arg', () => { - it('sets required to false by default', () => { - const isOptional = new Arg({ - name: 'optional_me', - }); - expect(isOptional.required).to.equal(false); - - const isRequired = new Arg({ - name: 'require_me', - required: true, - }); - expect(isRequired.required).to.equal(true); - }); -}); diff --git a/x-pack/plugins/canvas/common/lib/__tests__/get_by_alias.js b/x-pack/plugins/canvas/common/lib/__tests__/get_by_alias.js deleted file mode 100644 index eaeeeade4cc59..0000000000000 --- a/x-pack/plugins/canvas/common/lib/__tests__/get_by_alias.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from 'expect.js'; -import { getByAlias } from '../get_by_alias'; - -describe('getByAlias', () => { - const fnsObject = { - foo: { name: 'foo', aliases: ['f'] }, - bar: { name: 'bar', aliases: ['b'] }, - }; - - const fnsArray = [{ name: 'foo', aliases: ['f'] }, { name: 'bar', aliases: ['b'] }]; - - it('returns the function by name', () => { - expect(getByAlias(fnsObject, 'foo')).to.be(fnsObject.foo); - expect(getByAlias(fnsObject, 'bar')).to.be(fnsObject.bar); - expect(getByAlias(fnsArray, 'foo')).to.be(fnsArray[0]); - expect(getByAlias(fnsArray, 'bar')).to.be(fnsArray[1]); - }); - - it('returns the function by alias', () => { - expect(getByAlias(fnsObject, 'f')).to.be(fnsObject.foo); - expect(getByAlias(fnsObject, 'b')).to.be(fnsObject.bar); - expect(getByAlias(fnsArray, 'f')).to.be(fnsArray[0]); - expect(getByAlias(fnsArray, 'b')).to.be(fnsArray[1]); - }); - - it('returns the function by case-insensitive name', () => { - expect(getByAlias(fnsObject, 'FOO')).to.be(fnsObject.foo); - expect(getByAlias(fnsObject, 'BAR')).to.be(fnsObject.bar); - expect(getByAlias(fnsArray, 'FOO')).to.be(fnsArray[0]); - expect(getByAlias(fnsArray, 'BAR')).to.be(fnsArray[1]); - }); - - it('returns the function by case-insensitive alias', () => { - expect(getByAlias(fnsObject, 'F')).to.be(fnsObject.foo); - expect(getByAlias(fnsObject, 'B')).to.be(fnsObject.bar); - expect(getByAlias(fnsArray, 'F')).to.be(fnsArray[0]); - expect(getByAlias(fnsArray, 'B')).to.be(fnsArray[1]); - }); - - it('handles empty strings', () => { - const emptyStringFnsObject = { '': { name: '' } }; - const emptyStringAliasFnsObject = { foo: { name: 'foo', aliases: [''] } }; - expect(getByAlias(emptyStringFnsObject, '')).to.be(emptyStringFnsObject['']); - expect(getByAlias(emptyStringAliasFnsObject, '')).to.be(emptyStringAliasFnsObject.foo); - - const emptyStringFnsArray = [{ name: '' }]; - const emptyStringAliasFnsArray = [{ name: 'foo', aliases: [''] }]; - expect(getByAlias(emptyStringFnsArray, '')).to.be(emptyStringFnsArray[0]); - expect(getByAlias(emptyStringAliasFnsArray, '')).to.be(emptyStringAliasFnsArray[0]); - }); - - it('handles "undefined" strings', () => { - const undefinedFnsObject = { undefined: { name: 'undefined' } }; - const undefinedAliasFnsObject = { foo: { name: 'undefined', aliases: ['undefined'] } }; - expect(getByAlias(undefinedFnsObject, 'undefined')).to.be(undefinedFnsObject.undefined); - expect(getByAlias(undefinedAliasFnsObject, 'undefined')).to.be(undefinedAliasFnsObject.foo); - - const emptyStringFnsArray = [{ name: 'undefined' }]; - const emptyStringAliasFnsArray = [{ name: 'foo', aliases: ['undefined'] }]; - expect(getByAlias(emptyStringFnsArray, 'undefined')).to.be(emptyStringFnsArray[0]); - expect(getByAlias(emptyStringAliasFnsArray, 'undefined')).to.be(emptyStringAliasFnsArray[0]); - }); - - it('returns undefined if not found', () => { - expect(getByAlias(fnsObject, 'baz')).to.be(undefined); - expect(getByAlias(fnsArray, 'baz')).to.be(undefined); - }); -}); diff --git a/x-pack/plugins/canvas/common/lib/arg.js b/x-pack/plugins/canvas/common/lib/arg.js deleted file mode 100644 index 7713fcb342bc2..0000000000000 --- a/x-pack/plugins/canvas/common/lib/arg.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { includes } from 'lodash'; - -export function Arg(config) { - if (config.name === '_') throw Error('Arg names must not be _. Use it in aliases instead.'); - this.name = config.name; - this.required = config.required || false; - this.help = config.help || ''; - this.types = config.types || []; - this.default = config.default; - this.aliases = config.aliases || []; - this.multi = config.multi == null ? false : config.multi; - this.resolve = config.resolve == null ? true : config.resolve; - this.options = config.options || []; - this.accepts = type => { - if (!this.types.length) return true; - return includes(config.types, type); - }; -} diff --git a/x-pack/plugins/canvas/common/lib/autocomplete.js b/x-pack/plugins/canvas/common/lib/autocomplete.js index d87e199de4671..5a18c2570919b 100644 --- a/x-pack/plugins/canvas/common/lib/autocomplete.js +++ b/x-pack/plugins/canvas/common/lib/autocomplete.js @@ -5,8 +5,8 @@ */ import { uniq } from 'lodash'; -import { parse } from './grammar'; -import { getByAlias } from './get_by_alias'; +import { parse } from '@kbn/interpreter/common/lib/grammar'; +import { getByAlias } from '@kbn/interpreter/common/lib/get_by_alias'; const MARKER = 'CANVAS_SUGGESTION_MARKER'; diff --git a/x-pack/plugins/canvas/common/lib/functions_registry.js b/x-pack/plugins/canvas/common/lib/functions_registry.js deleted file mode 100644 index af8e8f0b122d0..0000000000000 --- a/x-pack/plugins/canvas/common/lib/functions_registry.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Registry } from '../../common/lib/registry'; -import { Fn } from '../lib/fn'; - -class FunctionsRegistry extends Registry { - wrapper(obj) { - return new Fn(obj); - } -} - -export const functionsRegistry = new FunctionsRegistry(); diff --git a/x-pack/plugins/canvas/common/lib/get_by_alias.js b/x-pack/plugins/canvas/common/lib/get_by_alias.js deleted file mode 100644 index c9986a5024008..0000000000000 --- a/x-pack/plugins/canvas/common/lib/get_by_alias.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** - * This is used for looking up function/argument definitions. It looks through - * the given object/array for a case-insensitive match, which could be either the - * `name` itself, or something under the `aliases` property. - */ -export function getByAlias(specs, name) { - const lowerCaseName = name.toLowerCase(); - return Object.values(specs).find(({ name, aliases }) => { - if (name.toLowerCase() === lowerCaseName) return true; - return (aliases || []).some(alias => { - return alias.toLowerCase() === lowerCaseName; - }); - }); -} diff --git a/x-pack/plugins/canvas/common/lib/get_type.js b/x-pack/plugins/canvas/common/lib/get_type.js deleted file mode 100644 index 8d2b5a13cb283..0000000000000 --- a/x-pack/plugins/canvas/common/lib/get_type.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export function getType(node) { - if (node == null) return 'null'; - if (typeof node === 'object') { - if (!node.type) throw new Error('Objects must have a type propery'); - return node.type; - } - - return typeof node; -} diff --git a/x-pack/plugins/canvas/common/lib/index.js b/x-pack/plugins/canvas/common/lib/index.js index 5d56a5026590d..321a4abff44e0 100644 --- a/x-pack/plugins/canvas/common/lib/index.js +++ b/x-pack/plugins/canvas/common/lib/index.js @@ -5,8 +5,6 @@ */ export * from './datatable'; -export * from './arg'; -export * from './ast'; export * from './autocomplete'; export * from './constants'; export * from './dataurl'; @@ -14,15 +12,10 @@ export * from './errors'; export * from './expression_form_handlers'; export * from './fetch'; export * from './find_in_object'; -export * from './fn'; export * from './fonts'; -export * from './functions_registry'; -export * from './get_by_alias'; export * from './get_colors_from_palette'; export * from './get_field_type'; export * from './get_legend_config'; -export * from './get_type'; -export * from './grammar'; export * from './handlebars'; export * from './hex_to_rgb'; export * from './httpurl'; @@ -30,10 +23,6 @@ export * from './latest_change'; export * from './missing_asset'; export * from './palettes'; export * from './pivot_object_array'; -export * from './registry'; export * from './resolve_dataurl'; -export * from './serialize'; -export * from './type'; -export * from './types_registry'; export * from './unquote_string'; export * from './url'; diff --git a/x-pack/plugins/canvas/common/lib/serialize.js b/x-pack/plugins/canvas/common/lib/serialize.js deleted file mode 100644 index 0786f6f06b3a3..0000000000000 --- a/x-pack/plugins/canvas/common/lib/serialize.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { get, identity } from 'lodash'; -import { getType } from '../lib/get_type'; - -export function serializeProvider(types) { - return { - serialize: provider('serialize'), - deserialize: provider('deserialize'), - }; - - function provider(key) { - return context => { - const type = getType(context); - const typeDef = types[type]; - const fn = get(typeDef, key) || identity; - return fn(context); - }; - } -} diff --git a/x-pack/plugins/canvas/common/lib/types_registry.js b/x-pack/plugins/canvas/common/lib/types_registry.js deleted file mode 100644 index 3d2bb65e9fa0f..0000000000000 --- a/x-pack/plugins/canvas/common/lib/types_registry.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Registry } from '../../common/lib/registry'; -import { Type } from '../../common/lib/type'; - -class TypesRegistry extends Registry { - wrapper(obj) { - return new Type(obj); - } -} - -export const typesRegistry = new TypesRegistry(); diff --git a/x-pack/plugins/canvas/index.js b/x-pack/plugins/canvas/index.js index b92e29341a14b..0f34eef6c2edb 100644 --- a/x-pack/plugins/canvas/index.js +++ b/x-pack/plugins/canvas/index.js @@ -5,9 +5,11 @@ */ import { resolve } from 'path'; +import { pathsRegistry } from '@kbn/interpreter/common/lib/paths_registry'; import init from './init'; import { mappings } from './server/mappings'; import { CANVAS_APP } from './common/lib/constants'; +import { pluginPaths } from './plugin_paths'; export function canvas(kibana) { return new kibana.Plugin({ @@ -39,6 +41,9 @@ export function canvas(kibana) { }).default(); }, + preInit: () => { + pathsRegistry.registerAll(pluginPaths); + }, init, }); } diff --git a/x-pack/plugins/canvas/init.js b/x-pack/plugins/canvas/init.js index 1ef56fac4e97c..70a8db10d7e66 100644 --- a/x-pack/plugins/canvas/init.js +++ b/x-pack/plugins/canvas/init.js @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ +import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; +import { getServerRegistries } from '@kbn/interpreter/server/server_registries'; import { routes } from './server/routes'; -import { functionsRegistry } from './common/lib'; import { commonFunctions } from './common/functions'; -import { populateServerRegistries } from './server/lib/server_registries'; import { registerCanvasUsageCollector } from './server/usage'; import { loadSampleData } from './server/sample_data'; @@ -34,6 +34,6 @@ export default async function(server /*options*/) { loadSampleData(server); // Do not initialize the app until the registries are populated - await populateServerRegistries(['serverFunctions', 'types']); + await getServerRegistries(); routes(server); } diff --git a/x-pack/plugins/canvas/plugin_paths.js b/x-pack/plugins/canvas/plugin_paths.js new file mode 100644 index 0000000000000..9c9f5d1c49bde --- /dev/null +++ b/x-pack/plugins/canvas/plugin_paths.js @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { resolve } from 'path'; + +export const pluginPaths = { + serverFunctions: resolve(__dirname, 'canvas_plugin/functions/server'), + browserFunctions: resolve(__dirname, 'canvas_plugin/functions/browser'), + commonFunctions: resolve(__dirname, 'canvas_plugin/functions/common'), + elements: resolve(__dirname, 'canvas_plugin/elements'), + renderers: resolve(__dirname, 'canvas_plugin/renderers'), + interfaces: resolve(__dirname, 'canvas_plugin/interfaces'), + transformUIs: resolve(__dirname, 'canvas_plugin/uis/transforms'), + datasourceUIs: resolve(__dirname, 'canvas_plugin/uis/datasources'), + modelUIs: resolve(__dirname, 'canvas_plugin/uis/models'), + viewUIs: resolve(__dirname, 'canvas_plugin/uis/views'), + argumentUIs: resolve(__dirname, 'canvas_plugin/uis/arguments'), +}; diff --git a/x-pack/plugins/canvas/public/components/app/index.js b/x-pack/plugins/canvas/public/components/app/index.js index 5f633169604d6..b776bf59efc99 100644 --- a/x-pack/plugins/canvas/public/components/app/index.js +++ b/x-pack/plugins/canvas/public/components/app/index.js @@ -4,15 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ +import { createSocket } from '@kbn/interpreter/public/socket'; +import { initialize as initializeInterpreter } from '@kbn/interpreter/public/interpreter'; import { connect } from 'react-redux'; import { compose, withProps } from 'recompose'; -import { createSocket } from '../../socket'; -import { initialize as initializeInterpreter } from '../../lib/interpreter'; -import { populateBrowserRegistries } from '../../lib/browser_registries'; +import { populateBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; import { getAppReady, getBasePath } from '../../state/selectors/app'; import { appReady, appError } from '../../state/actions/app'; -import { trackRouteChange } from './track_route_change'; +import { loadPrivateBrowserFunctions } from '../../lib/load_private_browser_functions'; +import { elementsRegistry } from '../../lib/elements_registry'; +import { renderFunctionsRegistry } from '../../lib/render_functions_registry'; +import { + argTypeRegistry, + datasourceRegistry, + modelRegistry, + transformRegistry, + viewRegistry, +} from '../../expression_types'; import { App as Component } from './app'; +import { trackRouteChange } from './track_route_change'; const mapStateToProps = state => { // appReady could be an error object @@ -24,13 +34,24 @@ const mapStateToProps = state => { }; }; +const types = { + elements: elementsRegistry, + renderers: renderFunctionsRegistry, + transformUIs: transformRegistry, + datasourceUIs: datasourceRegistry, + modelUIs: modelRegistry, + viewUIs: viewRegistry, + argumentUIs: argTypeRegistry, +}; + const mapDispatchToProps = dispatch => ({ // TODO: the correct socket path should come from upstream, using the constant here is not ideal setAppReady: basePath => async () => { try { // initialize the socket and interpreter await createSocket(basePath); - await populateBrowserRegistries(); + loadPrivateBrowserFunctions(); + await populateBrowserRegistries(types); await initializeInterpreter(); // set app state to ready diff --git a/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js b/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js index 2bd779de759d9..13ecfe89bb922 100644 --- a/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js +++ b/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js @@ -8,8 +8,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import { compose, withProps, withPropsOnChange } from 'recompose'; import { EuiForm, EuiTextArea, EuiButton, EuiButtonEmpty, EuiFormRow } from '@elastic/eui'; +import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; import { createStatefulPropHoc } from '../../components/enhance/stateful_prop'; -import { fromExpression, toExpression } from '../../../common/lib/ast'; export const AdvancedFailureComponent = props => { const { diff --git a/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js b/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js index 8b21c38a5f6f7..f1f3fb2ddae97 100644 --- a/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js +++ b/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ +import { interpretAst } from '@kbn/interpreter/public/interpreter'; import { pure, compose, lifecycle, withState, branch, renderComponent } from 'recompose'; import { PropTypes } from 'prop-types'; import { Loading } from '../../loading'; -import { interpretAst } from '../../../lib/interpreter'; import { DatasourcePreview as Component } from './datasource_preview'; export const DatasourcePreview = compose( diff --git a/x-pack/plugins/canvas/public/components/element_content/element_content.js b/x-pack/plugins/canvas/public/components/element_content/element_content.js index 4a62f219b2ba5..40cca930827db 100644 --- a/x-pack/plugins/canvas/public/components/element_content/element_content.js +++ b/x-pack/plugins/canvas/public/components/element_content/element_content.js @@ -8,7 +8,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { pure, compose, branch, renderComponent } from 'recompose'; import Style from 'style-it'; -import { getType } from '../../../common/lib/get_type'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; import { Loading } from '../loading'; import { RenderWithFn } from '../render_with_fn'; import { ElementShareContainer } from '../element_share_container'; diff --git a/x-pack/plugins/canvas/public/components/expression/index.js b/x-pack/plugins/canvas/public/components/expression/index.js index 18690529d4e80..81d73959e83b8 100644 --- a/x-pack/plugins/canvas/public/components/expression/index.js +++ b/x-pack/plugins/canvas/public/components/expression/index.js @@ -15,9 +15,9 @@ import { branch, renderComponent, } from 'recompose'; +import { fromExpression } from '@kbn/interpreter/common/lib/ast'; import { getSelectedPage, getSelectedElement } from '../../state/selectors/workpad'; import { setExpression, flushContext } from '../../state/actions/elements'; -import { fromExpression } from '../../../common/lib/ast'; import { getFunctionDefinitions } from '../../lib/function_definitions'; import { getWindow } from '../../lib/get_window'; import { ElementNotSelected } from './element_not_selected'; diff --git a/x-pack/plugins/canvas/public/components/function_form_list/index.js b/x-pack/plugins/canvas/public/components/function_form_list/index.js index 8b6702d94340f..84748f5bbbbb3 100644 --- a/x-pack/plugins/canvas/public/components/function_form_list/index.js +++ b/x-pack/plugins/canvas/public/components/function_form_list/index.js @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ +import { interpretAst } from '@kbn/interpreter/public/interpreter'; import { compose, withProps } from 'recompose'; import { get } from 'lodash'; +import { toExpression } from '@kbn/interpreter/common/lib/ast'; import { modelRegistry, viewRegistry, transformRegistry } from '../../expression_types'; -import { interpretAst } from '../../lib/interpreter'; -import { toExpression } from '../../../common/lib/ast'; import { FunctionFormList as Component } from './function_form_list'; function normalizeContext(chain) { diff --git a/x-pack/plugins/canvas/public/expression_types/arg_type.js b/x-pack/plugins/canvas/public/expression_types/arg_type.js index 76f29afee7185..a19c726e138c2 100644 --- a/x-pack/plugins/canvas/public/expression_types/arg_type.js +++ b/x-pack/plugins/canvas/public/expression_types/arg_type.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '../../common/lib/registry'; +import { Registry } from '@kbn/interpreter/common/lib/registry'; import { BaseForm } from './base_form'; export class ArgType extends BaseForm { diff --git a/x-pack/plugins/canvas/public/expression_types/datasource.js b/x-pack/plugins/canvas/public/expression_types/datasource.js index 858be2b4e33dd..cd9a8af5f0182 100644 --- a/x-pack/plugins/canvas/public/expression_types/datasource.js +++ b/x-pack/plugins/canvas/public/expression_types/datasource.js @@ -6,7 +6,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Registry } from '../../common/lib/registry'; +import { Registry } from '@kbn/interpreter/common/lib/registry'; import { RenderToDom } from '../components/render_to_dom'; import { ExpressionFormHandlers } from '../../common/lib/expression_form_handlers'; import { BaseForm } from './base_form'; diff --git a/x-pack/plugins/canvas/public/expression_types/function_form.js b/x-pack/plugins/canvas/public/expression_types/function_form.js index 70da0004ab175..c7bc16a5b2e2b 100644 --- a/x-pack/plugins/canvas/public/expression_types/function_form.js +++ b/x-pack/plugins/canvas/public/expression_types/function_form.js @@ -7,7 +7,7 @@ import { EuiCallOut } from '@elastic/eui'; import React from 'react'; import { isPlainObject, uniq, last, compact } from 'lodash'; -import { fromExpression } from '../../common/lib/ast'; +import { fromExpression } from '@kbn/interpreter/common/lib/ast'; import { ArgAddPopover } from '../components/arg_add_popover'; import { SidebarSection } from '../components/sidebar/sidebar_section'; import { SidebarSectionTitle } from '../components/sidebar/sidebar_section_title'; diff --git a/x-pack/plugins/canvas/public/expression_types/model.js b/x-pack/plugins/canvas/public/expression_types/model.js index bae74d75589be..7ce1126bdec55 100644 --- a/x-pack/plugins/canvas/public/expression_types/model.js +++ b/x-pack/plugins/canvas/public/expression_types/model.js @@ -5,7 +5,7 @@ */ import { get, pick } from 'lodash'; -import { Registry } from '../../common/lib/registry'; +import { Registry } from '@kbn/interpreter/common/lib/registry'; import { FunctionForm } from './function_form'; const NO_NEXT_EXP = 'no next expression'; diff --git a/x-pack/plugins/canvas/public/expression_types/transform.js b/x-pack/plugins/canvas/public/expression_types/transform.js index 216e79b9c106c..760eae46195d6 100644 --- a/x-pack/plugins/canvas/public/expression_types/transform.js +++ b/x-pack/plugins/canvas/public/expression_types/transform.js @@ -5,7 +5,7 @@ */ import { pick } from 'lodash'; -import { Registry } from '../../common/lib/registry'; +import { Registry } from '@kbn/interpreter/common/lib/registry'; import { FunctionForm } from './function_form'; export class Transform extends FunctionForm { diff --git a/x-pack/plugins/canvas/public/expression_types/view.js b/x-pack/plugins/canvas/public/expression_types/view.js index ee83fe3340d76..1b7fe13d508b0 100644 --- a/x-pack/plugins/canvas/public/expression_types/view.js +++ b/x-pack/plugins/canvas/public/expression_types/view.js @@ -5,7 +5,7 @@ */ import { pick } from 'lodash'; -import { Registry } from '../../common/lib/registry'; +import { Registry } from '@kbn/interpreter/common/lib/registry'; import { FunctionForm } from './function_form'; export class View extends FunctionForm { diff --git a/x-pack/plugins/canvas/public/functions/filters.js b/x-pack/plugins/canvas/public/functions/filters.js index a6f8d2a63fc5e..3c578a93fc3b6 100644 --- a/x-pack/plugins/canvas/public/functions/filters.js +++ b/x-pack/plugins/canvas/public/functions/filters.js @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { fromExpression } from '../../common/lib/ast'; -import { typesRegistry } from '../../common/lib/types_registry'; +import { interpretAst } from '@kbn/interpreter/public/interpreter'; +import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; import { getState } from '../state/store'; import { getGlobalFilterExpression } from '../state/selectors/workpad'; -import { interpretAst } from '../lib/interpreter'; export const filters = () => ({ name: 'filters', diff --git a/x-pack/plugins/canvas/public/lib/arg_helpers.js b/x-pack/plugins/canvas/public/lib/arg_helpers.js index e53e26b62dd15..e1cd8b64b323f 100644 --- a/x-pack/plugins/canvas/public/lib/arg_helpers.js +++ b/x-pack/plugins/canvas/public/lib/arg_helpers.js @@ -5,7 +5,7 @@ */ import { includes } from 'lodash'; -import { getType } from '../../common/lib/get_type'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; /* diff --git a/x-pack/plugins/canvas/public/lib/browser_registries.js b/x-pack/plugins/canvas/public/lib/browser_registries.js deleted file mode 100644 index efceec04d6dce..0000000000000 --- a/x-pack/plugins/canvas/public/lib/browser_registries.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; -import $script from 'scriptjs'; -import { typesRegistry } from '../../common/lib/types_registry'; -import { - argTypeRegistry, - datasourceRegistry, - transformRegistry, - modelRegistry, - viewRegistry, -} from '../expression_types'; -import { elementsRegistry } from './elements_registry'; -import { renderFunctionsRegistry } from './render_functions_registry'; -import { functionsRegistry as browserFunctions } from './functions_registry'; -import { loadPrivateBrowserFunctions } from './load_private_browser_functions'; - -const registries = { - browserFunctions: browserFunctions, - commonFunctions: browserFunctions, - elements: elementsRegistry, - types: typesRegistry, - renderers: renderFunctionsRegistry, - transformUIs: transformRegistry, - datasourceUIs: datasourceRegistry, - modelUIs: modelRegistry, - viewUIs: viewRegistry, - argumentUIs: argTypeRegistry, -}; - -let resolve = null; -let called = false; - -const populatePromise = new Promise(_resolve => { - resolve = _resolve; -}); - -export const getBrowserRegistries = () => { - return populatePromise; -}; - -export const populateBrowserRegistries = () => { - if (called) throw new Error('function should only be called once per process'); - called = true; - - // loadPrivateBrowserFunctions is sync. No biggie. - loadPrivateBrowserFunctions(); - - const remainingTypes = Object.keys(registries); - const populatedTypes = {}; - - function loadType() { - const type = remainingTypes.pop(); - window.canvas = window.canvas || {}; - window.canvas.register = d => registries[type].register(d); - - // Load plugins one at a time because each needs a different loader function - // $script will only load each of these once, we so can call this as many times as we need? - const pluginPath = chrome.addBasePath(`/api/canvas/plugins?type=${type}`); - $script(pluginPath, () => { - populatedTypes[type] = registries[type]; - - if (remainingTypes.length) loadType(); - else resolve(populatedTypes); - }); - } - - if (remainingTypes.length) loadType(); - return populatePromise; -}; diff --git a/x-pack/plugins/canvas/public/lib/create_handlers.js b/x-pack/plugins/canvas/public/lib/create_handlers.js deleted file mode 100644 index 93247210eb291..0000000000000 --- a/x-pack/plugins/canvas/public/lib/create_handlers.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export function createHandlers(/*socket*/) { - return { - environment: 'client', - }; -} diff --git a/x-pack/plugins/canvas/public/lib/elements_registry.js b/x-pack/plugins/canvas/public/lib/elements_registry.js index 898fba183c9f5..dc3d743f49877 100644 --- a/x-pack/plugins/canvas/public/lib/elements_registry.js +++ b/x-pack/plugins/canvas/public/lib/elements_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '../../common/lib/registry'; +import { Registry } from '@kbn/interpreter/common/lib/registry'; import { Element } from './element'; class ElementsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/function_definitions.js b/x-pack/plugins/canvas/public/lib/function_definitions.js index c4bc16a4c94c3..c0f3496dfc083 100644 --- a/x-pack/plugins/canvas/public/lib/function_definitions.js +++ b/x-pack/plugins/canvas/public/lib/function_definitions.js @@ -5,8 +5,8 @@ */ import uniqBy from 'lodash.uniqby'; +import { getBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; import { getServerFunctions } from '../state/selectors/app'; -import { getBrowserRegistries } from './browser_registries'; export async function getFunctionDefinitions(state) { const { browserFunctions } = await getBrowserRegistries(); diff --git a/x-pack/plugins/canvas/public/lib/functions_registry.js b/x-pack/plugins/canvas/public/lib/functions_registry.js index 3cc084d8ca66e..36f9a631f06ea 100644 --- a/x-pack/plugins/canvas/public/lib/functions_registry.js +++ b/x-pack/plugins/canvas/public/lib/functions_registry.js @@ -5,4 +5,4 @@ */ // export the common registry here, so it's available in plugin public code -export { functionsRegistry } from '../../common/lib/functions_registry'; +export { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; diff --git a/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js b/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js index f8eec880af624..696c058e34a2b 100644 --- a/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js +++ b/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js @@ -5,7 +5,7 @@ */ import { get, mapValues, map } from 'lodash'; -import { fromExpression } from '../../common/lib/ast'; +import { fromExpression } from '@kbn/interpreter/common/lib/ast'; export function parseSingleFunctionChain(filterString) { const ast = fromExpression(filterString); diff --git a/x-pack/plugins/canvas/public/lib/render_functions_registry.js b/x-pack/plugins/canvas/public/lib/render_functions_registry.js index 3d040047aeb9a..a34ed009a33b1 100644 --- a/x-pack/plugins/canvas/public/lib/render_functions_registry.js +++ b/x-pack/plugins/canvas/public/lib/render_functions_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '../../common/lib/registry'; +import { Registry } from '@kbn/interpreter/common/lib/registry'; import { RenderFunction } from './render_function'; class RenderFunctionsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/run_interpreter.js b/x-pack/plugins/canvas/public/lib/run_interpreter.js index cc0d9a7544786..7bb898b254ec8 100644 --- a/x-pack/plugins/canvas/public/lib/run_interpreter.js +++ b/x-pack/plugins/canvas/public/lib/run_interpreter.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { fromExpression } from '../../common/lib/ast'; -import { getType } from '../../common/lib/get_type'; -import { interpretAst } from './interpreter'; +import { interpretAst } from '@kbn/interpreter/public/interpreter'; +import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { getType } from '@kbn/interpreter/common/lib/get_type'; import { notify } from './notify'; /** diff --git a/x-pack/plugins/canvas/public/lib/transitions_registry.js b/x-pack/plugins/canvas/public/lib/transitions_registry.js index 8d2e421b8233c..8ead0aa896ab7 100644 --- a/x-pack/plugins/canvas/public/lib/transitions_registry.js +++ b/x-pack/plugins/canvas/public/lib/transitions_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '../../common/lib/registry'; +import { Registry } from '@kbn/interpreter/common/lib/registry'; import { Transition } from '../transitions/transition'; class TransitionsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/types_registry.js b/x-pack/plugins/canvas/public/lib/types_registry.js index c1f13b1ae4612..05b82c744c383 100644 --- a/x-pack/plugins/canvas/public/lib/types_registry.js +++ b/x-pack/plugins/canvas/public/lib/types_registry.js @@ -5,4 +5,4 @@ */ // export the common registry here, so it's available in plugin public code -export { typesRegistry } from '../../common/lib/types_registry'; +export { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; diff --git a/x-pack/plugins/canvas/public/state/actions/elements.js b/x-pack/plugins/canvas/public/state/actions/elements.js index fb82de32fc0ef..be157d9d8085b 100644 --- a/x-pack/plugins/canvas/public/state/actions/elements.js +++ b/x-pack/plugins/canvas/public/state/actions/elements.js @@ -4,17 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ +import { interpretAst } from '@kbn/interpreter/public/interpreter'; import { createAction } from 'redux-actions'; import { createThunk } from 'redux-thunks'; import { set, del } from 'object-path-immutable'; import { get, pick, cloneDeep, without } from 'lodash'; +import { toExpression, safeElementFromExpression } from '@kbn/interpreter/common/lib/ast'; import { getPages, getElementById, getSelectedPageIndex } from '../selectors/workpad'; import { getValue as getResolvedArgsValue } from '../selectors/resolved_args'; import { getDefaultElement } from '../defaults'; -import { toExpression, safeElementFromExpression } from '../../../common/lib/ast'; import { notify } from '../../lib/notify'; import { runInterpreter } from '../../lib/run_interpreter'; -import { interpretAst } from '../../lib/interpreter'; import { selectElement } from './transient'; import * as args from './resolved_args'; diff --git a/x-pack/plugins/canvas/public/state/selectors/workpad.js b/x-pack/plugins/canvas/public/state/selectors/workpad.js index 1db0128abab07..6d888f60c2191 100644 --- a/x-pack/plugins/canvas/public/state/selectors/workpad.js +++ b/x-pack/plugins/canvas/public/state/selectors/workpad.js @@ -5,7 +5,7 @@ */ import { get, omit } from 'lodash'; -import { safeElementFromExpression } from '../../../common/lib/ast'; +import { safeElementFromExpression } from '@kbn/interpreter/common/lib/ast'; import { append } from '../../lib/modify_path'; import { getAssets } from './assets'; diff --git a/x-pack/plugins/canvas/server/lib/feature_check.js b/x-pack/plugins/canvas/server/lib/feature_check.js deleted file mode 100644 index e9cec02923582..0000000000000 --- a/x-pack/plugins/canvas/server/lib/feature_check.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// TODO: replace this when we use the method exposed by security https://github.com/elastic/kibana/pull/24616 -export const isSecurityEnabled = server => { - const kibanaSecurity = server.plugins.security; - const esSecurity = server.plugins.xpack_main.info.feature('security'); - - return kibanaSecurity && esSecurity.isAvailable() && esSecurity.isEnabled(); -}; diff --git a/x-pack/plugins/canvas/server/lib/get_plugin_paths.js b/x-pack/plugins/canvas/server/lib/get_plugin_paths.js deleted file mode 100644 index 02582e5f749cc..0000000000000 --- a/x-pack/plugins/canvas/server/lib/get_plugin_paths.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import path from 'path'; -import fs from 'fs'; -import { promisify } from 'util'; -import { flatten } from 'lodash'; -import { pluginPaths } from './plugin_paths'; - -const lstat = promisify(fs.lstat); -const readdir = promisify(fs.readdir); - -const canvasPluginDirectoryName = 'canvas_plugin'; - -const isDirectory = path => - lstat(path) - .then(stat => stat.isDirectory()) - .catch(() => false); - -const isDirname = (p, name) => path.basename(p) === name; - -const getKibanaPluginsPath = () => { - const basePluginPath = path.resolve(__dirname, '..', '..', '..', '..', '..'); - - // find the kibana path in dev mode - if (isDirname(basePluginPath, 'kibana')) return path.join(basePluginPath, 'plugins'); - - // find the kibana path in the build, which lives in node_modules and requires going 1 path up - const buildPluginPath = path.join(basePluginPath, '..'); - if (isDirname(basePluginPath, 'node_modules')) { - const pluginPath = path.join(buildPluginPath, 'plugins'); - return isDirectory(pluginPath) && pluginPath; - } - - return false; -}; - -// These must all exist -const paths = [ - path.resolve(__dirname, '..', '..', '..'), // Canvas core plugins - getKibanaPluginsPath(), // Kibana plugin directory -].filter(Boolean); - -export const getPluginPaths = type => { - const typePath = pluginPaths[type]; - if (!typePath) throw new Error(`Unknown type: ${type}`); - - async function findPlugins(directory) { - const isDir = await isDirectory(directory); - if (!isDir) return; - - const names = await readdir(directory); // Get names of everything in the directory - return names - .filter(name => name[0] !== '.') - .map(name => path.resolve(directory, name, canvasPluginDirectoryName, ...typePath)); - } - - return Promise.all(paths.map(findPlugins)) - .then(dirs => - dirs.reduce((list, dir) => { - if (!dir) return list; - return list.concat(dir); - }, []) - ) - .then(possibleCanvasPlugins => { - // Check how many are directories. If lstat fails it doesn't exist anyway. - return Promise.all( - // An array - possibleCanvasPlugins.map(pluginPath => isDirectory(pluginPath)) - ).then(isDirectory => possibleCanvasPlugins.filter((pluginPath, i) => isDirectory[i])); - }) - .then(canvasPluginDirectories => { - return Promise.all( - canvasPluginDirectories.map(dir => - // Get the full path of all files in the directory - readdir(dir).then(files => files.map(file => path.resolve(dir, file))) - ) - ).then(flatten); - }); -}; diff --git a/x-pack/plugins/canvas/server/lib/get_plugin_stream.js b/x-pack/plugins/canvas/server/lib/get_plugin_stream.js deleted file mode 100644 index 6a08e2beeff8e..0000000000000 --- a/x-pack/plugins/canvas/server/lib/get_plugin_stream.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import fs from 'fs'; -import ss from 'stream-stream'; -import { getPluginPaths } from './get_plugin_paths'; - -export const getPluginStream = type => { - const stream = ss({ - separator: '\n', - }); - - getPluginPaths(type).then(files => { - files.forEach(file => { - stream.write(fs.createReadStream(file)); - }); - stream.end(); - }); - - return stream; -}; diff --git a/x-pack/plugins/canvas/server/lib/get_request.js b/x-pack/plugins/canvas/server/lib/get_request.js deleted file mode 100644 index d55421e437fc4..0000000000000 --- a/x-pack/plugins/canvas/server/lib/get_request.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import boom from 'boom'; -import { API_ROUTE } from '../../common/lib/constants'; - -export function getRequest(server, { headers }) { - const url = `${API_ROUTE}/ping`; - - return server - .inject({ - method: 'POST', - url, - headers, - }) - .then(res => { - if (res.statusCode !== 200) { - if (process.env.NODE_ENV !== 'production') { - console.error( - new Error(`Auth request failed: [${res.statusCode}] ${res.result.message}`) - ); - } - throw boom.unauthorized('Failed to authenticate socket connection'); - } - - return res.request; - }); -} diff --git a/x-pack/plugins/canvas/server/lib/plugin_paths.js b/x-pack/plugins/canvas/server/lib/plugin_paths.js deleted file mode 100644 index cb90cc0c0f06c..0000000000000 --- a/x-pack/plugins/canvas/server/lib/plugin_paths.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const pluginPaths = { - serverFunctions: ['functions', 'server'], - browserFunctions: ['functions', 'browser'], - commonFunctions: ['functions', 'common'], - types: ['types'], - elements: ['elements'], - renderers: ['renderers'], - interfaces: ['interfaces'], - transformUIs: ['uis', 'transforms'], - datasourceUIs: ['uis', 'datasources'], - modelUIs: ['uis', 'models'], - viewUIs: ['uis', 'views'], - argumentUIs: ['uis', 'arguments'], -}; diff --git a/x-pack/plugins/canvas/server/lib/route_expression/server.js b/x-pack/plugins/canvas/server/lib/route_expression/server.js deleted file mode 100644 index b24e4cb7e5e41..0000000000000 --- a/x-pack/plugins/canvas/server/lib/route_expression/server.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { getServerRegistries } from '../server_registries'; -import { interpretProvider } from '../../../common/interpreter/interpret'; -import { createHandlers } from '../create_handlers'; - -export const server = async ({ onFunctionNotFound, server, request }) => { - const { serverFunctions, types } = await getServerRegistries(['serverFunctions', 'types']); - - return { - interpret: (ast, context) => { - const interpret = interpretProvider({ - types: types.toJS(), - functions: serverFunctions.toJS(), - handlers: createHandlers(request, server), - onFunctionNotFound, - }); - - return interpret(ast, context); - }, - getFunctions: () => Object.keys(serverFunctions.toJS()), - }; -}; diff --git a/x-pack/plugins/canvas/server/lib/route_expression/thread/babeled.js b/x-pack/plugins/canvas/server/lib/route_expression/thread/babeled.js deleted file mode 100644 index b7c1e83beb7c7..0000000000000 --- a/x-pack/plugins/canvas/server/lib/route_expression/thread/babeled.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -require('babel-register')({ - ignore: [ - // stolen from kibana/src/setup_node_env/babel_register/register.js - // ignore paths matching `/node_modules/{a}/{b}`, unless `a` - // is `x-pack` and `b` is not `node_modules` - /\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, - ], - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/node_preset')], -}); - -require('./polyfill'); -require('./worker'); diff --git a/x-pack/plugins/canvas/server/lib/route_expression/thread/polyfill.js b/x-pack/plugins/canvas/server/lib/route_expression/thread/polyfill.js deleted file mode 100644 index be4983e9a37e8..0000000000000 --- a/x-pack/plugins/canvas/server/lib/route_expression/thread/polyfill.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// taken from kibana/src/setup_node_env/babel_register/polyfill.js -// ... -// `babel-preset-env` looks for and rewrites the following import -// statement into a list of import statements based on the polyfills -// necessary for our target environment (the current version of node) -// but since it does that during compilation, `import 'babel-polyfill'` -// must be in a file that is loaded with `require()` AFTER `babel-register` -// is configured. -// -// This is why we have this single statement in it's own file and require -// it from ./babeled.js -import 'babel-polyfill'; diff --git a/x-pack/plugins/canvas/server/lib/server_registries.js b/x-pack/plugins/canvas/server/lib/server_registries.js deleted file mode 100644 index cff63a1138ea3..0000000000000 --- a/x-pack/plugins/canvas/server/lib/server_registries.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { typesRegistry } from '../../common/lib/types_registry'; -import { functionsRegistry as serverFunctions } from '../../common/lib/functions_registry'; -import { getPluginPaths } from './get_plugin_paths'; - -const registries = { - serverFunctions: serverFunctions, - commonFunctions: serverFunctions, - types: typesRegistry, -}; - -let resolve = null; -let called = false; - -const populatePromise = new Promise(_resolve => { - resolve = _resolve; -}); - -export const getServerRegistries = () => { - return populatePromise; -}; - -export const populateServerRegistries = types => { - if (called) throw new Error('function should only be called once per process'); - called = true; - if (!types || !types.length) throw new Error('types is required'); - - const remainingTypes = types; - const populatedTypes = {}; - - const loadType = () => { - const type = remainingTypes.pop(); - getPluginPaths(type).then(paths => { - global.canvas = global.canvas || {}; - global.canvas.register = d => registries[type].register(d); - - paths.forEach(path => { - require(path); - }); - - global.canvas = undefined; - populatedTypes[type] = registries[type]; - if (remainingTypes.length) loadType(); - else resolve(populatedTypes); - }); - }; - - if (remainingTypes.length) loadType(); - return populatePromise; -}; diff --git a/x-pack/plugins/canvas/server/routes/index.js b/x-pack/plugins/canvas/server/routes/index.js index ab2edfe86b56f..45f26a423fc84 100644 --- a/x-pack/plugins/canvas/server/routes/index.js +++ b/x-pack/plugins/canvas/server/routes/index.js @@ -5,15 +5,9 @@ */ import { workpad } from './workpad'; -import { socketApi } from './socket'; -import { translate } from './translate'; import { esFields } from './es_fields'; -import { plugins } from './plugins'; export function routes(server) { workpad(server); - socketApi(server); - translate(server); esFields(server); - plugins(server); } diff --git a/x-pack/plugins/canvas/server/routes/plugins.js b/x-pack/plugins/canvas/server/routes/plugins.js deleted file mode 100644 index be94ef52ac9e4..0000000000000 --- a/x-pack/plugins/canvas/server/routes/plugins.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { getPluginStream } from '../lib/get_plugin_stream'; -import { pluginPaths } from '../lib/plugin_paths'; - -export function plugins(server) { - server.route({ - method: 'GET', - path: '/api/canvas/plugins', - handler: function(request, h) { - const { type } = request.query; - - if (!pluginPaths[type]) return h.response({ error: 'Invalid type' }).code(400); - - return getPluginStream(type); - }, - config: { - auth: false, - }, - }); -} diff --git a/x-pack/plugins/canvas/server/routes/translate.js b/x-pack/plugins/canvas/server/routes/translate.js deleted file mode 100644 index 6125898a7dab9..0000000000000 --- a/x-pack/plugins/canvas/server/routes/translate.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { fromExpression, toExpression } from '../../common/lib/ast'; - -export function translate(server) { - /* - Get AST from expression - */ - server.route({ - method: 'GET', - path: '/api/canvas/ast', - handler: function(request, h) { - if (!request.query.expression) - return h.response({ error: '"expression" query is required' }).code(400); - return fromExpression(request.query.expression); - }, - }); - - server.route({ - method: 'POST', - path: '/api/canvas/expression', - handler: function(request, h) { - try { - return toExpression(request.payload); - } catch (e) { - return h.response({ error: e.message }).code(400); - } - }, - }); -} diff --git a/x-pack/plugins/canvas/server/usage/collector.js b/x-pack/plugins/canvas/server/usage/collector.js index a4e73ffe85071..d76d023f7c7e4 100644 --- a/x-pack/plugins/canvas/server/usage/collector.js +++ b/x-pack/plugins/canvas/server/usage/collector.js @@ -5,8 +5,8 @@ */ import { sum as arraySum, min as arrayMin, max as arrayMax, get } from 'lodash'; +import { fromExpression } from '@kbn/interpreter/common/lib/ast'; import { CANVAS_USAGE_TYPE, CANVAS_TYPE } from '../../common/lib/constants'; -import { fromExpression } from '../../common/lib/ast'; /* * @param ast: an ast that includes functions to track diff --git a/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js b/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js index c53eccd87bd97..8b8f3601d86e9 100644 --- a/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js +++ b/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js @@ -21,7 +21,6 @@ module.exports = { 'uis/arguments/all': path.join(sourceDir, 'uis/arguments/register.js'), 'functions/browser/all': path.join(sourceDir, 'functions/browser/register.js'), 'functions/common/all': path.join(sourceDir, 'functions/common/register.js'), - 'types/all': path.join(sourceDir, 'types/register.js'), }, // there were problems with the node and web targets since this code is actually From 40960f98ab5b005c55449ec49e395fefebdeeea9 Mon Sep 17 00:00:00 2001 From: Sonja Krause-Harder Date: Tue, 20 Nov 2018 11:26:29 +0100 Subject: [PATCH 29/95] [Infra UI] Refactor 'capabilites' to 'metadata'. (#25580) * Refactor 'capabilites' to 'metadata'. * Better language in inline documentation. --- .../infra/common/graphql/introspection.json | 11 +++--- x-pack/plugins/infra/common/graphql/types.ts | 30 +++++++-------- .../metadata.gql_query.ts} | 6 +-- .../with_metadata.tsx} | 38 +++++++++---------- .../infra/public/pages/metrics/index.tsx | 6 +-- x-pack/plugins/infra/server/graphql/index.ts | 4 +- .../{capabilities => metadata}/index.ts | 4 +- .../{capabilities => metadata}/resolvers.ts | 21 ++++------ .../{capabilities => metadata}/schema.gql.ts | 10 ++--- x-pack/plugins/infra/server/infra_server.ts | 4 +- .../lib/adapters/framework/adapter_types.ts | 8 ++-- .../adapter_types.ts | 12 +++--- .../elasticsearch_metadata_adapter.ts} | 20 +++++----- .../{capabilities => metadata}/index.ts | 0 .../infra/server/lib/compose/kibana.ts | 6 +-- .../index.ts | 2 +- .../metadata_domain.ts} | 35 ++++++++--------- .../plugins/infra/server/lib/infra_types.ts | 4 +- .../test/api_integration/apis/infra/index.js | 2 +- .../infra/{capabilities.ts => metadata.ts} | 20 +++++----- 20 files changed, 115 insertions(+), 128 deletions(-) rename x-pack/plugins/infra/public/containers/{capabilities/capabilities.gql_query.ts => metadata/metadata.gql_query.ts} (65%) rename x-pack/plugins/infra/public/containers/{capabilities/with_capabilites.tsx => metadata/with_metadata.tsx} (60%) rename x-pack/plugins/infra/server/graphql/{capabilities => metadata}/index.ts (68%) rename x-pack/plugins/infra/server/graphql/{capabilities => metadata}/resolvers.ts (54%) rename x-pack/plugins/infra/server/graphql/{capabilities => metadata}/schema.gql.ts (53%) rename x-pack/plugins/infra/server/lib/adapters/{capabilities => metadata}/adapter_types.ts (66%) rename x-pack/plugins/infra/server/lib/adapters/{capabilities/elasticsearch_capabilities_adapter.ts => metadata/elasticsearch_metadata_adapter.ts} (85%) rename x-pack/plugins/infra/server/lib/adapters/{capabilities => metadata}/index.ts (100%) rename x-pack/plugins/infra/server/lib/domains/{capabilities_domain => metadata_domain}/index.ts (86%) rename x-pack/plugins/infra/server/lib/domains/{capabilities_domain/capabilities_domain.ts => metadata_domain/metadata_domain.ts} (52%) rename x-pack/test/api_integration/apis/infra/{capabilities.ts => metadata.ts} (57%) diff --git a/x-pack/plugins/infra/common/graphql/introspection.json b/x-pack/plugins/infra/common/graphql/introspection.json index cd3e36a84c306..e0a54aa142c60 100644 --- a/x-pack/plugins/infra/common/graphql/introspection.json +++ b/x-pack/plugins/infra/common/graphql/introspection.json @@ -111,8 +111,8 @@ "deprecationReason": null }, { - "name": "capabilitiesByNode", - "description": "A hierarchy of capabilities available on nodes", + "name": "metadataByNode", + "description": "A hierarchy of metadata entries by node", "args": [ { "name": "nodeName", @@ -141,7 +141,7 @@ "ofType": { "kind": "LIST", "name": null, - "ofType": { "kind": "OBJECT", "name": "InfraNodeCapability", "ofType": null } + "ofType": { "kind": "OBJECT", "name": "InfraNodeMetadata", "ofType": null } } }, "isDeprecated": false, @@ -781,9 +781,8 @@ }, { "kind": "OBJECT", - "name": "InfraNodeCapability", - "description": - "One specific capability available on a node. A capability corresponds to a fileset or metricset", + "name": "InfraNodeMetadata", + "description": "One metadata entry for a node.", "fields": [ { "name": "name", diff --git a/x-pack/plugins/infra/common/graphql/types.ts b/x-pack/plugins/infra/common/graphql/types.ts index c79280bd7f43b..a48a0135f1ddf 100644 --- a/x-pack/plugins/infra/common/graphql/types.ts +++ b/x-pack/plugins/infra/common/graphql/types.ts @@ -17,7 +17,7 @@ export interface InfraSource { id: string /** The id of the source */; configuration: InfraSourceConfiguration /** The raw configuration of the source */; status: InfraSourceStatus /** The status of the source */; - capabilitiesByNode: (InfraNodeCapability | null)[] /** A hierarchy of capabilities available on nodes */; + metadataByNode: (InfraNodeMetadata | null)[] /** A hierarchy of metadata entries by node */; logEntriesAround: InfraLogEntryInterval /** A consecutive span of log entries surrounding a point in time */; logEntriesBetween: InfraLogEntryInterval /** A consecutive span of log entries within an interval */; logSummaryBetween: InfraLogSummaryInterval /** A consecutive span of summary buckets within an interval */; @@ -56,8 +56,8 @@ export interface InfraIndexField { searchable: boolean /** Whether the field's values can be efficiently searched for */; aggregatable: boolean /** Whether the field's values can be aggregated */; } -/** One specific capability available on a node. A capability corresponds to a fileset or metricset */ -export interface InfraNodeCapability { +/** One metadata entry for a node. */ +export interface InfraNodeMetadata { name: string; source: string; } @@ -163,7 +163,7 @@ export namespace InfraSourceResolvers { id?: IdResolver /** The id of the source */; configuration?: ConfigurationResolver /** The raw configuration of the source */; status?: StatusResolver /** The status of the source */; - capabilitiesByNode?: CapabilitiesByNodeResolver /** A hierarchy of capabilities available on nodes */; + metadataByNode?: MetadataByNodeResolver /** A hierarchy of metadata entries by node */; logEntriesAround?: LogEntriesAroundResolver /** A consecutive span of log entries surrounding a point in time */; logEntriesBetween?: LogEntriesBetweenResolver /** A consecutive span of log entries within an interval */; logSummaryBetween?: LogSummaryBetweenResolver /** A consecutive span of summary buckets within an interval */; @@ -174,11 +174,8 @@ export namespace InfraSourceResolvers { export type IdResolver = Resolver; export type ConfigurationResolver = Resolver; export type StatusResolver = Resolver; - export type CapabilitiesByNodeResolver = Resolver< - (InfraNodeCapability | null)[], - CapabilitiesByNodeArgs - >; - export interface CapabilitiesByNodeArgs { + export type MetadataByNodeResolver = Resolver<(InfraNodeMetadata | null)[], MetadataByNodeArgs>; + export interface MetadataByNodeArgs { nodeName: string; nodeType: InfraNodeType; } @@ -289,8 +286,8 @@ export namespace InfraIndexFieldResolvers { export type SearchableResolver = Resolver; export type AggregatableResolver = Resolver; } -/** One specific capability available on a node. A capability corresponds to a fileset or metricset */ -export namespace InfraNodeCapabilityResolvers { +/** One metadata entry for a node. */ +export namespace InfraNodeMetadataResolvers { export interface Resolvers { name?: NameResolver; source?: SourceResolver; @@ -493,7 +490,7 @@ export interface InfraMetricInput { export interface SourceQueryArgs { id: string /** The id of the source */; } -export interface CapabilitiesByNodeInfraSourceArgs { +export interface MetadataByNodeInfraSourceArgs { nodeName: string; nodeType: InfraNodeType; } @@ -604,7 +601,7 @@ export enum InfraOperator { /** A segment of the log entry message */ export type InfraLogMessageSegment = InfraLogMessageFieldSegment | InfraLogMessageConstantSegment; -export namespace CapabilitiesQuery { +export namespace MetadataQuery { export type Variables = { sourceId: string; nodeId: string; @@ -619,11 +616,11 @@ export namespace CapabilitiesQuery { export type Source = { __typename?: 'InfraSource'; id: string; - capabilitiesByNode: (CapabilitiesByNode | null)[]; + metadataByNode: (MetadataByNode | null)[]; }; - export type CapabilitiesByNode = { - __typename?: 'InfraNodeCapability'; + export type MetadataByNode = { + __typename?: 'InfraNodeMetadata'; name: string; source: string; }; @@ -815,6 +812,7 @@ export namespace SourceQuery { export type Source = { __typename?: 'InfraSource'; + id: string; configuration: Configuration; status: Status; }; diff --git a/x-pack/plugins/infra/public/containers/capabilities/capabilities.gql_query.ts b/x-pack/plugins/infra/public/containers/metadata/metadata.gql_query.ts similarity index 65% rename from x-pack/plugins/infra/public/containers/capabilities/capabilities.gql_query.ts rename to x-pack/plugins/infra/public/containers/metadata/metadata.gql_query.ts index 53845b463c0b5..9844c5b7afcb8 100644 --- a/x-pack/plugins/infra/public/containers/capabilities/capabilities.gql_query.ts +++ b/x-pack/plugins/infra/public/containers/metadata/metadata.gql_query.ts @@ -6,11 +6,11 @@ import gql from 'graphql-tag'; -export const capabilitiesQuery = gql` - query CapabilitiesQuery($sourceId: ID!, $nodeId: String!, $nodeType: InfraNodeType!) { +export const metadataQuery = gql` + query MetadataQuery($sourceId: ID!, $nodeId: String!, $nodeType: InfraNodeType!) { source(id: $sourceId) { id - capabilitiesByNode(nodeName: $nodeId, nodeType: $nodeType) { + metadataByNode(nodeName: $nodeId, nodeType: $nodeType) { name source } diff --git a/x-pack/plugins/infra/public/containers/capabilities/with_capabilites.tsx b/x-pack/plugins/infra/public/containers/metadata/with_metadata.tsx similarity index 60% rename from x-pack/plugins/infra/public/containers/capabilities/with_capabilites.tsx rename to x-pack/plugins/infra/public/containers/metadata/with_metadata.tsx index efdcb0e70e1d8..df8f25c408792 100644 --- a/x-pack/plugins/infra/public/containers/capabilities/with_capabilites.tsx +++ b/x-pack/plugins/infra/public/containers/metadata/with_metadata.tsx @@ -8,34 +8,34 @@ import _ from 'lodash'; import React from 'react'; import { Query } from 'react-apollo'; -import { CapabilitiesQuery, InfraNodeType } from '../../../common/graphql/types'; +import { InfraNodeType, MetadataQuery } from '../../../common/graphql/types'; import { InfraMetricLayout } from '../../pages/metrics/layouts/types'; -import { capabilitiesQuery } from './capabilities.gql_query'; +import { metadataQuery } from './metadata.gql_query'; -interface WithCapabilitiesProps { - children: (args: WithCapabilitiesArgs) => React.ReactNode; +interface WithMetadataProps { + children: (args: WithMetadataArgs) => React.ReactNode; layouts: InfraMetricLayout[]; nodeType: InfraNodeType; nodeId: string; sourceId: string; } -interface WithCapabilitiesArgs { +interface WithMetadataArgs { filteredLayouts: InfraMetricLayout[]; error?: string | undefined; loading: boolean; } -export const WithCapabilities = ({ +export const WithMetadata = ({ children, layouts, nodeType, nodeId, sourceId, -}: WithCapabilitiesProps) => { +}: WithMetadataProps) => { return ( - - query={capabilitiesQuery} + + query={metadataQuery} fetchPolicy="no-cache" variables={{ sourceId, @@ -44,8 +44,8 @@ export const WithCapabilities = ({ }} > {({ data, error, loading }) => { - const capabilities = data && data.source && data.source.capabilitiesByNode; - const filteredLayouts = getFilteredLayouts(layouts, capabilities); + const metadata = data && data.source && data.source.metadataByNode; + const filteredLayouts = getFilteredLayouts(layouts, metadata); return children({ filteredLayouts, error: error && error.message, @@ -58,31 +58,31 @@ export const WithCapabilities = ({ const getFilteredLayouts = ( layouts: InfraMetricLayout[], - capabilities: Array | undefined + metadata: Array | undefined ): InfraMetricLayout[] => { - if (!capabilities) { + if (!metadata) { return layouts; } - const metricCapabilities: Array = capabilities - .filter(cap => cap && cap.source === 'metrics') - .map(cap => cap && cap.name); + const metricMetadata: Array = metadata + .filter(data => data && data.source === 'metrics') + .map(data => data && data.name); // After filtering out sections that can't be displayed, a layout may end up empty and can be removed. const filteredLayouts = layouts - .map(layout => getFilteredLayout(layout, metricCapabilities)) + .map(layout => getFilteredLayout(layout, metricMetadata)) .filter(layout => layout.sections.length > 0); return filteredLayouts; }; const getFilteredLayout = ( layout: InfraMetricLayout, - metricCapabilities: Array + metricMetadata: Array ): InfraMetricLayout => { // A section is only displayed if at least one of its requirements is met // All others are filtered out. const filteredSections = layout.sections.filter( - section => _.intersection(section.requires, metricCapabilities).length > 0 + section => _.intersection(section.requires, metricMetadata).length > 0 ); return { ...layout, sections: filteredSections }; }; diff --git a/x-pack/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx index 8e4dd37b84a71..c67018d5eb019 100644 --- a/x-pack/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -25,7 +25,7 @@ import { Header } from '../../components/header'; import { Metrics } from '../../components/metrics'; import { MetricsTimeControls } from '../../components/metrics/time_controls'; import { ColumnarPage, PageContent } from '../../components/page'; -import { WithCapabilities } from '../../containers/capabilities/with_capabilites'; +import { WithMetadata } from '../../containers/metadata/with_metadata'; import { WithMetrics } from '../../containers/metrics/with_metrics'; import { WithMetricsTime, @@ -88,7 +88,7 @@ class MetricDetailPage extends React.PureComponent { startMetricsAutoReload, stopMetricsAutoReload, }) => ( - { ); }} - + )} )} diff --git a/x-pack/plugins/infra/server/graphql/index.ts b/x-pack/plugins/infra/server/graphql/index.ts index 7fb3a92330352..20aa0b75097d9 100644 --- a/x-pack/plugins/infra/server/graphql/index.ts +++ b/x-pack/plugins/infra/server/graphql/index.ts @@ -6,8 +6,8 @@ import { rootSchema } from '../../common/graphql/root/schema.gql'; import { sharedSchema } from '../../common/graphql/shared/schema.gql'; -import { capabilitiesSchema } from './capabilities/schema.gql'; import { logEntriesSchema } from './log_entries/schema.gql'; +import { metadataSchema } from './metadata/schema.gql'; import { metricsSchema } from './metrics/schema.gql'; import { nodesSchema } from './nodes/schema.gql'; import { sourceStatusSchema } from './source_status/schema.gql'; @@ -16,7 +16,7 @@ import { sourcesSchema } from './sources/schema.gql'; export const schemas = [ rootSchema, sharedSchema, - capabilitiesSchema, + metadataSchema, logEntriesSchema, nodesSchema, sourcesSchema, diff --git a/x-pack/plugins/infra/server/graphql/capabilities/index.ts b/x-pack/plugins/infra/server/graphql/metadata/index.ts similarity index 68% rename from x-pack/plugins/infra/server/graphql/capabilities/index.ts rename to x-pack/plugins/infra/server/graphql/metadata/index.ts index 3f6f9541eda33..cda731bdaa9b6 100644 --- a/x-pack/plugins/infra/server/graphql/capabilities/index.ts +++ b/x-pack/plugins/infra/server/graphql/metadata/index.ts @@ -4,5 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -export { createCapabilitiesResolvers } from './resolvers'; -export { capabilitiesSchema } from './schema.gql'; +export { createMetadataResolvers } from './resolvers'; +export { metadataSchema } from './schema.gql'; diff --git a/x-pack/plugins/infra/server/graphql/capabilities/resolvers.ts b/x-pack/plugins/infra/server/graphql/metadata/resolvers.ts similarity index 54% rename from x-pack/plugins/infra/server/graphql/capabilities/resolvers.ts rename to x-pack/plugins/infra/server/graphql/metadata/resolvers.ts index fa242f67b230f..0d4c66643721c 100644 --- a/x-pack/plugins/infra/server/graphql/capabilities/resolvers.ts +++ b/x-pack/plugins/infra/server/graphql/metadata/resolvers.ts @@ -6,31 +6,26 @@ import { InfraSourceResolvers } from '../../../common/graphql/types'; import { InfraResolvedResult, InfraResolverOf } from '../../lib/adapters/framework'; -import { InfraCapabilitiesDomain } from '../../lib/domains/capabilities_domain'; +import { InfraMetadataDomain } from '../../lib/domains/metadata_domain'; import { InfraContext } from '../../lib/infra_types'; import { QuerySourceResolver } from '../sources/resolvers'; -type InfraSourceCapabilitiesByNodeResolver = InfraResolverOf< - InfraSourceResolvers.CapabilitiesByNodeResolver, +type InfraSourceMetadataByNodeResolver = InfraResolverOf< + InfraSourceResolvers.MetadataByNodeResolver, InfraResolvedResult, InfraContext >; -export const createCapabilitiesResolvers = (libs: { - capabilities: InfraCapabilitiesDomain; +export const createMetadataResolvers = (libs: { + metadata: InfraMetadataDomain; }): { InfraSource: { - capabilitiesByNode: InfraSourceCapabilitiesByNodeResolver; + metadataByNode: InfraSourceMetadataByNodeResolver; }; } => ({ InfraSource: { - async capabilitiesByNode(source, args, { req }) { - const result = await libs.capabilities.getCapabilities( - req, - source.id, - args.nodeName, - args.nodeType - ); + async metadataByNode(source, args, { req }) { + const result = await libs.metadata.getMetadata(req, source.id, args.nodeName, args.nodeType); return result; }, }, diff --git a/x-pack/plugins/infra/server/graphql/capabilities/schema.gql.ts b/x-pack/plugins/infra/server/graphql/metadata/schema.gql.ts similarity index 53% rename from x-pack/plugins/infra/server/graphql/capabilities/schema.gql.ts rename to x-pack/plugins/infra/server/graphql/metadata/schema.gql.ts index 9a97ff29eeb85..1a0e40d8f0b82 100644 --- a/x-pack/plugins/infra/server/graphql/capabilities/schema.gql.ts +++ b/x-pack/plugins/infra/server/graphql/metadata/schema.gql.ts @@ -6,15 +6,15 @@ import gql from 'graphql-tag'; -export const capabilitiesSchema = gql` - "One specific capability available on a node. A capability corresponds to a fileset or metricset" - type InfraNodeCapability { +export const metadataSchema = gql` + "One metadata entry for a node." + type InfraNodeMetadata { name: String! source: String! } extend type InfraSource { - "A hierarchy of capabilities available on nodes" - capabilitiesByNode(nodeName: String!, nodeType: InfraNodeType!): [InfraNodeCapability]! + "A hierarchy of metadata entries by node" + metadataByNode(nodeName: String!, nodeType: InfraNodeType!): [InfraNodeMetadata]! } `; diff --git a/x-pack/plugins/infra/server/infra_server.ts b/x-pack/plugins/infra/server/infra_server.ts index eb68e44af6423..a89d3cb6e8170 100644 --- a/x-pack/plugins/infra/server/infra_server.ts +++ b/x-pack/plugins/infra/server/infra_server.ts @@ -6,8 +6,8 @@ import { IResolvers, makeExecutableSchema } from 'graphql-tools'; import { schemas } from './graphql'; -import { createCapabilitiesResolvers } from './graphql/capabilities'; import { createLogEntriesResolvers } from './graphql/log_entries'; +import { createMetadataResolvers } from './graphql/metadata'; import { createMetricResolvers } from './graphql/metrics/resolvers'; import { createNodeResolvers } from './graphql/nodes'; import { createSourceStatusResolvers } from './graphql/source_status'; @@ -18,7 +18,7 @@ import { initLegacyLoggingRoutes } from './logging_legacy'; export const initInfraServer = (libs: InfraBackendLibs) => { const schema = makeExecutableSchema({ resolvers: [ - createCapabilitiesResolvers(libs) as IResolvers, + createMetadataResolvers(libs) as IResolvers, createLogEntriesResolvers(libs) as IResolvers, createNodeResolvers(libs) as IResolvers, createSourcesResolvers(libs) as IResolvers, diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts index 28378248a6384..23de4c7b2b81d 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts @@ -148,15 +148,15 @@ export interface InfraDateRangeAggregationResponse { buckets: InfraDateRangeAggregationBucket[]; } -export interface InfraCapabilityAggregationBucket { +export interface InfraMetadataAggregationBucket { key: string; names?: { - buckets: InfraCapabilityAggregationBucket[]; + buckets: InfraMetadataAggregationBucket[]; }; } -export interface InfraCapabilityAggregationResponse { - buckets: InfraCapabilityAggregationBucket[]; +export interface InfraMetadataAggregationResponse { + buckets: InfraMetadataAggregationBucket[]; } export interface InfraFieldsResponse { diff --git a/x-pack/plugins/infra/server/lib/adapters/capabilities/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/metadata/adapter_types.ts similarity index 66% rename from x-pack/plugins/infra/server/lib/adapters/capabilities/adapter_types.ts rename to x-pack/plugins/infra/server/lib/adapters/metadata/adapter_types.ts index 1486d0d9e2e38..e7aece48c7cd0 100644 --- a/x-pack/plugins/infra/server/lib/adapters/capabilities/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metadata/adapter_types.ts @@ -5,19 +5,19 @@ */ import { InfraSourceConfiguration } from '../../sources'; -import { InfraCapabilityAggregationBucket, InfraFrameworkRequest } from '../framework'; +import { InfraFrameworkRequest, InfraMetadataAggregationBucket } from '../framework'; -export interface InfraCapabilitiesAdapter { - getMetricCapabilities( +export interface InfraMetadataAdapter { + getMetricMetadata( req: InfraFrameworkRequest, sourceConfiguration: InfraSourceConfiguration, nodeName: string, nodeType: string - ): Promise; - getLogCapabilities( + ): Promise; + getLogMetadata( req: InfraFrameworkRequest, sourceConfiguration: InfraSourceConfiguration, nodeName: string, nodeType: string - ): Promise; + ): Promise; } diff --git a/x-pack/plugins/infra/server/lib/adapters/capabilities/elasticsearch_capabilities_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/metadata/elasticsearch_metadata_adapter.ts similarity index 85% rename from x-pack/plugins/infra/server/lib/adapters/capabilities/elasticsearch_capabilities_adapter.ts rename to x-pack/plugins/infra/server/lib/adapters/metadata/elasticsearch_metadata_adapter.ts index 049fb864dcbc0..7972154124ee6 100644 --- a/x-pack/plugins/infra/server/lib/adapters/capabilities/elasticsearch_capabilities_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metadata/elasticsearch_metadata_adapter.ts @@ -7,24 +7,24 @@ import { InfraSourceConfiguration } from '../../sources'; import { InfraBackendFrameworkAdapter, - InfraCapabilityAggregationBucket, - InfraCapabilityAggregationResponse, InfraFrameworkRequest, + InfraMetadataAggregationBucket, + InfraMetadataAggregationResponse, } from '../framework'; -import { InfraCapabilitiesAdapter } from './adapter_types'; +import { InfraMetadataAdapter } from './adapter_types'; -export class ElasticsearchCapabilitiesAdapter implements InfraCapabilitiesAdapter { +export class ElasticsearchMetadataAdapter implements InfraMetadataAdapter { private framework: InfraBackendFrameworkAdapter; constructor(framework: InfraBackendFrameworkAdapter) { this.framework = framework; } - public async getMetricCapabilities( + public async getMetricMetadata( req: InfraFrameworkRequest, sourceConfiguration: InfraSourceConfiguration, nodeName: string, nodeType: 'host' | 'container' | 'pod' - ): Promise { + ): Promise { const idFieldName = getIdFieldName(sourceConfiguration, nodeType); const metricQuery = { index: sourceConfiguration.metricAlias, @@ -58,7 +58,7 @@ export class ElasticsearchCapabilitiesAdapter implements InfraCapabilitiesAdapte const response = await this.framework.callWithRequest< any, - { metrics?: InfraCapabilityAggregationResponse } + { metrics?: InfraMetadataAggregationResponse } >(req, 'search', metricQuery); return response.aggregations && response.aggregations.metrics @@ -66,12 +66,12 @@ export class ElasticsearchCapabilitiesAdapter implements InfraCapabilitiesAdapte : []; } - public async getLogCapabilities( + public async getLogMetadata( req: InfraFrameworkRequest, sourceConfiguration: InfraSourceConfiguration, nodeName: string, nodeType: 'host' | 'container' | 'pod' - ): Promise { + ): Promise { const idFieldName = getIdFieldName(sourceConfiguration, nodeType); const logQuery = { index: sourceConfiguration.logAlias, @@ -105,7 +105,7 @@ export class ElasticsearchCapabilitiesAdapter implements InfraCapabilitiesAdapte const response = await this.framework.callWithRequest< any, - { metrics?: InfraCapabilityAggregationResponse } + { metrics?: InfraMetadataAggregationResponse } >(req, 'search', logQuery); return response.aggregations && response.aggregations.metrics diff --git a/x-pack/plugins/infra/server/lib/adapters/capabilities/index.ts b/x-pack/plugins/infra/server/lib/adapters/metadata/index.ts similarity index 100% rename from x-pack/plugins/infra/server/lib/adapters/capabilities/index.ts rename to x-pack/plugins/infra/server/lib/adapters/metadata/index.ts diff --git a/x-pack/plugins/infra/server/lib/compose/kibana.ts b/x-pack/plugins/infra/server/lib/compose/kibana.ts index 23c5c3a45bd23..635e413e152e5 100644 --- a/x-pack/plugins/infra/server/lib/compose/kibana.ts +++ b/x-pack/plugins/infra/server/lib/compose/kibana.ts @@ -6,18 +6,18 @@ import { Server } from 'hapi'; -import { ElasticsearchCapabilitiesAdapter } from '../adapters/capabilities/elasticsearch_capabilities_adapter'; import { InfraKibanaConfigurationAdapter } from '../adapters/configuration/kibana_configuration_adapter'; import { FrameworkFieldsAdapter } from '../adapters/fields/framework_fields_adapter'; import { InfraKibanaBackendFrameworkAdapter } from '../adapters/framework/kibana_framework_adapter'; import { InfraKibanaLogEntriesAdapter } from '../adapters/log_entries/kibana_log_entries_adapter'; +import { ElasticsearchMetadataAdapter } from '../adapters/metadata/elasticsearch_metadata_adapter'; import { KibanaMetricsAdapter } from '../adapters/metrics/kibana_metrics_adapter'; import { ElasticsearchNodesAdapter } from '../adapters/nodes/elasticsearch_nodes_adapter'; import { InfraElasticsearchSourceStatusAdapter } from '../adapters/source_status'; import { InfraConfigurationSourcesAdapter } from '../adapters/sources/configuration_sources_adapter'; -import { InfraCapabilitiesDomain } from '../domains/capabilities_domain'; import { InfraFieldsDomain } from '../domains/fields_domain'; import { InfraLogEntriesDomain } from '../domains/log_entries_domain'; +import { InfraMetadataDomain } from '../domains/metadata_domain'; import { InfraMetricsDomain } from '../domains/metrics_domain'; import { InfraNodesDomain } from '../domains/nodes_domain'; import { InfraBackendLibs, InfraConfiguration, InfraDomainLibs } from '../infra_types'; @@ -33,7 +33,7 @@ export function compose(server: Server): InfraBackendLibs { }); const domainLibs: InfraDomainLibs = { - capabilities: new InfraCapabilitiesDomain(new ElasticsearchCapabilitiesAdapter(framework), { + metadata: new InfraMetadataDomain(new ElasticsearchMetadataAdapter(framework), { sources, }), fields: new InfraFieldsDomain(new FrameworkFieldsAdapter(framework), { diff --git a/x-pack/plugins/infra/server/lib/domains/capabilities_domain/index.ts b/x-pack/plugins/infra/server/lib/domains/metadata_domain/index.ts similarity index 86% rename from x-pack/plugins/infra/server/lib/domains/capabilities_domain/index.ts rename to x-pack/plugins/infra/server/lib/domains/metadata_domain/index.ts index 525e60a00f786..8095e8424873a 100644 --- a/x-pack/plugins/infra/server/lib/domains/capabilities_domain/index.ts +++ b/x-pack/plugins/infra/server/lib/domains/metadata_domain/index.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export * from './capabilities_domain'; +export * from './metadata_domain'; diff --git a/x-pack/plugins/infra/server/lib/domains/capabilities_domain/capabilities_domain.ts b/x-pack/plugins/infra/server/lib/domains/metadata_domain/metadata_domain.ts similarity index 52% rename from x-pack/plugins/infra/server/lib/domains/capabilities_domain/capabilities_domain.ts rename to x-pack/plugins/infra/server/lib/domains/metadata_domain/metadata_domain.ts index 2b3f73a9eccf7..9453061f590ec 100644 --- a/x-pack/plugins/infra/server/lib/domains/capabilities_domain/capabilities_domain.ts +++ b/x-pack/plugins/infra/server/lib/domains/metadata_domain/metadata_domain.ts @@ -4,54 +4,49 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraCapabilitiesAdapter } from '../../adapters/capabilities'; -import { InfraCapabilityAggregationBucket, InfraFrameworkRequest } from '../../adapters/framework'; +import { InfraFrameworkRequest, InfraMetadataAggregationBucket } from '../../adapters/framework'; +import { InfraMetadataAdapter } from '../../adapters/metadata'; import { InfraSources } from '../../sources'; -export class InfraCapabilitiesDomain { +export class InfraMetadataDomain { constructor( - private readonly adapter: InfraCapabilitiesAdapter, + private readonly adapter: InfraMetadataAdapter, private readonly libs: { sources: InfraSources } ) {} - public async getCapabilities( + public async getMetadata( req: InfraFrameworkRequest, sourceId: string, nodeName: string, nodeType: string ) { const sourceConfiguration = await this.libs.sources.getConfiguration(sourceId); - const metricsPromise = this.adapter.getMetricCapabilities( - req, - sourceConfiguration, - nodeName, - nodeType - ); - const logsPromise = this.adapter.getLogCapabilities( + const metricsPromise = this.adapter.getMetricMetadata( req, sourceConfiguration, nodeName, nodeType ); + const logsPromise = this.adapter.getLogMetadata(req, sourceConfiguration, nodeName, nodeType); const metrics = await metricsPromise; const logs = await logsPromise; - const metricCapabilities = pickCapabilities(metrics).map(metricCapability => { - return { name: metricCapability, source: 'metrics' }; + const metricMetadata = pickMetadata(metrics).map(entry => { + return { name: entry, source: 'metrics' }; }); - const logCapabilities = pickCapabilities(logs).map(logCapability => { - return { name: logCapability, source: 'logs' }; + const logMetadata = pickMetadata(logs).map(entry => { + return { name: entry, source: 'logs' }; }); - return metricCapabilities.concat(logCapabilities); + return metricMetadata.concat(logMetadata); } } -const pickCapabilities = (buckets: InfraCapabilityAggregationBucket[]): string[] => { +const pickMetadata = (buckets: InfraMetadataAggregationBucket[]): string[] => { if (buckets) { - const capabilities = buckets + const metadata = buckets .map(module => { if (module.names) { return module.names.buckets.map(name => { @@ -62,7 +57,7 @@ const pickCapabilities = (buckets: InfraCapabilityAggregationBucket[]): string[] } }) .reduce((a: string[], b: string[]) => a.concat(b), []); - return capabilities; + return metadata; } else { return []; } diff --git a/x-pack/plugins/infra/server/lib/infra_types.ts b/x-pack/plugins/infra/server/lib/infra_types.ts index 2a24a65daf8d6..3bb2fe3247416 100644 --- a/x-pack/plugins/infra/server/lib/infra_types.ts +++ b/x-pack/plugins/infra/server/lib/infra_types.ts @@ -6,16 +6,16 @@ import { InfraConfigurationAdapter } from './adapters/configuration'; import { InfraBackendFrameworkAdapter, InfraFrameworkRequest } from './adapters/framework'; -import { InfraCapabilitiesDomain } from './domains/capabilities_domain'; import { InfraFieldsDomain } from './domains/fields_domain'; import { InfraLogEntriesDomain } from './domains/log_entries_domain'; +import { InfraMetadataDomain } from './domains/metadata_domain'; import { InfraMetricsDomain } from './domains/metrics_domain'; import { InfraNodesDomain } from './domains/nodes_domain'; import { InfraSourceStatus } from './source_status'; import { InfraSourceConfigurations, InfraSources } from './sources'; export interface InfraDomainLibs { - capabilities: InfraCapabilitiesDomain; + metadata: InfraMetadataDomain; fields: InfraFieldsDomain; logEntries: InfraLogEntriesDomain; nodes: InfraNodesDomain; diff --git a/x-pack/test/api_integration/apis/infra/index.js b/x-pack/test/api_integration/apis/infra/index.js index aadef1c18b8f8..29074b31aa3e3 100644 --- a/x-pack/test/api_integration/apis/infra/index.js +++ b/x-pack/test/api_integration/apis/infra/index.js @@ -7,7 +7,7 @@ export default function ({ loadTestFile }) { describe('InfraOps GraphQL Endpoints', () => { - loadTestFile(require.resolve('./capabilities')); + loadTestFile(require.resolve('./metadata')); loadTestFile(require.resolve('./log_entries')); loadTestFile(require.resolve('./log_summary')); loadTestFile(require.resolve('./metrics')); diff --git a/x-pack/test/api_integration/apis/infra/capabilities.ts b/x-pack/test/api_integration/apis/infra/metadata.ts similarity index 57% rename from x-pack/test/api_integration/apis/infra/capabilities.ts rename to x-pack/test/api_integration/apis/infra/metadata.ts index 56b3349b8f943..741a2268803ab 100644 --- a/x-pack/test/api_integration/apis/infra/capabilities.ts +++ b/x-pack/test/api_integration/apis/infra/metadata.ts @@ -5,22 +5,22 @@ */ import expect from 'expect.js'; -import { CapabilitiesQuery } from '../../../../plugins/infra/common/graphql/types'; -import { capabilitiesQuery } from '../../../../plugins/infra/public/containers/capabilities/capabilities.gql_query'; +import { MetadataQuery } from '../../../../plugins/infra/common/graphql/types'; +import { metadataQuery } from '../../../../plugins/infra/public/containers/metadata/metadata.gql_query'; import { KbnTestProvider } from './types'; -const capabilitiesTests: KbnTestProvider = ({ getService }) => { +const metadataTests: KbnTestProvider = ({ getService }) => { const esArchiver = getService('esArchiver'); const client = getService('infraOpsGraphQLClient'); - describe('capabilities', () => { + describe('metadata', () => { before(() => esArchiver.load('infra')); after(() => esArchiver.unload('infra')); - it('supports the capabilities container query', () => { + it('supports the metadata container query', () => { return client - .query({ - query: capabilitiesQuery, + .query({ + query: metadataQuery, variables: { sourceId: 'default', nodeId: 'demo-stack-nginx-01', @@ -28,12 +28,12 @@ const capabilitiesTests: KbnTestProvider = ({ getService }) => { }, }) .then(resp => { - const capabilities = resp.data.source.capabilitiesByNode; - expect(capabilities.length).to.be(14); + const metadata = resp.data.source.metadataByNode; + expect(metadata.length).to.be(14); }); }); }); }; // tslint:disable-next-line no-default-export -export default capabilitiesTests; +export default metadataTests; From 973640c3b8d65c060e8cc5f25813402171e35c16 Mon Sep 17 00:00:00 2001 From: tibmt Date: Tue, 20 Nov 2018 17:09:55 +0300 Subject: [PATCH 30/95] Discover translations (#24079) * translate discover plugin * update discover translation PR * Update fetch_error.js * Update unit tests * Fix eslint * use separate span tag for label * use separate tags for translated labels * resolve review comments * Update snapshot * fix issue with bucket aria-label * fix quotes * Update snapshot * fix quotes * update snapshots --- .../components/fetch_error/fetch_error.js | 26 ++- .../field_chooser/discover_field.html | 2 +- .../field_chooser/discover_field.js | 23 ++- .../field_chooser/field_chooser.html | 72 +++++--- .../components/field_chooser/field_chooser.js | 12 +- .../lib/detail_views/string.html | 35 +++- .../field_chooser/lib/field_calculator.js | 19 ++- .../public/discover/controllers/discover.js | 111 +++++++++--- .../controllers/get_painless_error.ts | 6 +- .../__snapshots__/no_results.test.js.snap | 8 +- .../public/discover/directives/index.js | 5 +- .../public/discover/directives/no_results.js | 158 ++++++++++++++---- .../discover/directives/no_results.test.js | 16 +- .../directives/unsupported_index_pattern.js | 13 +- .../kibana/public/discover/index.html | 50 ++++-- .../kibana/public/discover/index.js | 10 +- .../discover/saved_searches/_saved_search.js | 6 +- .../open_search_panel.test.js.snap | 20 ++- .../discover/top_nav/open_search_panel.js | 20 ++- .../top_nav/show_open_search_panel.js | 11 +- 20 files changed, 481 insertions(+), 142 deletions(-) diff --git a/src/core_plugins/kibana/public/discover/components/fetch_error/fetch_error.js b/src/core_plugins/kibana/public/discover/components/fetch_error/fetch_error.js index 745693178d966..52dd71325a2a0 100644 --- a/src/core_plugins/kibana/public/discover/components/fetch_error/fetch_error.js +++ b/src/core_plugins/kibana/public/discover/components/fetch_error/fetch_error.js @@ -21,6 +21,7 @@ import 'ngreact'; import React, { Fragment } from 'react'; import { uiModules } from 'ui/modules'; import chrome from 'ui/chrome'; +import { FormattedMessage, injectI18nProvider } from '@kbn/i18n/react'; import { EuiFlexGroup, @@ -43,9 +44,26 @@ const DiscoverFetchError = ({ fetchError }) => { body = (

- You can address this error by editing the ‘{fetchError.script}’ field - in Management > Index Patterns, - under the “Scripted fields” tab. + , + managementLink: ( + + + + ) + }} + />

); } @@ -77,4 +95,4 @@ const DiscoverFetchError = ({ fetchError }) => { const app = uiModules.get('apps/discover', ['react']); -app.directive('discoverFetchError', reactDirective => reactDirective(DiscoverFetchError)); +app.directive('discoverFetchError', reactDirective => reactDirective(injectI18nProvider(DiscoverFetchError))); diff --git a/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html b/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html index 76d7bec8e454c..206239f6ae3c4 100644 --- a/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html +++ b/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html @@ -17,7 +17,7 @@ ng-if="field.name !== '_source'" ng-click="toggleDisplay(field)" ng-class="::field.display ? 'kuiButton--danger' : 'kuiButton--primary'" - ng-bind="::field.display ? 'remove' : 'add'" + ng-bind="::addRemoveButtonLabel" class="dscSidebarItem__action kuiButton kuiButton--small" data-test-subj="fieldToggle-{{::field.name}}" > diff --git a/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.js b/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.js index 4627dfbdcf9e8..8ff6e3a5751f6 100644 --- a/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.js +++ b/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.js @@ -26,7 +26,7 @@ import detailsHtml from './lib/detail_views/string.html'; import { uiModules } from 'ui/modules'; const app = uiModules.get('apps/discover'); -app.directive('discoverField', function ($compile) { +app.directive('discoverField', function ($compile, i18n) { return { restrict: 'E', template: html, @@ -42,11 +42,18 @@ app.directive('discoverField', function ($compile) { let detailsElem; let detailScope; - const init = function () { if ($scope.field.details) { $scope.toggleDetails($scope.field, true); } + + $scope.addRemoveButtonLabel = $scope.field.display + ? i18n('kbn.discover.fieldChooser.discoverField.removeButtonLabel', { + defaultMessage: 'remove', + }) + : i18n('kbn.discover.fieldChooser.discoverField.addButtonLabel', { + defaultMessage: 'add', + }); }; const getWarnings = function (field) { @@ -92,6 +99,18 @@ app.directive('discoverField', function ($compile) { $scope.onShowDetails(field, recompute); detailScope = $scope.$new(); detailScope.warnings = getWarnings(field); + detailScope.getBucketAriaLabel = (bucket) => { + return i18n('kbn.discover.fieldChooser.discoverField.bucketAriaLabel', { + defaultMessage: 'Value: {value}', + values: { + value: bucket.display === '' + ? i18n('kbn.discover.fieldChooser.discoverField.emptyStringText', { + defaultMessage: 'Empty string', + }) + : bucket.display, + }, + }); + }; detailsElem = $(detailsHtml); $compile(detailsElem)(detailScope); diff --git a/src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html b/src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html index 2e64db6656bca..73442a4ec74b8 100644 --- a/src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html +++ b/src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html @@ -1,4 +1,4 @@ -
diff --git a/src/core_plugins/kibana/public/discover/index.js b/src/core_plugins/kibana/public/discover/index.js index d1a0bb1c9f1e6..68685a9d5b28b 100644 --- a/src/core_plugins/kibana/public/discover/index.js +++ b/src/core_plugins/kibana/public/discover/index.js @@ -25,11 +25,15 @@ import './controllers/discover'; import 'ui/doc_table/components/table_row'; import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue'; -FeatureCatalogueRegistryProvider.register(() => { +FeatureCatalogueRegistryProvider.register(i18n => { return { id: 'discover', - title: 'Discover', - description: 'Interactively explore your data by querying and filtering raw documents.', + title: i18n('kbn.discover.discoverTitle', { + defaultMessage: 'Discover', + }), + description: i18n('kbn.discover.discoverDescription', { + defaultMessage: 'Interactively explore your data by querying and filtering raw documents.', + }), icon: 'discoverApp', path: '/app/kibana#/discover', showOnHomePage: true, diff --git a/src/core_plugins/kibana/public/discover/saved_searches/_saved_search.js b/src/core_plugins/kibana/public/discover/saved_searches/_saved_search.js index 5a15c5a08c6be..89df75c753520 100644 --- a/src/core_plugins/kibana/public/discover/saved_searches/_saved_search.js +++ b/src/core_plugins/kibana/public/discover/saved_searches/_saved_search.js @@ -27,7 +27,7 @@ const module = uiModules.get('discover/saved_searches', [ 'kibana/courier' ]); -module.factory('SavedSearch', function (Private) { +module.factory('SavedSearch', function (Private, i18n) { const SavedObject = Private(SavedObjectProvider); createLegacyClass(SavedSearch).inherits(SavedObject); function SavedSearch(id) { @@ -38,7 +38,9 @@ module.factory('SavedSearch', function (Private) { id: id, defaults: { - title: 'New Saved Search', + title: i18n('kbn.discover.savedSearch.newSavedSearchTitle', { + defaultMessage: 'New Saved Search', + }), description: '', columns: [], hits: 0, diff --git a/src/core_plugins/kibana/public/discover/top_nav/__snapshots__/open_search_panel.test.js.snap b/src/core_plugins/kibana/public/discover/top_nav/__snapshots__/open_search_panel.test.js.snap index 4ddf453c5a819..05b8fae9ab1dd 100644 --- a/src/core_plugins/kibana/public/discover/top_nav/__snapshots__/open_search_panel.test.js.snap +++ b/src/core_plugins/kibana/public/discover/top_nav/__snapshots__/open_search_panel.test.js.snap @@ -16,7 +16,11 @@ exports[`render 1`] = ` textTransform="none" >

- Open Search +

- Manage searches + } makeUrl={[Function]} - noItemsMessage="No matching searches found." + noItemsMessage={ + + } onChoose={[Function]} savedObjectType="search" /> diff --git a/src/core_plugins/kibana/public/discover/top_nav/open_search_panel.js b/src/core_plugins/kibana/public/discover/top_nav/open_search_panel.js index f06dcf5d9c3d6..1235272588fcb 100644 --- a/src/core_plugins/kibana/public/discover/top_nav/open_search_panel.js +++ b/src/core_plugins/kibana/public/discover/top_nav/open_search_panel.js @@ -21,6 +21,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; import rison from 'rison-node'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSpacer, @@ -40,7 +41,10 @@ export class OpenSearchPanel extends React.Component { onClick={this.props.onClose} href={`#/management/kibana/objects?_a=${rison.encode({ tab: SEARCH_OBJECT_TYPE })}`} > - Manage searches + ); } @@ -55,13 +59,23 @@ export class OpenSearchPanel extends React.Component { -

Open Search

+

+ +

+ } savedObjectType={SEARCH_OBJECT_TYPE} makeUrl={this.props.makeUrl} onChoose={this.props.onClose} diff --git a/src/core_plugins/kibana/public/discover/top_nav/show_open_search_panel.js b/src/core_plugins/kibana/public/discover/top_nav/show_open_search_panel.js index 5b76f9ebc6652..febfd55514910 100644 --- a/src/core_plugins/kibana/public/discover/top_nav/show_open_search_panel.js +++ b/src/core_plugins/kibana/public/discover/top_nav/show_open_search_panel.js @@ -20,6 +20,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { OpenSearchPanel } from './open_search_panel'; +import { I18nProvider } from '@kbn/i18n/react'; let isOpen = false; @@ -38,10 +39,12 @@ export function showOpenSearchPanel({ makeUrl }) { document.body.appendChild(container); const element = ( - + + + ); ReactDOM.render(element, container); } From 8104a028d0352caa8ecb5da3dcb171f70fcfa0f7 Mon Sep 17 00:00:00 2001 From: tibmt Date: Tue, 20 Nov 2018 17:12:18 +0300 Subject: [PATCH 31/95] translate InfraOps visualization component (Part 1 - folder pages) (#25194) * translate InfraOps vizualization component (Part 1 - folder pages) * update translation of Beats Management vizualization component (Part 1 - folder components) * Update toolbar.tsx * update translation of Beats Management vizualization component (Part 1 - folder components) * update translation of Infra Ops vizualization component (Part 1) * update translation of Infra Ops vizualization component (Part 1) * update Infra Ops Part 1 - change some ids, change i18n.translate() to intl.formatMessage() and directly wrap some classes by injectI18n() * update Infra-I - add static to displayName, update some ids --- .i18nrc.json | 6 +- .../plugins/infra/public/apps/start_app.tsx | 21 +- x-pack/plugins/infra/public/pages/404.tsx | 10 +- x-pack/plugins/infra/public/pages/error.tsx | 15 +- .../plugins/infra/public/pages/home/index.tsx | 84 +++-- .../infra/public/pages/home/toolbar.tsx | 43 ++- .../pages/link_to/redirect_to_node_logs.tsx | 62 ++-- .../plugins/infra/public/pages/logs/logs.tsx | 94 ++++-- .../infra/public/pages/logs/toolbar.tsx | 10 +- .../infra/public/pages/metrics/index.tsx | 310 +++++++++--------- .../public/pages/metrics/layouts/container.ts | 135 +++++++- .../public/pages/metrics/layouts/host.ts | 201 ++++++++++-- .../public/pages/metrics/layouts/nginx.ts | 36 +- .../infra/public/pages/metrics/layouts/pod.ts | 81 ++++- 14 files changed, 788 insertions(+), 320 deletions(-) diff --git a/.i18nrc.json b/.i18nrc.json index 4f7027e36ee3d..33e25169ce827 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -16,6 +16,7 @@ "tagCloud": "src/core_plugins/tagcloud", "xpack.grokDebugger": "x-pack/plugins/grokdebugger", "xpack.idxMgmt": "x-pack/plugins/index_management", + "xpack.infra": "x-pack/plugins/infra", "xpack.licenseMgmt": "x-pack/plugins/license_management", "xpack.monitoring": "x-pack/plugins/monitoring", "xpack.rollupJobs": "x-pack/plugins/rollup", @@ -25,6 +26,9 @@ }, "exclude": [ "src/ui/ui_render/bootstrap/app_bootstrap.js", - "src/ui/ui_render/ui_render_mixin.js" + "src/ui/ui_render/ui_render_mixin.js", + "x-pack/plugins/infra/public/utils/loading_state/loading_result.ts", + "x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts" + ] } diff --git a/x-pack/plugins/infra/public/apps/start_app.tsx b/x-pack/plugins/infra/public/apps/start_app.tsx index da32e65e8ffb0..7e9c7dfb53b0c 100644 --- a/x-pack/plugins/infra/public/apps/start_app.tsx +++ b/x-pack/plugins/infra/public/apps/start_app.tsx @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { I18nProvider } from '@kbn/i18n/react'; import { createHashHistory } from 'history'; import React from 'react'; import { ApolloProvider } from 'react-apollo'; @@ -29,14 +30,16 @@ export async function startApp(libs: InfraFrontendLibs) { }); libs.framework.render( - - - - - - - - - + + + + + + + + + + + ); } diff --git a/x-pack/plugins/infra/public/pages/404.tsx b/x-pack/plugins/infra/public/pages/404.tsx index 956bf90e84927..d99d7339c79d7 100644 --- a/x-pack/plugins/infra/public/pages/404.tsx +++ b/x-pack/plugins/infra/public/pages/404.tsx @@ -4,10 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ +import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; export class NotFoundPage extends React.PureComponent { public render() { - return
No content found
; + return ( +
+ +
+ ); } } diff --git a/x-pack/plugins/infra/public/pages/error.tsx b/x-pack/plugins/infra/public/pages/error.tsx index 75b158c42c5a1..0fd62ccd7e0a1 100644 --- a/x-pack/plugins/infra/public/pages/error.tsx +++ b/x-pack/plugins/infra/public/pages/error.tsx @@ -12,6 +12,7 @@ import { EuiPageHeaderSection, EuiTitle, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; import styled from 'styled-components'; import { Header } from '../components/header'; @@ -44,13 +45,23 @@ export const ErrorPageBody: React.SFC<{ message: string }> = ({ message }) => { -

Oops!

+

+ +

-

Please click the back button and try again.

+

+ +

diff --git a/x-pack/plugins/infra/public/pages/home/index.tsx b/x-pack/plugins/infra/public/pages/home/index.tsx index 9032b30d42266..20d8194e77026 100644 --- a/x-pack/plugins/infra/public/pages/home/index.tsx +++ b/x-pack/plugins/infra/public/pages/home/index.tsx @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React from 'react'; import { HomePageContent } from './page_content'; @@ -20,37 +21,54 @@ import { WithWaffleTimeUrlState } from '../../containers/waffle/with_waffle_time import { WithKibanaChrome } from '../../containers/with_kibana_chrome'; import { WithSource } from '../../containers/with_source'; -export class HomePage extends React.PureComponent { - public render() { - return ( - - - {({ metricIndicesExist }) => - metricIndicesExist || metricIndicesExist === null ? ( - <> - - - -
} /> - - - - ) : ( - - {({ basePath }) => ( - - )} - - ) - } - - - ); - } +interface HomePageProps { + intl: InjectedIntl; } + +export const HomePage = injectI18n( + class extends React.PureComponent { + public static displayName = 'HomePage'; + public render() { + const { intl } = this.props; + return ( + + + {({ metricIndicesExist }) => + metricIndicesExist || metricIndicesExist === null ? ( + <> + + + +
} /> + + + + ) : ( + + {({ basePath }) => ( + + )} + + ) + } + + + ); + } + } +); diff --git a/x-pack/plugins/infra/public/pages/home/toolbar.tsx b/x-pack/plugins/infra/public/pages/home/toolbar.tsx index 5abccd9f9763d..f933fa097e8f6 100644 --- a/x-pack/plugins/infra/public/pages/home/toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/home/toolbar.tsx @@ -5,6 +5,8 @@ */ import { EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elastic/eui'; +// import { i18n } from '@kbn/i18n'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; import React from 'react'; import { AutocompleteField } from '../../components/autocomplete_field'; @@ -20,25 +22,45 @@ import { WithWaffleOptions } from '../../containers/waffle/with_waffle_options'; import { WithWaffleTime } from '../../containers/waffle/with_waffle_time'; import { WithKueryAutocompletion } from '../../containers/with_kuery_autocompletion'; -const TITLES = { - [InfraNodeType.host]: 'Hosts', - [InfraNodeType.pod]: 'Kubernetes Pods', - [InfraNodeType.container]: 'Docker Containers', +const getTitle = (nodeType: string) => { + const TITLES = { + [InfraNodeType.host as string]: ( + + ), + [InfraNodeType.pod as string]: ( + + ), + [InfraNodeType.container as string]: ( + + ), + }; + return TITLES[nodeType]; }; -export const HomeToolbar: React.SFC = () => ( +export const HomeToolbar = injectI18n(({ intl }) => ( {({ nodeType }) => ( -

{TITLES[nodeType]}

+

{getTitle(nodeType)}

)}
-

Showing the last 1 minute of data from the time period

+

+ +

@@ -71,7 +93,10 @@ export const HomeToolbar: React.SFC = () => ( loadSuggestions={loadSuggestions} onChange={setFilterQueryDraftFromKueryExpression} onSubmit={applyFilterQueryFromKueryExpression} - placeholder="Search for infrastructure data... (e.g. host.name:host-1)" + placeholder={intl.formatMessage({ + id: 'xpack.infra.homePage.toolbar.kqlSearchFieldPlaceholder', + defaultMessage: 'Search for infrastructure data… (e.g. host.name:host-1)', + })} suggestions={suggestions} value={filterQueryDraft ? filterQueryDraft.expression : ''} /> @@ -111,4 +136,4 @@ export const HomeToolbar: React.SFC = () => (
-); +)); diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx index 821bb1126658d..dd28030076b92 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; import compose from 'lodash/fp/compose'; import React from 'react'; import { Redirect, RouteComponentProps } from 'react-router-dom'; @@ -15,31 +16,50 @@ import { replaceLogPositionInQueryString } from '../../containers/logs/with_log_ import { WithSource } from '../../containers/with_source'; import { getTimeFromLocation } from './query_params'; -type RedirectToNodeLogsProps = RouteComponentProps<{ +type RedirectToNodeLogsType = RouteComponentProps<{ nodeName: string; nodeType: InfraNodeType; }>; -export const RedirectToNodeLogs = ({ - match: { - params: { nodeName, nodeType }, - }, - location, -}: RedirectToNodeLogsProps) => ( - - {({ configuredFields }) => { - if (!configuredFields) { - return ; - } - - const searchString = compose( - replaceLogFilterInQueryString(`${configuredFields[nodeType]}: ${nodeName}`), - replaceLogPositionInQueryString(getTimeFromLocation(location)) - )(''); - - return ; - }} - +interface RedirectToNodeLogsProps extends RedirectToNodeLogsType { + intl: InjectedIntl; +} + +export const RedirectToNodeLogs = injectI18n( + ({ + match: { + params: { nodeName, nodeType }, + }, + location, + intl, + }: RedirectToNodeLogsProps) => ( + + {({ configuredFields }) => { + if (!configuredFields) { + return ( + + ); + } + + const searchString = compose( + replaceLogFilterInQueryString(`${configuredFields[nodeType]}: ${nodeName}`), + replaceLogPositionInQueryString(getTimeFromLocation(location)) + )(''); + + return ; + }} + + ) ); export const getNodeLogsUrl = ({ diff --git a/x-pack/plugins/infra/public/pages/logs/logs.tsx b/x-pack/plugins/infra/public/pages/logs/logs.tsx index 7b24cbaa52609..810cda560071f 100644 --- a/x-pack/plugins/infra/public/pages/logs/logs.tsx +++ b/x-pack/plugins/infra/public/pages/logs/logs.tsx @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React from 'react'; import { LogsPageContent } from './page_content'; @@ -21,40 +22,63 @@ import { WithLogTextviewUrlState } from '../../containers/logs/with_log_textview import { WithKibanaChrome } from '../../containers/with_kibana_chrome'; import { WithSource } from '../../containers/with_source'; -export class LogsPage extends React.Component { - public render() { - return ( - - - {({ logIndicesExist }) => - logIndicesExist || logIndicesExist === null ? ( - <> - - - - -
} - breadcrumbs={[{ text: 'Logs' }]} - /> - - - - ) : ( - - {({ basePath }) => ( - { + public static displayName = 'LogsPage'; + public render() { + const { intl } = this.props; + return ( + + + {({ logIndicesExist }) => + logIndicesExist || logIndicesExist === null ? ( + <> + + + + +
} + breadcrumbs={[ + { + text: intl.formatMessage({ + id: 'xpack.infra.logsPage.logsBreadcrumbsText', + defaultMessage: 'Logs', + }), + }, + ]} /> - )} - - ) - } - - - ); + + + + ) : ( + + {({ basePath }) => ( + + )} + + ) + } + + + ); + } } -} +); diff --git a/x-pack/plugins/infra/public/pages/logs/toolbar.tsx b/x-pack/plugins/infra/public/pages/logs/toolbar.tsx index 7c7c7004c4674..f3e06c2779158 100644 --- a/x-pack/plugins/infra/public/pages/logs/toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/logs/toolbar.tsx @@ -5,6 +5,7 @@ */ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { injectI18n } from '@kbn/i18n/react'; import React from 'react'; import { AutocompleteField } from '../../components/autocomplete_field'; @@ -20,7 +21,7 @@ import { WithLogPosition } from '../../containers/logs/with_log_position'; import { WithLogTextview } from '../../containers/logs/with_log_textview'; import { WithKueryAutocompletion } from '../../containers/with_kuery_autocompletion'; -export const LogsToolbar: React.SFC = () => ( +export const LogsToolbar = injectI18n(({ intl }) => ( @@ -40,7 +41,10 @@ export const LogsToolbar: React.SFC = () => ( loadSuggestions={loadSuggestions} onChange={setFilterQueryDraftFromKueryExpression} onSubmit={applyFilterQueryFromKueryExpression} - placeholder="Search for log entries... (e.g. host.name:host-1)" + placeholder={intl.formatMessage({ + id: 'xpack.infra.logsPage.toolbar.kqlSearchFieldPlaceholder', + defaultMessage: 'Search for log entries… (e.g. host.name:host-1)', + })} suggestions={suggestions} value={filterQueryDraft ? filterQueryDraft.expression : ''} /> @@ -95,4 +99,4 @@ export const LogsToolbar: React.SFC = () => ( -); +)); diff --git a/x-pack/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx index c67018d5eb019..6b089722b1f85 100644 --- a/x-pack/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -17,6 +17,7 @@ import { EuiSideNav, EuiTitle, } from '@elastic/eui'; +import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; import styled, { withTheme } from 'styled-components'; import { InfraNodeType, InfraTimerangeInput } from '../../../common/graphql/types'; import { AutoSizer } from '../../components/auto_sizer'; @@ -53,162 +54,177 @@ interface Props { node: string; }; }; + intl: InjectedIntl; } -class MetricDetailPage extends React.PureComponent { - public readonly state = { - isSideNavOpenOnMobile: false, - }; +export const MetricDetail = withTheme( + injectI18n( + class extends React.PureComponent { + public static displayName = 'MetricDetailPage'; + public readonly state = { + isSideNavOpenOnMobile: false, + }; - public render() { - const nodeName = this.props.match.params.node; - const nodeType = this.props.match.params.type as InfraNodeType; - const layoutCreator = layoutCreators[nodeType]; - if (!layoutCreator) { - return ; - } - const layouts = layoutCreator(this.props.theme); - const breadcrumbs = [{ text: nodeName }]; + public render() { + const { intl } = this.props; + const nodeName = this.props.match.params.node; + const nodeType = this.props.match.params.type as InfraNodeType; + const layoutCreator = layoutCreators[nodeType]; + if (!layoutCreator) { + return ( + + ); + } + const layouts = layoutCreator(this.props.theme); + const breadcrumbs = [{ text: nodeName }]; + + return ( + +
} + breadcrumbs={breadcrumbs} + /> + + + + {({ sourceId }) => ( + + {({ + currentTimeRange, + isAutoReloading, + setRangeTime, + startMetricsAutoReload, + stopMetricsAutoReload, + }) => ( + + {({ filteredLayouts }) => { + return ( + + {({ metrics, error, loading }) => { + if (error) { + return ; + } + const sideNav = filteredLayouts.map(item => { + return { + name: item.label, + id: item.id, + items: item.sections.map(section => ({ + id: section.id as string, + name: section.label, + onClick: this.handleClick(section), + })), + }; + }); + return ( + + + + + + + + + + + + + {({ measureRef, bounds: { width = 0 } }) => { + return ( + + + + + + + +

{nodeName}

+
+
+ +
+
+
- return ( - -
} - breadcrumbs={breadcrumbs} - /> - - - - {({ sourceId }) => ( - - {({ - currentTimeRange, - isAutoReloading, - setRangeTime, - startMetricsAutoReload, - stopMetricsAutoReload, - }) => ( - - {({ filteredLayouts }) => { - return ( - - {({ metrics, error, loading }) => { - if (error) { - return ; - } - const sideNav = filteredLayouts.map(item => { - return { - name: item.label, - id: item.id, - items: item.sections.map(section => ({ - id: section.id as string, - name: section.label, - onClick: this.handleClick(section), - })), - }; - }); - return ( - - - - - - - - - - - - - {({ measureRef, bounds: { width = 0 } }) => { - return ( - - - - - - - -

{nodeName}

-
-
- + 0 && isAutoReloading + ? false + : loading + } onChangeRangeTime={setRangeTime} - startLiveStreaming={startMetricsAutoReload} - stopLiveStreaming={stopMetricsAutoReload} /> -
-
-
- - - 0 && isAutoReloading - ? false - : loading - } - onChangeRangeTime={setRangeTime} - /> - -
-
- ); - }} -
-
- ); - }} -
- ); - }} -
+ + + + ); + }} + + + ); + }} + + ); + }} + + )} +
)} - - )} -
-
- - ); - } - - private handleClick = (section: InfraMetricLayoutSection) => () => { - const id = section.linkToId || section.id; - const el = document.getElementById(id); - if (el) { - el.scrollIntoView(); - } - }; + + + + ); + } - private toggleOpenOnMobile = () => { - this.setState({ - isSideNavOpenOnMobile: !this.state.isSideNavOpenOnMobile, - }); - }; -} + private handleClick = (section: InfraMetricLayoutSection) => () => { + const id = section.linkToId || section.id; + const el = document.getElementById(id); + if (el) { + el.scrollIntoView(); + } + }; -export const MetricDetail = withTheme(MetricDetailPage); + private toggleOpenOnMobile = () => { + this.setState({ + isSideNavOpenOnMobile: !this.state.isSideNavOpenOnMobile, + }); + }; + } + ) +); const EuiSideNavContainer = styled.div` position: fixed; diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/container.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/container.ts index 181f35435b9a7..c9b85021c108e 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/container.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/container.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { InfraMetric } from '../../../../common/graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { nginxLayoutCreator } from './nginx'; @@ -16,35 +17,62 @@ import { export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [ { id: 'containerOverview', - label: 'Container', + label: i18n.translate('xpack.infra.metricDetailPage.containerMetricsLayout.layoutLabel', { + defaultMessage: 'Container', + }), sections: [ { id: InfraMetric.containerOverview, - label: 'Overview', + label: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.sectionLabel', + { + defaultMessage: 'Overview', + } + ), requires: ['docker.cpu', 'docker.memory', 'docker.network'], type: InfraMetricLayoutSectionType.gauges, visConfig: { seriesOverrides: { cpu: { - name: 'CPU Usage', + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.cpuUsageSeriesLabel', + { + defaultMessage: 'CPU Usage', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.percent, gaugeMax: 1, }, memory: { - name: 'Memory Usage', + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.memoryUsageSeriesLabel', + { + defaultMessage: 'Memory Usage', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.percent, gaugeMax: 1, }, rx: { - name: 'Inbound (RX)', + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.inboundRXSeriesLabel', + { + defaultMessage: 'Inbound (RX)', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.bits, formatterTemplate: '{{value}}/s', }, tx: { - name: 'Outbound (TX)', + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.outboundTXSeriesLabel', + { + defaultMessage: 'Outbound (TX)', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.bits, formatterTemplate: '{{value}}/s', @@ -54,7 +82,12 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.containerCpuUsage, - label: 'CPU Usage', + label: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.cpuUsageSection.sectionLabel', + { + defaultMessage: 'CPU Usage', + } + ), requires: ['docker.cpu'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -68,7 +101,12 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.containerMemory, - label: 'Memory Usage', + label: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.memoryUsageSection.sectionLabel', + { + defaultMessage: 'Memory Usage', + } + ), requires: ['docker.memory'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -82,7 +120,12 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.containerNetworkTraffic, - label: 'Network Traffic', + label: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.networkTrafficSection.sectionLabel', + { + defaultMessage: 'Network Traffic', + } + ), requires: ['docker.network'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -90,14 +133,35 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [ formatterTemplate: '{{value}}/s', type: InfraMetricLayoutVisualizationType.area, seriesOverrides: { - rx: { color: theme.eui.euiColorVis1, name: 'in' }, - tx: { color: theme.eui.euiColorVis2, name: 'out' }, + rx: { + color: theme.eui.euiColorVis1, + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.networkTrafficSection.networkRxRateSeriesLabel', + { + defaultMessage: 'in', + } + ), + }, + tx: { + color: theme.eui.euiColorVis2, + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.networkTrafficSection.networkTxRateSeriesLabel', + { + defaultMessage: 'out', + } + ), + }, }, }, }, { id: InfraMetric.containerDiskIOOps, - label: 'Disk IO (Ops)', + label: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoOpsSection.sectionLabel', + { + defaultMessage: 'Disk IO (Ops)', + } + ), requires: ['docker.diskio'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -105,14 +169,35 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [ formatterTemplate: '{{value}}/s', type: InfraMetricLayoutVisualizationType.area, seriesOverrides: { - read: { color: theme.eui.euiColorVis1, name: 'reads' }, - write: { color: theme.eui.euiColorVis2, name: 'writes' }, + read: { + color: theme.eui.euiColorVis1, + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoOpsSection.readRateSeriesLabel', + { + defaultMessage: 'reads', + } + ), + }, + write: { + color: theme.eui.euiColorVis2, + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoOpsSection.writeRateSeriesLabel', + { + defaultMessage: 'writes', + } + ), + }, }, }, }, { id: InfraMetric.containerDiskIOBytes, - label: 'Disk IO (Bytes)', + label: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoBytesSection.sectionLabel', + { + defaultMessage: 'Disk IO (Bytes)', + } + ), requires: ['docker.diskio'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -120,8 +205,24 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [ formatterTemplate: '{{value}}/s', type: InfraMetricLayoutVisualizationType.area, seriesOverrides: { - read: { color: theme.eui.euiColorVis1, name: 'reads' }, - write: { color: theme.eui.euiColorVis2, name: 'writes' }, + read: { + color: theme.eui.euiColorVis1, + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoBytesSection.readRateSeriesLabel', + { + defaultMessage: 'reads', + } + ), + }, + write: { + color: theme.eui.euiColorVis2, + name: i18n.translate( + 'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoBytesSection.writeRateSeriesLabel', + { + defaultMessage: 'writes', + } + ), + }, }, }, }, diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/host.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/host.ts index 83c4f6ad52b7d..663d5f89802d8 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/host.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/host.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { InfraMetric } from '../../../../common/graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { nginxLayoutCreator } from './nginx'; @@ -16,37 +17,72 @@ import { export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ { id: 'hostOverview', - label: 'Host', + label: i18n.translate('xpack.infra.metricDetailPage.hostMetricsLayout.layoutLabel', { + defaultMessage: 'Host', + }), sections: [ { id: InfraMetric.hostSystemOverview, linkToId: 'hostOverview', - label: 'Overview', + label: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.overviewSection.sectionLabel', + { + defaultMessage: 'Overview', + } + ), requires: ['system.cpu', 'system.load', 'system.memory', 'system.network'], type: InfraMetricLayoutSectionType.gauges, visConfig: { seriesOverrides: { cpu: { - name: 'CPU Usage', + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.overviewSection.cpuUsageSeriesLabel', + { + defaultMessage: 'CPU Usage', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.percent, gaugeMax: 1, }, - load: { name: 'Load (5m)', color: theme.eui.euiColorFullShade }, + load: { + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.overviewSection.loadSeriesLabel', + { + defaultMessage: 'Load (5m)', + } + ), + color: theme.eui.euiColorFullShade, + }, memory: { - name: 'Memory Usage', + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.overviewSection.memoryCapacitySeriesLabel', + { + defaultMessage: 'Memory Usage', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.percent, gaugeMax: 1, }, rx: { - name: 'Inbound (RX)', + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.overviewSection.inboundRXSeriesLabel', + { + defaultMessage: 'Inbound (RX)', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.bits, formatterTemplate: '{{value}}/s', }, tx: { - name: 'Outbound (TX)', + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.overviewSection.outboundTXSeriesLabel', + { + defaultMessage: 'Outbound (TX)', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.bits, formatterTemplate: '{{value}}/s', @@ -56,7 +92,12 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.hostCpuUsage, - label: 'CPU Usage', + label: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.cpuUsageSection.sectionLabel', + { + defaultMessage: 'CPU Usage', + } + ), requires: ['system.cpu'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -77,20 +118,54 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.hostLoad, - label: 'Load', + label: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.loadSection.sectionLabel', + { + defaultMessage: 'Load', + } + ), requires: ['system.load'], type: InfraMetricLayoutSectionType.chart, visConfig: { seriesOverrides: { - load_1m: { color: theme.eui.euiColorVis0, name: '1m' }, - load_5m: { color: theme.eui.euiColorVis1, name: '5m' }, - load_15m: { color: theme.eui.euiColorVis3, name: '15m' }, + load_1m: { + color: theme.eui.euiColorVis0, + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.loadSection.oneMinuteSeriesLabel', + { + defaultMessage: '1m', + } + ), + }, + load_5m: { + color: theme.eui.euiColorVis1, + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.loadSection.fiveMinuteSeriesLabel', + { + defaultMessage: '5m', + } + ), + }, + load_15m: { + color: theme.eui.euiColorVis3, + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.loadSection.fifteenMinuteSeriesLabel', + { + defaultMessage: '15m', + } + ), + }, }, }, }, { id: InfraMetric.hostMemoryUsage, - label: 'MemoryUsage', + label: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.memoryUsageSection.sectionLabel', + { + defaultMessage: 'Memory Usage', + } + ), requires: ['system.memory'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -106,7 +181,12 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.hostNetworkTraffic, - label: 'Network Traffic', + label: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.networkTrafficSection.sectionLabel', + { + defaultMessage: 'Network Traffic', + } + ), requires: ['system.network'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -114,8 +194,24 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ formatterTemplate: '{{value}}/s', type: InfraMetricLayoutVisualizationType.area, seriesOverrides: { - rx: { color: theme.eui.euiColorVis1, name: 'in' }, - tx: { color: theme.eui.euiColorVis2, name: 'out' }, + rx: { + color: theme.eui.euiColorVis1, + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.networkTrafficSection.networkRxRateSeriesLabel', + { + defaultMessage: 'in', + } + ), + }, + tx: { + color: theme.eui.euiColorVis2, + name: i18n.translate( + 'xpack.infra.metricDetailPage.hostMetricsLayout.networkTrafficSection.networkTxRateSeriesLabel', + { + defaultMessage: 'out', + } + ), + }, }, }, }, @@ -128,32 +224,65 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ { id: InfraMetric.hostK8sOverview, linkToId: 'k8sOverview', - label: 'Overview', + label: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.overviewSection.sectionLabel', + { + defaultMessage: 'Overview', + } + ), requires: ['kubernetes.node'], type: InfraMetricLayoutSectionType.gauges, visConfig: { seriesOverrides: { cpucap: { - name: 'CPU Capacity', + name: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.overviewSection.cpuUsageSeriesLabel', + { + defaultMessage: 'CPU Capacity', + } + ), color: 'secondary', formatter: InfraFormatterType.percent, gaugeMax: 1, }, - load: { name: 'Load (5m)', color: 'secondary' }, + load: { + name: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.overviewSection.loadSeriesLabel', + { + defaultMessage: 'Load (5m)', + } + ), + color: 'secondary', + }, memorycap: { - name: 'Memory Capacity', + name: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.overviewSection.memoryUsageSeriesLabel', + { + defaultMessage: 'Memory Capacity', + } + ), color: 'secondary', formatter: InfraFormatterType.percent, gaugeMax: 1, }, podcap: { - name: 'Pod Capacity', + name: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.overviewSection.podCapacitySeriesLabel', + { + defaultMessage: 'Pod Capacity', + } + ), color: 'secondary', formatter: InfraFormatterType.percent, gaugeMax: 1, }, diskcap: { - name: 'Disk Capacity', + name: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.overviewSection.diskCapacitySeriesLabel', + { + defaultMessage: 'Disk Capacity', + } + ), color: 'secondary', formatter: InfraFormatterType.percent, gaugeMax: 1, @@ -163,7 +292,12 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.hostK8sCpuCap, - label: 'Node CPU Capacity', + label: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.nodeCpuCapacitySection.sectionLabel', + { + defaultMessage: 'Node CPU Capacity', + } + ), requires: ['kubernetes.node'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -176,7 +310,12 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.hostK8sMemoryCap, - label: 'Node Memory Capacity', + label: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.nodeMemoryCapacitySection.sectionLabel', + { + defaultMessage: 'Node Memory Capacity', + } + ), requires: ['kubernetes.node'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -189,7 +328,12 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.hostK8sDiskCap, - label: 'Node Disk Capacity', + label: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.nodeDiskCapacitySection.sectionLabel', + { + defaultMessage: 'Node Disk Capacity', + } + ), requires: ['kubernetes.node'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -202,7 +346,12 @@ export const hostLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.hostK8sPodCap, - label: 'Node Pod Capacity', + label: i18n.translate( + 'xpack.infra.metricDetailPage.kubernetesMetricsLayout.nodePodCapacitySection.sectionLabel', + { + defaultMessage: 'Node Pod Capacity', + } + ), requires: ['kubernetes.node'], type: InfraMetricLayoutSectionType.chart, visConfig: { diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/nginx.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/nginx.ts index f03580feb72c0..cee9f2ea43ab7 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/nginx.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/nginx.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { InfraMetric } from '../../../../common/graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { @@ -20,7 +21,12 @@ export const nginxLayoutCreator: InfraMetricLayoutCreator = theme => [ sections: [ { id: InfraMetric.nginxHits, - label: 'Hits', + label: i18n.translate( + 'xpack.infra.metricDetailPage.nginxMetricsLayout.hitsSection.sectionLabel', + { + defaultMessage: 'Hits', + } + ), requires: ['nginx.access'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -36,7 +42,12 @@ export const nginxLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.nginxRequestRate, - label: 'Request Rate', + label: i18n.translate( + 'xpack.infra.metricDetailPage.nginxMetricsLayout.requestRateSection.sectionLabel', + { + defaultMessage: 'Request Rate', + } + ), requires: ['nginx.statusstub'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -49,7 +60,12 @@ export const nginxLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.nginxActiveConnections, - label: 'Active Connections', + label: i18n.translate( + 'xpack.infra.metricDetailPage.nginxMetricsLayout.activeConnectionsSection.sectionLabel', + { + defaultMessage: 'Active Connections', + } + ), requires: ['nginx.statusstub'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -64,7 +80,12 @@ export const nginxLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.nginxRequestsPerConnection, - label: 'Requests per Connections', + label: i18n.translate( + 'xpack.infra.metricDetailPage.nginxMetricsLayout.requestsPerConnectionsSection.sectionLabel', + { + defaultMessage: 'Requests per Connections', + } + ), requires: ['nginx.statusstub'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -73,7 +94,12 @@ export const nginxLayoutCreator: InfraMetricLayoutCreator = theme => [ reqPerConns: { color: theme.eui.euiColorVis1, type: InfraMetricLayoutVisualizationType.bar, - name: 'reqs per conn', + name: i18n.translate( + 'xpack.infra.metricDetailPage.nginxMetricsLayout.requestsPerConnectionsSection.reqsPerConnSeriesLabel', + { + defaultMessage: 'reqs per conn', + } + ), }, }, }, diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/pod.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/pod.ts index 8794acee43848..612ccc8c79a6b 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/pod.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/pod.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { InfraMetric } from '../../../../common/graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { nginxLayoutCreator } from './nginx'; @@ -16,35 +17,62 @@ import { export const podLayoutCreator: InfraMetricLayoutCreator = theme => [ { id: 'podOverview', - label: 'Pod Overview', + label: i18n.translate('xpack.infra.metricDetailPage.podMetricsLayout.layoutLabel', { + defaultMessage: 'Pod', + }), sections: [ { id: InfraMetric.podOverview, - label: 'Pod Overview', + label: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.overviewSection.sectionLabel', + { + defaultMessage: 'Overview', + } + ), requires: ['kubernetes.pod'], type: InfraMetricLayoutSectionType.gauges, visConfig: { seriesOverrides: { cpu: { - name: 'CPU Usage', + name: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.overviewSection.cpuUsageSeriesLabel', + { + defaultMessage: 'CPU Usage', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.percent, gaugeMax: 1, }, memory: { - name: 'Memory Usage', + name: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.overviewSection.memoryUsageSeriesLabel', + { + defaultMessage: 'Memory Usage', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.percent, gaugeMax: 1, }, rx: { - name: 'Inbound (RX)', + name: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.overviewSection.inboundRXSeriesLabel', + { + defaultMessage: 'Inbound (RX)', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.bits, formatterTemplate: '{{value}}/s', }, tx: { - name: 'Outbound (TX)', + name: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.overviewSection.outboundTXSeriesLabel', + { + defaultMessage: 'Outbound (TX)', + } + ), color: theme.eui.euiColorFullShade, formatter: InfraFormatterType.bits, formatterTemplate: '{{value}}/s', @@ -54,7 +82,12 @@ export const podLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.podCpuUsage, - label: 'CPU Usage', + label: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.cpuUsageSection.sectionLabel', + { + defaultMessage: 'CPU Usage', + } + ), requires: ['kubernetes.pod'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -66,7 +99,12 @@ export const podLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.podMemoryUsage, - label: 'Memory Usage', + label: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.memoryUsageSection.sectionLabel', + { + defaultMessage: 'Memory Usage', + } + ), requires: ['kubernetes.pod'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -81,7 +119,12 @@ export const podLayoutCreator: InfraMetricLayoutCreator = theme => [ }, { id: InfraMetric.podNetworkTraffic, - label: 'Network Traffic', + label: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.networkTrafficSection.sectionLabel', + { + defaultMessage: 'Network Traffic', + } + ), requires: ['kubernetes.pod'], type: InfraMetricLayoutSectionType.chart, visConfig: { @@ -89,8 +132,24 @@ export const podLayoutCreator: InfraMetricLayoutCreator = theme => [ formatterTemplate: '{{value}}/s', type: InfraMetricLayoutVisualizationType.area, seriesOverrides: { - rx: { color: theme.eui.euiColorVis1, name: 'in' }, - tx: { color: theme.eui.euiColorVis2, name: 'out' }, + rx: { + color: theme.eui.euiColorVis1, + name: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.networkTrafficSection.networkRxRateSeriesLabel', + { + defaultMessage: 'in', + } + ), + }, + tx: { + color: theme.eui.euiColorVis2, + name: i18n.translate( + 'xpack.infra.metricDetailPage.podMetricsLayout.networkTrafficSection.networkTxRateSeriesLabel', + { + defaultMessage: 'out', + } + ), + }, }, }, }, From 076e00b3101f1a820322e4742eb434ac712efe1f Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 20 Nov 2018 08:05:20 -0800 Subject: [PATCH 32/95] [kbn-interpreter] ignore plugin build directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 15fa517ae7474..ca3da4ab034e4 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ package-lock.json npm-debug.log* .tern-project **/public/index.css +/packages/kbn-interpreter/plugin From 682c50c0c22fe8944dc9607cbe5d16eaa5913ae8 Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Tue, 20 Nov 2018 08:23:13 -0800 Subject: [PATCH 33/95] [APM] adds telemetry to APM (#25513) * [APM] adds telemetry to APM * [APM] Code and readability improvements for APM Telemetry * [APM] fixed failing tests for apm-telemetry and service routes * [APM] fix lint issues for APM Telemetry --- x-pack/plugins/apm/index.js | 11 +- x-pack/plugins/apm/mappings.json | 37 +++++ .../__test__/apm_telemetry.test.ts | 152 ++++++++++++++++++ .../server/lib/apm_telemetry/apm_telemetry.ts | 59 +++++++ .../apm/server/lib/apm_telemetry/index.ts | 14 ++ .../apm_telemetry/make_apm_usage_collector.ts | 42 +++++ x-pack/plugins/apm/server/routes/services.ts | 23 ++- 7 files changed, 335 insertions(+), 3 deletions(-) create mode 100644 x-pack/plugins/apm/mappings.json create mode 100644 x-pack/plugins/apm/server/lib/apm_telemetry/__test__/apm_telemetry.test.ts create mode 100644 x-pack/plugins/apm/server/lib/apm_telemetry/apm_telemetry.ts create mode 100644 x-pack/plugins/apm/server/lib/apm_telemetry/index.ts create mode 100644 x-pack/plugins/apm/server/lib/apm_telemetry/make_apm_usage_collector.ts diff --git a/x-pack/plugins/apm/index.js b/x-pack/plugins/apm/index.js index da81a5bfa6aee..f9685467b655d 100644 --- a/x-pack/plugins/apm/index.js +++ b/x-pack/plugins/apm/index.js @@ -10,6 +10,8 @@ import { initServicesApi } from './server/routes/services'; import { initErrorsApi } from './server/routes/errors'; import { initStatusApi } from './server/routes/status_check'; import { initTracesApi } from './server/routes/traces'; +import mappings from './mappings'; +import { makeApmUsageCollector } from './server/lib/apm_telemetry'; export function apm(kibana) { return new kibana.Plugin({ @@ -35,7 +37,13 @@ export function apm(kibana) { apmIndexPattern: config.get('apm_oss.indexPattern') }; }, - hacks: ['plugins/apm/hacks/toggle_app_link_in_nav'] + hacks: ['plugins/apm/hacks/toggle_app_link_in_nav'], + savedObjectSchemas: { + 'apm-telemetry': { + isNamespaceAgnostic: true + } + }, + mappings }, config(Joi) { @@ -60,6 +68,7 @@ export function apm(kibana) { initServicesApi(server); initErrorsApi(server); initStatusApi(server); + makeApmUsageCollector(server); } }); } diff --git a/x-pack/plugins/apm/mappings.json b/x-pack/plugins/apm/mappings.json new file mode 100644 index 0000000000000..3ed52b9c8d639 --- /dev/null +++ b/x-pack/plugins/apm/mappings.json @@ -0,0 +1,37 @@ +{ + "apm-telemetry": { + "properties": { + "has_any_services": { + "type": "boolean" + }, + "services_per_agent": { + "properties": { + "python": { + "type": "long", + "null_value": 0 + }, + "java": { + "type": "long", + "null_value": 0 + }, + "nodejs": { + "type": "long", + "null_value": 0 + }, + "js-base": { + "type": "long", + "null_value": 0 + }, + "ruby": { + "type": "long", + "null_value": 0 + }, + "go": { + "type": "long", + "null_value": 0 + } + } + } + } + } +} diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/__test__/apm_telemetry.test.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/__test__/apm_telemetry.test.ts new file mode 100644 index 0000000000000..9da683b48b618 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/__test__/apm_telemetry.test.ts @@ -0,0 +1,152 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { + AgentName, + APM_TELEMETRY_DOC_ID, + ApmTelemetry, + createApmTelementry, + getSavedObjectsClient, + storeApmTelemetry +} from '../apm_telemetry'; + +describe('apm_telemetry', () => { + describe('createApmTelementry', () => { + it('should create a ApmTelemetry object with boolean flag and frequency map of the given list of AgentNames', () => { + const apmTelemetry = createApmTelementry([ + AgentName.GoLang, + AgentName.NodeJs, + AgentName.GoLang, + AgentName.JsBase + ]); + expect(apmTelemetry.has_any_services).toBe(true); + expect(apmTelemetry.services_per_agent).toMatchObject({ + [AgentName.GoLang]: 2, + [AgentName.NodeJs]: 1, + [AgentName.JsBase]: 1 + }); + }); + it('should ignore undefined or unknown AgentName values', () => { + const apmTelemetry = createApmTelementry([ + AgentName.GoLang, + AgentName.NodeJs, + AgentName.GoLang, + AgentName.JsBase, + 'example-platform' as any, + undefined as any + ]); + expect(apmTelemetry.services_per_agent).toMatchObject({ + [AgentName.GoLang]: 2, + [AgentName.NodeJs]: 1, + [AgentName.JsBase]: 1 + }); + }); + }); + + describe('storeApmTelemetry', () => { + let server: any; + let apmTelemetry: ApmTelemetry; + let savedObjectsClientInstance: any; + + beforeEach(() => { + savedObjectsClientInstance = { create: jest.fn() }; + const callWithInternalUser = jest.fn(); + const internalRepository = jest.fn(); + server = { + savedObjects: { + SavedObjectsClient: jest.fn(() => savedObjectsClientInstance), + getSavedObjectsRepository: jest.fn(() => internalRepository) + }, + plugins: { + elasticsearch: { + getCluster: jest.fn(() => ({ callWithInternalUser })) + } + } + }; + apmTelemetry = { + has_any_services: true, + services_per_agent: { + [AgentName.GoLang]: 2, + [AgentName.NodeJs]: 1, + [AgentName.JsBase]: 1 + } + }; + }); + + it('should call savedObjectsClient create with the given ApmTelemetry object', () => { + storeApmTelemetry(server, apmTelemetry); + expect(savedObjectsClientInstance.create.mock.calls[0][1]).toBe( + apmTelemetry + ); + }); + + it('should call savedObjectsClient create with the apm-telemetry document type and ID', () => { + storeApmTelemetry(server, apmTelemetry); + expect(savedObjectsClientInstance.create.mock.calls[0][0]).toBe( + 'apm-telemetry' + ); + expect(savedObjectsClientInstance.create.mock.calls[0][2].id).toBe( + APM_TELEMETRY_DOC_ID + ); + }); + + it('should call savedObjectsClient create with overwrite: true', () => { + storeApmTelemetry(server, apmTelemetry); + expect(savedObjectsClientInstance.create.mock.calls[0][2].overwrite).toBe( + true + ); + }); + }); + + describe('getSavedObjectsClient', () => { + let server: any; + let savedObjectsClientInstance: any; + let callWithInternalUser: any; + let internalRepository: any; + + beforeEach(() => { + savedObjectsClientInstance = { create: jest.fn() }; + callWithInternalUser = jest.fn(); + internalRepository = jest.fn(); + server = { + savedObjects: { + SavedObjectsClient: jest.fn(() => savedObjectsClientInstance), + getSavedObjectsRepository: jest.fn(() => internalRepository) + }, + plugins: { + elasticsearch: { + getCluster: jest.fn(() => ({ callWithInternalUser })) + } + } + }; + }); + + it('should use internal user "admin"', () => { + getSavedObjectsClient(server); + + expect(server.plugins.elasticsearch.getCluster).toHaveBeenCalledWith( + 'admin' + ); + }); + + it('should call getSavedObjectsRepository with a cluster using the internal user context', () => { + getSavedObjectsClient(server); + + expect( + server.savedObjects.getSavedObjectsRepository + ).toHaveBeenCalledWith(callWithInternalUser); + }); + + it('should return a SavedObjectsClient initialized with the saved objects internal repository', () => { + const result = getSavedObjectsClient(server); + + expect(result).toBe(savedObjectsClientInstance); + expect(server.savedObjects.SavedObjectsClient).toHaveBeenCalledWith( + internalRepository + ); + }); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/apm_telemetry.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/apm_telemetry.ts new file mode 100644 index 0000000000000..f136030dd5652 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/apm_telemetry.ts @@ -0,0 +1,59 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Server } from 'hapi'; +import { countBy } from 'lodash'; + +// Support telemetry for additional agent types by appending definitions in +// mappings.json and the AgentName enum. + +export enum AgentName { + Python = 'python', + Java = 'java', + NodeJs = 'nodejs', + JsBase = 'js-base', + Ruby = 'ruby', + GoLang = 'go' +} + +export interface ApmTelemetry { + has_any_services: boolean; + services_per_agent: { [agentName in AgentName]?: number }; +} + +export const APM_TELEMETRY_DOC_ID = 'apm-telemetry'; + +export function createApmTelementry( + agentNames: AgentName[] = [] +): ApmTelemetry { + const validAgentNames = agentNames.filter(agentName => + Object.values(AgentName).includes(agentName) + ); + return { + has_any_services: validAgentNames.length > 0, + services_per_agent: countBy(validAgentNames) + }; +} + +export function storeApmTelemetry( + server: Server, + apmTelemetry: ApmTelemetry +): void { + const savedObjectsClient = getSavedObjectsClient(server); + savedObjectsClient.create('apm-telemetry', apmTelemetry, { + id: APM_TELEMETRY_DOC_ID, + overwrite: true + }); +} + +export function getSavedObjectsClient(server: Server): any { + const { SavedObjectsClient, getSavedObjectsRepository } = server.savedObjects; + const { callWithInternalUser } = server.plugins.elasticsearch.getCluster( + 'admin' + ); + const internalRepository = getSavedObjectsRepository(callWithInternalUser); + return new SavedObjectsClient(internalRepository); +} diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts new file mode 100644 index 0000000000000..96325952fb1a7 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { + ApmTelemetry, + AgentName, + storeApmTelemetry, + createApmTelementry, + APM_TELEMETRY_DOC_ID +} from './apm_telemetry'; +export { makeApmUsageCollector } from './make_apm_usage_collector'; diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/make_apm_usage_collector.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/make_apm_usage_collector.ts new file mode 100644 index 0000000000000..d09ea4cdab51e --- /dev/null +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/make_apm_usage_collector.ts @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Server } from 'hapi'; +import { + APM_TELEMETRY_DOC_ID, + ApmTelemetry, + createApmTelementry, + getSavedObjectsClient +} from './apm_telemetry'; + +// TODO this type should be defined by the platform +interface KibanaHapiServer extends Server { + usage: { + collectorSet: { + makeUsageCollector: any; + register: any; + }; + }; +} + +export function makeApmUsageCollector(server: KibanaHapiServer): void { + const apmUsageCollector = server.usage.collectorSet.makeUsageCollector({ + type: 'apm', + fetch: async (): Promise => { + const savedObjectsClient = getSavedObjectsClient(server); + try { + const apmTelemetrySavedObject = await savedObjectsClient.get( + 'apm-telemetry', + APM_TELEMETRY_DOC_ID + ); + return apmTelemetrySavedObject.attributes; + } catch (err) { + return createApmTelementry(); + } + } + }); + server.usage.collectorSet.register(apmUsageCollector); +} diff --git a/x-pack/plugins/apm/server/routes/services.ts b/x-pack/plugins/apm/server/routes/services.ts index f45cd21a7e625..ef7bbf6c86c86 100644 --- a/x-pack/plugins/apm/server/routes/services.ts +++ b/x-pack/plugins/apm/server/routes/services.ts @@ -6,6 +6,11 @@ import Boom from 'boom'; import { Server } from 'hapi'; +import { + AgentName, + createApmTelementry, + storeApmTelemetry +} from '../lib/apm_telemetry'; import { withDefaultValidators } from '../lib/helpers/input_validation'; import { setupRequest } from '../lib/helpers/setup_request'; import { getService } from '../lib/services/get_service'; @@ -30,9 +35,23 @@ export function initServicesApi(server: Server) { query: withDefaultValidators() } }, - handler: req => { + handler: async req => { const { setup } = req.pre; - return getServices(setup).catch(defaultErrorHandler); + + let serviceBucketList; + try { + serviceBucketList = await getServices(setup); + } catch (error) { + return defaultErrorHandler(error); + } + + // Store telemetry data derived from serviceBucketList + const apmTelemetry = createApmTelementry( + serviceBucketList.map(({ agentName }) => agentName as AgentName) + ); + storeApmTelemetry(server, apmTelemetry); + + return serviceBucketList; } }); From 7fbac45ec70f3f9fbcffede4b0f6acb566ffd586 Mon Sep 17 00:00:00 2001 From: Sarah Hersh Date: Tue, 20 Nov 2018 15:49:51 -0500 Subject: [PATCH 34/95] [DOCS]fix typo in link to source code (#25968) --- .../visualize/development-embedding-visualizations.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/visualize/development-embedding-visualizations.asciidoc b/docs/development/visualize/development-embedding-visualizations.asciidoc index ecfa93ba9e5b2..4748f3b546b13 100644 --- a/docs/development/visualize/development-embedding-visualizations.asciidoc +++ b/docs/development/visualize/development-embedding-visualizations.asciidoc @@ -55,4 +55,4 @@ The returned `EmbeddedVisualizeHandler` itself has the following methods and pro - `removeRenderCompleteListener(listener)`: removes an event listener from the handler again You can find the detailed `EmbeddedVisualizeHandler` documentation in its -{repo}blob/{branch}/src/ui/public/visualize/loader/embedded_visualize_handler.js[source code]. \ No newline at end of file +{repo}blob/{branch}/src/ui/public/visualize/loader/embedded_visualize_handler.ts[source code]. \ No newline at end of file From 70788a9a3ccea6f8e74b66a6b18e50748387238a Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Tue, 20 Nov 2018 15:51:49 -0600 Subject: [PATCH 35/95] [es] remove alpha1 suffix (#25763) --- packages/kbn-es/src/install/snapshot.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/kbn-es/src/install/snapshot.js b/packages/kbn-es/src/install/snapshot.js index 39da7432923a6..42c1307a04614 100644 --- a/packages/kbn-es/src/install/snapshot.js +++ b/packages/kbn-es/src/install/snapshot.js @@ -44,8 +44,7 @@ exports.downloadSnapshot = async function installSnapshot({ installPath = path.resolve(basePath, version), log = defaultLog, }) { - // TODO: remove -alpha1 once elastic/elasticsearch#35172 has been merged - const fileName = getFilename(license, version + '-alpha1'); + const fileName = getFilename(license, version); const url = `https://snapshots.elastic.co/downloads/elasticsearch/${fileName}`; const dest = path.resolve(basePath, 'cache', fileName); From 88af88ccdb417e7fb7ff5e92071bfb69b478f252 Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 20 Nov 2018 13:54:59 -0800 Subject: [PATCH 36/95] [chrome/breadcrumbs] migrate to the new platform (#25914) * [chrome/breadcrumbs] migrate to the new platform * expand some comments * typo * [apm] fix breadcrumbs tests --- src/core/public/chrome/chrome_service.test.ts | 46 +++++++++++- src/core/public/chrome/chrome_service.ts | 18 +++++ src/core/public/chrome/index.ts | 2 +- .../legacy_platform_service.test.ts.snap | 2 + .../legacy_platform_service.test.ts | 19 +++++ .../legacy_platform_service.ts | 1 + .../kibana/public/dashboard/dashboard_app.js | 4 +- .../kibana/public/dashboard/index.js | 5 +- .../public/discover/controllers/discover.js | 6 +- .../visualize/listing/visualize_listing.js | 4 +- src/ui/public/chrome/api/angular.js | 1 + src/ui/public/chrome/api/breadcrumbs.ts | 75 +++++++++++++++++++ src/ui/public/chrome/chrome.js | 2 + .../header_breadcrumbs.test.tsx.snap | 6 +- .../header_global_nav/components/header.tsx | 11 +-- .../components/header_breadcrumbs.test.tsx | 14 ++-- .../components/header_breadcrumbs.tsx | 22 +++--- .../header_global_nav/header_global_nav.js | 3 +- .../directives/header_global_nav/index.ts | 5 -- .../chrome/services/breadcrumb_state.ts | 62 --------------- src/ui/public/chrome/services/index.js | 1 - .../kbn_top_nav/bread_crumbs/bread_crumbs.js | 5 +- .../public/components/app/Main/Breadcrumbs.js | 8 +- .../app/Main/__test__/Breadcrumbs.test.js | 3 + .../ml/public/components/nav_menu/nav_menu.js | 5 +- .../public/services/breadcrumbs_provider.js | 4 +- 26 files changed, 219 insertions(+), 115 deletions(-) create mode 100644 src/ui/public/chrome/api/breadcrumbs.ts delete mode 100644 src/ui/public/chrome/services/breadcrumb_state.ts diff --git a/src/core/public/chrome/chrome_service.test.ts b/src/core/public/chrome/chrome_service.test.ts index 5840f826ba125..caaa588c2c9f8 100644 --- a/src/core/public/chrome/chrome_service.test.ts +++ b/src/core/public/chrome/chrome_service.test.ts @@ -202,19 +202,62 @@ Array [ "baz", ], ] +`); + }); + }); + + describe('breadcrumbs', () => { + it('updates/emits the current set of breadcrumbs', async () => { + const service = new ChromeService(); + const start = service.start(); + const promise = start + .getBreadcrumbs$() + .pipe(toArray()) + .toPromise(); + + start.setBreadcrumbs([{ text: 'foo' }, { text: 'bar' }]); + start.setBreadcrumbs([{ text: 'foo' }]); + start.setBreadcrumbs([{ text: 'bar' }]); + start.setBreadcrumbs([]); + service.stop(); + + await expect(promise).resolves.toMatchInlineSnapshot(` +Array [ + Array [], + Array [ + Object { + "text": "foo", + }, + Object { + "text": "bar", + }, + ], + Array [ + Object { + "text": "foo", + }, + ], + Array [ + Object { + "text": "bar", + }, + ], + Array [], +] `); }); }); }); describe('stop', () => { - it('completes applicationClass$, isCollapsed$, isVisible$, and brand$ observables', async () => { + it('completes applicationClass$, isCollapsed$, breadcrumbs$, isVisible$, and brand$ observables', async () => { const service = new ChromeService(); const start = service.start(); const promise = Rx.combineLatest( start.getBrand$(), start.getApplicationClasses$(), start.getIsCollapsed$(), + start.getBreadcrumbs$(), start.getIsVisible$() ).toPromise(); @@ -232,6 +275,7 @@ describe('stop', () => { start.getBrand$(), start.getApplicationClasses$(), start.getIsCollapsed$(), + start.getBreadcrumbs$(), start.getIsVisible$() ).toPromise() ).resolves.toBe(undefined); diff --git a/src/core/public/chrome/chrome_service.ts b/src/core/public/chrome/chrome_service.ts index 1e634aa42e2d8..8695385c9d20c 100644 --- a/src/core/public/chrome/chrome_service.ts +++ b/src/core/public/chrome/chrome_service.ts @@ -34,6 +34,11 @@ export interface Brand { smallLogo?: string; } +export interface Breadcrumb { + text: string; + href?: string; +} + export class ChromeService { private readonly stop$ = new Rx.ReplaySubject(1); @@ -44,6 +49,7 @@ export class ChromeService { const isVisible$ = new Rx.BehaviorSubject(true); const isCollapsed$ = new Rx.BehaviorSubject(!!localStorage.getItem(IS_COLLAPSED_KEY)); const applicationClasses$ = new Rx.BehaviorSubject>(new Set()); + const breadcrumbs$ = new Rx.BehaviorSubject([]); return { /** @@ -135,6 +141,18 @@ export class ChromeService { map(set => [...set]), takeUntil(this.stop$) ), + + /** + * Get an observable of the current list of breadcrumbs + */ + getBreadcrumbs$: () => breadcrumbs$.pipe(takeUntil(this.stop$)), + + /** + * Override the current set of breadcrumbs + */ + setBreadcrumbs: (newBreadcrumbs: Breadcrumb[]) => { + breadcrumbs$.next(newBreadcrumbs); + }, }; } diff --git a/src/core/public/chrome/index.ts b/src/core/public/chrome/index.ts index afc3d237ececb..ac54469e20bd4 100644 --- a/src/core/public/chrome/index.ts +++ b/src/core/public/chrome/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { ChromeService, ChromeStartContract, Brand } from './chrome_service'; +export { Breadcrumb, ChromeService, ChromeStartContract, Brand } from './chrome_service'; diff --git a/src/core/public/legacy_platform/__snapshots__/legacy_platform_service.test.ts.snap b/src/core/public/legacy_platform/__snapshots__/legacy_platform_service.test.ts.snap index b4a3fb8eface6..a1474127605dd 100644 --- a/src/core/public/legacy_platform/__snapshots__/legacy_platform_service.test.ts.snap +++ b/src/core/public/legacy_platform/__snapshots__/legacy_platform_service.test.ts.snap @@ -11,6 +11,7 @@ Array [ "ui/chrome/api/injected_vars", "ui/chrome/api/controls", "ui/chrome/api/theme", + "ui/chrome/api/breadcrumbs", "ui/chrome/services/global_nav_state", "ui/chrome", "legacy files", @@ -28,6 +29,7 @@ Array [ "ui/chrome/api/injected_vars", "ui/chrome/api/controls", "ui/chrome/api/theme", + "ui/chrome/api/breadcrumbs", "ui/chrome/services/global_nav_state", "ui/test_harness", "legacy files", diff --git a/src/core/public/legacy_platform/legacy_platform_service.test.ts b/src/core/public/legacy_platform/legacy_platform_service.test.ts index 8abf529a2a6bf..957731fb7bcbf 100644 --- a/src/core/public/legacy_platform/legacy_platform_service.test.ts +++ b/src/core/public/legacy_platform/legacy_platform_service.test.ts @@ -110,6 +110,14 @@ jest.mock('ui/chrome/api/theme', () => { }; }); +const mockChromeBreadcrumbsInit = jest.fn(); +jest.mock('ui/chrome/api/breadcrumbs', () => { + mockLoadOrder.push('ui/chrome/api/breadcrumbs'); + return { + __newPlatformInit__: mockChromeBreadcrumbsInit, + }; +}); + const mockGlobalNavStateInit = jest.fn(); jest.mock('ui/chrome/services/global_nav_state', () => { mockLoadOrder.push('ui/chrome/services/global_nav_state'); @@ -272,6 +280,17 @@ describe('#start()', () => { expect(mockChromeThemeInit).toHaveBeenCalledWith(chromeStartContract); }); + it('passes chrome service to ui/chrome/api/breadcrumbs', () => { + const legacyPlatform = new LegacyPlatformService({ + ...defaultParams, + }); + + legacyPlatform.start(defaultStartDeps); + + expect(mockChromeBreadcrumbsInit).toHaveBeenCalledTimes(1); + expect(mockChromeBreadcrumbsInit).toHaveBeenCalledWith(chromeStartContract); + }); + it('passes chrome service to ui/chrome/api/global_nav_state', () => { const legacyPlatform = new LegacyPlatformService({ ...defaultParams, diff --git a/src/core/public/legacy_platform/legacy_platform_service.ts b/src/core/public/legacy_platform/legacy_platform_service.ts index 8354b9592f840..54bb912614cb2 100644 --- a/src/core/public/legacy_platform/legacy_platform_service.ts +++ b/src/core/public/legacy_platform/legacy_platform_service.ts @@ -72,6 +72,7 @@ export class LegacyPlatformService { require('ui/chrome/api/injected_vars').__newPlatformInit__(injectedMetadata); require('ui/chrome/api/controls').__newPlatformInit__(chrome); require('ui/chrome/api/theme').__newPlatformInit__(chrome); + require('ui/chrome/api/breadcrumbs').__newPlatformInit__(chrome); require('ui/chrome/services/global_nav_state').__newPlatformInit__(chrome); // Load the bootstrap module before loading the legacy platform files so that diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_app.js b/src/core_plugins/kibana/public/dashboard/dashboard_app.js index 3a1fd54a24de0..919191885a433 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_app.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard_app.js @@ -85,11 +85,9 @@ app.directive('dashboardApp', function ($injector) { $rootScope, $route, $routeParams, - $location, getAppState, dashboardConfig, localStorage, - breadcrumbState, i18n, ) { const filterManager = Private(FilterManagerProvider); @@ -182,7 +180,7 @@ app.directive('dashboardApp', function ($injector) { // Push breadcrumbs to new header navigation const updateBreadcrumbs = () => { - breadcrumbState.set([ + chrome.breadcrumbs.set([ { text: i18n('kbn.dashboard.dashboardAppBreadcrumbsTitle', { defaultMessage: 'Dashboard', diff --git a/src/core_plugins/kibana/public/dashboard/index.js b/src/core_plugins/kibana/public/dashboard/index.js index a2965219d68bc..72280b7bc9d71 100644 --- a/src/core_plugins/kibana/public/dashboard/index.js +++ b/src/core_plugins/kibana/public/dashboard/index.js @@ -22,6 +22,7 @@ import './dashboard_app'; import './saved_dashboard/saved_dashboards'; import './dashboard_config'; import uiRoutes from 'ui/routes'; +import chrome from 'ui/chrome'; import { toastNotifications } from 'ui/notify'; import dashboardTemplate from './dashboard_app.html'; @@ -57,7 +58,7 @@ uiRoutes }) .when(DashboardConstants.LANDING_PAGE_PATH, { template: dashboardListingTemplate, - controller($injector, $location, $scope, Private, config, breadcrumbState, i18n) { + controller($injector, $location, $scope, Private, config, i18n) { const services = Private(SavedObjectRegistryProvider).byLoaderPropertiesName; const dashboardConfig = $injector.get('dashboardConfig'); @@ -70,7 +71,7 @@ uiRoutes }; $scope.hideWriteControls = dashboardConfig.getHideWriteControls(); $scope.initialFilter = ($location.search()).filter || EMPTY_FILTER; - breadcrumbState.set([{ + chrome.breadcrumbs.set([{ text: i18n('kbn.dashboard.dashboardBreadcrumbsTitle', { defaultMessage: 'Dashboards', }), diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 03acb19a18afb..a10ef78da11c4 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -20,6 +20,7 @@ import _ from 'lodash'; import React from 'react'; import angular from 'angular'; +import chrome from 'ui/chrome'; import { getSort } from 'ui/doc_table/lib/get_sort'; import * as columnActions from 'ui/doc_table/actions/columns'; import * as filterActions from 'ui/doc_table/actions/filter'; @@ -155,7 +156,6 @@ function discoverController( courier, kbnUrl, localStorage, - breadcrumbState, i18n, ) { const Vis = Private(VisProvider); @@ -320,12 +320,12 @@ function discoverController( }); if (savedSearch.id && savedSearch.title) { - breadcrumbState.set([{ + chrome.breadcrumbs.set([{ text: discoverBreadcrumbsTitle, href: '#/discover' }, { text: savedSearch.title }]); } else { - breadcrumbState.set([{ + chrome.breadcrumbs.set([{ text: discoverBreadcrumbsTitle, }]); } diff --git a/src/core_plugins/kibana/public/visualize/listing/visualize_listing.js b/src/core_plugins/kibana/public/visualize/listing/visualize_listing.js index 997023064f6b6..519ed05cc499b 100644 --- a/src/core_plugins/kibana/public/visualize/listing/visualize_listing.js +++ b/src/core_plugins/kibana/public/visualize/listing/visualize_listing.js @@ -23,6 +23,7 @@ import 'ui/pager'; import { uiModules } from 'ui/modules'; import { timefilter } from 'ui/timefilter'; import { i18n } from '@kbn/i18n'; +import chrome from 'ui/chrome'; import { VisualizeListingTable } from './visualize_listing_table'; @@ -35,7 +36,6 @@ export function VisualizeListingController($injector) { const Notifier = $injector.get('Notifier'); const Private = $injector.get('Private'); const config = $injector.get('config'); - const breadcrumbState = $injector.get('breadcrumbState'); timefilter.disableAutoRefreshSelector(); timefilter.disableTimeRangeSelector(); @@ -61,7 +61,7 @@ export function VisualizeListingController($injector) { .catch(error => notify.error(error)); }; - breadcrumbState.set([{ + chrome.breadcrumbs.set([{ text: i18n.translate('kbn.visualize.visualizeListingBreadcrumbsTitle', { defaultMessage: 'Visualize', }) diff --git a/src/ui/public/chrome/api/angular.js b/src/ui/public/chrome/api/angular.js index 19fcfa410f248..c9ed0153fe975 100644 --- a/src/ui/public/chrome/api/angular.js +++ b/src/ui/public/chrome/api/angular.js @@ -67,6 +67,7 @@ export function initAngularApi(chrome, internals) { $locationProvider.hashPrefix(''); }) .run(internals.capture$httpLoadingCount) + .run(internals.$setupBreadcrumbsAutoClear) .run(($location, $rootScope, Private, config) => { chrome.getFirstPathSegment = () => { return $location.path().split('/')[1]; diff --git a/src/ui/public/chrome/api/breadcrumbs.ts b/src/ui/public/chrome/api/breadcrumbs.ts new file mode 100644 index 0000000000000..83c29a2bcb772 --- /dev/null +++ b/src/ui/public/chrome/api/breadcrumbs.ts @@ -0,0 +1,75 @@ +/* + * 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. + */ + +// @ts-ignore +import { uiModules } from 'ui/modules'; +import { Breadcrumb, ChromeStartContract } from '../../../../core/public/chrome'; +export { Breadcrumb }; + +let newPlatformChrome: ChromeStartContract; +export function __newPlatformInit__(instance: ChromeStartContract) { + if (newPlatformChrome) { + throw new Error('ui/chrome/api/breadcrumbs is already initialized'); + } + + newPlatformChrome = instance; +} + +export function initBreadcrumbsApi( + chrome: { [key: string]: any }, + internals: { [key: string]: any } +) { + // A flag used to determine if we should automatically + // clear the breadcrumbs between angular route changes. + let shouldClear = false; + + // reset shouldClear any time the breadcrumbs change, even + // if it was done directly through the new platform + newPlatformChrome.getBreadcrumbs$().subscribe({ + next() { + shouldClear = false; + }, + }); + + chrome.breadcrumbs = { + get$() { + return newPlatformChrome.getBreadcrumbs$(); + }, + + set(newBreadcrumbs: Breadcrumb[]) { + newPlatformChrome.setBreadcrumbs(newBreadcrumbs); + }, + }; + + // define internal angular run function that will be called when angular + // bootstraps and lets us integrate with the angular router so that we can + // automatically clear the breadcrumbs if we switch to a Kibana app that + // does not use breadcrumbs correctly + internals.$setupBreadcrumbsAutoClear = ($rootScope: any) => { + $rootScope.$on('$routeChangeStart', () => { + shouldClear = true; + }); + + $rootScope.$on('$routeChangeSuccess', () => { + if (shouldClear) { + newPlatformChrome.setBreadcrumbs([]); + } + }); + }; +} diff --git a/src/ui/public/chrome/chrome.js b/src/ui/public/chrome/chrome.js index ffd3e5da25948..7eba951076803 100644 --- a/src/ui/public/chrome/chrome.js +++ b/src/ui/public/chrome/chrome.js @@ -35,6 +35,7 @@ import { initAngularApi } from './api/angular'; import appsApi from './api/apps'; import { initChromeControlsApi } from './api/controls'; import { initChromeNavApi } from './api/nav'; +import { initBreadcrumbsApi } from './api/breadcrumbs'; import templateApi from './api/template'; import { initChromeThemeApi } from './api/theme'; import { initChromeXsrfApi } from './api/xsrf'; @@ -67,6 +68,7 @@ initChromeXsrfApi(chrome, internals); initChromeBasePathApi(chrome); initChromeInjectedVarsApi(chrome); initChromeNavApi(chrome, internals); +initBreadcrumbsApi(chrome, internals); initLoadingCountApi(chrome, internals); initAngularApi(chrome, internals); initChromeControlsApi(chrome); diff --git a/src/ui/public/chrome/directives/header_global_nav/components/__snapshots__/header_breadcrumbs.test.tsx.snap b/src/ui/public/chrome/directives/header_global_nav/components/__snapshots__/header_breadcrumbs.test.tsx.snap index 74243a506a0fd..4b97c565f3d4b 100644 --- a/src/ui/public/chrome/directives/header_global_nav/components/__snapshots__/header_breadcrumbs.test.tsx.snap +++ b/src/ui/public/chrome/directives/header_global_nav/components/__snapshots__/header_breadcrumbs.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`HeaderBreadcrumbs renders updates to the breadcrumbs observable 1`] = ` +exports[`HeaderBreadcrumbs renders updates to the breadcrumbs$ observable 1`] = ` `; -exports[`HeaderBreadcrumbs renders updates to the breadcrumbs observable 2`] = ` +exports[`HeaderBreadcrumbs renders updates to the breadcrumbs$ observable 2`] = ` Array [ ; + breadcrumbs$: Rx.Observable; homeHref: string; isVisible: boolean; navLinks: NavLink[]; @@ -66,7 +67,7 @@ class HeaderUI extends Component { } public render() { - const { appTitle, breadcrumbs, isVisible, navControls, navLinks } = this.props; + const { appTitle, breadcrumbs$, isVisible, navControls, navLinks } = this.props; if (!isVisible) { return null; @@ -82,7 +83,7 @@ class HeaderUI extends Component { - + diff --git a/src/ui/public/chrome/directives/header_global_nav/components/header_breadcrumbs.test.tsx b/src/ui/public/chrome/directives/header_global_nav/components/header_breadcrumbs.test.tsx index 73c3724b1a95a..dabf36f91317e 100644 --- a/src/ui/public/chrome/directives/header_global_nav/components/header_breadcrumbs.test.tsx +++ b/src/ui/public/chrome/directives/header_global_nav/components/header_breadcrumbs.test.tsx @@ -19,23 +19,25 @@ import { mount } from 'enzyme'; import React from 'react'; -import { breadcrumbs, set } from '../../../services/breadcrumb_state'; +import * as Rx from 'rxjs'; +import { Breadcrumb } from '../../../../../../core/public/chrome'; import { HeaderBreadcrumbs } from './header_breadcrumbs'; describe('HeaderBreadcrumbs', () => { - it('renders updates to the breadcrumbs observable', () => { - const wrapper = mount(); + it('renders updates to the breadcrumbs$ observable', () => { + const breadcrumbs$ = new Rx.Subject(); + const wrapper = mount(); - set([{ text: 'First' }]); + breadcrumbs$.next([{ text: 'First' }]); // Unfortunately, enzyme won't update the wrapper until we call update. wrapper.update(); expect(wrapper.find('.euiBreadcrumb')).toMatchSnapshot(); - set([{ text: 'First' }, { text: 'Second' }]); + breadcrumbs$.next([{ text: 'First' }, { text: 'Second' }]); wrapper.update(); expect(wrapper.find('.euiBreadcrumb')).toMatchSnapshot(); - set([]); + breadcrumbs$.next([]); wrapper.update(); expect(wrapper.find('.euiBreadcrumb')).toMatchSnapshot(); }); diff --git a/src/ui/public/chrome/directives/header_global_nav/components/header_breadcrumbs.tsx b/src/ui/public/chrome/directives/header_global_nav/components/header_breadcrumbs.tsx index ff880ccbd9f67..828de8bf7d314 100644 --- a/src/ui/public/chrome/directives/header_global_nav/components/header_breadcrumbs.tsx +++ b/src/ui/public/chrome/directives/header_global_nav/components/header_breadcrumbs.tsx @@ -18,18 +18,18 @@ */ import React, { Component } from 'react'; -import { Subscribable, Unsubscribable } from 'rxjs'; +import * as Rx from 'rxjs'; import { // @ts-ignore EuiHeaderBreadcrumbs, } from '@elastic/eui'; -import { Breadcrumb } from '../'; +import { Breadcrumb } from '../../../../../../core/public/chrome'; interface Props { appTitle?: string; - breadcrumbs: Subscribable; + breadcrumbs$: Rx.Observable; } interface State { @@ -37,7 +37,7 @@ interface State { } export class HeaderBreadcrumbs extends Component { - private unsubscribable?: Unsubscribable; + private subscription?: Rx.Subscription; constructor(props: Props) { super(props); @@ -50,7 +50,7 @@ export class HeaderBreadcrumbs extends Component { } public componentDidUpdate(prevProps: Props) { - if (prevProps.breadcrumbs === this.props.breadcrumbs) { + if (prevProps.breadcrumbs$ === this.props.breadcrumbs$) { return; } @@ -73,15 +73,17 @@ export class HeaderBreadcrumbs extends Component { } private subscribe() { - this.unsubscribable = this.props.breadcrumbs.subscribe(breadcrumbs => { - this.setState({ breadcrumbs }); + this.subscription = this.props.breadcrumbs$.subscribe(breadcrumbs => { + this.setState({ + breadcrumbs, + }); }); } private unsubscribe() { - if (this.unsubscribable) { - this.unsubscribable.unsubscribe(); - delete this.unsubscribable; + if (this.subscription) { + this.subscription.unsubscribe(); + delete this.subscription; } } } diff --git a/src/ui/public/chrome/directives/header_global_nav/header_global_nav.js b/src/ui/public/chrome/directives/header_global_nav/header_global_nav.js index 1d6048b3f6b7c..10773e22894fc 100644 --- a/src/ui/public/chrome/directives/header_global_nav/header_global_nav.js +++ b/src/ui/public/chrome/directives/header_global_nav/header_global_nav.js @@ -22,7 +22,6 @@ import { uiModules } from '../../../modules'; import { Header } from './components/header'; import './header_global_nav.less'; import { chromeHeaderNavControlsRegistry } from 'ui/registry/chrome_header_nav_controls'; -import { breadcrumbs } from '../../services/breadcrumb_state'; import { injectI18nProvider } from '@kbn/i18n/react'; const module = uiModules.get('kibana'); @@ -40,7 +39,7 @@ module.directive('headerGlobalNav', (reactDirective, chrome, Private) => { {}, // angular injected React props { - breadcrumbs, + breadcrumbs$: chrome.breadcrumbs.get$(), navLinks, navControls, homeHref diff --git a/src/ui/public/chrome/directives/header_global_nav/index.ts b/src/ui/public/chrome/directives/header_global_nav/index.ts index 9b6b7521c2c4d..43e0d04916b7a 100644 --- a/src/ui/public/chrome/directives/header_global_nav/index.ts +++ b/src/ui/public/chrome/directives/header_global_nav/index.ts @@ -38,8 +38,3 @@ export interface NavLink { id: string; euiIconType: IconType; } - -export interface Breadcrumb { - text: string; - href?: string; -} diff --git a/src/ui/public/chrome/services/breadcrumb_state.ts b/src/ui/public/chrome/services/breadcrumb_state.ts deleted file mode 100644 index 020c9f1333968..0000000000000 --- a/src/ui/public/chrome/services/breadcrumb_state.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 { Subject, Subscribable } from 'rxjs'; -// @ts-ignore -import { uiModules } from '../../modules'; -import { Breadcrumb } from '../directives/header_global_nav'; - -// A flag used to keep track of clearing between route changes. -let shouldClear = false; - -// Subject used by Header component to subscribe to breadcrumbs changes. -// This is not exposed publicly. -const breadcrumbsSubject = new Subject(); - -/** - * A rxjs subscribable that can be used to subscribe to breadcrumb updates. - */ -export const breadcrumbs: Subscribable = breadcrumbsSubject; - -/** - * Should be called by plugins to set breadcrumbs in the header navigation. - * - * @param breadcrumbs: Array where Breadcrumb has shape - * { text: '', href?: '' } - */ -export const set = (newBreadcrumbs: Breadcrumb[]) => { - breadcrumbsSubject.next(newBreadcrumbs); - - // If a plugin called set, don't clear on route change. - shouldClear = false; -}; - -uiModules.get('kibana').service('breadcrumbState', ($rootScope: any) => { - // When a route change happens we want to clear the breadcrumbs ONLY if - // the new route does not set any breadcrumbs. Deferring the clearing until - // the route finishes changing helps avoiding the breadcrumbs from 'flickering'. - $rootScope.$on('$routeChangeStart', () => (shouldClear = true)); - $rootScope.$on('$routeChangeSuccess', () => { - if (shouldClear) { - set([]); - } - }); - - return { set }; -}); diff --git a/src/ui/public/chrome/services/index.js b/src/ui/public/chrome/services/index.js index 3c2f2fb71d202..3b3967f51b2ff 100644 --- a/src/ui/public/chrome/services/index.js +++ b/src/ui/public/chrome/services/index.js @@ -18,4 +18,3 @@ */ import './global_nav_state'; -import './breadcrumb_state'; diff --git a/src/ui/public/kbn_top_nav/bread_crumbs/bread_crumbs.js b/src/ui/public/kbn_top_nav/bread_crumbs/bread_crumbs.js index d0674cc68d2d5..0c69993887497 100644 --- a/src/ui/public/kbn_top_nav/bread_crumbs/bread_crumbs.js +++ b/src/ui/public/kbn_top_nav/bread_crumbs/bread_crumbs.js @@ -20,6 +20,7 @@ import breadCrumbsTemplate from './bread_crumbs.html'; import { uiModules } from '../../modules'; import uiRouter from '../../routes'; +import chrome from '../../chrome'; const module = uiModules.get('kibana'); @@ -46,7 +47,7 @@ module.directive('breadCrumbs', function () { useLinks: '=' }, template: breadCrumbsTemplate, - controller: function ($scope, config, breadcrumbState) { + controller: function ($scope, config) { config.watch('k7design', (val) => $scope.showPluginBreadcrumbs = !val); function omitPagesFilter(crumb) { @@ -78,7 +79,7 @@ module.directive('breadCrumbs', function () { newBreadcrumbs.push({ text: $scope.pageTitle }); } - breadcrumbState.set(newBreadcrumbs); + chrome.breadcrumbs.set(newBreadcrumbs); }); } }; diff --git a/x-pack/plugins/apm/public/components/app/Main/Breadcrumbs.js b/x-pack/plugins/apm/public/components/app/Main/Breadcrumbs.js index ba4fd5ed004a1..3c3a9568e5d44 100644 --- a/x-pack/plugins/apm/public/components/app/Main/Breadcrumbs.js +++ b/x-pack/plugins/apm/public/components/app/Main/Breadcrumbs.js @@ -6,10 +6,12 @@ import React from 'react'; import { withBreadcrumbs } from 'react-router-breadcrumbs-hoc'; +import { flatten, capitalize } from 'lodash'; + +import chrome from 'ui/chrome'; + import { toQuery } from '../../../utils/url'; import { routes } from './routeConfig'; -import { flatten, capitalize } from 'lodash'; -import { set } from 'ui/chrome/services/breadcrumb_state'; class Breadcrumbs extends React.Component { updateHeaderBreadcrumbs() { @@ -19,7 +21,7 @@ class Breadcrumbs extends React.Component { href: `#${match.url}?_g=${_g}&kuery=${kuery}` })); - set(breadcrumbs); + chrome.breadcrumbs.set(breadcrumbs); } componentDidMount() { diff --git a/x-pack/plugins/apm/public/components/app/Main/__test__/Breadcrumbs.test.js b/x-pack/plugins/apm/public/components/app/Main/__test__/Breadcrumbs.test.js index ac2a453509976..be57500928f4b 100644 --- a/x-pack/plugins/apm/public/components/app/Main/__test__/Breadcrumbs.test.js +++ b/x-pack/plugins/apm/public/components/app/Main/__test__/Breadcrumbs.test.js @@ -14,6 +14,9 @@ import { toJson } from '../../../../utils/testHelpers'; jest.mock( 'ui/chrome', () => ({ + breadcrumbs: { + set: () => {} + }, getBasePath: () => `/some/base/path`, getUiSettingsClient: () => { return { diff --git a/x-pack/plugins/ml/public/components/nav_menu/nav_menu.js b/x-pack/plugins/ml/public/components/nav_menu/nav_menu.js index 2ead5f96dd404..12425b7fa6c54 100644 --- a/x-pack/plugins/ml/public/components/nav_menu/nav_menu.js +++ b/x-pack/plugins/ml/public/components/nav_menu/nav_menu.js @@ -10,12 +10,13 @@ import _ from 'lodash'; import $ from 'jquery'; import template from './nav_menu.html'; import uiRouter from 'ui/routes'; +import chrome from 'ui/chrome'; import { isFullLicense } from '../../license/check_license'; import { uiModules } from 'ui/modules'; const module = uiModules.get('apps/ml'); -module.directive('mlNavMenu', function (breadcrumbState, config) { +module.directive('mlNavMenu', function (config) { return { restrict: 'E', transclude: true, @@ -73,7 +74,7 @@ module.directive('mlNavMenu', function (breadcrumbState, config) { scope.breadcrumbs = breadcrumbs.filter(Boolean); config.watch('k7design', (val) => scope.showPluginBreadcrumbs = !val); - breadcrumbState.set(scope.breadcrumbs.map(b => ({ text: b.label, href: b.url }))); + chrome.breadcrumbs.set(scope.breadcrumbs.map(b => ({ text: b.label, href: b.url }))); // when the page loads, focus on the first breadcrumb el.ready(() => { diff --git a/x-pack/plugins/monitoring/public/services/breadcrumbs_provider.js b/x-pack/plugins/monitoring/public/services/breadcrumbs_provider.js index 1b1cff5652afc..8d3adcb541e91 100644 --- a/x-pack/plugins/monitoring/public/services/breadcrumbs_provider.js +++ b/x-pack/plugins/monitoring/public/services/breadcrumbs_provider.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set as setBreadcrumbs } from 'ui/chrome/services/breadcrumb_state'; +import chrome from 'ui/chrome'; import { i18n } from '@kbn/i18n'; // Helper for making objects to use in a link element @@ -147,7 +147,7 @@ export function breadcrumbsProvider() { breadcrumbs = breadcrumbs.concat(getApmBreadcrumbs(mainInstance)); } - setBreadcrumbs(breadcrumbs.map(b => ({ text: b.label, href: b.url }))); + chrome.breadcrumbs.set(breadcrumbs.map(b => ({ text: b.label, href: b.url }))); return breadcrumbs; }; From ca778375db8e47bfdda1459da0b02d89654e08e6 Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 20 Nov 2018 13:58:52 -0800 Subject: [PATCH 37/95] [babel-register] ignore built canvas plugins (#25913) --- src/setup_node_env/babel_register/register.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/setup_node_env/babel_register/register.js b/src/setup_node_env/babel_register/register.js index 12690eab8f02c..17dd7f0705df1 100644 --- a/src/setup_node_env/babel_register/register.js +++ b/src/setup_node_env/babel_register/register.js @@ -38,8 +38,12 @@ var ignore = [ // https://github.com/elastic/kibana/issues/14800#issuecomment-366130268 // ignore paths matching `/node_modules/{a}/{b}`, unless `a` - // is `x-pack` and `b` is not `node_modules` - /\/node_modules\/(?!(x-pack\/|@kbn\/interpreter\/)(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/ + // is `x-pack` or `@kbn/interpreter` and `b` is not `node_modules` + /\/node_modules\/(?!(x-pack\/|@kbn\/interpreter\/)(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, + + // ignore paths matching `/canvas/canvas_plugin/{a}/{b}` unless + // `a` is `functions` and `b` is `server` + /\/canvas\/canvas_plugin\/(?!functions\/server)([^\/]+\/[^\/]+)/, ]; if (global.__BUILT_WITH_BABEL__) { From fad8d0cc3a3ae05c970e96a7e7c92bea453a4079 Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 20 Nov 2018 14:02:06 -0800 Subject: [PATCH 38/95] [ci][ftr][kbn/test] split up CI jobs (#25838) * [ci][ftr][kbn/test] split up CI jobs * [ci] run --assert-none-excluded in ci groups, before builds * [ftr] improve error message when excluded tests found * [ci] document other places the ciGroups live --- .ci/jobs.yml | 25 ++++- .ci/run.sh | 15 ++- .../src/functional_tests/lib/index.js | 2 +- .../lib/{fun_ftr.js => run_ftr.js} | 9 +- src/dev/jest/junit_reporter.js | 2 +- src/dev/mocha/junit_report_generation.js | 9 +- .../functional_test_runner.js | 4 +- .../lib/config/read_config_file.js | 19 ++-- tasks/config/run.js | 18 +--- tasks/function_test_groups.js | 97 +++++++++++++++++++ tasks/jenkins.js | 6 -- test/functional/apps/console/index.js | 2 + test/functional/apps/context/index.js | 2 + test/functional/apps/dashboard/index.js | 52 ++++++---- test/functional/apps/discover/index.js | 2 + test/functional/apps/getting_started/index.js | 2 + test/functional/apps/home/index.js | 2 + test/functional/apps/management/index.js | 43 ++++---- test/functional/apps/status_page/index.js | 2 + test/functional/apps/timelion/index.js | 2 + test/functional/apps/visualize/index.js | 72 +++++++++----- test/scripts/jenkins_ci_group.sh | 19 ++++ test/scripts/jenkins_selenium.sh | 12 --- test/scripts/jenkins_xpack.sh | 16 --- test/scripts/jenkins_xpack_ci_group.sh | 37 +++++++ x-pack/test/api_integration/apis/index.js | 4 +- .../functional/apps/dashboard_mode/index.js | 2 + x-pack/test/functional/apps/graph/index.js | 2 + .../functional/apps/grok_debugger/index.js | 4 +- .../test/functional/apps/infra/home_page.ts | 4 + x-pack/test/functional/apps/infra/index.ts | 4 +- x-pack/test/functional/apps/logstash/index.js | 4 +- .../test/functional/apps/monitoring/index.js | 4 +- x-pack/test/functional/apps/security/index.js | 2 + x-pack/test/functional/apps/spaces/index.ts | 2 + .../test/functional/apps/status_page/index.ts | 2 + x-pack/test/functional/apps/watcher/index.js | 2 + x-pack/test/reporting/api/chromium_tests.js | 4 +- x-pack/test/reporting/api/phantom_tests.js | 4 +- .../reporting/configs/chromium_functional.js | 2 +- .../reporting/configs/phantom_functional.js | 2 +- x-pack/test/reporting/functional/index.js | 1 + .../test/saml_api_integration/apis/index.js | 3 +- .../security_and_spaces/apis/index.ts | 4 +- .../security_only/apis/index.ts | 4 +- .../spaces_only/apis/index.ts | 4 +- .../security_and_spaces/apis/index.ts | 4 +- .../spaces_only/apis/index.ts | 4 +- 48 files changed, 394 insertions(+), 149 deletions(-) rename packages/kbn-test/src/functional_tests/lib/{fun_ftr.js => run_ftr.js} (89%) create mode 100644 tasks/function_test_groups.js create mode 100755 test/scripts/jenkins_ci_group.sh delete mode 100755 test/scripts/jenkins_selenium.sh create mode 100755 test/scripts/jenkins_xpack_ci_group.sh diff --git a/.ci/jobs.yml b/.ci/jobs.yml index 1740e1db33f2d..f9302db4b2910 100644 --- a/.ci/jobs.yml +++ b/.ci/jobs.yml @@ -1,7 +1,26 @@ JOB: - - selenium - - intake - - x-pack + - kibana-intake + - x-pack-intake + # make sure all kibana-ciGRoups are listed in tasks/function_test_groups.js + - kibana-ciGroup1 + - kibana-ciGroup2 + - kibana-ciGroup3 + - kibana-ciGroup4 + - kibana-ciGroup5 + - kibana-ciGroup6 + - kibana-ciGroup7 + - kibana-ciGroup8 + - kibana-ciGroup9 + - kibana-ciGroup10 + - kibana-ciGroup11 + - kibana-ciGroup12 + # make sure all x-pack-ciGroups are listed in test/scripts/jenkins_xpack_ci_group.sh + - x-pack-ciGroup1 + - x-pack-ciGroup2 + - x-pack-ciGroup3 + - x-pack-ciGroup4 + - x-pack-ciGroup5 + - x-pack-ciGroup6 # `~` is yaml for `null` exclude: ~ diff --git a/.ci/run.sh b/.ci/run.sh index 32c138bd2f450..57cc4afd6a38a 100755 --- a/.ci/run.sh +++ b/.ci/run.sh @@ -6,15 +6,20 @@ set -e cd "$(dirname "$0")/.." case "$JOB" in -"selenium") - ./test/scripts/jenkins_selenium.sh - ;; -"intake") +kibana-intake) ./test/scripts/jenkins_unit.sh ;; -"x-pack") +kibana-ciGroup*) + export CI_GROUP="${JOB##kibana-ciGroup}" + ./test/scripts/jenkins_ci_group.sh + ;; +x-pack-intake) ./test/scripts/jenkins_xpack.sh ;; +x-pack-ciGroup*) + export CI_GROUP="${JOB##x-pack-ciGroup}" + ./test/scripts/jenkins_xpack_ci_group.sh + ;; *) echo "JOB '$JOB' is not implemented." exit 1 diff --git a/packages/kbn-test/src/functional_tests/lib/index.js b/packages/kbn-test/src/functional_tests/lib/index.js index 886a77ba6e2e4..ec381b56b0699 100644 --- a/packages/kbn-test/src/functional_tests/lib/index.js +++ b/packages/kbn-test/src/functional_tests/lib/index.js @@ -19,6 +19,6 @@ export { runKibanaServer } from './run_kibana_server'; export { runElasticsearch } from './run_elasticsearch'; -export { runFtr, hasTests, assertNoneExcluded } from './fun_ftr'; +export { runFtr, hasTests, assertNoneExcluded } from './run_ftr'; export { KIBANA_ROOT, KIBANA_FTR_SCRIPT, FUNCTIONAL_CONFIG_PATH, API_CONFIG_PATH } from './paths'; export { runCli } from './run_cli'; diff --git a/packages/kbn-test/src/functional_tests/lib/fun_ftr.js b/packages/kbn-test/src/functional_tests/lib/run_ftr.js similarity index 89% rename from packages/kbn-test/src/functional_tests/lib/fun_ftr.js rename to packages/kbn-test/src/functional_tests/lib/run_ftr.js index e3dbe6cef6d8a..05e5cbb3d4b55 100644 --- a/packages/kbn-test/src/functional_tests/lib/fun_ftr.js +++ b/packages/kbn-test/src/functional_tests/lib/run_ftr.js @@ -39,14 +39,15 @@ export async function assertNoneExcluded({ configPath, options }) { const ftr = createFtr({ configPath, options }); const stats = await ftr.getTestStats(); - if (stats.excludedTests > 0) { + if (stats.excludedTests.length > 0) { throw new CliError(` - ${stats.excludedTests} tests in the ${configPath} config + ${stats.excludedTests.length} tests in the ${configPath} config are excluded when filtering by the tags run on CI. Make sure that all suites are tagged with one of the following tags, or extend the list of tags in test/scripts/jenkins_xpack.sh - ${JSON.stringify(options.suiteTags)} + tags: ${JSON.stringify(options.suiteTags)} + - ${stats.excludedTests.join('\n - ')} `); } } @@ -65,5 +66,5 @@ export async function runFtr({ configPath, options }) { export async function hasTests({ configPath, options }) { const ftr = createFtr({ configPath, options }); const stats = await ftr.getTestStats(); - return stats.tests > 0; + return stats.testCount > 0; } diff --git a/src/dev/jest/junit_reporter.js b/src/dev/jest/junit_reporter.js index 9f8f042b2ddb7..9d05e1dabf59c 100644 --- a/src/dev/jest/junit_reporter.js +++ b/src/dev/jest/junit_reporter.js @@ -49,7 +49,7 @@ export default class JestJUnitReporter { * @return {undefined} */ onRunComplete(contexts, results) { - if (!process.env.CI) { + if (!process.env.CI || !results.testResults.length) { return; } diff --git a/src/dev/mocha/junit_report_generation.js b/src/dev/mocha/junit_report_generation.js index e5c7aec947b8f..74b271e82f52e 100644 --- a/src/dev/mocha/junit_report_generation.js +++ b/src/dev/mocha/junit_report_generation.js @@ -27,6 +27,8 @@ import xmlBuilder from 'xmlbuilder'; import { getSnapshotOfRunnableLogs } from './log_cache'; import { escapeCdata } from '../xml'; +const dateNow = Date.now.bind(Date); + export function setupJUnitReportGeneration(runner, options = {}) { const { reportName = 'Unnamed Mocha Tests', @@ -47,11 +49,11 @@ export function setupJUnitReportGeneration(runner, options = {}) { ); const setStartTime = (node) => { - node.startTime = Date.now(); + node.startTime = dateNow(); }; const setEndTime = node => { - node.endTime = Date.now(); + node.endTime = dateNow(); }; const getFullTitle = node => { @@ -85,6 +87,9 @@ export function setupJUnitReportGeneration(runner, options = {}) { runner.on('end', () => { // crawl the test graph to collect all defined tests const allTests = findAllTests(runner.suite); + if (!allTests.length) { + return; + } // filter out just the failures const failures = results.filter(result => result.failed); diff --git a/src/functional_test_runner/functional_test_runner.js b/src/functional_test_runner/functional_test_runner.js index e7edb63777c1b..9356412ba0738 100644 --- a/src/functional_test_runner/functional_test_runner.js +++ b/src/functional_test_runner/functional_test_runner.js @@ -89,8 +89,8 @@ export function createFunctionalTestRunner({ log, configFile, configOverrides }) ); return { - tests: countTests(mocha.suite), - excludedTests: mocha.excludedTests.length + testCount: countTests(mocha.suite), + excludedTests: mocha.excludedTests.map(t => t.fullTitle()) }; }); } diff --git a/src/functional_test_runner/lib/config/read_config_file.js b/src/functional_test_runner/lib/config/read_config_file.js index bd3cddcf8e25a..e733d2b989ff3 100644 --- a/src/functional_test_runner/lib/config/read_config_file.js +++ b/src/functional_test_runner/lib/config/read_config_file.js @@ -22,18 +22,17 @@ import { defaultsDeep } from 'lodash'; import { Config } from './config'; import { transformDeprecations } from './transform_deprecations'; -async function getSettingsFromFile(log, path, settingOverrides) { - log.debug('Loading config file from %j', path); +const cache = new WeakMap(); +async function getSettingsFromFile(log, path, settingOverrides) { const configModule = require(path); const configProvider = configModule.__esModule ? configModule.default : configModule; - const settingsWithDefaults = defaultsDeep( - {}, - settingOverrides, - await configProvider({ + if (!cache.has(configProvider)) { + log.debug('Loading config file from %j', path); + cache.set(configProvider, configProvider({ log, async readConfigFile(...args) { return new Config({ @@ -42,7 +41,13 @@ async function getSettingsFromFile(log, path, settingOverrides) { path, }); } - }) + })); + } + + const settingsWithDefaults = defaultsDeep( + {}, + settingOverrides, + await cache.get(configProvider) ); const logDeprecation = (...args) => log.error(...args); diff --git a/tasks/config/run.js b/tasks/config/run.js index d950218ceb2e4..dc21d8cfd2897 100644 --- a/tasks/config/run.js +++ b/tasks/config/run.js @@ -18,6 +18,7 @@ */ import { resolve } from 'path'; +import { getFunctionalTestGroupRunConfigs } from '../function_test_groups'; const { version } = require('../../package.json'); const KIBANA_INSTALL_DIR = `./build/oss/kibana-${version}-SNAPSHOT-${process.platform}-x86_64`; @@ -220,18 +221,9 @@ module.exports = function (grunt) { ], }, - functionalTestsRelease: { - cmd: process.execPath, - args: [ - 'scripts/functional_tests', - '--config', 'test/functional/config.js', - '--esFrom', esFrom, - '--bail', - '--debug', - '--kibana-install-dir', KIBANA_INSTALL_DIR, - '--', - '--server.maxPayloadBytes=1648576', - ], - }, + ...getFunctionalTestGroupRunConfigs({ + esFrom, + kibanaInstallDir: KIBANA_INSTALL_DIR + }) }; }; diff --git a/tasks/function_test_groups.js b/tasks/function_test_groups.js new file mode 100644 index 0000000000000..9ac7bcbf49877 --- /dev/null +++ b/tasks/function_test_groups.js @@ -0,0 +1,97 @@ +/* + * 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 execa from 'execa'; +import grunt from 'grunt'; + +/** + * The list of tags that we use in the functional tests, if we add a new group we need to add it to this list + * and to the list of jobs in .ci/jobs.yml + */ +const TEST_TAGS = [ + 'ciGroup1', + 'ciGroup2', + 'ciGroup3', + 'ciGroup4', + 'ciGroup5', + 'ciGroup6', + 'ciGroup7', + 'ciGroup8', + 'ciGroup9', + 'ciGroup10', + 'ciGroup11', + 'ciGroup12' +]; + +export function getFunctionalTestGroupRunConfigs({ esFrom, kibanaInstallDir } = {}) { + return { + // include a run task for each test group + ...TEST_TAGS.reduce((acc, tag) => ({ + ...acc, + [`functionalTests_${tag}`]: { + cmd: process.execPath, + args: [ + 'scripts/functional_tests', + '--include-tag', tag, + '--config', 'test/functional/config.js', + '--esFrom', esFrom, + '--bail', + '--debug', + '--kibana-install-dir', kibanaInstallDir, + '--', + '--server.maxPayloadBytes=1648576', + ], + } + }), {}), + }; +} + +grunt.registerTask( + 'functionalTests:ensureAllTestsInCiGroup', + 'Check that all of the functional tests are in a CI group', + async function () { + const done = this.async(); + + try { + const stats = JSON.parse(await execa.stderr(process.execPath, [ + 'scripts/functional_test_runner', + ...TEST_TAGS.map(tag => `--include-tag=${tag}`), + '--config', 'test/functional/config.js', + '--test-stats' + ])); + + if (stats.excludedTests.length > 0) { + grunt.fail.fatal(` + ${stats.excludedTests.length} tests are excluded by the ciGroup tags, make sure that + all test suites have a "ciGroup{X}" tag and that "tasks/functional_test_groups.js" + knows about the tag that you are using. + + tags: ${JSON.stringify({ include: TEST_TAGS })} + + - ${stats.excludedTests.join('\n - ')} + `); + return; + } + + done(); + } catch (error) { + grunt.fail.fatal(error.stack); + } + } +); diff --git a/tasks/jenkins.js b/tasks/jenkins.js index 69f3bc8205934..283e93e782b24 100644 --- a/tasks/jenkins.js +++ b/tasks/jenkins.js @@ -41,12 +41,6 @@ module.exports = function (grunt) { 'run:apiIntegrationTests', ]); - grunt.registerTask('jenkins:selenium', [ - 'checkPlugins', - 'run:functionalTestsRelease', - 'run:pluginFunctionalTestsRelease', - ]); - grunt.registerTask( 'jenkins:report', 'Reports failed tests found in junit xml files to Github issues', diff --git a/test/functional/apps/console/index.js b/test/functional/apps/console/index.js index ff7c200d3c779..abf758b40d4ff 100644 --- a/test/functional/apps/console/index.js +++ b/test/functional/apps/console/index.js @@ -21,6 +21,8 @@ export default function ({ getService, loadTestFile }) { const remote = getService('remote'); describe('console app', function () { + this.tags('ciGroup1'); + before(async function () { await remote.setWindowSize(1300, 1100); }); diff --git a/test/functional/apps/context/index.js b/test/functional/apps/context/index.js index e912bafa68f22..0b699f2e404ca 100644 --- a/test/functional/apps/context/index.js +++ b/test/functional/apps/context/index.js @@ -24,6 +24,8 @@ export default function ({ getService, getPageObjects, loadTestFile }) { const kibanaServer = getService('kibanaServer'); describe('context app', function () { + this.tags('ciGroup1'); + before(async function () { await remote.setWindowSize(1200, 800); await esArchiver.loadIfNeeded('logstash_functional'); diff --git a/test/functional/apps/dashboard/index.js b/test/functional/apps/dashboard/index.js index d53364ecdd186..53ba2a77fd0a7 100644 --- a/test/functional/apps/dashboard/index.js +++ b/test/functional/apps/dashboard/index.js @@ -22,26 +22,30 @@ export default function ({ getService, loadTestFile, getPageObjects }) { const esArchiver = getService('esArchiver'); const PageObjects = getPageObjects(['dashboard']); + async function loadCurrentData() { + await remote.setWindowSize(1300, 900); + await PageObjects.dashboard.initTests({ + kibanaIndex: 'dashboard/current/kibana', + dataIndex: 'dashboard/current/data', + defaultIndex: 'logstash-*', + }); + await PageObjects.dashboard.preserveCrossAppState(); + } + + async function unloadCurrentData() { + await PageObjects.dashboard.clearSavedObjectsFromAppLinks(); + await esArchiver.unload('dashboard/current/kibana'); + await esArchiver.unload('dashboard/current/data'); + } + describe('dashboard app', function () { + // This has to be first since the other tests create some embeddables as side affects and our counting assumes + // a fresh index. describe('using current data', function () { - before(async () => { - await remote.setWindowSize(1300, 900); - await PageObjects.dashboard.initTests({ - kibanaIndex: 'dashboard/current/kibana', - dataIndex: 'dashboard/current/data', - defaultIndex: 'logstash-*', - }); - await PageObjects.dashboard.preserveCrossAppState(); - }); - - after(async function () { - await PageObjects.dashboard.clearSavedObjectsFromAppLinks(); - await esArchiver.unload('dashboard/current/kibana'); - await esArchiver.unload('dashboard/current/data'); - }); + this.tags('ciGroup2'); + before(loadCurrentData); + after(unloadCurrentData); - // This has to be first since the other tests create some embeddables as side affects and our counting assumes - // a fresh index. loadTestFile(require.resolve('./_empty_dashboard')); loadTestFile(require.resolve('./_dark_theme')); loadTestFile(require.resolve('./_embeddable_rendering')); @@ -50,6 +54,13 @@ export default function ({ getService, loadTestFile, getPageObjects }) { loadTestFile(require.resolve('./_dashboard_options')); loadTestFile(require.resolve('./_data_shared_attributes')); loadTestFile(require.resolve('./_embed_mode')); + }); + + describe('using current data', function () { + this.tags('ciGroup3'); + before(loadCurrentData); + after(unloadCurrentData); + loadTestFile(require.resolve('./_full_screen_mode')); loadTestFile(require.resolve('./_dashboard_filter_bar')); loadTestFile(require.resolve('./_dashboard_filtering')); @@ -63,12 +74,19 @@ export default function ({ getService, loadTestFile, getPageObjects }) { // the data once to save on time. Eventually, all of these tests should just use current data and we can reserve // legacy data only for specifically testing BWC situations. describe('using legacy data', function () { + this.tags('ciGroup4'); before(() => remote.setWindowSize(1200, 900)); loadTestFile(require.resolve('./_dashboard_time_picker')); loadTestFile(require.resolve('./_bwc_shared_urls')); loadTestFile(require.resolve('./_panel_controls')); loadTestFile(require.resolve('./_dashboard_state')); + }); + + describe('using legacy data', function () { + this.tags('ciGroup5'); + before(() => remote.setWindowSize(1200, 900)); + loadTestFile(require.resolve('./_dashboard_save')); loadTestFile(require.resolve('./_dashboard_time')); loadTestFile(require.resolve('./_dashboard_listing')); diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index 4c8441d5e40de..37e1853eea793 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -22,6 +22,8 @@ export default function ({ getService, loadTestFile }) { const remote = getService('remote'); describe('discover app', function () { + this.tags('ciGroup6'); + before(function () { return remote.setWindowSize(1200, 800); }); diff --git a/test/functional/apps/getting_started/index.js b/test/functional/apps/getting_started/index.js index 2683372b9df16..3a18bff81b81a 100644 --- a/test/functional/apps/getting_started/index.js +++ b/test/functional/apps/getting_started/index.js @@ -21,6 +21,8 @@ export default function ({ getService, loadTestFile }) { const remote = getService('remote'); describe('Getting Started ', function () { + this.tags('ciGroup6'); + before(async function () { await remote.setWindowSize(1200, 800); }); diff --git a/test/functional/apps/home/index.js b/test/functional/apps/home/index.js index b4ac690c37e0a..496eaf9fd6af8 100644 --- a/test/functional/apps/home/index.js +++ b/test/functional/apps/home/index.js @@ -21,6 +21,8 @@ export default function ({ getService, loadTestFile }) { const remote = getService('remote'); describe('homepage app', function () { + this.tags('ciGroup6'); + before(function () { return remote.setWindowSize(1200, 800); }); diff --git a/test/functional/apps/management/index.js b/test/functional/apps/management/index.js index 29ff8ddb9ad78..4d4031b4e489b 100644 --- a/test/functional/apps/management/index.js +++ b/test/functional/apps/management/index.js @@ -21,33 +21,38 @@ export default function ({ getService, loadTestFile }) { const esArchiver = getService('esArchiver'); describe('management', function () { - // on setup, we create an settingsPage instance - // that we will use for all the tests - before(async function () { + before(async () => { await esArchiver.unload('logstash_functional'); await esArchiver.load('empty_kibana'); await esArchiver.loadIfNeeded('makelogs'); }); - after(async function () { + after(async () => { await esArchiver.unload('makelogs'); await esArchiver.unload('empty_kibana'); }); - loadTestFile(require.resolve('./_create_index_pattern_wizard')); - loadTestFile(require.resolve('./_index_pattern_create_delete')); - loadTestFile(require.resolve('./_index_pattern_results_sort')); - loadTestFile(require.resolve('./_index_pattern_popularity')); - loadTestFile(require.resolve('./_kibana_settings')); - loadTestFile(require.resolve('./_scripted_fields')); - loadTestFile(require.resolve('./_scripted_fields_preview')); - loadTestFile(require.resolve('./_index_pattern_filter')); - loadTestFile(require.resolve('./_scripted_fields_filter')); - loadTestFile(require.resolve('./_import_objects')); - loadTestFile(require.resolve('./_mgmt_import_saved_objects')); - loadTestFile(require.resolve('./_test_huge_fields')); - loadTestFile(require.resolve('./_handle_alias')); - loadTestFile(require.resolve('./_handle_version_conflict')); - }); + describe('', function () { + this.tags('ciGroup7'); + + loadTestFile(require.resolve('./_create_index_pattern_wizard')); + loadTestFile(require.resolve('./_index_pattern_create_delete')); + loadTestFile(require.resolve('./_index_pattern_results_sort')); + loadTestFile(require.resolve('./_index_pattern_popularity')); + loadTestFile(require.resolve('./_kibana_settings')); + loadTestFile(require.resolve('./_scripted_fields')); + loadTestFile(require.resolve('./_scripted_fields_preview')); + }); + describe('', function () { + this.tags('ciGroup8'); + + loadTestFile(require.resolve('./_index_pattern_filter')); + loadTestFile(require.resolve('./_scripted_fields_filter')); + loadTestFile(require.resolve('./_import_objects')); + loadTestFile(require.resolve('./_test_huge_fields')); + loadTestFile(require.resolve('./_handle_alias')); + loadTestFile(require.resolve('./_handle_version_conflict')); + }); + }); } diff --git a/test/functional/apps/status_page/index.js b/test/functional/apps/status_page/index.js index 2d25e20042111..52d26cd9f3a45 100644 --- a/test/functional/apps/status_page/index.js +++ b/test/functional/apps/status_page/index.js @@ -25,6 +25,8 @@ export default function ({ getService, getPageObjects }) { const PageObjects = getPageObjects(['common']); describe('status page', function () { + this.tags('ciGroup1'); + beforeEach(async () => { await PageObjects.common.navigateToApp('status_page'); }); diff --git a/test/functional/apps/timelion/index.js b/test/functional/apps/timelion/index.js index 73c9375460b34..286f14f0fbcdd 100644 --- a/test/functional/apps/timelion/index.js +++ b/test/functional/apps/timelion/index.js @@ -24,6 +24,8 @@ export default function ({ getService, loadTestFile }) { const kibanaServer = getService('kibanaServer'); describe('timelion app', function () { + this.tags('ciGroup1'); + before(async function () { log.debug('Starting timelion before method'); remote.setWindowSize(1280, 800); diff --git a/test/functional/apps/visualize/index.js b/test/functional/apps/visualize/index.js index 808d7fdfe5bf9..c8a7fafed0ad6 100644 --- a/test/functional/apps/visualize/index.js +++ b/test/functional/apps/visualize/index.js @@ -23,8 +23,9 @@ export default function ({ getService, loadTestFile }) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); + describe('visualize app', function () { - before(async function () { + before(async ()=> { log.debug('Starting visualize before method'); remote.setWindowSize(1280, 800); await esArchiver.loadIfNeeded('logstash_functional'); @@ -32,30 +33,49 @@ export default function ({ getService, loadTestFile }) { await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'UTC', 'defaultIndex': 'logstash-*' }); }); - loadTestFile(require.resolve('./_embedding_chart')); - loadTestFile(require.resolve('./_inspector')); - loadTestFile(require.resolve('./_chart_types')); - loadTestFile(require.resolve('./_experimental_vis')); - loadTestFile(require.resolve('./_gauge_chart')); - loadTestFile(require.resolve('./_area_chart')); - loadTestFile(require.resolve('./_line_chart')); - loadTestFile(require.resolve('./_data_table')); - loadTestFile(require.resolve('./_data_table_nontimeindex')); - loadTestFile(require.resolve('./_pie_chart')); - loadTestFile(require.resolve('./_tag_cloud')); - loadTestFile(require.resolve('./_tile_map')); - loadTestFile(require.resolve('./_region_map')); - loadTestFile(require.resolve('./_vertical_bar_chart')); - loadTestFile(require.resolve('./_vertical_bar_chart_nontimeindex')); - loadTestFile(require.resolve('./_heatmap_chart')); - loadTestFile(require.resolve('./_point_series_options')); - loadTestFile(require.resolve('./_markdown_vis')); - loadTestFile(require.resolve('./_tsvb_chart')); - loadTestFile(require.resolve('./_shared_item')); - loadTestFile(require.resolve('./_input_control_vis')); - loadTestFile(require.resolve('./_histogram_request_start')); - loadTestFile(require.resolve('./_vega_chart')); - loadTestFile(require.resolve('./_lab_mode')); - loadTestFile(require.resolve('./_linked_saved_searches.js')); + describe('', function () { + this.tags('ciGroup9'); + + loadTestFile(require.resolve('./_embedding_chart')); + loadTestFile(require.resolve('./_chart_types')); + loadTestFile(require.resolve('./_area_chart')); + loadTestFile(require.resolve('./_data_table')); + loadTestFile(require.resolve('./_data_table_nontimeindex')); + }); + + describe('', function () { + this.tags('ciGroup10'); + + loadTestFile(require.resolve('./_inspector')); + loadTestFile(require.resolve('./_experimental_vis')); + loadTestFile(require.resolve('./_gauge_chart')); + loadTestFile(require.resolve('./_heatmap_chart')); + loadTestFile(require.resolve('./_input_control_vis')); + loadTestFile(require.resolve('./_histogram_request_start')); + }); + + describe('', function () { + this.tags('ciGroup11'); + + loadTestFile(require.resolve('./_line_chart')); + loadTestFile(require.resolve('./_pie_chart')); + loadTestFile(require.resolve('./_region_map')); + loadTestFile(require.resolve('./_point_series_options')); + loadTestFile(require.resolve('./_markdown_vis')); + loadTestFile(require.resolve('./_shared_item')); + loadTestFile(require.resolve('./_lab_mode')); + loadTestFile(require.resolve('./_linked_saved_searches')); + }); + + describe('', function () { + this.tags('ciGroup12'); + + loadTestFile(require.resolve('./_tag_cloud')); + loadTestFile(require.resolve('./_tile_map')); + loadTestFile(require.resolve('./_vertical_bar_chart')); + loadTestFile(require.resolve('./_vertical_bar_chart_nontimeindex')); + loadTestFile(require.resolve('./_tsvb_chart')); + loadTestFile(require.resolve('./_vega_chart')); + }); }); } diff --git a/test/scripts/jenkins_ci_group.sh b/test/scripts/jenkins_ci_group.sh new file mode 100755 index 0000000000000..ee678898f056e --- /dev/null +++ b/test/scripts/jenkins_ci_group.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e +source "$(dirname "$0")/../../src/dev/ci_setup/setup.sh" +source "$(dirname "$0")/../../src/dev/ci_setup/git_setup.sh" +source "$(dirname "$0")/../../src/dev/ci_setup/java_setup.sh" + +"$(FORCE_COLOR=0 yarn bin)/grunt" functionalTests:ensureAllTestsInCiGroup; + +node scripts/build --debug --oss; + +export TEST_BROWSER_HEADLESS=1 +export TEST_ES_FROM=${TEST_ES_FROM:-source} + +"$(FORCE_COLOR=0 yarn bin)/grunt" "run:functionalTests_ciGroup${CI_GROUP}" --from=source; + +if [ "$CI_GROUP" == "1" ]; then + "$(FORCE_COLOR=0 yarn bin)/grunt" run:pluginFunctionalTestsRelease --from=source; +fi diff --git a/test/scripts/jenkins_selenium.sh b/test/scripts/jenkins_selenium.sh deleted file mode 100755 index c90da64da7375..0000000000000 --- a/test/scripts/jenkins_selenium.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -source "$(dirname $0)/../../src/dev/ci_setup/setup.sh" -source "$(dirname $0)/../../src/dev/ci_setup/git_setup.sh" -source "$(dirname $0)/../../src/dev/ci_setup/java_setup.sh" - -node scripts/build --debug --oss; - -export TEST_BROWSER_HEADLESS=1 -export TEST_ES_FROM=${TEST_ES_FROM:-source} -"$(FORCE_COLOR=0 yarn bin)/grunt" jenkins:selenium --from=source; diff --git a/test/scripts/jenkins_xpack.sh b/test/scripts/jenkins_xpack.sh index 25fe08088cbbd..2af9241942c51 100755 --- a/test/scripts/jenkins_xpack.sh +++ b/test/scripts/jenkins_xpack.sh @@ -24,19 +24,3 @@ cd "$XPACK_DIR" node scripts/jest --ci --no-cache --verbose echo "" echo "" - - -echo " -> building and extracting default Kibana distributable for use in functional tests" -cd "$KIBANA_DIR" -node scripts/build --debug --no-oss -linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" -installDir="$PARENT_DIR/install/kibana" -mkdir -p "$installDir" -tar -xzf "$linuxBuild" -C "$installDir" --strip=1 - -export TEST_ES_FROM=${TEST_ES_FROM:-source} -echo " -> Running functional and api tests" -cd "$XPACK_DIR" -node scripts/functional_tests --debug --bail --kibana-install-dir "$installDir" -echo "" -echo "" diff --git a/test/scripts/jenkins_xpack_ci_group.sh b/test/scripts/jenkins_xpack_ci_group.sh new file mode 100755 index 0000000000000..62d2449451747 --- /dev/null +++ b/test/scripts/jenkins_xpack_ci_group.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +source "$(dirname "$0")/../../src/dev/ci_setup/setup.sh" +source "$(dirname "$0")/../../src/dev/ci_setup/git_setup.sh" +source "$(dirname "$0")/../../src/dev/ci_setup/java_setup.sh" + +export TEST_BROWSER_HEADLESS=1 +export XPACK_DIR="$(cd "$(dirname "$0")/../../x-pack"; pwd)" +echo "-> XPACK_DIR ${XPACK_DIR}" + +echo " -> Ensuring all functional tests are in a ciGroup" +cd "$XPACK_DIR" +node scripts/functional_tests --assert-none-excluded \ + --include-tag ciGroup1 \ + --include-tag ciGroup2 \ + --include-tag ciGroup3 \ + --include-tag ciGroup4 \ + --include-tag ciGroup5 \ + --include-tag ciGroup6 + +echo " -> building and extracting default Kibana distributable for use in functional tests" +cd "$KIBANA_DIR" +node scripts/build --debug --no-oss +linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" +installDir="$PARENT_DIR/install/kibana" +mkdir -p "$installDir" +tar -xzf "$linuxBuild" -C "$installDir" --strip=1 + +export TEST_ES_FROM=${TEST_ES_FROM:-source} +echo " -> Running functional and api tests" +cd "$XPACK_DIR" +node scripts/functional_tests --debug --bail --kibana-install-dir "$installDir" --include-tag "ciGroup$CI_GROUP" +echo "" +echo "" diff --git a/x-pack/test/api_integration/apis/index.js b/x-pack/test/api_integration/apis/index.js index aa2273ce64212..41d4cabc3b63f 100644 --- a/x-pack/test/api_integration/apis/index.js +++ b/x-pack/test/api_integration/apis/index.js @@ -5,7 +5,9 @@ */ export default function ({ loadTestFile }) { - describe('apis', () => { + describe('apis', function () { + this.tags('ciGroup5'); + loadTestFile(require.resolve('./es')); loadTestFile(require.resolve('./security')); loadTestFile(require.resolve('./monitoring')); diff --git a/x-pack/test/functional/apps/dashboard_mode/index.js b/x-pack/test/functional/apps/dashboard_mode/index.js index e7907f4fa6508..5953dd4924c5d 100644 --- a/x-pack/test/functional/apps/dashboard_mode/index.js +++ b/x-pack/test/functional/apps/dashboard_mode/index.js @@ -6,6 +6,8 @@ export default function ({ loadTestFile }) { describe('dashboard mode', function () { + this.tags('ciGroup3'); + loadTestFile(require.resolve('./dashboard_view_mode')); }); } diff --git a/x-pack/test/functional/apps/graph/index.js b/x-pack/test/functional/apps/graph/index.js index d77ec07969e63..98b360320c2c7 100644 --- a/x-pack/test/functional/apps/graph/index.js +++ b/x-pack/test/functional/apps/graph/index.js @@ -6,6 +6,8 @@ export default function ({ loadTestFile }) { describe('graph app', function () { + this.tags('ciGroup1'); + loadTestFile(require.resolve('./graph')); }); } diff --git a/x-pack/test/functional/apps/grok_debugger/index.js b/x-pack/test/functional/apps/grok_debugger/index.js index 3dc15acbe5e30..75c05f35abd28 100644 --- a/x-pack/test/functional/apps/grok_debugger/index.js +++ b/x-pack/test/functional/apps/grok_debugger/index.js @@ -5,7 +5,9 @@ */ export default function ({ loadTestFile }) { - describe('logstash', () => { + describe('logstash', function () { + this.tags('ciGroup2'); + loadTestFile(require.resolve('./grok_debugger')); }); } diff --git a/x-pack/test/functional/apps/infra/home_page.ts b/x-pack/test/functional/apps/infra/home_page.ts index d7efdb85838df..04382e4964cf0 100644 --- a/x-pack/test/functional/apps/infra/home_page.ts +++ b/x-pack/test/functional/apps/infra/home_page.ts @@ -15,6 +15,10 @@ export default ({ getPageObjects, getService }: KibanaFunctionalTestDefaultProvi const pageObjects = getPageObjects(['common', 'infraHome']); describe('Home page', () => { + before(async () => { + await esArchiver.load('empty_kibana'); + }); + describe('without metrics present', () => { before(async () => await esArchiver.unload('infra')); diff --git a/x-pack/test/functional/apps/infra/index.ts b/x-pack/test/functional/apps/infra/index.ts index efb3cc9f276bc..87abb2584b6c2 100644 --- a/x-pack/test/functional/apps/infra/index.ts +++ b/x-pack/test/functional/apps/infra/index.ts @@ -8,7 +8,9 @@ import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers'; // tslint:disable-next-line:no-default-export export default ({ loadTestFile }: KibanaFunctionalTestDefaultProviders) => { - describe('InfraOps app', () => { + describe('InfraOps app', function() { + (this as any).tags('ciGroup4'); + loadTestFile(require.resolve('./home_page')); }); }; diff --git a/x-pack/test/functional/apps/logstash/index.js b/x-pack/test/functional/apps/logstash/index.js index bd7577e2b88f7..bc7d2941b7198 100644 --- a/x-pack/test/functional/apps/logstash/index.js +++ b/x-pack/test/functional/apps/logstash/index.js @@ -5,7 +5,9 @@ */ export default function ({ loadTestFile }) { - describe('logstash', () => { + describe('logstash', function () { + this.tags('ciGroup2'); + loadTestFile(require.resolve('./pipeline_list')); loadTestFile(require.resolve('./pipeline_create')); }); diff --git a/x-pack/test/functional/apps/monitoring/index.js b/x-pack/test/functional/apps/monitoring/index.js index 817467f847ddc..a1551f2829a98 100644 --- a/x-pack/test/functional/apps/monitoring/index.js +++ b/x-pack/test/functional/apps/monitoring/index.js @@ -5,7 +5,9 @@ */ export default function ({ loadTestFile }) { - describe('Monitoring app', () => { + describe('Monitoring app', function () { + this.tags('ciGroup1'); + loadTestFile(require.resolve('./cluster/list')); loadTestFile(require.resolve('./cluster/overview')); loadTestFile(require.resolve('./cluster/alerts')); diff --git a/x-pack/test/functional/apps/security/index.js b/x-pack/test/functional/apps/security/index.js index 0bccef48960c3..2de59ddae3d3c 100644 --- a/x-pack/test/functional/apps/security/index.js +++ b/x-pack/test/functional/apps/security/index.js @@ -6,6 +6,8 @@ export default function ({ loadTestFile }) { describe('security app', function () { + this.tags('ciGroup4'); + loadTestFile(require.resolve('./security')); loadTestFile(require.resolve('./doc_level_security_roles')); loadTestFile(require.resolve('./management')); diff --git a/x-pack/test/functional/apps/spaces/index.ts b/x-pack/test/functional/apps/spaces/index.ts index 455692b86fc81..76eb7d911b17b 100644 --- a/x-pack/test/functional/apps/spaces/index.ts +++ b/x-pack/test/functional/apps/spaces/index.ts @@ -8,6 +8,8 @@ import { TestInvoker } from './lib/types'; // tslint:disable:no-default-export export default function spacesApp({ loadTestFile }: TestInvoker) { describe('Spaces app', function spacesAppTestSuite() { + (this as any).tags('ciGroup4'); + loadTestFile(require.resolve('./spaces_selection')); }); } diff --git a/x-pack/test/functional/apps/status_page/index.ts b/x-pack/test/functional/apps/status_page/index.ts index 15e6711090e09..6b6d5c1d97600 100644 --- a/x-pack/test/functional/apps/status_page/index.ts +++ b/x-pack/test/functional/apps/status_page/index.ts @@ -8,6 +8,8 @@ import { TestInvoker } from './lib/types'; // tslint:disable:no-default-export export default function statusPage({ loadTestFile }: TestInvoker) { describe('Status page', function statusPageTestSuite() { + (this as any).tags('ciGroup4'); + loadTestFile(require.resolve('./status_page')); }); } diff --git a/x-pack/test/functional/apps/watcher/index.js b/x-pack/test/functional/apps/watcher/index.js index 80e60c213d211..5542f5cb8f0b7 100644 --- a/x-pack/test/functional/apps/watcher/index.js +++ b/x-pack/test/functional/apps/watcher/index.js @@ -6,6 +6,8 @@ export default function ({ loadTestFile }) { describe('watcher app', function () { + this.tags('ciGroup1'); + //loadTestFile(require.resolve('./management')); loadTestFile(require.resolve('./watcher_test')); }); diff --git a/x-pack/test/reporting/api/chromium_tests.js b/x-pack/test/reporting/api/chromium_tests.js index d9da4ac802cbc..c9282eda4f0cc 100644 --- a/x-pack/test/reporting/api/chromium_tests.js +++ b/x-pack/test/reporting/api/chromium_tests.js @@ -10,7 +10,9 @@ export default function ({ loadTestFile, getService }) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - describe('chromium', () => { + describe('chromium', function () { + this.tags('ciGroup6'); + before(async () => { await esArchiver.load(OSS_KIBANA_ARCHIVE_PATH); await esArchiver.load(OSS_DATA_ARCHIVE_PATH); diff --git a/x-pack/test/reporting/api/phantom_tests.js b/x-pack/test/reporting/api/phantom_tests.js index 4a3212bff46ff..e0c8c11b326bd 100644 --- a/x-pack/test/reporting/api/phantom_tests.js +++ b/x-pack/test/reporting/api/phantom_tests.js @@ -10,7 +10,9 @@ export default function ({ loadTestFile, getService }) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - describe('phantom', () => { + describe('phantom', function () { + this.tags('ciGroup6'); + before(async () => { await esArchiver.load(OSS_KIBANA_ARCHIVE_PATH); await esArchiver.load(OSS_DATA_ARCHIVE_PATH); diff --git a/x-pack/test/reporting/configs/chromium_functional.js b/x-pack/test/reporting/configs/chromium_functional.js index f14d943746645..80a9024c06ab8 100644 --- a/x-pack/test/reporting/configs/chromium_functional.js +++ b/x-pack/test/reporting/configs/chromium_functional.js @@ -13,7 +13,7 @@ export default async function ({ readConfigFile }) { return { ...functionalConfig, junit: { - reportName: 'X-Pack Chromium API Reporting Tests', + reportName: 'X-Pack Chromium Functional Reporting Tests', }, testFiles: [require.resolve('../functional')], kbnTestServer: { diff --git a/x-pack/test/reporting/configs/phantom_functional.js b/x-pack/test/reporting/configs/phantom_functional.js index 48d2559479186..e9a61ee813cf2 100644 --- a/x-pack/test/reporting/configs/phantom_functional.js +++ b/x-pack/test/reporting/configs/phantom_functional.js @@ -13,7 +13,7 @@ export default async function ({ readConfigFile }) { return { ...functionalConfig, junit: { - reportName: 'X-Pack Phantom API Reporting Tests', + reportName: 'X-Pack Phantom Functional Reporting Tests', }, testFiles: [require.resolve('../functional')], kbnTestServer: { diff --git a/x-pack/test/reporting/functional/index.js b/x-pack/test/reporting/functional/index.js index d99cf9a900153..fa473f454a925 100644 --- a/x-pack/test/reporting/functional/index.js +++ b/x-pack/test/reporting/functional/index.js @@ -6,6 +6,7 @@ export default function ({ loadTestFile }) { describe('reporting app', function () { + this.tags('ciGroup6'); loadTestFile(require.resolve('./reporting')); }); } diff --git a/x-pack/test/saml_api_integration/apis/index.js b/x-pack/test/saml_api_integration/apis/index.js index ce7c48029e66a..ac08d2e078abf 100644 --- a/x-pack/test/saml_api_integration/apis/index.js +++ b/x-pack/test/saml_api_integration/apis/index.js @@ -5,7 +5,8 @@ */ export default function ({ loadTestFile }) { - describe('apis SAML', () => { + describe('apis SAML', function () { + this.tags('ciGroup6'); loadTestFile(require.resolve('./security')); }); } diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/index.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/index.ts index d25a9b852b789..b2b62b501e765 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/index.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/index.ts @@ -12,7 +12,9 @@ export default function({ getService, loadTestFile }: TestInvoker) { const es = getService('es'); const supertest = getService('supertest'); - describe('saved objects security and spaces enabled', () => { + describe('saved objects security and spaces enabled', function() { + (this as any).tags('ciGroup5'); + before(async () => { await createUsersAndRoles(es, supertest); }); diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/index.ts b/x-pack/test/saved_object_api_integration/security_only/apis/index.ts index c9be7152f96ea..a0797300ebf2b 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/index.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/index.ts @@ -12,7 +12,9 @@ export default function({ getService, loadTestFile }: TestInvoker) { const es = getService('es'); const supertest = getService('supertest'); - describe('saved objects security only enabled', () => { + describe('saved objects security only enabled', function() { + (this as any).tags('ciGroup5'); + before(async () => { await createUsersAndRoles(es, supertest); }); diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/index.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/index.ts index 113cf86454d5f..b1028fa6c74c9 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/index.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/index.ts @@ -8,7 +8,9 @@ import { TestInvoker } from '../../common/lib/types'; // tslint:disable:no-default-export export default function({ loadTestFile }: TestInvoker) { - describe('saved objects spaces only enabled', () => { + describe('saved objects spaces only enabled', function() { + (this as any).tags('ciGroup5'); + loadTestFile(require.resolve('./bulk_create')); loadTestFile(require.resolve('./bulk_get')); loadTestFile(require.resolve('./create')); diff --git a/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts b/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts index 65ab34e7ae8f8..6d8402fbb9244 100644 --- a/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts +++ b/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts @@ -12,7 +12,9 @@ export default function({ loadTestFile, getService }: TestInvoker) { const es = getService('es'); const supertest = getService('supertest'); - describe('spaces api with security', () => { + describe('spaces api with security', function() { + (this as any).tags('ciGroup5'); + before(async () => { await createUsersAndRoles(es, supertest); }); diff --git a/x-pack/test/spaces_api_integration/spaces_only/apis/index.ts b/x-pack/test/spaces_api_integration/spaces_only/apis/index.ts index 6864ee7fbda94..75b546dd16022 100644 --- a/x-pack/test/spaces_api_integration/spaces_only/apis/index.ts +++ b/x-pack/test/spaces_api_integration/spaces_only/apis/index.ts @@ -8,7 +8,9 @@ import { TestInvoker } from '../../common/lib/types'; // tslint:disable:no-default-export export default function spacesOnlyTestSuite({ loadTestFile }: TestInvoker) { - describe('spaces api without security', () => { + describe('spaces api without security', function() { + (this as any).tags('ciGroup5'); + loadTestFile(require.resolve('./create')); loadTestFile(require.resolve('./delete')); loadTestFile(require.resolve('./get_all')); From ff49a1c6742d67fa5daed569ff3bb269783f6bd1 Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 20 Nov 2018 14:22:44 -0800 Subject: [PATCH 39/95] [ci] load the boostrap_cache baked into CI images (#25841) We're creating a cache of files that should speed up bootstraping CI jobs and baking it into the CI images with https://github.com/elastic/kibana/blob/992daf5fed416177a61b73d798e882401788d323/.ci/packer_cache.sh. This PR utilizes that cache (that will start showing up in CI images shortly) by extracting it into the Kibana workspace and failing if it's missing for some reason. --- .ci/run.sh | 2 ++ src/dev/ci_setup/load_bootstrap_cache.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100755 src/dev/ci_setup/load_bootstrap_cache.sh diff --git a/.ci/run.sh b/.ci/run.sh index 57cc4afd6a38a..1761c5e78cdcf 100755 --- a/.ci/run.sh +++ b/.ci/run.sh @@ -5,6 +5,8 @@ set -e # move to Kibana root cd "$(dirname "$0")/.." +./src/dev/ci_setup/load_bootstrap_cache.sh; + case "$JOB" in kibana-intake) ./test/scripts/jenkins_unit.sh diff --git a/src/dev/ci_setup/load_bootstrap_cache.sh b/src/dev/ci_setup/load_bootstrap_cache.sh new file mode 100755 index 0000000000000..cbbd46a7ff652 --- /dev/null +++ b/src/dev/ci_setup/load_bootstrap_cache.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +bootstrapCache="$HOME/.kibana/bootstrap_cache/master.tar" + +if [ -f "$bootstrapCache" ]; then + echo "extracting bootstrap_cache from $bootstrapCache"; + tar -xf "$bootstrapCache"; +else + echo "bootstrap_cache missing"; + exit 1; +fi From e8e05d80f43e137834e7e752e43788e262a83375 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 21 Nov 2018 02:03:41 +0000 Subject: [PATCH 40/95] Fix git dir discovery into the precommit hook setup (#25870) * fix(NA): git dir discovery into the precommt hook setup. * refact(NA): promisify gitrevparse function. * docs(NA): fix typo on comments --- src/dev/register_git_hook/register_git_hook.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dev/register_git_hook/register_git_hook.js b/src/dev/register_git_hook/register_git_hook.js index e0a119b33e421..670a3cb2b3aea 100644 --- a/src/dev/register_git_hook/register_git_hook.js +++ b/src/dev/register_git_hook/register_git_hook.js @@ -22,13 +22,23 @@ import { chmod, unlink, writeFile } from 'fs'; import dedent from 'dedent'; import { resolve } from 'path'; import { promisify } from 'util'; +import SimpleGit from 'simple-git'; import { REPO_ROOT } from '../constants'; +const simpleGit = new SimpleGit(REPO_ROOT); + const chmodAsync = promisify(chmod); +const gitRevParseAsync = promisify(simpleGit.revparse.bind(simpleGit)); const unlinkAsync = promisify(unlink); const writeFileAsync = promisify(writeFile); -const PRECOMMIT_GIT_HOOK_SCRIPT_PATH = resolve(REPO_ROOT, '.git/hooks/pre-commit'); +async function getPrecommitGitHookScriptPath(rootPath) { + // Retrieves the correct location for the .git dir for + // every git setup (including git worktree) + const gitDirPath = (await gitRevParseAsync(['--git-dir'])).trim(); + + return resolve(rootPath, gitDirPath, 'hooks/pre-commit'); +} function getKbnPrecommitGitHookScript(rootPath) { return dedent(` @@ -69,7 +79,7 @@ export async function registerPrecommitGitHook(log) { try { await writeGitHook( - PRECOMMIT_GIT_HOOK_SCRIPT_PATH, + await getPrecommitGitHookScriptPath(REPO_ROOT), getKbnPrecommitGitHookScript(REPO_ROOT) ); } catch (e) { From 415c61bc99f9a4e52a7d37353b6941f5a7153e3c Mon Sep 17 00:00:00 2001 From: Silvia Mitter Date: Wed, 21 Nov 2018 08:09:05 +0100 Subject: [PATCH 41/95] apm: Update Kibana Index Pattern (#25929) --- .../server/tutorials/apm/saved_objects/index_pattern.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core_plugins/kibana/server/tutorials/apm/saved_objects/index_pattern.json b/src/core_plugins/kibana/server/tutorials/apm/saved_objects/index_pattern.json index 1a071768ab78c..066e425e866fa 100644 --- a/src/core_plugins/kibana/server/tutorials/apm/saved_objects/index_pattern.json +++ b/src/core_plugins/kibana/server/tutorials/apm/saved_objects/index_pattern.json @@ -1,7 +1,7 @@ { "attributes": { "fieldFormatMap": "{\"@timestamp\":{\"id\":\"date\"},\"context.service.name\":{\"id\":\"url\",\"params\":{\"labelTemplate\":\"{{value}}\",\"openLinkInCurrentTab\":true,\"urlTemplate\":\"../app/kibana#/dashboard/41b5d920-7821-11e7-8c47-65b845b5cfb3?_a=(query:(language:lucene,query:'context.service.name:\\\"{{value}}\\\"'))\"}},\"error id icon\":{\"id\":\"url\",\"params\":{\"labelTemplate\":\"-\"}},\"error.grouping_key\":{\"id\":\"url\",\"params\":{\"labelTemplate\":\"View Error Details\",\"openLinkInCurrentTab\":true,\"urlTemplate\":\"../app/kibana#/dashboard/5f08a870-7c6a-11e7-aa55-3b0d52c71c60?_a=(query:(language:lucene,query:'error.grouping_key:{{value}}'))\"}},\"span.duration.us\":{\"id\":\"duration\",\"params\":{\"inputFormat\":\"microseconds\",\"outputFormat\":\"asMilliseconds\",\"outputPrecision\":0}},\"system.cpu.total.norm.pct\":{\"id\":\"percent\"},\"system.memory.actual.free\":{\"id\":\"bytes\"},\"system.memory.total\":{\"id\":\"bytes\"},\"system.process.cpu.total.norm.pct\":{\"id\":\"percent\"},\"system.process.memory.rss.bytes\":{\"id\":\"bytes\"},\"system.process.memory.size\":{\"id\":\"bytes\"},\"transaction.duration.us\":{\"id\":\"duration\",\"params\":{\"inputFormat\":\"microseconds\",\"outputFormat\":\"asMilliseconds\",\"outputPrecision\":0}},\"transaction.id\":{\"id\":\"url\",\"params\":{\"labelTemplate\":\"View Spans\",\"openLinkInCurrentTab\":true,\"urlTemplate\":\"../app/kibana#/dashboard/3e3de700-7de0-11e7-b115-df9c90da2df1?_a=(query:(language:lucene,query:'transaction.id:{{value}}'))\"}},\"view errors\":{\"id\":\"url\",\"params\":{\"labelTemplate\":\"View Errors\",\"openLinkInCurrentTab\":true,\"urlTemplate\":\"../app/kibana#/dashboard/37f6fac0-7c6a-11e7-aa55-3b0d52c71c60?_a=(query:(language:lucene,query:'context.service.name:\\\"{{value}}\\\"'))\"}},\"view spans\":{\"id\":\"url\",\"params\":{\"labelTemplate\":\"View Spans\"}}}", - "fields": "[{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"beat.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"beat.hostname\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"beat.timezone\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"beat.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"@timestamp\",\"scripted\":false,\"searchable\":true,\"type\":\"date\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"tags\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"fields\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.message\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.code\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.provider\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.instance_id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.instance_name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.machine_type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.availability_zone\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.project_id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.region\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"docker.container.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"docker.container.image\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"docker.container.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"docker.container.labels\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.architecture\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.os.platform\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.os.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.os.family\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.ip\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.mac\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.pod.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.pod.uid\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.namespace\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.node.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.labels\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.annotations\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.container.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.container.image\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"listening\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"processor.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"processor.event\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.tags\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.username\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.email\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.ip\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.user-agent\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.raw\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.protocol\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.full\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.hostname\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.port\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.pathname\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.search\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.hash\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.http_version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.method\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.response.status_code\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.response.finished\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.system.hostname\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.system.architecture\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.system.platform\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.system.ip\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.process.pid\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.process.ppid\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.process.title\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.environment\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.language.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.language.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.runtime.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.runtime.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.framework.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.framework.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.agent.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.agent.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":true,\"lang\":\"painless\",\"name\":\"view errors\",\"script\":\"doc['context.service.name'].value\",\"scripted\":true,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":true,\"lang\":\"painless\",\"name\":\"error id icon\",\"script\":\"doc['error.grouping_key'].value\",\"scripted\":true,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":4,\"doc_values\":true,\"indexed\":true,\"name\":\"error.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":2,\"doc_values\":true,\"indexed\":true,\"name\":\"error.culprit\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.grouping_key\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.code\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":2,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.message\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.module\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":4,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":2,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.handled\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.log.level\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.log.logger_name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":2,\"doc_values\":true,\"indexed\":true,\"name\":\"error.log.message\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.log.param_message\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.cpu.total.norm.pct\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.memory.total\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.memory.actual.free\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.process.cpu.total.norm.pct\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.process.memory.size\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.process.memory.rss.bytes\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"sourcemap.service.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"sourcemap.service.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"sourcemap.bundle_filepath\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"view spans\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"span.id\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"span.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"span.type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"span.start.us\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"span.duration.us\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"span.parent\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.name.keyword\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.duration.us\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.result\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.marks\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.marks.navigationTiming\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.sampled\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.span_count.dropped.total\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":false,\"name\":\"_id\",\"scripted\":false,\"searchable\":false,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":false,\"name\":\"_type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":false,\"name\":\"_index\",\"scripted\":false,\"searchable\":false,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":false,\"name\":\"_score\",\"scripted\":false,\"searchable\":false,\"type\":\"number\"}]", + "fields": "[{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"trace.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"parent.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"span.hex_id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"span.sync\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"beat.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"beat.hostname\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"beat.timezone\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"beat.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"@timestamp\",\"scripted\":false,\"searchable\":true,\"type\":\"date\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"timestamp.us\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"tags\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"fields\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.message\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.code\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.provider\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.instance_id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.instance_name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.machine_type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.availability_zone\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.project_id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"meta.cloud.region\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"docker.container.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"docker.container.image\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"docker.container.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"docker.container.labels\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.architecture\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.os.platform\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.os.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.os.kernel\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.os.family\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.ip\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"host.mac\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.pod.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.pod.uid\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.namespace\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.node.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.labels\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.annotations\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.container.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"kubernetes.container.image\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"listening\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"processor.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"processor.event\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.tags\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.username\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.email\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.ip\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.user.user-agent\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.raw\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.protocol\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.full\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.hostname\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.port\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.pathname\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.search\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.url.hash\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.http_version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.http.status_code\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.request.method\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.response.status_code\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.response.finished\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.system.hostname\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.system.architecture\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.system.platform\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.system.ip\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.process.pid\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.process.ppid\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.process.title\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.environment\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.language.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.language.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.runtime.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.runtime.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.framework.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.framework.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.agent.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"context.service.agent.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":true,\"lang\":\"painless\",\"name\":\"view errors\",\"script\":\"doc['context.service.name'].value\",\"scripted\":true,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":true,\"lang\":\"painless\",\"name\":\"error id icon\",\"script\":\"doc['error.grouping_key'].value\",\"scripted\":true,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":4,\"doc_values\":true,\"indexed\":true,\"name\":\"error.id\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":2,\"doc_values\":true,\"indexed\":true,\"name\":\"error.culprit\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.grouping_key\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.code\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":2,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.message\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.module\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":4,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":2,\"doc_values\":true,\"indexed\":true,\"name\":\"error.exception.handled\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.log.level\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.log.logger_name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":2,\"doc_values\":true,\"indexed\":true,\"name\":\"error.log.message\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"error.log.param_message\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.cpu.total.norm.pct\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.memory.total\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.memory.actual.free\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.process.cpu.total.norm.pct\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.process.memory.size\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"system.process.memory.rss.bytes\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"sourcemap.service.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"sourcemap.service.version\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"sourcemap.bundle_filepath\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"view spans\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"span.id\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"span.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"span.type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"span.start.us\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":1,\"doc_values\":true,\"indexed\":true,\"name\":\"span.duration.us\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"span.parent\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.name\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.name.keyword\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.duration.us\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.result\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.marks\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.marks.navigationTiming\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.sampled\",\"scripted\":false,\"searchable\":true},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":true,\"indexed\":true,\"name\":\"transaction.span_count.dropped.total\",\"scripted\":false,\"searchable\":true,\"type\":\"number\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":false,\"name\":\"_id\",\"scripted\":false,\"searchable\":false,\"type\":\"string\"},{\"aggregatable\":true,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":false,\"name\":\"_type\",\"scripted\":false,\"searchable\":true,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":false,\"name\":\"_index\",\"scripted\":false,\"searchable\":false,\"type\":\"string\"},{\"aggregatable\":false,\"analyzed\":false,\"count\":0,\"doc_values\":false,\"indexed\":false,\"name\":\"_score\",\"scripted\":false,\"searchable\":false,\"type\":\"number\"}]", "sourceFilters": "[{\"value\":\"sourcemap.sourcemap\"}]", "timeFieldName": "@timestamp" }, From 360dd787c8d0b64e3c3cbe567a64c1ea659da1ad Mon Sep 17 00:00:00 2001 From: tibmt Date: Wed, 21 Nov 2018 12:18:43 +0300 Subject: [PATCH 42/95] remove extra line from i18nrc.json --- .i18nrc.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.i18nrc.json b/.i18nrc.json index 33e25169ce827..0c780d84c5b1a 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -29,6 +29,5 @@ "src/ui/ui_render/ui_render_mixin.js", "x-pack/plugins/infra/public/utils/loading_state/loading_result.ts", "x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts" - ] } From 9ca8cffb61a6c0410cebb6bb000d50222f770153 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Wed, 21 Nov 2018 09:34:41 +0000 Subject: [PATCH 43/95] [ML] Fixes font size regressions following less to sass conversion (#25945) --- .../ml/public/explorer/explorer_charts/_explorer_chart.scss | 2 +- .../simple/components/event_rate_chart/_event_rate_chart.scss | 2 +- .../jobs/new_job/simple/recognize/create_job/_create_jobs.scss | 2 +- .../new_job/simple/single_metric/create_job/_create_job.scss | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/_explorer_chart.scss b/x-pack/plugins/ml/public/explorer/explorer_charts/_explorer_chart.scss index 4808d47fccd4f..32d589581929d 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/_explorer_chart.scss +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/_explorer_chart.scss @@ -2,7 +2,7 @@ overflow: hidden; .ml-explorer-chart-svg { - font-size: $euiSizeXS; + font-size: $euiFontSizeXS; font-family: $euiFontFamily; .line-chart { diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/components/event_rate_chart/_event_rate_chart.scss b/x-pack/plugins/ml/public/jobs/new_job/simple/components/event_rate_chart/_event_rate_chart.scss index fba7df107f02d..6378ca2b5c80c 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/components/event_rate_chart/_event_rate_chart.scss +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/components/event_rate_chart/_event_rate_chart.scss @@ -1,6 +1,6 @@ ml-event-rate-chart { svg { - font-size: $euiSizeXS; + font-size: $euiFontSizeXS; font-family: $euiFontFamily; margin-top: -20px; // SASSTODO: Proper calc } diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/_create_jobs.scss b/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/_create_jobs.scss index 100acd586ea37..21d0cefd55511 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/_create_jobs.scss +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/_create_jobs.scss @@ -88,7 +88,7 @@ // SASSTODO: Proper selector span { - font-size: $euiSizeXS; + font-size: $euiFontSizeXS; } } .sub-title { diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/_create_job.scss b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/_create_job.scss index 25fdcee21bb11..bb339185a127c 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/_create_job.scss +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/_create_job.scss @@ -105,7 +105,7 @@ ml-single-metric-job-chart { svg { - font-size: $euiSizeXS; + font-size: $euiFontSizeXS; font-family: $euiFontFamily; } From ef4fa62f51b72c8db446310654a4756ba4c64b94 Mon Sep 17 00:00:00 2001 From: Nox911 Date: Wed, 21 Nov 2018 12:51:15 +0300 Subject: [PATCH 44/95] Feature/translate monitoring server (#25195) * Translate monitoring server(without metrics folder) * Fix issue * Fix issues * Fix issues * Remove eslint rule disabling --- .../cluster_alerts/alerts_cluster_search.js | 9 ++++-- .../alerts_clusters_aggregation.js | 10 ++++++- .../server/cluster_alerts/check_license.js | 29 ++++++++++++++++--- .../verify_monitoring_license.js | 7 +++-- .../server/lib/cluster/get_cluster_stats.js | 13 +++++++-- .../lib/cluster/get_clusters_from_request.js | 8 ++++- .../indices/get_index_summary.js | 8 +++-- .../lib/elasticsearch/indices/get_indices.js | 4 ++- .../elasticsearch/nodes/get_node_summary.js | 10 +++++-- .../server/lib/elasticsearch/nodes/lookups.js | 21 ++++++++++---- .../server/lib/errors/auth_errors.js | 7 +++-- .../server/lib/errors/known_errors.js | 11 ++++--- 12 files changed, 107 insertions(+), 30 deletions(-) diff --git a/x-pack/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js b/x-pack/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js index bf2eda6325188..567483d30f295 100644 --- a/x-pack/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js +++ b/x-pack/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js @@ -7,6 +7,7 @@ import { get } from 'lodash'; import moment from 'moment'; import { verifyMonitoringLicense } from './verify_monitoring_license'; +import { i18n } from '@kbn/i18n'; /** * Retrieve any statically defined cluster alerts (not indexed) for the {@code cluster}. @@ -32,8 +33,12 @@ export function staticAlertForCluster(cluster) { }, update_timestamp: cluster.timestamp, timestamp: get(cluster, 'license.issue_date', cluster.timestamp), - prefix: 'Configuring TLS will be required to apply a Gold or Platinum license when security is enabled.', - message: 'See documentation for details.' + prefix: i18n.translate('xpack.monitoring.clusterAlerts.clusterNeedsTSLEnabledDescription', { + defaultMessage: 'Configuring TLS will be required to apply a Gold or Platinum license when security is enabled.' + }), + message: i18n.translate('xpack.monitoring.clusterAlerts.seeDocumentationDescription', { + defaultMessage: 'See documentation for details.' + }) }; } diff --git a/x-pack/plugins/monitoring/server/cluster_alerts/alerts_clusters_aggregation.js b/x-pack/plugins/monitoring/server/cluster_alerts/alerts_clusters_aggregation.js index a1cf3b34ee8ee..d35be35b90c2f 100644 --- a/x-pack/plugins/monitoring/server/cluster_alerts/alerts_clusters_aggregation.js +++ b/x-pack/plugins/monitoring/server/cluster_alerts/alerts_clusters_aggregation.js @@ -6,6 +6,7 @@ import { get, find } from 'lodash'; import { verifyMonitoringLicense } from './verify_monitoring_license'; +import { i18n } from '@kbn/i18n'; export function alertsClustersAggregation(req, alertsIndex, clusters, checkLicense) { const verification = verifyMonitoringLicense(req.server); @@ -105,7 +106,14 @@ export function alertsClustersAggregation(req, alertsIndex, clusters, checkLicen alerts = { clusterMeta: { enabled: false, - message: `Cluster [${cluster.cluster_name}] license type [${license.type}] does not support Cluster Alerts` } + message: i18n.translate('xpack.monitoring.clusterAlerts.unsupportedClusterAlertsDescription', { + defaultMessage: 'Cluster [{clusterName}] license type [{licenseType}] does not support Cluster Alerts', + values: { + clusterName: cluster.cluster_name, + licenseType: `${license.type}` + } + }) + } }; } diff --git a/x-pack/plugins/monitoring/server/cluster_alerts/check_license.js b/x-pack/plugins/monitoring/server/cluster_alerts/check_license.js index 2280cbb313469..8bc15c8cc3e82 100644 --- a/x-pack/plugins/monitoring/server/cluster_alerts/check_license.js +++ b/x-pack/plugins/monitoring/server/cluster_alerts/check_license.js @@ -5,6 +5,7 @@ */ import { includes } from 'lodash'; +import { i18n } from '@kbn/i18n'; /** * Function to do the work of checking license for cluster alerts feature support @@ -24,27 +25,47 @@ export function checkLicense(type, active, clusterSource, watcher = true) { // Disabled because there is no license if (!type) { return Object.assign(licenseInfo, { - message: `Cluster Alerts are not displayed because the [${clusterSource}] cluster's license could not be determined.` + message: i18n.translate('xpack.monitoring.clusterAlerts.checkLicense.licenseNotDeterminedDescription', { + defaultMessage: `Cluster Alerts are not displayed because the [{clusterSource}] cluster's license could not be determined.`, + values: { + clusterSource + } + }) }); } // Disabled because the license type is not valid (basic) if (!includes([ 'trial', 'standard', 'gold', 'platinum' ], type)) { return Object.assign(licenseInfo, { - message: `Cluster Alerts are not displayed if Watcher is disabled or the [${clusterSource}] cluster's current license is basic.` + message: i18n.translate('xpack.monitoring.clusterAlerts.checkLicense.licenseIsBasicDescription', { + defaultMessage: + `Cluster Alerts are not displayed if Watcher is disabled or the [{clusterSource}] cluster's current license is basic.`, + values: { + clusterSource + } + }) }); } // Disabled because the license is inactive if (!active) { return Object.assign(licenseInfo, { - message: `Cluster Alerts are not displayed because the [${clusterSource}] cluster's current license [${type}] is not active.` + message: i18n.translate('xpack.monitoring.clusterAlerts.checkLicense.licenseNotActiveDescription', { + defaultMessage: `Cluster Alerts are not displayed because the [{clusterSource}] cluster's current license [{type}] is not active.`, + values: { + clusterSource, + type + } + }) }); } // Disabled because Watcher is not enabled (it may or may not be available) if (!watcher) { - return Object.assign(licenseInfo, { message: 'Cluster alerts is not enabled because Watcher is disabled.' }); + return Object.assign(licenseInfo, { + message: i18n.translate('xpack.monitoring.clusterAlerts.checkLicense.watcherIsDisabledDescription', { + defaultMessage: 'Cluster alerts is not enabled because Watcher is disabled.' }) + }); } return Object.assign(licenseInfo, { clusterAlerts: { enabled: true } }); diff --git a/x-pack/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js b/x-pack/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js index 79fec68181c3d..cfa0c685c5fe4 100644 --- a/x-pack/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js +++ b/x-pack/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js @@ -5,6 +5,7 @@ */ import { get } from 'lodash'; +import { i18n } from '@kbn/i18n'; /** * Determine if an API for Cluster Alerts should respond based on the license and configuration of the monitoring cluster. @@ -31,12 +32,14 @@ export function verifyMonitoringLicense(server) { return { enabled: false, - message: 'Status of Cluster Alerts feature could not be determined.' + message: i18n.translate('xpack.monitoring.clusterAlerts.notDeterminedLicenseDescription', { + defaultMessage: 'Status of Cluster Alerts feature could not be determined.' }) }; } return { enabled: false, - message: 'Cluster Alerts feature is disabled.' + message: i18n.translate('xpack.monitoring.clusterAlerts.disabledLicenseDescription', { + defaultMessage: 'Cluster Alerts feature is disabled.' }) }; } diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_stats.js b/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_stats.js index 1820a104d5578..4dac6c80ba39a 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_stats.js +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_stats.js @@ -6,6 +6,7 @@ import { badRequest, notFound } from 'boom'; import { getClustersStats } from './get_clusters_stats'; +import { i18n } from '@kbn/i18n'; /** * This will fetch the cluster stats and cluster state as a single object for the cluster specified by the {@code req}. @@ -17,14 +18,22 @@ import { getClustersStats } from './get_clusters_stats'; */ export function getClusterStats(req, esIndexPattern, clusterUuid) { if (!clusterUuid) { - throw badRequest('clusterUuid not specified'); + throw badRequest(i18n.translate('xpack.monitoring.clusterStats.uuidNotSpecifiedErrorMessage', { + defaultMessage: '{clusterUuid} not specified', + values: { clusterUuid: 'clusterUuid' } + })); } // passing clusterUuid so `get_clusters` will filter for single cluster return getClustersStats(req, esIndexPattern, clusterUuid) .then(clusters => { if (!clusters || clusters.length === 0) { - throw notFound(`Unable to find the cluster in the selected time range. UUID: ${clusterUuid}`); + throw notFound(i18n.translate('xpack.monitoring.clusterStats.uuidNotFoundErrorMessage', { + defaultMessage: 'Unable to find the cluster in the selected time range. UUID: {clusterUuid}', + values: { + clusterUuid + } + })); } return clusters[0]; diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js index 6e88e55811fd2..2f906f1dd7597 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js @@ -19,6 +19,7 @@ import { checkLicense as checkLicenseForAlerts } from '../../cluster_alerts/chec import { getClustersSummary } from './get_clusters_summary'; import { CLUSTER_ALERTS_SEARCH_SIZE } from '../../../common/constants'; import { getApmsForClusters } from '../apm/get_apms_for_clusters'; +import { i18n } from '@kbn/i18n'; /** * Get all clusters or the cluster associated with {@code clusterUuid} when it is defined. @@ -39,7 +40,12 @@ export async function getClustersFromRequest(req, indexPatterns, { clusterUuid, // TODO: this handling logic should be two different functions if (clusterUuid) { // if is defined, get specific cluster (no need for license checking) if (!clusters || clusters.length === 0) { - throw notFound(`Unable to find the cluster in the selected time range. UUID: ${clusterUuid}`); + throw notFound(i18n.translate('xpack.monitoring.requestedClusters.uuidNotFoundErrorMessage', { + defaultMessage: 'Unable to find the cluster in the selected time range. UUID: {clusterUuid}', + values: { + clusterUuid + } + })); } const cluster = clusters[0]; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.js b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.js index 5417a33053ebc..99192f849584e 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.js +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.js @@ -8,6 +8,7 @@ import { get } from 'lodash'; import { checkParam } from '../../error_missing_required'; import { createQuery } from '../../create_query'; import { ElasticsearchMetric } from '../../metrics'; +import { i18n } from '@kbn/i18n'; export function handleResponse(shardStats, indexUuid) { return response => { @@ -31,10 +32,13 @@ export function handleResponse(shardStats, indexUuid) { indexSummary = { unassignedShards, totalShards: get(_shardStats, 'primary', 0) + get(_shardStats, 'replica', 0) + unassignedShards, - status: _shardStats.status || 'Unknown', + status: _shardStats.status || i18n.translate('xpack.monitoring.es.indices.unknownStatusLabel', { + defaultMessage: 'Unknown' }) }; } else { - indexSummary = { status: 'Not Available', }; + indexSummary = { status: i18n.translate('xpack.monitoring.es.indices.notAvailableStatusLabel', { + defaultMessage: 'Not Available' }) + }; } return { diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js index 1c8618fdd7014..d09d625fed94a 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js @@ -10,6 +10,7 @@ import { ElasticsearchMetric } from '../../metrics'; import { createQuery } from '../../create_query'; import { calculateRate } from '../../calculate_rate'; import { getUnassignedShards } from '../shards'; +import { i18n } from '@kbn/i18n'; export function handleResponse(resp, min, max, shardStats) { // map the hits @@ -57,7 +58,8 @@ export function handleResponse(resp, min, max, shardStats) { statusSort = 3; } } else { - status = 'Deleted / Closed'; + status = i18n.translate('xpack.monitoring.es.indices.deletedClosedStatusLabel', { + defaultMessage: 'Deleted / Closed' }); statusSort = 0; } diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.js b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.js index cd58db5c8bb60..a470dbc1f4ad3 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.js +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.js @@ -11,6 +11,7 @@ import { ElasticsearchMetric } from '../../metrics'; import { getDefaultNodeFromId } from './get_default_node_from_id'; import { calculateNodeType } from './calculate_node_type'; import { getNodeTypeClassLabel } from './get_node_type_class_label'; +import { i18n } from '@kbn/i18n'; export function handleResponse(clusterState, shardStats, nodeUuid) { return response => { @@ -44,13 +45,16 @@ export function handleResponse(clusterState, shardStats, nodeUuid) { dataSize: get(sourceStats, 'indices.store.size_in_bytes'), freeSpace: get(sourceStats, 'fs.total.available_in_bytes'), usedHeap: get(sourceStats, 'jvm.mem.heap_used_percent'), - status: 'Online', + status: i18n.translate('xpack.monitoring.es.nodes.onlineStatusLabel', { + defaultMessage: 'Online' }), isOnline: true, }; } else { nodeSummary = { - nodeTypeLabel: 'Offline Node', - status: 'Offline', + nodeTypeLabel: i18n.translate('xpack.monitoring.es.nodes.offlineNodeStatusLabel', { + defaultMessage: 'Offline Node' }), + status: i18n.translate('xpack.monitoring.es.nodes.offlineStatusLabel', { + defaultMessage: 'Offline' }), isOnline: false, }; } diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/lookups.js b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/lookups.js index 821226818046f..f8d97acf792c3 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/lookups.js +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/lookups.js @@ -8,6 +8,9 @@ * Note: currently only `node` and `master` are supported due to * https://github.com/elastic/x-pack-kibana/issues/608 */ + +import { i18n } from '@kbn/i18n'; + export const nodeTypeClass = { invalid: 'fa-exclamation-triangle', node: 'fa-server', @@ -18,10 +21,16 @@ export const nodeTypeClass = { }; export const nodeTypeLabel = { - invalid: 'Invalid Node', - node: 'Node', - master: 'Master Node', - master_only: 'Master Only Node', - data: 'Data Only Node', - client: 'Client Node' + invalid: i18n.translate('xpack.monitoring.es.nodeType.invalidNodeLabel', { + defaultMessage: 'Invalid Node' }), + node: i18n.translate('xpack.monitoring.es.nodeType.nodeLabel', { + defaultMessage: 'Node' }), + master: i18n.translate('xpack.monitoring.es.nodeType.masterNodeLabel', { + defaultMessage: 'Master Node' }), + master_only: i18n.translate('xpack.monitoring.es.nodeType.masterOnlyNodeLabel', { + defaultMessage: 'Master Only Node' }), + data: i18n.translate('xpack.monitoring.es.nodeType.dataOnlyNodeLabel', { + defaultMessage: 'Data Only Node' }), + client: i18n.translate('xpack.monitoring.es.nodeType.clientNodeLabel', { + defaultMessage: 'Client Node' }) }; diff --git a/x-pack/plugins/monitoring/server/lib/errors/auth_errors.js b/x-pack/plugins/monitoring/server/lib/errors/auth_errors.js index 4060a335584d0..60b3a20ee0b1b 100644 --- a/x-pack/plugins/monitoring/server/lib/errors/auth_errors.js +++ b/x-pack/plugins/monitoring/server/lib/errors/auth_errors.js @@ -5,6 +5,7 @@ */ import { forbidden } from 'boom'; +import { i18n } from '@kbn/i18n'; const getStatusCode = err => { return err.isBoom ? err.output.statusCode : err.statusCode; @@ -26,9 +27,11 @@ export function handleAuthError(err) { * connection but not the monitoring connection */ if (statusCode === 401) { - message = 'Invalid authentication for monitoring cluster'; + message = i18n.translate('xpack.monitoring.errors.invalidAuthErrorMessage', { + defaultMessage: 'Invalid authentication for monitoring cluster' }); } else { - message = 'Insufficient user permissions for monitoring data'; + message = i18n.translate('xpack.monitoring.errors.insufficientUserErrorMessage', { + defaultMessage: 'Insufficient user permissions for monitoring data' }); } return forbidden(message); diff --git a/x-pack/plugins/monitoring/server/lib/errors/known_errors.js b/x-pack/plugins/monitoring/server/lib/errors/known_errors.js index 0f59a0af3f108..06d33cb4678ee 100644 --- a/x-pack/plugins/monitoring/server/lib/errors/known_errors.js +++ b/x-pack/plugins/monitoring/server/lib/errors/known_errors.js @@ -5,7 +5,7 @@ */ import { boomify } from 'boom'; - +import { i18n } from '@kbn/i18n'; /* * Check if the given error message is a known "safe" type of error * in which case we want to give the status as 503 and show the error message. @@ -17,9 +17,12 @@ import { boomify } from 'boom'; const KNOWN_ERROR_STATUS_CODE = 503; const mapTypeMessage = { - ConnectionFault: 'Check the Elasticsearch Monitoring cluster network connection and refer to the Kibana logs for more information.', - NoConnections: 'Check the Elasticsearch Monitoring cluster network connection and refer to the Kibana logs for more information.', - StatusCodeError: 'Check the Elasticsearch Monitoring cluster network connection or the load level of the nodes.' + ConnectionFault: i18n.translate('xpack.monitoring.errors.connectionFaultErrorMessage', { + defaultMessage: 'Check the Elasticsearch Monitoring cluster network connection and refer to the Kibana logs for more information.' }), + NoConnections: i18n.translate('xpack.monitoring.errors.noConnectionsErrorMessage', { + defaultMessage: 'Check the Elasticsearch Monitoring cluster network connection and refer to the Kibana logs for more information.' }), + StatusCodeError: i18n.translate('xpack.monitoring.errors.statusCodeErrorMessage', { + defaultMessage: 'Check the Elasticsearch Monitoring cluster network connection or the load level of the nodes.' }) }; export function isKnownError(err) { From ac9c3756628dc6455240fcfce424c9050ab79a66 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 21 Nov 2018 11:32:23 +0100 Subject: [PATCH 45/95] [ML] Fix cleanup of mlAnomaliesTableService listeners in Time Series Viewer. (#25967) - A missing call to componentWillUnmount() in the Single Series Viewer didn't properly clean up the listeners for mlAnomaliesTableService so when switching to the Anomaly Explorer the page would crash if the user hovered the Anomaly Table. - This fixes it by calling ReactDOM.unmountComponentAtNode(element[0]); in element.on('$destroy', () => { ... }) to trigger the cleanup. - Additionally, as a safety measure, mlChartTooltipService.show() now silently fails if target is undefined. --- .../chart_tooltip/__tests__/chart_tooltip.js | 6 ++ .../chart_tooltip/chart_tooltip_service.js | 2 +- .../__tests__/timeseries_chart_directive.js | 62 +++++++++++++++++++ .../timeseries_chart_directive.js | 3 + 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugins/ml/public/timeseriesexplorer/__tests__/timeseries_chart_directive.js diff --git a/x-pack/plugins/ml/public/components/chart_tooltip/__tests__/chart_tooltip.js b/x-pack/plugins/ml/public/components/chart_tooltip/__tests__/chart_tooltip.js index 9477984f758c0..817e5894211bb 100644 --- a/x-pack/plugins/ml/public/components/chart_tooltip/__tests__/chart_tooltip.js +++ b/x-pack/plugins/ml/public/components/chart_tooltip/__tests__/chart_tooltip.js @@ -15,4 +15,10 @@ describe('ML - mlChartTooltipService', () => { expect(mlChartTooltipService.hide).to.be.a('function'); }); + it('should fail silently when target is not defined', () => { + mlChartTooltipService.element = {}; + expect(() => { + mlChartTooltipService.show('', undefined); + }).to.not.throwError('Call to show() should fail silently.'); + }); }); diff --git a/x-pack/plugins/ml/public/components/chart_tooltip/chart_tooltip_service.js b/x-pack/plugins/ml/public/components/chart_tooltip/chart_tooltip_service.js index a548e9a9ec798..53a0a1b7adc7a 100644 --- a/x-pack/plugins/ml/public/components/chart_tooltip/chart_tooltip_service.js +++ b/x-pack/plugins/ml/public/components/chart_tooltip/chart_tooltip_service.js @@ -18,7 +18,7 @@ export const mlChartTooltipService = { }; mlChartTooltipService.show = function (contents, target, offset = { x: 0, y: 0 }) { - if (this.element === null) { + if (this.element === null || typeof target === 'undefined') { return; } diff --git a/x-pack/plugins/ml/public/timeseriesexplorer/__tests__/timeseries_chart_directive.js b/x-pack/plugins/ml/public/timeseriesexplorer/__tests__/timeseries_chart_directive.js new file mode 100644 index 0000000000000..aeb224a89bb23 --- /dev/null +++ b/x-pack/plugins/ml/public/timeseriesexplorer/__tests__/timeseries_chart_directive.js @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; +import sinon from 'sinon'; + +import { TimeseriesChart } from '../timeseries_chart'; + +describe('ML - ', () => { + let $scope; + let $compile; + let $element; + + beforeEach(ngMock.module('kibana')); + beforeEach(() => { + ngMock.inject(function ($injector) { + $compile = $injector.get('$compile'); + const $rootScope = $injector.get('$rootScope'); + $scope = $rootScope.$new(); + }); + }); + + afterEach(() => { + $scope.$destroy(); + }); + + it('Plain initialization doesn\'t throw an error', () => { + // this creates a dummy DOM element with class 'ml-timeseries-chart' as a direct child of + // the tag so the directive can find it in the DOM to create the resizeChecker. + const mockClassedElement = document.createElement('div'); + mockClassedElement.classList.add('ml-timeseries-chart'); + document.getElementsByTagName('body')[0].append(mockClassedElement); + + // spy the TimeseriesChart component's unmount method to be able to test if it was called + const componentWillUnmountSpy = sinon.spy(TimeseriesChart.prototype, 'componentWillUnmount'); + + $element = $compile('')($scope); + const scope = $element.isolateScope(); + + // sanity test to check if directive picked up the attribute for its scope + expect(scope.showForecast).to.equal(true); + + // componentWillUnmount() should not have been called so far + expect(componentWillUnmountSpy.callCount).to.equal(0); + + // remove $element to trigger $destroy() callback + $element.remove(); + + // componentWillUnmount() should now have been called once + expect(componentWillUnmountSpy.callCount).to.equal(1); + + componentWillUnmountSpy.restore(); + + // clean up the dummy DOM element + mockClassedElement.parentNode.removeChild(mockClassedElement); + }); + +}); diff --git a/x-pack/plugins/ml/public/timeseriesexplorer/timeseries_chart_directive.js b/x-pack/plugins/ml/public/timeseriesexplorer/timeseries_chart_directive.js index 45c5437fc9ee7..3bd9c1d107e7b 100644 --- a/x-pack/plugins/ml/public/timeseriesexplorer/timeseries_chart_directive.js +++ b/x-pack/plugins/ml/public/timeseriesexplorer/timeseries_chart_directive.js @@ -90,6 +90,9 @@ module.directive('mlTimeseriesChart', function () { element.on('$destroy', () => { resizeChecker.destroy(); + // unmountComponentAtNode() needs to be called so mlAnomaliesTableService listeners within + // the TimeseriesChart component get unwatched properly. + ReactDOM.unmountComponentAtNode(element[0]); scope.$destroy(); }); From a3602f62bdbee295e074727c4e0d8dcf210fe86f Mon Sep 17 00:00:00 2001 From: Maryia Lapata Date: Wed, 21 Nov 2018 14:55:07 +0300 Subject: [PATCH 46/95] [i18n] Translations for Monitoring: Beats (#24976) * Beats translations * Fix unit tests * Remove colon from translated label --- .../public/components/beats/beat/beat.js | 83 +++++++++++++++---- .../__snapshots__/overview.test.js.snap | 23 +++-- .../beats/overview/latest_active.js | 20 +++-- .../beats/overview/latest_active.test.js | 6 +- .../components/beats/overview/overview.js | 44 ++++++++-- .../beats/overview/overview.test.js | 10 +-- .../public/components/beats/stats.js | 19 ++++- .../public/directives/beats/beat/index.js | 13 +-- .../public/directives/beats/listing/index.js | 51 +++++++++--- .../public/directives/beats/overview/index.js | 11 ++- .../public/views/beats/beat/index.js | 9 +- .../public/views/beats/listing/index.js | 4 +- .../public/views/beats/overview/index.js | 4 +- 13 files changed, 225 insertions(+), 72 deletions(-) diff --git a/x-pack/plugins/monitoring/public/components/beats/beat/beat.js b/x-pack/plugins/monitoring/public/components/beats/beat/beat.js index 857f2a259a5e9..b3c7aaa290fac 100644 --- a/x-pack/plugins/monitoring/public/components/beats/beat/beat.js +++ b/x-pack/plugins/monitoring/public/components/beats/beat/beat.js @@ -8,8 +8,9 @@ import React from 'react'; import { MonitoringTimeseriesContainer } from '../../chart'; import { formatMetric } from '../../../lib/format_number'; import { EuiFlexItem, EuiFlexGroup, EuiPage, EuiPageBody, EuiFlexGrid, EuiSpacer } from '@elastic/eui'; +import { injectI18n } from '@kbn/i18n/react'; -export function Beat({ summary, metrics, ...props }) { +function BeatUi({ summary, metrics, intl, ...props }) { const metricsToShow = [ metrics.beat_event_rates, @@ -40,22 +41,74 @@ export function Beat({ summary, metrics, ...props }) { ); const summarytStatsTop = [ - { label: 'Name', value: summary.name, dataTestSubj: 'name' }, - { label: 'Host', value: summary.transportAddress, dataTestSubj: 'host' }, - { label: 'Version', value: summary.version, dataTestSubj: 'version' }, - { label: 'Type', value: summary.type, dataTestSubj: 'type' }, - { label: 'Output', value: summary.output, dataTestSubj: 'output' }, - { label: 'Config reloads', value: formatMetric(summary.configReloads, 'int_commas'), dataTestSubj: 'configReloads' }, - { label: 'Uptime', value: formatMetric(summary.uptime, 'time_since'), dataTestSubj: 'uptime' }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.nameLabel', defaultMessage: 'Name' }), + value: summary.name, + dataTestSubj: 'name' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.hostLabel', defaultMessage: 'Host' }), + value: summary.transportAddress, + dataTestSubj: 'host' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.versionLabel', defaultMessage: 'Version' }), + value: summary.version, + dataTestSubj: 'version' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.typeLabel', defaultMessage: 'Type' }), + value: summary.type, + dataTestSubj: 'type' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.outputLabel', defaultMessage: 'Output' }), + value: summary.output, + dataTestSubj: 'output' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.configReloadsLabel', defaultMessage: 'Config reloads' }), + value: formatMetric(summary.configReloads, 'int_commas'), + dataTestSubj: 'configReloads' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.uptimeLabel', defaultMessage: 'Uptime' }), + value: formatMetric(summary.uptime, 'time_since'), + dataTestSubj: 'uptime' + }, ]; const summarytStatsBot = [ - { label: 'Events total', value: formatMetric(summary.eventsTotal, 'int_commas'), dataTestSubj: 'eventsTotal' }, - { label: 'Events emitted', value: formatMetric(summary.eventsEmitted, 'int_commas'), dataTestSubj: 'eventsEmitted' }, - { label: 'Events dropped', value: formatMetric(summary.eventsDropped, 'int_commas'), dataTestSubj: 'eventsDropped' }, - { label: 'Bytes sent', value: formatMetric(summary.bytesWritten, 'byte'), dataTestSubj: 'bytesWritten' }, - { label: 'Handles limit (soft)', value: formatMetric(summary.handlesSoftLimit, 'byte'), dataTestSubj: 'handlesLimitSoft' }, - { label: 'Handles limit (hard)', value: formatMetric(summary.handlesHardLimit, 'byte'), dataTestSubj: 'handlesLimitHard' }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.eventsTotalLabel', defaultMessage: 'Events total' }), + value: formatMetric(summary.eventsTotal, 'int_commas'), + dataTestSubj: 'eventsTotal' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.eventsEmittedLabel', defaultMessage: 'Events emitted' }), + value: formatMetric(summary.eventsEmitted, 'int_commas'), + dataTestSubj: 'eventsEmitted' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.eventsDroppedLabel', defaultMessage: 'Events dropped' }), + value: formatMetric(summary.eventsDropped, 'int_commas'), + dataTestSubj: 'eventsDropped' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.bytesSentLabel', defaultMessage: 'Bytes sent' }), + value: formatMetric(summary.bytesWritten, 'byte'), + dataTestSubj: 'bytesWritten' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.handlesLimitSoftLabel', defaultMessage: 'Handles limit (soft)' }), + value: formatMetric(summary.handlesSoftLimit, 'byte'), + dataTestSubj: 'handlesLimitSoft' + }, + { + label: intl.formatMessage({ id: 'xpack.monitoring.beats.instance.handlesLimitHardLabel', defaultMessage: 'Handles limit (hard)' }), + value: formatMetric(summary.handlesHardLimit, 'byte'), + dataTestSubj: 'handlesLimitHard' + }, ]; return ( @@ -102,3 +155,5 @@ export function Beat({ summary, metrics, ...props }) {
); } + +export const Beat = injectI18n(BeatUi); diff --git a/x-pack/plugins/monitoring/public/components/beats/overview/__snapshots__/overview.test.js.snap b/x-pack/plugins/monitoring/public/components/beats/overview/__snapshots__/overview.test.js.snap index 124802f0ef8a4..924fcebd5c823 100644 --- a/x-pack/plugins/monitoring/public/components/beats/overview/__snapshots__/overview.test.js.snap +++ b/x-pack/plugins/monitoring/public/components/beats/overview/__snapshots__/overview.test.js.snap @@ -35,13 +35,17 @@ exports[`Overview that overview page renders normally 1`] = ` textTransform="none" >

- Active Beats in Last Day +

-

- Top 5 Beat Types in Last Day +

- Top 5 Versions in Last Day +

({ @@ -42,9 +46,11 @@ export function LatestActive({ latestActive }) { ); } -LatestActive.propTypes = { +LatestActiveUi.propTypes = { latestActive: PropTypes.arrayOf(PropTypes.shape({ range: PropTypes.string.isRequired, count: PropTypes.number.isRequired, })).isRequired }; + +export const LatestActive = injectI18n(LatestActiveUi); diff --git a/x-pack/plugins/monitoring/public/components/beats/overview/latest_active.test.js b/x-pack/plugins/monitoring/public/components/beats/overview/latest_active.test.js index 2afbe2bebb448..233f933202222 100644 --- a/x-pack/plugins/monitoring/public/components/beats/overview/latest_active.test.js +++ b/x-pack/plugins/monitoring/public/components/beats/overview/latest_active.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from '../../../../../../test_utils/enzyme_helpers'; import { LatestActive } from './latest_active'; @@ -19,8 +19,8 @@ describe('Latest Active', () => { { range: 'last1d', count: 10 }, ]; - const component = shallow( - ); diff --git a/x-pack/plugins/monitoring/public/components/beats/overview/overview.js b/x-pack/plugins/monitoring/public/components/beats/overview/overview.js index 7b86dcaaeb1a0..2fa946e1def35 100644 --- a/x-pack/plugins/monitoring/public/components/beats/overview/overview.js +++ b/x-pack/plugins/monitoring/public/components/beats/overview/overview.js @@ -10,6 +10,7 @@ import { LatestVersions } from './latest_versions'; import { LatestTypes } from './latest_types'; import { Stats } from '../'; import { MonitoringTimeseriesContainer } from '../../chart'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; import { EuiCallOut, EuiTitle, @@ -21,27 +22,48 @@ import { EuiPanel } from '@elastic/eui'; -function renderLatestActive(latestActive, latestTypes, latestVersions) { +function renderLatestActive(latestActive, latestTypes, latestVersions, intl) { if (latestTypes && latestTypes.length > 0) { return ( -

Active Beats in Last Day

+ +

+ +

+
-

Top 5 Beat Types in Last Day

+ +

+ +

+
-

Top 5 Versions in Last Day

+ +

+ +

+
@@ -50,8 +72,11 @@ function renderLatestActive(latestActive, latestTypes, latestVersions) { ); } - const calloutMsg = `Hi there! This area is where your latest Beats activity would show -up, but you don't seem to have any activity within the last day.`; + const calloutMsg = intl.formatMessage({ + id: 'xpack.monitoring.beats.overview.noActivityDescription', + // eslint-disable-next-line max-len + defaultMessage: `Hi there! This area is where your latest Beats activity would show up, but you don't seem to have any activity within the last day.` + }); return ( - {renderLatestActive(latestActive, latestTypes, latestVersions)} + {renderLatestActive(latestActive, latestTypes, latestVersions, intl)} @@ -102,3 +128,5 @@ export function BeatsOverview({ ); } + +export const BeatsOverview = injectI18n(BeatsOverviewUi); diff --git a/x-pack/plugins/monitoring/public/components/beats/overview/overview.test.js b/x-pack/plugins/monitoring/public/components/beats/overview/overview.test.js index 3e849f9da63d1..6cf814ea90d42 100644 --- a/x-pack/plugins/monitoring/public/components/beats/overview/overview.test.js +++ b/x-pack/plugins/monitoring/public/components/beats/overview/overview.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from '../../../../../../test_utils/enzyme_helpers'; jest.mock('../stats', () => ({ Stats: () => 'Stats', @@ -41,8 +41,8 @@ describe('Overview', () => { beat_output_errors: 1 }; - const component = shallow( - { beat_output_errors: 1 }; - const component = shallow( - diff --git a/x-pack/plugins/monitoring/public/components/beats/stats.js b/x-pack/plugins/monitoring/public/components/beats/stats.js index a0fd2c3f2fc02..f5fceb04eccda 100644 --- a/x-pack/plugins/monitoring/public/components/beats/stats.js +++ b/x-pack/plugins/monitoring/public/components/beats/stats.js @@ -8,6 +8,7 @@ import { get } from 'lodash'; import React from 'react'; import { formatMetric } from 'plugins/monitoring/lib/format_number'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; export function Stats({ stats }) { const types = stats.types.map(({ type, count }, index) => { @@ -35,7 +36,11 @@ export function Stats({ stats }) { - Total Beats:  + + :  @@ -46,7 +51,11 @@ export function Stats({ stats }) { {types} - Total Events:  + + :  @@ -56,7 +65,11 @@ export function Stats({ stats }) { - Bytes Sent:  + + :  diff --git a/x-pack/plugins/monitoring/public/directives/beats/beat/index.js b/x-pack/plugins/monitoring/public/directives/beats/beat/index.js index 94c84e0eea14b..e7f0fc291c68a 100644 --- a/x-pack/plugins/monitoring/public/directives/beats/beat/index.js +++ b/x-pack/plugins/monitoring/public/directives/beats/beat/index.js @@ -10,6 +10,7 @@ import { render } from 'react-dom'; import { uiModules } from 'ui/modules'; import { Beat } from 'plugins/monitoring/components/beats/beat'; import { timefilter } from 'ui/timefilter'; +import { I18nProvider } from '@kbn/i18n/react'; const uiModule = uiModules.get('monitoring/directives', []); uiModule.directive('monitoringBeatsBeat', () => { @@ -30,11 +31,13 @@ uiModule.directive('monitoringBeatsBeat', () => { scope.$watch('data', (data = {}) => { render(( - + + + ), $el[0]); }); diff --git a/x-pack/plugins/monitoring/public/directives/beats/listing/index.js b/x-pack/plugins/monitoring/public/directives/beats/listing/index.js index f3a49d417e5df..779dffaf2309a 100644 --- a/x-pack/plugins/monitoring/public/directives/beats/listing/index.js +++ b/x-pack/plugins/monitoring/public/directives/beats/listing/index.js @@ -9,6 +9,8 @@ import { render } from 'react-dom'; import { uiModules } from 'ui/modules'; import { Stats } from 'plugins/monitoring/components/beats'; import { formatMetric } from 'plugins/monitoring/lib/format_number'; +import { I18nProvider } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; import { SORT_ASCENDING, SORT_DESCENDING, @@ -23,18 +25,43 @@ import { MonitoringTable } from 'plugins/monitoring/components/table'; import { EuiLink, } from '@elastic/eui'; -import { I18nProvider } from '@kbn/i18n/react'; const filterFields = [ 'name', 'type', 'version', 'output' ]; const columns = [ - { title: 'Name', sortKey: 'name', sortOrder: SORT_ASCENDING }, - { title: 'Type', sortKey: 'type' }, - { title: 'Output Enabled', sortKey: 'output' }, - { title: 'Total Events Rate', sortKey: 'total_events_rate', secondarySortOrder: SORT_DESCENDING }, - { title: 'Bytes Sent Rate', sortKey: 'bytes_sent_rate' }, - { title: 'Output Errors', sortKey: 'errors' }, - { title: 'Allocated Memory', sortKey: 'memory' }, - { title: 'Version', sortKey: 'version' }, + { + title: i18n.translate('xpack.monitoring.beats.instances.nameTitle', { defaultMessage: 'Name' }), + sortKey: 'name', + sortOrder: SORT_ASCENDING + }, + { + title: i18n.translate('xpack.monitoring.beats.instances.typeTitle', { defaultMessage: 'Type' }), + sortKey: 'type' + }, + { + title: i18n.translate('xpack.monitoring.beats.instances.outputEnabledTitle', { defaultMessage: 'Output Enabled' }), + sortKey: 'output' + }, + { + title: i18n.translate('xpack.monitoring.beats.instances.totalEventsRateTitle', { defaultMessage: 'Total Events Rate' }), + sortKey: 'total_events_rate', + secondarySortOrder: SORT_DESCENDING + }, + { + title: i18n.translate('xpack.monitoring.beats.instances.bytesSentRateTitle', { defaultMessage: 'Bytes Sent Rate' }), + sortKey: 'bytes_sent_rate' + }, + { + title: i18n.translate('xpack.monitoring.beats.instances.outputErrorsTitle', { defaultMessage: 'Output Errors' }), + sortKey: 'errors' + }, + { + title: i18n.translate('xpack.monitoring.beats.instances.allocatedMemoryTitle', { defaultMessage: 'Allocated Memory' }), + sortKey: 'memory' + }, + { + title: i18n.translate('xpack.monitoring.beats.instances.versionTitle', { defaultMessage: 'Version' }), + sortKey: 'version' + }, ]; const beatRowFactory = (scope, kbnUrl) => { return props => { @@ -94,7 +121,7 @@ const beatRowFactory = (scope, kbnUrl) => { }; const uiModule = uiModules.get('monitoring/directives', []); -uiModule.directive('monitoringBeatsListing', (kbnUrl) => { +uiModule.directive('monitoringBeatsListing', (kbnUrl, i18n) => { return { restrict: 'E', scope: { @@ -108,6 +135,8 @@ uiModule.directive('monitoringBeatsListing', (kbnUrl) => { link(scope, $el) { scope.$watch('data', (data = {}) => { + const filterBeatsPlaceholder = i18n('xpack.monitoring.beats.filterBeatsPlaceholder', { defaultMessage: 'Filter Beats…' }); + render((
@@ -121,7 +150,7 @@ uiModule.directive('monitoringBeatsListing', (kbnUrl) => { sortKey={scope.sortKey} sortOrder={scope.sortOrder} onNewState={scope.onNewState} - placeholder="Filter Beats..." + placeholder={filterBeatsPlaceholder} filterFields={filterFields} columns={columns} rowComponent={beatRowFactory(scope, kbnUrl)} diff --git a/x-pack/plugins/monitoring/public/directives/beats/overview/index.js b/x-pack/plugins/monitoring/public/directives/beats/overview/index.js index 2f981ee50cd2d..e99433c741d43 100644 --- a/x-pack/plugins/monitoring/public/directives/beats/overview/index.js +++ b/x-pack/plugins/monitoring/public/directives/beats/overview/index.js @@ -10,6 +10,7 @@ import { render } from 'react-dom'; import { uiModules } from 'ui/modules'; import { BeatsOverview } from 'plugins/monitoring/components/beats/overview'; import { timefilter } from 'ui/timefilter'; +import { I18nProvider } from '@kbn/i18n/react'; const uiModule = uiModules.get('monitoring/directives', []); uiModule.directive('monitoringBeatsOverview', () => { @@ -30,10 +31,12 @@ uiModule.directive('monitoringBeatsOverview', () => { scope.$watch('data', (data = {}) => { render(( - + + + ), $el[0]); }); diff --git a/x-pack/plugins/monitoring/public/views/beats/beat/index.js b/x-pack/plugins/monitoring/public/views/beats/beat/index.js index c9aa37428793b..be764ad7e7f9b 100644 --- a/x-pack/plugins/monitoring/public/views/beats/beat/index.js +++ b/x-pack/plugins/monitoring/public/views/beats/beat/index.js @@ -22,7 +22,7 @@ uiRoutes.when('/beats/beat/:beatUuid', { }, controllerAs: 'beat', controller: class BeatDetail extends MonitoringViewBaseController { - constructor($injector, $scope) { + constructor($injector, $scope, i18n) { // breadcrumbs + page title const $route = $injector.get('$route'); const globalState = $injector.get('globalState'); @@ -30,7 +30,12 @@ uiRoutes.when('/beats/beat/:beatUuid', { const pageData = $route.current.locals.pageData; super({ - title: `Beats - ${pageData.summary.name} - Overview`, + title: i18n('xpack.monitoring.beats.instance.routeTitle', { + defaultMessage: 'Beats - {instanceName} - Overview', + values: { + instanceName: pageData.summary.name + } + }), getPageData, $scope, $injector diff --git a/x-pack/plugins/monitoring/public/views/beats/listing/index.js b/x-pack/plugins/monitoring/public/views/beats/listing/index.js index d86ff5e04050d..ae9947ba620b8 100644 --- a/x-pack/plugins/monitoring/public/views/beats/listing/index.js +++ b/x-pack/plugins/monitoring/public/views/beats/listing/index.js @@ -22,14 +22,14 @@ uiRoutes.when('/beats/beats', { }, controllerAs: 'beats', controller: class BeatsListing extends MonitoringViewBaseTableController { - constructor($injector, $scope) { + constructor($injector, $scope, i18n) { // breadcrumbs + page title const $route = $injector.get('$route'); const globalState = $injector.get('globalState'); $scope.cluster = find($route.current.locals.clusters, { cluster_uuid: globalState.cluster_uuid }); super({ - title: 'Beats', + title: i18n('xpack.monitoring.beats.routeTitle', { defaultMessage: 'Beats' }), storageKey: 'beats.beats', getPageData, $scope, diff --git a/x-pack/plugins/monitoring/public/views/beats/overview/index.js b/x-pack/plugins/monitoring/public/views/beats/overview/index.js index ee7700fc7fe1d..7d06e32469e06 100644 --- a/x-pack/plugins/monitoring/public/views/beats/overview/index.js +++ b/x-pack/plugins/monitoring/public/views/beats/overview/index.js @@ -22,14 +22,14 @@ uiRoutes.when('/beats', { }, controllerAs: 'beats', controller: class BeatsOverview extends MonitoringViewBaseController { - constructor($injector, $scope) { + constructor($injector, $scope, i18n) { // breadcrumbs + page title const $route = $injector.get('$route'); const globalState = $injector.get('globalState'); $scope.cluster = find($route.current.locals.clusters, { cluster_uuid: globalState.cluster_uuid }); super({ - title: 'Beats - Overview', + title: i18n('xpack.monitoring.beats.overview.routeTitle', { defaultMessage: 'Beats - Overview' }), getPageData, $scope, $injector From 7e57c107ab80027f9be1ddd0ca2c6c0cea4d0cde Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 21 Nov 2018 05:45:05 -0800 Subject: [PATCH 47/95] [pageObjects/visualize] use retry to avoid stale element references (#25973) Fixes https://github.com/elastic/kibana/issues/25892 This should address the flakiness observed in this issue by retrying if there is a stale element in the complex `PageObjects.visualize.filterOnTableCell()` method, and using `testSubjects.getVisibleText()` rather than calling `getVisibleText()` directly on the element without retrying. --- .../functional/page_objects/visualize_page.js | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/test/functional/page_objects/visualize_page.js b/test/functional/page_objects/visualize_page.js index 70ee0ee9960b9..2c082dfe4a28e 100644 --- a/test/functional/page_objects/visualize_page.js +++ b/test/functional/page_objects/visualize_page.js @@ -942,8 +942,7 @@ export function VisualizePageProvider({ getService, getPageObjects }) { * If you are writing new tests, you should rather look into getTableVisContent method instead. */ async getTableVisData() { - const dataTable = await testSubjects.find('paginated-table-body'); - return await dataTable.getVisibleText(); + return await testSubjects.getVisibleText('paginated-table-body'); } /** @@ -952,29 +951,31 @@ export function VisualizePageProvider({ getService, getPageObjects }) { * cell values into arrays. Please use this function for newer tests. */ async getTableVisContent({ stripEmptyRows = true } = { }) { - const container = await testSubjects.find('tableVis'); - const allTables = await testSubjects.findAllDescendant('paginated-table-body', container); - - if (allTables.length === 0) { - return []; - } + return await retry.try(async () => { + const container = await testSubjects.find('tableVis'); + const allTables = await testSubjects.findAllDescendant('paginated-table-body', container); - const allData = await Promise.all(allTables.map(async (t) => { - let data = await table.getDataFromElement(t); - if (stripEmptyRows) { - data = data.filter(row => row.length > 0 && row.some(cell => cell.trim().length > 0)); + if (allTables.length === 0) { + return []; } - return data; - })); - if (allTables.length === 1) { + const allData = await Promise.all(allTables.map(async (t) => { + let data = await table.getDataFromElement(t); + if (stripEmptyRows) { + data = data.filter(row => row.length > 0 && row.some(cell => cell.trim().length > 0)); + } + return data; + })); + + if (allTables.length === 1) { // If there was only one table we return only the data for that table // This prevents an unnecessary array around that single table, which // is the case we have in most tests. - return allData[0]; - } + return allData[0]; + } - return allData; + return allData; + }); } async getInspectorTableData() { @@ -1144,11 +1145,13 @@ export function VisualizePageProvider({ getService, getPageObjects }) { } async filterOnTableCell(column, row) { - const table = await testSubjects.find('tableVis'); - const cell = await table.findByCssSelector(`tbody tr:nth-child(${row}) td:nth-child(${column})`); - await remote.moveMouseTo(cell); - const filterBtn = await testSubjects.findDescendant('filterForCellValue', cell); - await filterBtn.click(); + await retry.try(async () => { + const table = await testSubjects.find('tableVis'); + const cell = await table.findByCssSelector(`tbody tr:nth-child(${row}) td:nth-child(${column})`); + await remote.moveMouseTo(cell); + const filterBtn = await testSubjects.findDescendant('filterForCellValue', cell); + await filterBtn.click(); + }); } async toggleLegend(show = true) { From 42feaaa5af689be720dc7855146f97940925afbc Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Wed, 21 Nov 2018 15:21:13 +0100 Subject: [PATCH 48/95] removing indexPattern from vega/tsvb/timelion request handler (#26007) --- .../metrics/public/kbn_vis_types/request_handler.js | 4 ++-- .../timelion/public/vis/timelion_request_handler.js | 4 ++-- src/core_plugins/vega/public/vega_request_handler.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core_plugins/metrics/public/kbn_vis_types/request_handler.js b/src/core_plugins/metrics/public/kbn_vis_types/request_handler.js index 51bce4c094fbe..67a0f34ee72d7 100644 --- a/src/core_plugins/metrics/public/kbn_vis_types/request_handler.js +++ b/src/core_plugins/metrics/public/kbn_vis_types/request_handler.js @@ -28,7 +28,7 @@ const MetricsRequestHandlerProvider = function (Private, Notifier, config, $http return { name: 'metrics', - handler: function ({ aggs, uiState, timeRange, filters, query, visParams }) { + handler: function ({ uiState, timeRange, filters, query, visParams }) { const timezone = Private(timezoneProvider)(); return new Promise((resolve) => { const panel = visParams; @@ -39,7 +39,7 @@ const MetricsRequestHandlerProvider = function (Private, Notifier, config, $http if (panel && panel.id) { const params = { timerange: { timezone, ...parsedTimeRange }, - filters: [buildEsQuery(aggs.indexPattern, [query], filters)], + filters: [buildEsQuery(undefined, [query], filters)], panels: [panel], state: uiStateObj }; diff --git a/src/core_plugins/timelion/public/vis/timelion_request_handler.js b/src/core_plugins/timelion/public/vis/timelion_request_handler.js index a2aa4b8f5582b..2cd30d7ed1bdc 100644 --- a/src/core_plugins/timelion/public/vis/timelion_request_handler.js +++ b/src/core_plugins/timelion/public/vis/timelion_request_handler.js @@ -31,7 +31,7 @@ const TimelionRequestHandlerProvider = function (Private, Notifier, $http) { return { name: 'timelion', - handler: function ({ aggs, timeRange, filters, query, visParams }) { + handler: function ({ timeRange, filters, query, visParams }) { return new Promise((resolve, reject) => { const expression = visParams.expression; @@ -41,7 +41,7 @@ const TimelionRequestHandlerProvider = function (Private, Notifier, $http) { sheet: [expression], extended: { es: { - filter: buildEsQuery(aggs.indexPattern, [query], filters) + filter: buildEsQuery(undefined, [query], filters) } }, time: _.extend(timeRange, { diff --git a/src/core_plugins/vega/public/vega_request_handler.js b/src/core_plugins/vega/public/vega_request_handler.js index 3fba8216c7236..d394ac0a6b22d 100644 --- a/src/core_plugins/vega/public/vega_request_handler.js +++ b/src/core_plugins/vega/public/vega_request_handler.js @@ -33,9 +33,9 @@ export function VegaRequestHandlerProvider(Private, es, serviceSettings) { name: 'vega', - handler({ aggs, timeRange, filters, query, visParams }) { + handler({ timeRange, filters, query, visParams }) { timeCache.setTimeRange(timeRange); - const filtersDsl = buildEsQuery(aggs.indexPattern, [query], filters); + const filtersDsl = buildEsQuery(undefined, [query], filters); const vp = new VegaParser(visParams.spec, searchCache, timeCache, filtersDsl, serviceSettings); return vp.parseAsync(); } From 1b3d6ae0b35d6db231c497c014a97edc1dc4dc2e Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Wed, 21 Nov 2018 15:53:47 +0000 Subject: [PATCH 49/95] [ML] Ensures jobs from saved searches are cloned in advanced wizard (#26002) * [ML] Ensures jobs from saved searches are cloned in advanced wizard * [ML] Use useSavedSearch property for setting job created_by --- .../multi_metric/create_job/create_job_controller.js | 1 + .../multi_metric/create_job/create_job_service.js | 10 +++++++--- .../population/create_job/create_job_controller.js | 2 +- .../simple/population/create_job/create_job_service.js | 10 +++++++--- .../single_metric/create_job/create_job_controller.js | 1 + .../single_metric/create_job/create_job_service.js | 10 +++++++--- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_controller.js index aaa412d3ea77e..8c93eee273eae 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_controller.js @@ -199,6 +199,7 @@ module query, filters, combinedQuery, + usesSavedSearch: (savedSearch.id !== undefined), jobId: '', description: '', jobGroups: [], diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_service.js b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_service.js index b6b96e6c5510a..66db8d98461c7 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_service.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_service.js @@ -243,9 +243,13 @@ export function MultiMetricJobServiceProvider() { job.results_index_name = job.job_id; } - job.custom_settings = { - created_by: WIZARD_TYPE.MULTI_METRIC - }; + if (formConfig.usesSavedSearch === false) { + // Jobs created from saved searches cannot be cloned in the wizard as the + // ML job config holds no reference to the saved search ID. + job.custom_settings = { + created_by: WIZARD_TYPE.MULTI_METRIC + }; + } return job; } diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_controller.js index a26564d264f0f..f72602946a288 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_controller.js @@ -197,13 +197,13 @@ module end: 0, overField: undefined, timeField: indexPattern.timeFieldName, - // splitField: undefined, influencerFields: [], firstSplitFieldName: undefined, indexPattern: indexPattern, query, filters, combinedQuery, + usesSavedSearch: (savedSearch.id !== undefined), jobId: '', description: '', jobGroups: [], diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_service.js b/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_service.js index 21dd734736434..4fa742533bc72 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_service.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_service.js @@ -276,9 +276,13 @@ export function PopulationJobServiceProvider(Private) { job.results_index_name = job.job_id; } - job.custom_settings = { - created_by: WIZARD_TYPE.POPULATION - }; + if (formConfig.usesSavedSearch === false) { + // Jobs created from saved searches cannot be cloned in the wizard as the + // ML job config holds no reference to the saved search ID. + job.custom_settings = { + created_by: WIZARD_TYPE.POPULATION + }; + } return job; } diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_controller.js index 3fb48c0535330..b6cfed211f01e 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_controller.js @@ -199,6 +199,7 @@ module end: 0, timeField: indexPattern.timeFieldName, indexPattern: undefined, + usesSavedSearch: (savedSearch.id !== undefined), query, filters, combinedQuery, diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_service.js b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_service.js index e8b251c591670..8accd028ffd52 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_service.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_service.js @@ -174,9 +174,13 @@ export function SingleMetricJobServiceProvider() { job.results_index_name = job.job_id; } - job.custom_settings = { - created_by: WIZARD_TYPE.SINGLE_METRIC - }; + if (formConfig.usesSavedSearch === false) { + // Jobs created from saved searches cannot be cloned in the wizard as the + // ML job config holds no reference to the saved search ID. + job.custom_settings = { + created_by: WIZARD_TYPE.SINGLE_METRIC + }; + } // Use the original es agg type rather than the ML version // e.g. count rather than high_count From 453e1f1a2d8041e4cfd6e840f742e10d248df8ed Mon Sep 17 00:00:00 2001 From: Jason Rhodes Date: Wed, 21 Nov 2018 11:06:03 -0500 Subject: [PATCH 50/95] Changes APM home page to use route-based tabs (#25891) * Changed home page to use route based history tabs, abstracted history tabs to component with tests * Spreads location on tab links to preserve query string etc * Adds ts-ignore to 'fix' problem with TS not finding EuiTab and EuiTabs modules in EUI exports * Fixes breadcrumbs and service redirect * Removes commented code --- .../apm/public/components/app/Main/Home.tsx | 31 ++++--- .../__test__/__snapshots__/Home.test.js.snap | 11 +-- .../components/app/Main/routeConfig.tsx | 46 +++++++--- .../HistoryTabs/__test__/HistoryTabs.test.tsx | 92 +++++++++++++++++++ .../__snapshots__/HistoryTabs.test.tsx.snap | 70 ++++++++++++++ .../components/shared/HistoryTabs/index.tsx | 49 ++++++++++ 6 files changed, 268 insertions(+), 31 deletions(-) create mode 100644 x-pack/plugins/apm/public/components/shared/HistoryTabs/__test__/HistoryTabs.test.tsx create mode 100644 x-pack/plugins/apm/public/components/shared/HistoryTabs/__test__/__snapshots__/HistoryTabs.test.tsx.snap create mode 100644 x-pack/plugins/apm/public/components/shared/HistoryTabs/index.tsx diff --git a/x-pack/plugins/apm/public/components/app/Main/Home.tsx b/x-pack/plugins/apm/public/components/app/Main/Home.tsx index 9be8185fa1acf..3cedc433e952b 100644 --- a/x-pack/plugins/apm/public/components/app/Main/Home.tsx +++ b/x-pack/plugins/apm/public/components/app/Main/Home.tsx @@ -5,8 +5,12 @@ */ // @ts-ignore -import { EuiTabbedContent } from '@elastic/eui'; +import { EuiTab, EuiTabs } from '@elastic/eui'; import React from 'react'; +import { + HistoryTabs, + IHistoryTab +} from 'x-pack/plugins/apm/public/components/shared/HistoryTabs'; // @ts-ignore import { KueryBar } from '../../shared/KueryBar'; import { SetupInstructionsLink } from '../../shared/SetupInstructionsLink'; @@ -16,6 +20,19 @@ import { HeaderContainer } from '../../shared/UIComponents'; import { ServiceOverview } from '../ServiceOverview'; import { TraceOverview } from '../TraceOverview'; +const homeTabs: IHistoryTab[] = [ + { + path: '/services', + name: 'Services', + component: ServiceOverview + }, + { + path: '/traces', + name: 'Traces', + component: TraceOverview + } +]; + export function Home() { return (
@@ -24,17 +41,7 @@ export function Home() { - - }, - { id: 'traces_overview', name: 'Traces', content: } - ]} - /> +
); } diff --git a/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/Home.test.js.snap b/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/Home.test.js.snap index 0383b11745400..e922597126815 100644 --- a/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/Home.test.js.snap +++ b/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/Home.test.js.snap @@ -9,19 +9,18 @@ exports[`Home component should render 1`] = ` - , - "id": "services_overview", + "component": [Function], "name": "Services", + "path": "/services", }, Object { - "content": , - "id": "traces_overview", + "component": [Function], "name": "Traces", + "path": "/traces", }, ] } diff --git a/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx b/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx index f7a5a59420318..888fc008e3047 100644 --- a/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx +++ b/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx @@ -20,19 +20,33 @@ import { Home } from './Home'; interface BreadcrumbArgs { match: { - params: StringMap; + params: StringMap; }; } interface RenderArgs { - location: StringMap; + location: StringMap; + match: { + params: StringMap; + }; } +const renderAsRedirectTo = (to: string) => { + return ({ location }: RenderArgs) => ( + + ); +}; + export const routes = [ { exact: true, path: '/', - component: Home, + render: renderAsRedirectTo('/services'), breadcrumb: 'APM' }, { @@ -56,20 +70,26 @@ export const routes = [ breadcrumb: 'Invalid License', render: () =>
Invalid license
}, + { + exact: true, + path: '/services', + component: Home, + breadcrumb: 'Services' + }, + { + exact: true, + path: '/traces', + component: Home, + breadcrumb: 'Traces' + }, { exact: true, path: '/:serviceName', breadcrumb: ({ match }: BreadcrumbArgs) => match.params.serviceName, - render: ({ location }: RenderArgs) => { - return ( - - ); - } + render: (props: RenderArgs) => + renderAsRedirectTo(`/${props.match.params.serviceName}/transactions`)( + props + ) } ] }, diff --git a/x-pack/plugins/apm/public/components/shared/HistoryTabs/__test__/HistoryTabs.test.tsx b/x-pack/plugins/apm/public/components/shared/HistoryTabs/__test__/HistoryTabs.test.tsx new file mode 100644 index 0000000000000..89624bbbe599a --- /dev/null +++ b/x-pack/plugins/apm/public/components/shared/HistoryTabs/__test__/HistoryTabs.test.tsx @@ -0,0 +1,92 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// @ts-ignore otherwise TS complains "Module ''@elastic/eui'' has no exported member 'EuiTab'" +import { EuiTab } from '@elastic/eui'; +import { mount, ReactWrapper, shallow, ShallowWrapper } from 'enzyme'; +import React from 'react'; +import { MemoryRouter } from 'react-router-dom'; +import { + HistoryTabs, + HistoryTabsProps, + HistoryTabsWithoutRouter, + IHistoryTab +} from '..'; + +describe('HistoryTabs', () => { + let mockLocation: any; + let mockHistory: any; + let testTabs: IHistoryTab[]; + let testProps: HistoryTabsProps; + + beforeEach(() => { + mockLocation = { + pathname: '' + }; + mockHistory = { + push: jest.fn() + }; + + const Content = (props: { name: string }) =>
{props.name}
; + + testTabs = [ + { + name: 'One', + path: '/one', + component: () => + }, + { + name: 'Two', + path: '/two', + component: () => + }, + { + name: 'Three', + path: '/three', + component: () => + } + ]; + + testProps = ({ + location: mockLocation, + history: mockHistory, + tabs: testTabs + } as unknown) as HistoryTabsProps; + }); + + it('should render correctly', () => { + mockLocation.pathname = '/two'; + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + + const tabs: ShallowWrapper = wrapper.find(EuiTab); + expect(tabs.at(0).props().isSelected).toEqual(false); + expect(tabs.at(1).props().isSelected).toEqual(true); + expect(tabs.at(2).props().isSelected).toEqual(false); + }); + + it('should change the selected item on tab click', () => { + const wrapper = mount( + + + + ); + + expect(wrapper.find('Content')).toMatchSnapshot(); + + wrapper + .find(EuiTab) + .at(2) + .simulate('click'); + + const tabs: ReactWrapper = wrapper.find(EuiTab); + expect(tabs.at(0).props().isSelected).toEqual(false); + expect(tabs.at(1).props().isSelected).toEqual(false); + expect(tabs.at(2).props().isSelected).toEqual(true); + + expect(wrapper.find('Content')).toMatchSnapshot(); + }); +}); diff --git a/x-pack/plugins/apm/public/components/shared/HistoryTabs/__test__/__snapshots__/HistoryTabs.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/HistoryTabs/__test__/__snapshots__/HistoryTabs.test.tsx.snap new file mode 100644 index 0000000000000..05b72c5ab7f2e --- /dev/null +++ b/x-pack/plugins/apm/public/components/shared/HistoryTabs/__test__/__snapshots__/HistoryTabs.test.tsx.snap @@ -0,0 +1,70 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`HistoryTabs should change the selected item on tab click 1`] = ` + +
+ two +
+
+`; + +exports[`HistoryTabs should change the selected item on tab click 2`] = ` + +
+ three +
+
+`; + +exports[`HistoryTabs should render correctly 1`] = ` + + + + One + + + Two + + + Three + + + + + + +`; diff --git a/x-pack/plugins/apm/public/components/shared/HistoryTabs/index.tsx b/x-pack/plugins/apm/public/components/shared/HistoryTabs/index.tsx new file mode 100644 index 0000000000000..db4d0b4141bcd --- /dev/null +++ b/x-pack/plugins/apm/public/components/shared/HistoryTabs/index.tsx @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// @ts-ignore otherwise TS complains "Module ''@elastic/eui'' has no exported member 'EuiTab'" +import { EuiTab, EuiTabs } from '@elastic/eui'; +import React from 'react'; +import { Route, RouteComponentProps, withRouter } from 'react-router-dom'; + +export interface IHistoryTab { + path: string; + name: string; + component: React.SFC | React.ComponentClass; +} + +export interface HistoryTabsProps extends RouteComponentProps { + tabs: IHistoryTab[]; +} + +const HistoryTabsWithoutRouter = ({ + tabs, + history, + location +}: HistoryTabsProps) => { + return ( + + + {tabs.map(tab => ( + history.push({ ...location, pathname: tab.path })} + isSelected={location.pathname === tab.path} + key={`${tab.path}--${tab.name}`} + > + {tab.name} + + ))} + + {tabs.map(tab => ( + + ))} + + ); +}; + +const HistoryTabs = withRouter(HistoryTabsWithoutRouter); + +export { HistoryTabsWithoutRouter, HistoryTabs }; From f56579d5533183f7e699a8076b5bf521e24b887c Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Wed, 21 Nov 2018 09:35:11 -0800 Subject: [PATCH 51/95] [DOCS] Adds screenshot for monitoring jobs (#25904) --- docs/monitoring/elasticsearch-details.asciidoc | 10 ++++++++++ docs/monitoring/images/monitoring-jobs.png | Bin 0 -> 65869 bytes 2 files changed, 10 insertions(+) create mode 100644 docs/monitoring/images/monitoring-jobs.png diff --git a/docs/monitoring/elasticsearch-details.asciidoc b/docs/monitoring/elasticsearch-details.asciidoc index 025fc8f2887cb..9af2a08363ca7 100644 --- a/docs/monitoring/elasticsearch-details.asciidoc +++ b/docs/monitoring/elasticsearch-details.asciidoc @@ -98,3 +98,13 @@ image::monitoring/images/monitoring-index-advanced.png["Elasticsearch Index Adva The Advanced index view can be used to diagnose issues that generally involve more advanced knowledge of {es}, such as wasteful index memory usage. + +[float] +[[jobs-page]] +==== Jobs + +To view {ml} job metrics, click **Jobs**. For each job in your cluster, it shows +information such as its status, the number of records processed, the size of the +model, the number of forecasts, and the node that runs the job. + +image::monitoring/images/monitoring-jobs.png["Machine learning jobs",link="images/monitoring-jobs.png"] \ No newline at end of file diff --git a/docs/monitoring/images/monitoring-jobs.png b/docs/monitoring/images/monitoring-jobs.png new file mode 100644 index 0000000000000000000000000000000000000000..bf454f1edb01d60fa52ab6ff8c708c4f2b47e875 GIT binary patch literal 65869 zcmaI7bzGFuy7x^<3Jf4!LrY0_hXSIYfG{*eN=r8g(mB-7AfbqKcQ->L-8FPe5Ae=@ z-sf|kz4zJY{K0&fyw|%nzY= z0Ye$oC?BtM43i92W1n;;NU*nkQ6Qq>0?(ZNrF*bYI#h2pbWu?h>3`K{>jFP*3<9VJ zOuhnClSTDokPn(M#ahAonKMjn9N-op`-IK9Gqr+e|IvyX2VwaCNVp?1&@H5MYob8*{gq%W(b1)Y5 zd*-NU9r*JDcTNxQB;qOHak6<|k9-N?nM9?m1tH&CQg+6~KUcrljYk88(BFj{K5H3& z8UCJuAZ4pp(e`he?#7o_Jzqk;zurJ|$g?~)&6VVm>(=GWpre-vt~RHsvvgom|9M_q zBlBb6y{YYuV?^*0!{cmkUe61+VT#%hnKbB?!aeW29ORQ0Fss?goJ>RQ%p*N55W;|a z92O!58-F_+D3_#>84oOla65{dETWN*%D@o#Hu}%$A^bw?j9PAqBdH=W)HC?}&u*>( zM%Os6+wq)5F0)D^&kPGUcEs$kANxqu)ZC^P*eF=T@mXb23$L62IU(0qJdKgKer3E3 z;%TRiG_jU5r+v>;MgYDj@I}Q}w7Pe^v|A`nN{*^Lh#zz~Sdu{Wd0A`&!Sq~8_TNM} zzN}wOPuUdZf%Mtrc~qo9^1q%0OFqdM%0g{wJ_s?9ONNTlD+Ws5=;x-hP+mcw`-f4T ziLBi6&PdKBnXT^6eIO~Fcp2)cE3N?T;Wd59mq4NB+VlQYc8NYNbj)OK$%%f+ShC4wsN4F*q?t*|9g5)sr_H=x~! z7%aKf><_RB#j@c?+v9+()7R5N?k{w3-%`rq{1o+-(p*$obV+@!JH^9U5G&-;P?otK zU;g0I_NxZv>Z7r~X;kII9OWT~JAp)WEee_YbKBlmrb?Ddao5$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y5Ctlv&^z{BTNgP0 zW|4oj&KMCS#9ASi_#2bX;F`aV;oq()bg)k3DB6p~toHzd!p23Ncvl>bs*M=-aV>nMHqZ^INKwk4PP*57By!cA_UelK+J9 zKXp^s<@=zIS z>@M!t0wknT{vF-_1Kw9B050Macd-)e=E*NtCO|oxuz#;vdgU9yRpu;Gg`i>=(1iVa zh&u6bPA)K$4jVsd>&E=1E+0f22LvtkJn%r!?&n|&%J0!9w8A*9uK(%xKQ0;&;m1oA z*W$)93Ch%g1A;q8$bn38V+M^hKBwY;gZ8hGcaF++#?FQ41KiL`mVsr&(|F{;V476_ z8desd5@8lqn-ZPaAiklS+|NyJ`@{y;tid>}5!Q zV|AvC$bY%40s@*m6X zUwdOL-MJb&NDW#d%4yj-N2_+|p&eZ=;PReg05wBlT$F*PubQWl0~IaLzX$^St^NVp zU%#eMt=KVk>TSLioNjVq;gd&oOd}w-4aRz`4GVT;yvg;;h;DFc&e8v*9LI79%*aT1 zD908gp!-*w`C|sFB9as>nXI7&^w1rZlnFb@?Hnb(2+bhNID^JYyIIdMtRq~ESSfeO zc_Nj|{MNeX(tYp`2U<(e*D^BkH(&i~PDyyd@?~0XPYpfMNymBcTO@y^_(?H$C*Hp! z{3q-$;gQewP3lECBc@LkAqxf?E0d1#L*s`wl?T4U3IkCm0Oq@{95NfAJ>_o= zR~HtwkduqZpB-+U*vk8~IRB(aCkwuhu_+fKiRYIB{^&mc_Jq*{_opB6UkBU=u{_;J zJheRC^-!m>EEJ)YeqmKedRBa_B=rrDZII{o09}Mhp=ul{j`g=jvqFTz Date: Wed, 21 Nov 2018 10:42:03 -0700 Subject: [PATCH 52/95] Test: canvas functional smoke test (#25262) ~~Blocked by https://github.com/elastic/kibana/issues/23046 (pending https://github.com/elastic/kibana/pull/25828)~~ merged Adds functional smoke tests for Canvas. - Loads and checks the list of workpads - Loads the first workpad and checks that elements render This is the simple workpad it's testing ![screenshot 2018-11-19 12 37 07](https://user-images.githubusercontent.com/404731/48730518-da7ee980-ebf7-11e8-9abb-cf294079bb5f.png) --- .../element_content/element_content.js | 1 + .../workpad_loader/workpad_loader.js | 2 + .../components/workpad_page/workpad_page.js | 1 + x-pack/test/functional/apps/canvas/index.js | 11 + .../test/functional/apps/canvas/smoke_test.js | 81 ++++ x-pack/test/functional/config.js | 5 + .../es_archives/canvas/default/data.json.gz | Bin 0 -> 1326 bytes .../es_archives/canvas/default/mappings.json | 353 ++++++++++++++++++ 8 files changed, 454 insertions(+) create mode 100644 x-pack/test/functional/apps/canvas/index.js create mode 100644 x-pack/test/functional/apps/canvas/smoke_test.js create mode 100644 x-pack/test/functional/es_archives/canvas/default/data.json.gz create mode 100644 x-pack/test/functional/es_archives/canvas/default/mappings.json diff --git a/x-pack/plugins/canvas/public/components/element_content/element_content.js b/x-pack/plugins/canvas/public/components/element_content/element_content.js index 40cca930827db..cb53f9efd0e63 100644 --- a/x-pack/plugins/canvas/public/components/element_content/element_content.js +++ b/x-pack/plugins/canvas/public/components/element_content/element_content.js @@ -51,6 +51,7 @@ export const ElementContent = compose( // TODO: 'canvas__element' was added for BWC, It can be removed after a while className={'canvas__element canvasElement'} style={{ ...renderable.containerStyle, ...size }} + data-test-subj="canvasWorkpadPageElementContent" > diff --git a/x-pack/plugins/canvas/public/components/workpad_page/workpad_page.js b/x-pack/plugins/canvas/public/components/workpad_page/workpad_page.js index fc46820aca56f..35ec5db959d76 100644 --- a/x-pack/plugins/canvas/public/components/workpad_page/workpad_page.js +++ b/x-pack/plugins/canvas/public/components/workpad_page/workpad_page.js @@ -72,6 +72,7 @@ export class WorkpadPage extends PureComponent {

{ + const workpadListSelector = 'canvasWorkpadLoaderTable canvasWorkpadLoaderWorkpad'; + const testWorkpadId = 'workpad-1705f884-6224-47de-ba49-ca224fe6ec31'; + + before(async () => { + // init data + await Promise.all([ + esArchiver.loadIfNeeded('logstash_functional'), + esArchiver.load('canvas/default'), + ]); + + // load canvas + // see also navigateToUrl(app, hash) + await PageObjects.common.navigateToApp('canvas'); + }); + + it('loads workpad list', async () => { + await retry.try(async () => { + const workpadRows = await testSubjects.findAll(workpadListSelector); + expect(workpadRows).to.have.length(1); + expect(await workpadRows[0].getVisibleText()).to.equal('Test Workpad'); + }); + }); + + it('loads workpage when clicked', async () => { + // click the first workpad in the list to load it + await testSubjects.click(workpadListSelector); + + // wait for the workpad page to load + await retry.waitFor('workpad page', () => testSubjects.exists('canvasWorkpadPage')); + + // check that workpad loaded in url + const url = await remote.getCurrentUrl(); + expect(parse(url).hash).to.equal(`#/workpad/${testWorkpadId}/page/1`); + }); + + it('renders elements on workpad', async () => { + await retry.try(async () => { + // check for elements on the page + const elements = await testSubjects.findAll( + 'canvasWorkpadPage canvasWorkpadPageElementContent' + ); + expect(elements).to.have.length(4); + + // check that the elements are what we expect + + // first is a markdown element + const md = await elements[0].findByCssSelector('.canvasMarkdown'); + expect(await md.getVisibleText()).to.contain('Welcome to Canvas'); + + // second element is a datatable that uses essql + const serverRows = await elements[1].findAllByCssSelector('.canvasDataTable tbody tr'); + expect(serverRows).to.have.length(10); + + // third is a datatable that uses csv + const commonRows = await elements[2].findAllByCssSelector('.canvasDataTable tbody tr'); + expect(commonRows).to.have.length(2); + + // fourth is a datatable that uses timelion + const timelionRows = await elements[3].findAllByCssSelector('.canvasDataTable tbody tr'); + expect(timelionRows).to.have.length(12); + }); + }); + }); +} diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 5183461a4760e..51432cff565f5 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -63,6 +63,7 @@ export default async function ({ readConfigFile }) { return { // list paths to the files that contain your plugins tests testFiles: [ + resolve(__dirname, './apps/canvas'), resolve(__dirname, './apps/graph'), resolve(__dirname, './apps/monitoring'), resolve(__dirname, './apps/watcher'), @@ -180,6 +181,10 @@ export default async function ({ readConfigFile }) { }, infraOps: { pathname: '/app/infra' + }, + canvas: { + pathname: '/app/canvas', + hash: '/', } }, diff --git a/x-pack/test/functional/es_archives/canvas/default/data.json.gz b/x-pack/test/functional/es_archives/canvas/default/data.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..de9d891058cb11725c011ae927ded826ac9f74c2 GIT binary patch literal 1326 zcmV+}1=0E+iwFP!000026TMe$Z`(Ey{+?gK$zR&RH29_$8VFD{Yli~O+AYQkbS?_M zI%;gmmE9?V0J7wFm0CP-du&6^m(eEvm~!rEcwljamnAP$6cm$=|l- zwjyn6Rps+0FAJ|RI?Zd~K1*j7Y+eOgi@$Vdsd8FYUcZNsw32pZpDRfCsrn`&V; zlGU}!%>vhs-oT5w7LC!LMdO78;S6F7Q8L2Wkf0$+1}UN+qgH)&;J>SbgR7quYgHCD zpA6Fh8lbyFz1G@}wOr&={l{YFP>xWFIVUko8R8t@8HtUZZwmz(qHK^7_P>Qf6z8Ib z7iD!e7kaq)g*ZjA%`yfPLKtMJHc$%2p%QLvO=1+q_e5^X=zg}2Ox=JF8;uUZ)^7cP zAMNamTsNoAK*mr9JvI5{)JL0>E<6_#?@9>O4*TZ@0v+c&4thnXXr?raImE~s$YRT3 z#!?B1k~%diWfb#{ck5_1%jtFjUsFq{vq@Dhiq?M5S{rSttO7$#C5k%Vl=f99HB&P) zMH8-NcRigoZRWttCQM)?Ai|bHCQ=MVk`WlogrrIurjZGjwGLi+>(7qV$*0EpBv3kt z`}^cgId|f2iaNsU%u<@|mEYu;+@T|>Naf_zDOKlvz&pPYO) zpEjndeFh!)bqc;NOyzTN^6KrYqY*HdjVZixUoIO{gV%q(I|k$NIGUCd$HMybS3dx6 z-yFXg0gTpMXoQ@aA0-6~NP!0Fep)akm3bOk5JIgXl0s{x+X+yLpfCxB)SyIWC?-P6 zN6>=Y*ODl|pB4l?KnqOClhZ=g=dKm`6JCE_<;o?qG8)*tKJ8z0@@nbi(RXKD2-3c^x zTfO@@tSPS%Od!RbW&!4=dhbp>hn`NiWcq$0SM6_%VL;a99Zqkz_0XlZsqehqCp7>C)<&nHW~MdAI{^_) zg`sncw1Na+mS|%1&fBHn;oDLBgwD55xXktmz?bb4fUnzU8>}W$JR@=3zy6}<(O!P$ z^@l2Nj4!6m?YSd-;j7x!?rh$@6=FWZd`Oca$p(z`kKMb@3so6^k=)hC=@64a!jdh0 kQP-xu5L~V9zN>EE+#a~IcD;)+-oCT`2LYJxQz;Pu03wc&S^xk5 literal 0 HcmV?d00001 diff --git a/x-pack/test/functional/es_archives/canvas/default/mappings.json b/x-pack/test/functional/es_archives/canvas/default/mappings.json new file mode 100644 index 0000000000000..6b943fc162b37 --- /dev/null +++ b/x-pack/test/functional/es_archives/canvas/default/mappings.json @@ -0,0 +1,353 @@ +{ + "type": "index", + "value": { + "index": ".kibana_1", + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "1" + } + }, + "mappings": { + "doc": { + "dynamic": "strict", + "properties": { + "canvas-workpad": { + "dynamic": "false", + "properties": { + "@created": { + "type": "date" + }, + "@timestamp": { + "type": "date" + }, + "id": { + "type": "text", + "index": false + }, + "name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + } + } + }, + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "graph-workspace": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "numLinks": { + "type": "integer" + }, + "numVertices": { + "type": "integer" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "wsState": { + "type": "text" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "type": { + "type": "keyword" + }, + "typeMeta": { + "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" + }, + "optOutCount": { + "type": "long" + } + } + }, + "migrationVersion": { + "type": "object", + "dynamic": "true" + }, + "namespace": { + "type": "keyword" + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "space": { + "properties": { + "_reserved": { + "type": "boolean" + }, + "color": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "initials": { + "type": "keyword" + }, + "name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "telemetry": { + "properties": { + "enabled": { + "type": "boolean" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + }, + "aliases": { + ".kibana": {} + } + } +} \ No newline at end of file From c8647f109bf22963e4f3597b8063d664a7febe9c Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Wed, 21 Nov 2018 18:55:48 +0100 Subject: [PATCH 53/95] Add typings for new tags API (#26027) * Add typings for new tags API * Remove test code --- x-pack/test/functional/apps/infra/index.ts | 2 +- x-pack/test/functional/apps/spaces/index.ts | 2 +- .../test/functional/apps/status_page/index.ts | 2 +- .../security_and_spaces/apis/index.ts | 2 +- .../security_only/apis/index.ts | 2 +- .../spaces_only/apis/index.ts | 2 +- .../security_and_spaces/apis/index.ts | 2 +- .../spaces_only/apis/index.ts | 2 +- x-pack/test/types/mocha_decorations.d.ts | 17 +++++++++++++++++ 9 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 x-pack/test/types/mocha_decorations.d.ts diff --git a/x-pack/test/functional/apps/infra/index.ts b/x-pack/test/functional/apps/infra/index.ts index 87abb2584b6c2..117f309d9470e 100644 --- a/x-pack/test/functional/apps/infra/index.ts +++ b/x-pack/test/functional/apps/infra/index.ts @@ -9,7 +9,7 @@ import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers'; // tslint:disable-next-line:no-default-export export default ({ loadTestFile }: KibanaFunctionalTestDefaultProviders) => { describe('InfraOps app', function() { - (this as any).tags('ciGroup4'); + this.tags('ciGroup4'); loadTestFile(require.resolve('./home_page')); }); diff --git a/x-pack/test/functional/apps/spaces/index.ts b/x-pack/test/functional/apps/spaces/index.ts index 76eb7d911b17b..7882831473b3f 100644 --- a/x-pack/test/functional/apps/spaces/index.ts +++ b/x-pack/test/functional/apps/spaces/index.ts @@ -8,7 +8,7 @@ import { TestInvoker } from './lib/types'; // tslint:disable:no-default-export export default function spacesApp({ loadTestFile }: TestInvoker) { describe('Spaces app', function spacesAppTestSuite() { - (this as any).tags('ciGroup4'); + this.tags('ciGroup4'); loadTestFile(require.resolve('./spaces_selection')); }); diff --git a/x-pack/test/functional/apps/status_page/index.ts b/x-pack/test/functional/apps/status_page/index.ts index 6b6d5c1d97600..86a9f0ad17dc3 100644 --- a/x-pack/test/functional/apps/status_page/index.ts +++ b/x-pack/test/functional/apps/status_page/index.ts @@ -8,7 +8,7 @@ import { TestInvoker } from './lib/types'; // tslint:disable:no-default-export export default function statusPage({ loadTestFile }: TestInvoker) { describe('Status page', function statusPageTestSuite() { - (this as any).tags('ciGroup4'); + this.tags('ciGroup4'); loadTestFile(require.resolve('./status_page')); }); diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/index.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/index.ts index b2b62b501e765..98049300ad3d9 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/index.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/index.ts @@ -13,7 +13,7 @@ export default function({ getService, loadTestFile }: TestInvoker) { const supertest = getService('supertest'); describe('saved objects security and spaces enabled', function() { - (this as any).tags('ciGroup5'); + this.tags('ciGroup5'); before(async () => { await createUsersAndRoles(es, supertest); diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/index.ts b/x-pack/test/saved_object_api_integration/security_only/apis/index.ts index a0797300ebf2b..6eeff5459e1a7 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/index.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/index.ts @@ -13,7 +13,7 @@ export default function({ getService, loadTestFile }: TestInvoker) { const supertest = getService('supertest'); describe('saved objects security only enabled', function() { - (this as any).tags('ciGroup5'); + this.tags('ciGroup5'); before(async () => { await createUsersAndRoles(es, supertest); diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/index.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/index.ts index b1028fa6c74c9..4e932d7ce0d91 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/index.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/index.ts @@ -9,7 +9,7 @@ import { TestInvoker } from '../../common/lib/types'; // tslint:disable:no-default-export export default function({ loadTestFile }: TestInvoker) { describe('saved objects spaces only enabled', function() { - (this as any).tags('ciGroup5'); + this.tags('ciGroup5'); loadTestFile(require.resolve('./bulk_create')); loadTestFile(require.resolve('./bulk_get')); diff --git a/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts b/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts index 6d8402fbb9244..20457aeb842d9 100644 --- a/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts +++ b/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts @@ -13,7 +13,7 @@ export default function({ loadTestFile, getService }: TestInvoker) { const supertest = getService('supertest'); describe('spaces api with security', function() { - (this as any).tags('ciGroup5'); + this.tags('ciGroup5'); before(async () => { await createUsersAndRoles(es, supertest); diff --git a/x-pack/test/spaces_api_integration/spaces_only/apis/index.ts b/x-pack/test/spaces_api_integration/spaces_only/apis/index.ts index 75b546dd16022..ead6f4e7f9eac 100644 --- a/x-pack/test/spaces_api_integration/spaces_only/apis/index.ts +++ b/x-pack/test/spaces_api_integration/spaces_only/apis/index.ts @@ -9,7 +9,7 @@ import { TestInvoker } from '../../common/lib/types'; // tslint:disable:no-default-export export default function spacesOnlyTestSuite({ loadTestFile }: TestInvoker) { describe('spaces api without security', function() { - (this as any).tags('ciGroup5'); + this.tags('ciGroup5'); loadTestFile(require.resolve('./create')); loadTestFile(require.resolve('./delete')); diff --git a/x-pack/test/types/mocha_decorations.d.ts b/x-pack/test/types/mocha_decorations.d.ts new file mode 100644 index 0000000000000..5f359c119ebb2 --- /dev/null +++ b/x-pack/test/types/mocha_decorations.d.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Suite } from 'mocha'; + +// tslint:disable-next-line:no-namespace We need to use the namespace here to match the Mocha definition +declare module 'mocha' { + interface Suite { + /** + * Assign tags to the test suite to determine in which CI job it should be run. + */ + tags(tags: string[] | string): void; + } +} From b3ef0c4eafd01e3249039061e10989528c5c7469 Mon Sep 17 00:00:00 2001 From: Robert Monfera Date: Wed, 21 Nov 2018 19:21:51 +0100 Subject: [PATCH 54/95] Fix: IE11 SVG elements have neither classList nor parentElement... (#26035) --- .../public/components/workpad_page/event_handlers.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/canvas/public/components/workpad_page/event_handlers.js b/x-pack/plugins/canvas/public/components/workpad_page/event_handlers.js index b6aa9c8da6328..b749e7bfbf2bc 100644 --- a/x-pack/plugins/canvas/public/components/workpad_page/event_handlers.js +++ b/x-pack/plugins/canvas/public/components/workpad_page/event_handlers.js @@ -6,10 +6,11 @@ import { withHandlers } from 'recompose'; -const ancestorElement = (element, className) => { +const ancestorElement = element => { if (!element) return element; - do if (element.classList.contains(className)) return element; - while ((element = element.parentElement)); + // IE11 has no classList on SVG elements, but we're not interested in SVG elements + do if (element.classList && element.classList.contains('canvasPage')) return element; + while ((element = element.parentElement || element.parentNode)); // no IE11 SVG parentElement }; const localMousePosition = (box, clientX, clientY) => { @@ -27,7 +28,7 @@ const resetHandler = () => { const setupHandler = (commit, target) => { // Ancestor has to be identified on setup, rather than 1st interaction, otherwise events may be triggered on // DOM elements that had been removed: kibana-canvas github issue #1093 - const canvasPage = ancestorElement(target, 'canvasPage'); + const canvasPage = ancestorElement(target); if (!canvasPage) return; const canvasOrigin = canvasPage.getBoundingClientRect(); window.onmousemove = ({ clientX, clientY, altKey, metaKey, shiftKey }) => { @@ -63,7 +64,7 @@ const handleMouseDown = (commit, e, isEditable) => { resetHandler(); return; // left-click and edit mode only } - const ancestor = ancestorElement(target, 'canvasPage'); + const ancestor = ancestorElement(target); if (!ancestor) return; const { x, y } = localMousePosition(ancestor, clientX, clientY); setupHandler(commit, ancestor); From 9ea7720b5058a50908b1be697f291246c8bf53c9 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Wed, 21 Nov 2018 11:24:24 -0800 Subject: [PATCH 55/95] [ML] Ensure Anomaly Explorer and Single View do not hang by fixing TypeError: finally is not a function (#25961) * Replace finally with catch/then to fix typeError * update error messages --- x-pack/plugins/ml/public/explorer/explorer_controller.js | 3 ++- .../timeseriesexplorer/timeseriesexplorer_controller.js | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/ml/public/explorer/explorer_controller.js b/x-pack/plugins/ml/public/explorer/explorer_controller.js index bbecb26e5b2fd..8842c3e12ee8c 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_controller.js +++ b/x-pack/plugins/ml/public/explorer/explorer_controller.js @@ -264,7 +264,8 @@ module.controller('MlExplorerController', function ( // Populate the map of jobs / detectors / field formatters for the selected IDs. mlFieldFormatService.populateFormats(selectedIds, getIndexPatterns()) - .finally(() => { + .catch((err) => { console.log('Error populating field formats:', err); }) + .then(() => { // Load the data - if the FieldFormats failed to populate // the default formatting will be used for metric values. loadOverallData(); diff --git a/x-pack/plugins/ml/public/timeseriesexplorer/timeseriesexplorer_controller.js b/x-pack/plugins/ml/public/timeseriesexplorer/timeseriesexplorer_controller.js index 46a718859ce67..6fed683f89811 100644 --- a/x-pack/plugins/ml/public/timeseriesexplorer/timeseriesexplorer_controller.js +++ b/x-pack/plugins/ml/public/timeseriesexplorer/timeseriesexplorer_controller.js @@ -673,9 +673,10 @@ module.controller('MlTimeSeriesExplorerController', function ( // Populate the map of jobs / detectors / field formatters for the selected IDs and refresh. mlFieldFormatService.populateFormats([jobId], getIndexPatterns()) - .finally(() => { - // Load the data - if the FieldFormats failed to populate - // the default formatting will be used for metric values. + .catch((err) => { console.log('Error populating field formats:', err); }) + // Load the data - if the FieldFormats failed to populate + // the default formatting will be used for metric values. + .then(() => { $scope.refresh(); }); } From 2b6769a088d699ea96971f73fdf36d91885abf0f Mon Sep 17 00:00:00 2001 From: Robert Monfera Date: Wed, 21 Nov 2018 20:30:17 +0100 Subject: [PATCH 56/95] [Layout Engine] PC friendly element resize modifier keys; stuck key fix (#25935) * keyboard fixes * add handling for the ctrl key (PC) * don't transmit modifier keys (no need; confuses PC) --- .../components/workpad_page/event_handlers.js | 22 ++-- .../canvas/public/lib/aeroelastic/gestures.js | 106 ++++-------------- 2 files changed, 34 insertions(+), 94 deletions(-) diff --git a/x-pack/plugins/canvas/public/components/workpad_page/event_handlers.js b/x-pack/plugins/canvas/public/components/workpad_page/event_handlers.js index b749e7bfbf2bc..6d95194e7af61 100644 --- a/x-pack/plugins/canvas/public/components/workpad_page/event_handlers.js +++ b/x-pack/plugins/canvas/public/components/workpad_page/event_handlers.js @@ -31,35 +31,35 @@ const setupHandler = (commit, target) => { const canvasPage = ancestorElement(target); if (!canvasPage) return; const canvasOrigin = canvasPage.getBoundingClientRect(); - window.onmousemove = ({ clientX, clientY, altKey, metaKey, shiftKey }) => { + window.onmousemove = ({ clientX, clientY, altKey, metaKey, shiftKey, ctrlKey }) => { const { x, y } = localMousePosition(canvasOrigin, clientX, clientY); - commit('cursorPosition', { x, y, altKey, metaKey, shiftKey }); + commit('cursorPosition', { x, y, altKey, metaKey, shiftKey, ctrlKey }); }; window.onmouseup = e => { e.stopPropagation(); - const { clientX, clientY, altKey, metaKey, shiftKey } = e; + const { clientX, clientY, altKey, metaKey, shiftKey, ctrlKey } = e; const { x, y } = localMousePosition(canvasOrigin, clientX, clientY); - commit('mouseEvent', { event: 'mouseUp', x, y, altKey, metaKey, shiftKey }); + commit('mouseEvent', { event: 'mouseUp', x, y, altKey, metaKey, shiftKey, ctrlKey }); resetHandler(); }; }; const handleMouseMove = ( commit, - { target, clientX, clientY, altKey, metaKey, shiftKey }, + { target, clientX, clientY, altKey, metaKey, shiftKey, ctrlKey }, isEditable ) => { // mouse move must be handled even before an initial click if (!window.onmousemove && isEditable) { const { x, y } = localMousePosition(target, clientX, clientY); setupHandler(commit, target); - commit('cursorPosition', { x, y, altKey, metaKey, shiftKey }); + commit('cursorPosition', { x, y, altKey, metaKey, shiftKey, ctrlKey }); } }; const handleMouseDown = (commit, e, isEditable) => { e.stopPropagation(); - const { target, clientX, clientY, button, altKey, metaKey, shiftKey } = e; + const { target, clientX, clientY, button, altKey, metaKey, shiftKey, ctrlKey } = e; if (button !== 0 || !isEditable) { resetHandler(); return; // left-click and edit mode only @@ -68,7 +68,7 @@ const handleMouseDown = (commit, e, isEditable) => { if (!ancestor) return; const { x, y } = localMousePosition(ancestor, clientX, clientY); setupHandler(commit, ancestor); - commit('mouseEvent', { event: 'mouseDown', x, y, altKey, metaKey, shiftKey }); + commit('mouseEvent', { event: 'mouseDown', x, y, altKey, metaKey, shiftKey, ctrlKey }); }; const keyCode = key => (key === 'Meta' ? 'MetaLeft' : 'Key' + key.toUpperCase()); @@ -97,6 +97,8 @@ const isNotTextInput = ({ tagName, type }) => { } }; +const modifierKey = key => ['KeyALT', 'KeyCONTROL'].indexOf(keyCode(key)) > -1; + const handleKeyDown = (commit, e, isEditable, remove) => { const { key, target } = e; @@ -104,7 +106,7 @@ const handleKeyDown = (commit, e, isEditable, remove) => { if (isNotTextInput(target) && (key === 'Backspace' || key === 'Delete')) { e.preventDefault(); remove(); - } else { + } else if (!modifierKey(key)) { commit('keyboardEvent', { event: 'keyDown', code: keyCode(key), // convert to standard event code @@ -114,7 +116,7 @@ const handleKeyDown = (commit, e, isEditable, remove) => { }; const handleKeyUp = (commit, { key }, isEditable) => { - if (isEditable) { + if (isEditable && !modifierKey(key)) { commit('keyboardEvent', { event: 'keyUp', code: keyCode(key), // convert to standard event code diff --git a/x-pack/plugins/canvas/public/lib/aeroelastic/gestures.js b/x-pack/plugins/canvas/public/lib/aeroelastic/gestures.js index 825fabb5d0350..e419380684157 100644 --- a/x-pack/plugins/canvas/public/lib/aeroelastic/gestures.js +++ b/x-pack/plugins/canvas/public/lib/aeroelastic/gestures.js @@ -6,6 +6,18 @@ const { select, selectReduce } = require('./state'); +// Only needed to shuffle some modifier keys for Apple keyboards as per vector editing software conventions, +// so it's OK that user agent strings are not reliable; in case it's spoofed, it'll just work with a slightly +// different modifier key map (also, there aren't a lot of alternatives for OS / hw / keyboard detection). +// It shouldn't fail in testing environments (node.js) either, where it can just return false, no need for +// actually getting the OS on the server side. +const appleKeyboard = Boolean( + window && + window.navigator && + window.navigator.userAgent && + window.navigator.userAgent.match('Macintosh|iPhone|iPad') +); + /** * Selectors directly from a state object * @@ -27,81 +39,18 @@ const mouseButtonEvent = select(action => (action.type === 'mouseEvent' ? action primaryUpdate ); -const keyboardEvent = select(action => (action.type === 'keyboardEvent' ? action.payload : null))( - primaryUpdate -); - -const keyInfoFromMouseEvents = select( - ({ type, payload: { altKey, metaKey, shiftKey } }) => - type === 'cursorPosition' || type === 'mouseEvent' ? { altKey, metaKey, shiftKey } : null +const keyFromMouse = select( + ({ type, payload: { altKey, metaKey, shiftKey, ctrlKey } }) => + type === 'cursorPosition' || type === 'mouseEvent' ? { altKey, metaKey, shiftKey, ctrlKey } : {} )(primaryUpdate); -const altTest = key => key.slice(0, 3).toLowerCase() === 'alt' || key === 'KeyALT'; -const metaTest = key => key.slice(0, 4).toLowerCase() === 'meta'; -const shiftTest = key => key === 'KeySHIFT' || key.slice(0, 5) === 'Shift'; -const deadKey1 = 'KeyDEAD'; -const deadKey2 = 'Key†'; - -// Key states (up vs down) from keyboard events are trivially only captured if there's a keyboard event, and that only -// happens if the user is interacting with the browser, and specifically, with the DOM subset that captures the keyboard -// event. It's also clear that all keys, and importantly, modifier keys (alt, meta etc.) can alter state while the user -// is not sending keyboard DOM events to the browser, eg. while using another tab or application. Similarly, an alt-tab -// switch away from the browser will cause the registration of an `Alt down`, but not an `Alt up`, because that happens -// in the switched-to application (https://github.com/elastic/kibana-canvas/issues/901). -// -// The solution is to also harvest modifier key (and in the future, maybe other key) statuses from mouse events, as these -// modifier keys typically alter behavior while a pointer gesture is going on, in this case now, relaxing or tightening -// snapping behavior. So we simply toggle the current key set up/down status (`lookup`) opportunistically. -// -// This function destructively modifies lookup, but could be made to work on immutable structures in the future. -const updateKeyLookupFromMouseEvent = (lookup, keyInfoFromMouseEvent) => { - Object.entries(keyInfoFromMouseEvent).forEach(([key, value]) => { - if (metaTest(key)) { - if (value) lookup.meta = true; - else delete lookup.meta; - } - if (altTest(key)) { - if (value) lookup.alt = true; - else delete lookup.alt; - } - if (shiftTest(key)) { - if (value) lookup.shift = true; - else delete lookup.shift; - } - }); - return lookup; -}; - -const pressedKeys = selectReduce((prevLookup, next, keyInfoFromMouseEvent) => { - const lookup = keyInfoFromMouseEvent - ? updateKeyLookupFromMouseEvent(prevLookup, keyInfoFromMouseEvent) - : prevLookup; - // these weird things get in when we alt-tab (or similar) etc. away and get back later: - delete lookup[deadKey1]; - delete lookup[deadKey2]; - if (!next) return { ...lookup }; - - let code = next.code; - if (altTest(next.code)) code = 'alt'; +const metaHeld = select(appleKeyboard ? e => e.metaKey : e => e.altKey)(keyFromMouse); +const optionHeld = select(appleKeyboard ? e => e.altKey : e => e.ctrlKey)(keyFromMouse); +const shiftHeld = select(e => e.shiftKey)(keyFromMouse); - if (metaTest(next.code)) code = 'meta'; - - if (shiftTest(next.code)) code = 'shift'; - - if (next.event === 'keyDown') { - return { ...lookup, [code]: true }; - } else { - /*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/ - const { [code]: ignore, ...rest } = lookup; - return rest; - } -}, {})(keyboardEvent, keyInfoFromMouseEvents); - -const keyUp = select(keys => Object.keys(keys).length === 0)(pressedKeys); - -const metaHeld = select(lookup => Boolean(lookup.meta))(pressedKeys); -const optionHeld = select(lookup => Boolean(lookup.alt))(pressedKeys); -const shiftHeld = select(lookup => Boolean(lookup.shift))(pressedKeys); +// retaining this for now to avoid removing dependent inactive code `keyTransformGesture` from layout.js +// todo remove this, and `keyTransformGesture` from layout.js and do accessibility outside the layout engine +const pressedKeys = () => ({}); const cursorPosition = selectReduce((previous, position) => position || previous, { x: 0, y: 0 })( rawCursorPosition @@ -122,18 +71,7 @@ const mouseIsDown = selectReduce( false )(mouseButtonEvent); -const gestureEnd = selectReduce( - (prev, keyUp, mouseIsDown) => { - const inAction = !keyUp || mouseIsDown; - const ended = !inAction && prev.inAction; - return { ended, inAction }; - }, - { - ended: false, - inAction: false, - }, - d => d.ended -)(keyUp, mouseIsDown); +const gestureEnd = select(next => next && next.event === 'mouseUp')(mouseButtonEvent); /** * mouseButtonStateTransitions From a6c67069651e3c3cf11ba97188f1cb98fde1ddd0 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Wed, 21 Nov 2018 13:47:18 -0700 Subject: [PATCH 57/95] test: add tags to canvas functional suite (#26046) --- x-pack/test/functional/apps/canvas/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/test/functional/apps/canvas/index.js b/x-pack/test/functional/apps/canvas/index.js index 9862ba5a70735..6620ee6c26f02 100644 --- a/x-pack/test/functional/apps/canvas/index.js +++ b/x-pack/test/functional/apps/canvas/index.js @@ -6,6 +6,7 @@ export default function canvasApp({ loadTestFile }) { describe('Canvas app', function canvasAppTestSuite() { + this.tags('ciGroup2'); // CI requires tags ヽ(゜Q。)ノ? loadTestFile(require.resolve('./smoke_test')); }); } From 7ae0d28d87ec4e504d749733753be4c4c78ff101 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 21 Nov 2018 13:45:55 -0800 Subject: [PATCH 58/95] [canvas] skip functional tests for now --- x-pack/test/functional/apps/canvas/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/canvas/index.js b/x-pack/test/functional/apps/canvas/index.js index 6620ee6c26f02..9ede9ff8c67cb 100644 --- a/x-pack/test/functional/apps/canvas/index.js +++ b/x-pack/test/functional/apps/canvas/index.js @@ -5,7 +5,7 @@ */ export default function canvasApp({ loadTestFile }) { - describe('Canvas app', function canvasAppTestSuite() { + describe.skip('Canvas app', function canvasAppTestSuite() { this.tags('ciGroup2'); // CI requires tags ヽ(゜Q。)ノ? loadTestFile(require.resolve('./smoke_test')); }); From 4f1ca7e07fbc16c1db99068f7c8025561d96f472 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Wed, 21 Nov 2018 16:25:12 -0700 Subject: [PATCH 59/95] Fix: revert and enable canvas tests (#26054) ## Summary CI was broken when enabling functional smoke tests via #25262. The problem is that the Kibana build is broken in master... I think #25711 broke it, which was merged in between #25262 passing and it being merged (and then CI breaking). So this PR reverts that PR and enabled canvas smoke tests again to see if CI will pass. - Revert #25711 - Revert 7ae0d28d87 --- .eslintignore | 3 +- package.json | 3 +- packages/kbn-interpreter/.babelrc | 3 - .../common/interpreter/create_error.js | 26 ----- packages/kbn-interpreter/common/lib/arg.js | 37 ------- .../kbn-interpreter/common/lib/arg.test.js | 35 ------ .../common/lib/functions_registry.js | 29 ----- .../common/lib/get_by_alias.js | 33 ------ .../common/lib/get_by_alias.test.js | 86 --------------- .../kbn-interpreter/common/lib/get_type.js | 28 ----- .../common/lib/paths_registry.js | 65 ------------ .../common/lib/paths_registry.test.js | 92 ---------------- .../kbn-interpreter/common/lib/serialize.js | 37 ------- .../common/lib/types_registry.js | 29 ----- packages/kbn-interpreter/package.json | 10 -- .../plugin_src/functions/common/clog.js | 27 ----- .../plugin_src/functions/common/index.js | 24 ----- .../plugin_src/functions/common/register.js | 23 ---- .../plugin_src/types/boolean.js | 42 -------- .../kbn-interpreter/plugin_src/types/error.js | 35 ------ .../plugin_src/types/filter.js | 33 ------ .../kbn-interpreter/plugin_src/types/image.js | 31 ------ .../kbn-interpreter/plugin_src/types/index.js | 46 -------- .../kbn-interpreter/plugin_src/types/null.js | 25 ----- .../plugin_src/types/number.js | 42 -------- .../plugin_src/types/pointseries.js | 44 -------- .../plugin_src/types/register.js | 24 ----- .../plugin_src/types/render.js | 29 ----- .../kbn-interpreter/plugin_src/types/shape.js | 31 ------ .../plugin_src/types/string.js | 41 ------- .../kbn-interpreter/plugin_src/types/style.js | 31 ------ .../public/browser_registries.js | 83 --------------- .../kbn-interpreter/public/create_handlers.js | 24 ----- .../server/get_plugin_paths.js | 55 ---------- .../server/server_registries.js | 78 -------------- packages/kbn-interpreter/tasks/build.js | 40 ------- .../kbn-interpreter/tasks/webpack.plugins.js | 100 ------------------ .../interpreter/common/constants.js | 21 ---- src/core_plugins/interpreter/index.js | 41 ------- src/core_plugins/interpreter/init.js | 41 ------- src/core_plugins/interpreter/package.json | 4 - src/core_plugins/interpreter/plugin_paths.js | 27 ----- .../public/load_browser_plugins.js | 30 ------ .../interpreter/server/lib/feature_check.js | 26 ----- .../server/lib/get_plugin_stream.js | 37 ------- .../interpreter/server/lib/get_request.js | 44 -------- .../server/lib/route_expression/server.js | 40 ------- .../lib/route_expression/thread/babeled.js | 32 ------ .../lib/route_expression/thread/polyfill.js | 31 ------ .../interpreter/server/routes/index.js | 28 ----- .../interpreter/server/routes/plugins.js | 35 ------ .../interpreter/server/routes/translate.js | 48 --------- src/optimize/base_optimizer.js | 5 +- src/setup_node_env/babel_register/register.js | 6 +- .../create_or_upgrade_integration.js | 2 +- x-pack/package.json | 1 - .../__tests__/fixtures/function_specs.js | 2 +- .../canvas_plugin_src/functions/common/as.js | 2 +- .../functions/common/clog.js | 14 +++ .../functions/common/index.js | 2 + .../functions/common/mapColumn.js | 2 +- .../common/plot/get_flot_axis_config.js | 2 +- .../functions/common/staticColumn.js | 2 +- .../renderers/dropdown_filter/index.js | 2 +- .../components/time_filter/time_filter.js | 2 +- .../renderers/time_filter/index.js | 2 +- .../canvas/canvas_plugin_src/types/boolean.js | 29 +++++ .../canvas_plugin_src}/types/datatable.js | 22 +--- .../canvas/canvas_plugin_src/types/error.js | 22 ++++ .../canvas/canvas_plugin_src/types/filter.js | 20 ++++ .../canvas/canvas_plugin_src/types/image.js | 18 ++++ .../canvas/canvas_plugin_src/types/index.js | 33 ++++++ .../canvas/canvas_plugin_src/types/null.js | 12 +++ .../canvas/canvas_plugin_src/types/number.js | 29 +++++ .../canvas_plugin_src/types/pointseries.js | 31 ++++++ .../canvas_plugin_src/types/register.js | 10 ++ .../canvas/canvas_plugin_src/types/render.js | 16 +++ .../canvas/canvas_plugin_src/types/shape.js | 18 ++++ .../canvas/canvas_plugin_src/types/string.js | 28 +++++ .../canvas/canvas_plugin_src/types/style.js | 18 ++++ .../uis/arguments/datacolumn/index.js | 2 +- .../uis/arguments/palette.js | 2 +- x-pack/plugins/canvas/common/functions/to.js | 2 +- .../canvas}/common/interpreter/cast.js | 22 +--- .../canvas/common/interpreter/create_error.js | 13 +++ .../canvas}/common/interpreter/interpret.js | 25 +---- .../common/interpreter/socket_interpret.js | 22 +--- .../canvas/common/lib/__tests__/arg.js | 23 ++++ .../lib/__tests__/ast.from_expression.js | 60 +++++------ .../common/lib/__tests__/ast.to_expression.js | 85 ++++++--------- .../common/lib/__tests__/get_by_alias.js | 74 +++++++++++++ .../canvas/common/lib/__tests__/registry.js | 71 ++++++------- x-pack/plugins/canvas/common/lib/arg.js | 24 +++++ .../plugins/canvas}/common/lib/ast.js | 24 +---- .../plugins/canvas/common/lib/autocomplete.js | 4 +- .../plugins/canvas}/common/lib/fn.js | 19 +--- .../canvas/common/lib/functions_registry.js | 16 +++ .../plugins/canvas/common/lib/get_by_alias.js | 20 ++++ x-pack/plugins/canvas/common/lib/get_type.js | 15 +++ .../plugins/canvas}/common/lib/grammar.js | 0 .../plugins/canvas}/common/lib/grammar.peg | 0 x-pack/plugins/canvas/common/lib/index.js | 11 ++ .../plugins/canvas}/common/lib/registry.js | 22 +--- x-pack/plugins/canvas/common/lib/serialize.js | 24 +++++ .../plugins/canvas}/common/lib/type.js | 27 ++--- .../canvas/common/lib/types_registry.js | 16 +++ x-pack/plugins/canvas/index.js | 5 - x-pack/plugins/canvas/init.js | 6 +- x-pack/plugins/canvas/plugin_paths.js | 21 ---- .../canvas/public/components/app/index.js | 31 +----- .../components/arg_form/advanced_failure.js | 2 +- .../datasource/datasource_preview/index.js | 2 +- .../element_content/element_content.js | 2 +- .../public/components/expression/index.js | 2 +- .../components/function_form_list/index.js | 4 +- .../public/expression_types/arg_type.js | 2 +- .../public/expression_types/datasource.js | 2 +- .../public/expression_types/function_form.js | 2 +- .../canvas/public/expression_types/model.js | 2 +- .../public/expression_types/transform.js | 2 +- .../canvas/public/expression_types/view.js | 2 +- .../canvas/public/functions/filters.js | 6 +- .../plugins/canvas/public/lib/arg_helpers.js | 2 +- .../canvas/public/lib/browser_registries.js | 74 +++++++++++++ .../canvas/public/lib/create_handlers.js | 11 ++ .../canvas/public/lib/elements_registry.js | 2 +- .../canvas/public/lib/function_definitions.js | 2 +- .../canvas/public/lib/functions_registry.js | 2 +- .../plugins/canvas/public/lib}/interpreter.js | 29 ++--- .../public/lib/parse_single_function_chain.js | 2 +- .../public/lib/render_functions_registry.js | 2 +- .../canvas/public/lib/run_interpreter.js | 6 +- .../canvas/public/lib/transitions_registry.js | 2 +- .../canvas/public/lib/types_registry.js | 2 +- .../plugins/canvas}/public/socket.js | 21 +--- .../canvas/public/state/actions/elements.js | 4 +- .../canvas/public/state/selectors/workpad.js | 2 +- .../server/lib/__tests__/create_handlers.js | 21 +--- .../canvas}/server/lib/create_handlers.js | 24 +---- .../canvas/server/lib/feature_check.js | 13 +++ .../canvas/server/lib/get_plugin_paths.js | 83 +++++++++++++++ .../canvas/server/lib/get_plugin_stream.js | 24 +++++ .../plugins/canvas/server/lib/get_request.js | 30 ++++++ .../plugins/canvas/server/lib/plugin_paths.js | 20 ++++ .../server/lib/route_expression/browser.js | 19 +--- .../server/lib/route_expression/index.js | 22 +--- .../server/lib/route_expression/server.js | 27 +++++ .../lib/route_expression/thread/babeled.js | 19 ++++ .../lib/route_expression/thread/index.js | 19 +--- .../lib/route_expression/thread/polyfill.js | 18 ++++ .../lib/route_expression/thread/worker.js | 28 ++--- .../canvas/server/lib/server_registries.js | 55 ++++++++++ x-pack/plugins/canvas/server/routes/index.js | 6 ++ .../plugins/canvas/server/routes/plugins.js | 25 +++++ .../plugins/canvas}/server/routes/socket.js | 31 ++---- .../plugins/canvas/server/routes/translate.js | 34 ++++++ .../plugins/canvas/server/usage/collector.js | 2 +- .../canvas/tasks/helpers/webpack.plugins.js | 1 + x-pack/test/functional/apps/canvas/index.js | 2 +- 159 files changed, 1205 insertions(+), 2458 deletions(-) delete mode 100644 packages/kbn-interpreter/.babelrc delete mode 100644 packages/kbn-interpreter/common/interpreter/create_error.js delete mode 100644 packages/kbn-interpreter/common/lib/arg.js delete mode 100644 packages/kbn-interpreter/common/lib/arg.test.js delete mode 100644 packages/kbn-interpreter/common/lib/functions_registry.js delete mode 100644 packages/kbn-interpreter/common/lib/get_by_alias.js delete mode 100644 packages/kbn-interpreter/common/lib/get_by_alias.test.js delete mode 100644 packages/kbn-interpreter/common/lib/get_type.js delete mode 100644 packages/kbn-interpreter/common/lib/paths_registry.js delete mode 100644 packages/kbn-interpreter/common/lib/paths_registry.test.js delete mode 100644 packages/kbn-interpreter/common/lib/serialize.js delete mode 100644 packages/kbn-interpreter/common/lib/types_registry.js delete mode 100644 packages/kbn-interpreter/package.json delete mode 100644 packages/kbn-interpreter/plugin_src/functions/common/clog.js delete mode 100644 packages/kbn-interpreter/plugin_src/functions/common/index.js delete mode 100644 packages/kbn-interpreter/plugin_src/functions/common/register.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/boolean.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/error.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/filter.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/image.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/index.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/null.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/number.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/pointseries.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/register.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/render.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/shape.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/string.js delete mode 100644 packages/kbn-interpreter/plugin_src/types/style.js delete mode 100644 packages/kbn-interpreter/public/browser_registries.js delete mode 100644 packages/kbn-interpreter/public/create_handlers.js delete mode 100644 packages/kbn-interpreter/server/get_plugin_paths.js delete mode 100644 packages/kbn-interpreter/server/server_registries.js delete mode 100644 packages/kbn-interpreter/tasks/build.js delete mode 100644 packages/kbn-interpreter/tasks/webpack.plugins.js delete mode 100644 src/core_plugins/interpreter/common/constants.js delete mode 100644 src/core_plugins/interpreter/index.js delete mode 100644 src/core_plugins/interpreter/init.js delete mode 100644 src/core_plugins/interpreter/package.json delete mode 100644 src/core_plugins/interpreter/plugin_paths.js delete mode 100644 src/core_plugins/interpreter/public/load_browser_plugins.js delete mode 100644 src/core_plugins/interpreter/server/lib/feature_check.js delete mode 100644 src/core_plugins/interpreter/server/lib/get_plugin_stream.js delete mode 100644 src/core_plugins/interpreter/server/lib/get_request.js delete mode 100644 src/core_plugins/interpreter/server/lib/route_expression/server.js delete mode 100644 src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js delete mode 100644 src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js delete mode 100644 src/core_plugins/interpreter/server/routes/index.js delete mode 100644 src/core_plugins/interpreter/server/routes/plugins.js delete mode 100644 src/core_plugins/interpreter/server/routes/translate.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/functions/common/clog.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/boolean.js rename {packages/kbn-interpreter/plugin_src => x-pack/plugins/canvas/canvas_plugin_src}/types/datatable.js (63%) create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/error.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/filter.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/image.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/index.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/null.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/number.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/pointseries.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/register.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/render.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/shape.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/string.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/types/style.js rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/interpreter/cast.js (53%) create mode 100644 x-pack/plugins/canvas/common/interpreter/create_error.js rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/interpreter/interpret.js (88%) rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/interpreter/socket_interpret.js (72%) create mode 100644 x-pack/plugins/canvas/common/lib/__tests__/arg.js rename packages/kbn-interpreter/common/lib/ast.from_expression.test.js => x-pack/plugins/canvas/common/lib/__tests__/ast.from_expression.js (59%) rename packages/kbn-interpreter/common/lib/ast.to_expression.test.js => x-pack/plugins/canvas/common/lib/__tests__/ast.to_expression.js (83%) create mode 100644 x-pack/plugins/canvas/common/lib/__tests__/get_by_alias.js rename packages/kbn-interpreter/common/lib/registry.test.js => x-pack/plugins/canvas/common/lib/__tests__/registry.js (60%) create mode 100644 x-pack/plugins/canvas/common/lib/arg.js rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/lib/ast.js (81%) rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/lib/fn.js (54%) create mode 100644 x-pack/plugins/canvas/common/lib/functions_registry.js create mode 100644 x-pack/plugins/canvas/common/lib/get_by_alias.js create mode 100644 x-pack/plugins/canvas/common/lib/get_type.js rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/lib/grammar.js (100%) rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/lib/grammar.peg (100%) rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/lib/registry.js (56%) create mode 100644 x-pack/plugins/canvas/common/lib/serialize.js rename {packages/kbn-interpreter => x-pack/plugins/canvas}/common/lib/type.js (61%) create mode 100644 x-pack/plugins/canvas/common/lib/types_registry.js delete mode 100644 x-pack/plugins/canvas/plugin_paths.js create mode 100644 x-pack/plugins/canvas/public/lib/browser_registries.js create mode 100644 x-pack/plugins/canvas/public/lib/create_handlers.js rename {packages/kbn-interpreter/public => x-pack/plugins/canvas/public/lib}/interpreter.js (55%) rename {packages/kbn-interpreter => x-pack/plugins/canvas}/public/socket.js (64%) rename {src/core_plugins/interpreter => x-pack/plugins/canvas}/server/lib/__tests__/create_handlers.js (83%) rename {src/core_plugins/interpreter => x-pack/plugins/canvas}/server/lib/create_handlers.js (58%) create mode 100644 x-pack/plugins/canvas/server/lib/feature_check.js create mode 100644 x-pack/plugins/canvas/server/lib/get_plugin_paths.js create mode 100644 x-pack/plugins/canvas/server/lib/get_plugin_stream.js create mode 100644 x-pack/plugins/canvas/server/lib/get_request.js create mode 100644 x-pack/plugins/canvas/server/lib/plugin_paths.js rename {src/core_plugins/interpreter => x-pack/plugins/canvas}/server/lib/route_expression/browser.js (65%) rename {src/core_plugins/interpreter => x-pack/plugins/canvas}/server/lib/route_expression/index.js (51%) create mode 100644 x-pack/plugins/canvas/server/lib/route_expression/server.js create mode 100644 x-pack/plugins/canvas/server/lib/route_expression/thread/babeled.js rename {src/core_plugins/interpreter => x-pack/plugins/canvas}/server/lib/route_expression/thread/index.js (78%) create mode 100644 x-pack/plugins/canvas/server/lib/route_expression/thread/polyfill.js rename {src/core_plugins/interpreter => x-pack/plugins/canvas}/server/lib/route_expression/thread/worker.js (62%) create mode 100644 x-pack/plugins/canvas/server/lib/server_registries.js create mode 100644 x-pack/plugins/canvas/server/routes/plugins.js rename {src/core_plugins/interpreter => x-pack/plugins/canvas}/server/routes/socket.js (68%) create mode 100644 x-pack/plugins/canvas/server/routes/translate.js diff --git a/.eslintignore b/.eslintignore index 50901af5b9eea..f697ad004caab 100644 --- a/.eslintignore +++ b/.eslintignore @@ -27,8 +27,7 @@ bower_components /x-pack/coverage /x-pack/build /x-pack/plugins/**/__tests__/fixtures/** -/packages/kbn-interpreter/common/lib/grammar.js -/packages/kbn-interpreter/plugin +/x-pack/plugins/canvas/common/lib/grammar.js /x-pack/plugins/canvas/canvas_plugin /x-pack/plugins/canvas/canvas_plugin_src/lib/flot-charts **/*.js.snap diff --git a/package.json b/package.json index d4f63df304f9a..b0555fad091e1 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,6 @@ "@kbn/pm": "1.0.0", "@kbn/test-subj-selector": "0.2.1", "@kbn/ui-framework": "1.0.0", - "@kbn/interpreter": "1.0.0", "JSONStream": "1.1.1", "abortcontroller-polyfill": "^1.1.9", "angular": "1.6.9", @@ -384,4 +383,4 @@ "node": "8.11.4", "yarn": "^1.10.1" } -} +} \ No newline at end of file diff --git a/packages/kbn-interpreter/.babelrc b/packages/kbn-interpreter/.babelrc deleted file mode 100644 index dc6a77bbe0bcd..0000000000000 --- a/packages/kbn-interpreter/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@kbn/babel-preset/webpack_preset"] -} diff --git a/packages/kbn-interpreter/common/interpreter/create_error.js b/packages/kbn-interpreter/common/interpreter/create_error.js deleted file mode 100644 index 2740358b1c960..0000000000000 --- a/packages/kbn-interpreter/common/interpreter/create_error.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -export const createError = err => ({ - type: 'error', - error: { - stack: process.env.NODE_ENV === 'production' ? undefined : err.stack, - message: typeof err === 'string' ? err : err.message, - }, -}); diff --git a/packages/kbn-interpreter/common/lib/arg.js b/packages/kbn-interpreter/common/lib/arg.js deleted file mode 100644 index 0aa2b52e35acb..0000000000000 --- a/packages/kbn-interpreter/common/lib/arg.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 { includes } from 'lodash'; - -export function Arg(config) { - if (config.name === '_') throw Error('Arg names must not be _. Use it in aliases instead.'); - this.name = config.name; - this.required = config.required || false; - this.help = config.help || ''; - this.types = config.types || []; - this.default = config.default; - this.aliases = config.aliases || []; - this.multi = config.multi == null ? false : config.multi; - this.resolve = config.resolve == null ? true : config.resolve; - this.options = config.options || []; - this.accepts = type => { - if (!this.types.length) return true; - return includes(config.types, type); - }; -} diff --git a/packages/kbn-interpreter/common/lib/arg.test.js b/packages/kbn-interpreter/common/lib/arg.test.js deleted file mode 100644 index 2edd65cd4af49..0000000000000 --- a/packages/kbn-interpreter/common/lib/arg.test.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 { Arg } from './arg'; - -describe('Arg', () => { - it('sets required to false by default', () => { - const isOptional = new Arg({ - name: 'optional_me', - }); - expect(isOptional.required).toBe(false); - - const isRequired = new Arg({ - name: 'require_me', - required: true, - }); - expect(isRequired.required).toBe(true); - }); -}); diff --git a/packages/kbn-interpreter/common/lib/functions_registry.js b/packages/kbn-interpreter/common/lib/functions_registry.js deleted file mode 100644 index 1c71707d84722..0000000000000 --- a/packages/kbn-interpreter/common/lib/functions_registry.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 { Registry } from './registry'; -import { Fn } from './fn'; - -class FunctionsRegistry extends Registry { - wrapper(obj) { - return new Fn(obj); - } -} - -export const functionsRegistry = new FunctionsRegistry(); diff --git a/packages/kbn-interpreter/common/lib/get_by_alias.js b/packages/kbn-interpreter/common/lib/get_by_alias.js deleted file mode 100644 index d7bb1bbf9e79d..0000000000000 --- a/packages/kbn-interpreter/common/lib/get_by_alias.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -/** - * This is used for looking up function/argument definitions. It looks through - * the given object/array for a case-insensitive match, which could be either the - * `name` itself, or something under the `aliases` property. - */ -export function getByAlias(specs, name) { - const lowerCaseName = name.toLowerCase(); - return Object.values(specs).find(({ name, aliases }) => { - if (name.toLowerCase() === lowerCaseName) return true; - return (aliases || []).some(alias => { - return alias.toLowerCase() === lowerCaseName; - }); - }); -} diff --git a/packages/kbn-interpreter/common/lib/get_by_alias.test.js b/packages/kbn-interpreter/common/lib/get_by_alias.test.js deleted file mode 100644 index 9cfc37fd8f304..0000000000000 --- a/packages/kbn-interpreter/common/lib/get_by_alias.test.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 { getByAlias } from './get_by_alias'; - -describe('getByAlias', () => { - const fnsObject = { - foo: { name: 'foo', aliases: ['f'] }, - bar: { name: 'bar', aliases: ['b'] }, - }; - - const fnsArray = [{ name: 'foo', aliases: ['f'] }, { name: 'bar', aliases: ['b'] }]; - - it('returns the function by name', () => { - expect(getByAlias(fnsObject, 'foo')).toBe(fnsObject.foo); - expect(getByAlias(fnsObject, 'bar')).toBe(fnsObject.bar); - expect(getByAlias(fnsArray, 'foo')).toBe(fnsArray[0]); - expect(getByAlias(fnsArray, 'bar')).toBe(fnsArray[1]); - }); - - it('returns the function by alias', () => { - expect(getByAlias(fnsObject, 'f')).toBe(fnsObject.foo); - expect(getByAlias(fnsObject, 'b')).toBe(fnsObject.bar); - expect(getByAlias(fnsArray, 'f')).toBe(fnsArray[0]); - expect(getByAlias(fnsArray, 'b')).toBe(fnsArray[1]); - }); - - it('returns the function by case-insensitive name', () => { - expect(getByAlias(fnsObject, 'FOO')).toBe(fnsObject.foo); - expect(getByAlias(fnsObject, 'BAR')).toBe(fnsObject.bar); - expect(getByAlias(fnsArray, 'FOO')).toBe(fnsArray[0]); - expect(getByAlias(fnsArray, 'BAR')).toBe(fnsArray[1]); - }); - - it('returns the function by case-insensitive alias', () => { - expect(getByAlias(fnsObject, 'F')).toBe(fnsObject.foo); - expect(getByAlias(fnsObject, 'B')).toBe(fnsObject.bar); - expect(getByAlias(fnsArray, 'F')).toBe(fnsArray[0]); - expect(getByAlias(fnsArray, 'B')).toBe(fnsArray[1]); - }); - - it('handles empty strings', () => { - const emptyStringFnsObject = { '': { name: '' } }; - const emptyStringAliasFnsObject = { foo: { name: 'foo', aliases: [''] } }; - expect(getByAlias(emptyStringFnsObject, '')).toBe(emptyStringFnsObject['']); - expect(getByAlias(emptyStringAliasFnsObject, '')).toBe(emptyStringAliasFnsObject.foo); - - const emptyStringFnsArray = [{ name: '' }]; - const emptyStringAliasFnsArray = [{ name: 'foo', aliases: [''] }]; - expect(getByAlias(emptyStringFnsArray, '')).toBe(emptyStringFnsArray[0]); - expect(getByAlias(emptyStringAliasFnsArray, '')).toBe(emptyStringAliasFnsArray[0]); - }); - - it('handles "undefined" strings', () => { - const undefinedFnsObject = { undefined: { name: 'undefined' } }; - const undefinedAliasFnsObject = { foo: { name: 'undefined', aliases: ['undefined'] } }; - expect(getByAlias(undefinedFnsObject, 'undefined')).toBe(undefinedFnsObject.undefined); - expect(getByAlias(undefinedAliasFnsObject, 'undefined')).toBe(undefinedAliasFnsObject.foo); - - const emptyStringFnsArray = [{ name: 'undefined' }]; - const emptyStringAliasFnsArray = [{ name: 'foo', aliases: ['undefined'] }]; - expect(getByAlias(emptyStringFnsArray, 'undefined')).toBe(emptyStringFnsArray[0]); - expect(getByAlias(emptyStringAliasFnsArray, 'undefined')).toBe(emptyStringAliasFnsArray[0]); - }); - - it('returns undefined if not found', () => { - expect(getByAlias(fnsObject, 'baz')).toBe(undefined); - expect(getByAlias(fnsArray, 'baz')).toBe(undefined); - }); -}); diff --git a/packages/kbn-interpreter/common/lib/get_type.js b/packages/kbn-interpreter/common/lib/get_type.js deleted file mode 100644 index ac440acf8da5d..0000000000000 --- a/packages/kbn-interpreter/common/lib/get_type.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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. - */ - -export function getType(node) { - if (node == null) return 'null'; - if (typeof node === 'object') { - if (!node.type) throw new Error('Objects must have a type property'); - return node.type; - } - - return typeof node; -} diff --git a/packages/kbn-interpreter/common/lib/paths_registry.js b/packages/kbn-interpreter/common/lib/paths_registry.js deleted file mode 100644 index 3ad2b5dddf82e..0000000000000 --- a/packages/kbn-interpreter/common/lib/paths_registry.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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. - */ - -class PathsRegistry { - - constructor() { - this.paths = new Map(); - } - - register = (type, paths) => { - if (!type) { - throw new Error(`Register requires a type`); - } - const lowerCaseType = type.toLowerCase(); - - const pathArray = Array.isArray(paths) ? paths : [paths]; - if (!this.paths.has(lowerCaseType)) { - this.paths.set(lowerCaseType, []); - } - - pathArray.forEach(p => { - this.paths.get(lowerCaseType).push(p); - }); - }; - - registerAll = (paths) => { - Object.keys(paths).forEach(type => { - this.register(type, paths[type]); - }); - }; - - toArray = () => { - return [...this.paths.values()]; - }; - - get = (type) => { - if (!type) { - return []; - } - const lowerCaseType = type.toLowerCase(); - return this.paths.has(lowerCaseType) ? this.paths.get(lowerCaseType) : []; - }; - - reset = () => { - this.paths.clear(); - }; -} - -export const pathsRegistry = new PathsRegistry(); diff --git a/packages/kbn-interpreter/common/lib/paths_registry.test.js b/packages/kbn-interpreter/common/lib/paths_registry.test.js deleted file mode 100644 index ad2b9d949deb3..0000000000000 --- a/packages/kbn-interpreter/common/lib/paths_registry.test.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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. - */ - -describe('pathsRegistry', () => { - let registry; - beforeEach(() => { - jest.resetModules(); - registry = require('./paths_registry').pathsRegistry; - }); - - const paths = { - foo: 'bar', - sometype: [ - 'Here', - 'be', - 'more', - 'paths!' - ], - anothertype: ['with just one lonely path'] - }; - - it('throws when no type is provided', () => { - const check = () => registry.register(null, paths.foo); - expect(check).toThrowError(/requires a type/); - }); - - it('accepts paths as a string', () => { - registry.register('foo', paths.foo); - expect(registry.get('foo')).toEqual([paths.foo]); - }); - - it('accepts paths as an array', () => { - registry.register('sometype', paths.sometype); - expect(registry.get('sometype')).toEqual(paths.sometype); - }); - - it('ignores case when setting items', () => { - registry.register('FOO', paths.foo); - expect(registry.get('foo')).toEqual([paths.foo]); - }); - - it('gets items by lookup property', () => { - registry.register('sometype', paths.sometype); - expect(registry.get('sometype')).toEqual(paths.sometype); - }); - - it('can register an object of `type: path` key-value pairs', () => { - registry.registerAll(paths); - expect(registry.get('foo')).toEqual([paths.foo]); - expect(registry.get('sometype')).toEqual(paths.sometype); - expect(registry.get('anothertype')).toEqual(paths.anothertype); - }); - - it('ignores case when getting items', () => { - registry.registerAll(paths); - expect(registry.get('FOO')).toEqual([paths.foo]); - expect(registry.get('SOmEType')).toEqual(paths.sometype); - expect(registry.get('anoThertYPE')).toEqual(paths.anothertype); - }); - - it('returns an empty array with no match', () => { - expect(registry.get('@@nope_nope')).toEqual([]); - }); - - it('returns an array of all path values', () => { - registry.registerAll(paths); - expect(registry.toArray()).toEqual([[paths.foo], paths.sometype, paths.anothertype]); - }); - - it('resets the registry', () => { - registry.registerAll(paths); - expect(registry.get('sometype')).toEqual(paths.sometype); - registry.reset(); - expect(registry.get('sometype')).toEqual([]); - }); -}); \ No newline at end of file diff --git a/packages/kbn-interpreter/common/lib/serialize.js b/packages/kbn-interpreter/common/lib/serialize.js deleted file mode 100644 index 2f881db3c77e0..0000000000000 --- a/packages/kbn-interpreter/common/lib/serialize.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 { get, identity } from 'lodash'; -import { getType } from './get_type'; - -export function serializeProvider(types) { - return { - serialize: provider('serialize'), - deserialize: provider('deserialize'), - }; - - function provider(key) { - return context => { - const type = getType(context); - const typeDef = types[type]; - const fn = get(typeDef, key) || identity; - return fn(context); - }; - } -} diff --git a/packages/kbn-interpreter/common/lib/types_registry.js b/packages/kbn-interpreter/common/lib/types_registry.js deleted file mode 100644 index 97e28875d7e20..0000000000000 --- a/packages/kbn-interpreter/common/lib/types_registry.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 { Registry } from './registry'; -import { Type } from './type'; - -class TypesRegistry extends Registry { - wrapper(obj) { - return new Type(obj); - } -} - -export const typesRegistry = new TypesRegistry(); diff --git a/packages/kbn-interpreter/package.json b/packages/kbn-interpreter/package.json deleted file mode 100644 index 0178b9e2cfe32..0000000000000 --- a/packages/kbn-interpreter/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "@kbn/interpreter", - "version": "1.0.0", - "license": "Apache-2.0", - "scripts": { - "build": "node tasks/build.js", - "canvas:peg": "pegjs common/lib/grammar.peg", - "kbn:bootstrap": "yarn build" - } -} diff --git a/packages/kbn-interpreter/plugin_src/functions/common/clog.js b/packages/kbn-interpreter/plugin_src/functions/common/clog.js deleted file mode 100644 index 634d166f5f0bb..0000000000000 --- a/packages/kbn-interpreter/plugin_src/functions/common/clog.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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. - */ - -export const clog = () => ({ - name: 'clog', - help: 'Outputs the context to the console', - fn: context => { - console.log(context); //eslint-disable-line no-console - return context; - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/functions/common/index.js b/packages/kbn-interpreter/plugin_src/functions/common/index.js deleted file mode 100644 index 2f5f91181faec..0000000000000 --- a/packages/kbn-interpreter/plugin_src/functions/common/index.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 { clog } from './clog'; - -export const commonFunctions = [ - clog, -]; diff --git a/packages/kbn-interpreter/plugin_src/functions/common/register.js b/packages/kbn-interpreter/plugin_src/functions/common/register.js deleted file mode 100644 index 8b146b8f849c3..0000000000000 --- a/packages/kbn-interpreter/plugin_src/functions/common/register.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 { commonFunctions } from './index'; - -// eslint-disable-next-line no-undef -commonFunctions.forEach(canvas.register); diff --git a/packages/kbn-interpreter/plugin_src/types/boolean.js b/packages/kbn-interpreter/plugin_src/types/boolean.js deleted file mode 100644 index cc5f0a79e39a8..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/boolean.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -export const boolean = () => ({ - name: 'boolean', - from: { - null: () => false, - number: n => Boolean(n), - string: s => Boolean(s), - }, - to: { - render: value => { - const text = `${value}`; - return { - type: 'render', - as: 'text', - value: { text }, - }; - }, - datatable: value => ({ - type: 'datatable', - columns: [{ name: 'value', type: 'boolean' }], - rows: [{ value }], - }), - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/error.js b/packages/kbn-interpreter/plugin_src/types/error.js deleted file mode 100644 index 1415a065d810e..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/error.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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. - */ - -export const error = () => ({ - name: 'error', - to: { - render: input => { - const { error, info } = input; - return { - type: 'render', - as: 'error', - value: { - error, - info, - }, - }; - }, - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/filter.js b/packages/kbn-interpreter/plugin_src/types/filter.js deleted file mode 100644 index 484050671b2f9..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/filter.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -export const filter = () => ({ - name: 'filter', - from: { - null: () => { - return { - type: 'filter', - // Any meta data you wish to pass along. - meta: {}, - // And filters. If you need an "or", create a filter type for it. - and: [], - }; - }, - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/image.js b/packages/kbn-interpreter/plugin_src/types/image.js deleted file mode 100644 index 7666451145f5d..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/image.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ - -export const image = () => ({ - name: 'image', - to: { - render: input => { - return { - type: 'render', - as: 'image', - value: input, - }; - }, - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/index.js b/packages/kbn-interpreter/plugin_src/types/index.js deleted file mode 100644 index 1ae5f874835c3..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 { boolean } from './boolean'; -import { datatable } from './datatable'; -import { error } from './error'; -import { filter } from './filter'; -import { image } from './image'; -import { nullType } from './null'; -import { number } from './number'; -import { pointseries } from './pointseries'; -import { render } from './render'; -import { shape } from './shape'; -import { string } from './string'; -import { style } from './style'; - -export const typeSpecs = [ - boolean, - datatable, - error, - filter, - image, - number, - nullType, - pointseries, - render, - shape, - string, - style, -]; diff --git a/packages/kbn-interpreter/plugin_src/types/null.js b/packages/kbn-interpreter/plugin_src/types/null.js deleted file mode 100644 index 2789ce330ac6c..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/null.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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. - */ - -export const nullType = () => ({ - name: 'null', - from: { - '*': () => null, - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/number.js b/packages/kbn-interpreter/plugin_src/types/number.js deleted file mode 100644 index 8f8f31ea8a2fb..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/number.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -export const number = () => ({ - name: 'number', - from: { - null: () => 0, - boolean: b => Number(b), - string: n => Number(n), - }, - to: { - render: value => { - const text = `${value}`; - return { - type: 'render', - as: 'text', - value: { text }, - }; - }, - datatable: value => ({ - type: 'datatable', - columns: [{ name: 'value', type: 'number' }], - rows: [{ value }], - }), - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/pointseries.js b/packages/kbn-interpreter/plugin_src/types/pointseries.js deleted file mode 100644 index 2275ea9e04094..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/pointseries.js +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -export const pointseries = () => ({ - name: 'pointseries', - from: { - null: () => { - return { - type: 'pointseries', - rows: [], - columns: [], - }; - }, - }, - to: { - render: (pointseries, types) => { - const datatable = types.datatable.from(pointseries, types); - return { - type: 'render', - as: 'table', - value: { - datatable, - showHeader: true, - }, - }; - }, - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/register.js b/packages/kbn-interpreter/plugin_src/types/register.js deleted file mode 100644 index 17b03f0229672..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/register.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 'babel-polyfill'; -import { typeSpecs } from './index'; - -// eslint-disable-next-line no-undef -typeSpecs.forEach(canvas.register); diff --git a/packages/kbn-interpreter/plugin_src/types/render.js b/packages/kbn-interpreter/plugin_src/types/render.js deleted file mode 100644 index 99ce3ca7d1cd7..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/render.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -export const render = () => ({ - name: 'render', - from: { - '*': v => ({ - type: 'render', - as: 'debug', - value: v, - }), - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/shape.js b/packages/kbn-interpreter/plugin_src/types/shape.js deleted file mode 100644 index 1ed7a111268d1..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/shape.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ - -export const shape = () => ({ - name: 'shape', - to: { - render: input => { - return { - type: 'render', - as: 'shape', - value: input, - }; - }, - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/string.js b/packages/kbn-interpreter/plugin_src/types/string.js deleted file mode 100644 index 90e6b17cc9dcf..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/string.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ - -export const string = () => ({ - name: 'string', - from: { - null: () => '', - boolean: b => String(b), - number: n => String(n), - }, - to: { - render: text => { - return { - type: 'render', - as: 'text', - value: { text }, - }; - }, - datatable: value => ({ - type: 'datatable', - columns: [{ name: 'value', type: 'string' }], - rows: [{ value }], - }), - }, -}); diff --git a/packages/kbn-interpreter/plugin_src/types/style.js b/packages/kbn-interpreter/plugin_src/types/style.js deleted file mode 100644 index 97057b415a475..0000000000000 --- a/packages/kbn-interpreter/plugin_src/types/style.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ - -export const style = () => ({ - name: 'style', - from: { - null: () => { - return { - type: 'style', - spec: {}, - css: '', - }; - }, - }, -}); diff --git a/packages/kbn-interpreter/public/browser_registries.js b/packages/kbn-interpreter/public/browser_registries.js deleted file mode 100644 index 778a0b03a7624..0000000000000 --- a/packages/kbn-interpreter/public/browser_registries.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 chrome from 'ui/chrome'; -import $script from 'scriptjs'; - -let resolvePromise = null; -let called = false; - -let populatePromise = new Promise(_resolve => { - resolvePromise = _resolve; -}); - -export const getBrowserRegistries = () => { - return populatePromise; -}; - -const loadBrowserRegistries = (registries) => { - const remainingTypes = Object.keys(registries); - const populatedTypes = {}; - - return new Promise(resolve => { - function loadType() { - if (!remainingTypes.length) { - resolve(populatedTypes); - return; - } - const type = remainingTypes.pop(); - window.canvas = window.canvas || {}; - window.canvas.register = d => registries[type].register(d); - - // Load plugins one at a time because each needs a different loader function - // $script will only load each of these once, we so can call this as many times as we need? - const pluginPath = chrome.addBasePath(`/api/canvas/plugins?type=${type}`); - $script(pluginPath, () => { - populatedTypes[type] = registries[type]; - loadType(); - }); - } - - loadType(); - }); -}; - -export const populateBrowserRegistries = (registries) => { - if (called) { - const oldPromise = populatePromise; - let newResolve; - populatePromise = new Promise(_resolve => { - newResolve = _resolve; - }); - oldPromise.then(oldTypes => { - loadBrowserRegistries(registries).then(newTypes => { - newResolve({ - ...oldTypes, - ...newTypes, - }); - }); - }); - return populatePromise; - } - called = true; - loadBrowserRegistries(registries).then(registries => { - resolvePromise(registries); - }); - return populatePromise; -}; diff --git a/packages/kbn-interpreter/public/create_handlers.js b/packages/kbn-interpreter/public/create_handlers.js deleted file mode 100644 index 3446a945ae76e..0000000000000 --- a/packages/kbn-interpreter/public/create_handlers.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -export function createHandlers(/*socket*/) { - return { - environment: 'client', - }; -} diff --git a/packages/kbn-interpreter/server/get_plugin_paths.js b/packages/kbn-interpreter/server/get_plugin_paths.js deleted file mode 100644 index f6520563c912f..0000000000000 --- a/packages/kbn-interpreter/server/get_plugin_paths.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 fs from 'fs'; -import { resolve } from 'path'; -import { promisify } from 'util'; -import { flatten } from 'lodash'; -import { pathsRegistry } from '../common/lib/paths_registry'; - -const lstat = promisify(fs.lstat); -const readdir = promisify(fs.readdir); - -const isDirectory = path => - lstat(path) - .then(stat => stat.isDirectory()) - .catch(() => false); - -export const getPluginPaths = type => { - const typePaths = pathsRegistry.get(type); - if (!typePaths) { - throw new Error(`Unknown type: ${type}`); - } - - return Promise.all(typePaths.map(async path => { - const isDir = await isDirectory(path); - if (!isDir) { - return; - } - // Get the full path of all js files in the directory - return readdir(path).then(files => { - return files.reduce((acc, file) => { - if (file.endsWith('.js')) { - acc.push(resolve(path, file)); - } - return acc; - }, []); - }).catch(); - })).then(flatten); -}; diff --git a/packages/kbn-interpreter/server/server_registries.js b/packages/kbn-interpreter/server/server_registries.js deleted file mode 100644 index 3fbb957673e63..0000000000000 --- a/packages/kbn-interpreter/server/server_registries.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 { typesRegistry } from '../common/lib/types_registry'; -import { functionsRegistry as serverFunctions } from '../common/lib/functions_registry'; -import { getPluginPaths } from './get_plugin_paths'; - -const registries = { - serverFunctions: serverFunctions, - commonFunctions: serverFunctions, - types: typesRegistry, -}; - -let resolve = null; -let called = false; - -const populatePromise = new Promise(_resolve => { - resolve = _resolve; -}); - -export const getServerRegistries = () => { - return populatePromise; -}; - -export const populateServerRegistries = types => { - if (called) { - console.log('function should only be called once per process'); - return populatePromise; - } - called = true; - if (!types || !types.length) throw new Error('types is required'); - - const remainingTypes = types; - const populatedTypes = {}; - - const globalKeys = Object.keys(global); - - const loadType = () => { - const type = remainingTypes.pop(); - getPluginPaths(type).then(paths => { - global.canvas = global.canvas || {}; - global.canvas.register = d => registries[type].register(d); - - paths.forEach(path => { - require(path); - }); - - Object.keys(global).forEach(key => { - if (!globalKeys.includes(key)) { - delete global[key]; - } - }); - - populatedTypes[type] = registries[type]; - if (remainingTypes.length) loadType(); - else resolve(populatedTypes); - }); - }; - - if (remainingTypes.length) loadType(); - return populatePromise; -}; diff --git a/packages/kbn-interpreter/tasks/build.js b/packages/kbn-interpreter/tasks/build.js deleted file mode 100644 index 37776e8d74cca..0000000000000 --- a/packages/kbn-interpreter/tasks/build.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 webpack = require('webpack'); -const webpackConfig = require('./webpack.plugins'); - -const devtool = 'inline-cheap-module-source-map'; - -const onComplete = function (done) { - return function (err, stats) { - if (err) { - done && done(err); - } else { - const seconds = ((stats.endTime - stats.startTime) / 1000).toFixed(2); - console.log(`Plugins built in ${seconds} seconds`); - done && done(); - } - }; -}; - -webpack({ ...webpackConfig, devtool }, onComplete(function () { - console.log('all done'); -})); - diff --git a/packages/kbn-interpreter/tasks/webpack.plugins.js b/packages/kbn-interpreter/tasks/webpack.plugins.js deleted file mode 100644 index 8b16edc5ad462..0000000000000 --- a/packages/kbn-interpreter/tasks/webpack.plugins.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 path = require('path'); - -const sourceDir = path.resolve(__dirname, '../plugin_src'); -const buildDir = path.resolve(__dirname, '../plugin'); - -module.exports = { - entry: { - 'types/all': path.join(sourceDir, 'types/register.js'), - 'functions/common/all': path.join(sourceDir, 'functions/common/register.js'), - }, - target: 'webworker', - - output: { - path: buildDir, - filename: '[name].js', // Need long paths here. - libraryTarget: 'umd', - }, - - resolve: { - extensions: ['.js', '.json'], - mainFields: ['browser', 'main'], - }, - - plugins: [ - function loaderFailHandler() { - // bails on error, including loader errors - // see https://github.com/webpack/webpack/issues/708, which does not fix loader errors - let isWatch = true; - - this.plugin('run', function (compiler, callback) { - isWatch = false; - callback.call(compiler); - }); - - this.plugin('done', function (stats) { - if (!stats.hasErrors()) { - return; - } - const errorMessage = stats.toString('errors-only'); - if (isWatch) { - console.error(errorMessage); - } - else { - throw new Error(errorMessage); - } - }); - }, - ], - - module: { - rules: [ - { - test: /\.js$/, - exclude: [/node_modules/], - loaders: 'babel-loader', - options: { - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/webpack_preset')], - }, - }, - { - test: /\.(png|jpg|gif|jpeg|svg)$/, - loaders: ['url-loader'], - }, - { - test: /\.(css|scss)$/, - loaders: ['style-loader', 'css-loader', 'sass-loader'], - }, - ], - }, - - node: { - // Don't replace built-in globals - __filename: false, - __dirname: false, - }, - - watchOptions: { - ignored: [/node_modules/], - }, -}; diff --git a/src/core_plugins/interpreter/common/constants.js b/src/core_plugins/interpreter/common/constants.js deleted file mode 100644 index a5751ee72e826..0000000000000 --- a/src/core_plugins/interpreter/common/constants.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -export const SECURITY_AUTH_MESSAGE = 'Authentication failed'; -export const API_ROUTE = '/api/canvas'; diff --git a/src/core_plugins/interpreter/index.js b/src/core_plugins/interpreter/index.js deleted file mode 100644 index 273c8b8c37957..0000000000000 --- a/src/core_plugins/interpreter/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { resolve } from 'path'; -import init from './init'; -import { pathsRegistry } from '@kbn/interpreter/common/lib/paths_registry'; -import { pluginPaths } from './plugin_paths'; - -export default function (kibana) { - return new kibana.Plugin({ - id: 'interpreter', - require: ['kibana', 'elasticsearch'], - publicDir: resolve(__dirname, 'public'), - uiExports: { - hacks: [ - 'plugins/interpreter/load_browser_plugins.js', - ], - }, - preInit: () => { - pathsRegistry.registerAll(pluginPaths); - }, - init, - }); -} - diff --git a/src/core_plugins/interpreter/init.js b/src/core_plugins/interpreter/init.js deleted file mode 100644 index 58385973ac930..0000000000000 --- a/src/core_plugins/interpreter/init.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { routes } from './server/routes'; -import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; -import { populateServerRegistries } from '@kbn/interpreter/server/server_registries'; - -export default function (server /*options*/) { - server.injectUiAppVars('canvas', () => { - const config = server.config(); - const basePath = config.get('server.basePath'); - const reportingBrowserType = config.get('xpack.reporting.capture.browser.type'); - - return { - kbnIndex: config.get('kibana.index'), - esShardTimeout: config.get('elasticsearch.shardTimeout'), - esApiVersion: config.get('elasticsearch.apiVersion'), - serverFunctions: functionsRegistry.toArray(), - basePath, - reportingBrowserType, - }; - }); - - populateServerRegistries(['serverFunctions', 'types']).then(() => routes(server)); -} diff --git a/src/core_plugins/interpreter/package.json b/src/core_plugins/interpreter/package.json deleted file mode 100644 index 3265dadd7fbfc..0000000000000 --- a/src/core_plugins/interpreter/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "interpreter", - "version": "kibana" -} diff --git a/src/core_plugins/interpreter/plugin_paths.js b/src/core_plugins/interpreter/plugin_paths.js deleted file mode 100644 index ca44ce1a1f7b2..0000000000000 --- a/src/core_plugins/interpreter/plugin_paths.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 { resolve } from 'path'; - -const dir = resolve(__dirname, '..', '..', '..'); - -export const pluginPaths = { - commonFunctions: resolve(dir, 'node_modules/@kbn/interpreter/plugin/functions/common'), - types: resolve(dir, 'node_modules/@kbn/interpreter/plugin/types'), -}; diff --git a/src/core_plugins/interpreter/public/load_browser_plugins.js b/src/core_plugins/interpreter/public/load_browser_plugins.js deleted file mode 100644 index 6322e8e340e45..0000000000000 --- a/src/core_plugins/interpreter/public/load_browser_plugins.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 { populateBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; -import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; -import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; - -const types = { - commonFunctions: functionsRegistry, - browserFunctions: functionsRegistry, - types: typesRegistry -}; - -populateBrowserRegistries(types); diff --git a/src/core_plugins/interpreter/server/lib/feature_check.js b/src/core_plugins/interpreter/server/lib/feature_check.js deleted file mode 100644 index 9f7a8993fa3ff..0000000000000 --- a/src/core_plugins/interpreter/server/lib/feature_check.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -// TODO: replace this when we use the method exposed by security https://github.com/elastic/kibana/pull/24616 -export const isSecurityEnabled = server => { - const kibanaSecurity = server.plugins.security; - const esSecurity = server.plugins.xpack_main.info.feature('security'); - - return kibanaSecurity && esSecurity.isAvailable() && esSecurity.isEnabled(); -}; diff --git a/src/core_plugins/interpreter/server/lib/get_plugin_stream.js b/src/core_plugins/interpreter/server/lib/get_plugin_stream.js deleted file mode 100644 index d685d365d31a4..0000000000000 --- a/src/core_plugins/interpreter/server/lib/get_plugin_stream.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 fs from 'fs'; -import ss from 'stream-stream'; -import { getPluginPaths } from '@kbn/interpreter/server/get_plugin_paths'; - -export const getPluginStream = type => { - const stream = ss({ - separator: '\n', - }); - - getPluginPaths(type).then(files => { - files.forEach(file => { - stream.write(fs.createReadStream(file)); - }); - stream.end(); - }); - - return stream; -}; diff --git a/src/core_plugins/interpreter/server/lib/get_request.js b/src/core_plugins/interpreter/server/lib/get_request.js deleted file mode 100644 index 2b29b05fd07aa..0000000000000 --- a/src/core_plugins/interpreter/server/lib/get_request.js +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 boom from 'boom'; -import { API_ROUTE } from '../../common/constants'; - -export function getRequest(server, { headers }) { - const url = `${API_ROUTE}/ping`; - - return server - .inject({ - method: 'POST', - url, - headers, - }) - .then(res => { - if (res.statusCode !== 200) { - if (process.env.NODE_ENV !== 'production') { - console.error( - new Error(`Auth request failed: [${res.statusCode}] ${res.result.message}`) - ); - } - throw boom.unauthorized('Failed to authenticate socket connection'); - } - - return res.request; - }); -} diff --git a/src/core_plugins/interpreter/server/lib/route_expression/server.js b/src/core_plugins/interpreter/server/lib/route_expression/server.js deleted file mode 100644 index 50a80a1e0275a..0000000000000 --- a/src/core_plugins/interpreter/server/lib/route_expression/server.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 { getServerRegistries } from '@kbn/interpreter/server/server_registries'; -import { interpretProvider } from '@kbn/interpreter/common/interpreter/interpret'; -import { createHandlers } from '../create_handlers'; - -export const server = async ({ onFunctionNotFound, server, request }) => { - const { serverFunctions, types } = await getServerRegistries(['serverFunctions', 'types']); - - return { - interpret: (ast, context) => { - const interpret = interpretProvider({ - types: types.toJS(), - functions: serverFunctions.toJS(), - handlers: createHandlers(request, server), - onFunctionNotFound, - }); - - return interpret(ast, context); - }, - getFunctions: () => Object.keys(serverFunctions.toJS()), - }; -}; diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js b/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js deleted file mode 100644 index 2a19ef81d135e..0000000000000 --- a/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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('babel-register')({ - ignore: [ - // stolen from kibana/src/setup_node_env/babel_register/register.js - // ignore paths matching `/node_modules/{a}/{b}`, unless `a` - // is `x-pack` and `b` is not `node_modules` - /\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, - ], - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/node_preset')], -}); - -require('./polyfill'); -require('./worker'); diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js b/src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js deleted file mode 100644 index 476777b4bc693..0000000000000 --- a/src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ - -// taken from kibana/src/setup_node_env/babel_register/polyfill.js -// ... -// `babel-preset-env` looks for and rewrites the following import -// statement into a list of import statements based on the polyfills -// necessary for our target environment (the current version of node) -// but since it does that during compilation, `import 'babel-polyfill'` -// must be in a file that is loaded with `require()` AFTER `babel-register` -// is configured. -// -// This is why we have this single statement in it's own file and require -// it from ./babeled.js -import 'babel-polyfill'; diff --git a/src/core_plugins/interpreter/server/routes/index.js b/src/core_plugins/interpreter/server/routes/index.js deleted file mode 100644 index f78baf4ad496d..0000000000000 --- a/src/core_plugins/interpreter/server/routes/index.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 { socketApi } from './socket'; -import { translate } from './translate'; -import { plugins } from './plugins'; - -export function routes(server) { - plugins(server); - socketApi(server); - translate(server); -} diff --git a/src/core_plugins/interpreter/server/routes/plugins.js b/src/core_plugins/interpreter/server/routes/plugins.js deleted file mode 100644 index 3d8c8614cc107..0000000000000 --- a/src/core_plugins/interpreter/server/routes/plugins.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 { getPluginStream } from '../lib/get_plugin_stream'; - -export function plugins(server) { - server.route({ - method: 'GET', - path: '/api/canvas/plugins', - handler: function (request) { - const { type } = request.query; - - return getPluginStream(type); - }, - config: { - auth: false, - }, - }); -} diff --git a/src/core_plugins/interpreter/server/routes/translate.js b/src/core_plugins/interpreter/server/routes/translate.js deleted file mode 100644 index 865c0da3e0617..0000000000000 --- a/src/core_plugins/interpreter/server/routes/translate.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; - -export function translate(server) { - /* - Get AST from expression - */ - server.route({ - method: 'GET', - path: '/api/canvas/ast', - handler: function (request, h) { - if (!request.query.expression) { - return h.response({ error: '"expression" query is required' }).code(400); - } - return fromExpression(request.query.expression); - }, - }); - - server.route({ - method: 'POST', - path: '/api/canvas/expression', - handler: function (request, h) { - try { - return toExpression(request.payload); - } catch (e) { - return h.response({ error: e.message }).code(400); - } - }, - }); -} diff --git a/src/optimize/base_optimizer.js b/src/optimize/base_optimizer.js index 1bf29fbac1d9d..b0fe947f56920 100644 --- a/src/optimize/base_optimizer.js +++ b/src/optimize/base_optimizer.js @@ -150,9 +150,8 @@ export default class BaseOptimizer { }, { test, - include: /[\/\\]node_modules[\/\\](x-pack|@kbn[\/\\]interpreter)[\/\\]/, - exclude: /[\/\\]node_modules[\/\\](x-pack|@kbn[\/\\]interpreter)[\/\\]node_modules[\/\\]/, - + include: /[\/\\]node_modules[\/\\]x-pack[\/\\]/, + exclude: /[\/\\]node_modules[\/\\]x-pack[\/\\](.+?[\/\\])*node_modules[\/\\]/, } ]; }; diff --git a/src/setup_node_env/babel_register/register.js b/src/setup_node_env/babel_register/register.js index 17dd7f0705df1..8c49c624f4894 100644 --- a/src/setup_node_env/babel_register/register.js +++ b/src/setup_node_env/babel_register/register.js @@ -38,11 +38,11 @@ var ignore = [ // https://github.com/elastic/kibana/issues/14800#issuecomment-366130268 // ignore paths matching `/node_modules/{a}/{b}`, unless `a` - // is `x-pack` or `@kbn/interpreter` and `b` is not `node_modules` - /\/node_modules\/(?!(x-pack\/|@kbn\/interpreter\/)(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, + // is `x-pack` or `b` is not `node_modules` + /\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, // ignore paths matching `/canvas/canvas_plugin/{a}/{b}` unless - // `a` is `functions` and `b` is `server` + // is `x-pack` and `b` is not `node_modules` /\/canvas\/canvas_plugin\/(?!functions\/server)([^\/]+\/[^\/]+)/, ]; diff --git a/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_integration.js b/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_integration.js index 1c8ade94456d0..34415cb6aeef5 100644 --- a/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_integration.js +++ b/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_integration.js @@ -201,4 +201,4 @@ describe('createOrUpgradeSavedConfig()', () => { '5.4.0-rc1': true, }); }); -}); +}); \ No newline at end of file diff --git a/x-pack/package.json b/x-pack/package.json index ec99e4858af6b..02a59ea7ff3bc 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -126,7 +126,6 @@ "@kbn/datemath": "5.0.0", "@kbn/i18n": "1.0.0", "@kbn/ui-framework": "1.0.0", - "@kbn/interpreter": "1.0.0", "@samverschueren/stream-to-observable": "^0.3.0", "@scant/router": "^0.1.0", "@slack/client": "^4.2.2", diff --git a/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js b/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js index 6ca97f159a1d5..433b5ec64b753 100644 --- a/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js +++ b/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Fn } from '@kbn/interpreter/common/lib/fn'; +import { Fn } from '../../common/lib/fn'; import { functions as browserFns } from '../../canvas_plugin_src/functions/browser'; import { functions as commonFns } from '../../canvas_plugin_src/functions/common'; import { functions as serverFns } from '../../canvas_plugin_src/functions/server/src'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js index fcda50653380c..c85cc9e0d5baf 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '../../../common/lib/get_type'; export const asFn = () => ({ name: 'as', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clog.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clog.js new file mode 100644 index 0000000000000..db4cc4179762f --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clog.js @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const clog = () => ({ + name: 'clog', + help: 'Outputs the context to the console', + fn: context => { + console.log(context); //eslint-disable-line no-console + return context; + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/index.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/index.js index f20c78bb1fa07..410dbc60db952 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/index.js @@ -11,6 +11,7 @@ import { asFn } from './as'; import { axisConfig } from './axisConfig'; import { compare } from './compare'; import { containerStyle } from './containerStyle'; +import { clog } from './clog'; import { context } from './context'; import { columns } from './columns'; import { csv } from './csv'; @@ -64,6 +65,7 @@ export const functions = [ any, asFn, axisConfig, + clog, columns, compare, containerStyle, diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js index c02c6a2d2691b..db55780205296 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '../../../common/lib/get_type'; export const mapColumn = () => ({ name: 'mapColumn', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js index ce4b9170d1710..1a8ee7daf7370 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js @@ -5,7 +5,7 @@ */ import { get, map } from 'lodash'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '../../../../common/lib/get_type'; export const getFlotAxisConfig = (axis, argValue, { columns, ticks, font } = {}) => { if (!argValue || argValue.show === false) return { show: false }; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js index b144cf179652d..77580be49719a 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '../../../common/lib/get_type'; export const staticColumn = () => ({ name: 'staticColumn', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js index 04f92bc475256..863fa41a90be5 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js @@ -7,7 +7,7 @@ import ReactDOM from 'react-dom'; import React from 'react'; import { get } from 'lodash'; -import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression, toExpression } from '../../../common/lib/ast'; import { DropdownFilter } from './component'; export const dropdownFilter = () => ({ diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js index 7ace73bc430d5..d04a8f0b54d96 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js @@ -7,7 +7,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { get } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression } from '../../../../../common/lib/ast'; import { TimePicker } from '../time_picker'; import { TimePickerMini } from '../time_picker_mini'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js index 2ffc7bcf44208..cdc4f563e1340 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js @@ -7,7 +7,7 @@ import ReactDOM from 'react-dom'; import React from 'react'; import { get, set } from 'lodash'; -import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression, toExpression } from '../../../common/lib/ast'; import { TimeFilter } from './components/time_filter'; export const timeFilter = () => ({ diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/boolean.js b/x-pack/plugins/canvas/canvas_plugin_src/types/boolean.js new file mode 100644 index 0000000000000..697277a471fea --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const boolean = () => ({ + name: 'boolean', + from: { + null: () => false, + number: n => Boolean(n), + string: s => Boolean(s), + }, + to: { + render: value => { + const text = `${value}`; + return { + type: 'render', + as: 'text', + value: { text }, + }; + }, + datatable: value => ({ + type: 'datatable', + columns: [{ name: 'value', type: 'boolean' }], + rows: [{ value }], + }), + }, +}); diff --git a/packages/kbn-interpreter/plugin_src/types/datatable.js b/x-pack/plugins/canvas/canvas_plugin_src/types/datatable.js similarity index 63% rename from packages/kbn-interpreter/plugin_src/types/datatable.js rename to x-pack/plugins/canvas/canvas_plugin_src/types/datatable.js index 92bd2c9b1b59e..cfe75605f1ebf 100644 --- a/packages/kbn-interpreter/plugin_src/types/datatable.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/datatable.js @@ -1,20 +1,7 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import { map, zipObject } from 'lodash'; @@ -23,9 +10,8 @@ export const datatable = () => ({ name: 'datatable', validate: datatable => { // TODO: Check columns types. Only string, boolean, number, date, allowed for now. - if (!datatable.columns) { + if (!datatable.columns) throw new Error('datatable must have a columns array, even if it is empty'); - } if (!datatable.rows) throw new Error('datatable must have a rows array, even if it is empty'); }, diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/error.js b/x-pack/plugins/canvas/canvas_plugin_src/types/error.js new file mode 100644 index 0000000000000..51051c804db56 --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/error.js @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const error = () => ({ + name: 'error', + to: { + render: input => { + const { error, info } = input; + return { + type: 'render', + as: 'error', + value: { + error, + info, + }, + }; + }, + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/filter.js b/x-pack/plugins/canvas/canvas_plugin_src/types/filter.js new file mode 100644 index 0000000000000..8627dd20bb89f --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/filter.js @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const filter = () => ({ + name: 'filter', + from: { + null: () => { + return { + type: 'filter', + // Any meta data you wish to pass along. + meta: {}, + // And filters. If you need an "or", create a filter type for it. + and: [], + }; + }, + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/image.js b/x-pack/plugins/canvas/canvas_plugin_src/types/image.js new file mode 100644 index 0000000000000..f63d3f1b8b2aa --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/image.js @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const image = () => ({ + name: 'image', + to: { + render: input => { + return { + type: 'render', + as: 'image', + value: input, + }; + }, + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/index.js b/x-pack/plugins/canvas/canvas_plugin_src/types/index.js new file mode 100644 index 0000000000000..2e9a4fa02ef8e --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/index.js @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { boolean } from './boolean'; +import { datatable } from './datatable'; +import { error } from './error'; +import { filter } from './filter'; +import { image } from './image'; +import { nullType } from './null'; +import { number } from './number'; +import { pointseries } from './pointseries'; +import { render } from './render'; +import { shape } from './shape'; +import { string } from './string'; +import { style } from './style'; + +export const typeSpecs = [ + boolean, + datatable, + error, + filter, + image, + number, + nullType, + pointseries, + render, + shape, + string, + style, +]; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/null.js b/x-pack/plugins/canvas/canvas_plugin_src/types/null.js new file mode 100644 index 0000000000000..27e9cdf59b004 --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/null.js @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const nullType = () => ({ + name: 'null', + from: { + '*': () => null, + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/number.js b/x-pack/plugins/canvas/canvas_plugin_src/types/number.js new file mode 100644 index 0000000000000..63ee587075fdd --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/number.js @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const number = () => ({ + name: 'number', + from: { + null: () => 0, + boolean: b => Number(b), + string: n => Number(n), + }, + to: { + render: value => { + const text = `${value}`; + return { + type: 'render', + as: 'text', + value: { text }, + }; + }, + datatable: value => ({ + type: 'datatable', + columns: [{ name: 'value', type: 'number' }], + rows: [{ value }], + }), + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/pointseries.js b/x-pack/plugins/canvas/canvas_plugin_src/types/pointseries.js new file mode 100644 index 0000000000000..1a00738620050 --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/pointseries.js @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const pointseries = () => ({ + name: 'pointseries', + from: { + null: () => { + return { + type: 'pointseries', + rows: [], + columns: [], + }; + }, + }, + to: { + render: (pointseries, types) => { + const datatable = types.datatable.from(pointseries, types); + return { + type: 'render', + as: 'table', + value: { + datatable, + showHeader: true, + }, + }; + }, + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/register.js b/x-pack/plugins/canvas/canvas_plugin_src/types/register.js new file mode 100644 index 0000000000000..e960dd0f6566a --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/register.js @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import 'babel-polyfill'; +import { typeSpecs } from './index'; + +typeSpecs.forEach(canvas.register); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/render.js b/x-pack/plugins/canvas/canvas_plugin_src/types/render.js new file mode 100644 index 0000000000000..0f261f0398816 --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/render.js @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const render = () => ({ + name: 'render', + from: { + '*': v => ({ + type: 'render', + as: 'debug', + value: v, + }), + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/shape.js b/x-pack/plugins/canvas/canvas_plugin_src/types/shape.js new file mode 100644 index 0000000000000..1b306b7b1c391 --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/shape.js @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const shape = () => ({ + name: 'shape', + to: { + render: input => { + return { + type: 'render', + as: 'shape', + value: input, + }; + }, + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/string.js b/x-pack/plugins/canvas/canvas_plugin_src/types/string.js new file mode 100644 index 0000000000000..c8d58aaaffbca --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/string.js @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const string = () => ({ + name: 'string', + from: { + null: () => '', + boolean: b => String(b), + number: n => String(n), + }, + to: { + render: text => { + return { + type: 'render', + as: 'text', + value: { text }, + }; + }, + datatable: value => ({ + type: 'datatable', + columns: [{ name: 'value', type: 'string' }], + rows: [{ value }], + }), + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/types/style.js b/x-pack/plugins/canvas/canvas_plugin_src/types/style.js new file mode 100644 index 0000000000000..62632c03231ad --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/types/style.js @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const style = () => ({ + name: 'style', + from: { + null: () => { + return { + type: 'style', + spec: {}, + css: '', + }; + }, + }, +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js index 64a426a84a7cd..0540a14603460 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js @@ -9,8 +9,8 @@ import { compose, withPropsOnChange, withHandlers } from 'recompose'; import PropTypes from 'prop-types'; import { EuiSelect, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { sortBy } from 'lodash'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; import { createStatefulPropHoc } from '../../../../public/components/enhance/stateful_prop'; +import { getType } from '../../../../common/lib/get_type'; import { templateFromReactComponent } from '../../../../public/lib/template_from_react_component'; import { SimpleMathFunction } from './simple_math_function'; import { getFormObject } from './get_form_object'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js index fc0f89692f646..e0f8e56df8b6f 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js @@ -7,8 +7,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import { get } from 'lodash'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; import { PalettePicker } from '../../../public/components/palette_picker'; +import { getType } from '../../../common/lib/get_type'; import { templateFromReactComponent } from '../../../public/lib/template_from_react_component'; const PaletteArgInput = ({ onValueChange, argValue, renderError }) => { diff --git a/x-pack/plugins/canvas/common/functions/to.js b/x-pack/plugins/canvas/common/functions/to.js index 25446b2868652..6f15569c27a11 100644 --- a/x-pack/plugins/canvas/common/functions/to.js +++ b/x-pack/plugins/canvas/common/functions/to.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { castProvider } from '@kbn/interpreter/common/interpreter/cast'; +import { castProvider } from '../interpreter/cast'; export const to = () => ({ name: 'to', diff --git a/packages/kbn-interpreter/common/interpreter/cast.js b/x-pack/plugins/canvas/common/interpreter/cast.js similarity index 53% rename from packages/kbn-interpreter/common/interpreter/cast.js rename to x-pack/plugins/canvas/common/interpreter/cast.js index cc257a7dc55e0..7e559afcba40e 100644 --- a/packages/kbn-interpreter/common/interpreter/cast.js +++ b/x-pack/plugins/canvas/common/interpreter/cast.js @@ -1,20 +1,7 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import { getType } from '../lib/get_type'; @@ -32,9 +19,8 @@ export function castProvider(types) { for (let i = 0; i < toTypeNames.length; i++) { // First check if the current type can cast to this type - if (fromTypeDef && fromTypeDef.castsTo(toTypeNames[i])) { + if (fromTypeDef && fromTypeDef.castsTo(toTypeNames[i])) return fromTypeDef.to(node, toTypeNames[i], types); - } // If that isn't possible, check if this type can cast from the current type const toTypeDef = types[toTypeNames[i]]; diff --git a/x-pack/plugins/canvas/common/interpreter/create_error.js b/x-pack/plugins/canvas/common/interpreter/create_error.js new file mode 100644 index 0000000000000..5de9819330dbd --- /dev/null +++ b/x-pack/plugins/canvas/common/interpreter/create_error.js @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const createError = err => ({ + type: 'error', + error: { + stack: process.env.NODE_ENV === 'production' ? undefined : err.stack, + message: typeof err === 'string' ? err : err.message, + }, +}); diff --git a/packages/kbn-interpreter/common/interpreter/interpret.js b/x-pack/plugins/canvas/common/interpreter/interpret.js similarity index 88% rename from packages/kbn-interpreter/common/interpreter/interpret.js rename to x-pack/plugins/canvas/common/interpreter/interpret.js index d2a786cd3c85d..ff7a2547f236f 100644 --- a/packages/kbn-interpreter/common/interpreter/interpret.js +++ b/x-pack/plugins/canvas/common/interpreter/interpret.js @@ -1,20 +1,7 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import clone from 'lodash.clone'; @@ -125,9 +112,8 @@ export function interpretProvider(config) { (argAsts, argAst, argName) => { const argDef = getByAlias(argDefs, argName); // TODO: Implement a system to allow for undeclared arguments - if (!argDef) { + if (!argDef) throw new Error(`Unknown argument '${argName}' passed to function '${fnDef.name}'`); - } argAsts[argDef.name] = (argAsts[argDef.name] || []).concat(argAst); return argAsts; @@ -156,9 +142,8 @@ export function interpretProvider(config) { const argAstsWithDefaults = reduce( argDefs, (argAsts, argDef, argName) => { - if (typeof argAsts[argName] === 'undefined' && typeof argDef.default !== 'undefined') { + if (typeof argAsts[argName] === 'undefined' && typeof argDef.default !== 'undefined') argAsts[argName] = [fromExpression(argDef.default, 'argument')]; - } return argAsts; }, diff --git a/packages/kbn-interpreter/common/interpreter/socket_interpret.js b/x-pack/plugins/canvas/common/interpreter/socket_interpret.js similarity index 72% rename from packages/kbn-interpreter/common/interpreter/socket_interpret.js rename to x-pack/plugins/canvas/common/interpreter/socket_interpret.js index 1ea95e0f5f6f1..c8d5acf4fdd52 100644 --- a/packages/kbn-interpreter/common/interpreter/socket_interpret.js +++ b/x-pack/plugins/canvas/common/interpreter/socket_interpret.js @@ -1,20 +1,7 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import uuid from 'uuid/v4'; @@ -53,9 +40,8 @@ export function socketInterpreterProvider({ // Get the list of functions that are known elsewhere return Promise.resolve(referableFunctions).then(referableFunctionMap => { // Check if the not-found function is in the list of alternatives, if not, throw - if (!getByAlias(referableFunctionMap, functionName)) { + if (!getByAlias(referableFunctionMap, functionName)) throw new Error(`Function not found: ${functionName}`); - } // set a unique message ID so the code knows what response to process const id = uuid(); diff --git a/x-pack/plugins/canvas/common/lib/__tests__/arg.js b/x-pack/plugins/canvas/common/lib/__tests__/arg.js new file mode 100644 index 0000000000000..f8badc67175ac --- /dev/null +++ b/x-pack/plugins/canvas/common/lib/__tests__/arg.js @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from 'expect.js'; +import { Arg } from '../arg'; + +describe('Arg', () => { + it('sets required to false by default', () => { + const isOptional = new Arg({ + name: 'optional_me', + }); + expect(isOptional.required).to.equal(false); + + const isRequired = new Arg({ + name: 'require_me', + required: true, + }); + expect(isRequired.required).to.equal(true); + }); +}); diff --git a/packages/kbn-interpreter/common/lib/ast.from_expression.test.js b/x-pack/plugins/canvas/common/lib/__tests__/ast.from_expression.js similarity index 59% rename from packages/kbn-interpreter/common/lib/ast.from_expression.test.js rename to x-pack/plugins/canvas/common/lib/__tests__/ast.from_expression.js index c144770f94c54..631973247dc6c 100644 --- a/packages/kbn-interpreter/common/lib/ast.from_expression.test.js +++ b/x-pack/plugins/canvas/common/lib/__tests__/ast.from_expression.js @@ -1,47 +1,35 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ -import { fromExpression } from './ast'; -import { getType } from './get_type'; +import expect from 'expect.js'; +import { fromExpression } from '../ast'; +import { getType } from '../../lib/get_type'; describe('ast fromExpression', () => { describe('invalid expression', () => { it('throws when empty', () => { const check = () => fromExpression(''); - expect(check).toThrowError(/Unable to parse expression/i); + expect(check).to.throwException(/Unable to parse expression/i); }); it('throws with invalid expression', () => { const check = () => fromExpression('wat!'); - expect(check).toThrowError(/Unable to parse expression/i); + expect(check).to.throwException(/Unable to parse expression/i); }); }); describe('single item expression', () => { it('is a chain', () => { const expression = 'whatever'; - expect(fromExpression(expression)).toHaveProperty('chain'); + expect(fromExpression(expression)).to.have.property('chain'); }); it('is a value', () => { const expression = '"hello"'; - expect(fromExpression(expression, 'argument')).toBe('hello'); + expect(fromExpression(expression, 'argument')).to.equal('hello'); }); describe('function without arguments', () => { @@ -56,15 +44,15 @@ describe('ast fromExpression', () => { }); it('is a function ', () => { - expect(getType(block)).toBe('function'); + expect(getType(block)).to.equal('function'); }); it('is csv function', () => { - expect(block.function).toBe('csv'); + expect(block.function).to.equal('csv'); }); it('has no arguments', () => { - expect(block.arguments).toEqual({}); + expect(block.arguments).to.eql({}); }); }); @@ -80,17 +68,17 @@ describe('ast fromExpression', () => { }); it('has arguemnts properties', () => { - expect(block.arguments).not.toEqual({}); + expect(block.arguments).not.to.eql({}); }); it('has index argument with string value', () => { - expect(block.arguments).toHaveProperty('index'); - expect(block.arguments.index).toEqual(['logstash-*']); + expect(block.arguments).to.have.property('index'); + expect(block.arguments.index).to.eql(['logstash-*']); }); it('has oranges argument with string value', () => { - expect(block.arguments).toHaveProperty('oranges'); - expect(block.arguments.oranges).toEqual(['bananas']); + expect(block.arguments).to.have.property('oranges'); + expect(block.arguments.oranges).to.eql(['bananas']); }); }); @@ -106,12 +94,12 @@ describe('ast fromExpression', () => { }); it('is expression type', () => { - expect(block.arguments).toHaveProperty('exampleFunction'); - expect(block.arguments.exampleFunction[0]).toHaveProperty('type'); + expect(block.arguments).to.have.property('exampleFunction'); + expect(block.arguments.exampleFunction[0]).to.have.property('type', 'expression'); }); it('has expected shape', () => { - expect(block.arguments.exampleFunction).toEqual([ + expect(block.arguments.exampleFunction).to.eql([ { type: 'expression', chain: [ @@ -140,12 +128,12 @@ describe('ast fromExpression', () => { }); it('is expression type', () => { - expect(block.arguments).toHaveProperty('examplePartial'); - expect(block.arguments.examplePartial[0]).toHaveProperty('type'); + expect(block.arguments).to.have.property('examplePartial'); + expect(block.arguments.examplePartial[0]).to.have.property('type', 'expression'); }); it('has expected shape', () => { - expect(block.arguments.examplePartial).toEqual([ + expect(block.arguments.examplePartial).to.eql([ { type: 'expression', chain: [ diff --git a/packages/kbn-interpreter/common/lib/ast.to_expression.test.js b/x-pack/plugins/canvas/common/lib/__tests__/ast.to_expression.js similarity index 83% rename from packages/kbn-interpreter/common/lib/ast.to_expression.test.js rename to x-pack/plugins/canvas/common/lib/__tests__/ast.to_expression.js index 455b12f583f30..4b5985832e6ab 100644 --- a/packages/kbn-interpreter/common/lib/ast.to_expression.test.js +++ b/x-pack/plugins/canvas/common/lib/__tests__/ast.to_expression.js @@ -1,39 +1,18 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ -import { toExpression } from './ast'; +import expect from 'expect.js'; +import { toExpression } from '../ast'; describe('ast toExpression', () => { describe('single expression', () => { - it('throws if no type included', () => { - const errMsg = 'Objects must have a type property'; - const astObject = { hello: 'world' }; - expect(() => toExpression(astObject)).toThrowError(errMsg); - }); - it('throws if not correct type', () => { const errMsg = 'Expression must be an expression or argument function'; - const astObject = { - type: 'hi', - hello: 'world', - }; - expect(() => toExpression(astObject)).toThrowError(errMsg); + const astObject = { hello: 'world' }; + expect(() => toExpression(astObject)).to.throwException(errMsg); }); it('throws if expression without chain', () => { @@ -42,7 +21,7 @@ describe('ast toExpression', () => { type: 'expression', hello: 'world', }; - expect(() => toExpression(astObject)).toThrowError(errMsg); + expect(() => toExpression(astObject)).to.throwException(errMsg); }); it('throws if arguments type is invalid', () => { @@ -50,7 +29,7 @@ describe('ast toExpression', () => { const invalidTypes = [null, []]; function validate(obj) { - expect(() => toExpression(obj)).toThrowError(errMsg); + expect(() => toExpression(obj)).to.throwException(errMsg); } for (let i = 0; i < invalidTypes.length; i++) { @@ -77,12 +56,12 @@ describe('ast toExpression', () => { function: 'pointseries', arguments: null, }; - expect(() => toExpression(astObject)).toThrowError(errMsg); + expect(() => toExpression(astObject)).to.throwException(errMsg); }); it('throws on invalid argument type', () => { const argType = '__invalid__wat__'; - const errMsg = `Invalid argument type in AST: ${argType}`; + const errMsg = `invalid argument type: ${argType}`; const astObject = { type: 'expression', chain: [ @@ -101,7 +80,7 @@ describe('ast toExpression', () => { ], }; - expect(() => toExpression(astObject)).toThrowError(errMsg); + expect(() => toExpression(astObject)).to.throwException(errMsg); }); it('throws on expressions without chains', () => { @@ -125,7 +104,7 @@ describe('ast toExpression', () => { ], }; - expect(() => toExpression(astObject)).toThrowError(errMsg); + expect(() => toExpression(astObject)).to.throwException(errMsg); }); it('throws on nameless functions and partials', () => { @@ -141,7 +120,7 @@ describe('ast toExpression', () => { ], }; - expect(() => toExpression(astObject)).toThrowError(errMsg); + expect(() => toExpression(astObject)).to.throwException(errMsg); }); it('single expression', () => { @@ -157,7 +136,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('csv'); + expect(expression).to.equal('csv'); }); it('single expression with string argument', () => { @@ -175,7 +154,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('csv input="stuff\nthings"'); + expect(expression).to.equal('csv input="stuff\nthings"'); }); it('single expression string value with a backslash', () => { @@ -193,7 +172,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('csv input="slash \\\\\\\\ slash"'); + expect(expression).to.equal('csv input="slash \\\\\\\\ slash"'); }); it('single expression string value with a double quote', () => { @@ -211,7 +190,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('csv input="stuff\nthings\n\\"such\\""'); + expect(expression).to.equal('csv input="stuff\nthings\n\\"such\\""'); }); it('single expression with number argument', () => { @@ -229,7 +208,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('series input=1234'); + expect(expression).to.equal('series input=1234'); }); it('single expression with boolean argument', () => { @@ -247,7 +226,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('series input=true'); + expect(expression).to.equal('series input=true'); }); it('single expression with null argument', () => { @@ -265,7 +244,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('series input=null'); + expect(expression).to.equal('series input=null'); }); it('single expression with multiple arguments', () => { @@ -284,7 +263,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('csv input="stuff\nthings" separator="\\\\n"'); + expect(expression).to.equal('csv input="stuff\nthings" separator="\\\\n"'); }); it('single expression with multiple and repeated arguments', () => { @@ -303,12 +282,12 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe( + expect(expression).to.equal( 'csv input="stuff\nthings" input="more,things\nmore,stuff" separator="\\\\n"' ); }); - it('single expression with `getcalc` expression argument', () => { + it('single expression with expression argument', () => { const astObj = { type: 'expression', chain: [ @@ -335,10 +314,10 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('csv calc={getcalc} input="stuff\nthings"'); + expect(expression).to.equal('csv calc={getcalc} input="stuff\nthings"'); }); - it('single expression with `partcalc` expression argument', () => { + it('single expression with expression argument', () => { const astObj = { type: 'expression', chain: [ @@ -365,7 +344,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('csv calc={partcalc} input="stuff\nthings"'); + expect(expression).to.equal('csv calc={partcalc} input="stuff\nthings"'); }); it('single expression with expression arguments, with arguments', () => { @@ -411,7 +390,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe( + expect(expression).to.equal( 'csv sep={partcalc type="comma"} input="stuff\nthings" break={setBreak type="newline"}' ); }); @@ -489,7 +468,7 @@ describe('ast toExpression', () => { '2016,honda,fit,15890,', '2016,honda,civic,18640"\n| line x={distinct f="year"} y={sum f="price"} colors={distinct f="model"}', ]; - expect(expression).toBe(expected.join('\n')); + expect(expression).to.equal(expected.join('\n')); }); it('three chained expressions', () => { @@ -584,7 +563,7 @@ describe('ast toExpression', () => { '2016,honda,civic,18640"\n| pointseries x={distinct f="year"} y={sum f="price"} ' + 'colors={distinct f="model"}\n| line pallette={getColorPallette name="elastic"}', ]; - expect(expression).toBe(expected.join('\n')); + expect(expression).to.equal(expected.join('\n')); }); }); @@ -604,7 +583,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('list "one" "two" "three"'); + expect(expression).to.equal('list "one" "two" "three"'); }); it('named and unnamed', () => { @@ -624,7 +603,7 @@ describe('ast toExpression', () => { }; const expression = toExpression(astObj); - expect(expression).toBe('both named="example" another="item" "one" "two" "three"'); + expect(expression).to.equal('both named="example" another="item" "one" "two" "three"'); }); }); }); diff --git a/x-pack/plugins/canvas/common/lib/__tests__/get_by_alias.js b/x-pack/plugins/canvas/common/lib/__tests__/get_by_alias.js new file mode 100644 index 0000000000000..eaeeeade4cc59 --- /dev/null +++ b/x-pack/plugins/canvas/common/lib/__tests__/get_by_alias.js @@ -0,0 +1,74 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from 'expect.js'; +import { getByAlias } from '../get_by_alias'; + +describe('getByAlias', () => { + const fnsObject = { + foo: { name: 'foo', aliases: ['f'] }, + bar: { name: 'bar', aliases: ['b'] }, + }; + + const fnsArray = [{ name: 'foo', aliases: ['f'] }, { name: 'bar', aliases: ['b'] }]; + + it('returns the function by name', () => { + expect(getByAlias(fnsObject, 'foo')).to.be(fnsObject.foo); + expect(getByAlias(fnsObject, 'bar')).to.be(fnsObject.bar); + expect(getByAlias(fnsArray, 'foo')).to.be(fnsArray[0]); + expect(getByAlias(fnsArray, 'bar')).to.be(fnsArray[1]); + }); + + it('returns the function by alias', () => { + expect(getByAlias(fnsObject, 'f')).to.be(fnsObject.foo); + expect(getByAlias(fnsObject, 'b')).to.be(fnsObject.bar); + expect(getByAlias(fnsArray, 'f')).to.be(fnsArray[0]); + expect(getByAlias(fnsArray, 'b')).to.be(fnsArray[1]); + }); + + it('returns the function by case-insensitive name', () => { + expect(getByAlias(fnsObject, 'FOO')).to.be(fnsObject.foo); + expect(getByAlias(fnsObject, 'BAR')).to.be(fnsObject.bar); + expect(getByAlias(fnsArray, 'FOO')).to.be(fnsArray[0]); + expect(getByAlias(fnsArray, 'BAR')).to.be(fnsArray[1]); + }); + + it('returns the function by case-insensitive alias', () => { + expect(getByAlias(fnsObject, 'F')).to.be(fnsObject.foo); + expect(getByAlias(fnsObject, 'B')).to.be(fnsObject.bar); + expect(getByAlias(fnsArray, 'F')).to.be(fnsArray[0]); + expect(getByAlias(fnsArray, 'B')).to.be(fnsArray[1]); + }); + + it('handles empty strings', () => { + const emptyStringFnsObject = { '': { name: '' } }; + const emptyStringAliasFnsObject = { foo: { name: 'foo', aliases: [''] } }; + expect(getByAlias(emptyStringFnsObject, '')).to.be(emptyStringFnsObject['']); + expect(getByAlias(emptyStringAliasFnsObject, '')).to.be(emptyStringAliasFnsObject.foo); + + const emptyStringFnsArray = [{ name: '' }]; + const emptyStringAliasFnsArray = [{ name: 'foo', aliases: [''] }]; + expect(getByAlias(emptyStringFnsArray, '')).to.be(emptyStringFnsArray[0]); + expect(getByAlias(emptyStringAliasFnsArray, '')).to.be(emptyStringAliasFnsArray[0]); + }); + + it('handles "undefined" strings', () => { + const undefinedFnsObject = { undefined: { name: 'undefined' } }; + const undefinedAliasFnsObject = { foo: { name: 'undefined', aliases: ['undefined'] } }; + expect(getByAlias(undefinedFnsObject, 'undefined')).to.be(undefinedFnsObject.undefined); + expect(getByAlias(undefinedAliasFnsObject, 'undefined')).to.be(undefinedAliasFnsObject.foo); + + const emptyStringFnsArray = [{ name: 'undefined' }]; + const emptyStringAliasFnsArray = [{ name: 'foo', aliases: ['undefined'] }]; + expect(getByAlias(emptyStringFnsArray, 'undefined')).to.be(emptyStringFnsArray[0]); + expect(getByAlias(emptyStringAliasFnsArray, 'undefined')).to.be(emptyStringAliasFnsArray[0]); + }); + + it('returns undefined if not found', () => { + expect(getByAlias(fnsObject, 'baz')).to.be(undefined); + expect(getByAlias(fnsArray, 'baz')).to.be(undefined); + }); +}); diff --git a/packages/kbn-interpreter/common/lib/registry.test.js b/x-pack/plugins/canvas/common/lib/__tests__/registry.js similarity index 60% rename from packages/kbn-interpreter/common/lib/registry.test.js rename to x-pack/plugins/canvas/common/lib/__tests__/registry.js index dbeeb16dc1ff0..fd19bf0300417 100644 --- a/packages/kbn-interpreter/common/lib/registry.test.js +++ b/x-pack/plugins/canvas/common/lib/__tests__/registry.js @@ -1,63 +1,51 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from './registry'; +import expect from 'expect.js'; +import { Registry } from '../registry'; function validateRegistry(registry, elements) { it('gets items by lookup property', () => { - expect(registry.get('__test2')).toEqual(elements[1]()); + expect(registry.get('__test2')).to.eql(elements[1]()); }); it('ignores case when getting items', () => { - expect(registry.get('__TeSt2')).toEqual(elements[1]()); - expect(registry.get('__tESt2')).toEqual(elements[1]()); + expect(registry.get('__TeSt2')).to.eql(elements[1]()); + expect(registry.get('__tESt2')).to.eql(elements[1]()); }); it('gets a shallow clone', () => { - expect(registry.get('__test2')).not.toBe(elements[1]()); + expect(registry.get('__test2')).to.not.equal(elements[1]()); }); it('is null with no match', () => { - expect(registry.get('@@nope_nope')).toBe(null); + expect(registry.get('@@nope_nope')).to.be(null); }); it('returns shallow clone of the whole registry via toJS', () => { const regAsJs = registry.toJS(); - expect(regAsJs).toEqual({ + expect(regAsJs).to.eql({ __test1: elements[0](), __test2: elements[1](), }); - expect(regAsJs.__test1).toEqual(elements[0]()); - expect(regAsJs.__test1).not.toBe(elements[0]()); + expect(regAsJs.__test1).to.eql(elements[0]()); + expect(regAsJs.__test1).to.not.equal(elements[0]()); }); it('returns shallow clone array via toArray', () => { const regAsArray = registry.toArray(); - expect(regAsArray).toBeInstanceOf(Array); - expect(regAsArray[0]).toEqual(elements[0]()); - expect(regAsArray[0]).not.toBe(elements[0]()); + expect(regAsArray).to.be.an(Array); + expect(regAsArray[0]).to.eql(elements[0]()); + expect(regAsArray[0]).to.not.equal(elements[0]()); }); it('resets the registry', () => { - expect(registry.get('__test2')).toEqual(elements[1]()); + expect(registry.get('__test2')).to.eql(elements[1]()); registry.reset(); - expect(registry.get('__test2')).toBe(null); + expect(registry.get('__test2')).to.equal(null); }); } @@ -82,12 +70,12 @@ describe('Registry', () => { validateRegistry(registry, elements); it('has a prop of name', () => { - expect(registry.getProp()).toBe('name'); + expect(registry.getProp()).to.equal('name'); }); it('throws when object is missing the lookup prop', () => { const check = () => registry.register(() => ({ hello: 'world' })); - expect(check).toThrowError(/object with a name property/); + expect(check).to.throwException(/object with a name property/i); }); }); @@ -111,12 +99,12 @@ describe('Registry', () => { validateRegistry(registry, elements); it('has a prop of type', () => { - expect(registry.getProp()).toBe('type'); + expect(registry.getProp()).to.equal('type'); }); it('throws when object is missing the lookup prop', () => { const check = () => registry.register(() => ({ hello: 'world' })); - expect(check).toThrowError(/object with a type property/); + expect(check).to.throwException(/object with a type property/i); }); }); @@ -149,8 +137,9 @@ describe('Registry', () => { registry.register(elements[1]); it('contains wrapped elements', () => { - expect(registry.get(elements[0]().name)).toHaveProperty('__CUSTOM_PROP__'); - expect(registry.get(elements[1]().name)).toHaveProperty('__CUSTOM_PROP__'); + // test for the custom prop on the returned elements + expect(registry.get(elements[0]().name)).to.have.property('__CUSTOM_PROP__', 1); + expect(registry.get(elements[1]().name)).to.have.property('__CUSTOM_PROP__', 2); }); }); @@ -182,18 +171,20 @@ describe('Registry', () => { }); it('get contains the full prototype', () => { - expect(typeof thing().baseFunc).toBe('function'); - expect(typeof registry.get(name).baseFunc).toBe('function'); + expect(thing().baseFunc).to.be.a('function'); + expect(registry.get(name).baseFunc).to.be.a('function'); }); it('toJS contains the full prototype', () => { const val = registry.toJS(); - expect(typeof val[name].baseFunc).toBe('function'); + expect(val[name].baseFunc).to.be.a('function'); }); }); describe('throws when lookup prop is not a string', () => { const check = () => new Registry(2); - expect(check).toThrowError(/must be a string/); + expect(check).to.throwException(e => { + expect(e.message).to.be('Registry property name must be a string'); + }); }); }); diff --git a/x-pack/plugins/canvas/common/lib/arg.js b/x-pack/plugins/canvas/common/lib/arg.js new file mode 100644 index 0000000000000..7713fcb342bc2 --- /dev/null +++ b/x-pack/plugins/canvas/common/lib/arg.js @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { includes } from 'lodash'; + +export function Arg(config) { + if (config.name === '_') throw Error('Arg names must not be _. Use it in aliases instead.'); + this.name = config.name; + this.required = config.required || false; + this.help = config.help || ''; + this.types = config.types || []; + this.default = config.default; + this.aliases = config.aliases || []; + this.multi = config.multi == null ? false : config.multi; + this.resolve = config.resolve == null ? true : config.resolve; + this.options = config.options || []; + this.accepts = type => { + if (!this.types.length) return true; + return includes(config.types, type); + }; +} diff --git a/packages/kbn-interpreter/common/lib/ast.js b/x-pack/plugins/canvas/common/lib/ast.js similarity index 81% rename from packages/kbn-interpreter/common/lib/ast.js rename to x-pack/plugins/canvas/common/lib/ast.js index 61cfe94ac955c..b31848944e9db 100644 --- a/packages/kbn-interpreter/common/lib/ast.js +++ b/x-pack/plugins/canvas/common/lib/ast.js @@ -1,23 +1,10 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ -import { getType } from './get_type'; +import { getType } from '../lib/get_type'; import { parse } from './grammar'; function getArgumentString(arg, argKey, level = 0) { @@ -61,9 +48,8 @@ function getExpressionArgs(block, level = 0) { const lineLength = acc.split('\n').pop().length; // if arg values are too long, move it to the next line - if (level === 0 && lineLength + argString.length > MAX_LINE_LENGTH) { + if (level === 0 && lineLength + argString.length > MAX_LINE_LENGTH) return `${acc}\n ${argString}`; - } // append arg values to existing arg values if (lineLength > 0) return `${acc} ${argString}`; diff --git a/x-pack/plugins/canvas/common/lib/autocomplete.js b/x-pack/plugins/canvas/common/lib/autocomplete.js index 5a18c2570919b..d87e199de4671 100644 --- a/x-pack/plugins/canvas/common/lib/autocomplete.js +++ b/x-pack/plugins/canvas/common/lib/autocomplete.js @@ -5,8 +5,8 @@ */ import { uniq } from 'lodash'; -import { parse } from '@kbn/interpreter/common/lib/grammar'; -import { getByAlias } from '@kbn/interpreter/common/lib/get_by_alias'; +import { parse } from './grammar'; +import { getByAlias } from './get_by_alias'; const MARKER = 'CANVAS_SUGGESTION_MARKER'; diff --git a/packages/kbn-interpreter/common/lib/fn.js b/x-pack/plugins/canvas/common/lib/fn.js similarity index 54% rename from packages/kbn-interpreter/common/lib/fn.js rename to x-pack/plugins/canvas/common/lib/fn.js index c6b2fcbe67799..70948c76579b3 100644 --- a/packages/kbn-interpreter/common/lib/fn.js +++ b/x-pack/plugins/canvas/common/lib/fn.js @@ -1,20 +1,7 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import { mapValues, includes } from 'lodash'; diff --git a/x-pack/plugins/canvas/common/lib/functions_registry.js b/x-pack/plugins/canvas/common/lib/functions_registry.js new file mode 100644 index 0000000000000..af8e8f0b122d0 --- /dev/null +++ b/x-pack/plugins/canvas/common/lib/functions_registry.js @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Registry } from '../../common/lib/registry'; +import { Fn } from '../lib/fn'; + +class FunctionsRegistry extends Registry { + wrapper(obj) { + return new Fn(obj); + } +} + +export const functionsRegistry = new FunctionsRegistry(); diff --git a/x-pack/plugins/canvas/common/lib/get_by_alias.js b/x-pack/plugins/canvas/common/lib/get_by_alias.js new file mode 100644 index 0000000000000..c9986a5024008 --- /dev/null +++ b/x-pack/plugins/canvas/common/lib/get_by_alias.js @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +/** + * This is used for looking up function/argument definitions. It looks through + * the given object/array for a case-insensitive match, which could be either the + * `name` itself, or something under the `aliases` property. + */ +export function getByAlias(specs, name) { + const lowerCaseName = name.toLowerCase(); + return Object.values(specs).find(({ name, aliases }) => { + if (name.toLowerCase() === lowerCaseName) return true; + return (aliases || []).some(alias => { + return alias.toLowerCase() === lowerCaseName; + }); + }); +} diff --git a/x-pack/plugins/canvas/common/lib/get_type.js b/x-pack/plugins/canvas/common/lib/get_type.js new file mode 100644 index 0000000000000..8d2b5a13cb283 --- /dev/null +++ b/x-pack/plugins/canvas/common/lib/get_type.js @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export function getType(node) { + if (node == null) return 'null'; + if (typeof node === 'object') { + if (!node.type) throw new Error('Objects must have a type propery'); + return node.type; + } + + return typeof node; +} diff --git a/packages/kbn-interpreter/common/lib/grammar.js b/x-pack/plugins/canvas/common/lib/grammar.js similarity index 100% rename from packages/kbn-interpreter/common/lib/grammar.js rename to x-pack/plugins/canvas/common/lib/grammar.js diff --git a/packages/kbn-interpreter/common/lib/grammar.peg b/x-pack/plugins/canvas/common/lib/grammar.peg similarity index 100% rename from packages/kbn-interpreter/common/lib/grammar.peg rename to x-pack/plugins/canvas/common/lib/grammar.peg diff --git a/x-pack/plugins/canvas/common/lib/index.js b/x-pack/plugins/canvas/common/lib/index.js index 321a4abff44e0..5d56a5026590d 100644 --- a/x-pack/plugins/canvas/common/lib/index.js +++ b/x-pack/plugins/canvas/common/lib/index.js @@ -5,6 +5,8 @@ */ export * from './datatable'; +export * from './arg'; +export * from './ast'; export * from './autocomplete'; export * from './constants'; export * from './dataurl'; @@ -12,10 +14,15 @@ export * from './errors'; export * from './expression_form_handlers'; export * from './fetch'; export * from './find_in_object'; +export * from './fn'; export * from './fonts'; +export * from './functions_registry'; +export * from './get_by_alias'; export * from './get_colors_from_palette'; export * from './get_field_type'; export * from './get_legend_config'; +export * from './get_type'; +export * from './grammar'; export * from './handlebars'; export * from './hex_to_rgb'; export * from './httpurl'; @@ -23,6 +30,10 @@ export * from './latest_change'; export * from './missing_asset'; export * from './palettes'; export * from './pivot_object_array'; +export * from './registry'; export * from './resolve_dataurl'; +export * from './serialize'; +export * from './type'; +export * from './types_registry'; export * from './unquote_string'; export * from './url'; diff --git a/packages/kbn-interpreter/common/lib/registry.js b/x-pack/plugins/canvas/common/lib/registry.js similarity index 56% rename from packages/kbn-interpreter/common/lib/registry.js rename to x-pack/plugins/canvas/common/lib/registry.js index 9882f3abde723..accabae4bc5eb 100644 --- a/packages/kbn-interpreter/common/lib/registry.js +++ b/x-pack/plugins/canvas/common/lib/registry.js @@ -1,20 +1,7 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import clone from 'lodash.clone'; @@ -35,9 +22,8 @@ export class Registry { const obj = fn(); - if (typeof obj !== 'object' || !obj[this._prop]) { + if (typeof obj !== 'object' || !obj[this._prop]) throw new Error(`Registered functions must return an object with a ${this._prop} property`); - } this._indexed[obj[this._prop].toLowerCase()] = this.wrapper(obj); } diff --git a/x-pack/plugins/canvas/common/lib/serialize.js b/x-pack/plugins/canvas/common/lib/serialize.js new file mode 100644 index 0000000000000..0786f6f06b3a3 --- /dev/null +++ b/x-pack/plugins/canvas/common/lib/serialize.js @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { get, identity } from 'lodash'; +import { getType } from '../lib/get_type'; + +export function serializeProvider(types) { + return { + serialize: provider('serialize'), + deserialize: provider('deserialize'), + }; + + function provider(key) { + return context => { + const type = getType(context); + const typeDef = types[type]; + const fn = get(typeDef, key) || identity; + return fn(context); + }; + } +} diff --git a/packages/kbn-interpreter/common/lib/type.js b/x-pack/plugins/canvas/common/lib/type.js similarity index 61% rename from packages/kbn-interpreter/common/lib/type.js rename to x-pack/plugins/canvas/common/lib/type.js index 356b82bf91cbd..d917750e3848e 100644 --- a/packages/kbn-interpreter/common/lib/type.js +++ b/x-pack/plugins/canvas/common/lib/type.js @@ -1,25 +1,12 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ // All types must be universal and be castable on the client or on the server import { get } from 'lodash'; -import { getType } from './get_type'; +import { getType } from '../lib/get_type'; // TODO: Currently all casting functions must be syncronous. @@ -48,12 +35,10 @@ export function Type(config) { this.to = (node, toTypeName, types) => { const typeName = getType(node); - if (typeName !== this.name) { + if (typeName !== this.name) throw new Error(`Can not cast object of type '${typeName}' using '${this.name}'`); - } - else if (!this.castsTo(toTypeName)) { + else if (!this.castsTo(toTypeName)) throw new Error(`Can not cast '${typeName}' to '${toTypeName}'`); - } return getToFn(toTypeName)(node, types); }; diff --git a/x-pack/plugins/canvas/common/lib/types_registry.js b/x-pack/plugins/canvas/common/lib/types_registry.js new file mode 100644 index 0000000000000..3d2bb65e9fa0f --- /dev/null +++ b/x-pack/plugins/canvas/common/lib/types_registry.js @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Registry } from '../../common/lib/registry'; +import { Type } from '../../common/lib/type'; + +class TypesRegistry extends Registry { + wrapper(obj) { + return new Type(obj); + } +} + +export const typesRegistry = new TypesRegistry(); diff --git a/x-pack/plugins/canvas/index.js b/x-pack/plugins/canvas/index.js index 0f34eef6c2edb..b92e29341a14b 100644 --- a/x-pack/plugins/canvas/index.js +++ b/x-pack/plugins/canvas/index.js @@ -5,11 +5,9 @@ */ import { resolve } from 'path'; -import { pathsRegistry } from '@kbn/interpreter/common/lib/paths_registry'; import init from './init'; import { mappings } from './server/mappings'; import { CANVAS_APP } from './common/lib/constants'; -import { pluginPaths } from './plugin_paths'; export function canvas(kibana) { return new kibana.Plugin({ @@ -41,9 +39,6 @@ export function canvas(kibana) { }).default(); }, - preInit: () => { - pathsRegistry.registerAll(pluginPaths); - }, init, }); } diff --git a/x-pack/plugins/canvas/init.js b/x-pack/plugins/canvas/init.js index 70a8db10d7e66..1ef56fac4e97c 100644 --- a/x-pack/plugins/canvas/init.js +++ b/x-pack/plugins/canvas/init.js @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; -import { getServerRegistries } from '@kbn/interpreter/server/server_registries'; import { routes } from './server/routes'; +import { functionsRegistry } from './common/lib'; import { commonFunctions } from './common/functions'; +import { populateServerRegistries } from './server/lib/server_registries'; import { registerCanvasUsageCollector } from './server/usage'; import { loadSampleData } from './server/sample_data'; @@ -34,6 +34,6 @@ export default async function(server /*options*/) { loadSampleData(server); // Do not initialize the app until the registries are populated - await getServerRegistries(); + await populateServerRegistries(['serverFunctions', 'types']); routes(server); } diff --git a/x-pack/plugins/canvas/plugin_paths.js b/x-pack/plugins/canvas/plugin_paths.js deleted file mode 100644 index 9c9f5d1c49bde..0000000000000 --- a/x-pack/plugins/canvas/plugin_paths.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { resolve } from 'path'; - -export const pluginPaths = { - serverFunctions: resolve(__dirname, 'canvas_plugin/functions/server'), - browserFunctions: resolve(__dirname, 'canvas_plugin/functions/browser'), - commonFunctions: resolve(__dirname, 'canvas_plugin/functions/common'), - elements: resolve(__dirname, 'canvas_plugin/elements'), - renderers: resolve(__dirname, 'canvas_plugin/renderers'), - interfaces: resolve(__dirname, 'canvas_plugin/interfaces'), - transformUIs: resolve(__dirname, 'canvas_plugin/uis/transforms'), - datasourceUIs: resolve(__dirname, 'canvas_plugin/uis/datasources'), - modelUIs: resolve(__dirname, 'canvas_plugin/uis/models'), - viewUIs: resolve(__dirname, 'canvas_plugin/uis/views'), - argumentUIs: resolve(__dirname, 'canvas_plugin/uis/arguments'), -}; diff --git a/x-pack/plugins/canvas/public/components/app/index.js b/x-pack/plugins/canvas/public/components/app/index.js index b776bf59efc99..5f633169604d6 100644 --- a/x-pack/plugins/canvas/public/components/app/index.js +++ b/x-pack/plugins/canvas/public/components/app/index.js @@ -4,25 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ -import { createSocket } from '@kbn/interpreter/public/socket'; -import { initialize as initializeInterpreter } from '@kbn/interpreter/public/interpreter'; import { connect } from 'react-redux'; import { compose, withProps } from 'recompose'; -import { populateBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; +import { createSocket } from '../../socket'; +import { initialize as initializeInterpreter } from '../../lib/interpreter'; +import { populateBrowserRegistries } from '../../lib/browser_registries'; import { getAppReady, getBasePath } from '../../state/selectors/app'; import { appReady, appError } from '../../state/actions/app'; -import { loadPrivateBrowserFunctions } from '../../lib/load_private_browser_functions'; -import { elementsRegistry } from '../../lib/elements_registry'; -import { renderFunctionsRegistry } from '../../lib/render_functions_registry'; -import { - argTypeRegistry, - datasourceRegistry, - modelRegistry, - transformRegistry, - viewRegistry, -} from '../../expression_types'; -import { App as Component } from './app'; import { trackRouteChange } from './track_route_change'; +import { App as Component } from './app'; const mapStateToProps = state => { // appReady could be an error object @@ -34,24 +24,13 @@ const mapStateToProps = state => { }; }; -const types = { - elements: elementsRegistry, - renderers: renderFunctionsRegistry, - transformUIs: transformRegistry, - datasourceUIs: datasourceRegistry, - modelUIs: modelRegistry, - viewUIs: viewRegistry, - argumentUIs: argTypeRegistry, -}; - const mapDispatchToProps = dispatch => ({ // TODO: the correct socket path should come from upstream, using the constant here is not ideal setAppReady: basePath => async () => { try { // initialize the socket and interpreter await createSocket(basePath); - loadPrivateBrowserFunctions(); - await populateBrowserRegistries(types); + await populateBrowserRegistries(); await initializeInterpreter(); // set app state to ready diff --git a/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js b/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js index 13ecfe89bb922..2bd779de759d9 100644 --- a/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js +++ b/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js @@ -8,8 +8,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import { compose, withProps, withPropsOnChange } from 'recompose'; import { EuiForm, EuiTextArea, EuiButton, EuiButtonEmpty, EuiFormRow } from '@elastic/eui'; -import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; import { createStatefulPropHoc } from '../../components/enhance/stateful_prop'; +import { fromExpression, toExpression } from '../../../common/lib/ast'; export const AdvancedFailureComponent = props => { const { diff --git a/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js b/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js index f1f3fb2ddae97..8b21c38a5f6f7 100644 --- a/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js +++ b/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; import { pure, compose, lifecycle, withState, branch, renderComponent } from 'recompose'; import { PropTypes } from 'prop-types'; import { Loading } from '../../loading'; +import { interpretAst } from '../../../lib/interpreter'; import { DatasourcePreview as Component } from './datasource_preview'; export const DatasourcePreview = compose( diff --git a/x-pack/plugins/canvas/public/components/element_content/element_content.js b/x-pack/plugins/canvas/public/components/element_content/element_content.js index cb53f9efd0e63..4f9ee400940a4 100644 --- a/x-pack/plugins/canvas/public/components/element_content/element_content.js +++ b/x-pack/plugins/canvas/public/components/element_content/element_content.js @@ -8,7 +8,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { pure, compose, branch, renderComponent } from 'recompose'; import Style from 'style-it'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '../../../common/lib/get_type'; import { Loading } from '../loading'; import { RenderWithFn } from '../render_with_fn'; import { ElementShareContainer } from '../element_share_container'; diff --git a/x-pack/plugins/canvas/public/components/expression/index.js b/x-pack/plugins/canvas/public/components/expression/index.js index 81d73959e83b8..18690529d4e80 100644 --- a/x-pack/plugins/canvas/public/components/expression/index.js +++ b/x-pack/plugins/canvas/public/components/expression/index.js @@ -15,9 +15,9 @@ import { branch, renderComponent, } from 'recompose'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; import { getSelectedPage, getSelectedElement } from '../../state/selectors/workpad'; import { setExpression, flushContext } from '../../state/actions/elements'; +import { fromExpression } from '../../../common/lib/ast'; import { getFunctionDefinitions } from '../../lib/function_definitions'; import { getWindow } from '../../lib/get_window'; import { ElementNotSelected } from './element_not_selected'; diff --git a/x-pack/plugins/canvas/public/components/function_form_list/index.js b/x-pack/plugins/canvas/public/components/function_form_list/index.js index 84748f5bbbbb3..8b6702d94340f 100644 --- a/x-pack/plugins/canvas/public/components/function_form_list/index.js +++ b/x-pack/plugins/canvas/public/components/function_form_list/index.js @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; import { compose, withProps } from 'recompose'; import { get } from 'lodash'; -import { toExpression } from '@kbn/interpreter/common/lib/ast'; import { modelRegistry, viewRegistry, transformRegistry } from '../../expression_types'; +import { interpretAst } from '../../lib/interpreter'; +import { toExpression } from '../../../common/lib/ast'; import { FunctionFormList as Component } from './function_form_list'; function normalizeContext(chain) { diff --git a/x-pack/plugins/canvas/public/expression_types/arg_type.js b/x-pack/plugins/canvas/public/expression_types/arg_type.js index a19c726e138c2..76f29afee7185 100644 --- a/x-pack/plugins/canvas/public/expression_types/arg_type.js +++ b/x-pack/plugins/canvas/public/expression_types/arg_type.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '../../common/lib/registry'; import { BaseForm } from './base_form'; export class ArgType extends BaseForm { diff --git a/x-pack/plugins/canvas/public/expression_types/datasource.js b/x-pack/plugins/canvas/public/expression_types/datasource.js index cd9a8af5f0182..858be2b4e33dd 100644 --- a/x-pack/plugins/canvas/public/expression_types/datasource.js +++ b/x-pack/plugins/canvas/public/expression_types/datasource.js @@ -6,7 +6,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '../../common/lib/registry'; import { RenderToDom } from '../components/render_to_dom'; import { ExpressionFormHandlers } from '../../common/lib/expression_form_handlers'; import { BaseForm } from './base_form'; diff --git a/x-pack/plugins/canvas/public/expression_types/function_form.js b/x-pack/plugins/canvas/public/expression_types/function_form.js index c7bc16a5b2e2b..70da0004ab175 100644 --- a/x-pack/plugins/canvas/public/expression_types/function_form.js +++ b/x-pack/plugins/canvas/public/expression_types/function_form.js @@ -7,7 +7,7 @@ import { EuiCallOut } from '@elastic/eui'; import React from 'react'; import { isPlainObject, uniq, last, compact } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression } from '../../common/lib/ast'; import { ArgAddPopover } from '../components/arg_add_popover'; import { SidebarSection } from '../components/sidebar/sidebar_section'; import { SidebarSectionTitle } from '../components/sidebar/sidebar_section_title'; diff --git a/x-pack/plugins/canvas/public/expression_types/model.js b/x-pack/plugins/canvas/public/expression_types/model.js index 7ce1126bdec55..bae74d75589be 100644 --- a/x-pack/plugins/canvas/public/expression_types/model.js +++ b/x-pack/plugins/canvas/public/expression_types/model.js @@ -5,7 +5,7 @@ */ import { get, pick } from 'lodash'; -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '../../common/lib/registry'; import { FunctionForm } from './function_form'; const NO_NEXT_EXP = 'no next expression'; diff --git a/x-pack/plugins/canvas/public/expression_types/transform.js b/x-pack/plugins/canvas/public/expression_types/transform.js index 760eae46195d6..216e79b9c106c 100644 --- a/x-pack/plugins/canvas/public/expression_types/transform.js +++ b/x-pack/plugins/canvas/public/expression_types/transform.js @@ -5,7 +5,7 @@ */ import { pick } from 'lodash'; -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '../../common/lib/registry'; import { FunctionForm } from './function_form'; export class Transform extends FunctionForm { diff --git a/x-pack/plugins/canvas/public/expression_types/view.js b/x-pack/plugins/canvas/public/expression_types/view.js index 1b7fe13d508b0..ee83fe3340d76 100644 --- a/x-pack/plugins/canvas/public/expression_types/view.js +++ b/x-pack/plugins/canvas/public/expression_types/view.js @@ -5,7 +5,7 @@ */ import { pick } from 'lodash'; -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '../../common/lib/registry'; import { FunctionForm } from './function_form'; export class View extends FunctionForm { diff --git a/x-pack/plugins/canvas/public/functions/filters.js b/x-pack/plugins/canvas/public/functions/filters.js index 3c578a93fc3b6..a6f8d2a63fc5e 100644 --- a/x-pack/plugins/canvas/public/functions/filters.js +++ b/x-pack/plugins/canvas/public/functions/filters.js @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; -import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; +import { fromExpression } from '../../common/lib/ast'; +import { typesRegistry } from '../../common/lib/types_registry'; import { getState } from '../state/store'; import { getGlobalFilterExpression } from '../state/selectors/workpad'; +import { interpretAst } from '../lib/interpreter'; export const filters = () => ({ name: 'filters', diff --git a/x-pack/plugins/canvas/public/lib/arg_helpers.js b/x-pack/plugins/canvas/public/lib/arg_helpers.js index e1cd8b64b323f..e53e26b62dd15 100644 --- a/x-pack/plugins/canvas/public/lib/arg_helpers.js +++ b/x-pack/plugins/canvas/public/lib/arg_helpers.js @@ -5,7 +5,7 @@ */ import { includes } from 'lodash'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '../../common/lib/get_type'; /* diff --git a/x-pack/plugins/canvas/public/lib/browser_registries.js b/x-pack/plugins/canvas/public/lib/browser_registries.js new file mode 100644 index 0000000000000..efceec04d6dce --- /dev/null +++ b/x-pack/plugins/canvas/public/lib/browser_registries.js @@ -0,0 +1,74 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import chrome from 'ui/chrome'; +import $script from 'scriptjs'; +import { typesRegistry } from '../../common/lib/types_registry'; +import { + argTypeRegistry, + datasourceRegistry, + transformRegistry, + modelRegistry, + viewRegistry, +} from '../expression_types'; +import { elementsRegistry } from './elements_registry'; +import { renderFunctionsRegistry } from './render_functions_registry'; +import { functionsRegistry as browserFunctions } from './functions_registry'; +import { loadPrivateBrowserFunctions } from './load_private_browser_functions'; + +const registries = { + browserFunctions: browserFunctions, + commonFunctions: browserFunctions, + elements: elementsRegistry, + types: typesRegistry, + renderers: renderFunctionsRegistry, + transformUIs: transformRegistry, + datasourceUIs: datasourceRegistry, + modelUIs: modelRegistry, + viewUIs: viewRegistry, + argumentUIs: argTypeRegistry, +}; + +let resolve = null; +let called = false; + +const populatePromise = new Promise(_resolve => { + resolve = _resolve; +}); + +export const getBrowserRegistries = () => { + return populatePromise; +}; + +export const populateBrowserRegistries = () => { + if (called) throw new Error('function should only be called once per process'); + called = true; + + // loadPrivateBrowserFunctions is sync. No biggie. + loadPrivateBrowserFunctions(); + + const remainingTypes = Object.keys(registries); + const populatedTypes = {}; + + function loadType() { + const type = remainingTypes.pop(); + window.canvas = window.canvas || {}; + window.canvas.register = d => registries[type].register(d); + + // Load plugins one at a time because each needs a different loader function + // $script will only load each of these once, we so can call this as many times as we need? + const pluginPath = chrome.addBasePath(`/api/canvas/plugins?type=${type}`); + $script(pluginPath, () => { + populatedTypes[type] = registries[type]; + + if (remainingTypes.length) loadType(); + else resolve(populatedTypes); + }); + } + + if (remainingTypes.length) loadType(); + return populatePromise; +}; diff --git a/x-pack/plugins/canvas/public/lib/create_handlers.js b/x-pack/plugins/canvas/public/lib/create_handlers.js new file mode 100644 index 0000000000000..93247210eb291 --- /dev/null +++ b/x-pack/plugins/canvas/public/lib/create_handlers.js @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export function createHandlers(/*socket*/) { + return { + environment: 'client', + }; +} diff --git a/x-pack/plugins/canvas/public/lib/elements_registry.js b/x-pack/plugins/canvas/public/lib/elements_registry.js index dc3d743f49877..898fba183c9f5 100644 --- a/x-pack/plugins/canvas/public/lib/elements_registry.js +++ b/x-pack/plugins/canvas/public/lib/elements_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '../../common/lib/registry'; import { Element } from './element'; class ElementsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/function_definitions.js b/x-pack/plugins/canvas/public/lib/function_definitions.js index c0f3496dfc083..c4bc16a4c94c3 100644 --- a/x-pack/plugins/canvas/public/lib/function_definitions.js +++ b/x-pack/plugins/canvas/public/lib/function_definitions.js @@ -5,8 +5,8 @@ */ import uniqBy from 'lodash.uniqby'; -import { getBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; import { getServerFunctions } from '../state/selectors/app'; +import { getBrowserRegistries } from './browser_registries'; export async function getFunctionDefinitions(state) { const { browserFunctions } = await getBrowserRegistries(); diff --git a/x-pack/plugins/canvas/public/lib/functions_registry.js b/x-pack/plugins/canvas/public/lib/functions_registry.js index 36f9a631f06ea..3cc084d8ca66e 100644 --- a/x-pack/plugins/canvas/public/lib/functions_registry.js +++ b/x-pack/plugins/canvas/public/lib/functions_registry.js @@ -5,4 +5,4 @@ */ // export the common registry here, so it's available in plugin public code -export { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; +export { functionsRegistry } from '../../common/lib/functions_registry'; diff --git a/packages/kbn-interpreter/public/interpreter.js b/x-pack/plugins/canvas/public/lib/interpreter.js similarity index 55% rename from packages/kbn-interpreter/public/interpreter.js rename to x-pack/plugins/canvas/public/lib/interpreter.js index 5c1e199bce363..36878871b8b15 100644 --- a/packages/kbn-interpreter/public/interpreter.js +++ b/x-pack/plugins/canvas/public/lib/interpreter.js @@ -1,28 +1,15 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ -import { socketInterpreterProvider } from '../common/interpreter/socket_interpret'; -import { serializeProvider } from '../common/lib/serialize'; -import { getSocket } from './socket'; -import { typesRegistry } from '../common/lib/types_registry'; +import { socketInterpreterProvider } from '../../common/interpreter/socket_interpret'; +import { serializeProvider } from '../../common/lib/serialize'; +import { getSocket } from '../socket'; +import { typesRegistry } from '../../common/lib/types_registry'; import { createHandlers } from './create_handlers'; -import { functionsRegistry } from '../common/lib/functions_registry'; +import { functionsRegistry } from './functions_registry'; import { getBrowserRegistries } from './browser_registries'; let socket; diff --git a/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js b/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js index 696c058e34a2b..f8eec880af624 100644 --- a/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js +++ b/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js @@ -5,7 +5,7 @@ */ import { get, mapValues, map } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression } from '../../common/lib/ast'; export function parseSingleFunctionChain(filterString) { const ast = fromExpression(filterString); diff --git a/x-pack/plugins/canvas/public/lib/render_functions_registry.js b/x-pack/plugins/canvas/public/lib/render_functions_registry.js index a34ed009a33b1..3d040047aeb9a 100644 --- a/x-pack/plugins/canvas/public/lib/render_functions_registry.js +++ b/x-pack/plugins/canvas/public/lib/render_functions_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '../../common/lib/registry'; import { RenderFunction } from './render_function'; class RenderFunctionsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/run_interpreter.js b/x-pack/plugins/canvas/public/lib/run_interpreter.js index 7bb898b254ec8..cc0d9a7544786 100644 --- a/x-pack/plugins/canvas/public/lib/run_interpreter.js +++ b/x-pack/plugins/canvas/public/lib/run_interpreter.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { fromExpression } from '../../common/lib/ast'; +import { getType } from '../../common/lib/get_type'; +import { interpretAst } from './interpreter'; import { notify } from './notify'; /** diff --git a/x-pack/plugins/canvas/public/lib/transitions_registry.js b/x-pack/plugins/canvas/public/lib/transitions_registry.js index 8ead0aa896ab7..8d2e421b8233c 100644 --- a/x-pack/plugins/canvas/public/lib/transitions_registry.js +++ b/x-pack/plugins/canvas/public/lib/transitions_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '../../common/lib/registry'; import { Transition } from '../transitions/transition'; class TransitionsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/types_registry.js b/x-pack/plugins/canvas/public/lib/types_registry.js index 05b82c744c383..c1f13b1ae4612 100644 --- a/x-pack/plugins/canvas/public/lib/types_registry.js +++ b/x-pack/plugins/canvas/public/lib/types_registry.js @@ -5,4 +5,4 @@ */ // export the common registry here, so it's available in plugin public code -export { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; +export { typesRegistry } from '../../common/lib/types_registry'; diff --git a/packages/kbn-interpreter/public/socket.js b/x-pack/plugins/canvas/public/socket.js similarity index 64% rename from packages/kbn-interpreter/public/socket.js rename to x-pack/plugins/canvas/public/socket.js index 9143f0018377b..92deedd488c06 100644 --- a/packages/kbn-interpreter/public/socket.js +++ b/x-pack/plugins/canvas/public/socket.js @@ -1,25 +1,12 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import io from 'socket.io-client'; import { functionsRegistry } from '../common/lib/functions_registry'; -import { getBrowserRegistries } from './browser_registries'; +import { getBrowserRegistries } from './lib/browser_registries'; const SOCKET_CONNECTION_TIMEOUT = 5000; // timeout in ms let socket; diff --git a/x-pack/plugins/canvas/public/state/actions/elements.js b/x-pack/plugins/canvas/public/state/actions/elements.js index be157d9d8085b..fb82de32fc0ef 100644 --- a/x-pack/plugins/canvas/public/state/actions/elements.js +++ b/x-pack/plugins/canvas/public/state/actions/elements.js @@ -4,17 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; import { createAction } from 'redux-actions'; import { createThunk } from 'redux-thunks'; import { set, del } from 'object-path-immutable'; import { get, pick, cloneDeep, without } from 'lodash'; -import { toExpression, safeElementFromExpression } from '@kbn/interpreter/common/lib/ast'; import { getPages, getElementById, getSelectedPageIndex } from '../selectors/workpad'; import { getValue as getResolvedArgsValue } from '../selectors/resolved_args'; import { getDefaultElement } from '../defaults'; +import { toExpression, safeElementFromExpression } from '../../../common/lib/ast'; import { notify } from '../../lib/notify'; import { runInterpreter } from '../../lib/run_interpreter'; +import { interpretAst } from '../../lib/interpreter'; import { selectElement } from './transient'; import * as args from './resolved_args'; diff --git a/x-pack/plugins/canvas/public/state/selectors/workpad.js b/x-pack/plugins/canvas/public/state/selectors/workpad.js index 6d888f60c2191..1db0128abab07 100644 --- a/x-pack/plugins/canvas/public/state/selectors/workpad.js +++ b/x-pack/plugins/canvas/public/state/selectors/workpad.js @@ -5,7 +5,7 @@ */ import { get, omit } from 'lodash'; -import { safeElementFromExpression } from '@kbn/interpreter/common/lib/ast'; +import { safeElementFromExpression } from '../../../common/lib/ast'; import { append } from '../../lib/modify_path'; import { getAssets } from './assets'; diff --git a/src/core_plugins/interpreter/server/lib/__tests__/create_handlers.js b/x-pack/plugins/canvas/server/lib/__tests__/create_handlers.js similarity index 83% rename from src/core_plugins/interpreter/server/lib/__tests__/create_handlers.js rename to x-pack/plugins/canvas/server/lib/__tests__/create_handlers.js index 9afe458c444a7..9dbe0e413a1af 100644 --- a/src/core_plugins/interpreter/server/lib/__tests__/create_handlers.js +++ b/x-pack/plugins/canvas/server/lib/__tests__/create_handlers.js @@ -1,25 +1,12 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import expect from 'expect.js'; import { createHandlers } from '../create_handlers'; -import { SECURITY_AUTH_MESSAGE } from '../../../common/constants'; +import { SECURITY_AUTH_MESSAGE } from '../../../common/lib/constants'; let securityMode = 'pass'; let isSecurityAvailable = true; diff --git a/src/core_plugins/interpreter/server/lib/create_handlers.js b/x-pack/plugins/canvas/server/lib/create_handlers.js similarity index 58% rename from src/core_plugins/interpreter/server/lib/create_handlers.js rename to x-pack/plugins/canvas/server/lib/create_handlers.js index 9c4dcd112c928..f42f8fbe1a59d 100644 --- a/src/core_plugins/interpreter/server/lib/create_handlers.js +++ b/x-pack/plugins/canvas/server/lib/create_handlers.js @@ -1,25 +1,12 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import boom from 'boom'; +import { SECURITY_AUTH_MESSAGE } from '../../common/lib/constants'; import { isSecurityEnabled } from './feature_check'; -import { SECURITY_AUTH_MESSAGE } from '../../common/constants'; export const createHandlers = (request, server) => { const { callWithRequest } = server.plugins.elasticsearch.getCluster('data'); @@ -37,9 +24,8 @@ export const createHandlers = (request, server) => { if (isSecurityEnabled(server)) { try { const authenticationResult = await server.plugins.security.authenticate(request); - if (!authenticationResult.succeeded()) { + if (!authenticationResult.succeeded()) throw boom.unauthorized(authenticationResult.error); - } } catch (e) { // if authenticate throws, show error in development if (process.env.NODE_ENV !== 'production') { diff --git a/x-pack/plugins/canvas/server/lib/feature_check.js b/x-pack/plugins/canvas/server/lib/feature_check.js new file mode 100644 index 0000000000000..e9cec02923582 --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/feature_check.js @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// TODO: replace this when we use the method exposed by security https://github.com/elastic/kibana/pull/24616 +export const isSecurityEnabled = server => { + const kibanaSecurity = server.plugins.security; + const esSecurity = server.plugins.xpack_main.info.feature('security'); + + return kibanaSecurity && esSecurity.isAvailable() && esSecurity.isEnabled(); +}; diff --git a/x-pack/plugins/canvas/server/lib/get_plugin_paths.js b/x-pack/plugins/canvas/server/lib/get_plugin_paths.js new file mode 100644 index 0000000000000..02582e5f749cc --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/get_plugin_paths.js @@ -0,0 +1,83 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import path from 'path'; +import fs from 'fs'; +import { promisify } from 'util'; +import { flatten } from 'lodash'; +import { pluginPaths } from './plugin_paths'; + +const lstat = promisify(fs.lstat); +const readdir = promisify(fs.readdir); + +const canvasPluginDirectoryName = 'canvas_plugin'; + +const isDirectory = path => + lstat(path) + .then(stat => stat.isDirectory()) + .catch(() => false); + +const isDirname = (p, name) => path.basename(p) === name; + +const getKibanaPluginsPath = () => { + const basePluginPath = path.resolve(__dirname, '..', '..', '..', '..', '..'); + + // find the kibana path in dev mode + if (isDirname(basePluginPath, 'kibana')) return path.join(basePluginPath, 'plugins'); + + // find the kibana path in the build, which lives in node_modules and requires going 1 path up + const buildPluginPath = path.join(basePluginPath, '..'); + if (isDirname(basePluginPath, 'node_modules')) { + const pluginPath = path.join(buildPluginPath, 'plugins'); + return isDirectory(pluginPath) && pluginPath; + } + + return false; +}; + +// These must all exist +const paths = [ + path.resolve(__dirname, '..', '..', '..'), // Canvas core plugins + getKibanaPluginsPath(), // Kibana plugin directory +].filter(Boolean); + +export const getPluginPaths = type => { + const typePath = pluginPaths[type]; + if (!typePath) throw new Error(`Unknown type: ${type}`); + + async function findPlugins(directory) { + const isDir = await isDirectory(directory); + if (!isDir) return; + + const names = await readdir(directory); // Get names of everything in the directory + return names + .filter(name => name[0] !== '.') + .map(name => path.resolve(directory, name, canvasPluginDirectoryName, ...typePath)); + } + + return Promise.all(paths.map(findPlugins)) + .then(dirs => + dirs.reduce((list, dir) => { + if (!dir) return list; + return list.concat(dir); + }, []) + ) + .then(possibleCanvasPlugins => { + // Check how many are directories. If lstat fails it doesn't exist anyway. + return Promise.all( + // An array + possibleCanvasPlugins.map(pluginPath => isDirectory(pluginPath)) + ).then(isDirectory => possibleCanvasPlugins.filter((pluginPath, i) => isDirectory[i])); + }) + .then(canvasPluginDirectories => { + return Promise.all( + canvasPluginDirectories.map(dir => + // Get the full path of all files in the directory + readdir(dir).then(files => files.map(file => path.resolve(dir, file))) + ) + ).then(flatten); + }); +}; diff --git a/x-pack/plugins/canvas/server/lib/get_plugin_stream.js b/x-pack/plugins/canvas/server/lib/get_plugin_stream.js new file mode 100644 index 0000000000000..6a08e2beeff8e --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/get_plugin_stream.js @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import fs from 'fs'; +import ss from 'stream-stream'; +import { getPluginPaths } from './get_plugin_paths'; + +export const getPluginStream = type => { + const stream = ss({ + separator: '\n', + }); + + getPluginPaths(type).then(files => { + files.forEach(file => { + stream.write(fs.createReadStream(file)); + }); + stream.end(); + }); + + return stream; +}; diff --git a/x-pack/plugins/canvas/server/lib/get_request.js b/x-pack/plugins/canvas/server/lib/get_request.js new file mode 100644 index 0000000000000..d55421e437fc4 --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/get_request.js @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import boom from 'boom'; +import { API_ROUTE } from '../../common/lib/constants'; + +export function getRequest(server, { headers }) { + const url = `${API_ROUTE}/ping`; + + return server + .inject({ + method: 'POST', + url, + headers, + }) + .then(res => { + if (res.statusCode !== 200) { + if (process.env.NODE_ENV !== 'production') { + console.error( + new Error(`Auth request failed: [${res.statusCode}] ${res.result.message}`) + ); + } + throw boom.unauthorized('Failed to authenticate socket connection'); + } + + return res.request; + }); +} diff --git a/x-pack/plugins/canvas/server/lib/plugin_paths.js b/x-pack/plugins/canvas/server/lib/plugin_paths.js new file mode 100644 index 0000000000000..cb90cc0c0f06c --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/plugin_paths.js @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const pluginPaths = { + serverFunctions: ['functions', 'server'], + browserFunctions: ['functions', 'browser'], + commonFunctions: ['functions', 'common'], + types: ['types'], + elements: ['elements'], + renderers: ['renderers'], + interfaces: ['interfaces'], + transformUIs: ['uis', 'transforms'], + datasourceUIs: ['uis', 'datasources'], + modelUIs: ['uis', 'models'], + viewUIs: ['uis', 'views'], + argumentUIs: ['uis', 'arguments'], +}; diff --git a/src/core_plugins/interpreter/server/lib/route_expression/browser.js b/x-pack/plugins/canvas/server/lib/route_expression/browser.js similarity index 65% rename from src/core_plugins/interpreter/server/lib/route_expression/browser.js rename to x-pack/plugins/canvas/server/lib/route_expression/browser.js index 0fe27f4d27c68..feae107873ac6 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/browser.js +++ b/x-pack/plugins/canvas/server/lib/route_expression/browser.js @@ -1,20 +1,7 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import uuid from 'uuid/v4'; diff --git a/src/core_plugins/interpreter/server/lib/route_expression/index.js b/x-pack/plugins/canvas/server/lib/route_expression/index.js similarity index 51% rename from src/core_plugins/interpreter/server/lib/route_expression/index.js rename to x-pack/plugins/canvas/server/lib/route_expression/index.js index 1b3556e051d2d..3533b55687246 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/index.js +++ b/x-pack/plugins/canvas/server/lib/route_expression/index.js @@ -1,23 +1,9 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ - -import { createError } from '@kbn/interpreter/common/interpreter/create_error'; +import { createError } from '../../../common/interpreter/create_error'; export const routeExpressionProvider = environments => { async function routeExpression(ast, context = null) { diff --git a/x-pack/plugins/canvas/server/lib/route_expression/server.js b/x-pack/plugins/canvas/server/lib/route_expression/server.js new file mode 100644 index 0000000000000..b24e4cb7e5e41 --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/route_expression/server.js @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { getServerRegistries } from '../server_registries'; +import { interpretProvider } from '../../../common/interpreter/interpret'; +import { createHandlers } from '../create_handlers'; + +export const server = async ({ onFunctionNotFound, server, request }) => { + const { serverFunctions, types } = await getServerRegistries(['serverFunctions', 'types']); + + return { + interpret: (ast, context) => { + const interpret = interpretProvider({ + types: types.toJS(), + functions: serverFunctions.toJS(), + handlers: createHandlers(request, server), + onFunctionNotFound, + }); + + return interpret(ast, context); + }, + getFunctions: () => Object.keys(serverFunctions.toJS()), + }; +}; diff --git a/x-pack/plugins/canvas/server/lib/route_expression/thread/babeled.js b/x-pack/plugins/canvas/server/lib/route_expression/thread/babeled.js new file mode 100644 index 0000000000000..b7c1e83beb7c7 --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/route_expression/thread/babeled.js @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +require('babel-register')({ + ignore: [ + // stolen from kibana/src/setup_node_env/babel_register/register.js + // ignore paths matching `/node_modules/{a}/{b}`, unless `a` + // is `x-pack` and `b` is not `node_modules` + /\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, + ], + babelrc: false, + presets: [require.resolve('@kbn/babel-preset/node_preset')], +}); + +require('./polyfill'); +require('./worker'); diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/index.js b/x-pack/plugins/canvas/server/lib/route_expression/thread/index.js similarity index 78% rename from src/core_plugins/interpreter/server/lib/route_expression/thread/index.js rename to x-pack/plugins/canvas/server/lib/route_expression/thread/index.js index ff476793325e9..d3748db02f65c 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/thread/index.js +++ b/x-pack/plugins/canvas/server/lib/route_expression/thread/index.js @@ -1,20 +1,7 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import { fork } from 'child_process'; diff --git a/x-pack/plugins/canvas/server/lib/route_expression/thread/polyfill.js b/x-pack/plugins/canvas/server/lib/route_expression/thread/polyfill.js new file mode 100644 index 0000000000000..be4983e9a37e8 --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/route_expression/thread/polyfill.js @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// taken from kibana/src/setup_node_env/babel_register/polyfill.js +// ... +// `babel-preset-env` looks for and rewrites the following import +// statement into a list of import statements based on the polyfills +// necessary for our target environment (the current version of node) +// but since it does that during compilation, `import 'babel-polyfill'` +// must be in a file that is loaded with `require()` AFTER `babel-register` +// is configured. +// +// This is why we have this single statement in it's own file and require +// it from ./babeled.js +import 'babel-polyfill'; diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js b/x-pack/plugins/canvas/server/lib/route_expression/thread/worker.js similarity index 62% rename from src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js rename to x-pack/plugins/canvas/server/lib/route_expression/thread/worker.js index 5159679bb9f4f..d81df410f7af7 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js +++ b/x-pack/plugins/canvas/server/lib/route_expression/thread/worker.js @@ -1,26 +1,13 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import uuid from 'uuid/v4'; -import { populateServerRegistries } from '@kbn/interpreter/server/server_registries'; -import { interpretProvider } from '@kbn/interpreter/common/interpreter/interpret'; -import { serializeProvider } from '@kbn/interpreter/common/lib/serialize'; +import { populateServerRegistries } from '../../server_registries'; +import { interpretProvider } from '../../../../common/interpreter/interpret'; +import { serializeProvider } from '../../../../common/lib/serialize'; // We actually DO need populateServerRegistries here since this is a different node process const pluginsReady = populateServerRegistries(['commonFunctions', 'types']); @@ -57,9 +44,8 @@ process.on('message', msg => { }, }); - if (type === 'getFunctions') { + if (type === 'getFunctions') process.send({ type: 'functionList', value: Object.keys(commonFunctions.toJS()) }); - } if (type === 'msgSuccess') { heap[id].resolve(deserialize(value)); diff --git a/x-pack/plugins/canvas/server/lib/server_registries.js b/x-pack/plugins/canvas/server/lib/server_registries.js new file mode 100644 index 0000000000000..cff63a1138ea3 --- /dev/null +++ b/x-pack/plugins/canvas/server/lib/server_registries.js @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { typesRegistry } from '../../common/lib/types_registry'; +import { functionsRegistry as serverFunctions } from '../../common/lib/functions_registry'; +import { getPluginPaths } from './get_plugin_paths'; + +const registries = { + serverFunctions: serverFunctions, + commonFunctions: serverFunctions, + types: typesRegistry, +}; + +let resolve = null; +let called = false; + +const populatePromise = new Promise(_resolve => { + resolve = _resolve; +}); + +export const getServerRegistries = () => { + return populatePromise; +}; + +export const populateServerRegistries = types => { + if (called) throw new Error('function should only be called once per process'); + called = true; + if (!types || !types.length) throw new Error('types is required'); + + const remainingTypes = types; + const populatedTypes = {}; + + const loadType = () => { + const type = remainingTypes.pop(); + getPluginPaths(type).then(paths => { + global.canvas = global.canvas || {}; + global.canvas.register = d => registries[type].register(d); + + paths.forEach(path => { + require(path); + }); + + global.canvas = undefined; + populatedTypes[type] = registries[type]; + if (remainingTypes.length) loadType(); + else resolve(populatedTypes); + }); + }; + + if (remainingTypes.length) loadType(); + return populatePromise; +}; diff --git a/x-pack/plugins/canvas/server/routes/index.js b/x-pack/plugins/canvas/server/routes/index.js index 45f26a423fc84..ab2edfe86b56f 100644 --- a/x-pack/plugins/canvas/server/routes/index.js +++ b/x-pack/plugins/canvas/server/routes/index.js @@ -5,9 +5,15 @@ */ import { workpad } from './workpad'; +import { socketApi } from './socket'; +import { translate } from './translate'; import { esFields } from './es_fields'; +import { plugins } from './plugins'; export function routes(server) { workpad(server); + socketApi(server); + translate(server); esFields(server); + plugins(server); } diff --git a/x-pack/plugins/canvas/server/routes/plugins.js b/x-pack/plugins/canvas/server/routes/plugins.js new file mode 100644 index 0000000000000..be94ef52ac9e4 --- /dev/null +++ b/x-pack/plugins/canvas/server/routes/plugins.js @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { getPluginStream } from '../lib/get_plugin_stream'; +import { pluginPaths } from '../lib/plugin_paths'; + +export function plugins(server) { + server.route({ + method: 'GET', + path: '/api/canvas/plugins', + handler: function(request, h) { + const { type } = request.query; + + if (!pluginPaths[type]) return h.response({ error: 'Invalid type' }).code(400); + + return getPluginStream(type); + }, + config: { + auth: false, + }, + }); +} diff --git a/src/core_plugins/interpreter/server/routes/socket.js b/x-pack/plugins/canvas/server/routes/socket.js similarity index 68% rename from src/core_plugins/interpreter/server/routes/socket.js rename to x-pack/plugins/canvas/server/routes/socket.js index daf16ec7a4432..8e06c25769d4c 100644 --- a/src/core_plugins/interpreter/server/routes/socket.js +++ b/x-pack/plugins/canvas/server/routes/socket.js @@ -1,32 +1,19 @@ /* - * 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. + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. */ import socket from 'socket.io'; -import { serializeProvider } from '@kbn/interpreter/common/lib/serialize'; -import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; -import { getServerRegistries } from '@kbn/interpreter/server/server_registries'; -import { routeExpressionProvider } from '../lib/route_expression/index'; +import { serializeProvider } from '../../common/lib/serialize'; +import { typesRegistry } from '../../common/lib/types_registry'; +import { getServerRegistries } from '../lib/server_registries'; +import { routeExpressionProvider } from '../lib/route_expression'; import { browser } from '../lib/route_expression/browser'; -import { thread } from '../lib/route_expression/thread/index'; +import { thread } from '../lib/route_expression/thread'; import { server as serverEnv } from '../lib/route_expression/server'; import { getRequest } from '../lib/get_request'; -import { API_ROUTE } from '../../common/constants'; +import { API_ROUTE } from '../../common/lib/constants'; async function getModifiedRequest(server, socket) { try { diff --git a/x-pack/plugins/canvas/server/routes/translate.js b/x-pack/plugins/canvas/server/routes/translate.js new file mode 100644 index 0000000000000..6125898a7dab9 --- /dev/null +++ b/x-pack/plugins/canvas/server/routes/translate.js @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { fromExpression, toExpression } from '../../common/lib/ast'; + +export function translate(server) { + /* + Get AST from expression + */ + server.route({ + method: 'GET', + path: '/api/canvas/ast', + handler: function(request, h) { + if (!request.query.expression) + return h.response({ error: '"expression" query is required' }).code(400); + return fromExpression(request.query.expression); + }, + }); + + server.route({ + method: 'POST', + path: '/api/canvas/expression', + handler: function(request, h) { + try { + return toExpression(request.payload); + } catch (e) { + return h.response({ error: e.message }).code(400); + } + }, + }); +} diff --git a/x-pack/plugins/canvas/server/usage/collector.js b/x-pack/plugins/canvas/server/usage/collector.js index d76d023f7c7e4..a4e73ffe85071 100644 --- a/x-pack/plugins/canvas/server/usage/collector.js +++ b/x-pack/plugins/canvas/server/usage/collector.js @@ -5,8 +5,8 @@ */ import { sum as arraySum, min as arrayMin, max as arrayMax, get } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; import { CANVAS_USAGE_TYPE, CANVAS_TYPE } from '../../common/lib/constants'; +import { fromExpression } from '../../common/lib/ast'; /* * @param ast: an ast that includes functions to track diff --git a/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js b/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js index 8b8f3601d86e9..c53eccd87bd97 100644 --- a/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js +++ b/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js @@ -21,6 +21,7 @@ module.exports = { 'uis/arguments/all': path.join(sourceDir, 'uis/arguments/register.js'), 'functions/browser/all': path.join(sourceDir, 'functions/browser/register.js'), 'functions/common/all': path.join(sourceDir, 'functions/common/register.js'), + 'types/all': path.join(sourceDir, 'types/register.js'), }, // there were problems with the node and web targets since this code is actually diff --git a/x-pack/test/functional/apps/canvas/index.js b/x-pack/test/functional/apps/canvas/index.js index 9ede9ff8c67cb..6620ee6c26f02 100644 --- a/x-pack/test/functional/apps/canvas/index.js +++ b/x-pack/test/functional/apps/canvas/index.js @@ -5,7 +5,7 @@ */ export default function canvasApp({ loadTestFile }) { - describe.skip('Canvas app', function canvasAppTestSuite() { + describe('Canvas app', function canvasAppTestSuite() { this.tags('ciGroup2'); // CI requires tags ヽ(゜Q。)ノ? loadTestFile(require.resolve('./smoke_test')); }); From bdcccfb30494808042a22ceecc5749d0121f7c2c Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 21 Nov 2018 18:06:10 -0800 Subject: [PATCH 60/95] [canvas/plugins] enable typescript support (#26050) --- x-pack/package.json | 1 + .../canvas/tasks/helpers/webpack.plugins.js | 189 ++++++++++-------- x-pack/plugins/canvas/tasks/plugins.js | 8 +- 3 files changed, 116 insertions(+), 82 deletions(-) diff --git a/x-pack/package.json b/x-pack/package.json index 02a59ea7ff3bc..8d84eb501f748 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -110,6 +110,7 @@ "supertest-as-promised": "^4.0.2", "tmp": "0.0.31", "tree-kill": "^1.1.0", + "ts-loader": "^3.5.0", "typescript": "^3.0.3", "vinyl-fs": "^3.0.2", "xml-crypto": "^0.10.1", diff --git a/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js b/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js index c53eccd87bd97..7df740d4e27a2 100644 --- a/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js +++ b/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js @@ -10,92 +10,125 @@ const CopyWebpackPlugin = require('copy-webpack-plugin'); const sourceDir = path.resolve(__dirname, '../../canvas_plugin_src'); const buildDir = path.resolve(__dirname, '../../canvas_plugin'); -module.exports = { - entry: { - 'elements/all': path.join(sourceDir, 'elements/register.js'), - 'renderers/all': path.join(sourceDir, 'renderers/register.js'), - 'uis/transforms/all': path.join(sourceDir, 'uis/transforms/register.js'), - 'uis/models/all': path.join(sourceDir, 'uis/models/register.js'), - 'uis/views/all': path.join(sourceDir, 'uis/views/register.js'), - 'uis/datasources/all': path.join(sourceDir, 'uis/datasources/register.js'), - 'uis/arguments/all': path.join(sourceDir, 'uis/arguments/register.js'), - 'functions/browser/all': path.join(sourceDir, 'functions/browser/register.js'), - 'functions/common/all': path.join(sourceDir, 'functions/common/register.js'), - 'types/all': path.join(sourceDir, 'types/register.js'), - }, +export function getWebpackConfig({ devtool, watch } = {}) { + return { + watch, + devtool, - // there were problems with the node and web targets since this code is actually - // targetting both the browser and node.js. If there was a hybrid target we'd use - // it, but this seems to work either way. - target: 'webworker', + entry: { + 'elements/all': path.join(sourceDir, 'elements/register.js'), + 'renderers/all': path.join(sourceDir, 'renderers/register.js'), + 'uis/transforms/all': path.join(sourceDir, 'uis/transforms/register.js'), + 'uis/models/all': path.join(sourceDir, 'uis/models/register.js'), + 'uis/views/all': path.join(sourceDir, 'uis/views/register.js'), + 'uis/datasources/all': path.join(sourceDir, 'uis/datasources/register.js'), + 'uis/arguments/all': path.join(sourceDir, 'uis/arguments/register.js'), + 'functions/browser/all': path.join(sourceDir, 'functions/browser/register.js'), + 'functions/common/all': path.join(sourceDir, 'functions/common/register.js'), + 'types/all': path.join(sourceDir, 'types/register.js'), + }, - output: { - path: buildDir, - filename: '[name].js', // Need long paths here. - libraryTarget: 'umd', - }, + // there were problems with the node and web targets since this code is actually + // targetting both the browser and node.js. If there was a hybrid target we'd use + // it, but this seems to work either way. + target: 'webworker', - resolve: { - extensions: ['.js', '.json'], - mainFields: ['browser', 'main'], - }, + output: { + path: buildDir, + filename: '[name].js', // Need long paths here. + libraryTarget: 'umd', + }, - plugins: [ - function loaderFailHandler() { - // bails on error, including loader errors - // see https://github.com/webpack/webpack/issues/708, which does not fix loader errors - let isWatch = true; + resolve: { + extensions: ['.ts', '.tsx', '.js', '.json'], + mainFields: ['browser', 'main'], + }, - this.plugin('run', function(compiler, callback) { - isWatch = false; - callback.call(compiler); - }); + plugins: [ + function loaderFailHandler() { + // bails on error, including loader errors + // see https://github.com/webpack/webpack/issues/708, which does not fix loader errors + let isWatch = true; - this.plugin('done', function(stats) { - if (!stats.hasErrors()) return; - const errorMessage = stats.toString('errors-only'); - if (isWatch) console.error(errorMessage); - else throw new Error(errorMessage); - }); - }, - new CopyWebpackPlugin([ - { - from: `${sourceDir}/functions/server/`, - to: `${buildDir}/functions/server/`, - ignore: '**/__tests__/**', - }, - ]), - ], + this.plugin('run', function(compiler, callback) { + isWatch = false; + callback.call(compiler); + }); - module: { - rules: [ - { - test: /\.js$/, - exclude: [/node_modules/], - loaders: 'babel-loader', - options: { - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/webpack_preset')], - }, - }, - { - test: /\.(png|jpg|gif|jpeg|svg)$/, - loaders: ['url-loader'], - }, - { - test: /\.(css|scss)$/, - loaders: ['style-loader', 'css-loader', 'sass-loader'], + this.plugin('done', function(stats) { + if (!stats.hasErrors()) return; + const errorMessage = stats.toString('errors-only'); + if (isWatch) console.error(errorMessage); + else throw new Error(errorMessage); + }); }, + new CopyWebpackPlugin([ + { + from: `${sourceDir}/functions/server/`, + to: `${buildDir}/functions/server/`, + ignore: '**/__tests__/**', + }, + ]), ], - }, - node: { - // Don't replace built-in globals - __filename: false, - __dirname: false, - }, + module: { + rules: [ + { + test: /\.js$/, + exclude: [/node_modules/], + loaders: 'babel-loader', + options: { + babelrc: false, + presets: [require.resolve('@kbn/babel-preset/webpack_preset')], + }, + }, + { + test: /\.(png|jpg|gif|jpeg|svg)$/, + loaders: ['url-loader'], + }, + { + test: /\.(css|scss)$/, + loaders: ['style-loader', 'css-loader', 'sass-loader'], + }, + { + test: /\.tsx?$/, + include: sourceDir, + use: [ + { + loader: 'ts-loader', + options: { + transpileOnly: true, + experimentalWatchApi: true, + onlyCompileBundledFiles: true, + configFile: require.resolve('../../../../tsconfig.json'), + compilerOptions: { + sourceMap: Boolean(devtool), + }, + }, + }, + ], + }, + ], + }, - watchOptions: { - ignored: [/node_modules/], - }, -}; + node: { + // Don't replace built-in globals + __filename: false, + __dirname: false, + }, + + watchOptions: { + ignored: [/node_modules/], + }, + + stats: { + // when typescript doesn't do a full type check, as we have the ts-loader + // configured here, it does not have enough information to determine + // whether an imported name is a type or not, so when the name is then + // exported, typescript has no choice but to emit the export. Fortunately, + // the extraneous export should not be harmful, so we just suppress these warnings + // https://github.com/TypeStrong/ts-loader#transpileonly-boolean-defaultfalse + warningsFilter: /export .* was not found in/, + }, + }; +} diff --git a/x-pack/plugins/canvas/tasks/plugins.js b/x-pack/plugins/canvas/tasks/plugins.js index 991b4d85c6ec5..0b8643880ffe5 100644 --- a/x-pack/plugins/canvas/tasks/plugins.js +++ b/x-pack/plugins/canvas/tasks/plugins.js @@ -8,7 +8,7 @@ import path from 'path'; // eslint-disable-next-line import/no-extraneous-dependencies import webpack from 'webpack'; import del from 'del'; -import webpackConfig from './helpers/webpack.plugins'; +import { getWebpackConfig } from './helpers/webpack.plugins'; const devtool = 'inline-cheap-module-source-map'; const buildDir = path.resolve(__dirname, '../canvas_plugin'); @@ -26,20 +26,20 @@ export default function pluginsTasks(gulp, { log, colors }) { }; gulp.task('canvas:plugins:build', function(done) { - del(buildDir).then(() => webpack({ ...webpackConfig, devtool }, onComplete(done))); + del(buildDir).then(() => webpack(getWebpackConfig({ devtool }), onComplete(done))); }); // eslint-disable-next-line no-unused-vars gulp.task('canvas:plugins:dev', function(done /* added to make gulp async */) { log(`${colors.green.bold('canvas:plugins')} Starting initial build, this will take a while`); del(buildDir).then(() => - webpack({ ...webpackConfig, devtool, watch: true }, (err, stats) => { + webpack(getWebpackConfig({ devtool, watch: true }), (err, stats) => { onComplete()(err, stats); }) ); }); gulp.task('canvas:plugins:build-prod', function(done) { - del(buildDir).then(() => webpack(webpackConfig, onComplete(done))); + del(buildDir).then(() => webpack(getWebpackConfig(), onComplete(done))); }); } From 5e247f506c54710fc27482430d8fb5186f79178a Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 22 Nov 2018 02:59:38 +0000 Subject: [PATCH 61/95] fix(NA): remove mutex from kbn bootstrap script as all jobs are running isolated. (#26058) --- packages/kbn-pm/dist/index.js | 2 +- packages/kbn-pm/src/utils/scripts.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 56a18caef6407..4660a71d482e0 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -19655,7 +19655,7 @@ exports.runScriptInPackage = exports.installInDir = undefined; */ let installInDir = exports.installInDir = (() => { var _ref = _asyncToGenerator(function* (directory, extraArgs = []) { - const options = ['install', '--non-interactive', '--mutex=file', ...extraArgs]; + const options = ['install', '--non-interactive', ...extraArgs]; // We pass the mutex flag to ensure only one instance of yarn runs at any // given time (e.g. to avoid conflicts). yield (0, _child_process.spawn)('yarn', options, { diff --git a/packages/kbn-pm/src/utils/scripts.ts b/packages/kbn-pm/src/utils/scripts.ts index 177068b9b1112..f1e0a45222673 100644 --- a/packages/kbn-pm/src/utils/scripts.ts +++ b/packages/kbn-pm/src/utils/scripts.ts @@ -24,7 +24,7 @@ import { Project } from './project'; * Install all dependencies in the given directory */ export async function installInDir(directory: string, extraArgs: string[] = []) { - const options = ['install', '--non-interactive', '--mutex=file', ...extraArgs]; + const options = ['install', '--non-interactive', ...extraArgs]; // We pass the mutex flag to ensure only one instance of yarn runs at any // given time (e.g. to avoid conflicts). From 854757cb6f46aadac32bb09b3761304981fdb9ed Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Thu, 22 Nov 2018 04:27:13 +0100 Subject: [PATCH 62/95] pass global filters from editor (#26009) --- .../kibana/public/visualize/editor/editor.html | 1 + .../kibana/public/visualize/editor/editor.js | 15 +-------------- .../visualize/editor/visualization_editor.js | 10 +++++++--- src/ui/public/vis/editors/default/default.js | 6 ++++-- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/core_plugins/kibana/public/visualize/editor/editor.html b/src/core_plugins/kibana/public/visualize/editor/editor.html index c73805e4eb678..06c058d37da5a 100644 --- a/src/core_plugins/kibana/public/visualize/editor/editor.html +++ b/src/core_plugins/kibana/public/visualize/editor/editor.html @@ -73,6 +73,7 @@ saved-obj="savedVis" ui-state="uiState" time-range="timeRange" + filters="globalFilters" class="visEditor__content" /> diff --git a/src/core_plugins/kibana/public/visualize/editor/editor.js b/src/core_plugins/kibana/public/visualize/editor/editor.js index 5e4ec07ff5e83..fa0a679c459d5 100644 --- a/src/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/core_plugins/kibana/public/visualize/editor/editor.js @@ -128,18 +128,6 @@ function VisEditor( // SearchSource is a promise-based stream of search results that can inherit from other search sources. const { vis, searchSource } = savedVis; - // adds top level search source to the stack to which global filters are applied - const getTopLevelSearchSource = (searchSource) => { - if (searchSource.getParent()) return getTopLevelSearchSource(searchSource.getParent()); - return searchSource; - }; - - const topLevelSearchSource = getTopLevelSearchSource(searchSource); - const globalFiltersSearchSource = searchSource.create(); - globalFiltersSearchSource.setField('index', searchSource.getField('index')); - topLevelSearchSource.setParent(globalFiltersSearchSource); - - $scope.vis = vis; const $appStatus = this.appStatus = { @@ -338,10 +326,9 @@ function VisEditor( // update the searchSource when query updates $scope.fetch = function () { $state.save(); - const globalFilters = queryFilter.getGlobalFilters(); savedVis.searchSource.setField('query', $state.query); savedVis.searchSource.setField('filter', $state.filters); - globalFiltersSearchSource.setField('filter', globalFilters); + $scope.globalFilters = queryFilter.getGlobalFilters(); $scope.vis.forceReload(); }; diff --git a/src/core_plugins/kibana/public/visualize/editor/visualization_editor.js b/src/core_plugins/kibana/public/visualize/editor/visualization_editor.js index 1f8426386613c..a2ed44df2f5b0 100644 --- a/src/core_plugins/kibana/public/visualize/editor/visualization_editor.js +++ b/src/core_plugins/kibana/public/visualize/editor/visualization_editor.js @@ -17,6 +17,7 @@ * under the License. */ +import { debounce } from 'lodash'; import { uiModules } from 'ui/modules'; import 'angular-sanitize'; import { VisEditorTypesRegistryProvider } from 'ui/registry/vis_editor_types'; @@ -31,7 +32,8 @@ uiModules scope: { savedObj: '=', uiState: '=?', - timeRange: '=' + timeRange: '=', + filters: '=', }, link: function ($scope, element) { const editorType = $scope.savedObj.vis.type.editor; @@ -43,6 +45,7 @@ uiModules editor.render({ uiState: $scope.uiState, timeRange: $scope.timeRange, + filters: $scope.filters, appState: getAppState(), }); }; @@ -56,8 +59,9 @@ uiModules editor.destroy(); }); - $scope.$watch('timeRange', $scope.renderFunction); - + $scope.$watchGroup(['timeRange', 'filters'], debounce(() => { + $scope.renderFunction(); + }, 100)); } }; }); diff --git a/src/ui/public/vis/editors/default/default.js b/src/ui/public/vis/editors/default/default.js index e1802960eb2a0..b21dd52bc7bfe 100644 --- a/src/ui/public/vis/editors/default/default.js +++ b/src/ui/public/vis/editors/default/default.js @@ -53,7 +53,7 @@ const defaultEditor = function ($rootScope, $compile, i18n) { } } - render({ uiState, timeRange, appState }) { + render({ uiState, timeRange, filters, appState }) { let $scope; const updateScope = () => { @@ -166,12 +166,14 @@ const defaultEditor = function ($rootScope, $compile, i18n) { uiState: uiState, listenOnChange: false, timeRange: timeRange, + filters: filters, appState: appState, }); }); } else { this._handler.update({ - timeRange: timeRange + timeRange: timeRange, + filters: filters, }); } From 8f880918c9c7d6ba704f6744f49cc3f8871dc83a Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Thu, 22 Nov 2018 04:28:55 +0100 Subject: [PATCH 63/95] dont use schemas in aggconfigs to output dsl (#26010) --- src/core_plugins/kibana/public/visualize/editor/editor.js | 1 + .../public/visualize/saved_visualizations/_saved_vis.js | 3 +++ src/ui/public/agg_types/__tests__/buckets/_geo_hash.js | 2 +- src/ui/public/agg_types/buckets/geo_hash.js | 5 +++++ src/ui/public/vis/agg_configs.js | 4 ++-- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/core_plugins/kibana/public/visualize/editor/editor.js b/src/core_plugins/kibana/public/visualize/editor/editor.js index fa0a679c459d5..b501d84f10ac4 100644 --- a/src/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/core_plugins/kibana/public/visualize/editor/editor.js @@ -423,6 +423,7 @@ function VisEditor( const searchSourceGrandparent = searchSourceParent.getParent(); delete savedVis.savedSearchId; + delete vis.savedSearchId; searchSourceParent.setField('filter', _.union(searchSource.getOwnField('filter'), searchSourceParent.getOwnField('filter'))); $state.query = searchSourceParent.getField('query'); diff --git a/src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js b/src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js index 8909fabb97b33..0e31ccf313863 100644 --- a/src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js +++ b/src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js @@ -141,6 +141,8 @@ uiModules self.visState ); + self.vis.savedSearchId = self.savedSearchId; + return self.vis; }; @@ -150,6 +152,7 @@ uiModules self.vis.indexPattern = self.searchSource.getField('index'); self.visState.title = self.title; self.vis.setState(self.visState); + self.vis.savedSearchId = self.savedSearchId; }; return SavedVis; diff --git a/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js b/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js index a0736ebd2f526..041030a9afb2a 100644 --- a/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js +++ b/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js @@ -94,7 +94,7 @@ describe('Geohash Agg', () => { describe('precision parameter', () => { - const PRECISION_PARAM_INDEX = 6; + const PRECISION_PARAM_INDEX = 7; let precisionParam; beforeEach(() => { precisionParam = geoHashBucketAgg.params[PRECISION_PARAM_INDEX]; diff --git a/src/ui/public/agg_types/buckets/geo_hash.js b/src/ui/public/agg_types/buckets/geo_hash.js index 1ade0f904c332..a532b9d6780b5 100644 --- a/src/ui/public/agg_types/buckets/geo_hash.js +++ b/src/ui/public/agg_types/buckets/geo_hash.js @@ -100,6 +100,11 @@ export const geoHashBucketAgg = new BucketAggType({ default: [0, 0], write: _.noop }, + { + name: 'mapBounds', + default: null, + write: _.noop + }, { name: 'precision', editor: precisionTemplate, diff --git a/src/ui/public/vis/agg_configs.js b/src/ui/public/vis/agg_configs.js index 6aebeabd08159..33ba6e163d2ec 100644 --- a/src/ui/public/vis/agg_configs.js +++ b/src/ui/public/vis/agg_configs.js @@ -52,7 +52,7 @@ class AggConfigs extends IndexedArray { super({ index: ['id'], - group: ['schema.group', 'type.name', 'schema.name'], + group: ['schema.group', 'type.name', 'type.type', 'schema.name'], }); this.indexPattern = indexPattern; @@ -152,7 +152,7 @@ class AggConfigs extends IndexedArray { if (hierarchical) { // collect all metrics, and filter out the ones that we won't be copying - nestedMetrics = _(this.bySchemaGroup.metrics) + nestedMetrics = _(this.byTypeType.metrics) .filter(function (agg) { return agg.type.name !== 'count'; }) From bcb5ee0e7de539d60875e3aab780d49c1e1ff43d Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Thu, 22 Nov 2018 10:12:15 +0100 Subject: [PATCH 64/95] Add en for numeral locale setting (#25948) --- src/core_plugins/kibana/ui_setting_defaults.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core_plugins/kibana/ui_setting_defaults.js b/src/core_plugins/kibana/ui_setting_defaults.js index 3b43d99550313..76b916656e554 100644 --- a/src/core_plugins/kibana/ui_setting_defaults.js +++ b/src/core_plugins/kibana/ui_setting_defaults.js @@ -24,9 +24,11 @@ import { IS_KIBANA_RELEASE } from '../../utils'; export function getUiSettingDefaults() { const weekdays = moment.weekdays().slice(); const [defaultWeekday] = weekdays; - const numeralLanguageIds = numeralLanguages.map(function (numeralLanguage) { + // We add the `en` key manually here, since that's not a real numeral locale, but the + // default fallback in case the locale is not found. + const numeralLanguageIds = ['en', ...numeralLanguages.map(function (numeralLanguage) { return numeralLanguage.id; - }); + })]; // wrapped in provider so that a new instance is given to each app/test return { From acff23e810a487fe787a58cd1d575c74745c0b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Thu, 22 Nov 2018 10:30:25 +0100 Subject: [PATCH 65/95] [APM] Migrate to Typescript and refactor backend apis (#25848) --- package.json | 3 +- src/ui/public/kfetch/index.ts | 2 +- src/ui/public/kfetch/kfetch.ts | 2 +- .../__snapshots__/DetailView.test.js.snap | 4 +- .../app/TraceOverview/TraceList.tsx | 4 +- .../components/app/TraceOverview/view.tsx | 4 +- .../TransactionDetails/Distribution/index.tsx | 6 +- .../app/TransactionDetails/view.tsx | 4 +- .../components/shared/DiscoverButton.tsx | 9 +- .../components/shared/ManagedTable/index.tsx | 4 +- .../PropertiesTable/NestedKeyValueTable.tsx | 6 +- .../CustomPlot/test/responseWithData.json | 11 +- ...onStorageMock.js => SessionStorageMock.ts} | 12 +- .../{callApi.test.js => callApi.test.ts} | 5 +- .../plugins/apm/public/services/rest/apm.ts | 60 +- .../services/rest/{callApi.js => callApi.ts} | 12 +- .../public/store/mockData/mockTraceList.json | 30 - ...Charts.js => transactionDetailsCharts.tsx} | 32 +- .../transactionDistribution.tsx | 6 +- ...harts.js => transactionOverviewCharts.tsx} | 29 +- .../store/reactReduxRequest/waterfallV2.tsx | 4 +- ...st.js.snap => chartSelectors.test.ts.snap} | 0 ...lectors.test.js => chartSelectors.test.ts} | 32 +- .../__tests__/mockData/anomalyData.json | 186 -- .../__tests__/mockData/anomalyData.ts | 192 ++ .../{chartSelectors.js => chartSelectors.ts} | 127 +- x-pack/plugins/apm/public/store/urlParams.ts | 4 +- x-pack/plugins/apm/public/utils/url.tsx | 7 +- .../get_bucket_size/{index.js => index.ts} | 26 +- .../apm/server/lib/helpers/setup_request.ts | 20 +- .../lib/helpers/transaction_group_query.ts | 95 - .../apm/server/lib/services/get_service.ts | 24 +- .../apm/server/lib/services/get_services.ts | 14 +- .../apm/server/lib/traces/get_top_traces.ts | 93 +- .../apm/server/lib/traces/get_trace.ts | 13 +- .../__snapshots__/fetcher.test.ts.snap | 56 + .../__snapshots__/transform.test.ts.snap | 2822 ++++++++++++++++ .../lib/transaction_groups/fetcher.test.ts | 34 + .../server/lib/transaction_groups/fetcher.ts | 85 + .../server/lib/transaction_groups/index.ts | 20 + .../transactionGroupsResponse.ts | 2700 ++++++++++++++++ .../lib/transaction_groups/transform.test.ts | 57 + .../lib/transaction_groups/transform.ts | 61 + .../get_timeseries_data.test.js.snap | 1240 -------- .../__test__/get_timeseries_data.test.js | 63 - .../response_time_anomaly_response.json | 1175 ------- .../charts/__test__/timeseries_response.json | 2821 ---------------- ...s_with_initial_anomaly_bounds.test.ts.snap | 46 + ...s_with_initial_anomaly_bounds.test.js.snap | 118 - .../__test__/get_anomaly_aggs.test.ts | 27 - .../mockData/firstBucketsResponse.json | 83 - .../mockData/mainBucketsResponse.json | 152 - .../__snapshots__/fetcher.test.ts.snap | 73 + .../__snapshots__/transform.test.ts.snap | 49 + .../get_anomaly_aggs/fetcher.test.ts | 55 + .../fetcher.ts} | 52 +- .../get_anomaly_aggs/index.ts | 13 + .../get_anomaly_aggs/transform.test.ts | 18 + .../get_anomaly_aggs/transform.ts | 37 + ...get_buckets_with_initial_anomaly_bounds.js | 52 - ...ckets_with_initial_anomaly_bounds.test.ts} | 30 +- ...get_buckets_with_initial_anomaly_bounds.ts | 66 + ...e_time_anomalies.test.js => index.test.ts} | 22 +- ...vg_response_time_anomalies.js => index.ts} | 56 +- .../mock-responses/firstBucketsResponse.ts | 89 + .../mock-responses/mainBucketsResponse.ts | 159 + .../__snapshots__/fetcher.test.ts.snap | 93 + .../__snapshots__/transform.test.ts.snap | 682 ++++ .../get_timeseries_data/fetcher.test.ts | 37 + .../fetcher.ts} | 132 +- .../charts/get_timeseries_data/index.ts | 31 + .../mock-responses/timeseries_response.ts | 2829 +++++++++++++++++ .../get_timeseries_data/transform.test.ts | 116 + .../charts/get_timeseries_data/transform.ts | 107 + .../distribution/calculate_bucket_size.ts | 11 +- .../fetcher.ts} | 68 +- .../distribution/get_buckets/index.ts | 25 + .../distribution/get_buckets/transform.ts | 62 + .../{get_distribution.ts => index.ts} | 26 +- .../lib/transactions/get_top_transactions.ts | 63 - .../get_top_transactions/index.ts | 47 + .../index.ts} | 12 +- .../lib/transactions/spans/get_spans.ts | 12 +- x-pack/plugins/apm/server/routes/services.ts | 1 - x-pack/plugins/apm/server/routes/traces.ts | 1 - .../plugins/apm/server/routes/transactions.ts | 4 +- x-pack/plugins/apm/typings/APMDoc.ts | 4 +- x-pack/plugins/apm/typings/Error.ts | 2 +- x-pack/plugins/apm/typings/Span.ts | 2 +- x-pack/plugins/apm/typings/Transaction.ts | 7 +- .../plugins/apm/typings/TransactionGroup.ts | 16 - x-pack/plugins/apm/typings/elasticsearch.ts | 16 + .../{waterfall.ts => lodash.mean.d.ts} | 8 +- x-pack/plugins/apm/typings/numeral.d.ts | 2 +- yarn.lock | 216 +- 95 files changed, 11218 insertions(+), 6827 deletions(-) rename x-pack/plugins/apm/public/services/__test__/{SessionStorageMock.js => SessionStorageMock.ts} (65%) rename x-pack/plugins/apm/public/services/__test__/{callApi.test.js => callApi.test.ts} (98%) rename x-pack/plugins/apm/public/services/rest/{callApi.js => callApi.ts} (81%) delete mode 100644 x-pack/plugins/apm/public/store/mockData/mockTraceList.json rename x-pack/plugins/apm/public/store/reactReduxRequest/{transactionDetailsCharts.js => transactionDetailsCharts.tsx} (64%) rename x-pack/plugins/apm/public/store/reactReduxRequest/{transactionOverviewCharts.js => transactionOverviewCharts.tsx} (69%) rename x-pack/plugins/apm/public/store/selectors/__tests__/__snapshots__/{chartSelectors.test.js.snap => chartSelectors.test.ts.snap} (100%) rename x-pack/plugins/apm/public/store/selectors/__tests__/{chartSelectors.test.js => chartSelectors.test.ts} (79%) delete mode 100644 x-pack/plugins/apm/public/store/selectors/__tests__/mockData/anomalyData.json create mode 100644 x-pack/plugins/apm/public/store/selectors/__tests__/mockData/anomalyData.ts rename x-pack/plugins/apm/public/store/selectors/{chartSelectors.js => chartSelectors.ts} (58%) rename x-pack/plugins/apm/server/lib/helpers/get_bucket_size/{index.js => index.ts} (58%) delete mode 100644 x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts create mode 100644 x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/fetcher.test.ts.snap create mode 100644 x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/transform.test.ts.snap create mode 100644 x-pack/plugins/apm/server/lib/transaction_groups/fetcher.test.ts create mode 100644 x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts create mode 100644 x-pack/plugins/apm/server/lib/transaction_groups/index.ts create mode 100644 x-pack/plugins/apm/server/lib/transaction_groups/mock-responses/transactionGroupsResponse.ts create mode 100644 x-pack/plugins/apm/server/lib/transaction_groups/transform.test.ts create mode 100644 x-pack/plugins/apm/server/lib/transaction_groups/transform.ts delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/__test__/__snapshots__/get_timeseries_data.test.js.snap delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/__test__/get_timeseries_data.test.js delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/__test__/response_time_anomaly_response.json delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/__test__/timeseries_response.json create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__snapshots__/get_buckets_with_initial_anomaly_bounds.test.ts.snap delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/__snapshots__/get_buckets_with_initial_anomaly_bounds.test.js.snap delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/mockData/firstBucketsResponse.json delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/mockData/mainBucketsResponse.json create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/__snapshots__/fetcher.test.ts.snap create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/__snapshots__/transform.test.ts.snap create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/fetcher.test.ts rename x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/{get_anomaly_aggs.js => get_anomaly_aggs/fetcher.ts} (61%) create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/index.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform.test.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform.ts delete mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.js rename x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/{__test__/get_buckets_with_initial_anomaly_bounds.test.js => get_buckets_with_initial_anomaly_bounds.test.ts} (55%) create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.ts rename x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/{__test__/get_avg_response_time_anomalies.test.js => index.test.ts} (66%) rename x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/{get_avg_response_time_anomalies.js => index.ts} (54%) create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/mock-responses/firstBucketsResponse.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/mock-responses/mainBucketsResponse.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/__snapshots__/fetcher.test.ts.snap create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/__snapshots__/transform.test.ts.snap create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/fetcher.test.ts rename x-pack/plugins/apm/server/lib/transactions/charts/{get_timeseries_data.js => get_timeseries_data/fetcher.ts} (52%) create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/index.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/mock-responses/timeseries_response.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform.test.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform.ts rename x-pack/plugins/apm/server/lib/transactions/distribution/{get_buckets.ts => get_buckets/fetcher.ts} (58%) create mode 100644 x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/index.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/transform.ts rename x-pack/plugins/apm/server/lib/transactions/distribution/{get_distribution.ts => index.ts} (59%) delete mode 100644 x-pack/plugins/apm/server/lib/transactions/get_top_transactions.ts create mode 100644 x-pack/plugins/apm/server/lib/transactions/get_top_transactions/index.ts rename x-pack/plugins/apm/server/lib/transactions/{get_transaction.ts => get_transaction/index.ts} (82%) delete mode 100644 x-pack/plugins/apm/typings/TransactionGroup.ts rename x-pack/plugins/apm/typings/{waterfall.ts => lodash.mean.d.ts} (64%) diff --git a/package.json b/package.json index b0555fad091e1..301a43b94cd2b 100644 --- a/package.json +++ b/package.json @@ -243,7 +243,7 @@ "@types/boom": "^7.2.0", "@types/chance": "^1.0.0", "@types/classnames": "^2.2.3", - "@types/d3": "^5.0.0", + "@types/d3": "^3.5.41", "@types/dedent": "^0.7.0", "@types/del": "^3.0.1", "@types/elasticsearch": "^5.0.26", @@ -257,6 +257,7 @@ "@types/hapi": "^17.0.18", "@types/has-ansi": "^3.0.0", "@types/hoek": "^4.1.3", + "@types/humps": "^1.1.2", "@types/jest": "^23.3.1", "@types/joi": "^13.4.2", "@types/jquery": "^3.3.6", diff --git a/src/ui/public/kfetch/index.ts b/src/ui/public/kfetch/index.ts index 1b0861da9fc1b..f871d97f0fd54 100644 --- a/src/ui/public/kfetch/index.ts +++ b/src/ui/public/kfetch/index.ts @@ -17,5 +17,5 @@ * under the License. */ -export { kfetch, addInterceptor } from './kfetch'; +export { kfetch, addInterceptor, KFetchOptions } from './kfetch'; export { kfetchAbortable } from './kfetch_abortable'; diff --git a/src/ui/public/kfetch/kfetch.ts b/src/ui/public/kfetch/kfetch.ts index 2d93c89f57d2b..06edae2d9e756 100644 --- a/src/ui/public/kfetch/kfetch.ts +++ b/src/ui/public/kfetch/kfetch.ts @@ -26,7 +26,7 @@ import chrome from '../chrome'; import { KFetchError } from './kfetch_error'; interface KFetchQuery { - [key: string]: string | number | boolean; + [key: string]: string | number | boolean | undefined; } export interface KFetchOptions extends RequestInit { diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap index 393a73aaf2a68..d0a6b69f71ed2 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap @@ -12,7 +12,7 @@ exports[`DetailView should render with data 1`] = ` > Error occurrence - View 18 occurences in Discover - + ) => ( + render={({ data, status }: RRRRenderResponse) => ( ) => ( + render={({ data }) => ( = ({ + query, + children, + ...rest +}) => { return ( ); -} +}; diff --git a/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx b/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx index 1b426121fce63..447c34b0189aa 100644 --- a/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx @@ -18,7 +18,7 @@ export interface ITableColumn { align?: string; width?: string; sortable?: boolean; - render?: (value: any, item?: any) => any; + render?: (value: any, item?: any) => unknown; } export interface IManagedTableProps { @@ -31,7 +31,7 @@ export interface IManagedTableProps { field: string; direction: 'asc' | 'desc'; }; - noItemsMessage?: any; + noItemsMessage?: React.ReactNode; } export class ManagedTable extends Component { diff --git a/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx b/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx index 4804adbc80e4a..bea0f145bbac4 100644 --- a/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx +++ b/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx @@ -17,7 +17,7 @@ import { units } from '../../../style/variables'; -export type KeySorter = (data: StringMap, parentKey?: string) => string[]; +export type KeySorter = (data: StringMap, parentKey?: string) => string[]; const Table = styled.table` font-family: ${fontFamilyCode}; @@ -60,7 +60,7 @@ export function FormattedKey({ value }: { k: string; - value: any; + value: unknown; }): JSX.Element { if (value == null) { return {k}; @@ -87,7 +87,7 @@ export function NestedValue({ depth, keySorter }: { - value: any; + value: StringMap; depth: number; parentKey?: string; keySorter?: KeySorter; diff --git a/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/responseWithData.json b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/responseWithData.json index 472f2b65861ca..9efb6e7d9a531 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/responseWithData.json +++ b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/responseWithData.json @@ -131,13 +131,12 @@ 2547299.079999993, 4586742.89999998, 0 - ], - "avgAnomalies": {} + ] }, "tpmBuckets": [ { "key": "2xx", - "avg": "41.61538461538461", + "avg": 41.61538461538461, "values": [ 0, 0, @@ -174,7 +173,7 @@ }, { "key": "3xx", - "avg": "0", + "avg": 0, "values": [ 0, 0, @@ -211,7 +210,7 @@ }, { "key": "4xx", - "avg": "1.4615384615384615", + "avg": 1.4615384615384615, "values": [ 0, 0, @@ -248,7 +247,7 @@ }, { "key": "5xx", - "avg": "5.6923076923076925", + "avg": 5.6923076923076925, "values": [ 0, 0, diff --git a/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.js b/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts similarity index 65% rename from x-pack/plugins/apm/public/services/__test__/SessionStorageMock.js rename to x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts index c42d84b1da1d7..2423cbd11a2d0 100644 --- a/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.js +++ b/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts @@ -4,22 +4,24 @@ * you may not use this file except in compliance with the Elastic License. */ +import { StringMap } from 'x-pack/plugins/apm/typings/common'; + export class SessionStorageMock { - store = {}; + private store: StringMap = {}; - clear() { + public clear() { this.store = {}; } - getItem(key) { + public getItem(key: string) { return this.store[key] || null; } - setItem(key, value) { + public setItem(key: string, value: any) { this.store[key] = value.toString(); } - removeItem(key) { + public removeItem(key: string) { delete this.store[key]; } } diff --git a/x-pack/plugins/apm/public/services/__test__/callApi.test.js b/x-pack/plugins/apm/public/services/__test__/callApi.test.ts similarity index 98% rename from x-pack/plugins/apm/public/services/__test__/callApi.test.js rename to x-pack/plugins/apm/public/services/__test__/callApi.test.ts index 7e5439b2e6eb4..9533902fe39f8 100644 --- a/x-pack/plugins/apm/public/services/__test__/callApi.test.js +++ b/x-pack/plugins/apm/public/services/__test__/callApi.test.ts @@ -5,16 +5,17 @@ */ import * as kfetchModule from 'ui/kfetch'; -import { SessionStorageMock } from './SessionStorageMock'; import { callApi } from '../rest/callApi'; +import { SessionStorageMock } from './SessionStorageMock'; describe('callApi', () => { - let kfetchSpy; + let kfetchSpy: jest.Mock; beforeEach(() => { kfetchSpy = jest.spyOn(kfetchModule, 'kfetch').mockResolvedValue({ my_key: 'hello world' }); + // @ts-ignore global.sessionStorage = new SessionStorageMock(); }); diff --git a/x-pack/plugins/apm/public/services/rest/apm.ts b/x-pack/plugins/apm/public/services/rest/apm.ts index d065be4fa28a2..692c360980ef8 100644 --- a/x-pack/plugins/apm/public/services/rest/apm.ts +++ b/x-pack/plugins/apm/public/services/rest/apm.ts @@ -6,17 +6,20 @@ // @ts-ignore import { camelizeKeys } from 'humps'; -import { ServiceResponse } from 'x-pack/plugins/apm/server/lib/services/get_service'; -import { IServiceListItem } from 'x-pack/plugins/apm/server/lib/services/get_services'; -import { IDistributionResponse } from 'x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution'; +import { ServiceAPIResponse } from 'x-pack/plugins/apm/server/lib/services/get_service'; +import { ServiceListAPIResponse } from 'x-pack/plugins/apm/server/lib/services/get_services'; +import { TraceListAPIResponse } from 'x-pack/plugins/apm/server/lib/traces/get_top_traces'; +import { TraceAPIResponse } from 'x-pack/plugins/apm/server/lib/traces/get_trace'; +import { TimeSeriesAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform'; +import { ITransactionDistributionAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/distribution'; +import { TransactionListAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/get_top_transactions'; +import { TransactionAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/get_transaction'; +import { SpanListAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/spans/get_spans'; import { Span } from 'x-pack/plugins/apm/typings/Span'; import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; -import { ITransactionGroup } from 'x-pack/plugins/apm/typings/TransactionGroup'; -import { WaterfallResponse } from 'x-pack/plugins/apm/typings/waterfall'; import { IUrlParams } from '../../store/urlParams'; // @ts-ignore import { convertKueryToEsQuery } from '../kuery'; -// @ts-ignore import { callApi } from './callApi'; // @ts-ignore import { getAPMIndexPattern } from './savedObjects'; @@ -34,7 +37,7 @@ export async function loadServerStatus() { } export async function loadAgentStatus() { - return callApi({ + return callApi<{ dataFound: boolean }>({ pathname: `/api/apm/status/agent` }); } @@ -54,12 +57,8 @@ export async function getEncodedEsQuery(kuery?: string) { return encodeURIComponent(JSON.stringify(esFilterQuery)); } -export async function loadServiceList({ - start, - end, - kuery -}: IUrlParams): Promise { - return callApi({ +export async function loadServiceList({ start, end, kuery }: IUrlParams) { + return callApi({ pathname: `/api/apm/services`, query: { start, @@ -74,8 +73,8 @@ export async function loadServiceDetails({ start, end, kuery -}: IUrlParams): Promise { - return callApi({ +}: IUrlParams) { + return callApi({ pathname: `/api/apm/services/${serviceName}`, query: { start, @@ -85,12 +84,8 @@ export async function loadServiceDetails({ }); } -export async function loadTraceList({ - start, - end, - kuery -}: IUrlParams): Promise { - const groups: ITransactionGroup[] = await callApi({ +export async function loadTraceList({ start, end, kuery }: IUrlParams) { + const groups = await callApi({ pathname: '/api/apm/traces', query: { start, @@ -111,8 +106,8 @@ export async function loadTransactionList({ end, kuery, transactionType -}: IUrlParams): Promise { - const groups: ITransactionGroup[] = await callApi({ +}: IUrlParams) { + const groups = await callApi({ pathname: `/api/apm/services/${serviceName}/transactions`, query: { start, @@ -134,8 +129,8 @@ export async function loadTransactionDistribution({ end, transactionName, kuery -}: IUrlParams): Promise { - return callApi({ +}: IUrlParams) { + return callApi({ pathname: `/api/apm/services/${serviceName}/transactions/distribution`, query: { start, @@ -168,8 +163,8 @@ export async function loadSpans({ start, end, transactionId -}: IUrlParams): Promise { - const hits: Span[] = await callApi({ +}: IUrlParams) { + const hits = await callApi({ pathname: `/api/apm/services/${serviceName}/transactions/${transactionId}/spans`, query: { start, @@ -181,7 +176,7 @@ export async function loadSpans({ } export async function loadTrace({ traceId, start, end }: IUrlParams) { - const hits: WaterfallResponse = await callApi( + const hits = await callApi( { pathname: `/api/apm/traces/${traceId}`, query: { @@ -205,7 +200,7 @@ export async function loadTransaction({ traceId, kuery }: IUrlParams) { - const result: Transaction | null = await callApi( + const result = await callApi( { pathname: `/api/apm/services/${serviceName}/transactions/${transactionId}`, query: { @@ -231,7 +226,7 @@ export async function loadCharts({ transactionType, transactionName }: IUrlParams) { - return callApi({ + return callApi({ pathname: `/api/apm/services/${serviceName}/transactions/charts`, query: { start, @@ -278,7 +273,8 @@ export async function loadErrorGroupDetails({ kuery, errorGroupId }: IUrlParams) { - const res = await callApi( + // TODO: add types when error section is converted to ts + const res = await callApi( { pathname: `/api/apm/services/${serviceName}/errors/${errorGroupId}`, query: { @@ -291,7 +287,7 @@ export async function loadErrorGroupDetails({ camelcase: false } ); - const camelizedRes = camelizeKeys(res); + const camelizedRes: any = camelizeKeys(res); if (res.error.context) { camelizedRes.error.context = res.error.context; } diff --git a/x-pack/plugins/apm/public/services/rest/callApi.js b/x-pack/plugins/apm/public/services/rest/callApi.ts similarity index 81% rename from x-pack/plugins/apm/public/services/rest/callApi.js rename to x-pack/plugins/apm/public/services/rest/callApi.ts index d33bea0644d5d..3de91a3f5e98f 100644 --- a/x-pack/plugins/apm/public/services/rest/callApi.js +++ b/x-pack/plugins/apm/public/services/rest/callApi.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import 'isomorphic-fetch'; import { camelizeKeys } from 'humps'; -import { kfetch } from 'ui/kfetch'; +import 'isomorphic-fetch'; import { startsWith } from 'lodash'; +import { kfetch, KFetchOptions } from 'ui/kfetch'; -function fetchOptionsWithDebug(fetchOptions) { +function fetchOptionsWithDebug(fetchOptions: KFetchOptions) { const debugEnabled = sessionStorage.getItem('apm_debug') === 'true' && startsWith(fetchOptions.pathname, '/api/apm'); @@ -27,10 +27,10 @@ function fetchOptionsWithDebug(fetchOptions) { }; } -export async function callApi( - fetchOptions, +export async function callApi( + fetchOptions: KFetchOptions, { camelcase = true, prependBasePath = true } = {} -) { +): Promise { const combinedFetchOptions = fetchOptionsWithDebug(fetchOptions); const res = await kfetch(combinedFetchOptions, { prependBasePath }); return camelcase ? camelizeKeys(res) : res; diff --git a/x-pack/plugins/apm/public/store/mockData/mockTraceList.json b/x-pack/plugins/apm/public/store/mockData/mockTraceList.json deleted file mode 100644 index 4e97a030a2621..0000000000000 --- a/x-pack/plugins/apm/public/store/mockData/mockTraceList.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "name": "log", - "serviceName": "flask-server", - "averageResponseTime": 1329, - "tracesPerMinute": 3201, - "impact": 70 - }, - { - "name": "products/item", - "serviceName": "client", - "averageResponseTime": 2301, - "tracesPerMinute": 5432, - "impact": 42 - }, - { - "name": "billing/payment", - "serviceName": "client", - "averageResponseTime": 789, - "tracesPerMinute": 1201, - "impact": 14 - }, - { - "name": "user/profile", - "serviceName": "client", - "averageResponseTime": 1212, - "tracesPerMinute": 904, - "impact": 92 - } -] diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetailsCharts.js b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetailsCharts.tsx similarity index 64% rename from x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetailsCharts.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetailsCharts.tsx index 484555bf86328..45c0d3e9f53d1 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetailsCharts.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetailsCharts.tsx @@ -5,36 +5,44 @@ */ import React from 'react'; +import { Request, RRRRender } from 'react-redux-request'; import { createSelector } from 'reselect'; -import { getCharts } from '../selectors/chartSelectors'; -import { getUrlParams } from '../urlParams'; -import { Request } from 'react-redux-request'; +import { TimeSeriesAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform'; import { loadCharts } from '../../services/rest/apm'; -import { createInitialDataSelector } from './helpers'; +import { IReduxState } from '../rootReducer'; +import { getCharts } from '../selectors/chartSelectors'; +import { getUrlParams, IUrlParams } from '../urlParams'; const ID = 'transactionDetailsCharts'; const INITIAL_DATA = { totalHits: 0, dates: [], - responseTimes: {}, + responseTimes: { + avg: [], + p95: [], + p99: [] + }, tpmBuckets: [], - overallAvgDuration: null + overallAvgDuration: undefined }; -const withInitialData = createInitialDataSelector(INITIAL_DATA); - export const getTransactionDetailsCharts = createSelector( getUrlParams, - state => withInitialData(state.reactReduxRequest[ID]), - (urlParams, detailCharts) => { + (state: IReduxState) => state.reactReduxRequest[ID], + (urlParams, detailCharts = {}) => { return { ...detailCharts, - data: getCharts(urlParams, detailCharts.data) + data: getCharts(urlParams, detailCharts.data || INITIAL_DATA) }; } ); -export function TransactionDetailsChartsRequest({ urlParams, render }) { +interface Props { + urlParams: IUrlParams; + render: RRRRender; +} + +export function TransactionDetailsChartsRequest({ urlParams, render }: Props) { const { serviceName, start, diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDistribution.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDistribution.tsx index b52644d6881d5..bf2e803b2c46c 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDistribution.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDistribution.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { Request, RRRRender, RRRRenderResponse } from 'react-redux-request'; -import { IDistributionResponse } from '../../../server/lib/transactions/distribution/get_distribution'; +import { ITransactionDistributionAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/distribution'; import { loadTransactionDistribution } from '../../services/rest/apm'; import { IReduxState } from '../rootReducer'; import { IUrlParams } from '../urlParams'; @@ -19,7 +19,7 @@ const withInitialData = createInitialDataSelector(INITIAL_DATA); export function getTransactionDistribution( state: IReduxState -): RRRRenderResponse { +): RRRRenderResponse { return withInitialData(state.reactReduxRequest[ID]); } @@ -37,7 +37,7 @@ export function TransactionDistributionRequest({ render }: { urlParams: IUrlParams; - render: RRRRender; + render: RRRRender; }) { const { serviceName, start, end, transactionName, kuery } = urlParams; diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionOverviewCharts.js b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionOverviewCharts.tsx similarity index 69% rename from x-pack/plugins/apm/public/store/reactReduxRequest/transactionOverviewCharts.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/transactionOverviewCharts.tsx index a5313c7efda10..87ecf58e0e338 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionOverviewCharts.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionOverviewCharts.tsx @@ -4,26 +4,32 @@ * you may not use this file except in compliance with the Elastic License. */ +import { get, isEmpty } from 'lodash'; import React from 'react'; +import { Request, RRRRender } from 'react-redux-request'; import { createSelector } from 'reselect'; -import { get, isEmpty } from 'lodash'; -import { getCharts } from '../selectors/chartSelectors'; -import { getUrlParams } from '../urlParams'; -import { Request } from 'react-redux-request'; +import { TimeSeriesAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform'; import { loadCharts } from '../../services/rest/apm'; +import { IReduxState } from '../rootReducer'; +import { getCharts } from '../selectors/chartSelectors'; +import { getUrlParams, IUrlParams } from '../urlParams'; const ID = 'transactionOverviewCharts'; const INITIAL_DATA = { totalHits: 0, dates: [], - responseTimes: {}, + responseTimes: { + avg: [], + p95: [], + p99: [] + }, tpmBuckets: [], - overallAvgDuration: null + overallAvgDuration: undefined }; export const getTransactionOverviewCharts = createSelector( getUrlParams, - state => state.reactReduxRequest[ID], + (state: IReduxState) => state.reactReduxRequest[ID], (urlParams, overviewCharts = {}) => { return { ...overviewCharts, @@ -32,7 +38,7 @@ export const getTransactionOverviewCharts = createSelector( } ); -export function hasDynamicBaseline(state) { +export function hasDynamicBaseline(state: IReduxState) { return !isEmpty( get( state, @@ -41,7 +47,12 @@ export function hasDynamicBaseline(state) { ); } -export function TransactionOverviewChartsRequest({ urlParams, render }) { +interface Props { + urlParams: IUrlParams; + render: RRRRender; +} + +export function TransactionOverviewChartsRequest({ urlParams, render }: Props) { const { serviceName, start, end, transactionType, kuery } = urlParams; if (!(serviceName && start && end && transactionType)) { diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx index 43e4f65c91d4b..996c80bb8a055 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx @@ -8,8 +8,8 @@ import { get } from 'lodash'; import React from 'react'; import { Request, RRRRender } from 'react-redux-request'; import { TRACE_ID } from 'x-pack/plugins/apm/common/constants'; +import { TraceAPIResponse } from 'x-pack/plugins/apm/server/lib/traces/get_trace'; import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; -import { WaterfallResponse } from 'x-pack/plugins/apm/typings/waterfall'; import { getWaterfall, IWaterfall @@ -36,7 +36,7 @@ export function WaterfallV2Request({ urlParams, transaction, render }: Props) { } return ( - + id={ID} fn={loadTrace} args={[{ traceId, start, end }]} diff --git a/x-pack/plugins/apm/public/store/selectors/__tests__/__snapshots__/chartSelectors.test.js.snap b/x-pack/plugins/apm/public/store/selectors/__tests__/__snapshots__/chartSelectors.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/public/store/selectors/__tests__/__snapshots__/chartSelectors.test.js.snap rename to x-pack/plugins/apm/public/store/selectors/__tests__/__snapshots__/chartSelectors.test.ts.snap diff --git a/x-pack/plugins/apm/public/store/selectors/__tests__/chartSelectors.test.js b/x-pack/plugins/apm/public/store/selectors/__tests__/chartSelectors.test.ts similarity index 79% rename from x-pack/plugins/apm/public/store/selectors/__tests__/chartSelectors.test.js rename to x-pack/plugins/apm/public/store/selectors/__tests__/chartSelectors.test.ts index 1850fd990c957..608a87ee48f2c 100644 --- a/x-pack/plugins/apm/public/store/selectors/__tests__/chartSelectors.test.js +++ b/x-pack/plugins/apm/public/store/selectors/__tests__/chartSelectors.test.ts @@ -4,14 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ +import { AvgAnomalyBucket } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform'; +import { TimeSeriesAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform'; import { + getAnomalyBoundaryValues, getAnomalyScoreValues, getResponseTimeSeries, - getTpmSeries, - getAnomalyBoundaryValues + getTpmSeries } from '../chartSelectors'; - -import anomalyData from './mockData/anomalyData.json'; +import { anomalyData } from './mockData/anomalyData'; describe('chartSelectors', () => { describe('getAnomalyScoreValues', () => { @@ -39,7 +40,7 @@ describe('chartSelectors', () => { { anomalyScore: 0 } - ]; + ] as AvgAnomalyBucket[]; expect(getAnomalyScoreValues(dates, buckets, 1000)).toEqual([ { x: 1000, y: 1 }, @@ -58,11 +59,10 @@ describe('chartSelectors', () => { responseTimes: { avg: [100, 200, 150, 250, 100, 50], p95: [200, 300, 250, 350, 200, 150], - p99: [300, 400, 350, 450, 100, 50], - avgAnomalies: {} + p99: [300, 400, 350, 450, 100, 50] }, overallAvgDuration: 200 - }; + } as TimeSeriesAPIResponse; it('should match snapshot', () => { expect(getResponseTimeSeries(chartsData)).toMatchSnapshot(); @@ -93,7 +93,7 @@ describe('chartSelectors', () => { values: [0, 1, 2, 1, 0, 2] } ] - }; + } as TimeSeriesAPIResponse; const transactionType = 'MyTransactionType'; @@ -104,10 +104,10 @@ describe('chartSelectors', () => { describe('getAnomalyBoundaryValues', () => { const { dates, buckets } = anomalyData; - const bucketSpan = 240000; + const bucketSize = 240000; it('should return correct buckets', () => { - expect(getAnomalyBoundaryValues(dates, buckets, bucketSpan)).toEqual([ + expect(getAnomalyBoundaryValues(dates, buckets, bucketSize)).toEqual([ { x: 1530614880000, y: 54799, y0: 15669 }, { x: 1530615060000, y: 49874, y0: 17808 }, { x: 1530615300000, y: 49421, y0: 18012 }, @@ -120,18 +120,18 @@ describe('chartSelectors', () => { ]); }); - it('should extend the last bucket with a size of bucketSpan', () => { + it('should extend the last bucket with a size of bucketSize', () => { const [lastBucket, secondLastBuckets] = getAnomalyBoundaryValues( dates, buckets, - bucketSpan + bucketSize ).reverse(); expect(secondLastBuckets.y).toBe(lastBucket.y); expect(secondLastBuckets.y0).toBe(lastBucket.y0); - expect(lastBucket.x - secondLastBuckets.x).toBeLessThanOrEqual( - bucketSpan - ); + expect( + (lastBucket.x as number) - (secondLastBuckets.x as number) + ).toBeLessThanOrEqual(bucketSize); }); }); }); diff --git a/x-pack/plugins/apm/public/store/selectors/__tests__/mockData/anomalyData.json b/x-pack/plugins/apm/public/store/selectors/__tests__/mockData/anomalyData.json deleted file mode 100644 index d91fc736801a7..0000000000000 --- a/x-pack/plugins/apm/public/store/selectors/__tests__/mockData/anomalyData.json +++ /dev/null @@ -1,186 +0,0 @@ -{ - "dates": [ - 1530614880000, - 1530614940000, - 1530615000000, - 1530615060000, - 1530615120000, - 1530615180000, - 1530615240000, - 1530615300000, - 1530615360000, - 1530615420000, - 1530615480000, - 1530615540000, - 1530615600000, - 1530615660000, - 1530615720000, - 1530615780000, - 1530615840000, - 1530615900000, - 1530615960000, - 1530616020000, - 1530616080000, - 1530616140000, - 1530616200000, - 1530616260000, - 1530616320000, - 1530616380000, - 1530616440000, - 1530616500000, - 1530616560000, - 1530616620000 - ], - "buckets": [ - { - "anomalyScore": null, - "lower": 15669, - "upper": 54799 - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": 0, - "lower": 17808, - "upper": 49874 - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": 0, - "lower": 18012, - "upper": 49421 - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": 0, - "lower": 17889, - "upper": 49654 - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": 0, - "lower": 17713, - "upper": 50026 - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": 0, - "lower": 18044, - "upper": 49371 - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": 0, - "lower": 17713, - "upper": 50110 - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": 0, - "lower": 17582, - "upper": 50419 - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - }, - { - "anomalyScore": null, - "lower": null, - "upper": null - } - ] -} diff --git a/x-pack/plugins/apm/public/store/selectors/__tests__/mockData/anomalyData.ts b/x-pack/plugins/apm/public/store/selectors/__tests__/mockData/anomalyData.ts new file mode 100644 index 0000000000000..af864e69dc72a --- /dev/null +++ b/x-pack/plugins/apm/public/store/selectors/__tests__/mockData/anomalyData.ts @@ -0,0 +1,192 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const anomalyData = { + dates: [ + 1530614880000, + 1530614940000, + 1530615000000, + 1530615060000, + 1530615120000, + 1530615180000, + 1530615240000, + 1530615300000, + 1530615360000, + 1530615420000, + 1530615480000, + 1530615540000, + 1530615600000, + 1530615660000, + 1530615720000, + 1530615780000, + 1530615840000, + 1530615900000, + 1530615960000, + 1530616020000, + 1530616080000, + 1530616140000, + 1530616200000, + 1530616260000, + 1530616320000, + 1530616380000, + 1530616440000, + 1530616500000, + 1530616560000, + 1530616620000 + ], + buckets: [ + { + anomalyScore: null, + lower: 15669, + upper: 54799 + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: 0, + lower: 17808, + upper: 49874 + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: 0, + lower: 18012, + upper: 49421 + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: 0, + lower: 17889, + upper: 49654 + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: 0, + lower: 17713, + upper: 50026 + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: 0, + lower: 18044, + upper: 49371 + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: 0, + lower: 17713, + upper: 50110 + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: 0, + lower: 17582, + upper: 50419 + }, + { + anomalyScore: null, + lower: null, + upper: null + }, + { + anomalyScore: null, + lower: null, + upper: null + } + ] +}; diff --git a/x-pack/plugins/apm/public/store/selectors/chartSelectors.js b/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts similarity index 58% rename from x-pack/plugins/apm/public/store/selectors/chartSelectors.js rename to x-pack/plugins/apm/public/store/selectors/chartSelectors.ts index 534da52262d16..d9670364131aa 100644 --- a/x-pack/plugins/apm/public/store/selectors/chartSelectors.js +++ b/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts @@ -5,10 +5,23 @@ */ import d3 from 'd3'; -import { last, zipObject, difference, memoize, get, isEmpty } from 'lodash'; -import { colors } from '../../style/variables'; -import { asMillis, asDecimal, tpmUnit } from '../../utils/formatters'; +import { difference, last, memoize, zipObject } from 'lodash'; import { rgba } from 'polished'; +import { AvgAnomalyBucket } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform'; +import { TimeSeriesAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform'; +import { StringMap } from 'x-pack/plugins/apm/typings/common'; +import { colors } from '../../style/variables'; +import { asDecimal, asMillis, tpmUnit } from '../../utils/formatters'; +import { IUrlParams } from '../urlParams'; + +interface Coordinate { + x: number; + y?: number | null; +} + +interface BoundaryCoordinate extends Coordinate { + y0: number | null; +} export const getEmptySerie = memoize( (start = Date.now() - 3600000, end = Date.now()) => { @@ -26,10 +39,13 @@ export const getEmptySerie = memoize( } ]; }, - (...args) => args.join('_') + (start: number, end: number) => [start, end].join('_') ); -export function getCharts(urlParams, charts) { +export function getCharts( + urlParams: IUrlParams, + charts: TimeSeriesAPIResponse +) { const { start, end, transactionType } = urlParams; const noHits = charts.totalHits === 0; const tpmSeries = noHits @@ -47,11 +63,23 @@ export function getCharts(urlParams, charts) { }; } -export function getResponseTimeSeries(chartsData) { +interface TimeSerie { + title: string; + titleShort?: string; + hideLegend?: boolean; + hideTooltipValue?: boolean; + data: Coordinate[]; + legendValue?: string; + type: string; + color: string; + areaColor?: string; +} + +export function getResponseTimeSeries(chartsData: TimeSeriesAPIResponse) { const { dates, overallAvgDuration } = chartsData; const { avg, p95, p99, avgAnomalies } = chartsData.responseTimes; - const series = [ + const series: TimeSerie[] = [ { title: 'Avg.', data: getChartValues(dates, avg), @@ -75,7 +103,7 @@ export function getResponseTimeSeries(chartsData) { } ]; - if (!isEmpty(avgAnomalies.buckets)) { + if (avgAnomalies) { // insert after Avg. serie series.splice(1, 0, { title: 'Anomaly Boundaries', @@ -84,7 +112,7 @@ export function getResponseTimeSeries(chartsData) { data: getAnomalyBoundaryValues( dates, avgAnomalies.buckets, - avgAnomalies.bucketSpanAsMillis + avgAnomalies.bucketSizeAsMillis ), type: 'area', color: 'none', @@ -98,7 +126,7 @@ export function getResponseTimeSeries(chartsData) { data: getAnomalyScoreValues( dates, avgAnomalies.buckets, - avgAnomalies.bucketSpanAsMillis + avgAnomalies.bucketSizeAsMillis ), type: 'areaMaxHeight', color: 'none', @@ -109,10 +137,14 @@ export function getResponseTimeSeries(chartsData) { return series; } -export function getTpmSeries(chartsData, transactionType) { +export function getTpmSeries( + chartsData: TimeSeriesAPIResponse, + transactionType?: string +) { const { dates, tpmBuckets } = chartsData; - const getColor = getColorByKey(tpmBuckets.map(({ key }) => key)); - const getTpmLegendTitle = bucketKey => { + const bucketKeys = tpmBuckets.map(({ key }) => key); + const getColor = getColorByKey(bucketKeys); + const getTpmLegendTitle = (bucketKey: string) => { // hide legend text for transactions without "result" if (bucketKey === 'transaction_result_missing') { return ''; @@ -125,15 +157,15 @@ export function getTpmSeries(chartsData, transactionType) { return { title: getTpmLegendTitle(bucket.key), data: getChartValues(dates, bucket.values), - legendValue: `${asDecimal(bucket.avg)} ${tpmUnit(transactionType)}`, + legendValue: `${asDecimal(bucket.avg)} ${tpmUnit(transactionType || '')}`, type: 'line', color: getColor(bucket.key) }; }); } -function getColorByKey(keys) { - const assignedColors = { +function getColorByKey(keys: string[]) { + const assignedColors: StringMap = { 'HTTP 2xx': colors.apmGreen, 'HTTP 3xx': colors.apmYellow, 'HTTP 4xx': colors.apmOrange, @@ -141,7 +173,7 @@ function getColorByKey(keys) { }; const unknownKeys = difference(keys, Object.keys(assignedColors)); - const unassignedColors = zipObject(unknownKeys, [ + const unassignedColors: StringMap = zipObject(unknownKeys, [ colors.apmBlue, colors.apmPurple, colors.apmPink, @@ -150,10 +182,13 @@ function getColorByKey(keys) { colors.apmBrown ]); - return key => assignedColors[key] || unassignedColors[key]; + return (key: string) => assignedColors[key] || unassignedColors[key]; } -function getChartValues(dates = [], buckets = []) { +function getChartValues( + dates: number[] = [], + buckets: Array = [] +) { return dates.map((x, i) => ({ x, y: buckets[i] @@ -161,27 +196,32 @@ function getChartValues(dates = [], buckets = []) { } export function getAnomalyScoreValues( - dates = [], - buckets = [], - bucketSpanAsMillis + dates: number[] = [], + buckets: AvgAnomalyBucket[] = [], + bucketSizeAsMillis: number ) { const ANOMALY_THRESHOLD = 75; - const getX = (currentX, i) => currentX + bucketSpanAsMillis * i; + const getX = (currentX: number, i: number) => + currentX + bucketSizeAsMillis * i; return dates - .map((x, i) => { - const { anomalyScore } = buckets[i] || {}; + .map((date, i) => { + const { anomalyScore } = buckets[i]; return { - x, + x: date, anomalyScore }; }) - .filter(p => p.anomalyScore > ANOMALY_THRESHOLD) - .reduce((acc, p, i, points) => { - acc.push({ x: p.x, y: 1 }); - const { x: nextX } = points[i + 1] || {}; + .filter(p => { + const res = + p && p.anomalyScore != null && p.anomalyScore > ANOMALY_THRESHOLD; + return res; + }) + .reduce((acc, p, i, points) => { + const nextPoint = points[i + 1] || {}; const endX = getX(p.x, 1); - if (nextX == null || nextX > endX) { + acc.push({ x: p.x, y: 1 }); + if (nextPoint.x == null || nextPoint.x > endX) { acc.push( { x: endX, @@ -198,26 +238,29 @@ export function getAnomalyScoreValues( } export function getAnomalyBoundaryValues( - dates = [], - buckets = [], - bucketSpanAsMillis + dates: number[] = [], + buckets: AvgAnomalyBucket[] = [], + bucketSizeAsMillis: number ) { const lastX = last(dates); return dates - .map((x, i) => ({ - x, - y0: get(buckets[i], 'lower'), - y: get(buckets[i], 'upper') - })) - .filter(point => point.y != null) - .reduce((acc, p, i, points) => { + .map((date, i) => { + const bucket = buckets[i]; + return { + x: date, + y0: bucket.lower, + y: bucket.upper + }; + }) + .filter(p => p.y != null) + .reduce((acc, p, i, points) => { const isLast = last(points) === p; acc.push(p); if (isLast) { acc.push({ ...p, - x: Math.min(p.x + bucketSpanAsMillis, lastX) // avoid going beyond the last date + x: Math.min(p.x + bucketSizeAsMillis, lastX) // avoid going beyond the last date }); } return acc; diff --git a/x-pack/plugins/apm/public/store/urlParams.ts b/x-pack/plugins/apm/public/store/urlParams.ts index cedcbfe337fee..b0850aa2cf880 100644 --- a/x-pack/plugins/apm/public/store/urlParams.ts +++ b/x-pack/plugins/apm/public/store/urlParams.ts @@ -157,13 +157,13 @@ export const getUrlParams = createSelector( ); export interface IUrlParams { - end?: string; + end?: number; errorGroupId?: string; flyoutDetailTab?: string; detailTab?: string; kuery?: string; serviceName?: string; - start?: string; + start?: number; traceId?: string; transactionId?: string; transactionName?: string; diff --git a/x-pack/plugins/apm/public/utils/url.tsx b/x-pack/plugins/apm/public/utils/url.tsx index 6ae3fcb643a6c..f2b0dfc9a34f3 100644 --- a/x-pack/plugins/apm/public/utils/url.tsx +++ b/x-pack/plugins/apm/public/utils/url.tsx @@ -30,15 +30,14 @@ interface ViewMlJobArgs { serviceName: string; transactionType: string; location: any; - children?: any; } -export function ViewMLJob({ +export const ViewMLJob: React.SFC = ({ serviceName, transactionType, location, children = 'View Job' -}: ViewMlJobArgs) { +}) => { const pathname = '/app/ml'; const hash = '/timeseriesexplorer'; const jobId = `${serviceName}-${transactionType}-high_mean_response_time`; @@ -59,7 +58,7 @@ export function ViewMLJob({ children={children} /> ); -} +}; export function toQuery(search?: string): StringMap { return search ? qs.parse(search.slice(1)) : {}; diff --git a/x-pack/plugins/apm/server/lib/helpers/get_bucket_size/index.js b/x-pack/plugins/apm/server/lib/helpers/get_bucket_size/index.ts similarity index 58% rename from x-pack/plugins/apm/server/lib/helpers/get_bucket_size/index.js rename to x-pack/plugins/apm/server/lib/helpers/get_bucket_size/index.ts index a7e4319243bc9..5ec0c2b7b2d96 100644 --- a/x-pack/plugins/apm/server/lib/helpers/get_bucket_size/index.js +++ b/x-pack/plugins/apm/server/lib/helpers/get_bucket_size/index.ts @@ -4,24 +4,26 @@ * you may not use this file except in compliance with the Elastic License. */ -import { calculateAuto } from './calculate_auto'; import moment from 'moment'; +// @ts-ignore +import { calculateAuto } from './calculate_auto'; +// @ts-ignore import { unitToSeconds } from './unit_to_seconds'; -export function getBucketSize(start, end, interval) { - const duration = moment.duration(end - start, 'ms'); - let bucketSize = calculateAuto.near(100, duration).asSeconds(); - if (bucketSize < 1) bucketSize = 1; // don't go too small - let intervalString = `${bucketSize}s`; +export function getBucketSize(start: number, end: number, interval: string) { + const duration = moment.duration(end - start, 'ms'); + const bucketSize = Math.max(calculateAuto.near(100, duration).asSeconds(), 1); + const intervalString = `${bucketSize}s`; const matches = interval && interval.match(/^([\d]+)([shmdwMy]|ms)$/); - let minBucketSize = 0; - if (matches) { - minBucketSize = Number(matches[1]) * unitToSeconds(matches[2]); - } + const minBucketSize = matches + ? Number(matches[1]) * unitToSeconds(matches[2]) + : 0; if (bucketSize < minBucketSize) { - bucketSize = minBucketSize; - intervalString = interval; + return { + bucketSize: minBucketSize, + intervalString: interval + }; } return { bucketSize, intervalString }; diff --git a/x-pack/plugins/apm/server/lib/helpers/setup_request.ts b/x-pack/plugins/apm/server/lib/helpers/setup_request.ts index 70773755c2c78..7d46d07865ba9 100644 --- a/x-pack/plugins/apm/server/lib/helpers/setup_request.ts +++ b/x-pack/plugins/apm/server/lib/helpers/setup_request.ts @@ -5,7 +5,7 @@ */ /* tslint:disable no-console */ -import { SearchParams, SearchResponse } from 'elasticsearch'; +import { AggregationSearchResponse, SearchParams } from 'elasticsearch'; import { Request } from 'hapi'; import moment from 'moment'; @@ -14,7 +14,7 @@ function decodeEsQuery(esQuery?: string): object { } interface KibanaConfig { - get: (key: string) => any; + get: (key: string) => T; } // Extend the defaults with the plugins and server methods we need. @@ -28,13 +28,16 @@ declare module 'hapi' { } } -type Client = (type: string, params: SearchParams) => SearchResponse; +export type ESClient = ( + type: string, + params: SearchParams +) => Promise>; -export interface Setup { +export interface Setup { start: number; end: number; - esFilterQuery: any; - client: Client; + esFilterQuery?: any; + client: ESClient; config: KibanaConfig; } @@ -49,7 +52,10 @@ export function setupRequest(req: Request) { const query = (req.query as unknown) as APMRequestQuery; const cluster = req.server.plugins.elasticsearch.getCluster('data'); - function client(type: string, params: SearchParams): SearchResponse { + function client( + type: string, + params: SearchParams + ): AggregationSearchResponse { if (query._debug) { console.log(`DEBUG ES QUERY:`); console.log( diff --git a/x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts b/x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts deleted file mode 100644 index db7b65c646870..0000000000000 --- a/x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import moment from 'moment'; -import { - TRANSACTION_DURATION, - TRANSACTION_NAME -} from '../../../common/constants'; -import { Transaction } from '../../../typings/Transaction'; -import { ITransactionGroup } from '../../../typings/TransactionGroup'; - -export interface ITransactionGroupBucket { - key: string; - doc_count: number; - avg: { - value: number; - }; - p95: { - values: { - '95.0': number; - }; - }; - sample: { - hits: { - hits: Array<{ - _source: Transaction; - }>; - }; - }; -} - -export const TRANSACTION_GROUP_AGGREGATES = { - transactions: { - terms: { - field: `${TRANSACTION_NAME}.keyword`, - order: { avg: 'desc' }, - size: 100 - }, - aggs: { - sample: { - top_hits: { - size: 1, - sort: [{ '@timestamp': { order: 'desc' } }] - } - }, - avg: { avg: { field: TRANSACTION_DURATION } }, - p95: { percentiles: { field: TRANSACTION_DURATION, percents: [95] } } - } - } -}; - -function calculateRelativeImpacts(results: ITransactionGroup[]) { - const values = results.map(({ impact }) => impact); - const max = Math.max(...values); - const min = Math.min(...values); - - return results.map(bucket => ({ - ...bucket, - impact: ((bucket.impact - min) / (max - min)) * 100 - })); -} - -export function prepareTransactionGroups({ - buckets, - start, - end -}: { - buckets: ITransactionGroupBucket[]; - start: number; - end: number; -}) { - const duration = moment.duration(end - start); - const minutes = duration.asMinutes(); - - const results = buckets.map((bucket: ITransactionGroupBucket) => { - const averageResponseTime = bucket.avg.value; - const transactionsPerMinute = bucket.doc_count / minutes; - const impact = Math.round(averageResponseTime * transactionsPerMinute); - const sample = bucket.sample.hits.hits[0]._source; - - return { - name: bucket.key, - sample, - p95: bucket.p95.values['95.0'], - averageResponseTime, - transactionsPerMinute, - impact - }; - }); - - return calculateRelativeImpacts(results); -} diff --git a/x-pack/plugins/apm/server/lib/services/get_service.ts b/x-pack/plugins/apm/server/lib/services/get_service.ts index 2998f3487ecc6..05beb6b96883d 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service.ts @@ -13,22 +13,22 @@ import { } from '../../../common/constants'; import { Setup } from '../helpers/setup_request'; -export interface ServiceResponse { - service_name: string; +export interface ServiceAPIResponse { + serviceName: string; types: string[]; - agent_name?: string; + agentName?: string; } export async function getService( serviceName: string, setup: Setup -): Promise { +): Promise { const { start, end, esFilterQuery, client, config } = setup; const params = { index: [ - config.get('apm_oss.errorIndices'), - config.get('apm_oss.transactionIndices') + config.get('apm_oss.errorIndices'), + config.get('apm_oss.transactionIndices') ], body: { size: 0, @@ -72,12 +72,12 @@ export async function getService( }; } - const resp = await client('search', params); - const aggs: Aggs = resp.aggregations; - + const { aggregations } = await client('search', params); return { - service_name: serviceName, - types: aggs.types.buckets.map(bucket => bucket.key), - agent_name: oc(aggs).agents.buckets[0].key() + serviceName, + types: oc(aggregations) + .types.buckets([]) + .map(bucket => bucket.key), + agentName: oc(aggregations).agents.buckets[0].key() }; } diff --git a/x-pack/plugins/apm/server/lib/services/get_services.ts b/x-pack/plugins/apm/server/lib/services/get_services.ts index 6d2019e64c1db..023e889e62fe5 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services.ts @@ -22,13 +22,17 @@ export interface IServiceListItem { avgResponseTime: number; } -export async function getServices(setup: Setup): Promise { +export type ServiceListAPIResponse = IServiceListItem[]; + +export async function getServices( + setup: Setup +): Promise { const { start, end, esFilterQuery, client, config } = setup; const params = { index: [ - config.get('apm_oss.errorIndices'), - config.get('apm_oss.transactionIndices') + config.get('apm_oss.errorIndices'), + config.get('apm_oss.transactionIndices') ], body: { size: 0, @@ -99,8 +103,8 @@ export async function getServices(setup: Setup): Promise { }; } - const resp = await client('search', params); - const aggs: Aggs = resp.aggregations; + const resp = await client('search', params); + const aggs = resp.aggregations; const serviceBuckets = oc(aggs).services.buckets([]); return serviceBuckets.map(bucket => { diff --git a/x-pack/plugins/apm/server/lib/traces/get_top_traces.ts b/x-pack/plugins/apm/server/lib/traces/get_top_traces.ts index 990879690d9b7..a75f69e3369cb 100644 --- a/x-pack/plugins/apm/server/lib/traces/get_top_traces.ts +++ b/x-pack/plugins/apm/server/lib/traces/get_top_traces.ts @@ -4,74 +4,53 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SearchResponse } from 'elasticsearch'; -import { get } from 'lodash'; import { PARENT_ID, PROCESSOR_EVENT, TRACE_ID } from '../../../common/constants'; -import { Transaction } from '../../../typings/Transaction'; -import { ITransactionGroup } from '../../../typings/TransactionGroup'; import { Setup } from '../helpers/setup_request'; -import { - ITransactionGroupBucket, - prepareTransactionGroups, - TRANSACTION_GROUP_AGGREGATES -} from '../helpers/transaction_group_query'; +import { getTransactionGroups } from '../transaction_groups'; +import { ITransactionGroup } from '../transaction_groups/transform'; -export async function getTopTraces(setup: Setup): Promise { - const { start, end, esFilterQuery, client, config } = setup; +export type TraceListAPIResponse = ITransactionGroup[]; - const params = { - index: config.get('apm_oss.transactionIndices'), - body: { - size: 0, - query: { - bool: { - must: { - // this criterion safeguards against data that lacks a transaction - // parent ID but still is not a "trace" by way of not having a - // trace ID (e.g. old data before parent ID was implemented, etc) - exists: { - field: TRACE_ID - } - }, - must_not: { - // no parent ID alongside a trace ID means this transaction is a - // "root" transaction, i.e. a trace - exists: { - field: PARENT_ID - } - }, - filter: [ - { - range: { - '@timestamp': { - gte: start, - lte: end, - format: 'epoch_millis' - } - } - }, - { term: { [PROCESSOR_EVENT]: 'transaction' } } - ] +export async function getTopTraces( + setup: Setup +): Promise { + const { start, end } = setup; + + const bodyQuery = { + bool: { + must: { + // this criterion safeguards against data that lacks a transaction + // parent ID but still is not a "trace" by way of not having a + // trace ID (e.g. old data before parent ID was implemented, etc) + exists: { + field: TRACE_ID } }, - aggs: TRANSACTION_GROUP_AGGREGATES + must_not: { + // no parent ID alongside a trace ID means this transaction is a + // "root" transaction, i.e. a trace + exists: { + field: PARENT_ID + } + }, + filter: [ + { + range: { + '@timestamp': { + gte: start, + lte: end, + format: 'epoch_millis' + } + } + }, + { term: { [PROCESSOR_EVENT]: 'transaction' } } + ] } }; - if (esFilterQuery) { - params.body.query.bool.filter.push(esFilterQuery); - } - - const response: SearchResponse = await client('search', params); - const buckets: ITransactionGroupBucket[] = get( - response.aggregations, - 'transactions.buckets', - [] - ); - - return prepareTransactionGroups({ buckets, start, end }); + return getTransactionGroups(setup, bodyQuery); } diff --git a/x-pack/plugins/apm/server/lib/traces/get_trace.ts b/x-pack/plugins/apm/server/lib/traces/get_trace.ts index b92e9e377e701..4adb8ece0c81b 100644 --- a/x-pack/plugins/apm/server/lib/traces/get_trace.ts +++ b/x-pack/plugins/apm/server/lib/traces/get_trace.ts @@ -4,17 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SearchParams, SearchResponse } from 'elasticsearch'; -import { WaterfallResponse } from 'x-pack/plugins/apm/typings/waterfall'; +import { SearchParams } from 'elasticsearch'; import { TRACE_ID } from '../../../common/constants'; import { Span } from '../../../typings/Span'; import { Transaction } from '../../../typings/Transaction'; import { Setup } from '../helpers/setup_request'; +export type TraceAPIResponse = Array; + export async function getTrace( traceId: string, setup: Setup -): Promise { +): Promise { const { start, end, client, config } = setup; const params: SearchParams = { @@ -40,10 +41,6 @@ export async function getTrace( } }; - const resp: SearchResponse = await client( - 'search', - params - ); - + const resp = await client('search', params); return resp.hits.hits.map(hit => hit._source); } diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/fetcher.test.ts.snap b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/fetcher.test.ts.snap new file mode 100644 index 0000000000000..9e180f3fcdb5d --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/fetcher.test.ts.snap @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`transactionGroupsFetcher should call client with correct query 1`] = ` +Array [ + Array [ + "search", + Object { + "body": Object { + "aggs": Object { + "transactions": Object { + "aggs": Object { + "avg": Object { + "avg": Object { + "field": "transaction.duration.us", + }, + }, + "p95": Object { + "percentiles": Object { + "field": "transaction.duration.us", + "percents": Array [ + 95, + ], + }, + }, + "sample": Object { + "top_hits": Object { + "size": 1, + "sort": Array [ + Object { + "@timestamp": Object { + "order": "desc", + }, + }, + ], + }, + }, + }, + "terms": Object { + "field": "transaction.name.keyword", + "order": Object { + "avg": "desc", + }, + "size": 100, + }, + }, + }, + "query": Object { + "my": "bodyQuery", + }, + "size": 0, + }, + "index": "myIndex", + }, + ], +] +`; diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/transform.test.ts.snap b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/transform.test.ts.snap new file mode 100644 index 0000000000000..a68d7dc80338a --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/transform.test.ts.snap @@ -0,0 +1,2822 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`transactionGroupsTransformer should match snapshot 1`] = ` +Array [ + Object { + "averageResponseTime": 255966.30555555556, + "impact": 4.369340653255684, + "name": "POST /api/orders", + "p95": 320238.5, + "sample": Object { + "@timestamp": "2018-11-18T20:43:32.010Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 4669, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 2413, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "body": "[REDACTED]", + "headers": Object { + "accept": "application/json", + "connection": "close", + "content-length": "129", + "content-type": "application/json", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "POST", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/orders", + "hostname": "opbeans-node", + "pathname": "/api/orders", + "port": "3000", + "protocol": "http:", + "raw": "/api/orders", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "13", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:43:32 GMT", + "etag": "W/\\"d-g9K2iK4ordyN88lGL4LmPlYNfhc\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542573812010006, + }, + "trace": Object { + "id": "2b1252a338249daeecf6afb0c236e31b", + }, + "transaction": Object { + "duration": Object { + "us": 291572, + }, + "id": "2c9f39e9ec4a0111", + "name": "POST /api/orders", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 16, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 5684.210526315789, + }, + Object { + "averageResponseTime": 48021.972616494, + "impact": 100, + "name": "GET /api", + "p95": 67138.18364917398, + "sample": Object { + "@timestamp": "2018-11-18T20:53:44.070Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 5176, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip, deflate", + "connection": "keep-alive", + "elastic-apm-traceparent": "00-86c68779d8a65b06fb78e770ffc436a5-4aaea53dc1791183-01", + "host": "opbeans-node:3000", + "user-agent": "python-requests/2.20.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.6", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/types/3", + "hostname": "opbeans-node", + "pathname": "/api/types/3", + "port": "3000", + "protocol": "http:", + "raw": "/api/types/3", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-type": "application/json;charset=UTF-8", + "date": "Sun, 18 Nov 2018 20:53:43 GMT", + "transfer-encoding": "chunked", + "x-powered-by": "Express", + }, + "status_code": 404, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "parent": Object { + "id": "4aaea53dc1791183", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574424070007, + }, + "trace": Object { + "id": "86c68779d8a65b06fb78e770ffc436a5", + }, + "transaction": Object { + "duration": Object { + "us": 8684, + }, + "id": "a78bca581dcd8ff8", + "name": "GET /api", + "result": "HTTP 4xx", + "sampled": true, + "span_count": Object { + "started": 1, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 691926.3157894736, + }, + Object { + "averageResponseTime": 33265.03326147213, + "impact": 10.256357027900046, + "name": "GET /api/orders", + "p95": 58827.489999999976, + "sample": Object { + "@timestamp": "2018-11-18T20:53:40.973Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 408, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/orders", + "hostname": "opbeans-node", + "pathname": "/api/orders", + "port": "3000", + "protocol": "http:", + "raw": "/api/orders", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "103612", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:53:40 GMT", + "etag": "W/\\"194bc-cOw6+iRf7XCeqMXHrle3IOig7tY\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574420973006, + }, + "trace": Object { + "id": "0afce85f593cbbdd09949936fe964f0f", + }, + "transaction": Object { + "duration": Object { + "us": 23040, + }, + "id": "89f200353eb50539", + "name": "GET /api/orders", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 2, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 102536.84210526315, + }, + Object { + "averageResponseTime": 32900.72714285714, + "impact": 2.179120743402716, + "name": "GET /log-message", + "p95": 40444, + "sample": Object { + "@timestamp": "2018-11-18T20:49:09.225Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 321, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3142, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/log-message", + "hostname": "opbeans-node", + "pathname": "/log-message", + "port": "3000", + "protocol": "http:", + "raw": "/log-message", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "24", + "content-type": "text/html; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:49:09 GMT", + "etag": "W/\\"18-MS3VbhH7auHMzO0fUuNF6v14N/M\\"", + "x-powered-by": "Express", + }, + "status_code": 500, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574149225004, + }, + "trace": Object { + "id": "ba18b741cdd3ac83eca89a5fede47577", + }, + "transaction": Object { + "duration": Object { + "us": 32381, + }, + "id": "b9a8f96d7554d09f", + "name": "GET /log-message", + "result": "HTTP 5xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 22105.263157894737, + }, + Object { + "averageResponseTime": 32554.36257814184, + "impact": 14.344171564855404, + "name": "GET /api/stats", + "p95": 59356.73611111111, + "sample": Object { + "@timestamp": "2018-11-18T20:53:42.560Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 207, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip, deflate", + "connection": "keep-alive", + "elastic-apm-traceparent": "00-63ccc3b0929dafb7f2fbcabdc7f7af25-821a787e73ab1563-01", + "host": "opbeans-node:3000", + "if-none-match": "W/\\"77-uxKJrX5GSMJJWTKh3orUFAEVxSs\\"", + "referer": "http://opbeans-node:3000/dashboard", + "user-agent": "Chromeless 1.4.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.7", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/stats", + "hostname": "opbeans-node", + "pathname": "/api/stats", + "port": "3000", + "protocol": "http:", + "raw": "/api/stats", + }, + }, + "response": Object { + "headers": Object { + "connection": "keep-alive", + "date": "Sun, 18 Nov 2018 20:53:42 GMT", + "etag": "W/\\"77-uxKJrX5GSMJJWTKh3orUFAEVxSs\\"", + "x-powered-by": "Express", + }, + "status_code": 304, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "parent": Object { + "id": "821a787e73ab1563", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574422560002, + }, + "trace": Object { + "id": "63ccc3b0929dafb7f2fbcabdc7f7af25", + }, + "transaction": Object { + "duration": Object { + "us": 28753, + }, + "id": "fb754e7628da2fb5", + "name": "GET /api/stats", + "result": "HTTP 3xx", + "sampled": true, + "span_count": Object { + "started": 7, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 146494.73684210525, + }, + Object { + "averageResponseTime": 32387.73641304348, + "impact": 2.2558112391673664, + "name": "GET /log-error", + "p95": 40061.1, + "sample": Object { + "@timestamp": "2018-11-18T20:52:51.462Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 4877, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3659, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/log-error", + "hostname": "opbeans-node", + "pathname": "/log-error", + "port": "3000", + "protocol": "http:", + "raw": "/log-error", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "24", + "content-type": "text/html; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:52:51 GMT", + "etag": "W/\\"18-MS3VbhH7auHMzO0fUuNF6v14N/M\\"", + "x-powered-by": "Express", + }, + "status_code": 500, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574371462005, + }, + "trace": Object { + "id": "15366d65659b5fc8f67ff127391b3aff", + }, + "transaction": Object { + "duration": Object { + "us": 33367, + }, + "id": "ec9c465c5042ded8", + "name": "GET /log-error", + "result": "HTTP 5xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 23242.105263157893, + }, + Object { + "averageResponseTime": 32159.926322043968, + "impact": 10.279049521913821, + "name": "GET /api/customers", + "p95": 59845.85714285714, + "sample": Object { + "@timestamp": "2018-11-18T20:53:21.180Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 2531, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3710, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip, deflate", + "connection": "keep-alive", + "elastic-apm-traceparent": "00-541025da8ecc2f51f21c1a4ad6992b77-ca18d9d4c3879519-01", + "host": "opbeans-node:3000", + "user-agent": "python-requests/2.20.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.6", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/customers", + "hostname": "opbeans-node", + "pathname": "/api/customers", + "port": "3000", + "protocol": "http:", + "raw": "/api/customers", + }, + }, + "response": Object { + "headers": Object { + "connection": "keep-alive", + "content-length": "186769", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:53:21 GMT", + "etag": "W/\\"2d991-yG3J8W/roH7fSxXTudZrO27Ax9s\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "parent": Object { + "id": "ca18d9d4c3879519", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574401180002, + }, + "trace": Object { + "id": "541025da8ecc2f51f21c1a4ad6992b77", + }, + "transaction": Object { + "duration": Object { + "us": 18077, + }, + "id": "94852b9dd1075982", + "name": "GET /api/customers", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 2, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 106294.73684210525, + }, + Object { + "averageResponseTime": 27516.89144558744, + "impact": 9.651458993728006, + "name": "GET /api/products/top", + "p95": 56064.679999999986, + "sample": Object { + "@timestamp": "2018-11-18T20:52:57.316Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 5113, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3686, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip, deflate", + "connection": "keep-alive", + "elastic-apm-traceparent": "00-74f12e705936d66350f4741ebeb55189-fcebe94cd2136215-01", + "host": "opbeans-node:3000", + "referer": "http://opbeans-node:3000/dashboard", + "user-agent": "Chromeless 1.4.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.7", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/products/top", + "hostname": "opbeans-node", + "pathname": "/api/products/top", + "port": "3000", + "protocol": "http:", + "raw": "/api/products/top", + }, + }, + "response": Object { + "headers": Object { + "connection": "keep-alive", + "content-length": "282", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:52:57 GMT", + "etag": "W/\\"11a-lcI9zuMZYYsDRpEZgYqDYr96cKM\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "parent": Object { + "id": "fcebe94cd2136215", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574377316005, + }, + "trace": Object { + "id": "74f12e705936d66350f4741ebeb55189", + }, + "transaction": Object { + "duration": Object { + "us": 48781, + }, + "id": "be4bd5475d5d9e6f", + "name": "GET /api/products/top", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 4, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 116652.63157894736, + }, + Object { + "averageResponseTime": 21331.714285714286, + "impact": 0.28817488008070574, + "name": "POST /api", + "p95": 30938, + "sample": Object { + "@timestamp": "2018-11-18T20:29:42.751Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 2927, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 546, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "body": "[REDACTED]", + "headers": Object { + "accept": "application/json", + "connection": "close", + "content-length": "129", + "content-type": "application/json", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "POST", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/orders", + "hostname": "opbeans-node", + "pathname": "/api/orders", + "port": "3000", + "protocol": "http:", + "raw": "/api/orders", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "0", + "date": "Sun, 18 Nov 2018 20:29:42 GMT", + "x-powered-by": "Express", + }, + "status_code": 400, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542572982751005, + }, + "trace": Object { + "id": "8ed4d94ec8fc11b1ea1b0aa59c2320ff", + }, + "transaction": Object { + "duration": Object { + "us": 21083, + }, + "id": "d67c2f7aa897110c", + "name": "POST /api", + "result": "HTTP 4xx", + "sampled": true, + "span_count": Object { + "started": 1, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 4642.105263157894, + }, + Object { + "averageResponseTime": 17189.329210275926, + "impact": 3.424381788267164, + "name": "GET /api/products/:id/customers", + "p95": 39284.79999999999, + "sample": Object { + "@timestamp": "2018-11-18T20:48:24.769Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 1735, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3100, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip, deflate", + "connection": "keep-alive", + "elastic-apm-traceparent": "00-28f178c354d17f400dea04bc4a7b3c57-68f5d1607cac7779-01", + "host": "opbeans-node:3000", + "user-agent": "python-requests/2.20.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.6", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/products/2/customers", + "hostname": "opbeans-node", + "pathname": "/api/products/2/customers", + "port": "3000", + "protocol": "http:", + "raw": "/api/products/2/customers", + }, + }, + "response": Object { + "headers": Object { + "connection": "keep-alive", + "content-length": "186570", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:48:24 GMT", + "etag": "W/\\"2d8ca-Z9NzuHyGyxwtzpOkcIxBvzm24iw\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "parent": Object { + "id": "68f5d1607cac7779", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574104769029, + }, + "trace": Object { + "id": "28f178c354d17f400dea04bc4a7b3c57", + }, + "transaction": Object { + "duration": Object { + "us": 49338, + }, + "id": "2a87ae20ad04ee0c", + "name": "GET /api/products/:id/customers", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 1, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 66378.94736842105, + }, + Object { + "averageResponseTime": 12763.68806073154, + "impact": 1.747992435179465, + "name": "GET /api/types/:id", + "p95": 30576.749999999996, + "sample": Object { + "@timestamp": "2018-11-18T20:53:35.967Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 5345, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/types/1", + "hostname": "opbeans-node", + "pathname": "/api/types/1", + "port": "3000", + "protocol": "http:", + "raw": "/api/types/1", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "217", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:53:35 GMT", + "etag": "W/\\"d9-cebOOHODBQMZd1wt+ZZBaSPgQLQ\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574415967005, + }, + "trace": Object { + "id": "2223b30b5cbaf2e221fcf70ac6d9abbe", + }, + "transaction": Object { + "duration": Object { + "us": 13064, + }, + "id": "053436abacdec0a4", + "name": "GET /api/types/:id", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 2, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 45757.8947368421, + }, + Object { + "averageResponseTime": 12683.190864600327, + "impact": 4.4239778511514745, + "name": "GET /api/products", + "p95": 35009.67999999999, + "sample": Object { + "@timestamp": "2018-11-18T20:53:43.477Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 2857, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/products", + "hostname": "opbeans-node", + "pathname": "/api/products", + "port": "3000", + "protocol": "http:", + "raw": "/api/products", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "1023", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:53:43 GMT", + "etag": "W/\\"3ff-VyOxcDApb+a/lnjkm9FeTOGSDrs\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574423477006, + }, + "trace": Object { + "id": "bee00a8efb523ca4b72adad57f7caba3", + }, + "transaction": Object { + "duration": Object { + "us": 6915, + }, + "id": "d8fc6d3b8707b64c", + "name": "GET /api/products", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 2, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 116147.36842105263, + }, + Object { + "averageResponseTime": 11257.757916666667, + "impact": 2.558180605423081, + "name": "GET /api/types", + "p95": 35222.944444444445, + "sample": Object { + "@timestamp": "2018-11-18T20:53:44.978Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 2193, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/types", + "hostname": "opbeans-node", + "pathname": "/api/types", + "port": "3000", + "protocol": "http:", + "raw": "/api/types", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "112", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:53:44 GMT", + "etag": "W/\\"70-1z6hT7P1WHgBgS/BeUEVeHhOCQU\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574424978005, + }, + "trace": Object { + "id": "0d84126973411c19b470f2d9eea958d3", + }, + "transaction": Object { + "duration": Object { + "us": 7891, + }, + "id": "0f10668e4fb3adc7", + "name": "GET /api/types", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 2, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 75789.47368421052, + }, + Object { + "averageResponseTime": 10584.05144193297, + "impact": 1.2808106158729446, + "name": "GET /api/orders/:id", + "p95": 26555.399999999998, + "sample": Object { + "@timestamp": "2018-11-18T20:51:36.949Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 5999, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3475, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/orders/183", + "hostname": "opbeans-node", + "pathname": "/api/orders/183", + "port": "3000", + "protocol": "http:", + "raw": "/api/orders/183", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "0", + "date": "Sun, 18 Nov 2018 20:51:36 GMT", + "x-powered-by": "Express", + }, + "status_code": 404, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574296949004, + }, + "trace": Object { + "id": "dab6421fa44a6869887e0edf32e1ad6f", + }, + "transaction": Object { + "duration": Object { + "us": 5906, + }, + "id": "937ef5588454f74a", + "name": "GET /api/orders/:id", + "result": "HTTP 4xx", + "sampled": true, + "span_count": Object { + "started": 1, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 40515.789473684206, + }, + Object { + "averageResponseTime": 10548.218597063622, + "impact": 1.8338764008269306, + "name": "GET /api/products/:id", + "p95": 28413.383333333328, + "sample": Object { + "@timestamp": "2018-11-18T20:52:57.963Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 7184, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3686, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/products/3", + "hostname": "opbeans-node", + "pathname": "/api/products/3", + "port": "3000", + "protocol": "http:", + "raw": "/api/products/3", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "231", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:52:57 GMT", + "etag": "W/\\"e7-kkuzj37GZDzXDh0CWqh5Gan0VO4\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574377963005, + }, + "trace": Object { + "id": "ca86ec845e412e4b4506a715d51548ec", + }, + "transaction": Object { + "duration": Object { + "us": 6959, + }, + "id": "d324897ffb7ebcdc", + "name": "GET /api/products/:id", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 1, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 58073.68421052631, + }, + Object { + "averageResponseTime": 9868.217894736843, + "impact": 1.7722323979309487, + "name": "GET /api/customers/:id", + "p95": 27486.5, + "sample": Object { + "@timestamp": "2018-11-18T20:52:56.797Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 8225, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3686, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip, deflate", + "connection": "keep-alive", + "elastic-apm-traceparent": "00-e6140d30363f18b585f5d3b753f4d025-aa82e2c847265626-01", + "host": "opbeans-node:3000", + "user-agent": "python-requests/2.20.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.6", + }, + "url": Object { + "full": "http://opbeans-node:3000/api/customers/700", + "hostname": "opbeans-node", + "pathname": "/api/customers/700", + "port": "3000", + "protocol": "http:", + "raw": "/api/customers/700", + }, + }, + "response": Object { + "headers": Object { + "connection": "keep-alive", + "content-length": "193", + "content-type": "application/json; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:52:56 GMT", + "etag": "W/\\"c1-LbuhkuLzFyZ0H+7+JQGA5b0kvNs\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "parent": Object { + "id": "aa82e2c847265626", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574376797031, + }, + "trace": Object { + "id": "e6140d30363f18b585f5d3b753f4d025", + }, + "transaction": Object { + "duration": Object { + "us": 9735, + }, + "id": "60e230d12f3f0960", + "name": "GET /api/customers/:id", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 1, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 59999.99999999999, + }, + Object { + "averageResponseTime": 5192.9, + "impact": 0, + "name": "POST unknown route", + "p95": 13230.5, + "sample": Object { + "@timestamp": "2018-11-18T18:43:50.994Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 6102, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 19196, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "body": "[REDACTED]", + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip, deflate", + "content-length": "380", + "content-type": "multipart/form-data; boundary=2b2e40be188a4cb5a56c05a0c182f6c9", + "elastic-apm-traceparent": "00-19688959ea6cbccda8013c11566ea329-1fc3665eef2dcdfc-01", + "host": "172.18.0.9:3000", + "user-agent": "Python/3.7 aiohttp/3.3.2", + "x-forwarded-for": "172.18.0.11", + }, + "http_version": "1.1", + "method": "POST", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.9", + }, + "url": Object { + "full": "http://172.18.0.9:3000/api/orders/csv", + "hostname": "172.18.0.9", + "pathname": "/api/orders/csv", + "port": "3000", + "protocol": "http:", + "raw": "/api/orders/csv", + }, + }, + "response": Object { + "headers": Object { + "connection": "keep-alive", + "content-length": "154", + "content-security-policy": "default-src 'self'", + "content-type": "text/html; charset=utf-8", + "date": "Sun, 18 Nov 2018 18:43:50 GMT", + "x-content-type-options": "nosniff", + "x-powered-by": "Express", + }, + "status_code": 404, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "parent": Object { + "id": "1fc3665eef2dcdfc", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542566630994005, + }, + "trace": Object { + "id": "19688959ea6cbccda8013c11566ea329", + }, + "transaction": Object { + "duration": Object { + "us": 3467, + }, + "id": "92c3ceea57899061", + "name": "POST unknown route", + "result": "HTTP 4xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 631.578947368421, + }, + Object { + "averageResponseTime": 4694.005586592179, + "impact": 0.1498514997591876, + "name": "GET /is-it-coffee-time", + "p95": 11022.99999999992, + "sample": Object { + "@timestamp": "2018-11-18T20:46:19.317Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 8593, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 2760, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/is-it-coffee-time", + "hostname": "opbeans-node", + "pathname": "/is-it-coffee-time", + "port": "3000", + "protocol": "http:", + "raw": "/is-it-coffee-time", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "148", + "content-security-policy": "default-src 'self'", + "content-type": "text/html; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:46:19 GMT", + "x-content-type-options": "nosniff", + "x-powered-by": "Express", + }, + "status_code": 500, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542573979317007, + }, + "trace": Object { + "id": "821812b416de4c73ced87f8777fa46a6", + }, + "transaction": Object { + "duration": Object { + "us": 4253, + }, + "id": "319a5c555a1ab207", + "name": "GET /is-it-coffee-time", + "result": "HTTP 5xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 11305.263157894737, + }, + Object { + "averageResponseTime": 4549.889880952381, + "impact": 0.1354336505457395, + "name": "GET /throw-error", + "p95": 7719.700000000001, + "sample": Object { + "@timestamp": "2018-11-18T20:47:10.714Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 7220, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 2895, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/throw-error", + "hostname": "opbeans-node", + "pathname": "/throw-error", + "port": "3000", + "protocol": "http:", + "raw": "/throw-error", + }, + }, + "response": Object { + "headers": Object { + "connection": "close", + "content-length": "148", + "content-security-policy": "default-src 'self'", + "content-type": "text/html; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:47:10 GMT", + "x-content-type-options": "nosniff", + "x-powered-by": "Express", + }, + "status_code": 500, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574030714012, + }, + "trace": Object { + "id": "6c0ef23e1f963f304ce440a909914d35", + }, + "transaction": Object { + "duration": Object { + "us": 4458, + }, + "id": "ecd187dc53f09fbd", + "name": "GET /throw-error", + "result": "HTTP 5xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 10610.526315789473, + }, + Object { + "averageResponseTime": 3504.5108924806746, + "impact": 2.36009934580083, + "name": "GET *", + "p95": 11431.738095238095, + "sample": Object { + "@timestamp": "2018-11-18T20:53:42.493Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 6446, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", + "accept-encoding": "gzip, deflate", + "connection": "keep-alive", + "host": "opbeans-node:3000", + "if-modified-since": "Mon, 12 Nov 2018 10:27:07 GMT", + "if-none-match": "W/\\"280-1670775e878\\"", + "upgrade-insecure-requests": "1", + "user-agent": "Chromeless 1.4.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.7", + }, + "url": Object { + "full": "http://opbeans-node:3000/dashboard", + "hostname": "opbeans-node", + "pathname": "/dashboard", + "port": "3000", + "protocol": "http:", + "raw": "/dashboard", + }, + }, + "response": Object { + "headers": Object { + "accept-ranges": "bytes", + "cache-control": "public, max-age=0", + "connection": "keep-alive", + "date": "Sun, 18 Nov 2018 20:53:42 GMT", + "etag": "W/\\"280-1670775e878\\"", + "last-modified": "Mon, 12 Nov 2018 10:27:07 GMT", + "x-powered-by": "Express", + }, + "status_code": 304, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574422493006, + }, + "trace": Object { + "id": "7efb6ade88cdea20cd96ca482681cde7", + }, + "transaction": Object { + "duration": Object { + "us": 1901, + }, + "id": "f5fc4621949b63fb", + "name": "GET *", + "result": "HTTP 3xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 224684.21052631576, + }, + Object { + "averageResponseTime": 2742.4615384615386, + "impact": 0.08501029113483448, + "name": "OPTIONS unknown route", + "p95": 4370.000000000002, + "sample": Object { + "@timestamp": "2018-11-18T20:49:00.707Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "custom": Object { + "containerId": 3775, + }, + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3142, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "connection": "close", + "content-length": "0", + "host": "opbeans-node:3000", + "user-agent": "workload/2.4.3", + }, + "http_version": "1.1", + "method": "OPTIONS", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/", + "hostname": "opbeans-node", + "pathname": "/", + "port": "3000", + "protocol": "http:", + "raw": "/", + }, + }, + "response": Object { + "headers": Object { + "allow": "GET,HEAD", + "connection": "close", + "content-length": "8", + "content-type": "text/html; charset=utf-8", + "date": "Sun, 18 Nov 2018 20:49:00 GMT", + "etag": "W/\\"8-ZRAf8oNBS3Bjb/SU2GYZCmbtmXg\\"", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + "tags": Object { + "foo": "bar", + "lorem": "ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.", + "multi-line": "foo +bar +baz", + "this-is-a-very-long-tag-name-without-any-spaces": "test", + }, + "user": Object { + "email": "kimchy@elastic.co", + "id": "42", + "username": "kimchy", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574140707006, + }, + "trace": Object { + "id": "469e3e5f91ffe3195a8e58cdd1cdefa8", + }, + "transaction": Object { + "duration": Object { + "us": 2371, + }, + "id": "a8c87ebc7ec68bc0", + "name": "OPTIONS unknown route", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 11494.736842105262, + }, + Object { + "averageResponseTime": 2651.8784461553205, + "impact": 15.770246498769827, + "name": "GET static file", + "p95": 6140.579335038363, + "sample": Object { + "@timestamp": "2018-11-18T20:53:43.304Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "*/*", + "host": "opbeans-node:3000", + "user-agent": "curl/7.38.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.10", + }, + "url": Object { + "full": "http://opbeans-node:3000/", + "hostname": "opbeans-node", + "pathname": "/", + "port": "3000", + "protocol": "http:", + "raw": "/", + }, + }, + "response": Object { + "headers": Object { + "accept-ranges": "bytes", + "cache-control": "public, max-age=0", + "connection": "keep-alive", + "content-length": "640", + "content-type": "text/html; charset=UTF-8", + "date": "Sun, 18 Nov 2018 20:53:43 GMT", + "etag": "W/\\"280-1670775e878\\"", + "last-modified": "Mon, 12 Nov 2018 10:27:07 GMT", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574423304006, + }, + "trace": Object { + "id": "b303d2a4a007946b63b9db7fafe639a0", + }, + "transaction": Object { + "duration": Object { + "us": 1801, + }, + "id": "2869c13633534be5", + "name": "GET static file", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 1977031.5789473683, + }, + Object { + "averageResponseTime": 1422.926672899693, + "impact": 1.002712481568783, + "name": "GET unknown route", + "p95": 2311.885238095238, + "sample": Object { + "@timestamp": "2018-11-18T20:53:42.504Z", + "agent": Object { + "hostname": "b359e3afece8", + "type": "apm-server", + "version": "7.0.0-alpha1", + }, + "context": Object { + "process": Object { + "argv": Array [ + "/usr/local/bin/node", + "/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js", + ], + "pid": 3756, + "ppid": 1, + "title": "node /app/server.js", + }, + "request": Object { + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip, deflate", + "connection": "keep-alive", + "host": "opbeans-node:3000", + "referer": "http://opbeans-node:3000/dashboard", + "user-agent": "Chromeless 1.4.0", + }, + "http_version": "1.1", + "method": "GET", + "socket": Object { + "encrypted": false, + "remote_address": "::ffff:172.18.0.7", + }, + "url": Object { + "full": "http://opbeans-node:3000/rum-config.js", + "hostname": "opbeans-node", + "pathname": "/rum-config.js", + "port": "3000", + "protocol": "http:", + "raw": "/rum-config.js", + }, + }, + "response": Object { + "headers": Object { + "connection": "keep-alive", + "content-length": "172", + "content-type": "text/javascript", + "date": "Sun, 18 Nov 2018 20:53:42 GMT", + "x-powered-by": "Express", + }, + "status_code": 200, + }, + "service": Object { + "agent": Object { + "name": "nodejs", + "version": "1.14.2", + }, + "language": Object { + "name": "javascript", + }, + "name": "opbeans-node", + "runtime": Object { + "name": "node", + "version": "8.12.0", + }, + "version": "1.0.0", + }, + "system": Object { + "architecture": "x64", + "hostname": "98195610c255", + "ip": "172.18.0.10", + "platform": "linux", + }, + }, + "host": Object { + "name": "b359e3afece8", + }, + "processor": Object { + "event": "transaction", + "name": "transaction", + }, + "timestamp": Object { + "us": 1542574422504004, + }, + "trace": Object { + "id": "4399e7233e6e7b77e70c2fff111b8f28", + }, + "transaction": Object { + "duration": Object { + "us": 911, + }, + "id": "107881ae2be1b56d", + "name": "GET unknown route", + "result": "HTTP 2xx", + "sampled": true, + "span_count": Object { + "started": 0, + }, + "type": "request", + }, + }, + "transactionsPerMinute": 236431.5789473684, + }, +] +`; diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.test.ts b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.test.ts new file mode 100644 index 0000000000000..cfbffe77222f3 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.test.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ESResponse, transactionGroupsFetcher } from './fetcher'; + +describe('transactionGroupsFetcher', () => { + let res: ESResponse; + let clientSpy: jest.Mock; + beforeEach(async () => { + clientSpy = jest.fn().mockResolvedValue('ES response'); + + const setup = { + start: 1528113600000, + end: 1528977600000, + client: clientSpy, + config: { + get: () => 'myIndex' as any + } + }; + const bodyQuery = { my: 'bodyQuery' }; + res = await transactionGroupsFetcher(setup, bodyQuery); + }); + + it('should call client with correct query', () => { + expect(clientSpy.mock.calls).toMatchSnapshot(); + }); + + it('should return correct response', () => { + expect(res).toBe('ES response'); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts new file mode 100644 index 0000000000000..9ab287402c561 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts @@ -0,0 +1,85 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { AggregationSearchResponse } from 'elasticsearch'; +import { StringMap } from 'x-pack/plugins/apm/typings/common'; +import { + TRANSACTION_DURATION, + TRANSACTION_NAME +} from '../../../common/constants'; +import { Transaction } from '../../../typings/Transaction'; +import { Setup } from '../helpers/setup_request'; + +interface Bucket { + key: string; + doc_count: number; + avg: { + value: number; + }; + p95: { + values: { + '95.0': number; + }; + }; + sample: { + hits: { + total: number; + max_score: number | null; + hits: Array<{ + _source: Transaction; + }>; + }; + }; +} + +interface Aggs { + transactions: { + buckets: Bucket[]; + }; +} + +export type ESResponse = AggregationSearchResponse; + +export function transactionGroupsFetcher( + setup: Setup, + bodyQuery: StringMap +): Promise { + const { esFilterQuery, client, config } = setup; + const params = { + index: config.get('apm_oss.transactionIndices'), + body: { + size: 0, + query: bodyQuery, + aggs: { + transactions: { + terms: { + field: `${TRANSACTION_NAME}.keyword`, + order: { avg: 'desc' }, + size: 100 + }, + aggs: { + sample: { + top_hits: { + size: 1, + sort: [{ '@timestamp': { order: 'desc' } }] + } + }, + avg: { avg: { field: TRANSACTION_DURATION } }, + p95: { + percentiles: { field: TRANSACTION_DURATION, percents: [95] } + } + } + } + } + } + }; + + if (esFilterQuery) { + params.body.query.bool.filter.push(esFilterQuery); + } + + return client('search', params); +} diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/index.ts b/x-pack/plugins/apm/server/lib/transaction_groups/index.ts new file mode 100644 index 0000000000000..ae59a2f8e5e4f --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transaction_groups/index.ts @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { StringMap } from 'x-pack/plugins/apm/typings/common'; +import { Setup } from '../helpers/setup_request'; +import { transactionGroupsFetcher } from './fetcher'; +import { transactionGroupsTransformer } from './transform'; + +export async function getTransactionGroups(setup: Setup, bodyQuery: StringMap) { + const { start, end } = setup; + const response = await transactionGroupsFetcher(setup, bodyQuery); + return transactionGroupsTransformer({ + response, + start, + end + }); +} diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/mock-responses/transactionGroupsResponse.ts b/x-pack/plugins/apm/server/lib/transaction_groups/mock-responses/transactionGroupsResponse.ts new file mode 100644 index 0000000000000..08492ee7a7839 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transaction_groups/mock-responses/transactionGroupsResponse.ts @@ -0,0 +1,2700 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ESResponse } from '../fetcher'; + +export const transactionGroupsResponse = ({ + took: 139, + timed_out: false, + _shards: { total: 44, successful: 44, skipped: 0, failed: 0 }, + hits: { total: 131557, max_score: null, hits: [] }, + aggregations: { + transactions: { + doc_count_error_upper_bound: 0, + sum_other_doc_count: 0, + buckets: [ + { + key: 'POST /api/orders', + doc_count: 180, + avg: { value: 255966.30555555556 }, + p95: { values: { '95.0': 320238.5 } }, + sample: { + hits: { + total: 180, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'TBGQKGcBVMxP8Wrugd8L', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:43:32.010Z', + context: { + request: { + http_version: '1.1', + method: 'POST', + url: { + port: '3000', + pathname: '/api/orders', + full: 'http://opbeans-node:3000/api/orders', + raw: '/api/orders', + protocol: 'http:', + hostname: 'opbeans-node' + }, + socket: { + encrypted: false, + remote_address: '::ffff:172.18.0.10' + }, + headers: { + host: 'opbeans-node:3000', + accept: 'application/json', + 'content-type': 'application/json', + 'content-length': '129', + connection: 'close', + 'user-agent': 'workload/2.4.3' + }, + body: '[REDACTED]' + }, + response: { + status_code: 200, + headers: { + date: 'Sun, 18 Nov 2018 20:43:32 GMT', + connection: 'close', + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8', + 'content-length': '13', + etag: 'W/"d-g9K2iK4ordyN88lGL4LmPlYNfhc"' + } + }, + system: { + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux' + }, + process: { + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 2413, + ppid: 1, + title: 'node /app/server.js' + }, + service: { + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0', + language: { name: 'javascript' } + }, + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar' + }, + custom: { containerId: 4669 } + }, + trace: { id: '2b1252a338249daeecf6afb0c236e31b' }, + timestamp: { us: 1542573812010006 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + sampled: true, + span_count: { started: 16 }, + id: '2c9f39e9ec4a0111', + name: 'POST /api/orders', + duration: { us: 291572 }, + type: 'request', + result: 'HTTP 2xx' + } + }, + sort: [1542573812010] + } + ] + } + } + }, + { + key: 'GET /api', + doc_count: 21911, + avg: { value: 48021.972616494 }, + p95: { values: { '95.0': 67138.18364917398 } }, + sample: { + hits: { + total: 21911, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '_hKZKGcBVMxP8Wru1G13', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:44.070Z', + timestamp: { us: 1542574424070007 }, + agent: { + hostname: 'b359e3afece8', + version: '7.0.0-alpha1', + type: 'apm-server' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + sampled: true, + span_count: { started: 1 }, + id: 'a78bca581dcd8ff8', + name: 'GET /api', + duration: { us: 8684 }, + type: 'request', + result: 'HTTP 4xx' + }, + context: { + response: { + status_code: 404, + headers: { + 'content-type': 'application/json;charset=UTF-8', + 'transfer-encoding': 'chunked', + date: 'Sun, 18 Nov 2018 20:53:43 GMT', + connection: 'close', + 'x-powered-by': 'Express' + } + }, + system: { + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10' + }, + process: { + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3756, + ppid: 1, + title: 'node /app/server.js' + }, + service: { + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0', + language: { name: 'javascript' } + }, + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + }, + custom: { containerId: 5176 }, + request: { + method: 'GET', + url: { + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/api/types/3', + full: 'http://opbeans-node:3000/api/types/3', + raw: '/api/types/3' + }, + socket: { + encrypted: false, + remote_address: '::ffff:172.18.0.6' + }, + headers: { + 'accept-encoding': 'gzip, deflate', + accept: '*/*', + connection: 'keep-alive', + 'elastic-apm-traceparent': + '00-86c68779d8a65b06fb78e770ffc436a5-4aaea53dc1791183-01', + host: 'opbeans-node:3000', + 'user-agent': 'python-requests/2.20.0' + }, + http_version: '1.1' + } + }, + parent: { id: '4aaea53dc1791183' }, + trace: { id: '86c68779d8a65b06fb78e770ffc436a5' } + }, + sort: [1542574424070] + } + ] + } + } + }, + { + key: 'GET /api/orders', + doc_count: 3247, + avg: { value: 33265.03326147213 }, + p95: { values: { '95.0': 58827.489999999976 } }, + sample: { + hits: { + total: 3247, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '6BKZKGcBVMxP8Wru1G13', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:40.973Z', + timestamp: { us: 1542574420973006 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + type: 'request', + result: 'HTTP 2xx', + sampled: true, + span_count: { started: 2 }, + id: '89f200353eb50539', + name: 'GET /api/orders', + duration: { us: 23040 } + }, + context: { + user: { + username: 'kimchy', + email: 'kimchy@elastic.co', + id: '42' + }, + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + }, + custom: { containerId: 408 }, + request: { + method: 'GET', + url: { + full: 'http://opbeans-node:3000/api/orders', + raw: '/api/orders', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/api/orders' + }, + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000', + connection: 'close' + }, + http_version: '1.1' + }, + response: { + status_code: 200, + headers: { + etag: 'W/"194bc-cOw6+iRf7XCeqMXHrle3IOig7tY"', + date: 'Sun, 18 Nov 2018 20:53:40 GMT', + connection: 'close', + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8', + 'content-length': '103612' + } + }, + system: { + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64' + }, + process: { + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3756, + ppid: 1 + }, + service: { + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' } + } + }, + trace: { id: '0afce85f593cbbdd09949936fe964f0f' } + }, + sort: [1542574420973] + } + ] + } + } + }, + { + key: 'GET /log-message', + doc_count: 700, + avg: { value: 32900.72714285714 }, + p95: { values: { '95.0': 40444 } }, + sample: { + hits: { + total: 700, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'qBKVKGcBVMxP8Wruqi_j', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:49:09.225Z', + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + sampled: true, + span_count: { started: 0 }, + id: 'b9a8f96d7554d09f', + name: 'GET /log-message', + duration: { us: 32381 }, + type: 'request', + result: 'HTTP 5xx' + }, + context: { + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar' + }, + custom: { containerId: 321 }, + request: { + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000', + connection: 'close' + }, + http_version: '1.1', + method: 'GET', + url: { + raw: '/log-message', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/log-message', + full: 'http://opbeans-node:3000/log-message' + } + }, + response: { + status_code: 500, + headers: { + 'x-powered-by': 'Express', + 'content-type': 'text/html; charset=utf-8', + 'content-length': '24', + etag: 'W/"18-MS3VbhH7auHMzO0fUuNF6v14N/M"', + date: 'Sun, 18 Nov 2018 20:49:09 GMT', + connection: 'close' + } + }, + system: { + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux' + }, + process: { + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3142, + ppid: 1 + }, + service: { + language: { name: 'javascript' }, + runtime: { version: '8.12.0', name: 'node' }, + name: 'opbeans-node', + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0' + } + }, + trace: { id: 'ba18b741cdd3ac83eca89a5fede47577' }, + timestamp: { us: 1542574149225004 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' } + }, + sort: [1542574149225] + } + ] + } + } + }, + { + key: 'GET /api/stats', + doc_count: 4639, + avg: { value: 32554.36257814184 }, + p95: { values: { '95.0': 59356.73611111111 } }, + sample: { + hits: { + total: 4639, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '9hKZKGcBVMxP8Wru1G13', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:42.560Z', + trace: { id: '63ccc3b0929dafb7f2fbcabdc7f7af25' }, + timestamp: { us: 1542574422560002 }, + agent: { + hostname: 'b359e3afece8', + version: '7.0.0-alpha1', + type: 'apm-server' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + sampled: true, + span_count: { started: 7 }, + id: 'fb754e7628da2fb5', + name: 'GET /api/stats', + duration: { us: 28753 }, + type: 'request', + result: 'HTTP 3xx' + }, + context: { + response: { + headers: { + 'x-powered-by': 'Express', + etag: 'W/"77-uxKJrX5GSMJJWTKh3orUFAEVxSs"', + date: 'Sun, 18 Nov 2018 20:53:42 GMT', + connection: 'keep-alive' + }, + status_code: 304 + }, + system: { + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux' + }, + process: { + pid: 3756, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + }, + service: { + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' } + }, + user: { + email: 'kimchy@elastic.co', + id: '42', + username: 'kimchy' + }, + tags: { + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test' + }, + custom: { containerId: 207 }, + request: { + url: { + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/api/stats', + full: 'http://opbeans-node:3000/api/stats', + raw: '/api/stats' + }, + socket: { + remote_address: '::ffff:172.18.0.7', + encrypted: false + }, + headers: { + 'if-none-match': 'W/"77-uxKJrX5GSMJJWTKh3orUFAEVxSs"', + host: 'opbeans-node:3000', + connection: 'keep-alive', + 'user-agent': 'Chromeless 1.4.0', + 'elastic-apm-traceparent': + '00-63ccc3b0929dafb7f2fbcabdc7f7af25-821a787e73ab1563-01', + accept: '*/*', + referer: 'http://opbeans-node:3000/dashboard', + 'accept-encoding': 'gzip, deflate' + }, + http_version: '1.1', + method: 'GET' + } + }, + parent: { id: '821a787e73ab1563' } + }, + sort: [1542574422560] + } + ] + } + } + }, + { + key: 'GET /log-error', + doc_count: 736, + avg: { value: 32387.73641304348 }, + p95: { values: { '95.0': 40061.1 } }, + sample: { + hits: { + total: 736, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'rBKYKGcBVMxP8Wru9mC0', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:52:51.462Z', + host: { name: 'b359e3afece8' }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + sampled: true, + span_count: { started: 0 }, + id: 'ec9c465c5042ded8', + name: 'GET /log-error', + duration: { us: 33367 }, + type: 'request', + result: 'HTTP 5xx' + }, + context: { + service: { + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' } + }, + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test' + }, + custom: { containerId: 4877 }, + request: { + http_version: '1.1', + method: 'GET', + url: { + full: 'http://opbeans-node:3000/log-error', + raw: '/log-error', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/log-error' + }, + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000', + connection: 'close' + } + }, + response: { + headers: { + date: 'Sun, 18 Nov 2018 20:52:51 GMT', + connection: 'close', + 'x-powered-by': 'Express', + 'content-type': 'text/html; charset=utf-8', + 'content-length': '24', + etag: 'W/"18-MS3VbhH7auHMzO0fUuNF6v14N/M"' + }, + status_code: 500 + }, + system: { + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255' + }, + process: { + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3659, + ppid: 1, + title: 'node /app/server.js' + } + }, + trace: { id: '15366d65659b5fc8f67ff127391b3aff' }, + timestamp: { us: 1542574371462005 } + }, + sort: [1542574371462] + } + ] + } + } + }, + { + key: 'GET /api/customers', + doc_count: 3366, + avg: { value: 32159.926322043968 }, + p95: { values: { '95.0': 59845.85714285714 } }, + sample: { + hits: { + total: 3366, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'aRKZKGcBVMxP8Wruf2ly', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:21.180Z', + transaction: { + sampled: true, + span_count: { started: 2 }, + id: '94852b9dd1075982', + name: 'GET /api/customers', + duration: { us: 18077 }, + type: 'request', + result: 'HTTP 2xx' + }, + context: { + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + }, + custom: { containerId: 2531 }, + request: { + http_version: '1.1', + method: 'GET', + url: { + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/api/customers', + full: 'http://opbeans-node:3000/api/customers', + raw: '/api/customers' + }, + socket: { + remote_address: '::ffff:172.18.0.6', + encrypted: false + }, + headers: { + accept: '*/*', + connection: 'keep-alive', + 'elastic-apm-traceparent': + '00-541025da8ecc2f51f21c1a4ad6992b77-ca18d9d4c3879519-01', + host: 'opbeans-node:3000', + 'user-agent': 'python-requests/2.20.0', + 'accept-encoding': 'gzip, deflate' + } + }, + response: { + status_code: 200, + headers: { + etag: 'W/"2d991-yG3J8W/roH7fSxXTudZrO27Ax9s"', + date: 'Sun, 18 Nov 2018 20:53:21 GMT', + connection: 'keep-alive', + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8', + 'content-length': '186769' + } + }, + system: { + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64' + }, + process: { + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3710, + ppid: 1 + }, + service: { + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' } + } + }, + parent: { id: 'ca18d9d4c3879519' }, + trace: { id: '541025da8ecc2f51f21c1a4ad6992b77' }, + timestamp: { us: 1542574401180002 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + } + }, + sort: [1542574401180] + } + ] + } + } + }, + { + key: 'GET /api/products/top', + doc_count: 3694, + avg: { value: 27516.89144558744 }, + p95: { values: { '95.0': 56064.679999999986 } }, + sample: { + hits: { + total: 3694, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'LhKZKGcBVMxP8WruHWMl', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:52:57.316Z', + host: { name: 'b359e3afece8' }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + span_count: { started: 4 }, + id: 'be4bd5475d5d9e6f', + name: 'GET /api/products/top', + duration: { us: 48781 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true + }, + context: { + request: { + headers: { + host: 'opbeans-node:3000', + connection: 'keep-alive', + 'user-agent': 'Chromeless 1.4.0', + 'elastic-apm-traceparent': + '00-74f12e705936d66350f4741ebeb55189-fcebe94cd2136215-01', + accept: '*/*', + referer: 'http://opbeans-node:3000/dashboard', + 'accept-encoding': 'gzip, deflate' + }, + http_version: '1.1', + method: 'GET', + url: { + port: '3000', + pathname: '/api/products/top', + full: 'http://opbeans-node:3000/api/products/top', + raw: '/api/products/top', + protocol: 'http:', + hostname: 'opbeans-node' + }, + socket: { + remote_address: '::ffff:172.18.0.7', + encrypted: false + } + }, + response: { + status_code: 200, + headers: { + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8', + 'content-length': '282', + etag: 'W/"11a-lcI9zuMZYYsDRpEZgYqDYr96cKM"', + date: 'Sun, 18 Nov 2018 20:52:57 GMT', + connection: 'keep-alive' + } + }, + system: { + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10' + }, + process: { + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3686, + ppid: 1 + }, + service: { + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { name: 'nodejs', version: '1.14.2' } + }, + user: { + username: 'kimchy', + email: 'kimchy@elastic.co', + id: '42' + }, + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + }, + custom: { containerId: 5113 } + }, + parent: { id: 'fcebe94cd2136215' }, + trace: { id: '74f12e705936d66350f4741ebeb55189' }, + timestamp: { us: 1542574377316005 } + }, + sort: [1542574377316] + } + ] + } + } + }, + { + key: 'POST /api', + doc_count: 147, + avg: { value: 21331.714285714286 }, + p95: { values: { '95.0': 30938 } }, + sample: { + hits: { + total: 147, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'DhGDKGcBVMxP8WruzRXV', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:29:42.751Z', + transaction: { + duration: { us: 21083 }, + type: 'request', + result: 'HTTP 4xx', + sampled: true, + span_count: { started: 1 }, + id: 'd67c2f7aa897110c', + name: 'POST /api' + }, + context: { + user: { + email: 'kimchy@elastic.co', + id: '42', + username: 'kimchy' + }, + tags: { + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test' + }, + custom: { containerId: 2927 }, + request: { + url: { + raw: '/api/orders', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/api/orders', + full: 'http://opbeans-node:3000/api/orders' + }, + socket: { + encrypted: false, + remote_address: '::ffff:172.18.0.10' + }, + headers: { + accept: 'application/json', + 'content-type': 'application/json', + 'content-length': '129', + connection: 'close', + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000' + }, + body: '[REDACTED]', + http_version: '1.1', + method: 'POST' + }, + response: { + status_code: 400, + headers: { + 'x-powered-by': 'Express', + date: 'Sun, 18 Nov 2018 20:29:42 GMT', + 'content-length': '0', + connection: 'close' + } + }, + system: { + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10' + }, + process: { + pid: 546, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + }, + service: { + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node' + } + }, + trace: { id: '8ed4d94ec8fc11b1ea1b0aa59c2320ff' }, + timestamp: { us: 1542572982751005 }, + agent: { + version: '7.0.0-alpha1', + type: 'apm-server', + hostname: 'b359e3afece8' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + } + }, + sort: [1542572982751] + } + ] + } + } + }, + { + key: 'GET /api/products/:id/customers', + doc_count: 2102, + avg: { value: 17189.329210275926 }, + p95: { values: { '95.0': 39284.79999999999 } }, + sample: { + hits: { + total: 2102, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'lhKVKGcBVMxP8WruDCUH', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:48:24.769Z', + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + event: 'transaction', + name: 'transaction' + }, + transaction: { + type: 'request', + result: 'HTTP 2xx', + sampled: true, + span_count: { started: 1 }, + id: '2a87ae20ad04ee0c', + name: 'GET /api/products/:id/customers', + duration: { us: 49338 } + }, + context: { + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar' + }, + custom: { containerId: 1735 }, + request: { + headers: { + accept: '*/*', + connection: 'keep-alive', + 'elastic-apm-traceparent': + '00-28f178c354d17f400dea04bc4a7b3c57-68f5d1607cac7779-01', + host: 'opbeans-node:3000', + 'user-agent': 'python-requests/2.20.0', + 'accept-encoding': 'gzip, deflate' + }, + http_version: '1.1', + method: 'GET', + url: { + port: '3000', + pathname: '/api/products/2/customers', + full: + 'http://opbeans-node:3000/api/products/2/customers', + raw: '/api/products/2/customers', + protocol: 'http:', + hostname: 'opbeans-node' + }, + socket: { + remote_address: '::ffff:172.18.0.6', + encrypted: false + } + }, + response: { + status_code: 200, + headers: { + 'content-length': '186570', + etag: 'W/"2d8ca-Z9NzuHyGyxwtzpOkcIxBvzm24iw"', + date: 'Sun, 18 Nov 2018 20:48:24 GMT', + connection: 'keep-alive', + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8' + } + }, + system: { + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64' + }, + process: { + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3100, + ppid: 1, + title: 'node /app/server.js' + }, + service: { + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0' + } + }, + parent: { id: '68f5d1607cac7779' }, + trace: { id: '28f178c354d17f400dea04bc4a7b3c57' }, + timestamp: { us: 1542574104769029 } + }, + sort: [1542574104769] + } + ] + } + } + }, + { + key: 'GET /api/types/:id', + doc_count: 1449, + avg: { value: 12763.68806073154 }, + p95: { values: { '95.0': 30576.749999999996 } }, + sample: { + hits: { + total: 1449, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'lxKZKGcBVMxP8WrurGuW', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:35.967Z', + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + id: '053436abacdec0a4', + name: 'GET /api/types/:id', + duration: { us: 13064 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true, + span_count: { started: 2 } + }, + context: { + process: { + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3756, + ppid: 1 + }, + service: { + name: 'opbeans-node', + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' } + }, + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + }, + custom: { containerId: 5345 }, + request: { + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000', + connection: 'close' + }, + http_version: '1.1', + method: 'GET', + url: { + pathname: '/api/types/1', + full: 'http://opbeans-node:3000/api/types/1', + raw: '/api/types/1', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000' + } + }, + response: { + status_code: 200, + headers: { + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8', + 'content-length': '217', + etag: 'W/"d9-cebOOHODBQMZd1wt+ZZBaSPgQLQ"', + date: 'Sun, 18 Nov 2018 20:53:35 GMT', + connection: 'close' + } + }, + system: { + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64' + } + }, + trace: { id: '2223b30b5cbaf2e221fcf70ac6d9abbe' }, + timestamp: { us: 1542574415967005 }, + host: { name: 'b359e3afece8' }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + } + }, + sort: [1542574415967] + } + ] + } + } + }, + { + key: 'GET /api/products', + doc_count: 3678, + avg: { value: 12683.190864600327 }, + p95: { values: { '95.0': 35009.67999999999 } }, + sample: { + hits: { + total: 3678, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '-hKZKGcBVMxP8Wru1G13', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:43.477Z', + trace: { id: 'bee00a8efb523ca4b72adad57f7caba3' }, + timestamp: { us: 1542574423477006 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + span_count: { started: 2 }, + id: 'd8fc6d3b8707b64c', + name: 'GET /api/products', + duration: { us: 6915 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true + }, + context: { + custom: { containerId: 2857 }, + request: { + headers: { + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000', + connection: 'close' + }, + http_version: '1.1', + method: 'GET', + url: { + full: 'http://opbeans-node:3000/api/products', + raw: '/api/products', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/api/products' + }, + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + } + }, + response: { + status_code: 200, + headers: { + connection: 'close', + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8', + 'content-length': '1023', + etag: 'W/"3ff-VyOxcDApb+a/lnjkm9FeTOGSDrs"', + date: 'Sun, 18 Nov 2018 20:53:43 GMT' + } + }, + system: { + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10' + }, + process: { + pid: 3756, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + }, + service: { + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0', + language: { name: 'javascript' } + }, + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + } + } + }, + sort: [1542574423477] + } + ] + } + } + }, + { + key: 'GET /api/types', + doc_count: 2400, + avg: { value: 11257.757916666667 }, + p95: { values: { '95.0': 35222.944444444445 } }, + sample: { + hits: { + total: 2400, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '_xKZKGcBVMxP8Wru1G13', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:44.978Z', + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + id: '0f10668e4fb3adc7', + name: 'GET /api/types', + duration: { us: 7891 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true, + span_count: { started: 2 } + }, + context: { + request: { + http_version: '1.1', + method: 'GET', + url: { + hostname: 'opbeans-node', + port: '3000', + pathname: '/api/types', + full: 'http://opbeans-node:3000/api/types', + raw: '/api/types', + protocol: 'http:' + }, + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + connection: 'close', + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000' + } + }, + response: { + status_code: 200, + headers: { + 'content-length': '112', + etag: 'W/"70-1z6hT7P1WHgBgS/BeUEVeHhOCQU"', + date: 'Sun, 18 Nov 2018 20:53:44 GMT', + connection: 'close', + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8' + } + }, + system: { + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10' + }, + process: { + pid: 3756, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + }, + service: { + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' } + }, + user: { + email: 'kimchy@elastic.co', + id: '42', + username: 'kimchy' + }, + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + }, + custom: { containerId: 2193 } + }, + trace: { id: '0d84126973411c19b470f2d9eea958d3' }, + timestamp: { us: 1542574424978005 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' } + }, + sort: [1542574424978] + } + ] + } + } + }, + { + key: 'GET /api/orders/:id', + doc_count: 1283, + avg: { value: 10584.05144193297 }, + p95: { values: { '95.0': 26555.399999999998 } }, + sample: { + hits: { + total: 1283, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'SRKXKGcBVMxP8Wru41Gf', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:51:36.949Z', + context: { + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + }, + custom: { containerId: 5999 }, + request: { + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + connection: 'close', + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000' + }, + http_version: '1.1', + method: 'GET', + url: { + raw: '/api/orders/183', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/api/orders/183', + full: 'http://opbeans-node:3000/api/orders/183' + } + }, + response: { + headers: { + date: 'Sun, 18 Nov 2018 20:51:36 GMT', + connection: 'close', + 'content-length': '0', + 'x-powered-by': 'Express' + }, + status_code: 404 + }, + system: { + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10' + }, + process: { + pid: 3475, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + }, + service: { + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node' + }, + user: { + username: 'kimchy', + email: 'kimchy@elastic.co', + id: '42' + } + }, + trace: { id: 'dab6421fa44a6869887e0edf32e1ad6f' }, + timestamp: { us: 1542574296949004 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + span_count: { started: 1 }, + id: '937ef5588454f74a', + name: 'GET /api/orders/:id', + duration: { us: 5906 }, + type: 'request', + result: 'HTTP 4xx', + sampled: true + } + }, + sort: [1542574296949] + } + ] + } + } + }, + { + key: 'GET /api/products/:id', + doc_count: 1839, + avg: { value: 10548.218597063622 }, + p95: { values: { '95.0': 28413.383333333328 } }, + sample: { + hits: { + total: 1839, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'OxKZKGcBVMxP8WruHWMl', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:52:57.963Z', + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + span_count: { started: 1 }, + id: 'd324897ffb7ebcdc', + name: 'GET /api/products/:id', + duration: { us: 6959 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true + }, + context: { + service: { + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { version: '8.12.0', name: 'node' } + }, + user: { + email: 'kimchy@elastic.co', + id: '42', + username: 'kimchy' + }, + tags: { + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test' + }, + custom: { containerId: 7184 }, + request: { + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + host: 'opbeans-node:3000', + connection: 'close', + 'user-agent': 'workload/2.4.3' + }, + http_version: '1.1', + method: 'GET', + url: { + port: '3000', + pathname: '/api/products/3', + full: 'http://opbeans-node:3000/api/products/3', + raw: '/api/products/3', + protocol: 'http:', + hostname: 'opbeans-node' + } + }, + response: { + status_code: 200, + headers: { + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8', + 'content-length': '231', + etag: 'W/"e7-kkuzj37GZDzXDh0CWqh5Gan0VO4"', + date: 'Sun, 18 Nov 2018 20:52:57 GMT', + connection: 'close' + } + }, + system: { + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux' + }, + process: { + pid: 3686, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + } + }, + trace: { id: 'ca86ec845e412e4b4506a715d51548ec' }, + timestamp: { us: 1542574377963005 } + }, + sort: [1542574377963] + } + ] + } + } + }, + { + key: 'GET /api/customers/:id', + doc_count: 1900, + avg: { value: 9868.217894736843 }, + p95: { values: { '95.0': 27486.5 } }, + sample: { + hits: { + total: 1900, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'IhKZKGcBVMxP8WruHGPb', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:52:56.797Z', + agent: { + hostname: 'b359e3afece8', + version: '7.0.0-alpha1', + type: 'apm-server' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + span_count: { started: 1 }, + id: '60e230d12f3f0960', + name: 'GET /api/customers/:id', + duration: { us: 9735 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true + }, + context: { + response: { + status_code: 200, + headers: { + connection: 'keep-alive', + 'x-powered-by': 'Express', + 'content-type': 'application/json; charset=utf-8', + 'content-length': '193', + etag: 'W/"c1-LbuhkuLzFyZ0H+7+JQGA5b0kvNs"', + date: 'Sun, 18 Nov 2018 20:52:56 GMT' + } + }, + system: { + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255' + }, + process: { + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3686 + }, + service: { + name: 'opbeans-node', + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' } + }, + user: { + username: 'kimchy', + email: 'kimchy@elastic.co', + id: '42' + }, + tags: { + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test' + }, + custom: { containerId: 8225 }, + request: { + headers: { + 'accept-encoding': 'gzip, deflate', + accept: '*/*', + connection: 'keep-alive', + 'elastic-apm-traceparent': + '00-e6140d30363f18b585f5d3b753f4d025-aa82e2c847265626-01', + host: 'opbeans-node:3000', + 'user-agent': 'python-requests/2.20.0' + }, + http_version: '1.1', + method: 'GET', + url: { + pathname: '/api/customers/700', + full: 'http://opbeans-node:3000/api/customers/700', + raw: '/api/customers/700', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000' + }, + socket: { + remote_address: '::ffff:172.18.0.6', + encrypted: false + } + } + }, + parent: { id: 'aa82e2c847265626' }, + trace: { id: 'e6140d30363f18b585f5d3b753f4d025' }, + timestamp: { us: 1542574376797031 } + }, + sort: [1542574376797] + } + ] + } + } + }, + { + key: 'POST unknown route', + doc_count: 20, + avg: { value: 5192.9 }, + p95: { values: { '95.0': 13230.5 } }, + sample: { + hits: { + total: 20, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '4wsiKGcBVMxP8Wru2j59', + _score: null, + _source: { + '@timestamp': '2018-11-18T18:43:50.994Z', + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + sampled: true, + span_count: { started: 0 }, + id: '92c3ceea57899061', + name: 'POST unknown route', + duration: { us: 3467 }, + type: 'request', + result: 'HTTP 4xx' + }, + context: { + system: { + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64' + }, + process: { + pid: 19196, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + }, + service: { + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' } + }, + user: { + email: 'kimchy@elastic.co', + id: '42', + username: 'kimchy' + }, + tags: { + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.' + }, + custom: { containerId: 6102 }, + request: { + method: 'POST', + url: { + raw: '/api/orders/csv', + protocol: 'http:', + hostname: '172.18.0.9', + port: '3000', + pathname: '/api/orders/csv', + full: 'http://172.18.0.9:3000/api/orders/csv' + }, + socket: { + remote_address: '::ffff:172.18.0.9', + encrypted: false + }, + headers: { + 'accept-encoding': 'gzip, deflate', + 'content-type': + 'multipart/form-data; boundary=2b2e40be188a4cb5a56c05a0c182f6c9', + 'elastic-apm-traceparent': + '00-19688959ea6cbccda8013c11566ea329-1fc3665eef2dcdfc-01', + 'x-forwarded-for': '172.18.0.11', + host: '172.18.0.9:3000', + 'user-agent': 'Python/3.7 aiohttp/3.3.2', + 'content-length': '380', + accept: '*/*' + }, + body: '[REDACTED]', + http_version: '1.1' + }, + response: { + headers: { + date: 'Sun, 18 Nov 2018 18:43:50 GMT', + connection: 'keep-alive', + 'x-powered-by': 'Express', + 'content-security-policy': "default-src 'self'", + 'x-content-type-options': 'nosniff', + 'content-type': 'text/html; charset=utf-8', + 'content-length': '154' + }, + status_code: 404 + } + }, + parent: { id: '1fc3665eef2dcdfc' }, + trace: { id: '19688959ea6cbccda8013c11566ea329' }, + timestamp: { us: 1542566630994005 }, + agent: { + version: '7.0.0-alpha1', + type: 'apm-server', + hostname: 'b359e3afece8' + } + }, + sort: [1542566630994] + } + ] + } + } + }, + { + key: 'GET /is-it-coffee-time', + doc_count: 358, + avg: { value: 4694.005586592179 }, + p95: { values: { '95.0': 11022.99999999992 } }, + sample: { + hits: { + total: 358, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '7RKSKGcBVMxP8Wru-gjC', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:46:19.317Z', + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + id: '319a5c555a1ab207', + name: 'GET /is-it-coffee-time', + duration: { us: 4253 }, + type: 'request', + result: 'HTTP 5xx', + sampled: true, + span_count: { started: 0 } + }, + context: { + process: { + pid: 2760, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + }, + service: { + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node' + }, + user: { + email: 'kimchy@elastic.co', + id: '42', + username: 'kimchy' + }, + tags: { + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz' + }, + custom: { containerId: 8593 }, + request: { + headers: { + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000', + connection: 'close' + }, + http_version: '1.1', + method: 'GET', + url: { + port: '3000', + pathname: '/is-it-coffee-time', + full: 'http://opbeans-node:3000/is-it-coffee-time', + raw: '/is-it-coffee-time', + protocol: 'http:', + hostname: 'opbeans-node' + }, + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + } + }, + response: { + status_code: 500, + headers: { + date: 'Sun, 18 Nov 2018 20:46:19 GMT', + connection: 'close', + 'x-powered-by': 'Express', + 'content-security-policy': "default-src 'self'", + 'x-content-type-options': 'nosniff', + 'content-type': 'text/html; charset=utf-8', + 'content-length': '148' + } + }, + system: { + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux' + } + }, + trace: { id: '821812b416de4c73ced87f8777fa46a6' }, + timestamp: { us: 1542573979317007 } + }, + sort: [1542573979317] + } + ] + } + } + }, + { + key: 'GET /throw-error', + doc_count: 336, + avg: { value: 4549.889880952381 }, + p95: { values: { '95.0': 7719.700000000001 } }, + sample: { + hits: { + total: 336, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: 'PhKTKGcBVMxP8WruwxSG', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:47:10.714Z', + agent: { + version: '7.0.0-alpha1', + type: 'apm-server', + hostname: 'b359e3afece8' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + id: 'ecd187dc53f09fbd', + name: 'GET /throw-error', + duration: { us: 4458 }, + type: 'request', + result: 'HTTP 5xx', + sampled: true, + span_count: { started: 0 } + }, + context: { + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar' + }, + custom: { containerId: 7220 }, + request: { + http_version: '1.1', + method: 'GET', + url: { + port: '3000', + pathname: '/throw-error', + full: 'http://opbeans-node:3000/throw-error', + raw: '/throw-error', + protocol: 'http:', + hostname: 'opbeans-node' + }, + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000', + connection: 'close' + } + }, + response: { + status_code: 500, + headers: { + 'x-content-type-options': 'nosniff', + 'content-type': 'text/html; charset=utf-8', + 'content-length': '148', + date: 'Sun, 18 Nov 2018 20:47:10 GMT', + connection: 'close', + 'x-powered-by': 'Express', + 'content-security-policy': "default-src 'self'" + } + }, + system: { + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64' + }, + process: { + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 2895, + ppid: 1 + }, + service: { + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' } + } + }, + trace: { id: '6c0ef23e1f963f304ce440a909914d35' }, + timestamp: { us: 1542574030714012 } + }, + sort: [1542574030714] + } + ] + } + } + }, + { + key: 'GET *', + doc_count: 7115, + avg: { value: 3504.5108924806746 }, + p95: { values: { '95.0': 11431.738095238095 } }, + sample: { + hits: { + total: 7115, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '6hKZKGcBVMxP8Wru1G13', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:42.493Z', + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + span_count: { started: 0 }, + id: 'f5fc4621949b63fb', + name: 'GET *', + duration: { us: 1901 }, + type: 'request', + result: 'HTTP 3xx', + sampled: true + }, + context: { + request: { + http_version: '1.1', + method: 'GET', + url: { + hostname: 'opbeans-node', + port: '3000', + pathname: '/dashboard', + full: 'http://opbeans-node:3000/dashboard', + raw: '/dashboard', + protocol: 'http:' + }, + socket: { + remote_address: '::ffff:172.18.0.7', + encrypted: false + }, + headers: { + accept: + 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', + 'accept-encoding': 'gzip, deflate', + 'if-none-match': 'W/"280-1670775e878"', + 'if-modified-since': 'Mon, 12 Nov 2018 10:27:07 GMT', + host: 'opbeans-node:3000', + connection: 'keep-alive', + 'upgrade-insecure-requests': '1', + 'user-agent': 'Chromeless 1.4.0' + } + }, + response: { + status_code: 304, + headers: { + 'x-powered-by': 'Express', + 'accept-ranges': 'bytes', + 'cache-control': 'public, max-age=0', + 'last-modified': 'Mon, 12 Nov 2018 10:27:07 GMT', + etag: 'W/"280-1670775e878"', + date: 'Sun, 18 Nov 2018 20:53:42 GMT', + connection: 'keep-alive' + } + }, + system: { + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10' + }, + process: { + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3756, + ppid: 1 + }, + service: { + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node', + agent: { version: '1.14.2', name: 'nodejs' } + }, + user: { + email: 'kimchy@elastic.co', + id: '42', + username: 'kimchy' + }, + tags: { + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.', + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test' + }, + custom: { containerId: 6446 } + }, + trace: { id: '7efb6ade88cdea20cd96ca482681cde7' }, + timestamp: { us: 1542574422493006 } + }, + sort: [1542574422493] + } + ] + } + } + }, + { + key: 'OPTIONS unknown route', + doc_count: 364, + avg: { value: 2742.4615384615386 }, + p95: { values: { '95.0': 4370.000000000002 } }, + sample: { + hits: { + total: 364, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '-xKVKGcBVMxP8WrucSs2', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:49:00.707Z', + timestamp: { us: 1542574140707006 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + span_count: { started: 0 }, + id: 'a8c87ebc7ec68bc0', + name: 'OPTIONS unknown route', + duration: { us: 2371 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true + }, + context: { + user: { + id: '42', + username: 'kimchy', + email: 'kimchy@elastic.co' + }, + tags: { + 'this-is-a-very-long-tag-name-without-any-spaces': + 'test', + 'multi-line': 'foo\nbar\nbaz', + foo: 'bar', + lorem: + 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.' + }, + custom: { containerId: 3775 }, + request: { + socket: { + remote_address: '::ffff:172.18.0.10', + encrypted: false + }, + headers: { + 'user-agent': 'workload/2.4.3', + host: 'opbeans-node:3000', + 'content-length': '0', + connection: 'close' + }, + http_version: '1.1', + method: 'OPTIONS', + url: { + port: '3000', + pathname: '/', + full: 'http://opbeans-node:3000/', + raw: '/', + protocol: 'http:', + hostname: 'opbeans-node' + } + }, + response: { + status_code: 200, + headers: { + 'content-type': 'text/html; charset=utf-8', + 'content-length': '8', + etag: 'W/"8-ZRAf8oNBS3Bjb/SU2GYZCmbtmXg"', + date: 'Sun, 18 Nov 2018 20:49:00 GMT', + connection: 'close', + 'x-powered-by': 'Express', + allow: 'GET,HEAD' + } + }, + system: { + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux' + }, + process: { + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3142 + }, + service: { + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node' + } + }, + trace: { id: '469e3e5f91ffe3195a8e58cdd1cdefa8' } + }, + sort: [1542574140707] + } + ] + } + } + }, + { + key: 'GET static file', + doc_count: 62606, + avg: { value: 2651.8784461553205 }, + p95: { values: { '95.0': 6140.579335038363 } }, + sample: { + hits: { + total: 62606, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '-RKZKGcBVMxP8Wru1G13', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:43.304Z', + context: { + system: { + platform: 'linux', + ip: '172.18.0.10', + hostname: '98195610c255', + architecture: 'x64' + }, + process: { + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ], + pid: 3756, + ppid: 1 + }, + service: { + name: 'opbeans-node', + agent: { name: 'nodejs', version: '1.14.2' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' } + }, + request: { + headers: { + 'user-agent': 'curl/7.38.0', + host: 'opbeans-node:3000', + accept: '*/*' + }, + http_version: '1.1', + method: 'GET', + url: { + pathname: '/', + full: 'http://opbeans-node:3000/', + raw: '/', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000' + }, + socket: { + encrypted: false, + remote_address: '::ffff:172.18.0.10' + } + }, + response: { + status_code: 200, + headers: { + 'content-length': '640', + 'accept-ranges': 'bytes', + 'cache-control': 'public, max-age=0', + etag: 'W/"280-1670775e878"', + 'x-powered-by': 'Express', + 'last-modified': 'Mon, 12 Nov 2018 10:27:07 GMT', + 'content-type': 'text/html; charset=UTF-8', + date: 'Sun, 18 Nov 2018 20:53:43 GMT', + connection: 'keep-alive' + } + } + }, + trace: { id: 'b303d2a4a007946b63b9db7fafe639a0' }, + timestamp: { us: 1542574423304006 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' }, + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + span_count: { started: 0 }, + id: '2869c13633534be5', + name: 'GET static file', + duration: { us: 1801 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true + } + }, + sort: [1542574423304] + } + ] + } + } + }, + { + key: 'GET unknown route', + doc_count: 7487, + avg: { value: 1422.926672899693 }, + p95: { values: { '95.0': 2311.885238095238 } }, + sample: { + hits: { + total: 7487, + max_score: null, + hits: [ + { + _index: 'apm-7.0.0-alpha1-2018.11.18', + _type: 'doc', + _id: '6xKZKGcBVMxP8Wru1G13', + _score: null, + _source: { + '@timestamp': '2018-11-18T20:53:42.504Z', + processor: { + name: 'transaction', + event: 'transaction' + }, + transaction: { + name: 'GET unknown route', + duration: { us: 911 }, + type: 'request', + result: 'HTTP 2xx', + sampled: true, + span_count: { started: 0 }, + id: '107881ae2be1b56d' + }, + context: { + system: { + hostname: '98195610c255', + architecture: 'x64', + platform: 'linux', + ip: '172.18.0.10' + }, + process: { + pid: 3756, + ppid: 1, + title: 'node /app/server.js', + argv: [ + '/usr/local/bin/node', + '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' + ] + }, + service: { + agent: { version: '1.14.2', name: 'nodejs' }, + version: '1.0.0', + language: { name: 'javascript' }, + runtime: { name: 'node', version: '8.12.0' }, + name: 'opbeans-node' + }, + request: { + http_version: '1.1', + method: 'GET', + url: { + full: 'http://opbeans-node:3000/rum-config.js', + raw: '/rum-config.js', + protocol: 'http:', + hostname: 'opbeans-node', + port: '3000', + pathname: '/rum-config.js' + }, + socket: { + remote_address: '::ffff:172.18.0.7', + encrypted: false + }, + headers: { + connection: 'keep-alive', + 'user-agent': 'Chromeless 1.4.0', + accept: '*/*', + referer: 'http://opbeans-node:3000/dashboard', + 'accept-encoding': 'gzip, deflate', + host: 'opbeans-node:3000' + } + }, + response: { + headers: { + 'x-powered-by': 'Express', + 'content-type': 'text/javascript', + 'content-length': '172', + date: 'Sun, 18 Nov 2018 20:53:42 GMT', + connection: 'keep-alive' + }, + status_code: 200 + } + }, + trace: { id: '4399e7233e6e7b77e70c2fff111b8f28' }, + timestamp: { us: 1542574422504004 }, + agent: { + type: 'apm-server', + hostname: 'b359e3afece8', + version: '7.0.0-alpha1' + }, + host: { name: 'b359e3afece8' } + }, + sort: [1542574422504] + } + ] + } + } + } + ] + } + } +} as unknown) as ESResponse; diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/transform.test.ts b/x-pack/plugins/apm/server/lib/transaction_groups/transform.test.ts new file mode 100644 index 0000000000000..73053aa04643d --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transaction_groups/transform.test.ts @@ -0,0 +1,57 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ESResponse } from './fetcher'; +import { transactionGroupsResponse } from './mock-responses/transactionGroupsResponse'; +import { transactionGroupsTransformer } from './transform'; + +describe('transactionGroupsTransformer', () => { + it('should match snapshot', () => { + expect( + transactionGroupsTransformer({ + response: transactionGroupsResponse, + start: 100, + end: 2000 + }) + ).toMatchSnapshot(); + }); + + fit('should transform response correctly', () => { + const bucket = { + key: 'POST /api/orders', + doc_count: 180, + avg: { value: 255966.30555555556 }, + p95: { values: { '95.0': 320238.5 } }, + sample: { + hits: { + total: 180, + hits: [{ _source: 'sample source' }] + } + } + }; + + const response = ({ + aggregations: { + transactions: { + buckets: [bucket] + } + } + } as unknown) as ESResponse; + + expect( + transactionGroupsTransformer({ response, start: 100, end: 20000 }) + ).toEqual([ + { + averageResponseTime: 255966.30555555556, + impact: 0, + name: 'POST /api/orders', + p95: 320238.5, + sample: 'sample source', + transactionsPerMinute: 542.713567839196 + } + ]); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts b/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts new file mode 100644 index 0000000000000..229134025b18f --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts @@ -0,0 +1,61 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import moment from 'moment'; +import { oc } from 'ts-optchain'; +import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { ESResponse } from './fetcher'; + +export interface ITransactionGroup { + name: string; + sample: Transaction; + p95: number; + averageResponseTime: number; + transactionsPerMinute: number; + impact: number; +} + +function calculateRelativeImpacts(results: ITransactionGroup[]) { + const values = results.map(({ impact }) => impact); + const max = Math.max(...values); + const min = Math.min(...values); + + return results.map(bucket => ({ + ...bucket, + impact: ((bucket.impact - min) / (max - min)) * 100 || 0 + })); +} + +export function transactionGroupsTransformer({ + response, + start, + end +}: { + response: ESResponse; + start: number; + end: number; +}): ITransactionGroup[] { + const buckets = oc(response).aggregations.transactions.buckets([]); + const duration = moment.duration(end - start); + const minutes = duration.asMinutes(); + const results = buckets.map(bucket => { + const averageResponseTime = bucket.avg.value; + const transactionsPerMinute = bucket.doc_count / minutes; + const impact = Math.round(averageResponseTime * transactionsPerMinute); + const sample = bucket.sample.hits.hits[0]._source; + + return { + name: bucket.key, + sample, + p95: bucket.p95.values['95.0'], + averageResponseTime, + transactionsPerMinute, + impact + }; + }); + + return calculateRelativeImpacts(results); +} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/__test__/__snapshots__/get_timeseries_data.test.js.snap b/x-pack/plugins/apm/server/lib/transactions/charts/__test__/__snapshots__/get_timeseries_data.test.js.snap deleted file mode 100644 index 7cee615bee11e..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/__test__/__snapshots__/get_timeseries_data.test.js.snap +++ /dev/null @@ -1,1240 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`get_timeseries_data should call client with correct query 1`] = ` -Array [ - Array [ - "search", - Object { - "body": Object { - "aggs": Object { - "overall_avg_duration": Object { - "avg": Object { - "field": "transaction.duration.us", - }, - }, - "response_times": Object { - "aggs": Object { - "avg": Object { - "avg": Object { - "field": "transaction.duration.us", - }, - }, - "pct": Object { - "percentiles": Object { - "field": "transaction.duration.us", - "percents": Array [ - 95, - 99, - ], - }, - }, - }, - "date_histogram": Object { - "extended_bounds": Object { - "max": 1528977600000, - "min": 1528113600000, - }, - "field": "@timestamp", - "interval": "10800s", - "min_doc_count": 0, - }, - }, - "transaction_results": Object { - "aggs": Object { - "timeseries": Object { - "date_histogram": Object { - "extended_bounds": Object { - "max": 1528977600000, - "min": 1528113600000, - }, - "field": "@timestamp", - "interval": "10800s", - "min_doc_count": 0, - }, - }, - }, - "terms": Object { - "field": "transaction.result", - "missing": "transaction_result_missing", - }, - }, - }, - "query": Object { - "bool": Object { - "filter": Array [ - Object { - "term": Object { - "context.service.name": "myServiceName", - }, - }, - Object { - "term": Object { - "transaction.type": "myTransactionType", - }, - }, - Object { - "range": Object { - "@timestamp": Object { - "format": "epoch_millis", - "gte": 1528113600000, - "lte": 1528977600000, - }, - }, - }, - ], - }, - }, - "size": 0, - }, - "index": "myIndex", - }, - ], - Array [ - "search", - Object { - "body": Object { - "aggs": Object { - "ml_avg_response_times": Object { - "aggs": Object { - "anomaly_score": Object { - "max": Object { - "field": "anomaly_score", - }, - }, - "lower": Object { - "min": Object { - "field": "model_lower", - }, - }, - "upper": Object { - "max": Object { - "field": "model_upper", - }, - }, - }, - "date_histogram": Object { - "extended_bounds": Object { - "max": 1528977600000, - "min": 1528113600000, - }, - "field": "timestamp", - "interval": "10800s", - "min_doc_count": 0, - }, - }, - "top_hits": Object { - "top_hits": Object { - "_source": Object { - "includes": Array [ - "bucket_span", - ], - }, - "size": 1, - "sort": Array [ - "bucket_span", - ], - }, - }, - }, - "query": Object { - "bool": Object { - "filter": Array [ - Object { - "range": Object { - "timestamp": Object { - "format": "epoch_millis", - "gte": 1528113600000, - "lte": 1528977600000, - }, - }, - }, - ], - }, - }, - "size": 0, - }, - "index": ".ml-anomalies-myservicename-mytransactiontype-high_mean_response_time", - }, - ], -] -`; - -exports[`get_timeseries_data should match snapshot 1`] = ` -Object { - "dates": Array [ - 1528124400000, - 1528135200000, - 1528146000000, - 1528156800000, - 1528167600000, - 1528178400000, - 1528189200000, - 1528200000000, - 1528210800000, - 1528221600000, - 1528232400000, - 1528243200000, - 1528254000000, - 1528264800000, - 1528275600000, - 1528286400000, - 1528297200000, - 1528308000000, - 1528318800000, - 1528329600000, - 1528340400000, - 1528351200000, - 1528362000000, - 1528372800000, - 1528383600000, - 1528394400000, - 1528405200000, - 1528416000000, - 1528426800000, - 1528437600000, - 1528448400000, - 1528459200000, - 1528470000000, - 1528480800000, - 1528491600000, - 1528502400000, - 1528513200000, - 1528524000000, - 1528534800000, - 1528545600000, - 1528556400000, - 1528567200000, - 1528578000000, - 1528588800000, - 1528599600000, - 1528610400000, - 1528621200000, - 1528632000000, - 1528642800000, - 1528653600000, - 1528664400000, - 1528675200000, - 1528686000000, - 1528696800000, - 1528707600000, - 1528718400000, - 1528729200000, - 1528740000000, - 1528750800000, - 1528761600000, - 1528772400000, - 1528783200000, - 1528794000000, - 1528804800000, - 1528815600000, - 1528826400000, - 1528837200000, - 1528848000000, - 1528858800000, - 1528869600000, - 1528880400000, - 1528891200000, - 1528902000000, - 1528912800000, - 1528923600000, - 1528934400000, - 1528945200000, - 1528956000000, - 1528966800000, - ], - "overall_avg_duration": 32861.15660262639, - "response_times": Object { - "avg": Array [ - 26193.277795595466, - 25291.787065995228, - 24690.306474667796, - 24809.8953814219, - 25460.0394764508, - 26360.440733498916, - 27050.95205479452, - 26555.857333903925, - 26164.343359049206, - 26989.84546419098, - 26314.409430068266, - 27460.774575018477, - 26461.469107431974, - 27657.584946692834, - 27940.445967005213, - 34454.377581534434, - 44024.31809353839, - 36374.53333333333, - 36991.29442471209, - 37178.002701986756, - 37605.57078923814, - 37319.89767295267, - 38709.5041348433, - 38140.131856255066, - 34564.81091043125, - 33256.37743828302, - 37251.5625266752, - 38681.89084929791, - 40677.801045709355, - 39987.86453616932, - 41059.392914139804, - 39630.710111535845, - 41561.81331074284, - 43079.490738297536, - 43925.39609283509, - 25821.91424646782, - 27343.60011755486, - 25249.95060523233, - 25492.77199074074, - 25991.647281682137, - 26273.31290445375, - 26234.98976780795, - 23494.54873786408, - 22008.80482069371, - 22828.136655635586, - 22138.7081404321, - 22634.985579811735, - 22202.780998080616, - 23084.082780163997, - 23109.666146341464, - 23306.89028152719, - 39341.022704095325, - 37467.17153341258, - 52457.50554180566, - 31327.95780166252, - 30695.334941163997, - 28895.042785967435, - 30649.363989982416, - 29802.63622014101, - 30759.03002829892, - 30399.76549608631, - 29421.610233534506, - 32641.679897096656, - 30621.65440666204, - 31039.60391005818, - 30954.760723541545, - 31902.050234568553, - 31594.350653473728, - 31343.87243248879, - 31200.14450867052, - 28560.946668743833, - 24700.216146371717, - 25261.025210523563, - 26041.39789649068, - 26123.556295209142, - 46231.36177177638, - 45350.42005506141, - 48256.049354513096, - 52360.30017052116, - ], - "avg_anomalies": Object { - "bucketSpanAsMillis": 10800000, - "buckets": Array [ - Object { - "anomaly_score": 0, - "lower": 737.7398559597923, - "upper": 27505.95012649385, - }, - Object { - "anomaly_score": 0, - "lower": 740.6510789069575, - "upper": 27831.385094457328, - }, - Object { - "anomaly_score": 0, - "lower": 743.0092006506535, - "upper": 28113.842130309873, - }, - Object { - "anomaly_score": 0, - "lower": 745.266369017907, - "upper": 28166.937431054437, - }, - Object { - "anomaly_score": 0.0214167, - "lower": 747.3207728528188, - "upper": 28506.23990430994, - }, - Object { - "anomaly_score": 0, - "lower": 749.6894207909651, - "upper": 29019.425285291298, - }, - Object { - "anomaly_score": 0.05939392, - "lower": 752.7726473096143, - "upper": 29293.392326541318, - }, - Object { - "anomaly_score": 0.01836784, - "lower": 754.7407389918743, - "upper": 29812.56398272085, - }, - Object { - "anomaly_score": 0, - "lower": 757.2268079827784, - "upper": 30060.955415439636, - }, - Object { - "anomaly_score": 0, - "lower": 758.3112520555287, - "upper": 30376.319798106222, - }, - Object { - "anomaly_score": 0, - "lower": 761.9827340264112, - "upper": 30627.243996529527, - }, - Object { - "anomaly_score": 0, - "lower": 771.7209606007517, - "upper": 31035.75952712361, - }, - Object { - "anomaly_score": 0, - "lower": 822.9174906119024, - "upper": 31062.244462967443, - }, - Object { - "anomaly_score": 0, - "lower": 867.1132870297309, - "upper": 31463.705363442183, - }, - Object { - "anomaly_score": 0, - "lower": 871.6217257693573, - "upper": 31743.78493690837, - }, - Object { - "anomaly_score": 93.09271062370188, - "lower": 630.1794765317344, - "upper": 42784.833235636936, - }, - Object { - "anomaly_score": 94.91969, - "lower": 871.0283056454996, - "upper": 34441.21907642463, - }, - Object { - "anomaly_score": 0.737564554333639, - "lower": 872.694053998953, - "upper": 35467.552283525925, - }, - Object { - "anomaly_score": 0.2233028643272195, - "lower": 872.8967719351887, - "upper": 36793.04873774251, - }, - Object { - "anomaly_score": 4.367981, - "lower": 873.2094351335686, - "upper": 37663.180967734144, - }, - Object { - "anomaly_score": 10.94823, - "lower": 872.096335158222, - "upper": 38704.9736025016, - }, - Object { - "anomaly_score": 0.025502508470513552, - "lower": 870.7141079237686, - "upper": 39411.4696425657, - }, - Object { - "anomaly_score": 0.04643894365231562, - "lower": 865.6904233415615, - "upper": 40436.89001900413, - }, - Object { - "anomaly_score": 0.08232853094836577, - "lower": 864.5587212551438, - "upper": 41583.671803791396, - }, - Object { - "anomaly_score": 0, - "lower": 862.0456649399898, - "upper": 41918.88300390927, - }, - Object { - "anomaly_score": 0, - "lower": 862.6952960489333, - "upper": 42346.34733913561, - }, - Object { - "anomaly_score": 0.09328928850624264, - "lower": 859.02865711764, - "upper": 43503.30873034762, - }, - Object { - "anomaly_score": 0.01490678070537287, - "lower": 853.1249075544679, - "upper": 43582.32622523151, - }, - Object { - "anomaly_score": 0.025631694904640304, - "lower": 850.0412997919607, - "upper": 44583.7194942183, - }, - Object { - "anomaly_score": 0, - "lower": 846.9251200783423, - "upper": 45027.0923125673, - }, - Object { - "anomaly_score": 0.1775235302080928, - "lower": 839.9462033017412, - "upper": 46355.1414826366, - }, - Object { - "anomaly_score": 0, - "lower": 740.8424736560071, - "upper": 46997.18507921725, - }, - Object { - "anomaly_score": 0, - "lower": 675.2681661332581, - "upper": 47730.52441880603, - }, - Object { - "anomaly_score": 0, - "lower": 672.90202453507, - "upper": 48709.29810572524, - }, - Object { - "anomaly_score": 0, - "lower": 676.0944399455826, - "upper": 49406.64628717409, - }, - Object { - "anomaly_score": 0, - "lower": 682.4396257998045, - "upper": 73477.3874808886, - }, - Object { - "anomaly_score": 0, - "lower": 686.44341250381, - "upper": 73487.82525090317, - }, - Object { - "anomaly_score": 0, - "lower": 690.5371630779586, - "upper": 72962.57745081023, - }, - Object { - "anomaly_score": 0, - "lower": 695.8034104561633, - "upper": 72489.77380542927, - }, - Object { - "anomaly_score": 0, - "lower": 707.6839448592744, - "upper": 72463.76348179985, - }, - Object { - "anomaly_score": 0.18086821490763677, - "lower": 781.8674002616508, - "upper": 72996.2561390666, - }, - Object { - "anomaly_score": 0, - "lower": 846.540373740061, - "upper": 73169.30855560771, - }, - Object { - "anomaly_score": 0, - "lower": 860.5368537637945, - "upper": 73491.08437587181, - }, - Object { - "anomaly_score": 0, - "lower": 863.0293573898325, - "upper": 72389.78456634001, - }, - Object { - "anomaly_score": 0, - "lower": 863.4144235290587, - "upper": 72311.41927730369, - }, - Object { - "anomaly_score": 0, - "lower": 863.6781514985616, - "upper": 71383.41956191002, - }, - Object { - "anomaly_score": 0, - "lower": 863.4492510434609, - "upper": 74565.86466696904, - }, - Object { - "anomaly_score": 0, - "lower": 863.1958870174615, - "upper": 71304.14035324028, - }, - Object { - "anomaly_score": 0, - "lower": 862.6161500045084, - "upper": 72434.51561823535, - }, - Object { - "anomaly_score": 0, - "lower": 861.9526316405551, - "upper": 71664.49530601672, - }, - Object { - "anomaly_score": 0, - "lower": 861.1638627191994, - "upper": 71264.41362778837, - }, - Object { - "anomaly_score": 0, - "lower": 860.1741427701811, - "upper": 49087.805718943775, - }, - Object { - "anomaly_score": 0, - "lower": 862.4069845546885, - "upper": 49089.84051479006, - }, - Object { - "anomaly_score": 2.718289217634223, - "lower": 862.7834836635291, - "upper": 51834.13246654848, - }, - Object { - "anomaly_score": 0, - "lower": 863.5914163409548, - "upper": 51136.66870946708, - }, - Object { - "anomaly_score": 0, - "lower": 865.9550918866486, - "upper": 50968.889501405334, - }, - Object { - "anomaly_score": 0, - "lower": 866.5727896346234, - "upper": 51039.136906324355, - }, - Object { - "anomaly_score": 0, - "lower": 866.4824432593966, - "upper": 50450.44063039239, - }, - Object { - "anomaly_score": 0, - "lower": 869.2106974966512, - "upper": 49883.2079974308, - }, - Object { - "anomaly_score": 0, - "lower": 869.7908032042425, - "upper": 50019.796552072105, - }, - Object { - "anomaly_score": 0, - "lower": 872.0969808877924, - "upper": 50352.19806206938, - }, - Object { - "anomaly_score": 0, - "lower": 873.8327021716271, - "upper": 49893.959882267525, - }, - Object { - "anomaly_score": 0, - "lower": 875.6449156690691, - "upper": 49882.868445094966, - }, - Object { - "anomaly_score": 0, - "lower": 874.6294655070553, - "upper": 49766.53895122279, - }, - Object { - "anomaly_score": 0, - "lower": 878.2077083935897, - "upper": 49424.25380462067, - }, - Object { - "anomaly_score": 0, - "lower": 879.6702185935983, - "upper": 50079.967231416216, - }, - Object { - "anomaly_score": 0, - "lower": 880.9475908626134, - "upper": 49447.853072406695, - }, - Object { - "anomaly_score": 0, - "lower": 883.2355577302953, - "upper": 49628.237099331986, - }, - Object { - "anomaly_score": 0, - "lower": 885.0345875232065, - "upper": 49121.655177004985, - }, - Object { - "anomaly_score": 0, - "lower": 886.8375619687324, - "upper": 49439.75445560749, - }, - Object { - "anomaly_score": 0, - "lower": 888.2875318407426, - "upper": 49095.91031920496, - }, - Object { - "anomaly_score": 0, - "lower": 887.4807424937617, - "upper": 48584.97256737151, - }, - Object { - "anomaly_score": 0, - "lower": 885.3782512926099, - "upper": 48401.4014885278, - }, - Object { - "anomaly_score": 0, - "lower": 883.9626695681782, - "upper": 48303.662251777845, - }, - Object { - "anomaly_score": 0, - "lower": 881.5723811019918, - "upper": 48079.01124458592, - }, - Object { - "anomaly_score": 66.42568, - "lower": 0, - "upper": 58715.507088231585, - }, - Object { - "anomaly_score": 0, - "lower": 0, - "upper": 49868.15796918666, - }, - Object { - "anomaly_score": 0.060750193569274885, - "lower": 2003.2599232283408, - "upper": 50310.902258087066, - }, - Object { - "anomaly_score": 0.2831448638843196, - "lower": 1346.2241502014724, - "upper": 51642.47679276076, - }, - ], - }, - "p95": Array [ - 80738.78571428556, - 77058.03529411761, - 77892.20721980717, - 77085.86687499998, - 80048.3462981744, - 84089.21370223971, - 84880.90143416924, - 84554.8884781166, - 81839.39583333326, - 85993.55410163336, - 85001.44588628765, - 86980.16445312503, - 84961.8710743802, - 88906.54601889332, - 90198.34708994703, - 135627.71242424246, - 167037.1993837535, - 128293.12184873945, - 130653.54236263742, - 131630.8902645502, - 133581.33541666638, - 132697.92762266204, - 140003.6918918918, - 138149.5673529411, - 121872.37504835591, - 116378.03873517792, - 131545.40999999995, - 133111.25804878055, - 144821.9855278593, - 134737.3997727272, - 141206.57726666646, - 137731.8994082841, - 141476.23189033198, - 149636.31340909077, - 151934.55000000002, - 82198.17857142858, - 85946.43199999983, - 78617.66249999996, - 79606.48333333322, - 76297.93999999986, - 80742.63333333324, - 81291.45969696966, - 73467.02500000004, - 69177.66999999993, - 71956.06111111109, - 68480.91142857139, - 68957.0999999999, - 67489.50416666668, - 71556.91249999998, - 72157.65128205132, - 76124.5625, - 141709.34661835746, - 132371.48641975303, - 186783.51503759398, - 99540.17819499348, - 95982.62454212455, - 89559.3525925925, - 95769.83153735634, - 94063.90833755062, - 96399.67269119772, - 96436.42520161276, - 91860.16988095238, - 105989.8333333334, - 97937.60342555979, - 98967.2249999999, - 97561.02469135808, - 102557.78813357186, - 100137.87578595306, - 98412.97120445351, - 101607.8328012912, - 92000.51368421057, - 78027.29473684198, - 80762.078801789, - 81160.83425925927, - 84215.58945578222, - 194188.21428571426, - 172616.2293896504, - 182653.81858220184, - 194970.75667682925, - ], - "p99": Array [ - 293257.27333333343, - 290195.8800000004, - 278548.1649999994, - 290701.8973333341, - 286839.5897777779, - 287979.5149999999, - 300107.5009999992, - 294402.2179999999, - 289849.459333332, - 296942.86299999955, - 292048.20571428596, - 299308.7371666667, - 292151.2377777781, - 302274.4192592592, - 299457.1612121209, - 350398.59259259375, - 421204.23333333334, - 368166.68976190523, - 367193.6128571426, - 375658.10190476174, - 368152.03822222137, - 365705.8319999995, - 380075.48533333326, - 375697.1923809518, - 351080.94111111073, - 339294.12799999997, - 378902.90649999987, - 384483.3233333327, - 394692.25000000105, - 403362.50399999996, - 396559.0274999993, - 371815.8320000008, - 405477.6133333326, - 413542.18133333366, - 424399.340000001, - 303815.9000000001, - 306305.0800000006, - 297521.94999999984, - 317938.0900000003, - 312262.3000000003, - 318428.8700000002, - 295421.4099999999, - 293067.86000000004, - 264935.71999999933, - 282795.0400000003, - 285390.8400000001, - 290402.24, - 293655.53, - 292723.56999999995, - 301051.32000000105, - 291322.0499999998, - 379855.2444444447, - 371175.2592000001, - 498378.4238888898, - 331118.6599999997, - 328101.3999999988, - 313951.54249999986, - 323340.5274074075, - 315055.5047619052, - 330070.03599999985, - 320531.54416666675, - 315137.16628571344, - 337251.4042424246, - 327054.9243636365, - 327653.0000000006, - 324505.1399999999, - 338040.3999999998, - 328600.5173333335, - 334060.93628571345, - 328569.4964999998, - 320227.32399999973, - 292019.2899999998, - 297757.72666666657, - 308034.4466666669, - 301128.4895238093, - 447266.9, - 409147.332500001, - 423121.9773333328, - 473485.4199999998, - ], - }, - "total_hits": 1297673, - "tpm_buckets": Array [ - Object { - "avg": 78.106329113924, - "key": "HTTP 2xx", - "values": Array [ - 90.5, - 91.5, - 91.7, - 93.3, - 92, - 91.3, - 91, - 90.5, - 92.8, - 91.5, - 91.5, - 92, - 92.6, - 91.2, - 90.3, - 84.1, - 89.9, - 91.8, - 90.1, - 91.4, - 91.7, - 92.2, - 91.8, - 89.8, - 91.8, - 91.9, - 90.6, - 92.6, - 90, - 92.1, - 90.7, - 92, - 91.9, - 91.6, - 91.1, - 25.2, - 25.3, - 25.4, - 25.5, - 26, - 26, - 25.1, - 25.6, - 25.2, - 25.6, - 25.6, - 25, - 25.6, - 25.5, - 25.5, - 25.6, - 90.3, - 93.5, - 90.5, - 91.6, - 91.3, - 94.5, - 90.9, - 92.5, - 92.8, - 91.7, - 92.2, - 92.7, - 90.9, - 92.5, - 91.7, - 91.2, - 91.5, - 93.1, - 92.2, - 93.4, - 93.7, - 92.5, - 92.9, - 92.1, - 84, - 91.3, - 91.5, - 90.9, - ], - }, - Object { - "avg": 0.46835443037974683, - "key": "HTTP 3xx", - "values": Array [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 22.5, - 2.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 12, - 0, - 0, - 0, - ], - }, - Object { - "avg": 5.68354430379747, - "key": "HTTP 4xx", - "values": Array [ - 6.7, - 6.7, - 6.5, - 6.9, - 6.6, - 7.1, - 6.9, - 6.5, - 6.9, - 6.8, - 6.8, - 6.7, - 6.9, - 6.8, - 6.6, - 6.3, - 6.9, - 6.9, - 6.5, - 6.8, - 6.7, - 6.6, - 6.9, - 6.6, - 6.8, - 6.7, - 6.6, - 6.8, - 6.5, - 6.8, - 7, - 6.9, - 6.5, - 7, - 6.4, - 1.6, - 1.3, - 1.5, - 1.6, - 1.6, - 1.7, - 1.5, - 1.4, - 1.6, - 1.4, - 1.6, - 1.4, - 1.7, - 1.5, - 1.6, - 1.5, - 6.5, - 7.1, - 6.5, - 6.4, - 6.8, - 6.8, - 6.6, - 6.4, - 6.7, - 6.7, - 7.1, - 6.7, - 6.6, - 6.5, - 6.5, - 7.1, - 6.8, - 7, - 6.7, - 6.7, - 7, - 6.8, - 7, - 7.1, - 6.6, - 6.8, - 6.7, - 6.7, - ], - }, - Object { - "avg": 5.689873417721517, - "key": "HTTP 5xx", - "values": Array [ - 6.7, - 6.6, - 6.8, - 6.9, - 7.1, - 6.8, - 6.8, - 6.9, - 6.9, - 6.4, - 6.8, - 6.6, - 6.9, - 6.7, - 6.6, - 6.1, - 6.5, - 6.9, - 6.7, - 6.7, - 7.2, - 6.9, - 6.8, - 6.4, - 6.9, - 6.5, - 6.9, - 7, - 6.6, - 6.6, - 6.8, - 7.1, - 6.5, - 6.7, - 6.9, - 1.6, - 1.7, - 1.6, - 1.7, - 1.8, - 1.5, - 1.7, - 1.5, - 1.6, - 1.5, - 1.6, - 1.3, - 1.6, - 1.4, - 1.5, - 1.6, - 6.7, - 7, - 6.3, - 6.9, - 6.8, - 6.9, - 6.7, - 6.7, - 6.5, - 6.7, - 6.7, - 6.5, - 6.6, - 6.9, - 6.9, - 7.1, - 6.7, - 6.5, - 6.8, - 6.9, - 6.8, - 6.9, - 6.8, - 6.8, - 6, - 6.9, - 6.5, - 6.6, - ], - }, - Object { - "avg": NaN, - "key": "A Custom Bucket (that should be last)", - "values": Array [], - }, - ], -} -`; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/__test__/get_timeseries_data.test.js b/x-pack/plugins/apm/server/lib/transactions/charts/__test__/get_timeseries_data.test.js deleted file mode 100644 index 36ac9a0aff72e..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/__test__/get_timeseries_data.test.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import _ from 'lodash'; -import { getTimeseriesData } from '../get_timeseries_data'; -import timeseriesResponse from './timeseries_response.json'; -import responseTimeAnomalyResponse from './response_time_anomaly_response.json'; - -describe('get_timeseries_data', () => { - let res; - let clientSpy; - beforeEach(async () => { - clientSpy = jest - .fn() - .mockResolvedValueOnce(timeseriesResponse) - .mockResolvedValueOnce(responseTimeAnomalyResponse); - - res = await getTimeseriesData({ - serviceName: 'myServiceName', - transactionType: 'myTransactionType', - transactionName: null, - setup: { - start: 1528113600000, - end: 1528977600000, - client: clientSpy, - config: { - get: () => 'myIndex' - } - } - }); - }); - - it('should call client with correct query', () => { - expect(clientSpy.mock.calls).toMatchSnapshot(); - }); - - it('should not contain first and last bucket', () => { - const mockDates = timeseriesResponse.aggregations.transaction_results.buckets[0].timeseries.buckets.map( - bucket => bucket.key - ); - - expect(res.dates).not.toContain(_.first(mockDates)); - expect(res.dates).not.toContain(_.last(mockDates)); - expect(res.tpm_buckets[0].values).toHaveLength(res.dates.length); - }); - - it('should have correct order', () => { - expect(res.tpm_buckets.map(bucket => bucket.key)).toEqual([ - 'HTTP 2xx', - 'HTTP 3xx', - 'HTTP 4xx', - 'HTTP 5xx', - 'A Custom Bucket (that should be last)' - ]); - }); - - it('should match snapshot', () => { - expect(res).toMatchSnapshot(); - }); -}); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/__test__/response_time_anomaly_response.json b/x-pack/plugins/apm/server/lib/transactions/charts/__test__/response_time_anomaly_response.json deleted file mode 100644 index 8f022a7778e8d..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/__test__/response_time_anomaly_response.json +++ /dev/null @@ -1,1175 +0,0 @@ -{ - "took": 14, - "timed_out": false, - "_shards": { - "total": 5, - "successful": 5, - "skipped": 0, - "failed": 0 - }, - "hits": { - "total": 4117, - "max_score": 0, - "hits": [] - }, - "aggregations": { - "ml_avg_response_times": { - "buckets": [ - { - "key_as_string": "2018-06-04T12:00:00.000Z", - "key": 1528113600000, - "doc_count": 60, - "anomaly_score": { - "value": 0.07062823 - }, - "upper": { - "value": 26781.294783193 - }, - "lower": { - "value": 734.6120832292385 - } - }, - { - "key_as_string": "2018-06-04T15:00:00.000Z", - "key": 1528124400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 27505.95012649385 - }, - "lower": { - "value": 737.7398559597923 - } - }, - { - "key_as_string": "2018-06-04T18:00:00.000Z", - "key": 1528135200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 27831.385094457328 - }, - "lower": { - "value": 740.6510789069575 - } - }, - { - "key_as_string": "2018-06-04T21:00:00.000Z", - "key": 1528146000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 28113.842130309873 - }, - "lower": { - "value": 743.0092006506535 - } - }, - { - "key_as_string": "2018-06-05T00:00:00.000Z", - "key": 1528156800000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 28166.937431054437 - }, - "lower": { - "value": 745.266369017907 - } - }, - { - "key_as_string": "2018-06-05T03:00:00.000Z", - "key": 1528167600000, - "doc_count": 50, - "anomaly_score": { - "value": 0.0214167 - }, - "upper": { - "value": 28506.23990430994 - }, - "lower": { - "value": 747.3207728528188 - } - }, - { - "key_as_string": "2018-06-05T06:00:00.000Z", - "key": 1528178400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 29019.425285291298 - }, - "lower": { - "value": 749.6894207909651 - } - }, - { - "key_as_string": "2018-06-05T09:00:00.000Z", - "key": 1528189200000, - "doc_count": 51, - "anomaly_score": { - "value": 0.05939392 - }, - "upper": { - "value": 29293.392326541318 - }, - "lower": { - "value": 752.7726473096143 - } - }, - { - "key_as_string": "2018-06-05T12:00:00.000Z", - "key": 1528200000000, - "doc_count": 50, - "anomaly_score": { - "value": 0.01836784 - }, - "upper": { - "value": 29812.56398272085 - }, - "lower": { - "value": 754.7407389918743 - } - }, - { - "key_as_string": "2018-06-05T15:00:00.000Z", - "key": 1528210800000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 30060.955415439636 - }, - "lower": { - "value": 757.2268079827784 - } - }, - { - "key_as_string": "2018-06-05T18:00:00.000Z", - "key": 1528221600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 30376.319798106222 - }, - "lower": { - "value": 758.3112520555287 - } - }, - { - "key_as_string": "2018-06-05T21:00:00.000Z", - "key": 1528232400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 30627.243996529527 - }, - "lower": { - "value": 761.9827340264112 - } - }, - { - "key_as_string": "2018-06-06T00:00:00.000Z", - "key": 1528243200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 31035.75952712361 - }, - "lower": { - "value": 771.7209606007517 - } - }, - { - "key_as_string": "2018-06-06T03:00:00.000Z", - "key": 1528254000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 31062.244462967443 - }, - "lower": { - "value": 822.9174906119024 - } - }, - { - "key_as_string": "2018-06-06T06:00:00.000Z", - "key": 1528264800000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 31463.705363442183 - }, - "lower": { - "value": 867.1132870297309 - } - }, - { - "key_as_string": "2018-06-06T09:00:00.000Z", - "key": 1528275600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 31743.78493690837 - }, - "lower": { - "value": 871.6217257693573 - } - }, - { - "key_as_string": "2018-06-06T12:00:00.000Z", - "key": 1528286400000, - "doc_count": 86, - "anomaly_score": { - "value": 93.09271062370188 - }, - "upper": { - "value": 42784.833235636936 - }, - "lower": { - "value": 630.1794765317344 - } - }, - { - "key_as_string": "2018-06-06T15:00:00.000Z", - "key": 1528297200000, - "doc_count": 94, - "anomaly_score": { - "value": 94.91969 - }, - "upper": { - "value": 34441.21907642463 - }, - "lower": { - "value": 871.0283056454996 - } - }, - { - "key_as_string": "2018-06-06T18:00:00.000Z", - "key": 1528308000000, - "doc_count": 76, - "anomaly_score": { - "value": 0.737564554333639 - }, - "upper": { - "value": 35467.552283525925 - }, - "lower": { - "value": 872.694053998953 - } - }, - { - "key_as_string": "2018-06-06T21:00:00.000Z", - "key": 1528318800000, - "doc_count": 62, - "anomaly_score": { - "value": 0.2233028643272195 - }, - "upper": { - "value": 36793.04873774251 - }, - "lower": { - "value": 872.8967719351887 - } - }, - { - "key_as_string": "2018-06-07T00:00:00.000Z", - "key": 1528329600000, - "doc_count": 56, - "anomaly_score": { - "value": 4.367981 - }, - "upper": { - "value": 37663.180967734144 - }, - "lower": { - "value": 873.2094351335686 - } - }, - { - "key_as_string": "2018-06-07T03:00:00.000Z", - "key": 1528340400000, - "doc_count": 74, - "anomaly_score": { - "value": 10.94823 - }, - "upper": { - "value": 38704.9736025016 - }, - "lower": { - "value": 872.096335158222 - } - }, - { - "key_as_string": "2018-06-07T06:00:00.000Z", - "key": 1528351200000, - "doc_count": 50, - "anomaly_score": { - "value": 0.025502508470513552 - }, - "upper": { - "value": 39411.4696425657 - }, - "lower": { - "value": 870.7141079237686 - } - }, - { - "key_as_string": "2018-06-07T09:00:00.000Z", - "key": 1528362000000, - "doc_count": 52, - "anomaly_score": { - "value": 0.04643894365231562 - }, - "upper": { - "value": 40436.89001900413 - }, - "lower": { - "value": 865.6904233415615 - } - }, - { - "key_as_string": "2018-06-07T12:00:00.000Z", - "key": 1528372800000, - "doc_count": 52, - "anomaly_score": { - "value": 0.08232853094836577 - }, - "upper": { - "value": 41583.671803791396 - }, - "lower": { - "value": 864.5587212551438 - } - }, - { - "key_as_string": "2018-06-07T15:00:00.000Z", - "key": 1528383600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 41918.88300390927 - }, - "lower": { - "value": 862.0456649399898 - } - }, - { - "key_as_string": "2018-06-07T18:00:00.000Z", - "key": 1528394400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 42346.34733913561 - }, - "lower": { - "value": 862.6952960489333 - } - }, - { - "key_as_string": "2018-06-07T21:00:00.000Z", - "key": 1528405200000, - "doc_count": 50, - "anomaly_score": { - "value": 0.09328928850624264 - }, - "upper": { - "value": 43503.30873034762 - }, - "lower": { - "value": 859.02865711764 - } - }, - { - "key_as_string": "2018-06-08T00:00:00.000Z", - "key": 1528416000000, - "doc_count": 50, - "anomaly_score": { - "value": 0.01490678070537287 - }, - "upper": { - "value": 43582.32622523151 - }, - "lower": { - "value": 853.1249075544679 - } - }, - { - "key_as_string": "2018-06-08T03:00:00.000Z", - "key": 1528426800000, - "doc_count": 50, - "anomaly_score": { - "value": 0.025631694904640304 - }, - "upper": { - "value": 44583.7194942183 - }, - "lower": { - "value": 850.0412997919607 - } - }, - { - "key_as_string": "2018-06-08T06:00:00.000Z", - "key": 1528437600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 45027.0923125673 - }, - "lower": { - "value": 846.9251200783423 - } - }, - { - "key_as_string": "2018-06-08T09:00:00.000Z", - "key": 1528448400000, - "doc_count": 52, - "anomaly_score": { - "value": 0.1775235302080928 - }, - "upper": { - "value": 46355.1414826366 - }, - "lower": { - "value": 839.9462033017412 - } - }, - { - "key_as_string": "2018-06-08T12:00:00.000Z", - "key": 1528459200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 46997.18507921725 - }, - "lower": { - "value": 740.8424736560071 - } - }, - { - "key_as_string": "2018-06-08T15:00:00.000Z", - "key": 1528470000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 47730.52441880603 - }, - "lower": { - "value": 675.2681661332581 - } - }, - { - "key_as_string": "2018-06-08T18:00:00.000Z", - "key": 1528480800000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 48709.29810572524 - }, - "lower": { - "value": 672.90202453507 - } - }, - { - "key_as_string": "2018-06-08T21:00:00.000Z", - "key": 1528491600000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49406.64628717409 - }, - "lower": { - "value": 676.0944399455826 - } - }, - { - "key_as_string": "2018-06-09T00:00:00.000Z", - "key": 1528502400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 73477.3874808886 - }, - "lower": { - "value": 682.4396257998045 - } - }, - { - "key_as_string": "2018-06-09T03:00:00.000Z", - "key": 1528513200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 73487.82525090317 - }, - "lower": { - "value": 686.44341250381 - } - }, - { - "key_as_string": "2018-06-09T06:00:00.000Z", - "key": 1528524000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 72962.57745081023 - }, - "lower": { - "value": 690.5371630779586 - } - }, - { - "key_as_string": "2018-06-09T09:00:00.000Z", - "key": 1528534800000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 72489.77380542927 - }, - "lower": { - "value": 695.8034104561633 - } - }, - { - "key_as_string": "2018-06-09T12:00:00.000Z", - "key": 1528545600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 72463.76348179985 - }, - "lower": { - "value": 707.6839448592744 - } - }, - { - "key_as_string": "2018-06-09T15:00:00.000Z", - "key": 1528556400000, - "doc_count": 50, - "anomaly_score": { - "value": 0.18086821490763677 - }, - "upper": { - "value": 72996.2561390666 - }, - "lower": { - "value": 781.8674002616508 - } - }, - { - "key_as_string": "2018-06-09T18:00:00.000Z", - "key": 1528567200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 73169.30855560771 - }, - "lower": { - "value": 846.540373740061 - } - }, - { - "key_as_string": "2018-06-09T21:00:00.000Z", - "key": 1528578000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 73491.08437587181 - }, - "lower": { - "value": 860.5368537637945 - } - }, - { - "key_as_string": "2018-06-10T00:00:00.000Z", - "key": 1528588800000, - "doc_count": 49, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 72389.78456634001 - }, - "lower": { - "value": 863.0293573898325 - } - }, - { - "key_as_string": "2018-06-10T03:00:00.000Z", - "key": 1528599600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 72311.41927730369 - }, - "lower": { - "value": 863.4144235290587 - } - }, - { - "key_as_string": "2018-06-10T06:00:00.000Z", - "key": 1528610400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 71383.41956191002 - }, - "lower": { - "value": 863.6781514985616 - } - }, - { - "key_as_string": "2018-06-10T09:00:00.000Z", - "key": 1528621200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 74565.86466696904 - }, - "lower": { - "value": 863.4492510434609 - } - }, - { - "key_as_string": "2018-06-10T12:00:00.000Z", - "key": 1528632000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 71304.14035324028 - }, - "lower": { - "value": 863.1958870174615 - } - }, - { - "key_as_string": "2018-06-10T15:00:00.000Z", - "key": 1528642800000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 72434.51561823535 - }, - "lower": { - "value": 862.6161500045084 - } - }, - { - "key_as_string": "2018-06-10T18:00:00.000Z", - "key": 1528653600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 71664.49530601672 - }, - "lower": { - "value": 861.9526316405551 - } - }, - { - "key_as_string": "2018-06-10T21:00:00.000Z", - "key": 1528664400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 71264.41362778837 - }, - "lower": { - "value": 861.1638627191994 - } - }, - { - "key_as_string": "2018-06-11T00:00:00.000Z", - "key": 1528675200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49087.805718943775 - }, - "lower": { - "value": 860.1741427701811 - } - }, - { - "key_as_string": "2018-06-11T03:00:00.000Z", - "key": 1528686000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49089.84051479006 - }, - "lower": { - "value": 862.4069845546885 - } - }, - { - "key_as_string": "2018-06-11T06:00:00.000Z", - "key": 1528696800000, - "doc_count": 60, - "anomaly_score": { - "value": 2.718289217634223 - }, - "upper": { - "value": 51834.13246654848 - }, - "lower": { - "value": 862.7834836635291 - } - }, - { - "key_as_string": "2018-06-11T09:00:00.000Z", - "key": 1528707600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 51136.66870946708 - }, - "lower": { - "value": 863.5914163409548 - } - }, - { - "key_as_string": "2018-06-11T12:00:00.000Z", - "key": 1528718400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 50968.889501405334 - }, - "lower": { - "value": 865.9550918866486 - } - }, - { - "key_as_string": "2018-06-11T15:00:00.000Z", - "key": 1528729200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 51039.136906324355 - }, - "lower": { - "value": 866.5727896346234 - } - }, - { - "key_as_string": "2018-06-11T18:00:00.000Z", - "key": 1528740000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 50450.44063039239 - }, - "lower": { - "value": 866.4824432593966 - } - }, - { - "key_as_string": "2018-06-11T21:00:00.000Z", - "key": 1528750800000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49883.2079974308 - }, - "lower": { - "value": 869.2106974966512 - } - }, - { - "key_as_string": "2018-06-12T00:00:00.000Z", - "key": 1528761600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 50019.796552072105 - }, - "lower": { - "value": 869.7908032042425 - } - }, - { - "key_as_string": "2018-06-12T03:00:00.000Z", - "key": 1528772400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 50352.19806206938 - }, - "lower": { - "value": 872.0969808877924 - } - }, - { - "key_as_string": "2018-06-12T06:00:00.000Z", - "key": 1528783200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49893.959882267525 - }, - "lower": { - "value": 873.8327021716271 - } - }, - { - "key_as_string": "2018-06-12T09:00:00.000Z", - "key": 1528794000000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49882.868445094966 - }, - "lower": { - "value": 875.6449156690691 - } - }, - { - "key_as_string": "2018-06-12T12:00:00.000Z", - "key": 1528804800000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49766.53895122279 - }, - "lower": { - "value": 874.6294655070553 - } - }, - { - "key_as_string": "2018-06-12T15:00:00.000Z", - "key": 1528815600000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49424.25380462067 - }, - "lower": { - "value": 878.2077083935897 - } - }, - { - "key_as_string": "2018-06-12T18:00:00.000Z", - "key": 1528826400000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 50079.967231416216 - }, - "lower": { - "value": 879.6702185935983 - } - }, - { - "key_as_string": "2018-06-12T21:00:00.000Z", - "key": 1528837200000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49447.853072406695 - }, - "lower": { - "value": 880.9475908626134 - } - }, - { - "key_as_string": "2018-06-13T00:00:00.000Z", - "key": 1528848000000, - "doc_count": 51, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49628.237099331986 - }, - "lower": { - "value": 883.2355577302953 - } - }, - { - "key_as_string": "2018-06-13T03:00:00.000Z", - "key": 1528858800000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49121.655177004985 - }, - "lower": { - "value": 885.0345875232065 - } - }, - { - "key_as_string": "2018-06-13T06:00:00.000Z", - "key": 1528869600000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49439.75445560749 - }, - "lower": { - "value": 886.8375619687324 - } - }, - { - "key_as_string": "2018-06-13T09:00:00.000Z", - "key": 1528880400000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49095.91031920496 - }, - "lower": { - "value": 888.2875318407426 - } - }, - { - "key_as_string": "2018-06-13T12:00:00.000Z", - "key": 1528891200000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 48584.97256737151 - }, - "lower": { - "value": 887.4807424937617 - } - }, - { - "key_as_string": "2018-06-13T15:00:00.000Z", - "key": 1528902000000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 48401.4014885278 - }, - "lower": { - "value": 885.3782512926099 - } - }, - { - "key_as_string": "2018-06-13T18:00:00.000Z", - "key": 1528912800000, - "doc_count": 50, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 48303.662251777845 - }, - "lower": { - "value": 883.9626695681782 - } - }, - { - "key_as_string": "2018-06-13T21:00:00.000Z", - "key": 1528923600000, - "doc_count": 48, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 48079.01124458592 - }, - "lower": { - "value": 881.5723811019918 - } - }, - { - "key_as_string": "2018-06-14T00:00:00.000Z", - "key": 1528934400000, - "doc_count": 60, - "anomaly_score": { - "value": 66.42568 - }, - "upper": { - "value": 58715.507088231585 - }, - "lower": { - "value": 0 - } - }, - { - "key_as_string": "2018-06-14T03:00:00.000Z", - "key": 1528945200000, - "doc_count": 55, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 49868.15796918666 - }, - "lower": { - "value": 0 - } - }, - { - "key_as_string": "2018-06-14T06:00:00.000Z", - "key": 1528956000000, - "doc_count": 53, - "anomaly_score": { - "value": 0.060750193569274885 - }, - "upper": { - "value": 50310.902258087066 - }, - "lower": { - "value": 2003.2599232283408 - } - }, - { - "key_as_string": "2018-06-14T09:00:00.000Z", - "key": 1528966800000, - "doc_count": 62, - "anomaly_score": { - "value": 0.2831448638843196 - }, - "upper": { - "value": 51642.47679276076 - }, - "lower": { - "value": 1346.2241502014724 - } - }, - { - "key_as_string": "2018-06-14T12:00:00.000Z", - "key": 1528977600000, - "doc_count": 4, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 50550.64218576831 - }, - "lower": { - "value": 1317.070500756407 - } - } - ] - }, - "top_hits": { - "hits": { - "total": 4117, - "max_score": null, - "hits": [ - { - "_index": ".ml-anomalies-shared", - "_type": "doc", - "_id": "opbeans-node-request-high_mean_response_time_model_plot_1528170300000_900_0_29791_0", - "_score": null, - "_source": { - "bucket_span": 900 - }, - "sort": [ - 900 - ] - } - ] - } - } - } -} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/__test__/timeseries_response.json b/x-pack/plugins/apm/server/lib/transactions/charts/__test__/timeseries_response.json deleted file mode 100644 index 38aa0237aebd6..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/__test__/timeseries_response.json +++ /dev/null @@ -1,2821 +0,0 @@ -{ - "took": 368, - "timed_out": false, - "_shards": { - "total": 90, - "successful": 90, - "skipped": 0, - "failed": 0 - }, - "hits": { - "total": 1297673, - "max_score": 0, - "hits": [] - }, - "aggregations": { - "transaction_results": { - "doc_count_error_upper_bound": 0, - "sum_other_doc_count": 0, - "buckets": [ - { - "key": "A Custom Bucket (that should be last)", - "doc_count": 0, - "timeseries": { "buckets": [] } - }, - { - "key": "HTTP 2xx", - "doc_count": 1127080, - "timeseries": { - "buckets": [ - { - "key_as_string": "2018-06-04T12:00:00.000Z", - "key": 1528113600000, - "doc_count": 16446 - }, - { - "key_as_string": "2018-06-04T15:00:00.000Z", - "key": 1528124400000, - "doc_count": 16292 - }, - { - "key_as_string": "2018-06-04T18:00:00.000Z", - "key": 1528135200000, - "doc_count": 16464 - }, - { - "key_as_string": "2018-06-04T21:00:00.000Z", - "key": 1528146000000, - "doc_count": 16497 - }, - { - "key_as_string": "2018-06-05T00:00:00.000Z", - "key": 1528156800000, - "doc_count": 16799 - }, - { - "key_as_string": "2018-06-05T03:00:00.000Z", - "key": 1528167600000, - "doc_count": 16561 - }, - { - "key_as_string": "2018-06-05T06:00:00.000Z", - "key": 1528178400000, - "doc_count": 16431 - }, - { - "key_as_string": "2018-06-05T09:00:00.000Z", - "key": 1528189200000, - "doc_count": 16383 - }, - { - "key_as_string": "2018-06-05T12:00:00.000Z", - "key": 1528200000000, - "doc_count": 16295 - }, - { - "key_as_string": "2018-06-05T15:00:00.000Z", - "key": 1528210800000, - "doc_count": 16702 - }, - { - "key_as_string": "2018-06-05T18:00:00.000Z", - "key": 1528221600000, - "doc_count": 16469 - }, - { - "key_as_string": "2018-06-05T21:00:00.000Z", - "key": 1528232400000, - "doc_count": 16466 - }, - { - "key_as_string": "2018-06-06T00:00:00.000Z", - "key": 1528243200000, - "doc_count": 16551 - }, - { - "key_as_string": "2018-06-06T03:00:00.000Z", - "key": 1528254000000, - "doc_count": 16675 - }, - { - "key_as_string": "2018-06-06T06:00:00.000Z", - "key": 1528264800000, - "doc_count": 16410 - }, - { - "key_as_string": "2018-06-06T09:00:00.000Z", - "key": 1528275600000, - "doc_count": 16247 - }, - { - "key_as_string": "2018-06-06T12:00:00.000Z", - "key": 1528286400000, - "doc_count": 15145 - }, - { - "key_as_string": "2018-06-06T15:00:00.000Z", - "key": 1528297200000, - "doc_count": 16178 - }, - { - "key_as_string": "2018-06-06T18:00:00.000Z", - "key": 1528308000000, - "doc_count": 16530 - }, - { - "key_as_string": "2018-06-06T21:00:00.000Z", - "key": 1528318800000, - "doc_count": 16211 - }, - { - "key_as_string": "2018-06-07T00:00:00.000Z", - "key": 1528329600000, - "doc_count": 16453 - }, - { - "key_as_string": "2018-06-07T03:00:00.000Z", - "key": 1528340400000, - "doc_count": 16503 - }, - { - "key_as_string": "2018-06-07T06:00:00.000Z", - "key": 1528351200000, - "doc_count": 16604 - }, - { - "key_as_string": "2018-06-07T09:00:00.000Z", - "key": 1528362000000, - "doc_count": 16522 - }, - { - "key_as_string": "2018-06-07T12:00:00.000Z", - "key": 1528372800000, - "doc_count": 16164 - }, - { - "key_as_string": "2018-06-07T15:00:00.000Z", - "key": 1528383600000, - "doc_count": 16520 - }, - { - "key_as_string": "2018-06-07T18:00:00.000Z", - "key": 1528394400000, - "doc_count": 16534 - }, - { - "key_as_string": "2018-06-07T21:00:00.000Z", - "key": 1528405200000, - "doc_count": 16311 - }, - { - "key_as_string": "2018-06-08T00:00:00.000Z", - "key": 1528416000000, - "doc_count": 16670 - }, - { - "key_as_string": "2018-06-08T03:00:00.000Z", - "key": 1528426800000, - "doc_count": 16192 - }, - { - "key_as_string": "2018-06-08T06:00:00.000Z", - "key": 1528437600000, - "doc_count": 16579 - }, - { - "key_as_string": "2018-06-08T09:00:00.000Z", - "key": 1528448400000, - "doc_count": 16330 - }, - { - "key_as_string": "2018-06-08T12:00:00.000Z", - "key": 1528459200000, - "doc_count": 16565 - }, - { - "key_as_string": "2018-06-08T15:00:00.000Z", - "key": 1528470000000, - "doc_count": 16543 - }, - { - "key_as_string": "2018-06-08T18:00:00.000Z", - "key": 1528480800000, - "doc_count": 16492 - }, - { - "key_as_string": "2018-06-08T21:00:00.000Z", - "key": 1528491600000, - "doc_count": 16404 - }, - { - "key_as_string": "2018-06-09T00:00:00.000Z", - "key": 1528502400000, - "doc_count": 4528 - }, - { - "key_as_string": "2018-06-09T03:00:00.000Z", - "key": 1528513200000, - "doc_count": 4557 - }, - { - "key_as_string": "2018-06-09T06:00:00.000Z", - "key": 1528524000000, - "doc_count": 4566 - }, - { - "key_as_string": "2018-06-09T09:00:00.000Z", - "key": 1528534800000, - "doc_count": 4586 - }, - { - "key_as_string": "2018-06-09T12:00:00.000Z", - "key": 1528545600000, - "doc_count": 4672 - }, - { - "key_as_string": "2018-06-09T15:00:00.000Z", - "key": 1528556400000, - "doc_count": 4685 - }, - { - "key_as_string": "2018-06-09T18:00:00.000Z", - "key": 1528567200000, - "doc_count": 4521 - }, - { - "key_as_string": "2018-06-09T21:00:00.000Z", - "key": 1528578000000, - "doc_count": 4612 - }, - { - "key_as_string": "2018-06-10T00:00:00.000Z", - "key": 1528588800000, - "doc_count": 4535 - }, - { - "key_as_string": "2018-06-10T03:00:00.000Z", - "key": 1528599600000, - "doc_count": 4606 - }, - { - "key_as_string": "2018-06-10T06:00:00.000Z", - "key": 1528610400000, - "doc_count": 4614 - }, - { - "key_as_string": "2018-06-10T09:00:00.000Z", - "key": 1528621200000, - "doc_count": 4507 - }, - { - "key_as_string": "2018-06-10T12:00:00.000Z", - "key": 1528632000000, - "doc_count": 4611 - }, - { - "key_as_string": "2018-06-10T15:00:00.000Z", - "key": 1528642800000, - "doc_count": 4587 - }, - { - "key_as_string": "2018-06-10T18:00:00.000Z", - "key": 1528653600000, - "doc_count": 4582 - }, - { - "key_as_string": "2018-06-10T21:00:00.000Z", - "key": 1528664400000, - "doc_count": 4615 - }, - { - "key_as_string": "2018-06-11T00:00:00.000Z", - "key": 1528675200000, - "doc_count": 16251 - }, - { - "key_as_string": "2018-06-11T03:00:00.000Z", - "key": 1528686000000, - "doc_count": 16825 - }, - { - "key_as_string": "2018-06-11T06:00:00.000Z", - "key": 1528696800000, - "doc_count": 16288 - }, - { - "key_as_string": "2018-06-11T09:00:00.000Z", - "key": 1528707600000, - "doc_count": 16492 - }, - { - "key_as_string": "2018-06-11T12:00:00.000Z", - "key": 1528718400000, - "doc_count": 16434 - }, - { - "key_as_string": "2018-06-11T15:00:00.000Z", - "key": 1528729200000, - "doc_count": 17003 - }, - { - "key_as_string": "2018-06-11T18:00:00.000Z", - "key": 1528740000000, - "doc_count": 16364 - }, - { - "key_as_string": "2018-06-11T21:00:00.000Z", - "key": 1528750800000, - "doc_count": 16645 - }, - { - "key_as_string": "2018-06-12T00:00:00.000Z", - "key": 1528761600000, - "doc_count": 16695 - }, - { - "key_as_string": "2018-06-12T03:00:00.000Z", - "key": 1528772400000, - "doc_count": 16498 - }, - { - "key_as_string": "2018-06-12T06:00:00.000Z", - "key": 1528783200000, - "doc_count": 16588 - }, - { - "key_as_string": "2018-06-12T09:00:00.000Z", - "key": 1528794000000, - "doc_count": 16685 - }, - { - "key_as_string": "2018-06-12T12:00:00.000Z", - "key": 1528804800000, - "doc_count": 16361 - }, - { - "key_as_string": "2018-06-12T15:00:00.000Z", - "key": 1528815600000, - "doc_count": 16658 - }, - { - "key_as_string": "2018-06-12T18:00:00.000Z", - "key": 1528826400000, - "doc_count": 16507 - }, - { - "key_as_string": "2018-06-12T21:00:00.000Z", - "key": 1528837200000, - "doc_count": 16418 - }, - { - "key_as_string": "2018-06-13T00:00:00.000Z", - "key": 1528848000000, - "doc_count": 16477 - }, - { - "key_as_string": "2018-06-13T03:00:00.000Z", - "key": 1528858800000, - "doc_count": 16755 - }, - { - "key_as_string": "2018-06-13T06:00:00.000Z", - "key": 1528869600000, - "doc_count": 16594 - }, - { - "key_as_string": "2018-06-13T09:00:00.000Z", - "key": 1528880400000, - "doc_count": 16812 - }, - { - "key_as_string": "2018-06-13T12:00:00.000Z", - "key": 1528891200000, - "doc_count": 16863 - }, - { - "key_as_string": "2018-06-13T15:00:00.000Z", - "key": 1528902000000, - "doc_count": 16655 - }, - { - "key_as_string": "2018-06-13T18:00:00.000Z", - "key": 1528912800000, - "doc_count": 16723 - }, - { - "key_as_string": "2018-06-13T21:00:00.000Z", - "key": 1528923600000, - "doc_count": 16577 - }, - { - "key_as_string": "2018-06-14T00:00:00.000Z", - "key": 1528934400000, - "doc_count": 15125 - }, - { - "key_as_string": "2018-06-14T03:00:00.000Z", - "key": 1528945200000, - "doc_count": 16432 - }, - { - "key_as_string": "2018-06-14T06:00:00.000Z", - "key": 1528956000000, - "doc_count": 16464 - }, - { - "key_as_string": "2018-06-14T09:00:00.000Z", - "key": 1528966800000, - "doc_count": 16369 - }, - { - "key_as_string": "2018-06-14T12:00:00.000Z", - "key": 1528977600000, - "doc_count": 0 - } - ] - } - }, - { - "key": "HTTP 5xx", - "doc_count": 82036, - "timeseries": { - "buckets": [ - { - "key_as_string": "2018-06-04T12:00:00.000Z", - "key": 1528113600000, - "doc_count": 1209 - }, - { - "key_as_string": "2018-06-04T15:00:00.000Z", - "key": 1528124400000, - "doc_count": 1203 - }, - { - "key_as_string": "2018-06-04T18:00:00.000Z", - "key": 1528135200000, - "doc_count": 1196 - }, - { - "key_as_string": "2018-06-04T21:00:00.000Z", - "key": 1528146000000, - "doc_count": 1230 - }, - { - "key_as_string": "2018-06-05T00:00:00.000Z", - "key": 1528156800000, - "doc_count": 1233 - }, - { - "key_as_string": "2018-06-05T03:00:00.000Z", - "key": 1528167600000, - "doc_count": 1272 - }, - { - "key_as_string": "2018-06-05T06:00:00.000Z", - "key": 1528178400000, - "doc_count": 1218 - }, - { - "key_as_string": "2018-06-05T09:00:00.000Z", - "key": 1528189200000, - "doc_count": 1217 - }, - { - "key_as_string": "2018-06-05T12:00:00.000Z", - "key": 1528200000000, - "doc_count": 1235 - }, - { - "key_as_string": "2018-06-05T15:00:00.000Z", - "key": 1528210800000, - "doc_count": 1249 - }, - { - "key_as_string": "2018-06-05T18:00:00.000Z", - "key": 1528221600000, - "doc_count": 1158 - }, - { - "key_as_string": "2018-06-05T21:00:00.000Z", - "key": 1528232400000, - "doc_count": 1215 - }, - { - "key_as_string": "2018-06-06T00:00:00.000Z", - "key": 1528243200000, - "doc_count": 1191 - }, - { - "key_as_string": "2018-06-06T03:00:00.000Z", - "key": 1528254000000, - "doc_count": 1235 - }, - { - "key_as_string": "2018-06-06T06:00:00.000Z", - "key": 1528264800000, - "doc_count": 1212 - }, - { - "key_as_string": "2018-06-06T09:00:00.000Z", - "key": 1528275600000, - "doc_count": 1180 - }, - { - "key_as_string": "2018-06-06T12:00:00.000Z", - "key": 1528286400000, - "doc_count": 1091 - }, - { - "key_as_string": "2018-06-06T15:00:00.000Z", - "key": 1528297200000, - "doc_count": 1176 - }, - { - "key_as_string": "2018-06-06T18:00:00.000Z", - "key": 1528308000000, - "doc_count": 1243 - }, - { - "key_as_string": "2018-06-06T21:00:00.000Z", - "key": 1528318800000, - "doc_count": 1208 - }, - { - "key_as_string": "2018-06-07T00:00:00.000Z", - "key": 1528329600000, - "doc_count": 1202 - }, - { - "key_as_string": "2018-06-07T03:00:00.000Z", - "key": 1528340400000, - "doc_count": 1288 - }, - { - "key_as_string": "2018-06-07T06:00:00.000Z", - "key": 1528351200000, - "doc_count": 1241 - }, - { - "key_as_string": "2018-06-07T09:00:00.000Z", - "key": 1528362000000, - "doc_count": 1215 - }, - { - "key_as_string": "2018-06-07T12:00:00.000Z", - "key": 1528372800000, - "doc_count": 1152 - }, - { - "key_as_string": "2018-06-07T15:00:00.000Z", - "key": 1528383600000, - "doc_count": 1241 - }, - { - "key_as_string": "2018-06-07T18:00:00.000Z", - "key": 1528394400000, - "doc_count": 1177 - }, - { - "key_as_string": "2018-06-07T21:00:00.000Z", - "key": 1528405200000, - "doc_count": 1243 - }, - { - "key_as_string": "2018-06-08T00:00:00.000Z", - "key": 1528416000000, - "doc_count": 1255 - }, - { - "key_as_string": "2018-06-08T03:00:00.000Z", - "key": 1528426800000, - "doc_count": 1189 - }, - { - "key_as_string": "2018-06-08T06:00:00.000Z", - "key": 1528437600000, - "doc_count": 1183 - }, - { - "key_as_string": "2018-06-08T09:00:00.000Z", - "key": 1528448400000, - "doc_count": 1215 - }, - { - "key_as_string": "2018-06-08T12:00:00.000Z", - "key": 1528459200000, - "doc_count": 1282 - }, - { - "key_as_string": "2018-06-08T15:00:00.000Z", - "key": 1528470000000, - "doc_count": 1177 - }, - { - "key_as_string": "2018-06-08T18:00:00.000Z", - "key": 1528480800000, - "doc_count": 1199 - }, - { - "key_as_string": "2018-06-08T21:00:00.000Z", - "key": 1528491600000, - "doc_count": 1234 - }, - { - "key_as_string": "2018-06-09T00:00:00.000Z", - "key": 1528502400000, - "doc_count": 284 - }, - { - "key_as_string": "2018-06-09T03:00:00.000Z", - "key": 1528513200000, - "doc_count": 307 - }, - { - "key_as_string": "2018-06-09T06:00:00.000Z", - "key": 1528524000000, - "doc_count": 283 - }, - { - "key_as_string": "2018-06-09T09:00:00.000Z", - "key": 1528534800000, - "doc_count": 303 - }, - { - "key_as_string": "2018-06-09T12:00:00.000Z", - "key": 1528545600000, - "doc_count": 326 - }, - { - "key_as_string": "2018-06-09T15:00:00.000Z", - "key": 1528556400000, - "doc_count": 269 - }, - { - "key_as_string": "2018-06-09T18:00:00.000Z", - "key": 1528567200000, - "doc_count": 297 - }, - { - "key_as_string": "2018-06-09T21:00:00.000Z", - "key": 1528578000000, - "doc_count": 278 - }, - { - "key_as_string": "2018-06-10T00:00:00.000Z", - "key": 1528588800000, - "doc_count": 289 - }, - { - "key_as_string": "2018-06-10T03:00:00.000Z", - "key": 1528599600000, - "doc_count": 272 - }, - { - "key_as_string": "2018-06-10T06:00:00.000Z", - "key": 1528610400000, - "doc_count": 279 - }, - { - "key_as_string": "2018-06-10T09:00:00.000Z", - "key": 1528621200000, - "doc_count": 238 - }, - { - "key_as_string": "2018-06-10T12:00:00.000Z", - "key": 1528632000000, - "doc_count": 288 - }, - { - "key_as_string": "2018-06-10T15:00:00.000Z", - "key": 1528642800000, - "doc_count": 258 - }, - { - "key_as_string": "2018-06-10T18:00:00.000Z", - "key": 1528653600000, - "doc_count": 264 - }, - { - "key_as_string": "2018-06-10T21:00:00.000Z", - "key": 1528664400000, - "doc_count": 296 - }, - { - "key_as_string": "2018-06-11T00:00:00.000Z", - "key": 1528675200000, - "doc_count": 1213 - }, - { - "key_as_string": "2018-06-11T03:00:00.000Z", - "key": 1528686000000, - "doc_count": 1254 - }, - { - "key_as_string": "2018-06-11T06:00:00.000Z", - "key": 1528696800000, - "doc_count": 1135 - }, - { - "key_as_string": "2018-06-11T09:00:00.000Z", - "key": 1528707600000, - "doc_count": 1240 - }, - { - "key_as_string": "2018-06-11T12:00:00.000Z", - "key": 1528718400000, - "doc_count": 1215 - }, - { - "key_as_string": "2018-06-11T15:00:00.000Z", - "key": 1528729200000, - "doc_count": 1239 - }, - { - "key_as_string": "2018-06-11T18:00:00.000Z", - "key": 1528740000000, - "doc_count": 1209 - }, - { - "key_as_string": "2018-06-11T21:00:00.000Z", - "key": 1528750800000, - "doc_count": 1208 - }, - { - "key_as_string": "2018-06-12T00:00:00.000Z", - "key": 1528761600000, - "doc_count": 1176 - }, - { - "key_as_string": "2018-06-12T03:00:00.000Z", - "key": 1528772400000, - "doc_count": 1207 - }, - { - "key_as_string": "2018-06-12T06:00:00.000Z", - "key": 1528783200000, - "doc_count": 1198 - }, - { - "key_as_string": "2018-06-12T09:00:00.000Z", - "key": 1528794000000, - "doc_count": 1165 - }, - { - "key_as_string": "2018-06-12T12:00:00.000Z", - "key": 1528804800000, - "doc_count": 1188 - }, - { - "key_as_string": "2018-06-12T15:00:00.000Z", - "key": 1528815600000, - "doc_count": 1245 - }, - { - "key_as_string": "2018-06-12T18:00:00.000Z", - "key": 1528826400000, - "doc_count": 1238 - }, - { - "key_as_string": "2018-06-12T21:00:00.000Z", - "key": 1528837200000, - "doc_count": 1283 - }, - { - "key_as_string": "2018-06-13T00:00:00.000Z", - "key": 1528848000000, - "doc_count": 1198 - }, - { - "key_as_string": "2018-06-13T03:00:00.000Z", - "key": 1528858800000, - "doc_count": 1172 - }, - { - "key_as_string": "2018-06-13T06:00:00.000Z", - "key": 1528869600000, - "doc_count": 1229 - }, - { - "key_as_string": "2018-06-13T09:00:00.000Z", - "key": 1528880400000, - "doc_count": 1239 - }, - { - "key_as_string": "2018-06-13T12:00:00.000Z", - "key": 1528891200000, - "doc_count": 1231 - }, - { - "key_as_string": "2018-06-13T15:00:00.000Z", - "key": 1528902000000, - "doc_count": 1248 - }, - { - "key_as_string": "2018-06-13T18:00:00.000Z", - "key": 1528912800000, - "doc_count": 1220 - }, - { - "key_as_string": "2018-06-13T21:00:00.000Z", - "key": 1528923600000, - "doc_count": 1224 - }, - { - "key_as_string": "2018-06-14T00:00:00.000Z", - "key": 1528934400000, - "doc_count": 1088 - }, - { - "key_as_string": "2018-06-14T03:00:00.000Z", - "key": 1528945200000, - "doc_count": 1235 - }, - { - "key_as_string": "2018-06-14T06:00:00.000Z", - "key": 1528956000000, - "doc_count": 1161 - }, - { - "key_as_string": "2018-06-14T09:00:00.000Z", - "key": 1528966800000, - "doc_count": 1183 - }, - { - "key_as_string": "2018-06-14T12:00:00.000Z", - "key": 1528977600000, - "doc_count": 0 - } - ] - } - }, - { - "key": "HTTP 4xx", - "doc_count": 81907, - "timeseries": { - "buckets": [ - { - "key_as_string": "2018-06-04T12:00:00.000Z", - "key": 1528113600000, - "doc_count": 1186 - }, - { - "key_as_string": "2018-06-04T15:00:00.000Z", - "key": 1528124400000, - "doc_count": 1213 - }, - { - "key_as_string": "2018-06-04T18:00:00.000Z", - "key": 1528135200000, - "doc_count": 1205 - }, - { - "key_as_string": "2018-06-04T21:00:00.000Z", - "key": 1528146000000, - "doc_count": 1162 - }, - { - "key_as_string": "2018-06-05T00:00:00.000Z", - "key": 1528156800000, - "doc_count": 1238 - }, - { - "key_as_string": "2018-06-05T03:00:00.000Z", - "key": 1528167600000, - "doc_count": 1191 - }, - { - "key_as_string": "2018-06-05T06:00:00.000Z", - "key": 1528178400000, - "doc_count": 1274 - }, - { - "key_as_string": "2018-06-05T09:00:00.000Z", - "key": 1528189200000, - "doc_count": 1234 - }, - { - "key_as_string": "2018-06-05T12:00:00.000Z", - "key": 1528200000000, - "doc_count": 1164 - }, - { - "key_as_string": "2018-06-05T15:00:00.000Z", - "key": 1528210800000, - "doc_count": 1233 - }, - { - "key_as_string": "2018-06-05T18:00:00.000Z", - "key": 1528221600000, - "doc_count": 1223 - }, - { - "key_as_string": "2018-06-05T21:00:00.000Z", - "key": 1528232400000, - "doc_count": 1216 - }, - { - "key_as_string": "2018-06-06T00:00:00.000Z", - "key": 1528243200000, - "doc_count": 1200 - }, - { - "key_as_string": "2018-06-06T03:00:00.000Z", - "key": 1528254000000, - "doc_count": 1237 - }, - { - "key_as_string": "2018-06-06T06:00:00.000Z", - "key": 1528264800000, - "doc_count": 1231 - }, - { - "key_as_string": "2018-06-06T09:00:00.000Z", - "key": 1528275600000, - "doc_count": 1182 - }, - { - "key_as_string": "2018-06-06T12:00:00.000Z", - "key": 1528286400000, - "doc_count": 1125 - }, - { - "key_as_string": "2018-06-06T15:00:00.000Z", - "key": 1528297200000, - "doc_count": 1243 - }, - { - "key_as_string": "2018-06-06T18:00:00.000Z", - "key": 1528308000000, - "doc_count": 1247 - }, - { - "key_as_string": "2018-06-06T21:00:00.000Z", - "key": 1528318800000, - "doc_count": 1163 - }, - { - "key_as_string": "2018-06-07T00:00:00.000Z", - "key": 1528329600000, - "doc_count": 1220 - }, - { - "key_as_string": "2018-06-07T03:00:00.000Z", - "key": 1528340400000, - "doc_count": 1202 - }, - { - "key_as_string": "2018-06-07T06:00:00.000Z", - "key": 1528351200000, - "doc_count": 1192 - }, - { - "key_as_string": "2018-06-07T09:00:00.000Z", - "key": 1528362000000, - "doc_count": 1248 - }, - { - "key_as_string": "2018-06-07T12:00:00.000Z", - "key": 1528372800000, - "doc_count": 1189 - }, - { - "key_as_string": "2018-06-07T15:00:00.000Z", - "key": 1528383600000, - "doc_count": 1230 - }, - { - "key_as_string": "2018-06-07T18:00:00.000Z", - "key": 1528394400000, - "doc_count": 1206 - }, - { - "key_as_string": "2018-06-07T21:00:00.000Z", - "key": 1528405200000, - "doc_count": 1190 - }, - { - "key_as_string": "2018-06-08T00:00:00.000Z", - "key": 1528416000000, - "doc_count": 1232 - }, - { - "key_as_string": "2018-06-08T03:00:00.000Z", - "key": 1528426800000, - "doc_count": 1171 - }, - { - "key_as_string": "2018-06-08T06:00:00.000Z", - "key": 1528437600000, - "doc_count": 1232 - }, - { - "key_as_string": "2018-06-08T09:00:00.000Z", - "key": 1528448400000, - "doc_count": 1253 - }, - { - "key_as_string": "2018-06-08T12:00:00.000Z", - "key": 1528459200000, - "doc_count": 1250 - }, - { - "key_as_string": "2018-06-08T15:00:00.000Z", - "key": 1528470000000, - "doc_count": 1167 - }, - { - "key_as_string": "2018-06-08T18:00:00.000Z", - "key": 1528480800000, - "doc_count": 1258 - }, - { - "key_as_string": "2018-06-08T21:00:00.000Z", - "key": 1528491600000, - "doc_count": 1148 - }, - { - "key_as_string": "2018-06-09T00:00:00.000Z", - "key": 1528502400000, - "doc_count": 284 - }, - { - "key_as_string": "2018-06-09T03:00:00.000Z", - "key": 1528513200000, - "doc_count": 240 - }, - { - "key_as_string": "2018-06-09T06:00:00.000Z", - "key": 1528524000000, - "doc_count": 273 - }, - { - "key_as_string": "2018-06-09T09:00:00.000Z", - "key": 1528534800000, - "doc_count": 295 - }, - { - "key_as_string": "2018-06-09T12:00:00.000Z", - "key": 1528545600000, - "doc_count": 281 - }, - { - "key_as_string": "2018-06-09T15:00:00.000Z", - "key": 1528556400000, - "doc_count": 300 - }, - { - "key_as_string": "2018-06-09T18:00:00.000Z", - "key": 1528567200000, - "doc_count": 264 - }, - { - "key_as_string": "2018-06-09T21:00:00.000Z", - "key": 1528578000000, - "doc_count": 260 - }, - { - "key_as_string": "2018-06-10T00:00:00.000Z", - "key": 1528588800000, - "doc_count": 279 - }, - { - "key_as_string": "2018-06-10T03:00:00.000Z", - "key": 1528599600000, - "doc_count": 259 - }, - { - "key_as_string": "2018-06-10T06:00:00.000Z", - "key": 1528610400000, - "doc_count": 291 - }, - { - "key_as_string": "2018-06-10T09:00:00.000Z", - "key": 1528621200000, - "doc_count": 248 - }, - { - "key_as_string": "2018-06-10T12:00:00.000Z", - "key": 1528632000000, - "doc_count": 311 - }, - { - "key_as_string": "2018-06-10T15:00:00.000Z", - "key": 1528642800000, - "doc_count": 277 - }, - { - "key_as_string": "2018-06-10T18:00:00.000Z", - "key": 1528653600000, - "doc_count": 279 - }, - { - "key_as_string": "2018-06-10T21:00:00.000Z", - "key": 1528664400000, - "doc_count": 275 - }, - { - "key_as_string": "2018-06-11T00:00:00.000Z", - "key": 1528675200000, - "doc_count": 1167 - }, - { - "key_as_string": "2018-06-11T03:00:00.000Z", - "key": 1528686000000, - "doc_count": 1270 - }, - { - "key_as_string": "2018-06-11T06:00:00.000Z", - "key": 1528696800000, - "doc_count": 1163 - }, - { - "key_as_string": "2018-06-11T09:00:00.000Z", - "key": 1528707600000, - "doc_count": 1155 - }, - { - "key_as_string": "2018-06-11T12:00:00.000Z", - "key": 1528718400000, - "doc_count": 1217 - }, - { - "key_as_string": "2018-06-11T15:00:00.000Z", - "key": 1528729200000, - "doc_count": 1227 - }, - { - "key_as_string": "2018-06-11T18:00:00.000Z", - "key": 1528740000000, - "doc_count": 1194 - }, - { - "key_as_string": "2018-06-11T21:00:00.000Z", - "key": 1528750800000, - "doc_count": 1153 - }, - { - "key_as_string": "2018-06-12T00:00:00.000Z", - "key": 1528761600000, - "doc_count": 1211 - }, - { - "key_as_string": "2018-06-12T03:00:00.000Z", - "key": 1528772400000, - "doc_count": 1203 - }, - { - "key_as_string": "2018-06-12T06:00:00.000Z", - "key": 1528783200000, - "doc_count": 1269 - }, - { - "key_as_string": "2018-06-12T09:00:00.000Z", - "key": 1528794000000, - "doc_count": 1197 - }, - { - "key_as_string": "2018-06-12T12:00:00.000Z", - "key": 1528804800000, - "doc_count": 1184 - }, - { - "key_as_string": "2018-06-12T15:00:00.000Z", - "key": 1528815600000, - "doc_count": 1176 - }, - { - "key_as_string": "2018-06-12T18:00:00.000Z", - "key": 1528826400000, - "doc_count": 1162 - }, - { - "key_as_string": "2018-06-12T21:00:00.000Z", - "key": 1528837200000, - "doc_count": 1270 - }, - { - "key_as_string": "2018-06-13T00:00:00.000Z", - "key": 1528848000000, - "doc_count": 1224 - }, - { - "key_as_string": "2018-06-13T03:00:00.000Z", - "key": 1528858800000, - "doc_count": 1255 - }, - { - "key_as_string": "2018-06-13T06:00:00.000Z", - "key": 1528869600000, - "doc_count": 1207 - }, - { - "key_as_string": "2018-06-13T09:00:00.000Z", - "key": 1528880400000, - "doc_count": 1206 - }, - { - "key_as_string": "2018-06-13T12:00:00.000Z", - "key": 1528891200000, - "doc_count": 1254 - }, - { - "key_as_string": "2018-06-13T15:00:00.000Z", - "key": 1528902000000, - "doc_count": 1216 - }, - { - "key_as_string": "2018-06-13T18:00:00.000Z", - "key": 1528912800000, - "doc_count": 1263 - }, - { - "key_as_string": "2018-06-13T21:00:00.000Z", - "key": 1528923600000, - "doc_count": 1277 - }, - { - "key_as_string": "2018-06-14T00:00:00.000Z", - "key": 1528934400000, - "doc_count": 1183 - }, - { - "key_as_string": "2018-06-14T03:00:00.000Z", - "key": 1528945200000, - "doc_count": 1221 - }, - { - "key_as_string": "2018-06-14T06:00:00.000Z", - "key": 1528956000000, - "doc_count": 1198 - }, - { - "key_as_string": "2018-06-14T09:00:00.000Z", - "key": 1528966800000, - "doc_count": 1214 - }, - { - "key_as_string": "2018-06-14T12:00:00.000Z", - "key": 1528977600000, - "doc_count": 0 - } - ] - } - }, - { - "key": "HTTP 3xx", - "doc_count": 6650, - "timeseries": { - "buckets": [ - { - "key_as_string": "2018-06-04T12:00:00.000Z", - "key": 1528113600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-04T15:00:00.000Z", - "key": 1528124400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-04T18:00:00.000Z", - "key": 1528135200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-04T21:00:00.000Z", - "key": 1528146000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-05T00:00:00.000Z", - "key": 1528156800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-05T03:00:00.000Z", - "key": 1528167600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-05T06:00:00.000Z", - "key": 1528178400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-05T09:00:00.000Z", - "key": 1528189200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-05T12:00:00.000Z", - "key": 1528200000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-05T15:00:00.000Z", - "key": 1528210800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-05T18:00:00.000Z", - "key": 1528221600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-05T21:00:00.000Z", - "key": 1528232400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-06T00:00:00.000Z", - "key": 1528243200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-06T03:00:00.000Z", - "key": 1528254000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-06T06:00:00.000Z", - "key": 1528264800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-06T09:00:00.000Z", - "key": 1528275600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-06T12:00:00.000Z", - "key": 1528286400000, - "doc_count": 4041 - }, - { - "key_as_string": "2018-06-06T15:00:00.000Z", - "key": 1528297200000, - "doc_count": 454 - }, - { - "key_as_string": "2018-06-06T18:00:00.000Z", - "key": 1528308000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-06T21:00:00.000Z", - "key": 1528318800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-07T00:00:00.000Z", - "key": 1528329600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-07T03:00:00.000Z", - "key": 1528340400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-07T06:00:00.000Z", - "key": 1528351200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-07T09:00:00.000Z", - "key": 1528362000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-07T12:00:00.000Z", - "key": 1528372800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-07T15:00:00.000Z", - "key": 1528383600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-07T18:00:00.000Z", - "key": 1528394400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-07T21:00:00.000Z", - "key": 1528405200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-08T00:00:00.000Z", - "key": 1528416000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-08T03:00:00.000Z", - "key": 1528426800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-08T06:00:00.000Z", - "key": 1528437600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-08T09:00:00.000Z", - "key": 1528448400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-08T12:00:00.000Z", - "key": 1528459200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-08T15:00:00.000Z", - "key": 1528470000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-08T18:00:00.000Z", - "key": 1528480800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-08T21:00:00.000Z", - "key": 1528491600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-09T00:00:00.000Z", - "key": 1528502400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-09T03:00:00.000Z", - "key": 1528513200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-09T06:00:00.000Z", - "key": 1528524000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-09T09:00:00.000Z", - "key": 1528534800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-09T12:00:00.000Z", - "key": 1528545600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-09T15:00:00.000Z", - "key": 1528556400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-09T18:00:00.000Z", - "key": 1528567200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-09T21:00:00.000Z", - "key": 1528578000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-10T00:00:00.000Z", - "key": 1528588800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-10T03:00:00.000Z", - "key": 1528599600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-10T06:00:00.000Z", - "key": 1528610400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-10T09:00:00.000Z", - "key": 1528621200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-10T12:00:00.000Z", - "key": 1528632000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-10T15:00:00.000Z", - "key": 1528642800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-10T18:00:00.000Z", - "key": 1528653600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-10T21:00:00.000Z", - "key": 1528664400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-11T00:00:00.000Z", - "key": 1528675200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-11T03:00:00.000Z", - "key": 1528686000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-11T06:00:00.000Z", - "key": 1528696800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-11T09:00:00.000Z", - "key": 1528707600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-11T12:00:00.000Z", - "key": 1528718400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-11T15:00:00.000Z", - "key": 1528729200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-11T18:00:00.000Z", - "key": 1528740000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-11T21:00:00.000Z", - "key": 1528750800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-12T00:00:00.000Z", - "key": 1528761600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-12T03:00:00.000Z", - "key": 1528772400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-12T06:00:00.000Z", - "key": 1528783200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-12T09:00:00.000Z", - "key": 1528794000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-12T12:00:00.000Z", - "key": 1528804800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-12T15:00:00.000Z", - "key": 1528815600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-12T18:00:00.000Z", - "key": 1528826400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-12T21:00:00.000Z", - "key": 1528837200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-13T00:00:00.000Z", - "key": 1528848000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-13T03:00:00.000Z", - "key": 1528858800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-13T06:00:00.000Z", - "key": 1528869600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-13T09:00:00.000Z", - "key": 1528880400000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-13T12:00:00.000Z", - "key": 1528891200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-13T15:00:00.000Z", - "key": 1528902000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-13T18:00:00.000Z", - "key": 1528912800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-13T21:00:00.000Z", - "key": 1528923600000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-14T00:00:00.000Z", - "key": 1528934400000, - "doc_count": 2155 - }, - { - "key_as_string": "2018-06-14T03:00:00.000Z", - "key": 1528945200000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-14T06:00:00.000Z", - "key": 1528956000000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-14T09:00:00.000Z", - "key": 1528966800000, - "doc_count": 0 - }, - { - "key_as_string": "2018-06-14T12:00:00.000Z", - "key": 1528977600000, - "doc_count": 0 - } - ] - } - } - ] - }, - "response_times": { - "buckets": [ - { - "key_as_string": "2018-06-04T12:00:00.000Z", - "key": 1528113600000, - "doc_count": 18841, - "pct": { - "values": { - "95.0": 82172.85648714812, - "99.0": 293866.3866666665 - } - }, - "avg": { - "value": 26310.63483891513 - } - }, - { - "key_as_string": "2018-06-04T15:00:00.000Z", - "key": 1528124400000, - "doc_count": 18708, - "pct": { - "values": { - "95.0": 80738.78571428556, - "99.0": 293257.27333333343 - } - }, - "avg": { - "value": 26193.277795595466 - } - }, - { - "key_as_string": "2018-06-04T18:00:00.000Z", - "key": 1528135200000, - "doc_count": 18865, - "pct": { - "values": { - "95.0": 77058.03529411761, - "99.0": 290195.8800000004 - } - }, - "avg": { - "value": 25291.787065995228 - } - }, - { - "key_as_string": "2018-06-04T21:00:00.000Z", - "key": 1528146000000, - "doc_count": 18889, - "pct": { - "values": { - "95.0": 77892.20721980717, - "99.0": 278548.1649999994 - } - }, - "avg": { - "value": 24690.306474667796 - } - }, - { - "key_as_string": "2018-06-05T00:00:00.000Z", - "key": 1528156800000, - "doc_count": 19270, - "pct": { - "values": { - "95.0": 77085.86687499998, - "99.0": 290701.8973333341 - } - }, - "avg": { - "value": 24809.8953814219 - } - }, - { - "key_as_string": "2018-06-05T03:00:00.000Z", - "key": 1528167600000, - "doc_count": 19024, - "pct": { - "values": { - "95.0": 80048.3462981744, - "99.0": 286839.5897777779 - } - }, - "avg": { - "value": 25460.0394764508 - } - }, - { - "key_as_string": "2018-06-05T06:00:00.000Z", - "key": 1528178400000, - "doc_count": 18923, - "pct": { - "values": { - "95.0": 84089.21370223971, - "99.0": 287979.5149999999 - } - }, - "avg": { - "value": 26360.440733498916 - } - }, - { - "key_as_string": "2018-06-05T09:00:00.000Z", - "key": 1528189200000, - "doc_count": 18834, - "pct": { - "values": { - "95.0": 84880.90143416924, - "99.0": 300107.5009999992 - } - }, - "avg": { - "value": 27050.95205479452 - } - }, - { - "key_as_string": "2018-06-05T12:00:00.000Z", - "key": 1528200000000, - "doc_count": 18694, - "pct": { - "values": { - "95.0": 84554.8884781166, - "99.0": 294402.2179999999 - } - }, - "avg": { - "value": 26555.857333903925 - } - }, - { - "key_as_string": "2018-06-05T15:00:00.000Z", - "key": 1528210800000, - "doc_count": 19184, - "pct": { - "values": { - "95.0": 81839.39583333326, - "99.0": 289849.459333332 - } - }, - "avg": { - "value": 26164.343359049206 - } - }, - { - "key_as_string": "2018-06-05T18:00:00.000Z", - "key": 1528221600000, - "doc_count": 18850, - "pct": { - "values": { - "95.0": 85993.55410163336, - "99.0": 296942.86299999955 - } - }, - "avg": { - "value": 26989.84546419098 - } - }, - { - "key_as_string": "2018-06-05T21:00:00.000Z", - "key": 1528232400000, - "doc_count": 18897, - "pct": { - "values": { - "95.0": 85001.44588628765, - "99.0": 292048.20571428596 - } - }, - "avg": { - "value": 26314.409430068266 - } - }, - { - "key_as_string": "2018-06-06T00:00:00.000Z", - "key": 1528243200000, - "doc_count": 18942, - "pct": { - "values": { - "95.0": 86980.16445312503, - "99.0": 299308.7371666667 - } - }, - "avg": { - "value": 27460.774575018477 - } - }, - { - "key_as_string": "2018-06-06T03:00:00.000Z", - "key": 1528254000000, - "doc_count": 19147, - "pct": { - "values": { - "95.0": 84961.8710743802, - "99.0": 292151.2377777781 - } - }, - "avg": { - "value": 26461.469107431974 - } - }, - { - "key_as_string": "2018-06-06T06:00:00.000Z", - "key": 1528264800000, - "doc_count": 18853, - "pct": { - "values": { - "95.0": 88906.54601889332, - "99.0": 302274.4192592592 - } - }, - "avg": { - "value": 27657.584946692834 - } - }, - { - "key_as_string": "2018-06-06T09:00:00.000Z", - "key": 1528275600000, - "doc_count": 18609, - "pct": { - "values": { - "95.0": 90198.34708994703, - "99.0": 299457.1612121209 - } - }, - "avg": { - "value": 27940.445967005213 - } - }, - { - "key_as_string": "2018-06-06T12:00:00.000Z", - "key": 1528286400000, - "doc_count": 21402, - "pct": { - "values": { - "95.0": 135627.71242424246, - "99.0": 350398.59259259375 - } - }, - "avg": { - "value": 34454.377581534434 - } - }, - { - "key_as_string": "2018-06-06T15:00:00.000Z", - "key": 1528297200000, - "doc_count": 19051, - "pct": { - "values": { - "95.0": 167037.1993837535, - "99.0": 421204.23333333334 - } - }, - "avg": { - "value": 44024.31809353839 - } - }, - { - "key_as_string": "2018-06-06T18:00:00.000Z", - "key": 1528308000000, - "doc_count": 19020, - "pct": { - "values": { - "95.0": 128293.12184873945, - "99.0": 368166.68976190523 - } - }, - "avg": { - "value": 36374.53333333333 - } - }, - { - "key_as_string": "2018-06-06T21:00:00.000Z", - "key": 1528318800000, - "doc_count": 18582, - "pct": { - "values": { - "95.0": 130653.54236263742, - "99.0": 367193.6128571426 - } - }, - "avg": { - "value": 36991.29442471209 - } - }, - { - "key_as_string": "2018-06-07T00:00:00.000Z", - "key": 1528329600000, - "doc_count": 18875, - "pct": { - "values": { - "95.0": 131630.8902645502, - "99.0": 375658.10190476174 - } - }, - "avg": { - "value": 37178.002701986756 - } - }, - { - "key_as_string": "2018-06-07T03:00:00.000Z", - "key": 1528340400000, - "doc_count": 18993, - "pct": { - "values": { - "95.0": 133581.33541666638, - "99.0": 368152.03822222137 - } - }, - "avg": { - "value": 37605.57078923814 - } - }, - { - "key_as_string": "2018-06-07T06:00:00.000Z", - "key": 1528351200000, - "doc_count": 19037, - "pct": { - "values": { - "95.0": 132697.92762266204, - "99.0": 365705.8319999995 - } - }, - "avg": { - "value": 37319.89767295267 - } - }, - { - "key_as_string": "2018-06-07T09:00:00.000Z", - "key": 1528362000000, - "doc_count": 18985, - "pct": { - "values": { - "95.0": 140003.6918918918, - "99.0": 380075.48533333326 - } - }, - "avg": { - "value": 38709.5041348433 - } - }, - { - "key_as_string": "2018-06-07T12:00:00.000Z", - "key": 1528372800000, - "doc_count": 18505, - "pct": { - "values": { - "95.0": 138149.5673529411, - "99.0": 375697.1923809518 - } - }, - "avg": { - "value": 38140.131856255066 - } - }, - { - "key_as_string": "2018-06-07T15:00:00.000Z", - "key": 1528383600000, - "doc_count": 18991, - "pct": { - "values": { - "95.0": 121872.37504835591, - "99.0": 351080.94111111073 - } - }, - "avg": { - "value": 34564.81091043125 - } - }, - { - "key_as_string": "2018-06-07T18:00:00.000Z", - "key": 1528394400000, - "doc_count": 18917, - "pct": { - "values": { - "95.0": 116378.03873517792, - "99.0": 339294.12799999997 - } - }, - "avg": { - "value": 33256.37743828302 - } - }, - { - "key_as_string": "2018-06-07T21:00:00.000Z", - "key": 1528405200000, - "doc_count": 18744, - "pct": { - "values": { - "95.0": 131545.40999999995, - "99.0": 378902.90649999987 - } - }, - "avg": { - "value": 37251.5625266752 - } - }, - { - "key_as_string": "2018-06-08T00:00:00.000Z", - "key": 1528416000000, - "doc_count": 19157, - "pct": { - "values": { - "95.0": 133111.25804878055, - "99.0": 384483.3233333327 - } - }, - "avg": { - "value": 38681.89084929791 - } - }, - { - "key_as_string": "2018-06-08T03:00:00.000Z", - "key": 1528426800000, - "doc_count": 18552, - "pct": { - "values": { - "95.0": 144821.9855278593, - "99.0": 394692.25000000105 - } - }, - "avg": { - "value": 40677.801045709355 - } - }, - { - "key_as_string": "2018-06-08T06:00:00.000Z", - "key": 1528437600000, - "doc_count": 18994, - "pct": { - "values": { - "95.0": 134737.3997727272, - "99.0": 403362.50399999996 - } - }, - "avg": { - "value": 39987.86453616932 - } - }, - { - "key_as_string": "2018-06-08T09:00:00.000Z", - "key": 1528448400000, - "doc_count": 18798, - "pct": { - "values": { - "95.0": 141206.57726666646, - "99.0": 396559.0274999993 - } - }, - "avg": { - "value": 41059.392914139804 - } - }, - { - "key_as_string": "2018-06-08T12:00:00.000Z", - "key": 1528459200000, - "doc_count": 19097, - "pct": { - "values": { - "95.0": 137731.8994082841, - "99.0": 371815.8320000008 - } - }, - "avg": { - "value": 39630.710111535845 - } - }, - { - "key_as_string": "2018-06-08T15:00:00.000Z", - "key": 1528470000000, - "doc_count": 18887, - "pct": { - "values": { - "95.0": 141476.23189033198, - "99.0": 405477.6133333326 - } - }, - "avg": { - "value": 41561.81331074284 - } - }, - { - "key_as_string": "2018-06-08T18:00:00.000Z", - "key": 1528480800000, - "doc_count": 18949, - "pct": { - "values": { - "95.0": 149636.31340909077, - "99.0": 413542.18133333366 - } - }, - "avg": { - "value": 43079.490738297536 - } - }, - { - "key_as_string": "2018-06-08T21:00:00.000Z", - "key": 1528491600000, - "doc_count": 18786, - "pct": { - "values": { - "95.0": 151934.55000000002, - "99.0": 424399.340000001 - } - }, - "avg": { - "value": 43925.39609283509 - } - }, - { - "key_as_string": "2018-06-09T00:00:00.000Z", - "key": 1528502400000, - "doc_count": 5096, - "pct": { - "values": { - "95.0": 82198.17857142858, - "99.0": 303815.9000000001 - } - }, - "avg": { - "value": 25821.91424646782 - } - }, - { - "key_as_string": "2018-06-09T03:00:00.000Z", - "key": 1528513200000, - "doc_count": 5104, - "pct": { - "values": { - "95.0": 85946.43199999983, - "99.0": 306305.0800000006 - } - }, - "avg": { - "value": 27343.60011755486 - } - }, - { - "key_as_string": "2018-06-09T06:00:00.000Z", - "key": 1528524000000, - "doc_count": 5122, - "pct": { - "values": { - "95.0": 78617.66249999996, - "99.0": 297521.94999999984 - } - }, - "avg": { - "value": 25249.95060523233 - } - }, - { - "key_as_string": "2018-06-09T09:00:00.000Z", - "key": 1528534800000, - "doc_count": 5184, - "pct": { - "values": { - "95.0": 79606.48333333322, - "99.0": 317938.0900000003 - } - }, - "avg": { - "value": 25492.77199074074 - } - }, - { - "key_as_string": "2018-06-09T12:00:00.000Z", - "key": 1528545600000, - "doc_count": 5279, - "pct": { - "values": { - "95.0": 76297.93999999986, - "99.0": 312262.3000000003 - } - }, - "avg": { - "value": 25991.647281682137 - } - }, - { - "key_as_string": "2018-06-09T15:00:00.000Z", - "key": 1528556400000, - "doc_count": 5254, - "pct": { - "values": { - "95.0": 80742.63333333324, - "99.0": 318428.8700000002 - } - }, - "avg": { - "value": 26273.31290445375 - } - }, - { - "key_as_string": "2018-06-09T18:00:00.000Z", - "key": 1528567200000, - "doc_count": 5082, - "pct": { - "values": { - "95.0": 81291.45969696966, - "99.0": 295421.4099999999 - } - }, - "avg": { - "value": 26234.98976780795 - } - }, - { - "key_as_string": "2018-06-09T21:00:00.000Z", - "key": 1528578000000, - "doc_count": 5150, - "pct": { - "values": { - "95.0": 73467.02500000004, - "99.0": 293067.86000000004 - } - }, - "avg": { - "value": 23494.54873786408 - } - }, - { - "key_as_string": "2018-06-10T00:00:00.000Z", - "key": 1528588800000, - "doc_count": 5103, - "pct": { - "values": { - "95.0": 69177.66999999993, - "99.0": 264935.71999999933 - } - }, - "avg": { - "value": 22008.80482069371 - } - }, - { - "key_as_string": "2018-06-10T03:00:00.000Z", - "key": 1528599600000, - "doc_count": 5137, - "pct": { - "values": { - "95.0": 71956.06111111109, - "99.0": 282795.0400000003 - } - }, - "avg": { - "value": 22828.136655635586 - } - }, - { - "key_as_string": "2018-06-10T06:00:00.000Z", - "key": 1528610400000, - "doc_count": 5184, - "pct": { - "values": { - "95.0": 68480.91142857139, - "99.0": 285390.8400000001 - } - }, - "avg": { - "value": 22138.7081404321 - } - }, - { - "key_as_string": "2018-06-10T09:00:00.000Z", - "key": 1528621200000, - "doc_count": 4993, - "pct": { - "values": { - "95.0": 68957.0999999999, - "99.0": 290402.24 - } - }, - "avg": { - "value": 22634.985579811735 - } - }, - { - "key_as_string": "2018-06-10T12:00:00.000Z", - "key": 1528632000000, - "doc_count": 5210, - "pct": { - "values": { - "95.0": 67489.50416666668, - "99.0": 293655.53 - } - }, - "avg": { - "value": 22202.780998080616 - } - }, - { - "key_as_string": "2018-06-10T15:00:00.000Z", - "key": 1528642800000, - "doc_count": 5122, - "pct": { - "values": { - "95.0": 71556.91249999998, - "99.0": 292723.56999999995 - } - }, - "avg": { - "value": 23084.082780163997 - } - }, - { - "key_as_string": "2018-06-10T18:00:00.000Z", - "key": 1528653600000, - "doc_count": 5125, - "pct": { - "values": { - "95.0": 72157.65128205132, - "99.0": 301051.32000000105 - } - }, - "avg": { - "value": 23109.666146341464 - } - }, - { - "key_as_string": "2018-06-10T21:00:00.000Z", - "key": 1528664400000, - "doc_count": 5186, - "pct": { - "values": { - "95.0": 76124.5625, - "99.0": 291322.0499999998 - } - }, - "avg": { - "value": 23306.89028152719 - } - }, - { - "key_as_string": "2018-06-11T00:00:00.000Z", - "key": 1528675200000, - "doc_count": 18631, - "pct": { - "values": { - "95.0": 141709.34661835746, - "99.0": 379855.2444444447 - } - }, - "avg": { - "value": 39341.022704095325 - } - }, - { - "key_as_string": "2018-06-11T03:00:00.000Z", - "key": 1528686000000, - "doc_count": 19349, - "pct": { - "values": { - "95.0": 132371.48641975303, - "99.0": 371175.2592000001 - } - }, - "avg": { - "value": 37467.17153341258 - } - }, - { - "key_as_string": "2018-06-11T06:00:00.000Z", - "key": 1528696800000, - "doc_count": 18586, - "pct": { - "values": { - "95.0": 186783.51503759398, - "99.0": 498378.4238888898 - } - }, - "avg": { - "value": 52457.50554180566 - } - }, - { - "key_as_string": "2018-06-11T09:00:00.000Z", - "key": 1528707600000, - "doc_count": 18887, - "pct": { - "values": { - "95.0": 99540.17819499348, - "99.0": 331118.6599999997 - } - }, - "avg": { - "value": 31327.95780166252 - } - }, - { - "key_as_string": "2018-06-11T12:00:00.000Z", - "key": 1528718400000, - "doc_count": 18866, - "pct": { - "values": { - "95.0": 95982.62454212455, - "99.0": 328101.3999999988 - } - }, - "avg": { - "value": 30695.334941163997 - } - }, - { - "key_as_string": "2018-06-11T15:00:00.000Z", - "key": 1528729200000, - "doc_count": 19469, - "pct": { - "values": { - "95.0": 89559.3525925925, - "99.0": 313951.54249999986 - } - }, - "avg": { - "value": 28895.042785967435 - } - }, - { - "key_as_string": "2018-06-11T18:00:00.000Z", - "key": 1528740000000, - "doc_count": 18767, - "pct": { - "values": { - "95.0": 95769.83153735634, - "99.0": 323340.5274074075 - } - }, - "avg": { - "value": 30649.363989982416 - } - }, - { - "key_as_string": "2018-06-11T21:00:00.000Z", - "key": 1528750800000, - "doc_count": 19006, - "pct": { - "values": { - "95.0": 94063.90833755062, - "99.0": 315055.5047619052 - } - }, - "avg": { - "value": 29802.63622014101 - } - }, - { - "key_as_string": "2018-06-12T00:00:00.000Z", - "key": 1528761600000, - "doc_count": 19082, - "pct": { - "values": { - "95.0": 96399.67269119772, - "99.0": 330070.03599999985 - } - }, - "avg": { - "value": 30759.03002829892 - } - }, - { - "key_as_string": "2018-06-12T03:00:00.000Z", - "key": 1528772400000, - "doc_count": 18908, - "pct": { - "values": { - "95.0": 96436.42520161276, - "99.0": 320531.54416666675 - } - }, - "avg": { - "value": 30399.76549608631 - } - }, - { - "key_as_string": "2018-06-12T06:00:00.000Z", - "key": 1528783200000, - "doc_count": 19055, - "pct": { - "values": { - "95.0": 91860.16988095238, - "99.0": 315137.16628571344 - } - }, - "avg": { - "value": 29421.610233534506 - } - }, - { - "key_as_string": "2018-06-12T09:00:00.000Z", - "key": 1528794000000, - "doc_count": 19047, - "pct": { - "values": { - "95.0": 105989.8333333334, - "99.0": 337251.4042424246 - } - }, - "avg": { - "value": 32641.679897096656 - } - }, - { - "key_as_string": "2018-06-12T12:00:00.000Z", - "key": 1528804800000, - "doc_count": 18733, - "pct": { - "values": { - "95.0": 97937.60342555979, - "99.0": 327054.9243636365 - } - }, - "avg": { - "value": 30621.65440666204 - } - }, - { - "key_as_string": "2018-06-12T15:00:00.000Z", - "key": 1528815600000, - "doc_count": 19079, - "pct": { - "values": { - "95.0": 98967.2249999999, - "99.0": 327653.0000000006 - } - }, - "avg": { - "value": 31039.60391005818 - } - }, - { - "key_as_string": "2018-06-12T18:00:00.000Z", - "key": 1528826400000, - "doc_count": 18907, - "pct": { - "values": { - "95.0": 97561.02469135808, - "99.0": 324505.1399999999 - } - }, - "avg": { - "value": 30954.760723541545 - } - }, - { - "key_as_string": "2018-06-12T21:00:00.000Z", - "key": 1528837200000, - "doc_count": 18971, - "pct": { - "values": { - "95.0": 102557.78813357186, - "99.0": 338040.3999999998 - } - }, - "avg": { - "value": 31902.050234568553 - } - }, - { - "key_as_string": "2018-06-13T00:00:00.000Z", - "key": 1528848000000, - "doc_count": 18899, - "pct": { - "values": { - "95.0": 100137.87578595306, - "99.0": 328600.5173333335 - } - }, - "avg": { - "value": 31594.350653473728 - } - }, - { - "key_as_string": "2018-06-13T03:00:00.000Z", - "key": 1528858800000, - "doc_count": 19182, - "pct": { - "values": { - "95.0": 98412.97120445351, - "99.0": 334060.93628571345 - } - }, - "avg": { - "value": 31343.87243248879 - } - }, - { - "key_as_string": "2018-06-13T06:00:00.000Z", - "key": 1528869600000, - "doc_count": 19030, - "pct": { - "values": { - "95.0": 101607.8328012912, - "99.0": 328569.4964999998 - } - }, - "avg": { - "value": 31200.14450867052 - } - }, - { - "key_as_string": "2018-06-13T09:00:00.000Z", - "key": 1528880400000, - "doc_count": 19257, - "pct": { - "values": { - "95.0": 92000.51368421057, - "99.0": 320227.32399999973 - } - }, - "avg": { - "value": 28560.946668743833 - } - }, - { - "key_as_string": "2018-06-13T12:00:00.000Z", - "key": 1528891200000, - "doc_count": 19348, - "pct": { - "values": { - "95.0": 78027.29473684198, - "99.0": 292019.2899999998 - } - }, - "avg": { - "value": 24700.216146371717 - } - }, - { - "key_as_string": "2018-06-13T15:00:00.000Z", - "key": 1528902000000, - "doc_count": 19119, - "pct": { - "values": { - "95.0": 80762.078801789, - "99.0": 297757.72666666657 - } - }, - "avg": { - "value": 25261.025210523563 - } - }, - { - "key_as_string": "2018-06-13T18:00:00.000Z", - "key": 1528912800000, - "doc_count": 19206, - "pct": { - "values": { - "95.0": 81160.83425925927, - "99.0": 308034.4466666669 - } - }, - "avg": { - "value": 26041.39789649068 - } - }, - { - "key_as_string": "2018-06-13T21:00:00.000Z", - "key": 1528923600000, - "doc_count": 19078, - "pct": { - "values": { - "95.0": 84215.58945578222, - "99.0": 301128.4895238093 - } - }, - "avg": { - "value": 26123.556295209142 - } - }, - { - "key_as_string": "2018-06-14T00:00:00.000Z", - "key": 1528934400000, - "doc_count": 19551, - "pct": { - "values": { - "95.0": 194188.21428571426, - "99.0": 447266.9 - } - }, - "avg": { - "value": 46231.36177177638 - } - }, - { - "key_as_string": "2018-06-14T03:00:00.000Z", - "key": 1528945200000, - "doc_count": 18888, - "pct": { - "values": { - "95.0": 172616.2293896504, - "99.0": 409147.332500001 - } - }, - "avg": { - "value": 45350.42005506141 - } - }, - { - "key_as_string": "2018-06-14T06:00:00.000Z", - "key": 1528956000000, - "doc_count": 18823, - "pct": { - "values": { - "95.0": 182653.81858220184, - "99.0": 423121.9773333328 - } - }, - "avg": { - "value": 48256.049354513096 - } - }, - { - "key_as_string": "2018-06-14T09:00:00.000Z", - "key": 1528966800000, - "doc_count": 18766, - "pct": { - "values": { - "95.0": 194970.75667682925, - "99.0": 473485.4199999998 - } - }, - "avg": { - "value": 52360.30017052116 - } - }, - { - "key_as_string": "2018-06-14T12:00:00.000Z", - "key": 1528977600000, - "doc_count": 0, - "pct": { - "values": { - "95.0": "NaN", - "99.0": "NaN" - } - }, - "avg": { - "value": null - } - } - ] - }, - "overall_avg_duration": { - "value": 32861.15660262639 - } - } -} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__snapshots__/get_buckets_with_initial_anomaly_bounds.test.ts.snap b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__snapshots__/get_buckets_with_initial_anomaly_bounds.test.ts.snap new file mode 100644 index 0000000000000..072a819e75398 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__snapshots__/get_buckets_with_initial_anomaly_bounds.test.ts.snap @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`get_buckets_with_initial_anomaly_bounds should return correct buckets 1`] = ` +Array [ + Object { + "anomalyScore": 0, + "lower": 17688.182675688193, + "upper": 50381.01051622894, + }, + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": 0, + "lower": 16034.081569306454, + "upper": 54158.77731018045, + }, + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": 0, + "lower": 16034.081569306454, + "upper": 54158.77731018045, + }, + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": 0, + "lower": 16034.081569306454, + "upper": 54158.77731018045, + }, +] +`; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/__snapshots__/get_buckets_with_initial_anomaly_bounds.test.js.snap b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/__snapshots__/get_buckets_with_initial_anomaly_bounds.test.js.snap deleted file mode 100644 index 6809efff957af..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/__snapshots__/get_buckets_with_initial_anomaly_bounds.test.js.snap +++ /dev/null @@ -1,118 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`get_buckets_with_initial_anomaly_bounds should return correct buckets 1`] = ` -Array [ - Object { - "anomaly_score": Object { - "value": null, - }, - "doc_count": 0, - "key": 1530523000000, - "key_as_string": "2018-07-02T09:16:40.000Z", - "lower": Object { - "value": 17688.182675688193, - }, - "upper": Object { - "value": 50381.01051622894, - }, - }, - Object { - "anomaly_score": Object { - "value": null, - }, - "doc_count": 4, - "key": 1530523500000, - "key_as_string": "2018-07-02T09:25:00.000Z", - "lower": Object { - "value": null, - }, - "upper": Object { - "value": null, - }, - }, - Object { - "anomaly_score": Object { - "value": null, - }, - "doc_count": 0, - "key": 1530524000000, - "key_as_string": "2018-07-02T09:33:20.000Z", - "lower": Object { - "value": null, - }, - "upper": Object { - "value": null, - }, - }, - Object { - "anomaly_score": Object { - "value": 0, - }, - "doc_count": 2, - "key": 1530524500000, - "key_as_string": "2018-07-02T09:41:40.000Z", - "lower": Object { - "value": 16034.081569306454, - }, - "upper": Object { - "value": 54158.77731018045, - }, - }, - Object { - "anomaly_score": Object { - "value": null, - }, - "doc_count": 0, - "key": 1530525000000, - "key_as_string": "2018-07-02T09:50:00.000Z", - "lower": Object { - "value": null, - }, - "upper": Object { - "value": null, - }, - }, - Object { - "anomaly_score": Object { - "value": 0, - }, - "doc_count": 2, - "key": 1530525500000, - "key_as_string": "2018-07-02T09:58:20.000Z", - "lower": Object { - "value": 16034.081569306454, - }, - "upper": Object { - "value": 54158.77731018045, - }, - }, - Object { - "anomaly_score": Object { - "value": null, - }, - "doc_count": 0, - "key": 1530526000000, - "key_as_string": "2018-07-02T10:06:40.000Z", - "lower": Object { - "value": null, - }, - "upper": Object { - "value": null, - }, - }, - Object { - "anomaly_score": Object { - "value": 0, - }, - "doc_count": 2, - "key": 1530526500000, - "key_as_string": "2018-07-02T10:15:00.000Z", - "lower": Object { - "value": 16034.081569306454, - }, - "upper": Object { - "value": 54158.77731018045, - }, - }, -] -`; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts deleted file mode 100644 index 7ded075a7ae65..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// @ts-ignore -import { getAnomalyAggs } from '../get_anomaly_aggs'; - -test('getAnomalyAggs should swallow HTTP errors', () => { - const httpError = new Error('anomaly lookup failed') as any; - httpError.statusCode = 418; - const failClient = jest.fn(() => Promise.reject(httpError)); - - return expect(getAnomalyAggs({ client: failClient })).resolves.toEqual(null); -}); - -test('getAnomalyAggs should throw other errors', () => { - const otherError = new Error('anomaly lookup ASPLODED') as any; - const failClient = jest.fn(() => Promise.reject(otherError)); - - return expect( - getAnomalyAggs({ - client: failClient - }) - ).rejects.toThrow(otherError); -}); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/mockData/firstBucketsResponse.json b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/mockData/firstBucketsResponse.json deleted file mode 100644 index 08851e34c86f2..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/mockData/firstBucketsResponse.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "took": 22, - "timed_out": false, - "_shards": { - "total": 5, - "successful": 5, - "skipped": 0, - "failed": 0 - }, - "hits": { - "total": 2, - "max_score": 0, - "hits": [] - }, - "aggregations": { - "ml_avg_response_times": { - "buckets": [ - { - "key_as_string": "2018-07-02T09:00:00.000Z", - "key": 1530522000000, - "doc_count": 0, - "anomaly_score": { - "value": null - }, - "upper": { - "value": null - }, - "lower": { - "value": null - } - }, - { - "key_as_string": "2018-07-02T09:08:20.000Z", - "key": 1530522500000, - "doc_count": 2, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 50381.01051622894 - }, - "lower": { - "value": 17688.182675688193 - } - }, - { - "key_as_string": "2018-07-02T09:16:40.000Z", - "key": 1530523000000, - "doc_count": 0, - "anomaly_score": { - "value": null - }, - "upper": { - "value": null - }, - "lower": { - "value": null - } - } - ] - }, - "top_hits": { - "hits": { - "total": 2, - "max_score": null, - "hits": [ - { - "_index": ".ml-anomalies-shared", - "_type": "doc", - "_id": "opbeans-node-request-high_mean_response_time_model_plot_1530522900000_900_0_29791_0", - "_score": null, - "_source": { - "bucket_span": 900 - }, - "sort": [ - 900 - ] - } - ] - } - } - } -} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/mockData/mainBucketsResponse.json b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/mockData/mainBucketsResponse.json deleted file mode 100644 index 4c32ff9108ed1..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/mockData/mainBucketsResponse.json +++ /dev/null @@ -1,152 +0,0 @@ -{ - "took": 3, - "timed_out": false, - "_shards": { - "total": 5, - "successful": 5, - "skipped": 0, - "failed": 0 - }, - "hits": { - "total": 10, - "max_score": 0, - "hits": [] - }, - "aggregations": { - "ml_avg_response_times": { - "buckets": [ - { - "key_as_string": "2018-07-02T09:16:40.000Z", - "key": 1530523000000, - "doc_count": 0, - "anomaly_score": { - "value": null - }, - "upper": { - "value": null - }, - "lower": { - "value": null - } - }, - { - "key_as_string": "2018-07-02T09:25:00.000Z", - "key": 1530523500000, - "doc_count": 4, - "anomaly_score": { - "value": null - }, - "upper": { - "value": null - }, - "lower": { - "value": null - } - }, - { - "key_as_string": "2018-07-02T09:33:20.000Z", - "key": 1530524000000, - "doc_count": 0, - "anomaly_score": { - "value": null - }, - "upper": { - "value": null - }, - "lower": { - "value": null - } - }, - { - "key_as_string": "2018-07-02T09:41:40.000Z", - "key": 1530524500000, - "doc_count": 2, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 54158.77731018045 - }, - "lower": { - "value": 16034.081569306454 - } - }, - { - "key_as_string": "2018-07-02T09:50:00.000Z", - "key": 1530525000000, - "doc_count": 0, - "anomaly_score": { - "value": null - }, - "upper": { - "value": null - }, - "lower": { - "value": null - } - }, - { - "key_as_string": "2018-07-02T09:58:20.000Z", - "key": 1530525500000, - "doc_count": 2, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 54158.77731018045 - }, - "lower": { - "value": 16034.081569306454 - } - }, - { - "key_as_string": "2018-07-02T10:06:40.000Z", - "key": 1530526000000, - "doc_count": 0, - "anomaly_score": { - "value": null - }, - "upper": { - "value": null - }, - "lower": { - "value": null - } - }, - { - "key_as_string": "2018-07-02T10:15:00.000Z", - "key": 1530526500000, - "doc_count": 2, - "anomaly_score": { - "value": 0 - }, - "upper": { - "value": 54158.77731018045 - }, - "lower": { - "value": 16034.081569306454 - } - } - ] - }, - "top_hits": { - "hits": { - "total": 2, - "max_score": null, - "hits": [ - { - "_index": ".ml-anomalies-shared", - "_type": "doc", - "_id": - "opbeans-node-request-high_mean_response_time_model_plot_1530522900000_900_0_29791_0", - "_score": null, - "_source": { - "bucket_span": 900 - }, - "sort": [900] - } - ] - } - } - } -} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/__snapshots__/fetcher.test.ts.snap b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/__snapshots__/fetcher.test.ts.snap new file mode 100644 index 0000000000000..f3436641f3f1a --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/__snapshots__/fetcher.test.ts.snap @@ -0,0 +1,73 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`anomalyAggsFetcher when ES returns valid response should call client with correct query 1`] = ` +Array [ + Array [ + "search", + Object { + "body": Object { + "aggs": Object { + "ml_avg_response_times": Object { + "aggs": Object { + "anomaly_score": Object { + "max": Object { + "field": "anomaly_score", + }, + }, + "lower": Object { + "min": Object { + "field": "model_lower", + }, + }, + "upper": Object { + "max": Object { + "field": "model_upper", + }, + }, + }, + "date_histogram": Object { + "extended_bounds": Object { + "max": 1, + "min": 0, + }, + "field": "timestamp", + "interval": "myInterval", + "min_doc_count": 0, + }, + }, + "top_hits": Object { + "top_hits": Object { + "_source": Object { + "includes": Array [ + "bucket_span", + ], + }, + "size": 1, + "sort": Array [ + "bucket_span", + ], + }, + }, + }, + "query": Object { + "bool": Object { + "filter": Array [ + Object { + "range": Object { + "timestamp": Object { + "format": "epoch_millis", + "gte": 0, + "lte": 1, + }, + }, + }, + ], + }, + }, + "size": 0, + }, + "index": ".ml-anomalies-myservicename-mytransactiontype-high_mean_response_time", + }, + ], +] +`; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/__snapshots__/transform.test.ts.snap b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/__snapshots__/transform.test.ts.snap new file mode 100644 index 0000000000000..1eeac5ae02e5e --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/__snapshots__/transform.test.ts.snap @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`anomalyAggsTransform should match snapshot 1`] = ` +Object { + "bucketSize": 900, + "buckets": Array [ + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": 0, + "lower": 16034.081569306454, + "upper": 54158.77731018045, + }, + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": 0, + "lower": 16034.081569306454, + "upper": 54158.77731018045, + }, + Object { + "anomalyScore": null, + "lower": null, + "upper": null, + }, + Object { + "anomalyScore": 0, + "lower": 16034.081569306454, + "upper": 54158.77731018045, + }, + ], +} +`; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/fetcher.test.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/fetcher.test.ts new file mode 100644 index 0000000000000..7eaf84be12e79 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/fetcher.test.ts @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { anomalyAggsFetcher, ESResponse } from './fetcher'; + +describe('anomalyAggsFetcher', () => { + describe('when ES returns valid response', () => { + let response: ESResponse; + let clientSpy: jest.Mock; + + beforeEach(async () => { + clientSpy = jest.fn().mockReturnValue('ES Response'); + response = await anomalyAggsFetcher({ + serviceName: 'myServiceName', + transactionType: 'myTransactionType', + intervalString: 'myInterval', + client: clientSpy, + start: 0, + end: 1 + }); + }); + + it('should call client with correct query', () => { + expect(clientSpy.mock.calls).toMatchSnapshot(); + }); + + it('should return correct response', () => { + expect(response).toBe('ES Response'); + }); + }); + + it('should swallow HTTP errors', () => { + const httpError = new Error('anomaly lookup failed') as any; + httpError.statusCode = 418; + const failClient = jest.fn(() => Promise.reject(httpError)); + + return expect( + anomalyAggsFetcher({ client: failClient } as any) + ).resolves.toEqual(null); + }); + + it('should throw other errors', () => { + const otherError = new Error('anomaly lookup ASPLODED') as any; + const failClient = jest.fn(() => Promise.reject(otherError)); + + return expect( + anomalyAggsFetcher({ + client: failClient + } as any) + ).rejects.toThrow(otherError); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/fetcher.ts similarity index 61% rename from x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs.js rename to x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/fetcher.ts index cae78df06f725..eeb1fc32b8f68 100644 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs.js +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/fetcher.ts @@ -4,14 +4,53 @@ * you may not use this file except in compliance with the Elastic License. */ -export async function getAnomalyAggs({ +import { AggregationSearchResponse } from 'elasticsearch'; +import { TopHits } from 'x-pack/plugins/apm/typings/elasticsearch'; +import { ESClient } from '../../../../helpers/setup_request'; + +export interface IOptions { + serviceName: string; + transactionType: string; + intervalString: string; + client: ESClient; + start: number; + end: number; +} + +interface Bucket { + key_as_string: string; + key: number; + doc_count: number; + anomaly_score: { + value: number | null; + }; + lower: { + value: number | null; + }; + upper: { + value: number | null; + }; +} + +interface Aggs { + ml_avg_response_times: { + buckets: Bucket[]; + }; + top_hits: TopHits<{ + bucket_span: number; + }>; +} + +export type ESResponse = AggregationSearchResponse | null; + +export async function anomalyAggsFetcher({ serviceName, transactionType, intervalString, client, start, end -}) { +}: IOptions): Promise { const params = { index: `.ml-anomalies-${serviceName}-${transactionType}-high_mean_response_time`.toLowerCase(), body: { @@ -60,15 +99,12 @@ export async function getAnomalyAggs({ }; try { - const resp = await client('search', params); - return resp.aggregations; + return await client('search', params); } catch (err) { - if ('statusCode' in err) { - // swallow HTTP errors because there are lots of reasons - // the ml index lookup may fail, and we're ok with that + const isHttpError = 'statusCode' in err; + if (isHttpError) { return null; } - throw err; } } diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/index.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/index.ts new file mode 100644 index 0000000000000..c3df288527442 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { anomalyAggsFetcher, IOptions } from './fetcher'; +import { anomalyAggsTransform } from './transform'; + +export async function getAnomalyAggs(options: IOptions) { + const response = await anomalyAggsFetcher(options); + return anomalyAggsTransform(response); +} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform.test.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform.test.ts new file mode 100644 index 0000000000000..1b1dbf8848cfc --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform.test.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { mainBucketsResponse } from '../mock-responses/mainBucketsResponse'; +import { anomalyAggsTransform } from './transform'; + +describe('anomalyAggsTransform', () => { + it('should return null if response is empty', () => { + expect(anomalyAggsTransform(null)).toBe(null); + }); + + it('should match snapshot', () => { + expect(anomalyAggsTransform(mainBucketsResponse)).toMatchSnapshot(); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform.ts new file mode 100644 index 0000000000000..d6ebb3ba7a3a7 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_anomaly_aggs/transform.ts @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { oc } from 'ts-optchain'; +import { ESResponse } from './fetcher'; + +export interface AvgAnomalyBucket { + anomalyScore: number | null; + lower: number | null; + upper: number | null; +} + +export function anomalyAggsTransform(response: ESResponse) { + if (!response) { + return null; + } + + const buckets = oc(response) + .aggregations.ml_avg_response_times.buckets([]) + .map(bucket => { + return { + anomalyScore: bucket.anomaly_score.value, + lower: bucket.lower.value, + upper: bucket.upper.value + }; + }); + + return { + buckets, + bucketSize: oc( + response + ).aggregations.top_hits.hits.hits[0]._source.bucket_span(0) + }; +} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.js deleted file mode 100644 index 5d71559232445..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { last, get } from 'lodash'; -import { getAnomalyAggs } from './get_anomaly_aggs'; - -export async function getBucketWithInitialAnomalyBounds({ - serviceName, - transactionType, - client, - start, - mainBuckets, - anomalyBucketSpan -}) { - // abort if first bucket already has values for initial anomaly bounds - if (mainBuckets[0].lower.value || !anomalyBucketSpan) { - return mainBuckets; - } - - const newStart = start - anomalyBucketSpan * 1000; - const newEnd = start; - - const aggs = await getAnomalyAggs({ - serviceName, - transactionType, - intervalString: `${anomalyBucketSpan}s`, - client, - start: newStart, - end: newEnd - }); - - const firstBucketWithBounds = last( - get(aggs, 'ml_avg_response_times.buckets', []).filter( - bucket => bucket.lower.value - ) - ); - - return mainBuckets.map((bucket, i) => { - // replace first item - if (i === 0 && firstBucketWithBounds) { - return { - ...bucket, - upper: { value: firstBucketWithBounds.upper.value }, - lower: { value: firstBucketWithBounds.lower.value } - }; - } - return bucket; - }); -} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_buckets_with_initial_anomaly_bounds.test.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.test.ts similarity index 55% rename from x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_buckets_with_initial_anomaly_bounds.test.js rename to x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.test.ts index e8b37ee490642..f1fb18e2a035a 100644 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_buckets_with_initial_anomaly_bounds.test.js +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.test.ts @@ -4,24 +4,34 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getBucketWithInitialAnomalyBounds } from '../get_buckets_with_initial_anomaly_bounds'; -import mainBucketsResponse from './mockData/mainBucketsResponse'; -import firstBucketsResponse from './mockData/firstBucketsResponse'; +import { getAnomalyAggs } from './get_anomaly_aggs'; +import { AvgAnomalyBucket } from './get_anomaly_aggs/transform'; +import { getBucketWithInitialAnomalyBounds } from './get_buckets_with_initial_anomaly_bounds'; +import { firstBucketsResponse } from './mock-responses/firstBucketsResponse'; +import { mainBucketsResponse } from './mock-responses/mainBucketsResponse'; describe('get_buckets_with_initial_anomaly_bounds', () => { - const mainBuckets = - mainBucketsResponse.aggregations.ml_avg_response_times.buckets; - let buckets; + let buckets: AvgAnomalyBucket[]; + let mainBuckets: AvgAnomalyBucket[]; beforeEach(async () => { + const response = await getAnomalyAggs({ + serviceName: 'myServiceName', + transactionType: 'myTransactionType', + intervalString: '', + client: () => mainBucketsResponse as any, + start: 0, + end: 1 + }); + + mainBuckets = response!.buckets; buckets = await getBucketWithInitialAnomalyBounds({ serviceName: 'myServiceName', transactionType: 'myTransactionType', - intervalString: '60s', start: 1530523322742, - client: () => firstBucketsResponse, - mainBuckets, - anomalyBucketSpan: 900 + client: () => firstBucketsResponse as any, + buckets: mainBuckets, + bucketSize: 900 }); }); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.ts new file mode 100644 index 0000000000000..a56b656671672 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_buckets_with_initial_anomaly_bounds.ts @@ -0,0 +1,66 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { last } from 'lodash'; +import { ESClient } from '../../../helpers/setup_request'; +import { getAnomalyAggs } from './get_anomaly_aggs'; +import { AvgAnomalyBucket } from './get_anomaly_aggs/transform'; + +interface Props { + serviceName: string; + transactionType: string; + buckets: AvgAnomalyBucket[]; + bucketSize: number; + start: number; + client: ESClient; +} + +export async function getBucketWithInitialAnomalyBounds({ + serviceName, + transactionType, + buckets, + bucketSize, + start, + client +}: Props) { + // abort if first bucket already has values for initial anomaly bounds + if (buckets[0].lower || !bucketSize) { + return buckets; + } + + const newStart = start - bucketSize * 1000; + const newEnd = start; + + const aggs = await getAnomalyAggs({ + serviceName, + transactionType, + intervalString: `${bucketSize}s`, + client, + start: newStart, + end: newEnd + }); + + if (!aggs) { + return buckets; + } + + const firstBucketWithBounds = last( + aggs.buckets.filter(bucket => bucket.lower) + ); + + if (!firstBucketWithBounds) { + return buckets; + } + + return replaceFirstItem(buckets, firstBucketWithBounds); +} + +// copy array and replace first item +function replaceFirstItem(array: T[], value: T) { + const ret = array.slice(0); + ret[0] = value; + return ret; +} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_avg_response_time_anomalies.test.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/index.test.ts similarity index 66% rename from x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_avg_response_time_anomalies.test.js rename to x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/index.test.ts index c44c5ffe4fc80..468c2c7e3a074 100644 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_avg_response_time_anomalies.test.js +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/index.test.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getAvgResponseTimeAnomalies } from '../get_avg_response_time_anomalies'; -import mainBucketsResponse from './mockData/mainBucketsResponse'; -import firstBucketsResponse from './mockData/firstBucketsResponse'; +import { getAvgResponseTimeAnomalies } from '.'; +import { firstBucketsResponse } from './mock-responses/firstBucketsResponse'; +import { mainBucketsResponse } from './mock-responses/mainBucketsResponse'; describe('get_avg_response_time_anomalies', () => { it('', async () => { @@ -23,32 +23,32 @@ describe('get_avg_response_time_anomalies', () => { end: 1528977600000, client: clientSpy, config: { - get: () => 'myIndex' + get: () => 'myIndex' as any } } }); expect(avgAnomalies).toEqual({ - bucketSpanAsMillis: 10800000, + bucketSizeAsMillis: 10800000, buckets: [ { - anomaly_score: null, + anomalyScore: 0, lower: 17688.182675688193, upper: 50381.01051622894 }, - { anomaly_score: null, lower: null, upper: null }, + { anomalyScore: null, lower: null, upper: null }, { - anomaly_score: 0, + anomalyScore: 0, lower: 16034.081569306454, upper: 54158.77731018045 }, - { anomaly_score: null, lower: null, upper: null }, + { anomalyScore: null, lower: null, upper: null }, { - anomaly_score: 0, + anomalyScore: 0, lower: 16034.081569306454, upper: 54158.77731018045 }, - { anomaly_score: null, lower: null, upper: null } + { anomalyScore: null, lower: null, upper: null } ] }); }); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_avg_response_time_anomalies.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/index.ts similarity index 54% rename from x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_avg_response_time_anomalies.js rename to x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/index.ts index 3e950d919b6cc..31ee4a9d1a6d7 100644 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/get_avg_response_time_anomalies.js +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/index.ts @@ -4,23 +4,31 @@ * you may not use this file except in compliance with the Elastic License. */ -import { get } from 'lodash'; import { getBucketSize } from '../../../helpers/get_bucket_size'; +import { IOptions } from '../get_timeseries_data'; import { getAnomalyAggs } from './get_anomaly_aggs'; +import { AvgAnomalyBucket } from './get_anomaly_aggs/transform'; import { getBucketWithInitialAnomalyBounds } from './get_buckets_with_initial_anomaly_bounds'; +export interface IAvgAnomalies { + bucketSizeAsMillis: number; + buckets: AvgAnomalyBucket[]; +} + +export type IAvgAnomaliesResponse = IAvgAnomalies | undefined; + export async function getAvgResponseTimeAnomalies({ serviceName, transactionType, transactionName, setup -}) { +}: IOptions): Promise { const { start, end, client } = setup; const { intervalString, bucketSize } = getBucketSize(start, end, 'auto'); // don't fetch anomalies for transaction details page if (transactionName) { - return []; + return; } const aggs = await getAnomalyAggs({ @@ -33,42 +41,20 @@ export async function getAvgResponseTimeAnomalies({ }); if (!aggs) { - return { - message: 'Error reading machine learning index' - }; + return; } - const anomalyBucketSpan = get( - aggs, - 'top_hits.hits.hits[0]._source.bucket_span' - ); - - const mainBuckets = get(aggs, 'ml_avg_response_times.buckets', []).slice( - 1, - -1 - ); - - const bucketsWithInitialAnomalyBounds = await getBucketWithInitialAnomalyBounds( - { - serviceName, - transactionType, - client, - start, - mainBuckets, - anomalyBucketSpan - } - ); - - const buckets = bucketsWithInitialAnomalyBounds.map(bucket => { - return { - anomaly_score: bucket.anomaly_score.value, - lower: bucket.lower.value, - upper: bucket.upper.value - }; + const buckets = await getBucketWithInitialAnomalyBounds({ + serviceName, + transactionType, + buckets: aggs.buckets.slice(1, -1), + bucketSize: aggs.bucketSize, + start, + client }); return { - bucketSpanAsMillis: Math.max(bucketSize, anomalyBucketSpan) * 1000, - buckets + buckets, + bucketSizeAsMillis: Math.max(bucketSize, aggs.bucketSize) * 1000 }; } diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/mock-responses/firstBucketsResponse.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/mock-responses/firstBucketsResponse.ts new file mode 100644 index 0000000000000..d23807764af85 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/mock-responses/firstBucketsResponse.ts @@ -0,0 +1,89 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ESResponse } from '../get_anomaly_aggs/fetcher'; + +export const firstBucketsResponse: ESResponse = { + took: 22, + timed_out: false, + _shards: { + total: 5, + successful: 5, + skipped: 0, + failed: 0 + }, + hits: { + total: 2, + max_score: 0, + hits: [] + }, + aggregations: { + ml_avg_response_times: { + buckets: [ + { + key_as_string: '2018-07-02T09:00:00.000Z', + key: 1530522000000, + doc_count: 0, + anomaly_score: { + value: null + }, + upper: { + value: null + }, + lower: { + value: null + } + }, + { + key_as_string: '2018-07-02T09:08:20.000Z', + key: 1530522500000, + doc_count: 2, + anomaly_score: { + value: 0 + }, + upper: { + value: 50381.01051622894 + }, + lower: { + value: 17688.182675688193 + } + }, + { + key_as_string: '2018-07-02T09:16:40.000Z', + key: 1530523000000, + doc_count: 0, + anomaly_score: { + value: null + }, + upper: { + value: null + }, + lower: { + value: null + } + } + ] + }, + top_hits: { + hits: { + total: 2, + max_score: 0, + hits: [ + { + _index: '.ml-anomalies-shared', + _type: 'doc', + _id: + 'opbeans-node-request-high_mean_response_time_model_plot_1530522900000_900_0_29791_0', + _score: 0, + _source: { + bucket_span: 900 + } + } + ] + } + } + } +}; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/mock-responses/mainBucketsResponse.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/mock-responses/mainBucketsResponse.ts new file mode 100644 index 0000000000000..21983541af24b --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_avg_response_time_anomalies/mock-responses/mainBucketsResponse.ts @@ -0,0 +1,159 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ESResponse } from '../get_anomaly_aggs/fetcher'; + +export const mainBucketsResponse: ESResponse = { + took: 3, + timed_out: false, + _shards: { + total: 5, + successful: 5, + skipped: 0, + failed: 0 + }, + hits: { + total: 10, + max_score: 0, + hits: [] + }, + aggregations: { + ml_avg_response_times: { + buckets: [ + { + key_as_string: '2018-07-02T09:16:40.000Z', + key: 1530523000000, + doc_count: 0, + anomaly_score: { + value: null + }, + upper: { + value: null + }, + lower: { + value: null + } + }, + { + key_as_string: '2018-07-02T09:25:00.000Z', + key: 1530523500000, + doc_count: 4, + anomaly_score: { + value: null + }, + upper: { + value: null + }, + lower: { + value: null + } + }, + { + key_as_string: '2018-07-02T09:33:20.000Z', + key: 1530524000000, + doc_count: 0, + anomaly_score: { + value: null + }, + upper: { + value: null + }, + lower: { + value: null + } + }, + { + key_as_string: '2018-07-02T09:41:40.000Z', + key: 1530524500000, + doc_count: 2, + anomaly_score: { + value: 0 + }, + upper: { + value: 54158.77731018045 + }, + lower: { + value: 16034.081569306454 + } + }, + { + key_as_string: '2018-07-02T09:50:00.000Z', + key: 1530525000000, + doc_count: 0, + anomaly_score: { + value: null + }, + upper: { + value: null + }, + lower: { + value: null + } + }, + { + key_as_string: '2018-07-02T09:58:20.000Z', + key: 1530525500000, + doc_count: 2, + anomaly_score: { + value: 0 + }, + upper: { + value: 54158.77731018045 + }, + lower: { + value: 16034.081569306454 + } + }, + { + key_as_string: '2018-07-02T10:06:40.000Z', + key: 1530526000000, + doc_count: 0, + anomaly_score: { + value: null + }, + upper: { + value: null + }, + lower: { + value: null + } + }, + { + key_as_string: '2018-07-02T10:15:00.000Z', + key: 1530526500000, + doc_count: 2, + anomaly_score: { + value: 0 + }, + upper: { + value: 54158.77731018045 + }, + lower: { + value: 16034.081569306454 + } + } + ] + }, + top_hits: { + hits: { + total: 2, + max_score: 0, + hits: [ + { + _index: '.ml-anomalies-shared', + _type: 'doc', + _id: + 'opbeans-node-request-high_mean_response_time_model_plot_1530522900000_900_0_29791_0', + _score: 0, + _source: { + bucket_span: 900 + } + } + ] + } + } + } +}; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/__snapshots__/fetcher.test.ts.snap b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/__snapshots__/fetcher.test.ts.snap new file mode 100644 index 0000000000000..6e55d560a8931 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/__snapshots__/fetcher.test.ts.snap @@ -0,0 +1,93 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`timeseriesFetcher should call client with correct query 1`] = ` +Array [ + Array [ + "search", + Object { + "body": Object { + "aggs": Object { + "overall_avg_duration": Object { + "avg": Object { + "field": "transaction.duration.us", + }, + }, + "response_times": Object { + "aggs": Object { + "avg": Object { + "avg": Object { + "field": "transaction.duration.us", + }, + }, + "pct": Object { + "percentiles": Object { + "field": "transaction.duration.us", + "percents": Array [ + 95, + 99, + ], + }, + }, + }, + "date_histogram": Object { + "extended_bounds": Object { + "max": 1528977600000, + "min": 1528113600000, + }, + "field": "@timestamp", + "interval": "10800s", + "min_doc_count": 0, + }, + }, + "transaction_results": Object { + "aggs": Object { + "timeseries": Object { + "date_histogram": Object { + "extended_bounds": Object { + "max": 1528977600000, + "min": 1528113600000, + }, + "field": "@timestamp", + "interval": "10800s", + "min_doc_count": 0, + }, + }, + }, + "terms": Object { + "field": "transaction.result", + "missing": "transaction_result_missing", + }, + }, + }, + "query": Object { + "bool": Object { + "filter": Array [ + Object { + "term": Object { + "context.service.name": "myServiceName", + }, + }, + Object { + "term": Object { + "transaction.type": "myTransactionType", + }, + }, + Object { + "range": Object { + "@timestamp": Object { + "format": "epoch_millis", + "gte": 1528113600000, + "lte": 1528977600000, + }, + }, + }, + ], + }, + }, + "size": 0, + }, + "index": "myIndex", + }, + ], +] +`; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/__snapshots__/transform.test.ts.snap b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/__snapshots__/transform.test.ts.snap new file mode 100644 index 0000000000000..d94348c4f8513 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/__snapshots__/transform.test.ts.snap @@ -0,0 +1,682 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`timeseriesTransformer should match snapshot 1`] = ` +Object { + "dates": Array [ + 1528124400000, + 1528135200000, + 1528146000000, + 1528156800000, + 1528167600000, + 1528178400000, + 1528189200000, + 1528200000000, + 1528210800000, + 1528221600000, + 1528232400000, + 1528243200000, + 1528254000000, + 1528264800000, + 1528275600000, + 1528286400000, + 1528297200000, + 1528308000000, + 1528318800000, + 1528329600000, + 1528340400000, + 1528351200000, + 1528362000000, + 1528372800000, + 1528383600000, + 1528394400000, + 1528405200000, + 1528416000000, + 1528426800000, + 1528437600000, + 1528448400000, + 1528459200000, + 1528470000000, + 1528480800000, + 1528491600000, + 1528502400000, + 1528513200000, + 1528524000000, + 1528534800000, + 1528545600000, + 1528556400000, + 1528567200000, + 1528578000000, + 1528588800000, + 1528599600000, + 1528610400000, + 1528621200000, + 1528632000000, + 1528642800000, + 1528653600000, + 1528664400000, + 1528675200000, + 1528686000000, + 1528696800000, + 1528707600000, + 1528718400000, + 1528729200000, + 1528740000000, + 1528750800000, + 1528761600000, + 1528772400000, + 1528783200000, + 1528794000000, + 1528804800000, + 1528815600000, + 1528826400000, + 1528837200000, + 1528848000000, + 1528858800000, + 1528869600000, + 1528880400000, + 1528891200000, + 1528902000000, + 1528912800000, + 1528923600000, + 1528934400000, + 1528945200000, + 1528956000000, + 1528966800000, + ], + "overallAvgDuration": 32861.15660262639, + "responseTimes": Object { + "avg": Array [ + 26193.277795595466, + 25291.787065995228, + 24690.306474667796, + 24809.8953814219, + 25460.0394764508, + 26360.440733498916, + 27050.95205479452, + 26555.857333903925, + 26164.343359049206, + 26989.84546419098, + 26314.409430068266, + 27460.774575018477, + 26461.469107431974, + 27657.584946692834, + 27940.445967005213, + 34454.377581534434, + 44024.31809353839, + 36374.53333333333, + 36991.29442471209, + 37178.002701986756, + 37605.57078923814, + 37319.89767295267, + 38709.5041348433, + 38140.131856255066, + 34564.81091043125, + 33256.37743828302, + 37251.5625266752, + 38681.89084929791, + 40677.801045709355, + 39987.86453616932, + 41059.392914139804, + 39630.710111535845, + 41561.81331074284, + 43079.490738297536, + 43925.39609283509, + 25821.91424646782, + 27343.60011755486, + 25249.95060523233, + 25492.77199074074, + 25991.647281682137, + 26273.31290445375, + 26234.98976780795, + 23494.54873786408, + 22008.80482069371, + 22828.136655635586, + 22138.7081404321, + 22634.985579811735, + 22202.780998080616, + 23084.082780163997, + 23109.666146341464, + 23306.89028152719, + 39341.022704095325, + 37467.17153341258, + 52457.50554180566, + 31327.95780166252, + 30695.334941163997, + 28895.042785967435, + 30649.363989982416, + 29802.63622014101, + 30759.03002829892, + 30399.76549608631, + 29421.610233534506, + 32641.679897096656, + 30621.65440666204, + 31039.60391005818, + 30954.760723541545, + 31902.050234568553, + 31594.350653473728, + 31343.87243248879, + 31200.14450867052, + 28560.946668743833, + 24700.216146371717, + 25261.025210523563, + 26041.39789649068, + 26123.556295209142, + 46231.36177177638, + 45350.42005506141, + 48256.049354513096, + 52360.30017052116, + ], + "avgAnomalies": undefined, + "p95": Array [ + 80738.78571428556, + 77058.03529411761, + 77892.20721980717, + 77085.86687499998, + 80048.3462981744, + 84089.21370223971, + 84880.90143416924, + 84554.8884781166, + 81839.39583333326, + 85993.55410163336, + 85001.44588628765, + 86980.16445312503, + 84961.8710743802, + 88906.54601889332, + 90198.34708994703, + 135627.71242424246, + 167037.1993837535, + 128293.12184873945, + 130653.54236263742, + 131630.8902645502, + 133581.33541666638, + 132697.92762266204, + 140003.6918918918, + 138149.5673529411, + 121872.37504835591, + 116378.03873517792, + 131545.40999999995, + 133111.25804878055, + 144821.9855278593, + 134737.3997727272, + 141206.57726666646, + 137731.8994082841, + 141476.23189033198, + 149636.31340909077, + 151934.55000000002, + 82198.17857142858, + 85946.43199999983, + 78617.66249999996, + 79606.48333333322, + 76297.93999999986, + 80742.63333333324, + 81291.45969696966, + 73467.02500000004, + 69177.66999999993, + 71956.06111111109, + 68480.91142857139, + 68957.0999999999, + 67489.50416666668, + 71556.91249999998, + 72157.65128205132, + 76124.5625, + 141709.34661835746, + 132371.48641975303, + 186783.51503759398, + 99540.17819499348, + 95982.62454212455, + 89559.3525925925, + 95769.83153735634, + 94063.90833755062, + 96399.67269119772, + 96436.42520161276, + 91860.16988095238, + 105989.8333333334, + 97937.60342555979, + 98967.2249999999, + 97561.02469135808, + 102557.78813357186, + 100137.87578595306, + 98412.97120445351, + 101607.8328012912, + 92000.51368421057, + 78027.29473684198, + 80762.078801789, + 81160.83425925927, + 84215.58945578222, + 194188.21428571426, + 172616.2293896504, + 182653.81858220184, + 194970.75667682925, + ], + "p99": Array [ + 293257.27333333343, + 290195.8800000004, + 278548.1649999994, + 290701.8973333341, + 286839.5897777779, + 287979.5149999999, + 300107.5009999992, + 294402.2179999999, + 289849.459333332, + 296942.86299999955, + 292048.20571428596, + 299308.7371666667, + 292151.2377777781, + 302274.4192592592, + 299457.1612121209, + 350398.59259259375, + 421204.23333333334, + 368166.68976190523, + 367193.6128571426, + 375658.10190476174, + 368152.03822222137, + 365705.8319999995, + 380075.48533333326, + 375697.1923809518, + 351080.94111111073, + 339294.12799999997, + 378902.90649999987, + 384483.3233333327, + 394692.25000000105, + 403362.50399999996, + 396559.0274999993, + 371815.8320000008, + 405477.6133333326, + 413542.18133333366, + 424399.340000001, + 303815.9000000001, + 306305.0800000006, + 297521.94999999984, + 317938.0900000003, + 312262.3000000003, + 318428.8700000002, + 295421.4099999999, + 293067.86000000004, + 264935.71999999933, + 282795.0400000003, + 285390.8400000001, + 290402.24, + 293655.53, + 292723.56999999995, + 301051.32000000105, + 291322.0499999998, + 379855.2444444447, + 371175.2592000001, + 498378.4238888898, + 331118.6599999997, + 328101.3999999988, + 313951.54249999986, + 323340.5274074075, + 315055.5047619052, + 330070.03599999985, + 320531.54416666675, + 315137.16628571344, + 337251.4042424246, + 327054.9243636365, + 327653.0000000006, + 324505.1399999999, + 338040.3999999998, + 328600.5173333335, + 334060.93628571345, + 328569.4964999998, + 320227.32399999973, + 292019.2899999998, + 297757.72666666657, + 308034.4466666669, + 301128.4895238093, + 447266.9, + 409147.332500001, + 423121.9773333328, + 473485.4199999998, + ], + }, + "totalHits": 1297673, + "tpmBuckets": Array [ + Object { + "avg": 70293.29113924051, + "key": "HTTP 2xx", + "values": Array [ + 81460, + 82320, + 82485, + 83995, + 82805, + 82155, + 81915, + 81475, + 83510, + 82345, + 82330, + 82755, + 83375, + 82050, + 81235, + 75725, + 80890, + 82650, + 81055, + 82265, + 82515, + 83020, + 82610, + 80820, + 82600, + 82670, + 81555, + 83350, + 80960, + 82895, + 81650, + 82825, + 82715, + 82460, + 82020, + 22640, + 22785, + 22830, + 22930, + 23360, + 23425, + 22605, + 23060, + 22675, + 23030, + 23070, + 22535, + 23055, + 22935, + 22910, + 23075, + 81255, + 84125, + 81440, + 82460, + 82170, + 85015, + 81820, + 83225, + 83475, + 82490, + 82940, + 83425, + 81805, + 83290, + 82535, + 82090, + 82385, + 83775, + 82970, + 84060, + 84315, + 83275, + 83615, + 82885, + 75625, + 82160, + 82320, + 81845, + ], + }, + Object { + "avg": 420.88607594936707, + "key": "HTTP 3xx", + "values": Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 20205, + 2270, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 10775, + 0, + 0, + 0, + ], + }, + Object { + "avg": 5108.9240506329115, + "key": "HTTP 4xx", + "values": Array [ + 6065, + 6025, + 5810, + 6190, + 5955, + 6370, + 6170, + 5820, + 6165, + 6115, + 6080, + 6000, + 6185, + 6155, + 5910, + 5625, + 6215, + 6235, + 5815, + 6100, + 6010, + 5960, + 6240, + 5945, + 6150, + 6030, + 5950, + 6160, + 5855, + 6160, + 6265, + 6250, + 5835, + 6290, + 5740, + 1420, + 1200, + 1365, + 1475, + 1405, + 1500, + 1320, + 1300, + 1395, + 1295, + 1455, + 1240, + 1555, + 1385, + 1395, + 1375, + 5835, + 6350, + 5815, + 5775, + 6085, + 6135, + 5970, + 5765, + 6055, + 6015, + 6345, + 5985, + 5920, + 5880, + 5810, + 6350, + 6120, + 6275, + 6035, + 6030, + 6270, + 6080, + 6315, + 6385, + 5915, + 6105, + 5990, + 6070, + ], + }, + Object { + "avg": 5115.632911392405, + "key": "HTTP 5xx", + "values": Array [ + 6015, + 5980, + 6150, + 6165, + 6360, + 6090, + 6085, + 6175, + 6245, + 5790, + 6075, + 5955, + 6175, + 6060, + 5900, + 5455, + 5880, + 6215, + 6040, + 6010, + 6440, + 6205, + 6075, + 5760, + 6205, + 5885, + 6215, + 6275, + 5945, + 5915, + 6075, + 6410, + 5885, + 5995, + 6170, + 1420, + 1535, + 1415, + 1515, + 1630, + 1345, + 1485, + 1390, + 1445, + 1360, + 1395, + 1190, + 1440, + 1290, + 1320, + 1480, + 6065, + 6270, + 5675, + 6200, + 6075, + 6195, + 6045, + 6040, + 5880, + 6035, + 5990, + 5825, + 5940, + 6225, + 6190, + 6415, + 5990, + 5860, + 6145, + 6195, + 6155, + 6240, + 6100, + 6120, + 5440, + 6175, + 5805, + 5915, + ], + }, + Object { + "avg": NaN, + "key": "A Custom Bucket (that should be last)", + "values": Array [], + }, + ], +} +`; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/fetcher.test.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/fetcher.test.ts new file mode 100644 index 0000000000000..a756185eda701 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/fetcher.test.ts @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ESResponse, timeseriesFetcher } from './fetcher'; + +describe('timeseriesFetcher', () => { + let res: ESResponse; + let clientSpy: jest.Mock; + beforeEach(async () => { + clientSpy = jest.fn().mockResolvedValueOnce('ES response'); + + res = await timeseriesFetcher({ + serviceName: 'myServiceName', + transactionType: 'myTransactionType', + transactionName: undefined, + setup: { + start: 1528113600000, + end: 1528977600000, + client: clientSpy, + config: { + get: () => 'myIndex' as any + } + } + }); + }); + + it('should call client with correct query', () => { + expect(clientSpy.mock.calls).toMatchSnapshot(); + }); + + it('should return correct response', () => { + expect(res).toBe('ES response'); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/fetcher.ts similarity index 52% rename from x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data.js rename to x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/fetcher.ts index 8a9c68c013336..7360114c1df8d 100644 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data.js +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/fetcher.ts @@ -4,28 +4,70 @@ * you may not use this file except in compliance with the Elastic License. */ +import { AggregationSearchResponse } from 'elasticsearch'; +import { IOptions } from '.'; import { + SERVICE_NAME, TRANSACTION_DURATION, + TRANSACTION_NAME, TRANSACTION_RESULT, - SERVICE_NAME, - TRANSACTION_TYPE, - TRANSACTION_NAME -} from '../../../../common/constants'; -import { get, sortBy, round } from 'lodash'; -import mean from 'lodash.mean'; -import { getBucketSize } from '../../helpers/get_bucket_size'; -import { getAvgResponseTimeAnomalies } from './get_avg_response_time_anomalies/get_avg_response_time_anomalies'; + TRANSACTION_TYPE +} from '../../../../../common/constants'; +import { getBucketSize } from '../../../helpers/get_bucket_size'; + +interface ResponseTimeBucket { + key_as_string: string; + key: number; + doc_count: number; + avg: { + value: number | null; + }; + pct: { + values: { + '95.0': number | 'NaN'; + '99.0': number | 'NaN'; + }; + }; +} + +interface TransactionResultBucket { + key: string; + doc_count: number; + timeseries: { + buckets: Array<{ + key_as_string: string; + key: number; + doc_count: number; + }>; + }; +} + +interface Aggs { + response_times: { + buckets: ResponseTimeBucket[]; + }; + transaction_results: { + doc_count_error_upper_bound: number; + sum_other_doc_count: number; + buckets: TransactionResultBucket[]; + }; + overall_avg_duration: { + value: number; + }; +} + +export type ESResponse = AggregationSearchResponse; -export async function getTimeseriesData({ +export function timeseriesFetcher({ serviceName, transactionType, transactionName, setup -}) { +}: IOptions): Promise { const { start, end, esFilterQuery, client, config } = setup; - const { intervalString, bucketSize } = getBucketSize(start, end, 'auto'); + const { intervalString } = getBucketSize(start, end, 'auto'); - const params = { + const params: any = { index: config.get('apm_oss.transactionIndices'), body: { size: 0, @@ -105,69 +147,5 @@ export async function getTimeseriesData({ ]; } - const resp = await client('search', params); - const responseTimeBuckets = get( - resp, - 'aggregations.response_times.buckets', - [] - ).slice(1, -1); - - const transactionResultBuckets = get( - resp, - 'aggregations.transaction_results.buckets', - [] - ); - - const overallAvgDuration = get( - resp, - 'aggregations.overall_avg_duration.value' - ); - const dates = responseTimeBuckets.map(bucket => bucket.key); - - const responseTime = responseTimeBuckets.reduce( - (acc, bucket) => { - const { '95.0': p95, '99.0': p99 } = bucket.pct.values; - - acc.avg.push(bucket.avg.value); - acc.p95.push(p95 >= 0 ? p95 : null); - acc.p99.push(p99 >= 0 ? p99 : null); - return acc; - }, - { avg: [], p95: [], p99: [] } - ); - - const tpmBuckets = sortBy( - transactionResultBuckets.map(({ key, timeseries }) => { - const tpmValues = timeseries.buckets - .slice(1, -1) - .map(bucket => round(bucket.doc_count * (60 / bucketSize), 1)); - - return { - key, - avg: mean(tpmValues), - values: tpmValues - }; - }), - bucket => bucket.key.replace(/^HTTP (\d)xx$/, '00$1') // ensure that HTTP 3xx are sorted at the top - ); - - const avgResponseTimesAnomalies = await getAvgResponseTimeAnomalies({ - serviceName, - transactionType, - transactionName, - setup - }); - - return { - total_hits: resp.hits.total, - dates: dates, - response_times: { - avg: responseTime.avg, - p95: responseTime.p95, - p99: responseTime.p99, - avg_anomalies: avgResponseTimesAnomalies - }, - tpm_buckets: tpmBuckets, - overall_avg_duration: overallAvgDuration || 0 - }; + return client('search', params); } diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/index.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/index.ts new file mode 100644 index 0000000000000..8327193d82111 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/index.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { getBucketSize } from '../../../helpers/get_bucket_size'; +import { Setup } from '../../../helpers/setup_request'; +import { getAvgResponseTimeAnomalies } from '../get_avg_response_time_anomalies'; +import { timeseriesFetcher } from './fetcher'; +import { timeseriesTransformer } from './transform'; + +export interface IOptions { + serviceName: string; + transactionType: string; + transactionName?: string; + setup: Setup; +} + +export async function getTimeseriesData(options: IOptions) { + const { start, end } = options.setup; + const { bucketSize } = getBucketSize(start, end, 'auto'); + + const avgAnomaliesResponse = await getAvgResponseTimeAnomalies(options); + const timeseriesResponse = await timeseriesFetcher(options); + return timeseriesTransformer({ + timeseriesResponse, + avgAnomaliesResponse, + bucketSize + }); +} diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/mock-responses/timeseries_response.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/mock-responses/timeseries_response.ts new file mode 100644 index 0000000000000..075ede23fb38e --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/mock-responses/timeseries_response.ts @@ -0,0 +1,2829 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ESResponse } from '../fetcher'; + +export const timeseriesResponse: ESResponse = { + took: 368, + timed_out: false, + _shards: { + total: 90, + successful: 90, + skipped: 0, + failed: 0 + }, + hits: { + total: 1297673, + max_score: 0, + hits: [] + }, + aggregations: { + transaction_results: { + doc_count_error_upper_bound: 0, + sum_other_doc_count: 0, + buckets: [ + { + key: 'A Custom Bucket (that should be last)', + doc_count: 0, + timeseries: { buckets: [] } + }, + { + key: 'HTTP 2xx', + doc_count: 1127080, + timeseries: { + buckets: [ + { + key_as_string: '2018-06-04T12:00:00.000Z', + key: 1528113600000, + doc_count: 16446 + }, + { + key_as_string: '2018-06-04T15:00:00.000Z', + key: 1528124400000, + doc_count: 16292 + }, + { + key_as_string: '2018-06-04T18:00:00.000Z', + key: 1528135200000, + doc_count: 16464 + }, + { + key_as_string: '2018-06-04T21:00:00.000Z', + key: 1528146000000, + doc_count: 16497 + }, + { + key_as_string: '2018-06-05T00:00:00.000Z', + key: 1528156800000, + doc_count: 16799 + }, + { + key_as_string: '2018-06-05T03:00:00.000Z', + key: 1528167600000, + doc_count: 16561 + }, + { + key_as_string: '2018-06-05T06:00:00.000Z', + key: 1528178400000, + doc_count: 16431 + }, + { + key_as_string: '2018-06-05T09:00:00.000Z', + key: 1528189200000, + doc_count: 16383 + }, + { + key_as_string: '2018-06-05T12:00:00.000Z', + key: 1528200000000, + doc_count: 16295 + }, + { + key_as_string: '2018-06-05T15:00:00.000Z', + key: 1528210800000, + doc_count: 16702 + }, + { + key_as_string: '2018-06-05T18:00:00.000Z', + key: 1528221600000, + doc_count: 16469 + }, + { + key_as_string: '2018-06-05T21:00:00.000Z', + key: 1528232400000, + doc_count: 16466 + }, + { + key_as_string: '2018-06-06T00:00:00.000Z', + key: 1528243200000, + doc_count: 16551 + }, + { + key_as_string: '2018-06-06T03:00:00.000Z', + key: 1528254000000, + doc_count: 16675 + }, + { + key_as_string: '2018-06-06T06:00:00.000Z', + key: 1528264800000, + doc_count: 16410 + }, + { + key_as_string: '2018-06-06T09:00:00.000Z', + key: 1528275600000, + doc_count: 16247 + }, + { + key_as_string: '2018-06-06T12:00:00.000Z', + key: 1528286400000, + doc_count: 15145 + }, + { + key_as_string: '2018-06-06T15:00:00.000Z', + key: 1528297200000, + doc_count: 16178 + }, + { + key_as_string: '2018-06-06T18:00:00.000Z', + key: 1528308000000, + doc_count: 16530 + }, + { + key_as_string: '2018-06-06T21:00:00.000Z', + key: 1528318800000, + doc_count: 16211 + }, + { + key_as_string: '2018-06-07T00:00:00.000Z', + key: 1528329600000, + doc_count: 16453 + }, + { + key_as_string: '2018-06-07T03:00:00.000Z', + key: 1528340400000, + doc_count: 16503 + }, + { + key_as_string: '2018-06-07T06:00:00.000Z', + key: 1528351200000, + doc_count: 16604 + }, + { + key_as_string: '2018-06-07T09:00:00.000Z', + key: 1528362000000, + doc_count: 16522 + }, + { + key_as_string: '2018-06-07T12:00:00.000Z', + key: 1528372800000, + doc_count: 16164 + }, + { + key_as_string: '2018-06-07T15:00:00.000Z', + key: 1528383600000, + doc_count: 16520 + }, + { + key_as_string: '2018-06-07T18:00:00.000Z', + key: 1528394400000, + doc_count: 16534 + }, + { + key_as_string: '2018-06-07T21:00:00.000Z', + key: 1528405200000, + doc_count: 16311 + }, + { + key_as_string: '2018-06-08T00:00:00.000Z', + key: 1528416000000, + doc_count: 16670 + }, + { + key_as_string: '2018-06-08T03:00:00.000Z', + key: 1528426800000, + doc_count: 16192 + }, + { + key_as_string: '2018-06-08T06:00:00.000Z', + key: 1528437600000, + doc_count: 16579 + }, + { + key_as_string: '2018-06-08T09:00:00.000Z', + key: 1528448400000, + doc_count: 16330 + }, + { + key_as_string: '2018-06-08T12:00:00.000Z', + key: 1528459200000, + doc_count: 16565 + }, + { + key_as_string: '2018-06-08T15:00:00.000Z', + key: 1528470000000, + doc_count: 16543 + }, + { + key_as_string: '2018-06-08T18:00:00.000Z', + key: 1528480800000, + doc_count: 16492 + }, + { + key_as_string: '2018-06-08T21:00:00.000Z', + key: 1528491600000, + doc_count: 16404 + }, + { + key_as_string: '2018-06-09T00:00:00.000Z', + key: 1528502400000, + doc_count: 4528 + }, + { + key_as_string: '2018-06-09T03:00:00.000Z', + key: 1528513200000, + doc_count: 4557 + }, + { + key_as_string: '2018-06-09T06:00:00.000Z', + key: 1528524000000, + doc_count: 4566 + }, + { + key_as_string: '2018-06-09T09:00:00.000Z', + key: 1528534800000, + doc_count: 4586 + }, + { + key_as_string: '2018-06-09T12:00:00.000Z', + key: 1528545600000, + doc_count: 4672 + }, + { + key_as_string: '2018-06-09T15:00:00.000Z', + key: 1528556400000, + doc_count: 4685 + }, + { + key_as_string: '2018-06-09T18:00:00.000Z', + key: 1528567200000, + doc_count: 4521 + }, + { + key_as_string: '2018-06-09T21:00:00.000Z', + key: 1528578000000, + doc_count: 4612 + }, + { + key_as_string: '2018-06-10T00:00:00.000Z', + key: 1528588800000, + doc_count: 4535 + }, + { + key_as_string: '2018-06-10T03:00:00.000Z', + key: 1528599600000, + doc_count: 4606 + }, + { + key_as_string: '2018-06-10T06:00:00.000Z', + key: 1528610400000, + doc_count: 4614 + }, + { + key_as_string: '2018-06-10T09:00:00.000Z', + key: 1528621200000, + doc_count: 4507 + }, + { + key_as_string: '2018-06-10T12:00:00.000Z', + key: 1528632000000, + doc_count: 4611 + }, + { + key_as_string: '2018-06-10T15:00:00.000Z', + key: 1528642800000, + doc_count: 4587 + }, + { + key_as_string: '2018-06-10T18:00:00.000Z', + key: 1528653600000, + doc_count: 4582 + }, + { + key_as_string: '2018-06-10T21:00:00.000Z', + key: 1528664400000, + doc_count: 4615 + }, + { + key_as_string: '2018-06-11T00:00:00.000Z', + key: 1528675200000, + doc_count: 16251 + }, + { + key_as_string: '2018-06-11T03:00:00.000Z', + key: 1528686000000, + doc_count: 16825 + }, + { + key_as_string: '2018-06-11T06:00:00.000Z', + key: 1528696800000, + doc_count: 16288 + }, + { + key_as_string: '2018-06-11T09:00:00.000Z', + key: 1528707600000, + doc_count: 16492 + }, + { + key_as_string: '2018-06-11T12:00:00.000Z', + key: 1528718400000, + doc_count: 16434 + }, + { + key_as_string: '2018-06-11T15:00:00.000Z', + key: 1528729200000, + doc_count: 17003 + }, + { + key_as_string: '2018-06-11T18:00:00.000Z', + key: 1528740000000, + doc_count: 16364 + }, + { + key_as_string: '2018-06-11T21:00:00.000Z', + key: 1528750800000, + doc_count: 16645 + }, + { + key_as_string: '2018-06-12T00:00:00.000Z', + key: 1528761600000, + doc_count: 16695 + }, + { + key_as_string: '2018-06-12T03:00:00.000Z', + key: 1528772400000, + doc_count: 16498 + }, + { + key_as_string: '2018-06-12T06:00:00.000Z', + key: 1528783200000, + doc_count: 16588 + }, + { + key_as_string: '2018-06-12T09:00:00.000Z', + key: 1528794000000, + doc_count: 16685 + }, + { + key_as_string: '2018-06-12T12:00:00.000Z', + key: 1528804800000, + doc_count: 16361 + }, + { + key_as_string: '2018-06-12T15:00:00.000Z', + key: 1528815600000, + doc_count: 16658 + }, + { + key_as_string: '2018-06-12T18:00:00.000Z', + key: 1528826400000, + doc_count: 16507 + }, + { + key_as_string: '2018-06-12T21:00:00.000Z', + key: 1528837200000, + doc_count: 16418 + }, + { + key_as_string: '2018-06-13T00:00:00.000Z', + key: 1528848000000, + doc_count: 16477 + }, + { + key_as_string: '2018-06-13T03:00:00.000Z', + key: 1528858800000, + doc_count: 16755 + }, + { + key_as_string: '2018-06-13T06:00:00.000Z', + key: 1528869600000, + doc_count: 16594 + }, + { + key_as_string: '2018-06-13T09:00:00.000Z', + key: 1528880400000, + doc_count: 16812 + }, + { + key_as_string: '2018-06-13T12:00:00.000Z', + key: 1528891200000, + doc_count: 16863 + }, + { + key_as_string: '2018-06-13T15:00:00.000Z', + key: 1528902000000, + doc_count: 16655 + }, + { + key_as_string: '2018-06-13T18:00:00.000Z', + key: 1528912800000, + doc_count: 16723 + }, + { + key_as_string: '2018-06-13T21:00:00.000Z', + key: 1528923600000, + doc_count: 16577 + }, + { + key_as_string: '2018-06-14T00:00:00.000Z', + key: 1528934400000, + doc_count: 15125 + }, + { + key_as_string: '2018-06-14T03:00:00.000Z', + key: 1528945200000, + doc_count: 16432 + }, + { + key_as_string: '2018-06-14T06:00:00.000Z', + key: 1528956000000, + doc_count: 16464 + }, + { + key_as_string: '2018-06-14T09:00:00.000Z', + key: 1528966800000, + doc_count: 16369 + }, + { + key_as_string: '2018-06-14T12:00:00.000Z', + key: 1528977600000, + doc_count: 0 + } + ] + } + }, + { + key: 'HTTP 5xx', + doc_count: 82036, + timeseries: { + buckets: [ + { + key_as_string: '2018-06-04T12:00:00.000Z', + key: 1528113600000, + doc_count: 1209 + }, + { + key_as_string: '2018-06-04T15:00:00.000Z', + key: 1528124400000, + doc_count: 1203 + }, + { + key_as_string: '2018-06-04T18:00:00.000Z', + key: 1528135200000, + doc_count: 1196 + }, + { + key_as_string: '2018-06-04T21:00:00.000Z', + key: 1528146000000, + doc_count: 1230 + }, + { + key_as_string: '2018-06-05T00:00:00.000Z', + key: 1528156800000, + doc_count: 1233 + }, + { + key_as_string: '2018-06-05T03:00:00.000Z', + key: 1528167600000, + doc_count: 1272 + }, + { + key_as_string: '2018-06-05T06:00:00.000Z', + key: 1528178400000, + doc_count: 1218 + }, + { + key_as_string: '2018-06-05T09:00:00.000Z', + key: 1528189200000, + doc_count: 1217 + }, + { + key_as_string: '2018-06-05T12:00:00.000Z', + key: 1528200000000, + doc_count: 1235 + }, + { + key_as_string: '2018-06-05T15:00:00.000Z', + key: 1528210800000, + doc_count: 1249 + }, + { + key_as_string: '2018-06-05T18:00:00.000Z', + key: 1528221600000, + doc_count: 1158 + }, + { + key_as_string: '2018-06-05T21:00:00.000Z', + key: 1528232400000, + doc_count: 1215 + }, + { + key_as_string: '2018-06-06T00:00:00.000Z', + key: 1528243200000, + doc_count: 1191 + }, + { + key_as_string: '2018-06-06T03:00:00.000Z', + key: 1528254000000, + doc_count: 1235 + }, + { + key_as_string: '2018-06-06T06:00:00.000Z', + key: 1528264800000, + doc_count: 1212 + }, + { + key_as_string: '2018-06-06T09:00:00.000Z', + key: 1528275600000, + doc_count: 1180 + }, + { + key_as_string: '2018-06-06T12:00:00.000Z', + key: 1528286400000, + doc_count: 1091 + }, + { + key_as_string: '2018-06-06T15:00:00.000Z', + key: 1528297200000, + doc_count: 1176 + }, + { + key_as_string: '2018-06-06T18:00:00.000Z', + key: 1528308000000, + doc_count: 1243 + }, + { + key_as_string: '2018-06-06T21:00:00.000Z', + key: 1528318800000, + doc_count: 1208 + }, + { + key_as_string: '2018-06-07T00:00:00.000Z', + key: 1528329600000, + doc_count: 1202 + }, + { + key_as_string: '2018-06-07T03:00:00.000Z', + key: 1528340400000, + doc_count: 1288 + }, + { + key_as_string: '2018-06-07T06:00:00.000Z', + key: 1528351200000, + doc_count: 1241 + }, + { + key_as_string: '2018-06-07T09:00:00.000Z', + key: 1528362000000, + doc_count: 1215 + }, + { + key_as_string: '2018-06-07T12:00:00.000Z', + key: 1528372800000, + doc_count: 1152 + }, + { + key_as_string: '2018-06-07T15:00:00.000Z', + key: 1528383600000, + doc_count: 1241 + }, + { + key_as_string: '2018-06-07T18:00:00.000Z', + key: 1528394400000, + doc_count: 1177 + }, + { + key_as_string: '2018-06-07T21:00:00.000Z', + key: 1528405200000, + doc_count: 1243 + }, + { + key_as_string: '2018-06-08T00:00:00.000Z', + key: 1528416000000, + doc_count: 1255 + }, + { + key_as_string: '2018-06-08T03:00:00.000Z', + key: 1528426800000, + doc_count: 1189 + }, + { + key_as_string: '2018-06-08T06:00:00.000Z', + key: 1528437600000, + doc_count: 1183 + }, + { + key_as_string: '2018-06-08T09:00:00.000Z', + key: 1528448400000, + doc_count: 1215 + }, + { + key_as_string: '2018-06-08T12:00:00.000Z', + key: 1528459200000, + doc_count: 1282 + }, + { + key_as_string: '2018-06-08T15:00:00.000Z', + key: 1528470000000, + doc_count: 1177 + }, + { + key_as_string: '2018-06-08T18:00:00.000Z', + key: 1528480800000, + doc_count: 1199 + }, + { + key_as_string: '2018-06-08T21:00:00.000Z', + key: 1528491600000, + doc_count: 1234 + }, + { + key_as_string: '2018-06-09T00:00:00.000Z', + key: 1528502400000, + doc_count: 284 + }, + { + key_as_string: '2018-06-09T03:00:00.000Z', + key: 1528513200000, + doc_count: 307 + }, + { + key_as_string: '2018-06-09T06:00:00.000Z', + key: 1528524000000, + doc_count: 283 + }, + { + key_as_string: '2018-06-09T09:00:00.000Z', + key: 1528534800000, + doc_count: 303 + }, + { + key_as_string: '2018-06-09T12:00:00.000Z', + key: 1528545600000, + doc_count: 326 + }, + { + key_as_string: '2018-06-09T15:00:00.000Z', + key: 1528556400000, + doc_count: 269 + }, + { + key_as_string: '2018-06-09T18:00:00.000Z', + key: 1528567200000, + doc_count: 297 + }, + { + key_as_string: '2018-06-09T21:00:00.000Z', + key: 1528578000000, + doc_count: 278 + }, + { + key_as_string: '2018-06-10T00:00:00.000Z', + key: 1528588800000, + doc_count: 289 + }, + { + key_as_string: '2018-06-10T03:00:00.000Z', + key: 1528599600000, + doc_count: 272 + }, + { + key_as_string: '2018-06-10T06:00:00.000Z', + key: 1528610400000, + doc_count: 279 + }, + { + key_as_string: '2018-06-10T09:00:00.000Z', + key: 1528621200000, + doc_count: 238 + }, + { + key_as_string: '2018-06-10T12:00:00.000Z', + key: 1528632000000, + doc_count: 288 + }, + { + key_as_string: '2018-06-10T15:00:00.000Z', + key: 1528642800000, + doc_count: 258 + }, + { + key_as_string: '2018-06-10T18:00:00.000Z', + key: 1528653600000, + doc_count: 264 + }, + { + key_as_string: '2018-06-10T21:00:00.000Z', + key: 1528664400000, + doc_count: 296 + }, + { + key_as_string: '2018-06-11T00:00:00.000Z', + key: 1528675200000, + doc_count: 1213 + }, + { + key_as_string: '2018-06-11T03:00:00.000Z', + key: 1528686000000, + doc_count: 1254 + }, + { + key_as_string: '2018-06-11T06:00:00.000Z', + key: 1528696800000, + doc_count: 1135 + }, + { + key_as_string: '2018-06-11T09:00:00.000Z', + key: 1528707600000, + doc_count: 1240 + }, + { + key_as_string: '2018-06-11T12:00:00.000Z', + key: 1528718400000, + doc_count: 1215 + }, + { + key_as_string: '2018-06-11T15:00:00.000Z', + key: 1528729200000, + doc_count: 1239 + }, + { + key_as_string: '2018-06-11T18:00:00.000Z', + key: 1528740000000, + doc_count: 1209 + }, + { + key_as_string: '2018-06-11T21:00:00.000Z', + key: 1528750800000, + doc_count: 1208 + }, + { + key_as_string: '2018-06-12T00:00:00.000Z', + key: 1528761600000, + doc_count: 1176 + }, + { + key_as_string: '2018-06-12T03:00:00.000Z', + key: 1528772400000, + doc_count: 1207 + }, + { + key_as_string: '2018-06-12T06:00:00.000Z', + key: 1528783200000, + doc_count: 1198 + }, + { + key_as_string: '2018-06-12T09:00:00.000Z', + key: 1528794000000, + doc_count: 1165 + }, + { + key_as_string: '2018-06-12T12:00:00.000Z', + key: 1528804800000, + doc_count: 1188 + }, + { + key_as_string: '2018-06-12T15:00:00.000Z', + key: 1528815600000, + doc_count: 1245 + }, + { + key_as_string: '2018-06-12T18:00:00.000Z', + key: 1528826400000, + doc_count: 1238 + }, + { + key_as_string: '2018-06-12T21:00:00.000Z', + key: 1528837200000, + doc_count: 1283 + }, + { + key_as_string: '2018-06-13T00:00:00.000Z', + key: 1528848000000, + doc_count: 1198 + }, + { + key_as_string: '2018-06-13T03:00:00.000Z', + key: 1528858800000, + doc_count: 1172 + }, + { + key_as_string: '2018-06-13T06:00:00.000Z', + key: 1528869600000, + doc_count: 1229 + }, + { + key_as_string: '2018-06-13T09:00:00.000Z', + key: 1528880400000, + doc_count: 1239 + }, + { + key_as_string: '2018-06-13T12:00:00.000Z', + key: 1528891200000, + doc_count: 1231 + }, + { + key_as_string: '2018-06-13T15:00:00.000Z', + key: 1528902000000, + doc_count: 1248 + }, + { + key_as_string: '2018-06-13T18:00:00.000Z', + key: 1528912800000, + doc_count: 1220 + }, + { + key_as_string: '2018-06-13T21:00:00.000Z', + key: 1528923600000, + doc_count: 1224 + }, + { + key_as_string: '2018-06-14T00:00:00.000Z', + key: 1528934400000, + doc_count: 1088 + }, + { + key_as_string: '2018-06-14T03:00:00.000Z', + key: 1528945200000, + doc_count: 1235 + }, + { + key_as_string: '2018-06-14T06:00:00.000Z', + key: 1528956000000, + doc_count: 1161 + }, + { + key_as_string: '2018-06-14T09:00:00.000Z', + key: 1528966800000, + doc_count: 1183 + }, + { + key_as_string: '2018-06-14T12:00:00.000Z', + key: 1528977600000, + doc_count: 0 + } + ] + } + }, + { + key: 'HTTP 4xx', + doc_count: 81907, + timeseries: { + buckets: [ + { + key_as_string: '2018-06-04T12:00:00.000Z', + key: 1528113600000, + doc_count: 1186 + }, + { + key_as_string: '2018-06-04T15:00:00.000Z', + key: 1528124400000, + doc_count: 1213 + }, + { + key_as_string: '2018-06-04T18:00:00.000Z', + key: 1528135200000, + doc_count: 1205 + }, + { + key_as_string: '2018-06-04T21:00:00.000Z', + key: 1528146000000, + doc_count: 1162 + }, + { + key_as_string: '2018-06-05T00:00:00.000Z', + key: 1528156800000, + doc_count: 1238 + }, + { + key_as_string: '2018-06-05T03:00:00.000Z', + key: 1528167600000, + doc_count: 1191 + }, + { + key_as_string: '2018-06-05T06:00:00.000Z', + key: 1528178400000, + doc_count: 1274 + }, + { + key_as_string: '2018-06-05T09:00:00.000Z', + key: 1528189200000, + doc_count: 1234 + }, + { + key_as_string: '2018-06-05T12:00:00.000Z', + key: 1528200000000, + doc_count: 1164 + }, + { + key_as_string: '2018-06-05T15:00:00.000Z', + key: 1528210800000, + doc_count: 1233 + }, + { + key_as_string: '2018-06-05T18:00:00.000Z', + key: 1528221600000, + doc_count: 1223 + }, + { + key_as_string: '2018-06-05T21:00:00.000Z', + key: 1528232400000, + doc_count: 1216 + }, + { + key_as_string: '2018-06-06T00:00:00.000Z', + key: 1528243200000, + doc_count: 1200 + }, + { + key_as_string: '2018-06-06T03:00:00.000Z', + key: 1528254000000, + doc_count: 1237 + }, + { + key_as_string: '2018-06-06T06:00:00.000Z', + key: 1528264800000, + doc_count: 1231 + }, + { + key_as_string: '2018-06-06T09:00:00.000Z', + key: 1528275600000, + doc_count: 1182 + }, + { + key_as_string: '2018-06-06T12:00:00.000Z', + key: 1528286400000, + doc_count: 1125 + }, + { + key_as_string: '2018-06-06T15:00:00.000Z', + key: 1528297200000, + doc_count: 1243 + }, + { + key_as_string: '2018-06-06T18:00:00.000Z', + key: 1528308000000, + doc_count: 1247 + }, + { + key_as_string: '2018-06-06T21:00:00.000Z', + key: 1528318800000, + doc_count: 1163 + }, + { + key_as_string: '2018-06-07T00:00:00.000Z', + key: 1528329600000, + doc_count: 1220 + }, + { + key_as_string: '2018-06-07T03:00:00.000Z', + key: 1528340400000, + doc_count: 1202 + }, + { + key_as_string: '2018-06-07T06:00:00.000Z', + key: 1528351200000, + doc_count: 1192 + }, + { + key_as_string: '2018-06-07T09:00:00.000Z', + key: 1528362000000, + doc_count: 1248 + }, + { + key_as_string: '2018-06-07T12:00:00.000Z', + key: 1528372800000, + doc_count: 1189 + }, + { + key_as_string: '2018-06-07T15:00:00.000Z', + key: 1528383600000, + doc_count: 1230 + }, + { + key_as_string: '2018-06-07T18:00:00.000Z', + key: 1528394400000, + doc_count: 1206 + }, + { + key_as_string: '2018-06-07T21:00:00.000Z', + key: 1528405200000, + doc_count: 1190 + }, + { + key_as_string: '2018-06-08T00:00:00.000Z', + key: 1528416000000, + doc_count: 1232 + }, + { + key_as_string: '2018-06-08T03:00:00.000Z', + key: 1528426800000, + doc_count: 1171 + }, + { + key_as_string: '2018-06-08T06:00:00.000Z', + key: 1528437600000, + doc_count: 1232 + }, + { + key_as_string: '2018-06-08T09:00:00.000Z', + key: 1528448400000, + doc_count: 1253 + }, + { + key_as_string: '2018-06-08T12:00:00.000Z', + key: 1528459200000, + doc_count: 1250 + }, + { + key_as_string: '2018-06-08T15:00:00.000Z', + key: 1528470000000, + doc_count: 1167 + }, + { + key_as_string: '2018-06-08T18:00:00.000Z', + key: 1528480800000, + doc_count: 1258 + }, + { + key_as_string: '2018-06-08T21:00:00.000Z', + key: 1528491600000, + doc_count: 1148 + }, + { + key_as_string: '2018-06-09T00:00:00.000Z', + key: 1528502400000, + doc_count: 284 + }, + { + key_as_string: '2018-06-09T03:00:00.000Z', + key: 1528513200000, + doc_count: 240 + }, + { + key_as_string: '2018-06-09T06:00:00.000Z', + key: 1528524000000, + doc_count: 273 + }, + { + key_as_string: '2018-06-09T09:00:00.000Z', + key: 1528534800000, + doc_count: 295 + }, + { + key_as_string: '2018-06-09T12:00:00.000Z', + key: 1528545600000, + doc_count: 281 + }, + { + key_as_string: '2018-06-09T15:00:00.000Z', + key: 1528556400000, + doc_count: 300 + }, + { + key_as_string: '2018-06-09T18:00:00.000Z', + key: 1528567200000, + doc_count: 264 + }, + { + key_as_string: '2018-06-09T21:00:00.000Z', + key: 1528578000000, + doc_count: 260 + }, + { + key_as_string: '2018-06-10T00:00:00.000Z', + key: 1528588800000, + doc_count: 279 + }, + { + key_as_string: '2018-06-10T03:00:00.000Z', + key: 1528599600000, + doc_count: 259 + }, + { + key_as_string: '2018-06-10T06:00:00.000Z', + key: 1528610400000, + doc_count: 291 + }, + { + key_as_string: '2018-06-10T09:00:00.000Z', + key: 1528621200000, + doc_count: 248 + }, + { + key_as_string: '2018-06-10T12:00:00.000Z', + key: 1528632000000, + doc_count: 311 + }, + { + key_as_string: '2018-06-10T15:00:00.000Z', + key: 1528642800000, + doc_count: 277 + }, + { + key_as_string: '2018-06-10T18:00:00.000Z', + key: 1528653600000, + doc_count: 279 + }, + { + key_as_string: '2018-06-10T21:00:00.000Z', + key: 1528664400000, + doc_count: 275 + }, + { + key_as_string: '2018-06-11T00:00:00.000Z', + key: 1528675200000, + doc_count: 1167 + }, + { + key_as_string: '2018-06-11T03:00:00.000Z', + key: 1528686000000, + doc_count: 1270 + }, + { + key_as_string: '2018-06-11T06:00:00.000Z', + key: 1528696800000, + doc_count: 1163 + }, + { + key_as_string: '2018-06-11T09:00:00.000Z', + key: 1528707600000, + doc_count: 1155 + }, + { + key_as_string: '2018-06-11T12:00:00.000Z', + key: 1528718400000, + doc_count: 1217 + }, + { + key_as_string: '2018-06-11T15:00:00.000Z', + key: 1528729200000, + doc_count: 1227 + }, + { + key_as_string: '2018-06-11T18:00:00.000Z', + key: 1528740000000, + doc_count: 1194 + }, + { + key_as_string: '2018-06-11T21:00:00.000Z', + key: 1528750800000, + doc_count: 1153 + }, + { + key_as_string: '2018-06-12T00:00:00.000Z', + key: 1528761600000, + doc_count: 1211 + }, + { + key_as_string: '2018-06-12T03:00:00.000Z', + key: 1528772400000, + doc_count: 1203 + }, + { + key_as_string: '2018-06-12T06:00:00.000Z', + key: 1528783200000, + doc_count: 1269 + }, + { + key_as_string: '2018-06-12T09:00:00.000Z', + key: 1528794000000, + doc_count: 1197 + }, + { + key_as_string: '2018-06-12T12:00:00.000Z', + key: 1528804800000, + doc_count: 1184 + }, + { + key_as_string: '2018-06-12T15:00:00.000Z', + key: 1528815600000, + doc_count: 1176 + }, + { + key_as_string: '2018-06-12T18:00:00.000Z', + key: 1528826400000, + doc_count: 1162 + }, + { + key_as_string: '2018-06-12T21:00:00.000Z', + key: 1528837200000, + doc_count: 1270 + }, + { + key_as_string: '2018-06-13T00:00:00.000Z', + key: 1528848000000, + doc_count: 1224 + }, + { + key_as_string: '2018-06-13T03:00:00.000Z', + key: 1528858800000, + doc_count: 1255 + }, + { + key_as_string: '2018-06-13T06:00:00.000Z', + key: 1528869600000, + doc_count: 1207 + }, + { + key_as_string: '2018-06-13T09:00:00.000Z', + key: 1528880400000, + doc_count: 1206 + }, + { + key_as_string: '2018-06-13T12:00:00.000Z', + key: 1528891200000, + doc_count: 1254 + }, + { + key_as_string: '2018-06-13T15:00:00.000Z', + key: 1528902000000, + doc_count: 1216 + }, + { + key_as_string: '2018-06-13T18:00:00.000Z', + key: 1528912800000, + doc_count: 1263 + }, + { + key_as_string: '2018-06-13T21:00:00.000Z', + key: 1528923600000, + doc_count: 1277 + }, + { + key_as_string: '2018-06-14T00:00:00.000Z', + key: 1528934400000, + doc_count: 1183 + }, + { + key_as_string: '2018-06-14T03:00:00.000Z', + key: 1528945200000, + doc_count: 1221 + }, + { + key_as_string: '2018-06-14T06:00:00.000Z', + key: 1528956000000, + doc_count: 1198 + }, + { + key_as_string: '2018-06-14T09:00:00.000Z', + key: 1528966800000, + doc_count: 1214 + }, + { + key_as_string: '2018-06-14T12:00:00.000Z', + key: 1528977600000, + doc_count: 0 + } + ] + } + }, + { + key: 'HTTP 3xx', + doc_count: 6650, + timeseries: { + buckets: [ + { + key_as_string: '2018-06-04T12:00:00.000Z', + key: 1528113600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-04T15:00:00.000Z', + key: 1528124400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-04T18:00:00.000Z', + key: 1528135200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-04T21:00:00.000Z', + key: 1528146000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-05T00:00:00.000Z', + key: 1528156800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-05T03:00:00.000Z', + key: 1528167600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-05T06:00:00.000Z', + key: 1528178400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-05T09:00:00.000Z', + key: 1528189200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-05T12:00:00.000Z', + key: 1528200000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-05T15:00:00.000Z', + key: 1528210800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-05T18:00:00.000Z', + key: 1528221600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-05T21:00:00.000Z', + key: 1528232400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-06T00:00:00.000Z', + key: 1528243200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-06T03:00:00.000Z', + key: 1528254000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-06T06:00:00.000Z', + key: 1528264800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-06T09:00:00.000Z', + key: 1528275600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-06T12:00:00.000Z', + key: 1528286400000, + doc_count: 4041 + }, + { + key_as_string: '2018-06-06T15:00:00.000Z', + key: 1528297200000, + doc_count: 454 + }, + { + key_as_string: '2018-06-06T18:00:00.000Z', + key: 1528308000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-06T21:00:00.000Z', + key: 1528318800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-07T00:00:00.000Z', + key: 1528329600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-07T03:00:00.000Z', + key: 1528340400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-07T06:00:00.000Z', + key: 1528351200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-07T09:00:00.000Z', + key: 1528362000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-07T12:00:00.000Z', + key: 1528372800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-07T15:00:00.000Z', + key: 1528383600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-07T18:00:00.000Z', + key: 1528394400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-07T21:00:00.000Z', + key: 1528405200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-08T00:00:00.000Z', + key: 1528416000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-08T03:00:00.000Z', + key: 1528426800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-08T06:00:00.000Z', + key: 1528437600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-08T09:00:00.000Z', + key: 1528448400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-08T12:00:00.000Z', + key: 1528459200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-08T15:00:00.000Z', + key: 1528470000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-08T18:00:00.000Z', + key: 1528480800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-08T21:00:00.000Z', + key: 1528491600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-09T00:00:00.000Z', + key: 1528502400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-09T03:00:00.000Z', + key: 1528513200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-09T06:00:00.000Z', + key: 1528524000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-09T09:00:00.000Z', + key: 1528534800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-09T12:00:00.000Z', + key: 1528545600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-09T15:00:00.000Z', + key: 1528556400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-09T18:00:00.000Z', + key: 1528567200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-09T21:00:00.000Z', + key: 1528578000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-10T00:00:00.000Z', + key: 1528588800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-10T03:00:00.000Z', + key: 1528599600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-10T06:00:00.000Z', + key: 1528610400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-10T09:00:00.000Z', + key: 1528621200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-10T12:00:00.000Z', + key: 1528632000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-10T15:00:00.000Z', + key: 1528642800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-10T18:00:00.000Z', + key: 1528653600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-10T21:00:00.000Z', + key: 1528664400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-11T00:00:00.000Z', + key: 1528675200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-11T03:00:00.000Z', + key: 1528686000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-11T06:00:00.000Z', + key: 1528696800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-11T09:00:00.000Z', + key: 1528707600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-11T12:00:00.000Z', + key: 1528718400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-11T15:00:00.000Z', + key: 1528729200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-11T18:00:00.000Z', + key: 1528740000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-11T21:00:00.000Z', + key: 1528750800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-12T00:00:00.000Z', + key: 1528761600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-12T03:00:00.000Z', + key: 1528772400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-12T06:00:00.000Z', + key: 1528783200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-12T09:00:00.000Z', + key: 1528794000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-12T12:00:00.000Z', + key: 1528804800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-12T15:00:00.000Z', + key: 1528815600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-12T18:00:00.000Z', + key: 1528826400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-12T21:00:00.000Z', + key: 1528837200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-13T00:00:00.000Z', + key: 1528848000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-13T03:00:00.000Z', + key: 1528858800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-13T06:00:00.000Z', + key: 1528869600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-13T09:00:00.000Z', + key: 1528880400000, + doc_count: 0 + }, + { + key_as_string: '2018-06-13T12:00:00.000Z', + key: 1528891200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-13T15:00:00.000Z', + key: 1528902000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-13T18:00:00.000Z', + key: 1528912800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-13T21:00:00.000Z', + key: 1528923600000, + doc_count: 0 + }, + { + key_as_string: '2018-06-14T00:00:00.000Z', + key: 1528934400000, + doc_count: 2155 + }, + { + key_as_string: '2018-06-14T03:00:00.000Z', + key: 1528945200000, + doc_count: 0 + }, + { + key_as_string: '2018-06-14T06:00:00.000Z', + key: 1528956000000, + doc_count: 0 + }, + { + key_as_string: '2018-06-14T09:00:00.000Z', + key: 1528966800000, + doc_count: 0 + }, + { + key_as_string: '2018-06-14T12:00:00.000Z', + key: 1528977600000, + doc_count: 0 + } + ] + } + } + ] + }, + response_times: { + buckets: [ + { + key_as_string: '2018-06-04T12:00:00.000Z', + key: 1528113600000, + doc_count: 18841, + pct: { + values: { + '95.0': 82172.85648714812, + '99.0': 293866.3866666665 + } + }, + avg: { + value: 26310.63483891513 + } + }, + { + key_as_string: '2018-06-04T15:00:00.000Z', + key: 1528124400000, + doc_count: 18708, + pct: { + values: { + '95.0': 80738.78571428556, + '99.0': 293257.27333333343 + } + }, + avg: { + value: 26193.277795595466 + } + }, + { + key_as_string: '2018-06-04T18:00:00.000Z', + key: 1528135200000, + doc_count: 18865, + pct: { + values: { + '95.0': 77058.03529411761, + '99.0': 290195.8800000004 + } + }, + avg: { + value: 25291.787065995228 + } + }, + { + key_as_string: '2018-06-04T21:00:00.000Z', + key: 1528146000000, + doc_count: 18889, + pct: { + values: { + '95.0': 77892.20721980717, + '99.0': 278548.1649999994 + } + }, + avg: { + value: 24690.306474667796 + } + }, + { + key_as_string: '2018-06-05T00:00:00.000Z', + key: 1528156800000, + doc_count: 19270, + pct: { + values: { + '95.0': 77085.86687499998, + '99.0': 290701.8973333341 + } + }, + avg: { + value: 24809.8953814219 + } + }, + { + key_as_string: '2018-06-05T03:00:00.000Z', + key: 1528167600000, + doc_count: 19024, + pct: { + values: { + '95.0': 80048.3462981744, + '99.0': 286839.5897777779 + } + }, + avg: { + value: 25460.0394764508 + } + }, + { + key_as_string: '2018-06-05T06:00:00.000Z', + key: 1528178400000, + doc_count: 18923, + pct: { + values: { + '95.0': 84089.21370223971, + '99.0': 287979.5149999999 + } + }, + avg: { + value: 26360.440733498916 + } + }, + { + key_as_string: '2018-06-05T09:00:00.000Z', + key: 1528189200000, + doc_count: 18834, + pct: { + values: { + '95.0': 84880.90143416924, + '99.0': 300107.5009999992 + } + }, + avg: { + value: 27050.95205479452 + } + }, + { + key_as_string: '2018-06-05T12:00:00.000Z', + key: 1528200000000, + doc_count: 18694, + pct: { + values: { + '95.0': 84554.8884781166, + '99.0': 294402.2179999999 + } + }, + avg: { + value: 26555.857333903925 + } + }, + { + key_as_string: '2018-06-05T15:00:00.000Z', + key: 1528210800000, + doc_count: 19184, + pct: { + values: { + '95.0': 81839.39583333326, + '99.0': 289849.459333332 + } + }, + avg: { + value: 26164.343359049206 + } + }, + { + key_as_string: '2018-06-05T18:00:00.000Z', + key: 1528221600000, + doc_count: 18850, + pct: { + values: { + '95.0': 85993.55410163336, + '99.0': 296942.86299999955 + } + }, + avg: { + value: 26989.84546419098 + } + }, + { + key_as_string: '2018-06-05T21:00:00.000Z', + key: 1528232400000, + doc_count: 18897, + pct: { + values: { + '95.0': 85001.44588628765, + '99.0': 292048.20571428596 + } + }, + avg: { + value: 26314.409430068266 + } + }, + { + key_as_string: '2018-06-06T00:00:00.000Z', + key: 1528243200000, + doc_count: 18942, + pct: { + values: { + '95.0': 86980.16445312503, + '99.0': 299308.7371666667 + } + }, + avg: { + value: 27460.774575018477 + } + }, + { + key_as_string: '2018-06-06T03:00:00.000Z', + key: 1528254000000, + doc_count: 19147, + pct: { + values: { + '95.0': 84961.8710743802, + '99.0': 292151.2377777781 + } + }, + avg: { + value: 26461.469107431974 + } + }, + { + key_as_string: '2018-06-06T06:00:00.000Z', + key: 1528264800000, + doc_count: 18853, + pct: { + values: { + '95.0': 88906.54601889332, + '99.0': 302274.4192592592 + } + }, + avg: { + value: 27657.584946692834 + } + }, + { + key_as_string: '2018-06-06T09:00:00.000Z', + key: 1528275600000, + doc_count: 18609, + pct: { + values: { + '95.0': 90198.34708994703, + '99.0': 299457.1612121209 + } + }, + avg: { + value: 27940.445967005213 + } + }, + { + key_as_string: '2018-06-06T12:00:00.000Z', + key: 1528286400000, + doc_count: 21402, + pct: { + values: { + '95.0': 135627.71242424246, + '99.0': 350398.59259259375 + } + }, + avg: { + value: 34454.377581534434 + } + }, + { + key_as_string: '2018-06-06T15:00:00.000Z', + key: 1528297200000, + doc_count: 19051, + pct: { + values: { + '95.0': 167037.1993837535, + '99.0': 421204.23333333334 + } + }, + avg: { + value: 44024.31809353839 + } + }, + { + key_as_string: '2018-06-06T18:00:00.000Z', + key: 1528308000000, + doc_count: 19020, + pct: { + values: { + '95.0': 128293.12184873945, + '99.0': 368166.68976190523 + } + }, + avg: { + value: 36374.53333333333 + } + }, + { + key_as_string: '2018-06-06T21:00:00.000Z', + key: 1528318800000, + doc_count: 18582, + pct: { + values: { + '95.0': 130653.54236263742, + '99.0': 367193.6128571426 + } + }, + avg: { + value: 36991.29442471209 + } + }, + { + key_as_string: '2018-06-07T00:00:00.000Z', + key: 1528329600000, + doc_count: 18875, + pct: { + values: { + '95.0': 131630.8902645502, + '99.0': 375658.10190476174 + } + }, + avg: { + value: 37178.002701986756 + } + }, + { + key_as_string: '2018-06-07T03:00:00.000Z', + key: 1528340400000, + doc_count: 18993, + pct: { + values: { + '95.0': 133581.33541666638, + '99.0': 368152.03822222137 + } + }, + avg: { + value: 37605.57078923814 + } + }, + { + key_as_string: '2018-06-07T06:00:00.000Z', + key: 1528351200000, + doc_count: 19037, + pct: { + values: { + '95.0': 132697.92762266204, + '99.0': 365705.8319999995 + } + }, + avg: { + value: 37319.89767295267 + } + }, + { + key_as_string: '2018-06-07T09:00:00.000Z', + key: 1528362000000, + doc_count: 18985, + pct: { + values: { + '95.0': 140003.6918918918, + '99.0': 380075.48533333326 + } + }, + avg: { + value: 38709.5041348433 + } + }, + { + key_as_string: '2018-06-07T12:00:00.000Z', + key: 1528372800000, + doc_count: 18505, + pct: { + values: { + '95.0': 138149.5673529411, + '99.0': 375697.1923809518 + } + }, + avg: { + value: 38140.131856255066 + } + }, + { + key_as_string: '2018-06-07T15:00:00.000Z', + key: 1528383600000, + doc_count: 18991, + pct: { + values: { + '95.0': 121872.37504835591, + '99.0': 351080.94111111073 + } + }, + avg: { + value: 34564.81091043125 + } + }, + { + key_as_string: '2018-06-07T18:00:00.000Z', + key: 1528394400000, + doc_count: 18917, + pct: { + values: { + '95.0': 116378.03873517792, + '99.0': 339294.12799999997 + } + }, + avg: { + value: 33256.37743828302 + } + }, + { + key_as_string: '2018-06-07T21:00:00.000Z', + key: 1528405200000, + doc_count: 18744, + pct: { + values: { + '95.0': 131545.40999999995, + '99.0': 378902.90649999987 + } + }, + avg: { + value: 37251.5625266752 + } + }, + { + key_as_string: '2018-06-08T00:00:00.000Z', + key: 1528416000000, + doc_count: 19157, + pct: { + values: { + '95.0': 133111.25804878055, + '99.0': 384483.3233333327 + } + }, + avg: { + value: 38681.89084929791 + } + }, + { + key_as_string: '2018-06-08T03:00:00.000Z', + key: 1528426800000, + doc_count: 18552, + pct: { + values: { + '95.0': 144821.9855278593, + '99.0': 394692.25000000105 + } + }, + avg: { + value: 40677.801045709355 + } + }, + { + key_as_string: '2018-06-08T06:00:00.000Z', + key: 1528437600000, + doc_count: 18994, + pct: { + values: { + '95.0': 134737.3997727272, + '99.0': 403362.50399999996 + } + }, + avg: { + value: 39987.86453616932 + } + }, + { + key_as_string: '2018-06-08T09:00:00.000Z', + key: 1528448400000, + doc_count: 18798, + pct: { + values: { + '95.0': 141206.57726666646, + '99.0': 396559.0274999993 + } + }, + avg: { + value: 41059.392914139804 + } + }, + { + key_as_string: '2018-06-08T12:00:00.000Z', + key: 1528459200000, + doc_count: 19097, + pct: { + values: { + '95.0': 137731.8994082841, + '99.0': 371815.8320000008 + } + }, + avg: { + value: 39630.710111535845 + } + }, + { + key_as_string: '2018-06-08T15:00:00.000Z', + key: 1528470000000, + doc_count: 18887, + pct: { + values: { + '95.0': 141476.23189033198, + '99.0': 405477.6133333326 + } + }, + avg: { + value: 41561.81331074284 + } + }, + { + key_as_string: '2018-06-08T18:00:00.000Z', + key: 1528480800000, + doc_count: 18949, + pct: { + values: { + '95.0': 149636.31340909077, + '99.0': 413542.18133333366 + } + }, + avg: { + value: 43079.490738297536 + } + }, + { + key_as_string: '2018-06-08T21:00:00.000Z', + key: 1528491600000, + doc_count: 18786, + pct: { + values: { + '95.0': 151934.55000000002, + '99.0': 424399.340000001 + } + }, + avg: { + value: 43925.39609283509 + } + }, + { + key_as_string: '2018-06-09T00:00:00.000Z', + key: 1528502400000, + doc_count: 5096, + pct: { + values: { + '95.0': 82198.17857142858, + '99.0': 303815.9000000001 + } + }, + avg: { + value: 25821.91424646782 + } + }, + { + key_as_string: '2018-06-09T03:00:00.000Z', + key: 1528513200000, + doc_count: 5104, + pct: { + values: { + '95.0': 85946.43199999983, + '99.0': 306305.0800000006 + } + }, + avg: { + value: 27343.60011755486 + } + }, + { + key_as_string: '2018-06-09T06:00:00.000Z', + key: 1528524000000, + doc_count: 5122, + pct: { + values: { + '95.0': 78617.66249999996, + '99.0': 297521.94999999984 + } + }, + avg: { + value: 25249.95060523233 + } + }, + { + key_as_string: '2018-06-09T09:00:00.000Z', + key: 1528534800000, + doc_count: 5184, + pct: { + values: { + '95.0': 79606.48333333322, + '99.0': 317938.0900000003 + } + }, + avg: { + value: 25492.77199074074 + } + }, + { + key_as_string: '2018-06-09T12:00:00.000Z', + key: 1528545600000, + doc_count: 5279, + pct: { + values: { + '95.0': 76297.93999999986, + '99.0': 312262.3000000003 + } + }, + avg: { + value: 25991.647281682137 + } + }, + { + key_as_string: '2018-06-09T15:00:00.000Z', + key: 1528556400000, + doc_count: 5254, + pct: { + values: { + '95.0': 80742.63333333324, + '99.0': 318428.8700000002 + } + }, + avg: { + value: 26273.31290445375 + } + }, + { + key_as_string: '2018-06-09T18:00:00.000Z', + key: 1528567200000, + doc_count: 5082, + pct: { + values: { + '95.0': 81291.45969696966, + '99.0': 295421.4099999999 + } + }, + avg: { + value: 26234.98976780795 + } + }, + { + key_as_string: '2018-06-09T21:00:00.000Z', + key: 1528578000000, + doc_count: 5150, + pct: { + values: { + '95.0': 73467.02500000004, + '99.0': 293067.86000000004 + } + }, + avg: { + value: 23494.54873786408 + } + }, + { + key_as_string: '2018-06-10T00:00:00.000Z', + key: 1528588800000, + doc_count: 5103, + pct: { + values: { + '95.0': 69177.66999999993, + '99.0': 264935.71999999933 + } + }, + avg: { + value: 22008.80482069371 + } + }, + { + key_as_string: '2018-06-10T03:00:00.000Z', + key: 1528599600000, + doc_count: 5137, + pct: { + values: { + '95.0': 71956.06111111109, + '99.0': 282795.0400000003 + } + }, + avg: { + value: 22828.136655635586 + } + }, + { + key_as_string: '2018-06-10T06:00:00.000Z', + key: 1528610400000, + doc_count: 5184, + pct: { + values: { + '95.0': 68480.91142857139, + '99.0': 285390.8400000001 + } + }, + avg: { + value: 22138.7081404321 + } + }, + { + key_as_string: '2018-06-10T09:00:00.000Z', + key: 1528621200000, + doc_count: 4993, + pct: { + values: { + '95.0': 68957.0999999999, + '99.0': 290402.24 + } + }, + avg: { + value: 22634.985579811735 + } + }, + { + key_as_string: '2018-06-10T12:00:00.000Z', + key: 1528632000000, + doc_count: 5210, + pct: { + values: { + '95.0': 67489.50416666668, + '99.0': 293655.53 + } + }, + avg: { + value: 22202.780998080616 + } + }, + { + key_as_string: '2018-06-10T15:00:00.000Z', + key: 1528642800000, + doc_count: 5122, + pct: { + values: { + '95.0': 71556.91249999998, + '99.0': 292723.56999999995 + } + }, + avg: { + value: 23084.082780163997 + } + }, + { + key_as_string: '2018-06-10T18:00:00.000Z', + key: 1528653600000, + doc_count: 5125, + pct: { + values: { + '95.0': 72157.65128205132, + '99.0': 301051.32000000105 + } + }, + avg: { + value: 23109.666146341464 + } + }, + { + key_as_string: '2018-06-10T21:00:00.000Z', + key: 1528664400000, + doc_count: 5186, + pct: { + values: { + '95.0': 76124.5625, + '99.0': 291322.0499999998 + } + }, + avg: { + value: 23306.89028152719 + } + }, + { + key_as_string: '2018-06-11T00:00:00.000Z', + key: 1528675200000, + doc_count: 18631, + pct: { + values: { + '95.0': 141709.34661835746, + '99.0': 379855.2444444447 + } + }, + avg: { + value: 39341.022704095325 + } + }, + { + key_as_string: '2018-06-11T03:00:00.000Z', + key: 1528686000000, + doc_count: 19349, + pct: { + values: { + '95.0': 132371.48641975303, + '99.0': 371175.2592000001 + } + }, + avg: { + value: 37467.17153341258 + } + }, + { + key_as_string: '2018-06-11T06:00:00.000Z', + key: 1528696800000, + doc_count: 18586, + pct: { + values: { + '95.0': 186783.51503759398, + '99.0': 498378.4238888898 + } + }, + avg: { + value: 52457.50554180566 + } + }, + { + key_as_string: '2018-06-11T09:00:00.000Z', + key: 1528707600000, + doc_count: 18887, + pct: { + values: { + '95.0': 99540.17819499348, + '99.0': 331118.6599999997 + } + }, + avg: { + value: 31327.95780166252 + } + }, + { + key_as_string: '2018-06-11T12:00:00.000Z', + key: 1528718400000, + doc_count: 18866, + pct: { + values: { + '95.0': 95982.62454212455, + '99.0': 328101.3999999988 + } + }, + avg: { + value: 30695.334941163997 + } + }, + { + key_as_string: '2018-06-11T15:00:00.000Z', + key: 1528729200000, + doc_count: 19469, + pct: { + values: { + '95.0': 89559.3525925925, + '99.0': 313951.54249999986 + } + }, + avg: { + value: 28895.042785967435 + } + }, + { + key_as_string: '2018-06-11T18:00:00.000Z', + key: 1528740000000, + doc_count: 18767, + pct: { + values: { + '95.0': 95769.83153735634, + '99.0': 323340.5274074075 + } + }, + avg: { + value: 30649.363989982416 + } + }, + { + key_as_string: '2018-06-11T21:00:00.000Z', + key: 1528750800000, + doc_count: 19006, + pct: { + values: { + '95.0': 94063.90833755062, + '99.0': 315055.5047619052 + } + }, + avg: { + value: 29802.63622014101 + } + }, + { + key_as_string: '2018-06-12T00:00:00.000Z', + key: 1528761600000, + doc_count: 19082, + pct: { + values: { + '95.0': 96399.67269119772, + '99.0': 330070.03599999985 + } + }, + avg: { + value: 30759.03002829892 + } + }, + { + key_as_string: '2018-06-12T03:00:00.000Z', + key: 1528772400000, + doc_count: 18908, + pct: { + values: { + '95.0': 96436.42520161276, + '99.0': 320531.54416666675 + } + }, + avg: { + value: 30399.76549608631 + } + }, + { + key_as_string: '2018-06-12T06:00:00.000Z', + key: 1528783200000, + doc_count: 19055, + pct: { + values: { + '95.0': 91860.16988095238, + '99.0': 315137.16628571344 + } + }, + avg: { + value: 29421.610233534506 + } + }, + { + key_as_string: '2018-06-12T09:00:00.000Z', + key: 1528794000000, + doc_count: 19047, + pct: { + values: { + '95.0': 105989.8333333334, + '99.0': 337251.4042424246 + } + }, + avg: { + value: 32641.679897096656 + } + }, + { + key_as_string: '2018-06-12T12:00:00.000Z', + key: 1528804800000, + doc_count: 18733, + pct: { + values: { + '95.0': 97937.60342555979, + '99.0': 327054.9243636365 + } + }, + avg: { + value: 30621.65440666204 + } + }, + { + key_as_string: '2018-06-12T15:00:00.000Z', + key: 1528815600000, + doc_count: 19079, + pct: { + values: { + '95.0': 98967.2249999999, + '99.0': 327653.0000000006 + } + }, + avg: { + value: 31039.60391005818 + } + }, + { + key_as_string: '2018-06-12T18:00:00.000Z', + key: 1528826400000, + doc_count: 18907, + pct: { + values: { + '95.0': 97561.02469135808, + '99.0': 324505.1399999999 + } + }, + avg: { + value: 30954.760723541545 + } + }, + { + key_as_string: '2018-06-12T21:00:00.000Z', + key: 1528837200000, + doc_count: 18971, + pct: { + values: { + '95.0': 102557.78813357186, + '99.0': 338040.3999999998 + } + }, + avg: { + value: 31902.050234568553 + } + }, + { + key_as_string: '2018-06-13T00:00:00.000Z', + key: 1528848000000, + doc_count: 18899, + pct: { + values: { + '95.0': 100137.87578595306, + '99.0': 328600.5173333335 + } + }, + avg: { + value: 31594.350653473728 + } + }, + { + key_as_string: '2018-06-13T03:00:00.000Z', + key: 1528858800000, + doc_count: 19182, + pct: { + values: { + '95.0': 98412.97120445351, + '99.0': 334060.93628571345 + } + }, + avg: { + value: 31343.87243248879 + } + }, + { + key_as_string: '2018-06-13T06:00:00.000Z', + key: 1528869600000, + doc_count: 19030, + pct: { + values: { + '95.0': 101607.8328012912, + '99.0': 328569.4964999998 + } + }, + avg: { + value: 31200.14450867052 + } + }, + { + key_as_string: '2018-06-13T09:00:00.000Z', + key: 1528880400000, + doc_count: 19257, + pct: { + values: { + '95.0': 92000.51368421057, + '99.0': 320227.32399999973 + } + }, + avg: { + value: 28560.946668743833 + } + }, + { + key_as_string: '2018-06-13T12:00:00.000Z', + key: 1528891200000, + doc_count: 19348, + pct: { + values: { + '95.0': 78027.29473684198, + '99.0': 292019.2899999998 + } + }, + avg: { + value: 24700.216146371717 + } + }, + { + key_as_string: '2018-06-13T15:00:00.000Z', + key: 1528902000000, + doc_count: 19119, + pct: { + values: { + '95.0': 80762.078801789, + '99.0': 297757.72666666657 + } + }, + avg: { + value: 25261.025210523563 + } + }, + { + key_as_string: '2018-06-13T18:00:00.000Z', + key: 1528912800000, + doc_count: 19206, + pct: { + values: { + '95.0': 81160.83425925927, + '99.0': 308034.4466666669 + } + }, + avg: { + value: 26041.39789649068 + } + }, + { + key_as_string: '2018-06-13T21:00:00.000Z', + key: 1528923600000, + doc_count: 19078, + pct: { + values: { + '95.0': 84215.58945578222, + '99.0': 301128.4895238093 + } + }, + avg: { + value: 26123.556295209142 + } + }, + { + key_as_string: '2018-06-14T00:00:00.000Z', + key: 1528934400000, + doc_count: 19551, + pct: { + values: { + '95.0': 194188.21428571426, + '99.0': 447266.9 + } + }, + avg: { + value: 46231.36177177638 + } + }, + { + key_as_string: '2018-06-14T03:00:00.000Z', + key: 1528945200000, + doc_count: 18888, + pct: { + values: { + '95.0': 172616.2293896504, + '99.0': 409147.332500001 + } + }, + avg: { + value: 45350.42005506141 + } + }, + { + key_as_string: '2018-06-14T06:00:00.000Z', + key: 1528956000000, + doc_count: 18823, + pct: { + values: { + '95.0': 182653.81858220184, + '99.0': 423121.9773333328 + } + }, + avg: { + value: 48256.049354513096 + } + }, + { + key_as_string: '2018-06-14T09:00:00.000Z', + key: 1528966800000, + doc_count: 18766, + pct: { + values: { + '95.0': 194970.75667682925, + '99.0': 473485.4199999998 + } + }, + avg: { + value: 52360.30017052116 + } + }, + { + key_as_string: '2018-06-14T12:00:00.000Z', + key: 1528977600000, + doc_count: 0, + pct: { + values: { + '95.0': 'NaN', + '99.0': 'NaN' + } + }, + avg: { + value: null + } + } + ] + }, + overall_avg_duration: { + value: 32861.15660262639 + } + } +}; diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform.test.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform.test.ts new file mode 100644 index 0000000000000..ecf64e393b191 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform.test.ts @@ -0,0 +1,116 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { first, last } from 'lodash'; +import { timeseriesResponse } from './mock-responses/timeseries_response'; +import { + getTpmBuckets, + TimeSeriesAPIResponse, + timeseriesTransformer +} from './transform'; + +describe('timeseriesTransformer', () => { + let res: TimeSeriesAPIResponse; + beforeEach(async () => { + res = await timeseriesTransformer({ + timeseriesResponse, + avgAnomaliesResponse: undefined, + bucketSize: 12 + }); + }); + + it('should not contain first and last bucket', () => { + const mockDates = timeseriesResponse.aggregations.transaction_results.buckets[0].timeseries.buckets.map( + bucket => bucket.key + ); + + expect(res.dates).not.toContain(first(mockDates)); + expect(res.dates).not.toContain(last(mockDates)); + expect(res.tpmBuckets[0].values).toHaveLength(res.dates.length); + }); + + it('should have correct order', () => { + expect(res.tpmBuckets.map(bucket => bucket.key)).toEqual([ + 'HTTP 2xx', + 'HTTP 3xx', + 'HTTP 4xx', + 'HTTP 5xx', + 'A Custom Bucket (that should be last)' + ]); + }); + + it('should match snapshot', () => { + expect(res).toMatchSnapshot(); + }); +}); + +describe('getTpmBuckets', () => { + it('should return response', () => { + const buckets = [ + { + key: 'HTTP 4xx', + doc_count: 300, + timeseries: { + buckets: [ + { + key_as_string: '', + key: 0, + doc_count: 0 + }, + { + key_as_string: '', + key: 1, + doc_count: 200 + }, + { + key_as_string: '', + key: 2, + doc_count: 300 + }, + { + key_as_string: '', + key: 3, + doc_count: 1337 + } + ] + } + }, + { + key: 'HTTP 5xx', + doc_count: 400, + timeseries: { + buckets: [ + { + key_as_string: '', + key: 0, + doc_count: 0 + }, + { + key_as_string: '', + key: 1, + doc_count: 500 + }, + { + key_as_string: '', + key: 2, + doc_count: 100 + }, + { + key_as_string: '', + key: 3, + doc_count: 1337 + } + ] + } + } + ]; + const bucketSize = 10; + expect(getTpmBuckets(buckets, bucketSize)).toEqual([ + { avg: 1500, key: 'HTTP 4xx', values: [1200, 1800] }, + { avg: 1800, key: 'HTTP 5xx', values: [3000, 600] } + ]); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform.ts b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform.ts new file mode 100644 index 0000000000000..ff9b28239b521 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform.ts @@ -0,0 +1,107 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { isNumber, round, sortBy } from 'lodash'; +import mean from 'lodash.mean'; +import { oc } from 'ts-optchain'; +import { IAvgAnomaliesResponse } from '../get_avg_response_time_anomalies'; +import { ESResponse } from './fetcher'; + +type MaybeNumber = number | null; + +export interface TimeSeriesAPIResponse { + totalHits: number; + dates: number[]; + responseTimes: { + avg: MaybeNumber[]; + p95: MaybeNumber[]; + p99: MaybeNumber[]; + avgAnomalies?: IAvgAnomaliesResponse; + }; + tpmBuckets: Array<{ + key: string; + avg: number; + values: number[]; + }>; + overallAvgDuration?: number; +} + +export function timeseriesTransformer({ + timeseriesResponse, + avgAnomaliesResponse, + bucketSize +}: { + timeseriesResponse: ESResponse; + avgAnomaliesResponse: IAvgAnomaliesResponse; + bucketSize: number; +}): TimeSeriesAPIResponse { + const aggs = timeseriesResponse.aggregations; + const overallAvgDuration = oc(aggs).overall_avg_duration.value(); + + const responseTimeBuckets = oc(aggs) + .response_times.buckets([]) + .slice(1, -1); + const dates = responseTimeBuckets.map(bucket => bucket.key); + const { avg, p95, p99 } = getResponseTime(responseTimeBuckets); + + const transactionResultBuckets = oc(aggs).transaction_results.buckets([]); + const tpmBuckets = getTpmBuckets(transactionResultBuckets, bucketSize); + + return { + totalHits: timeseriesResponse.hits.total, + dates, + responseTimes: { + avg, + p95, + p99, + avgAnomalies: avgAnomaliesResponse + }, + tpmBuckets, + overallAvgDuration + }; +} + +export function getTpmBuckets( + transactionResultBuckets: ESResponse['aggregations']['transaction_results']['buckets'], + bucketSize: number +) { + const buckets = transactionResultBuckets.map(({ key, timeseries }) => { + const tpmValues = timeseries.buckets + .slice(1, -1) + .map(bucket => round(bucket.doc_count * (60 / bucketSize), 1)); + + return { + key, + avg: mean(tpmValues), + values: tpmValues + }; + }); + + return sortBy( + buckets, + bucket => bucket.key.replace(/^HTTP (\d)xx$/, '00$1') // ensure that HTTP 3xx are sorted at the top + ); +} + +function getResponseTime( + responseTimeBuckets: ESResponse['aggregations']['response_times']['buckets'] +) { + return responseTimeBuckets.reduce( + (acc, bucket) => { + const { '95.0': p95, '99.0': p99 } = bucket.pct.values; + + acc.avg.push(bucket.avg.value); + acc.p95.push(isNumber(p95) ? p95 : null); + acc.p99.push(isNumber(p99) ? p99 : null); + return acc; + }, + { + avg: [] as MaybeNumber[], + p95: [] as MaybeNumber[], + p99: [] as MaybeNumber[] + } + ); +} diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/calculate_bucket_size.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/calculate_bucket_size.ts index 38025110730bf..cb0209f648b92 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/calculate_bucket_size.ts +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/calculate_bucket_size.ts @@ -54,11 +54,16 @@ export async function calculateBucketSize( params.body.query.bool.filter.push(esFilterQuery); } - const resp = await client('search', params); + interface Aggs { + stats: { + max: number; + }; + } + + const resp = await client('search', params); const minBucketSize: number = config.get('xpack.apm.minimumBucketSize'); const bucketTargetCount: number = config.get('xpack.apm.bucketTargetCount'); - const max: number = resp.aggregations.stats.max; + const max = resp.aggregations.stats.max; const bucketSize = Math.floor(max / bucketTargetCount); - return bucketSize > minBucketSize ? bucketSize : minBucketSize; } diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts similarity index 58% rename from x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets.ts rename to x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts index b552d7e3146e7..c7334fc233591 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets.ts +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SearchParams, SearchResponse } from 'elasticsearch'; -import { oc } from 'ts-optchain'; +import { AggregationSearchResponse, SearchResponse } from 'elasticsearch'; import { SERVICE_NAME, TRACE_ID, @@ -13,27 +12,11 @@ import { TRANSACTION_ID, TRANSACTION_NAME, TRANSACTION_SAMPLED -} from '../../../../common/constants'; -import { Transaction } from '../../../../typings/Transaction'; -import { Setup } from '../../helpers/setup_request'; +} from 'x-pack/plugins/apm/common/constants'; +import { Setup } from 'x-pack/plugins/apm/server/lib/helpers/setup_request'; +import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; -export interface IBucket { - key: number; - count: number; - sample?: IBucketSample; -} - -interface IBucketSample { - traceId?: string; - transactionId?: string; -} - -interface IBucketsResponse { - totalHits: number; - buckets: IBucket[]; -} - -interface ESBucket { +interface Bucket { key: number; doc_count: number; sample: SearchResponse<{ @@ -44,16 +27,24 @@ interface ESBucket { }>; } -export async function getBuckets( +interface Aggs { + distribution: { + buckets: Bucket[]; + }; +} + +export type ESResponse = AggregationSearchResponse; + +export function bucketFetcher( serviceName: string, transactionName: string, bucketSize: number, setup: Setup -): Promise { +): Promise { const { start, end, esFilterQuery, client, config } = setup; - const bucketTargetCount: number = config.get('xpack.apm.bucketTargetCount'); - const params: SearchParams = { - index: config.get('apm_oss.transactionIndices'), + const bucketTargetCount = config.get('xpack.apm.bucketTargetCount'); + const params = { + index: config.get('apm_oss.transactionIndices'), body: { size: 0, query: { @@ -102,26 +93,5 @@ export async function getBuckets( params.body.query.bool.filter.push(esFilterQuery); } - const resp = await client('search', params); - const buckets = (resp.aggregations.distribution.buckets as ESBucket[]).map( - bucket => { - const sampleSource = oc(bucket).sample.hits.hits[0]._source(); - const isSampled = oc(sampleSource).transaction.sampled(false); - const sample = { - traceId: oc(sampleSource).trace.id(), - transactionId: oc(sampleSource).transaction.id() - }; - - return { - key: bucket.key, - count: bucket.doc_count, - sample: isSampled ? sample : undefined - }; - } - ); - - return { - totalHits: resp.hits.total, - buckets - }; + return client('search', params); } diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/index.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/index.ts new file mode 100644 index 0000000000000..80ad247edf9f5 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/index.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Setup } from '../../../helpers/setup_request'; +import { bucketFetcher } from './fetcher'; +import { bucketTransformer } from './transform'; + +export async function getBuckets( + serviceName: string, + transactionName: string, + bucketSize: number, + setup: Setup +) { + const response = await bucketFetcher( + serviceName, + transactionName, + bucketSize, + setup + ); + + return bucketTransformer(response); +} diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/transform.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/transform.ts new file mode 100644 index 0000000000000..1f8b76b54c2e1 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/transform.ts @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { isEmpty } from 'lodash'; +import { oc } from 'ts-optchain'; +import { ESResponse } from './fetcher'; + +export interface IBucket { + key: number; + count: number; + sample?: IBucketSample; +} + +interface IBucketSample { + traceId?: string; + transactionId?: string; +} + +interface IBucketsResponse { + totalHits: number; + buckets: IBucket[]; + defaultSample?: IBucketSample; +} + +function getDefaultSample(buckets: IBucket[]) { + const samples = buckets + .filter(bucket => bucket.count > 0 && bucket.sample) + .map(bucket => bucket.sample); + + if (isEmpty(samples)) { + return; + } + + const middleIndex = Math.floor(samples.length / 2); + return samples[middleIndex]; +} + +export function bucketTransformer(response: ESResponse): IBucketsResponse { + const buckets = response.aggregations.distribution.buckets.map(bucket => { + const sampleSource = oc(bucket).sample.hits.hits[0]._source(); + const isSampled = oc(sampleSource).transaction.sampled(false); + const sample = { + traceId: oc(sampleSource).trace.id(), + transactionId: oc(sampleSource).transaction.id() + }; + + return { + key: bucket.key, + count: bucket.doc_count, + sample: isSampled ? sample : undefined + }; + }); + + return { + totalHits: response.hits.total, + buckets, + defaultSample: getDefaultSample(buckets) + }; +} diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/index.ts similarity index 59% rename from x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution.ts rename to x-pack/plugins/apm/server/lib/transactions/distribution/index.ts index c3ba7d53c23e3..4ad022ef911ee 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution.ts +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/index.ts @@ -4,42 +4,30 @@ * you may not use this file except in compliance with the Elastic License. */ -import { isEmpty } from 'lodash'; import { Setup } from '../../helpers/setup_request'; import { calculateBucketSize } from './calculate_bucket_size'; -import { getBuckets, IBucket } from './get_buckets'; +import { getBuckets } from './get_buckets'; +import { IBucket } from './get_buckets/transform'; -export interface IDistributionResponse { +export interface ITransactionDistributionAPIResponse { totalHits: number; buckets: IBucket[]; bucketSize: number; defaultSample?: IBucket['sample']; } -function getDefaultSample(buckets: IBucket[]) { - const samples = buckets - .filter(bucket => bucket.count > 0 && bucket.sample) - .map(bucket => bucket.sample); - - if (isEmpty(samples)) { - return; - } - - const middleIndex = Math.floor(samples.length / 2); - return samples[middleIndex]; -} - export async function getDistribution( serviceName: string, transactionName: string, setup: Setup -): Promise { +): Promise { const bucketSize = await calculateBucketSize( serviceName, transactionName, setup ); - const { buckets, totalHits } = await getBuckets( + + const { defaultSample, buckets, totalHits } = await getBuckets( serviceName, transactionName, bucketSize, @@ -50,6 +38,6 @@ export async function getDistribution( totalHits, buckets, bucketSize, - defaultSample: getDefaultSample(buckets) + defaultSample }; } diff --git a/x-pack/plugins/apm/server/lib/transactions/get_top_transactions.ts b/x-pack/plugins/apm/server/lib/transactions/get_top_transactions.ts deleted file mode 100644 index 059d3710b969a..0000000000000 --- a/x-pack/plugins/apm/server/lib/transactions/get_top_transactions.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { SearchParams, SearchResponse } from 'elasticsearch'; -import { get } from 'lodash'; -import { - PROCESSOR_EVENT, - SERVICE_NAME, - TRANSACTION_TYPE -} from '../../../common/constants'; -import { Transaction } from '../../../typings/Transaction'; -import { ITransactionGroup } from '../../../typings/TransactionGroup'; -import { Setup } from '../helpers/setup_request'; -import { - prepareTransactionGroups, - TRANSACTION_GROUP_AGGREGATES -} from '../helpers/transaction_group_query'; - -export async function getTopTransactions({ - setup, - transactionType, - serviceName -}: { - setup: Setup; - transactionType: string; - serviceName: string; -}): Promise { - const { start, end, esFilterQuery, client, config } = setup; - - const params: SearchParams = { - index: config.get('apm_oss.transactionIndices'), - body: { - size: 0, - query: { - bool: { - filter: [ - { term: { [SERVICE_NAME]: serviceName } }, - { term: { [TRANSACTION_TYPE]: transactionType } }, - { term: { [PROCESSOR_EVENT]: 'transaction' } }, - { - range: { - '@timestamp': { gte: start, lte: end, format: 'epoch_millis' } - } - } - ] - } - }, - aggs: TRANSACTION_GROUP_AGGREGATES - } - }; - - if (esFilterQuery) { - params.body.query.bool.filter.push(esFilterQuery); - } - - const response: SearchResponse = await client('search', params); - const buckets = get(response, 'aggregations.transactions.buckets', []); - - return prepareTransactionGroups({ buckets, start, end }); -} diff --git a/x-pack/plugins/apm/server/lib/transactions/get_top_transactions/index.ts b/x-pack/plugins/apm/server/lib/transactions/get_top_transactions/index.ts new file mode 100644 index 0000000000000..8b1fe99a0d3e7 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/transactions/get_top_transactions/index.ts @@ -0,0 +1,47 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { + PROCESSOR_EVENT, + SERVICE_NAME, + TRANSACTION_TYPE +} from 'x-pack/plugins/apm/common/constants'; +import { Setup } from 'x-pack/plugins/apm/server/lib/helpers/setup_request'; +import { getTransactionGroups } from '../../transaction_groups'; +import { ITransactionGroup } from '../../transaction_groups/transform'; + +export interface IOptions { + setup: Setup; + transactionType: string; + serviceName: string; +} + +export type TransactionListAPIResponse = ITransactionGroup[]; + +export async function getTopTransactions({ + setup, + transactionType, + serviceName +}: IOptions) { + const { start, end } = setup; + + const bodyQuery = { + bool: { + filter: [ + { term: { [SERVICE_NAME]: serviceName } }, + { term: { [TRANSACTION_TYPE]: transactionType } }, + { term: { [PROCESSOR_EVENT]: 'transaction' } }, + { + range: { + '@timestamp': { gte: start, lte: end, format: 'epoch_millis' } + } + } + ] + } + }; + + return getTransactionGroups(setup, bodyQuery); +} diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction.ts b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts similarity index 82% rename from x-pack/plugins/apm/server/lib/transactions/get_transaction.ts rename to x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts index 301e54d1f2a03..e88b17d4ef99c 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts @@ -4,21 +4,23 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SearchParams, SearchResponse } from 'elasticsearch'; +import { SearchParams } from 'elasticsearch'; import { oc } from 'ts-optchain'; import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; import { PROCESSOR_EVENT, TRACE_ID, TRANSACTION_ID -} from '../../../common/constants'; -import { Setup } from '../helpers/setup_request'; +} from '../../../../common/constants'; +import { Setup } from '../../helpers/setup_request'; + +export type TransactionAPIResponse = Transaction | null; export async function getTransaction( transactionId: string, traceId: string | undefined, setup: Setup -) { +): Promise { const { start, end, esFilterQuery, client, config } = setup; const params: SearchParams = { @@ -53,6 +55,6 @@ export async function getTransaction( params.body.query.bool.filter.push({ term: { [TRACE_ID]: traceId } }); } - const resp: SearchResponse = await client('search', params); + const resp = await client('search', params); return oc(resp).hits.hits[0]._source() || null; } diff --git a/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts b/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts index dc587dfd2f49b..e3c794c01a033 100644 --- a/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts +++ b/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SearchResponse } from 'elasticsearch'; import { Span } from 'x-pack/plugins/apm/typings/Span'; import { PROCESSOR_EVENT, @@ -14,11 +13,16 @@ import { } from '../../../../common/constants'; import { Setup } from '../../helpers/setup_request'; -export async function getSpans(transactionId: string, setup: Setup) { +export type SpanListAPIResponse = Span[]; + +export async function getSpans( + transactionId: string, + setup: Setup +): Promise { const { start, end, client, config } = setup; const params = { - index: config.get('apm_oss.spanIndices'), + index: config.get('apm_oss.spanIndices'), body: { size: 500, query: { @@ -50,6 +54,6 @@ export async function getSpans(transactionId: string, setup: Setup) { } }; - const resp: SearchResponse = await client('search', params); + const resp = await client('search', params); return resp.hits.hits.map(hit => hit._source); } diff --git a/x-pack/plugins/apm/server/routes/services.ts b/x-pack/plugins/apm/server/routes/services.ts index ef7bbf6c86c86..e5d225c739356 100644 --- a/x-pack/plugins/apm/server/routes/services.ts +++ b/x-pack/plugins/apm/server/routes/services.ts @@ -21,7 +21,6 @@ const pre = [{ method: setupRequest, assign: 'setup' }]; const defaultErrorHandler = (err: Error) => { // tslint:disable-next-line console.error(err.stack); - // @ts-ignore throw Boom.boomify(err, { statusCode: 400 }); }; diff --git a/x-pack/plugins/apm/server/routes/traces.ts b/x-pack/plugins/apm/server/routes/traces.ts index 7c291cf785128..f8a8a042286ca 100644 --- a/x-pack/plugins/apm/server/routes/traces.ts +++ b/x-pack/plugins/apm/server/routes/traces.ts @@ -16,7 +16,6 @@ const ROOT = '/api/apm/traces'; const defaultErrorHandler = (err: Error) => { // tslint:disable-next-line console.error(err.stack); - // @ts-ignore throw Boom.boomify(err, { statusCode: 400 }); }; diff --git a/x-pack/plugins/apm/server/routes/transactions.ts b/x-pack/plugins/apm/server/routes/transactions.ts index 01311f896ef8d..fa1104534c074 100644 --- a/x-pack/plugins/apm/server/routes/transactions.ts +++ b/x-pack/plugins/apm/server/routes/transactions.ts @@ -9,9 +9,8 @@ import { Server } from 'hapi'; import Joi from 'joi'; import { withDefaultValidators } from '../lib/helpers/input_validation'; import { setupRequest } from '../lib/helpers/setup_request'; -// @ts-ignore import { getTimeseriesData } from '../lib/transactions/charts/get_timeseries_data'; -import { getDistribution } from '../lib/transactions/distribution/get_distribution'; +import { getDistribution } from '../lib/transactions/distribution'; import { getTopTransactions } from '../lib/transactions/get_top_transactions'; import { getTransaction } from '../lib/transactions/get_transaction'; import { getSpans } from '../lib/transactions/spans/get_spans'; @@ -21,7 +20,6 @@ const ROOT = '/api/apm/services/{serviceName}/transactions'; const defaultErrorHandler = (err: Error) => { // tslint:disable-next-line console.error(err.stack); - // @ts-ignore throw Boom.boomify(err, { statusCode: 400 }); }; diff --git a/x-pack/plugins/apm/typings/APMDoc.ts b/x-pack/plugins/apm/typings/APMDoc.ts index dc8fffad9bc30..1ca520132ba61 100644 --- a/x-pack/plugins/apm/typings/APMDoc.ts +++ b/x-pack/plugins/apm/typings/APMDoc.ts @@ -14,6 +14,7 @@ export interface APMDocV1 { host: { name: string; }; + agent?: object; } export interface APMDocV2 extends APMDocV1 { @@ -46,6 +47,7 @@ export interface ContextService { name: string; version?: string; }; + [key: string]: unknown; } export interface Stackframe { @@ -70,7 +72,7 @@ export interface Stackframe { updated?: boolean; error?: string; }; - vars?: any; + vars?: unknown; orig?: { filename?: string; abs_path?: string; diff --git a/x-pack/plugins/apm/typings/Error.ts b/x-pack/plugins/apm/typings/Error.ts index a4bacfeff62ce..b422b1d801a80 100644 --- a/x-pack/plugins/apm/typings/Error.ts +++ b/x-pack/plugins/apm/typings/Error.ts @@ -31,7 +31,7 @@ export interface Error extends APMDocV1 { type?: string; code?: string; module?: string; - attributes?: any; + attributes?: unknown; handled?: boolean; stacktrace?: Stackframe[]; }; diff --git a/x-pack/plugins/apm/typings/Span.ts b/x-pack/plugins/apm/typings/Span.ts index b14a328a85988..5079d75c1d8a9 100644 --- a/x-pack/plugins/apm/typings/Span.ts +++ b/x-pack/plugins/apm/typings/Span.ts @@ -21,7 +21,7 @@ interface Processor { interface Context { db?: DbContext; service: ContextService; - [key: string]: any; + [key: string]: unknown; } export interface SpanV1 extends APMDocV1 { diff --git a/x-pack/plugins/apm/typings/Transaction.ts b/x-pack/plugins/apm/typings/Transaction.ts index 88ddcccff7de3..8498d47b00c01 100644 --- a/x-pack/plugins/apm/typings/Transaction.ts +++ b/x-pack/plugins/apm/typings/Transaction.ts @@ -21,19 +21,24 @@ interface ContextSystem { interface Context { process?: { pid: number; + [key: string]: unknown; }; service: ContextService; system?: ContextSystem; request: { url: { full: string; + [key: string]: string; }; method: string; + [key: string]: unknown; }; user?: { id: string; + username?: string; + email?: string; }; - [key: string]: any; + [key: string]: unknown; } interface Marks { diff --git a/x-pack/plugins/apm/typings/TransactionGroup.ts b/x-pack/plugins/apm/typings/TransactionGroup.ts deleted file mode 100644 index 3967d4d94d5cf..0000000000000 --- a/x-pack/plugins/apm/typings/TransactionGroup.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Transaction } from './Transaction'; - -export interface ITransactionGroup { - name: string; - sample: Transaction; - p95: number; - averageResponseTime: number; - transactionsPerMinute: number; - impact: number; -} diff --git a/x-pack/plugins/apm/typings/elasticsearch.ts b/x-pack/plugins/apm/typings/elasticsearch.ts index f3a536e8993ff..35b58795ed1ca 100644 --- a/x-pack/plugins/apm/typings/elasticsearch.ts +++ b/x-pack/plugins/apm/typings/elasticsearch.ts @@ -4,7 +4,23 @@ * you may not use this file except in compliance with the Elastic License. */ +import { SearchResponse } from 'elasticsearch'; + export interface TermsAggsBucket { key: string; doc_count: number; } + +type Omit = Pick>; +export type TopHits = Omit< + SearchResponse, + 'took' | 'timed_out' | '_shards' +>; + +declare module 'elasticsearch' { + // extending SearchResponse to be able to have typed aggregations + export interface AggregationSearchResponse + extends SearchResponse { + aggregations: U; + } +} diff --git a/x-pack/plugins/apm/typings/waterfall.ts b/x-pack/plugins/apm/typings/lodash.mean.d.ts similarity index 64% rename from x-pack/plugins/apm/typings/waterfall.ts rename to x-pack/plugins/apm/typings/lodash.mean.d.ts index d33cdcda65cc3..c61f9adf9efd4 100644 --- a/x-pack/plugins/apm/typings/waterfall.ts +++ b/x-pack/plugins/apm/typings/lodash.mean.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Span } from './Span'; -import { Transaction } from './Transaction'; - -export type WaterfallResponse = Array; +declare module 'lodash.mean' { + function mean(numbers: number[]): number; + export = mean; +} diff --git a/x-pack/plugins/apm/typings/numeral.d.ts b/x-pack/plugins/apm/typings/numeral.d.ts index d21595041f14d..f08f99f5ef11a 100644 --- a/x-pack/plugins/apm/typings/numeral.d.ts +++ b/x-pack/plugins/apm/typings/numeral.d.ts @@ -5,7 +5,7 @@ */ interface Numeral { - (value?: any): Numeral; + (value?: unknown): Numeral; format: (pattern: string) => string; } diff --git a/yarn.lock b/yarn.lock index e12b32d3a855a..13efda1fa47aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1032,143 +1032,16 @@ "@types/cp-file" "*" "@types/glob" "*" -"@types/d3-array@*": - version "1.2.3" - resolved "https://registry.yarnpkg.com/@types/d3-array/-/d3-array-1.2.3.tgz#dd141e3ba311485fffbf0792a1b01a7f2ec12dc1" - integrity sha512-yTO4ws1jnWC7iSKK8j7sUAGKIcJ628ioiGTdyXmPd36cNnuY9fDcjgEW2r19yXWuQFLu61/JhHVZ8RYYTEzFSg== - "@types/d3-array@^1.2.1": version "1.2.1" resolved "https://registry.yarnpkg.com/@types/d3-array/-/d3-array-1.2.1.tgz#e489605208d46a1c9d980d2e5772fa9c75d9ec65" integrity sha512-YBaAfimGdWE4nDuoGVKsH89/dkz2hWZ0i8qC+xxqmqi+XJ/aXiRF0jPtzXmN7VdkpVjy1xuDmM5/m1FNuB6VWA== -"@types/d3-axis@*": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@types/d3-axis/-/d3-axis-1.0.11.tgz#efd975f9fec14c2afd03828f3acec0ef97d37c3b" - integrity sha512-cuigApCyCwYJxaQPghj+BqaxzbdRdT/lpZBMtF7EuEIJ61NMQ8yvGnqFvHCIgJEmUu2Wb2wiZqy9kiHi3Ddftg== - dependencies: - "@types/d3-selection" "*" - -"@types/d3-brush@*": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@types/d3-brush/-/d3-brush-1.0.9.tgz#c71070845946eeee4cf330e04123a3997e6476bf" - integrity sha512-mAx8IVc0luUHfk51pl0UN1vzybnAzLMUsvIwLt3fbsqqPkSXr+Pu1AxOPPeyNc27LhHJnfH/LCV7Jlv+Yzqu1A== - dependencies: - "@types/d3-selection" "*" - -"@types/d3-chord@*": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@types/d3-chord/-/d3-chord-1.0.8.tgz#08c0fbb10281be0a5b3fdf48c9c081af02f79fb6" - integrity sha512-F0ftYOo7FenAIxsRjXLt8vbij0NLDuVcL+xaGY7R9jUmF2Mrpj1T5XukBI9Cad+Ei7YSxEWREIO+CYcaKCl2qQ== - -"@types/d3-collection@*": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@types/d3-collection/-/d3-collection-1.0.7.tgz#829e1db477d6bbbcdc038cbc489f22798752d707" - integrity sha512-vR3BT0GwHc5y93Jv6bxn3zoxP/vGu+GdXu/r1ApjbP9dLk9I2g6NiV7iP/QMQSuFZd0It0n/qWrfXHxCWwHIkg== - -"@types/d3-color@*": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@types/d3-color/-/d3-color-1.2.1.tgz#26141c3c554e320edd40726b793570a3ae57397e" - integrity sha512-xwb1tqvYNWllbHuhMFhiXk63Imf+QNq/dJdmbXmr2wQVnwGenCuj3/0IWJ9hdIFQIqzvhT7T37cvx93jtAsDbQ== - -"@types/d3-contour@*": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@types/d3-contour/-/d3-contour-1.2.2.tgz#b32256b55aed9e2113f88a8ea23846e357fa386c" - integrity sha512-2BIp8c80HWJP/K6t7hov6CX6G/9LWPaf1IkRXmAY3xRDr293u6OxQDSsJNc8IHl3SDWfrUw9mZhBIavS5UOGKg== - dependencies: - "@types/d3-array" "*" - "@types/geojson" "*" - -"@types/d3-dispatch@*": - version "1.0.6" - resolved "https://registry.yarnpkg.com/@types/d3-dispatch/-/d3-dispatch-1.0.6.tgz#19b173f669cd2ab7dd3d862e8037aae1a98c7508" - integrity sha512-xyWJQMr832vqhu6fD/YqX+MSFBWnkxasNhcStvlhqygXxj0cKqPft0wuGoH5TIq5ADXgP83qeNVa4R7bEYN3uA== - -"@types/d3-drag@*": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@types/d3-drag/-/d3-drag-1.2.1.tgz#6394bcf2f6414140b3b0d521259cadc6fa1da926" - integrity sha512-J9liJ4NNeV0oN40MzPiqwWjqNi3YHCRtHNfNMZ1d3uL9yh1+vDuo346LBEr8yyBm30WHvrHssAkExVZrGCswtA== - dependencies: - "@types/d3-selection" "*" - -"@types/d3-dsv@*": - version "1.0.33" - resolved "https://registry.yarnpkg.com/@types/d3-dsv/-/d3-dsv-1.0.33.tgz#18de1867927f7ec898671aef82f730f16d4c7fcb" - integrity sha512-jx5YvaVC3Wfh6LobaiWTeU1NkvL2wPmmpmajk618bD+xVz98yNWzmZMvmlPHGK0HXbMeHmW/6oVX48V9AH1bRQ== - -"@types/d3-ease@*": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@types/d3-ease/-/d3-ease-1.0.7.tgz#93a301868be9e15061f3d44343b1ab3f8acb6f09" - integrity sha1-k6MBhovp4VBh89RDQ7GrP4rLbwk= - -"@types/d3-fetch@*": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@types/d3-fetch/-/d3-fetch-1.1.2.tgz#a59921477e25850ca6b3353e03d5d29e5a0e8e03" - integrity sha512-w6ANZv/mUh+6IV3drT22zgPWMRobzuGXhzOZC8JPD+ygce0/Vx6vTci3m3dizkocnQQCOwNbrWWWPYqpWiKzRQ== - dependencies: - "@types/d3-dsv" "*" - -"@types/d3-force@*": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@types/d3-force/-/d3-force-1.1.1.tgz#185c18b77932df63457894bd36d0d6e9692546c0" - integrity sha512-ePkELuaFWY4yOuf+Bvx5Xd+ihFiYG4bdnW0BlvigovIm8Sob2t76e9RGO6lybQbv6AlW9Icn9HuZ9fmdzEoJyg== - -"@types/d3-format@*": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@types/d3-format/-/d3-format-1.3.0.tgz#c5e115fac8e6861ce656fe9861892b22f6b0cfcb" - integrity sha512-ZiY4j3iJvAdOwzwW24WjlZbUNvqOsnPAMfPBmdXqxj3uKJbrzBlRrdGl5uC89pZpFs9Dc92E81KcwG2uEgkIZA== - -"@types/d3-geo@*": - version "1.10.3" - resolved "https://registry.yarnpkg.com/@types/d3-geo/-/d3-geo-1.10.3.tgz#3c01b2baa480e1108301096328dc2837e7ff4d8a" - integrity sha512-hfdaxM2L0wA9mDZrrSf2o+DyhEpnJYCiAN+lHFtpfZOVCQrYBA5g33sGRpUbAvjSMyO5jkHbftMWPEhuCMChSg== - dependencies: - "@types/geojson" "*" - -"@types/d3-hierarchy@*": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@types/d3-hierarchy/-/d3-hierarchy-1.1.4.tgz#b04dfcb1f2074da789ada10fe4942d13f0bce421" - integrity sha512-+d2VLfLPgW66VB7k56T8tC4LobfS6Rrhm+1pmYPMmlCpO5rccJLuwux7YXl/eGVst3Bhb5PJTN5/oaJERpNw8g== - -"@types/d3-interpolate@*": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@types/d3-interpolate/-/d3-interpolate-1.3.0.tgz#65b9627900bfdd82474875d9b23d574a4388af7c" - integrity sha512-Ng4ds7kPSvP/c3W3J5PPUQlgewif1tGBqCeh5lgY+UG82Y7H9zQ8c2gILsEFDLg7wRGOwnuKZ940Q/LSN14w9w== - dependencies: - "@types/d3-color" "*" - "@types/d3-path@*": version "1.0.7" resolved "https://registry.yarnpkg.com/@types/d3-path/-/d3-path-1.0.7.tgz#a0736fceed688a695f48265a82ff7a3369414b81" integrity sha512-U8dFRG+8WhkLJr2sxZ9Cw/5WeRgBnNqMxGdA1+Z0+ZG6tK0s75OQ4OXnxeyfKuh6E4wQPY8OAKr1+iNDx01BEQ== -"@types/d3-polygon@*": - version "1.0.6" - resolved "https://registry.yarnpkg.com/@types/d3-polygon/-/d3-polygon-1.0.6.tgz#db25c630a2afb9191fe51ba61dd37baee9dd44c7" - integrity sha512-E6Kyodn9JThgLq20nxSbEce9ow5/ePgm9PX2EO6W1INIL4DayM7cFaiG10DStuamjYAd0X4rntW2q+GRjiIktw== - -"@types/d3-quadtree@*": - version "1.0.6" - resolved "https://registry.yarnpkg.com/@types/d3-quadtree/-/d3-quadtree-1.0.6.tgz#45da9e603688ba90eedd3d40f6e504764e06e493" - integrity sha512-sphVuDdiSIaxLt9kQgebJW98pTktQ/xuN7Ysd8X68Rnjeg/q8+c36/ShlqU52qoKg9nob/JEHH1uQMdxURZidQ== - -"@types/d3-random@*": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@types/d3-random/-/d3-random-1.1.1.tgz#38647ce2ff4ce7d0d56974334c1c4092513c8b9f" - integrity sha512-jUPeBq1XKK9/5XasTvy5QAUwFeMsjma2yt/nP02yC2Tijovx7i/W5776U/HZugxc5SSmtpx4Z3g9KFVon0QrjQ== - -"@types/d3-scale-chromatic@*": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@types/d3-scale-chromatic/-/d3-scale-chromatic-1.3.0.tgz#b8b58a7a262a583fc1c95ce851d5a75811875034" - integrity sha512-JqQH5uu1kmdQEa6XSu7NYzQM71lL1YreBPS5o8SnmEDcBRKL6ooykXa8iFPPOEUiTah25ydi+cTrbsogBSMNSQ== - -"@types/d3-scale@*": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@types/d3-scale/-/d3-scale-2.0.2.tgz#61145948aa1a52ab31384766cd013308699112b3" - integrity sha512-pnmZsEVwTyX+68bjG9r3XXUBASUF6z3Ir2nlrv81mWCH9yqeRscR98myMNP5OwDd9urUnvjNabJul5B9K0+F2w== - dependencies: - "@types/d3-time" "*" - "@types/d3-scale@^2.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/d3-scale/-/d3-scale-2.0.1.tgz#f94cd991c50422b2e68d8f43be3f9fffdb1ae7be" @@ -1176,18 +1049,6 @@ dependencies: "@types/d3-time" "*" -"@types/d3-selection@*": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@types/d3-selection/-/d3-selection-1.3.2.tgz#dd5661a560ba9ce3aba823c424b8d4a1bc7e833f" - integrity sha512-K23sDOi7yMussv7aiqk097IWWbjFYbJpcDppQAcaf6DfmHxAsjr+6N4HJGokETLDuV7y/qJeeIJINPnkWJM5Hg== - -"@types/d3-shape@*": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@types/d3-shape/-/d3-shape-1.2.4.tgz#e65585f2254d83ae42c47af2e730dd9b97952996" - integrity sha512-X4Xq2mpChPIMDMAXwLfxHKLbqv+sowkJ94bENeSMqqhQJ5v4oXuoyLo0vnIkydVbuQ52ZwPplk219K0m2HJODg== - dependencies: - "@types/d3-path" "*" - "@types/d3-shape@^1.2.2": version "1.2.3" resolved "https://registry.yarnpkg.com/@types/d3-shape/-/d3-shape-1.2.3.tgz#cadc9f93a626db9190f306048a650df4ffa4e500" @@ -1195,7 +1056,7 @@ dependencies: "@types/d3-path" "*" -"@types/d3-time-format@*", "@types/d3-time-format@^2.1.0": +"@types/d3-time-format@^2.1.0": version "2.1.0" resolved "https://registry.yarnpkg.com/@types/d3-time-format/-/d3-time-format-2.1.0.tgz#011e0fb7937be34a9a8f580ae1e2f2f1336a8a22" integrity sha512-/myT3I7EwlukNOX2xVdMzb8FRgNzRMpsZddwst9Ld/VFe6LyJyRp0s32l/V9XoUzk+Gqu56F/oGk6507+8BxrA== @@ -1205,67 +1066,10 @@ resolved "https://registry.yarnpkg.com/@types/d3-time/-/d3-time-1.0.8.tgz#6c083127b330b3c2fc65cd0f3a6e9cbd9607b28c" integrity sha512-/UCphyyw97YAq4zKsuXH33R3UNB4jDSza0fLvMubWr/ONh9IePi1NbgFP222blhiCe724ebJs8U87+aDuAq/jA== -"@types/d3-timer@*": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@types/d3-timer/-/d3-timer-1.0.8.tgz#a3441d9605367059e14ad8c3494132143cbc8d58" - integrity sha512-AKUgQ/nljUFcUO2P3gK24weVI5XwUTdJvjoh8gJ0yxT4aJ+d7t2Or3TB+k9dEYl14BAjoj32D0ky+YzQSVszfg== - -"@types/d3-transition@*": - version "1.1.3" - resolved "https://registry.yarnpkg.com/@types/d3-transition/-/d3-transition-1.1.3.tgz#efcf4941dae22135d595514ba488f4f370d396b0" - integrity sha512-1EukXNuVu/z2G1GZpZagzFJnie9C5zze17ox/vhTgGXNy46rYAm4UkhLLlUeeZ1ndq88k95SOeC8898RpKMLOQ== - dependencies: - "@types/d3-selection" "*" - -"@types/d3-voronoi@*": - version "1.1.8" - resolved "https://registry.yarnpkg.com/@types/d3-voronoi/-/d3-voronoi-1.1.8.tgz#a039cb8368bce4efc1a70aebe744d210851cf1a7" - integrity sha512-zqNhW7QsYQGlfOdrwPNPG3Wk64zUa4epKRurkJ/dVc6oeXrB+iTDt8sRZ0KZKOOXvvfa1dcdB0e45TZeLBiodQ== - -"@types/d3-zoom@*": - version "1.7.2" - resolved "https://registry.yarnpkg.com/@types/d3-zoom/-/d3-zoom-1.7.2.tgz#ee67f063199c179949d83b6b1e6166207de5f06e" - integrity sha512-/ORNUzQ0g7h2f34L/hD1o+IytOjpNLwEf403yKmYAA+z3LC8eCH6xCKaCc0weuCWwiaZ2UqBW41Y6ciqjd+ndQ== - dependencies: - "@types/d3-interpolate" "*" - "@types/d3-selection" "*" - -"@types/d3@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@types/d3/-/d3-5.0.0.tgz#fec49f2aea0f0784f829eff38132926e92676d57" - integrity sha512-BVfPw7ha+UgsG24v6ymerMY4+pJgQ/6p+hJA4loCeaaqV9snGS/G6ReVaQEn8Himn67dWn/Je9WhRbnDO7MzLw== - dependencies: - "@types/d3-array" "*" - "@types/d3-axis" "*" - "@types/d3-brush" "*" - "@types/d3-chord" "*" - "@types/d3-collection" "*" - "@types/d3-color" "*" - "@types/d3-contour" "*" - "@types/d3-dispatch" "*" - "@types/d3-drag" "*" - "@types/d3-dsv" "*" - "@types/d3-ease" "*" - "@types/d3-fetch" "*" - "@types/d3-force" "*" - "@types/d3-format" "*" - "@types/d3-geo" "*" - "@types/d3-hierarchy" "*" - "@types/d3-interpolate" "*" - "@types/d3-path" "*" - "@types/d3-polygon" "*" - "@types/d3-quadtree" "*" - "@types/d3-random" "*" - "@types/d3-scale" "*" - "@types/d3-scale-chromatic" "*" - "@types/d3-selection" "*" - "@types/d3-shape" "*" - "@types/d3-time" "*" - "@types/d3-time-format" "*" - "@types/d3-timer" "*" - "@types/d3-transition" "*" - "@types/d3-voronoi" "*" - "@types/d3-zoom" "*" +"@types/d3@^3.5.41": + version "3.5.41" + resolved "https://registry.yarnpkg.com/@types/d3/-/d3-3.5.41.tgz#57f08fc79b75f0fecb0b3547abc22e46e9d660e4" + integrity sha512-dInnr7nSPsofnLggOf70xvsInUjf3tRrE8XmxsioXALWQHkwEWi7RhTBCa9mYmiUDHMtuanSDN/JOW187ChIhw== "@types/dedent@^0.7.0": version "0.7.0" @@ -1353,11 +1157,6 @@ dependencies: "@types/node" "*" -"@types/geojson@*": - version "7946.0.4" - resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.4.tgz#4e049756383c3f055dd8f3d24e63fb543e98eb07" - integrity sha512-MHmwBtCb7OCv1DSivz2UNJXPGU/1btAWRKlqJ2saEhVJkpkvqHMMaOpKg0v4sAbDWSQekHGvPVMM8nQ+Jen03Q== - "@types/getopts@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@types/getopts/-/getopts-2.0.0.tgz#8a603370cb367d3192bd8012ad39ab2320b5b476" @@ -1435,6 +1234,11 @@ resolved "https://registry.yarnpkg.com/@types/hoek/-/hoek-4.1.3.tgz#d1982d48fb0d2a0e5d7e9d91838264d8e428d337" integrity sha1-0ZgtSPsNKg5dfp2Rg4Jk2OQo0zc= +"@types/humps@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@types/humps/-/humps-1.1.2.tgz#fbcaf596d20ff2ed78f8f511c5d6a943b51101d6" + integrity sha1-+8r1ltIP8u14+PURxdapQ7URAdY= + "@types/indent-string@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/indent-string/-/indent-string-3.0.0.tgz#9ebb391ceda548926f5819ad16405349641b999f" From 43d4c22add95e6693972b967d1d8f09b45b153ad Mon Sep 17 00:00:00 2001 From: Leanid Shutau Date: Thu, 22 Nov 2018 13:41:03 +0300 Subject: [PATCH 66/95] [I18n] Translate Graph (#23987) * [I18n] Add Graph translations * Fix typo * Use template strings --- .i18nrc.json | 1 + x-pack/plugins/graph/public/app.js | 150 ++++++-- .../plugins/graph/public/register_feature.js | 6 +- .../graph/public/services/outlink_encoders.js | 50 ++- .../plugins/graph/public/templates/index.html | 325 +++++++++++++----- .../public/templates/load_workspace.html | 8 +- .../public/templates/save_workspace.html | 50 ++- .../graph/public/templates/settings.html | 223 ++++++++---- .../plugins/graph/server/lib/check_license.js | 22 +- 9 files changed, 620 insertions(+), 215 deletions(-) diff --git a/.i18nrc.json b/.i18nrc.json index 0c780d84c5b1a..45108fa6b8e63 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -14,6 +14,7 @@ "tileMap": "src/core_plugins/tile_map", "timelion": "src/core_plugins/timelion", "tagCloud": "src/core_plugins/tagcloud", + "xpack.graph": "x-pack/plugins/graph", "xpack.grokDebugger": "x-pack/plugins/grokdebugger", "xpack.idxMgmt": "x-pack/plugins/index_management", "xpack.infra": "x-pack/plugins/infra", diff --git a/x-pack/plugins/graph/public/app.js b/x-pack/plugins/graph/public/app.js index f7fa2f01bf288..77ae583ad259d 100644 --- a/x-pack/plugins/graph/public/app.js +++ b/x-pack/plugins/graph/public/app.js @@ -39,7 +39,7 @@ import { drillDownIconChoicesByClass } from './style_choices'; import { - outlinkEncoders + getOutlinkEncoders, } from './services/outlink_encoders'; const app = uiModules.get('app/graph'); @@ -96,11 +96,15 @@ uiRoutes .when('/workspace/:id', { template: appTemplate, resolve: { - savedWorkspace: function (savedGraphWorkspaces, courier, $route) { + savedWorkspace: function (savedGraphWorkspaces, courier, $route, i18n) { return savedGraphWorkspaces.get($route.current.params.id) .catch( function () { - toastNotifications.addDanger('Missing workspace'); + toastNotifications.addDanger( + i18n('xpack.graph.missingWorkspaceErrorMessage', { + defaultMessage: 'Missing workspace', + }) + ); } ); @@ -131,7 +135,7 @@ uiRoutes //======== Controller for basic UI ================== -app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnUrl, Private, Promise, confirmModal, kbnBaseUrl) { +app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnUrl, Private, Promise, confirmModal, kbnBaseUrl, i18n) { function handleSuccess(data) { return checkLicense(Private, Promise, kbnBaseUrl) @@ -151,7 +155,7 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU $scope.colors = colorChoices; $scope.iconChoicesByClass = iconChoicesByClass; - $scope.outlinkEncoders = outlinkEncoders; + $scope.outlinkEncoders = getOutlinkEncoders(i18n); $scope.fields = []; $scope.canEditDrillDownUrls = chrome.getInjected('canEditDrillDownUrls'); @@ -290,9 +294,13 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU const confirmModalOptions = { onConfirm: yesFn, onCancel: noFn, - confirmButtonText: 'Clear workspace' + confirmButtonText: i18n('xpack.graph.clearWorkspace.confirmButtonLabel', { + defaultMessage: 'Clear workspace', + }) }; - confirmModal('This will clear the workspace - are you sure?', confirmModalOptions); + confirmModal(i18n('xpack.graph.clearWorkspace.confirmText', { + defaultMessage: 'This will clear the workspace - are you sure?', + }), confirmModalOptions); } $scope.uiSelectIndex = function () { @@ -387,7 +395,11 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU return $http.post('../api/graph/graphExplore', request) .then(function (resp) { if (resp.data.resp.timed_out) { - toastNotifications.addWarning('Exploration timed out'); + toastNotifications.addWarning( + i18n('xpack.graph.exploreGraph.timedOutWarningText', { + defaultMessage: 'Exploration timed out', + }) + ); } responseHandler(resp.data.resp); }) @@ -536,8 +548,15 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU const found = $scope.newUrlTemplate.url.search(drillDownRegex) > -1; if (!found) { toastNotifications.addWarning({ - title: 'Invalid URL', - text: 'The URL must contain a {{gquery}} string', + title: i18n('xpack.graph.settings.drillDowns.invalidUrlWarningTitle', { + defaultMessage: 'Invalid URL', + }), + text: i18n('xpack.graph.settings.drillDowns.invalidUrlWarningText', { + defaultMessage: 'The URL must contain a {placeholder} string', + values: { + placeholder: '{{gquery}}' + } + }), }); return; } @@ -556,10 +575,18 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU $scope.removeUrlTemplate = function (urlTemplate) { const i = $scope.urlTemplates.indexOf(urlTemplate); if (i != -1) { - confirmModal('Remove "' + urlTemplate.description + '" drill-down?', { - onConfirm: () => $scope.urlTemplates.splice(i, 1), - confirmButtonText: 'Remove drill-down' - }); + confirmModal( + i18n('xpack.graph.settings.drillDowns.removeConfirmText', { + defaultMessage: 'Remove "{urlTemplateDesciption}" drill-down?', + values: { urlTemplateDesciption: urlTemplate.description }, + }), + { + onConfirm: () => $scope.urlTemplates.splice(i, 1), + confirmButtonText: i18n('xpack.graph.settings.drillDowns.removeConfirmButtonLabel', { + defaultMessage: 'Remove drill-down', + }), + }, + ); } }; @@ -651,7 +678,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU $scope.urlTemplates.push({ url: discoverUrl, - description: 'Raw documents', + description: i18n('xpack.graph.settings.drillDowns.defaultUrlTemplateTitle', { + defaultMessage: 'Raw documents', + }), encoder: $scope.outlinkEncoders[0] }); } @@ -730,30 +759,46 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU $scope.topNavMenu = []; $scope.topNavMenu.push({ key: 'new', - description: 'New Workspace', - tooltip: 'Create a new workspace', + description: i18n('xpack.graph.topNavMenu.newWorkspaceAriaLabel', { + defaultMessage: 'New Workspace', + }), + tooltip: i18n('xpack.graph.topNavMenu.newWorkspaceTooltip', { + defaultMessage: 'Create a new workspace', + }), run: function () {canWipeWorkspace(function () {kbnUrl.change('/home', {}); }); }, }); if (!$scope.allSavingDisabled) { $scope.topNavMenu.push({ key: 'save', - description: 'Save Workspace', - tooltip: 'Save this workspace', + description: i18n('xpack.graph.topNavMenu.saveWorkspace.enabledAriaLabel', { + defaultMessage: 'Save Workspace', + }), + tooltip: i18n('xpack.graph.topNavMenu.saveWorkspace.enabledTooltip', { + defaultMessage: 'Save this workspace', + }), disableButton: function () {return $scope.selectedFields.length === 0;}, template: require('./templates/save_workspace.html') }); }else { $scope.topNavMenu.push({ key: 'save', - description: 'Save Workspace', - tooltip: 'No changes to saved workspaces are permitted by the current save policy', + description: i18n('xpack.graph.topNavMenu.saveWorkspace.disabledAriaLabel', { + defaultMessage: 'Save Workspace', + }), + tooltip: i18n('xpack.graph.topNavMenu.saveWorkspace.disabledTooltip', { + defaultMessage: 'No changes to saved workspaces are permitted by the current save policy', + }), disableButton: true }); } $scope.topNavMenu.push({ key: 'open', - description: 'Load Saved Workspace', - tooltip: 'Load a saved workspace', + description: i18n('xpack.graph.topNavMenu.loadWorkspaceAriaLabel', { + defaultMessage: 'Load Saved Workspace', + }), + tooltip: i18n('xpack.graph.topNavMenu.loadWorkspaceTooltip', { + defaultMessage: 'Load a saved workspace', + }), template: require('./templates/load_workspace.html') }); if (!$scope.allSavingDisabled) { @@ -762,35 +807,58 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU disableButton: function () { return $route.current.locals === undefined || $route.current.locals.savedWorkspace === undefined; }, - description: 'Delete Saved Workspace', - tooltip: 'Delete this workspace', + description: i18n('xpack.graph.topNavMenu.deleteWorkspace.enabledAriaLabel', { + defaultMessage: 'Delete Saved Workspace', + }), + tooltip: i18n('xpack.graph.topNavMenu.deleteWorkspace.enabledAriaTooltip', { + defaultMessage: 'Delete this workspace', + }), run: function () { const title = $route.current.locals.savedWorkspace.title; function doDelete() { $route.current.locals.SavedWorkspacesProvider.delete($route.current.locals.savedWorkspace.id); kbnUrl.change('/home', {}); - toastNotifications.addSuccess(`Deleted '${title}'`); + toastNotifications.addSuccess( + i18n('xpack.graph.topNavMenu.deleteWorkspaceNotification', { + defaultMessage: `Deleted '{workspaceTitle}'`, + values: { workspaceTitle: title }, + }) + ); } const confirmModalOptions = { onConfirm: doDelete, - confirmButtonText: 'Delete workspace' + confirmButtonText: i18n('xpack.graph.topNavMenu.deleteWorkspace.confirmButtonLabel', { + defaultMessage: 'Delete workspace', + }), }; - confirmModal('Are you sure you want to delete the workspace ' + title + ' ?', confirmModalOptions); + confirmModal( + i18n('xpack.graph.topNavMenu.deleteWorkspace.confirmText', { + defaultMessage: 'Are you sure you want to delete the workspace {title} ?', + values: { title }, + }), + confirmModalOptions + ); } }); }else { $scope.topNavMenu.push({ key: 'delete', disableButton: true, - description: 'Delete Saved Workspace', - tooltip: 'No changes to saved workspaces are permitted by the current save policy' + description: i18n('xpack.graph.topNavMenu.deleteWorkspace.disabledAriaLabel', { + defaultMessage: 'Delete Saved Workspace', + }), + tooltip: i18n('xpack.graph.topNavMenu.deleteWorkspace.disabledTooltip', { + defaultMessage: 'No changes to saved workspaces are permitted by the current save policy', + }), }); } $scope.topNavMenu.push({ key: 'settings', disableButton: function () { return $scope.selectedIndex === null; }, - description: 'Settings', + description: i18n('xpack.graph.topNavMenu.settingsAriaLabel', { + defaultMessage: 'Settings', + }), template: require('./templates/settings.html') }); @@ -829,7 +897,12 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU } }); if(!savedObjectIndexPattern) { - toastNotifications.addDanger(`'Missing index pattern ${wsObj.indexPattern}`); + toastNotifications.addDanger( + i18n('xpack.graph.loadWorkspace.missingIndexPatternErrorMessage', { + defaultMessage: `'Missing index pattern {indexPattern}`, + values: { indexPattern: wsObj.indexPattern }, + }) + ); return; } @@ -946,7 +1019,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU if ($scope.allSavingDisabled) { // It should not be possible to navigate to this function if allSavingDisabled is set // but adding check here as a safeguard. - toastNotifications.addWarning('Saving is disabled'); + toastNotifications.addWarning( + i18n('xpack.graph.saveWorkspace.disabledWarning', { defaultMessage: 'Saving is disabled' }) + ); return; } initWorkspaceIfRequired(); @@ -1034,10 +1109,15 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU $scope.kbnTopNav.close('save'); $scope.userHasConfirmedSaveWorkspaceData = false; //reset flag if (id) { - const title = `Saved "${$scope.savedWorkspace.title}"`; + const title = i18n('xpack.graph.saveWorkspace.successNotificationTitle', { + defaultMessage: 'Saved "{workspaceTitle}"', + values: { workspaceTitle: $scope.savedWorkspace.title }, + }); let text; if (!canSaveData && $scope.workspace.nodes.length > 0) { - text = 'The configuration was saved, but the data was not saved'; + text = i18n('xpack.graph.saveWorkspace.successNotification.noDataSavedText', { + defaultMessage: 'The configuration was saved, but the data was not saved', + }); } toastNotifications.addSuccess({ diff --git a/x-pack/plugins/graph/public/register_feature.js b/x-pack/plugins/graph/public/register_feature.js index d780614972562..c147982dc081c 100644 --- a/x-pack/plugins/graph/public/register_feature.js +++ b/x-pack/plugins/graph/public/register_feature.js @@ -8,11 +8,13 @@ import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue'; -FeatureCatalogueRegistryProvider.register(() => { +FeatureCatalogueRegistryProvider.register((i18n) => { return { id: 'graph', title: 'Graph', - description: 'Surface and analyze relevant relationships in your Elasticsearch data.', + description: i18n('xpack.graph.pluginDescription', { + defaultMessage: 'Surface and analyze relevant relationships in your Elasticsearch data.', + }), icon: 'graphApp', path: '/app/graph', showOnHomePage: true, diff --git a/x-pack/plugins/graph/public/services/outlink_encoders.js b/x-pack/plugins/graph/public/services/outlink_encoders.js index e32fd090ff13d..cfc9d745cf8e8 100644 --- a/x-pack/plugins/graph/public/services/outlink_encoders.js +++ b/x-pack/plugins/graph/public/services/outlink_encoders.js @@ -6,38 +6,58 @@ import rison from 'rison-node'; -export const outlinkEncoders = [{ +export const getOutlinkEncoders = i18n => [{ id: 'esq-rison-loose', - title: 'elasticsearch OR query (rison encoded)', - description: 'rison-encoded JSON, minimum_should_match=1, compatible with most Kibana URLs', + title: i18n('xpack.graph.outlinkEncoders.esqRisonLooseTitle', { + defaultMessage: 'elasticsearch OR query (rison encoded)', + }), + description: i18n('xpack.graph.outlinkEncoders.esqRisonLooseDescription', { + defaultMessage: 'rison-encoded JSON, minimum_should_match=1, compatible with most Kibana URLs', + }), encode: function (workspace) { return encodeURIComponent(rison.encode(workspace.getQuery(workspace.getSelectedOrAllNodes(), true))); } }, { id: 'esq-rison', - title: 'elasticsearch AND query (rison encoded)', - description: 'rison-encoded JSON, minimum_should_match=2, compatible with most Kibana URLs', + title: i18n('xpack.graph.outlinkEncoders.esqRisonTitle', { + defaultMessage: 'elasticsearch AND query (rison encoded)', + }), + description: i18n('xpack.graph.outlinkEncoders.esqRisonDescription', { + defaultMessage: 'rison-encoded JSON, minimum_should_match=2, compatible with most Kibana URLs', + }), encode: function (workspace) { return encodeURIComponent(rison.encode(workspace.getQuery(workspace.getSelectedOrAllNodes()))); } }, { id: 'esq-similar-rison', - title: 'elasticsearch more like this query (rison encoded)', - description: 'rison-encoded JSON, "like this but not this" type query to find missing docs', + title: i18n('xpack.graph.outlinkEncoders.esqSimilarRisonTitle', { + defaultMessage: 'elasticsearch more like this query (rison encoded)', + }), + description: i18n('xpack.graph.outlinkEncoders.esqSimilarRisonDescription', { + defaultMessage: 'rison-encoded JSON, "like this but not this" type query to find missing docs', + }), encode: function (workspace) { return encodeURIComponent(rison.encode(workspace.getLikeThisButNotThisQuery(workspace.getSelectedOrAllNodes()))); } }, { id: 'esq-plain', - title: 'elasticsearch query (plain encoding)', - description: 'JSON encoded using standard url encoding', + title: i18n('xpack.graph.outlinkEncoders.esqPlainTitle', { + defaultMessage: 'elasticsearch query (plain encoding)', + }), + description: i18n('xpack.graph.outlinkEncoders.esqPlainDescription', { + defaultMessage: 'JSON encoded using standard url encoding', + }), encode: function (workspace) { return encodeURIComponent(JSON.stringify(workspace.getQuery(workspace.getSelectedOrAllNodes()))); } }, { id: 'text-plain', - title: 'plain text', - description: 'Text of selected vertex labels as a plain url-encoded string', + title: i18n('xpack.graph.outlinkEncoders.textPlainTitle', { + defaultMessage: 'plain text', + }), + description: i18n('xpack.graph.outlinkEncoders.textPlainDescription', { + defaultMessage: 'Text of selected vertex labels as a plain url-encoded string', + }), encode: function (workspace) { let q = ''; const nodes = workspace.getSelectedOrAllNodes(); @@ -52,8 +72,12 @@ export const outlinkEncoders = [{ } }, { id: 'text-lucene', - title: 'Lucene-escaped text', - description: 'Text of selected vertex labels with any Lucene special characters encoded', + title: i18n('xpack.graph.outlinkEncoders.textLuceneTitle', { + defaultMessage: 'Lucene-escaped text', + }), + description: i18n('xpack.graph.outlinkEncoders.textLuceneDescription', { + defaultMessage: 'Text of selected vertex labels with any Lucene special characters encoded', + }), encode: function (workspace) { let q = ''; const nodes = workspace.getSelectedOrAllNodes(); diff --git a/x-pack/plugins/graph/public/templates/index.html b/x-pack/plugins/graph/public/templates/index.html index 7548c60c9d0eb..20e54d4f569e5 100644 --- a/x-pack/plugins/graph/public/templates/index.html +++ b/x-pack/plugins/graph/public/templates/index.html @@ -5,18 +5,36 @@
- {{ savedWorkspace.lastSavedTitle || 'New Graph Workspace' }} + {{ savedWorkspace.lastSavedTitle }} +
- + @@ -27,9 +45,18 @@ - - @@ -39,7 +66,12 @@
-
@@ -51,14 +83,23 @@
- +
- +
@@ -68,13 +109,21 @@
- +
-
@@ -94,7 +143,12 @@
- +
- +
- +
-

Controls the number of terms returned each search step.

+

- Shift-clicking the field icons in the menu bar - provides a quick way to toggle this number to zero and back + + {{ + ::'xpack.graph.queryConfig.maxTermsHelpText' | i18n: { + defaultMessage: 'Shift-clicking the field icons in the menu bar provides a quick way to toggle this number to zero and back' + } + }}
@@ -137,9 +208,12 @@
- +
@@ -222,86 +296,122 @@
{{detail.label}} + {{detail.label}} {{detail.value}} ({{detail.percent}}) - - Reserved - - +
- + { tableRows } diff --git a/x-pack/plugins/monitoring/public/components/chart/monitoring_timeseries_container.js b/x-pack/plugins/monitoring/public/components/chart/monitoring_timeseries_container.js index abf8598230a67..4a48424f9ed08 100644 --- a/x-pack/plugins/monitoring/public/components/chart/monitoring_timeseries_container.js +++ b/x-pack/plugins/monitoring/public/components/chart/monitoring_timeseries_container.js @@ -14,8 +14,9 @@ import { InfoTooltip } from './info_tooltip'; import { EuiIconTip, EuiFlexGroup, EuiFlexItem, EuiTitle, EuiScreenReaderOnly } from '@elastic/eui'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; -export function MonitoringTimeseriesContainer({ series, onBrush }) { +function MonitoringTimeseriesContainerUI({ series, onBrush, intl }) { if (series === undefined) { return null; // still loading } @@ -25,7 +26,13 @@ export function MonitoringTimeseriesContainer({ series, onBrush }) { const units = getUnits(series); const bucketSize = get(first(series), 'bucket_size'); // bucket size will be the same for all metrics in all series - const seriesScreenReaderTextList = [`Interval: ${bucketSize}`] + const seriesScreenReaderTextList = [ + intl.formatMessage({ + id: 'xpack.monitoring.chart.seriesScreenReaderListDescription', + defaultMessage: 'Interval: {bucketSize}' }, { + bucketSize + }) + ] .concat(series.map(item => `${item.metric.label}: ${item.metric.description}`)); return ( @@ -35,7 +42,14 @@ export function MonitoringTimeseriesContainer({ series, onBrush }) { - This chart is not screen reader accessible + + + + +

{ getTitle(series) }{ units ? ` (${units})` : '' }

@@ -69,3 +83,5 @@ export function MonitoringTimeseriesContainer({ series, onBrush }) { ); } +export const MonitoringTimeseriesContainer = injectI18n(MonitoringTimeseriesContainerUI); + diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/__snapshots__/ccr_shard.test.js.snap b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/__snapshots__/ccr_shard.test.js.snap index aa5059ed84e16..9285aa7226e57 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/__snapshots__/ccr_shard.test.js.snap +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/ccr_shard/__snapshots__/ccr_shard.test.js.snap @@ -131,7 +131,7 @@ exports[`CcrShard that it renders normally 1`] = ` hasShadow={false} paddingSize="m" > - +
- + diff --git a/x-pack/plugins/monitoring/public/directives/chart/index.js b/x-pack/plugins/monitoring/public/directives/chart/index.js index 7237a97f48887..48912e7ecba75 100644 --- a/x-pack/plugins/monitoring/public/directives/chart/index.js +++ b/x-pack/plugins/monitoring/public/directives/chart/index.js @@ -11,6 +11,7 @@ import { uiModules } from 'ui/modules'; import { timefilter } from 'ui/timefilter'; import { MonitoringTimeseriesContainer } from '../../components/chart/monitoring_timeseries_container'; import { EuiSpacer } from '@elastic/eui'; +import { I18nProvider } from '@kbn/i18n/react'; const uiModule = uiModules.get('plugins/monitoring/directives', []); uiModule.directive('monitoringChart', () => { @@ -30,13 +31,15 @@ uiModule.directive('monitoringChart', () => { scope.$watch('series', series => { render( - - - - , + + + + + + , $elem[0] ); }); diff --git a/x-pack/plugins/monitoring/public/views/apm/instance/index.js b/x-pack/plugins/monitoring/public/views/apm/instance/index.js index d815e2f537b4b..a9afb883ae725 100644 --- a/x-pack/plugins/monitoring/public/views/apm/instance/index.js +++ b/x-pack/plugins/monitoring/public/views/apm/instance/index.js @@ -19,6 +19,7 @@ import template from './index.html'; import { MonitoringViewBaseController } from '../../base_controller'; import { ApmServerInstance } from '../../../components/apm/instance'; import { timefilter } from 'ui/timefilter'; +import { I18nProvider } from '@kbn/i18n/react'; uiRoutes.when('/apm/instances/:uuid', { template, @@ -30,7 +31,7 @@ uiRoutes.when('/apm/instances/:uuid', { }, controller: class extends MonitoringViewBaseController { - constructor($injector, $scope) { + constructor($injector, $scope, i18n) { const $route = $injector.get('$route'); const title = $injector.get('title'); const globalState = $injector.get('globalState'); @@ -39,7 +40,12 @@ uiRoutes.when('/apm/instances/:uuid', { }); super({ - title: `APM - Instance`, + title: i18n('xpack.monitoring.apm.instance.routeTitle', { + defaultMessage: '{apm} - Instance', + values: { + apm: 'APM' + } + }), api: `../api/monitoring/v1/clusters/${globalState.cluster_uuid}/apm/${$route.current.params.uuid}`, defaultData: {}, reactNodeId: 'apmInstanceReact', @@ -63,11 +69,13 @@ uiRoutes.when('/apm/instances/:uuid', { renderReact(data, onBrush) { const component = ( - + + + ); super.renderReact(component); } diff --git a/x-pack/plugins/monitoring/public/views/apm/instances/index.js b/x-pack/plugins/monitoring/public/views/apm/instances/index.js index 9d91d64d2fbec..a49aad8ca912b 100644 --- a/x-pack/plugins/monitoring/public/views/apm/instances/index.js +++ b/x-pack/plugins/monitoring/public/views/apm/instances/index.js @@ -22,7 +22,7 @@ uiRoutes.when('/apm/instances', { }, }, controller: class extends MonitoringViewBaseTableController { - constructor($injector, $scope) { + constructor($injector, $scope, i18n) { const $route = $injector.get('$route'); const globalState = $injector.get('globalState'); $scope.cluster = find($route.current.locals.clusters, { @@ -30,7 +30,12 @@ uiRoutes.when('/apm/instances', { }); super({ - title: 'APM - Instances', + title: i18n('xpack.monitoring.apm.instances.routeTitle', { + defaultMessage: '{apm} - Instances', + values: { + apm: 'APM' + } + }), storageKey: 'apm.instances', api: `../api/monitoring/v1/clusters/${globalState.cluster_uuid}/apm/instances`, defaultData: {}, diff --git a/x-pack/plugins/monitoring/public/views/apm/overview/index.js b/x-pack/plugins/monitoring/public/views/apm/overview/index.js index 23a4581be7614..f06a60d43c1df 100644 --- a/x-pack/plugins/monitoring/public/views/apm/overview/index.js +++ b/x-pack/plugins/monitoring/public/views/apm/overview/index.js @@ -13,6 +13,7 @@ import template from './index.html'; import { MonitoringViewBaseController } from '../../base_controller'; import { ApmOverview } from '../../../components/apm/overview'; import { timefilter } from 'ui/timefilter'; +import { I18nProvider } from '@kbn/i18n/react'; uiRoutes.when('/apm', { template, @@ -54,10 +55,12 @@ uiRoutes.when('/apm', { renderReact(data, onBrush) { const component = ( - + + + ); super.renderReact(component); } From b0a107f20173751ffe9b15c59a8e0412258aabb5 Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Fri, 23 Nov 2018 11:41:50 +0100 Subject: [PATCH 75/95] show drop partial buckets option (#25520) --- .../agg_types/controls/drop_partials.html | 4 +- .../apps/visualize/_vertical_bar_chart.js | 46 +++++++++++++++++++ .../functional/page_objects/visualize_page.js | 4 ++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/ui/public/agg_types/controls/drop_partials.html b/src/ui/public/agg_types/controls/drop_partials.html index 3b3713db22f87..776916e4817dd 100644 --- a/src/ui/public/agg_types/controls/drop_partials.html +++ b/src/ui/public/agg_types/controls/drop_partials.html @@ -1,6 +1,6 @@ -
+
Interval + + {bucketSize}
- - + + {rows} @@ -169,7 +191,12 @@ class MarkdownEditor extends Component { {rows.length === 0 && ( - No variables available for the selected data metrics. + + + )} @@ -177,8 +204,12 @@ class MarkdownEditor extends Component {

- There is also a special variable named _all which you can use to access the entire tree. This is useful for - creating lists with data from a group by... + _all) }} + />

diff --git a/src/core_plugins/metrics/public/components/no_data.js b/src/core_plugins/metrics/public/components/no_data.js index 579d87076fe05..4a7d62294bc6c 100644 --- a/src/core_plugins/metrics/public/components/no_data.js +++ b/src/core_plugins/metrics/public/components/no_data.js @@ -18,11 +18,17 @@ */ import React from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; function NoDataComponent() { return (
-
No data to display for the selected metrics
+
+ +
); } diff --git a/src/core_plugins/metrics/public/components/panel_config.js b/src/core_plugins/metrics/public/components/panel_config.js index 91c9449276083..c45c83d5644c2 100644 --- a/src/core_plugins/metrics/public/components/panel_config.js +++ b/src/core_plugins/metrics/public/components/panel_config.js @@ -25,6 +25,7 @@ import topN from './panel_config/top_n'; import table from './panel_config/table'; import gauge from './panel_config/gauge'; import markdown from './panel_config/markdown'; +import { FormattedMessage } from '@kbn/i18n/react'; const types = { timeseries, @@ -41,7 +42,14 @@ function PanelConfig(props) { if (component) { return React.createElement(component, props); } - return (
Missing panel config for “{model.type}”
); + return ( +
+ +
); } PanelConfig.propTypes = { diff --git a/src/core_plugins/metrics/public/components/series.js b/src/core_plugins/metrics/public/components/series.js index 9cec7b7eace1d..fba1a69e1cc72 100644 --- a/src/core_plugins/metrics/public/components/series.js +++ b/src/core_plugins/metrics/public/components/series.js @@ -28,6 +28,7 @@ import table from './vis_types/table/series'; import gauge from './vis_types/gauge/series'; import markdown from './vis_types/markdown/series'; import { sortable } from 'react-anything-sortable'; +import { FormattedMessage } from '@kbn/i18n/react'; const lookup = { top_n: topN, @@ -98,7 +99,15 @@ class Series extends Component { }; return (); } - return (
Missing Series component for panel type: {panel.type}
); + return ( +
+ +
+ ); } } diff --git a/src/core_plugins/metrics/public/components/series_config.js b/src/core_plugins/metrics/public/components/series_config.js index ba46b589f1a04..989a59a21a4a1 100644 --- a/src/core_plugins/metrics/public/components/series_config.js +++ b/src/core_plugins/metrics/public/components/series_config.js @@ -35,6 +35,7 @@ import { EuiFormLabel, EuiSpacer, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; export const SeriesConfig = props => { const defaults = { offset_time: '', value_template: '' }; @@ -55,7 +56,10 @@ export const SeriesConfig = props => { )} fullWidth > { eg.{'{{value}}/s'}} + label={()} + helpText={( + + {'{{value}}/s'}) }} + /> + + )} fullWidth > { )} > { - Override Index Pattern? + + + + + + ); } diff --git a/src/core_plugins/metrics/public/components/vis_editor_visualization.js b/src/core_plugins/metrics/public/components/vis_editor_visualization.js index 278265769b772..eac9a9e99b849 100644 --- a/src/core_plugins/metrics/public/components/vis_editor_visualization.js +++ b/src/core_plugins/metrics/public/components/vis_editor_visualization.js @@ -21,6 +21,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { keyCodes, EuiFlexGroup, EuiFlexItem, EuiButton, EuiText, EuiSwitch } from '@elastic/eui'; import { getVisualizeLoader } from 'ui/visualize/loader/visualize_loader'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; const MIN_CHART_HEIGHT = 250; @@ -140,15 +141,31 @@ class VisEditorVisualization extends Component { style.userSelect = 'none'; } - let applyMessage = 'The latest changes have been applied.'; - if (dirty) applyMessage = 'The changes to this visualization have not been applied.'; - if (autoApply) applyMessage = 'The changes will be automatically applied.'; + let applyMessage = (); + if (dirty) { + applyMessage = (); + } + if (autoApply) { + applyMessage = (); + } const applyButton = ( )} checked={autoApply} onChange={this.props.onToggleAutoApply} /> @@ -164,7 +181,12 @@ class VisEditorVisualization extends Component { {!autoApply && - Apply changes + + + } @@ -189,7 +211,10 @@ class VisEditorVisualization extends Component { onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp} onKeyDown={this.onSizeHandleKeyDown} - aria-label="Press up/down to adjust the chart size" + aria-label={this.props.intl.formatMessage({ + id: 'tsvb.colorRules.adjustChartSizeAriaLabel', + defaultMessage: 'Press up/down to adjust the chart size' + })} > @@ -215,4 +240,4 @@ VisEditorVisualization.propTypes = { appState: PropTypes.object, }; -export default VisEditorVisualization; +export default injectI18n(VisEditorVisualization); diff --git a/src/core_plugins/metrics/public/components/vis_editor_visualization.test.js b/src/core_plugins/metrics/public/components/vis_editor_visualization.test.js index 15b6666207f73..146afeb07605d 100644 --- a/src/core_plugins/metrics/public/components/vis_editor_visualization.test.js +++ b/src/core_plugins/metrics/public/components/vis_editor_visualization.test.js @@ -20,7 +20,7 @@ jest.mock('ui/visualize/loader/visualize_loader', () => ({})); import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; import VisEditorVisualization from './vis_editor_visualization'; describe('getVisualizeLoader', () => { @@ -45,7 +45,7 @@ describe('getVisualizeLoader', () => { }); it('should not call _handler.update until getVisualizeLoader returns _handler', async () => { - const wrapper = mount( + const wrapper = mountWithIntl( ); diff --git a/src/core_plugins/metrics/public/components/vis_picker.js b/src/core_plugins/metrics/public/components/vis_picker.js index 22579125837a3..d58fa8cfd43a2 100644 --- a/src/core_plugins/metrics/public/components/vis_picker.js +++ b/src/core_plugins/metrics/public/components/vis_picker.js @@ -20,6 +20,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { EuiTabs, EuiTab } from '@elastic/eui'; +import { injectI18n } from '@kbn/i18n/react'; function VisPickerItem(props) { const { label, type, selected } = props; @@ -44,19 +45,19 @@ VisPickerItem.propTypes = { selected: PropTypes.bool }; -function VisPicker(props) { +const VisPicker = injectI18n(function (props) { const handleChange = (type) => { props.onChange({ type }); }; - const { model } = props; + const { model, intl } = props; const tabs = [ - { type: 'timeseries', label: 'Time Series' }, - { type: 'metric', label: 'Metric' }, - { type: 'top_n', label: 'Top N' }, - { type: 'gauge', label: 'Gauge' }, - { type: 'markdown', label: 'Markdown' }, - { type: 'table', label: 'Table' } + { type: 'timeseries', label: intl.formatMessage({ id: 'tsvb.visPicker.timeSeriesLabel', defaultMessage: 'Time Series' }) }, + { type: 'metric', label: intl.formatMessage({ id: 'tsvb.visPicker.metricLabel', defaultMessage: 'Metric' }) }, + { type: 'top_n', label: intl.formatMessage({ id: 'tsvb.visPicker.topNLabel', defaultMessage: 'Top N' }) }, + { type: 'gauge', label: intl.formatMessage({ id: 'tsvb.visPicker.gaugeLabel', defaultMessage: 'Gauge' }) }, + { type: 'markdown', label: intl.formatMessage({ id: 'tsvb.visPicker.markdownLabel', defaultMessage: 'Markdown' }) }, + { type: 'table', label: intl.formatMessage({ id: 'tsvb.visPicker.tableLabel', defaultMessage: 'Table' }) } ].map(item => { return ( ); -} +}); VisPicker.propTypes = { model: PropTypes.object, diff --git a/src/core_plugins/metrics/public/components/vis_types/table/config.js b/src/core_plugins/metrics/public/components/vis_types/table/config.js index 324bc89d4dc86..c0d20467d66dc 100644 --- a/src/core_plugins/metrics/public/components/vis_types/table/config.js +++ b/src/core_plugins/metrics/public/components/vis_types/table/config.js @@ -39,6 +39,7 @@ import { EuiSpacer, EuiTitle, } from '@elastic/eui'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; class TableSeriesConfig extends Component { @@ -57,17 +58,18 @@ class TableSeriesConfig extends Component { const handleSelectChange = createSelectHandler(this.props.onChange); const handleTextChange = createTextHandler(this.props.onChange); const htmlId = htmlIdGenerator(); + const { intl } = this.props; const functionOptions = [ - { label: 'Sum', value: 'sum' }, - { label: 'Max', value: 'max' }, - { label: 'Min', value: 'min' }, - { label: 'Avg', value: 'mean' }, - { label: 'Overall Sum', value: 'overall_sum' }, - { label: 'Overall Max', value: 'overall_max' }, - { label: 'Overall Min', value: 'overall_min' }, - { label: 'Overall Avg', value: 'overall_avg' }, - { label: 'Cumulative Sum', value: 'cumulative_sum' }, + { label: intl.formatMessage({ id: 'tsvb.table.sumLabel', defaultMessage: 'Sum' }), value: 'sum' }, + { label: intl.formatMessage({ id: 'tsvb.table.maxLabel', defaultMessage: 'Max' }), value: 'max' }, + { label: intl.formatMessage({ id: 'tsvb.table.minLabel', defaultMessage: 'Min' }), value: 'min' }, + { label: intl.formatMessage({ id: 'tsvb.table.avgLabel', defaultMessage: 'Avg' }), value: 'mean' }, + { label: intl.formatMessage({ id: 'tsvb.table.overallSumLabel', defaultMessage: 'Overall Sum' }), value: 'overall_sum' }, + { label: intl.formatMessage({ id: 'tsvb.table.overallMaxLabel', defaultMessage: 'Overall Max' }), value: 'overall_max' }, + { label: intl.formatMessage({ id: 'tsvb.table.overallMinLabel', defaultMessage: 'Overall Min' }), value: 'overall_min' }, + { label: intl.formatMessage({ id: 'tsvb.table.overallAvgLabel', defaultMessage: 'Overall Avg' }), value: 'overall_avg' }, + { label: intl.formatMessage({ id: 'tsvb.table.cumulativeSumLabel', defaultMessage: 'Cumulative Sum' }), value: 'cumulative_sum' }, ]; const selectedAggFuncOption = functionOptions.find(option => { return model.aggregate_function === option.value; @@ -86,8 +88,19 @@ class TableSeriesConfig extends Component { eg.{'{{value}}/s'}} + label={()} + helpText={ + + {'{{value}}/s'}) }} + /> + + } fullWidth > )} fullWidth > - Show trend arrows? + + + - + )} + > )} fullWidth > - Color rules + + + + + props.switchTab('metrics')} > - Metrics + props.switchTab('options')} > - Options + {seriesBody} @@ -102,11 +110,16 @@ function TopNSeries(props) { if (!props.disableDelete) { dragHandle = ( - + )} + > @@ -127,7 +140,7 @@ function TopNSeries(props) { iconType={caretIcon} color="text" onClick={props.toggleVisible} - aria-label="Toggle series editor" + aria-label={intl.formatMessage({ id: 'tsvb.table.toggleSeriesEditorAriaLabel', defaultMessage: 'Toggle series editor' })} aria-expanded={props.visible} /> @@ -135,9 +148,9 @@ function TopNSeries(props) { @@ -146,9 +159,9 @@ function TopNSeries(props) { {headerContent} + )} + > + {headerContent} + ); } @@ -176,10 +184,15 @@ class TableVis extends Component { if (_.isArray(visData.series) && visData.series.length) { rows = visData.series.map(this.renderRow); } else { - let message = 'No results available.'; - if (!model.pivot_id) { - message += ' You must choose a group by field for this visualization.'; - } + const message = model.pivot_id ? + () + : (); rows = (
NameValue + + + +
{ return model.stacked === option.value; }); const positionOptions = [ - { label: 'Right', value: 'right' }, - { label: 'Left', value: 'left' } + { label: intl.formatMessage({ id: 'tsvb.timeSeries.rightLabel', defaultMessage: 'Right' }), value: 'right' }, + { label: intl.formatMessage({ id: 'tsvb.timeSeries.leftLabel', defaultMessage: 'Left' }), value: 'left' } ]; const selectedAxisPosOption = positionOptions.find(option => { return model.axis_position === option.value; }); const chartTypeOptions = [ - { label: 'Bar', value: 'bar' }, - { label: 'Line', value: 'line' } + { label: intl.formatMessage({ id: 'tsvb.timeSeries.barLabel', defaultMessage: 'Bar' }), value: 'bar' }, + { label: intl.formatMessage({ id: 'tsvb.timeSeries.lineLabel', defaultMessage: 'Line' }), value: 'line' } ]; const selectedChartTypeOption = chartTypeOptions.find(option => { return model.chart_type === option.value; }); const splitColorOptions = [ - { label: 'Gradient', value: 'gradient' }, - { label: 'Rainbow', value: 'rainbow' } + { label: intl.formatMessage({ id: 'tsvb.timeSeries.gradientLabel', defaultMessage: 'Gradient' }), value: 'gradient' }, + { label: intl.formatMessage({ id: 'tsvb.timeSeries.rainbowLabel', defaultMessage: 'Rainbow' }), value: 'rainbow' } ]; const selectedSplitColorOption = splitColorOptions.find(option => { return model.split_color_mode === option.value; @@ -97,7 +99,10 @@ function TimeseriesConfig(props) { )} > )} > )} > )} > )} > - Steps + + + )} > )} > )} > )} > eg.{'{{value}}/s'}} + label={()} + helpText={( + + {'{{value}}/s'}) }} + /> + + )} fullWidth > )} fullWidth > )} > - Hide in legend + + + )} > - Separate axis? + + + )} > {/* EUITODO: The following input couldn't be converted to EUI because of type mis-match. @@ -345,7 +413,10 @@ function TimeseriesConfig(props) { )} > {/* EUITODO: The following input couldn't be converted to EUI because of type mis-match. @@ -362,7 +433,10 @@ function TimeseriesConfig(props) { )} > - Override Index Pattern? + + + ); -} +}); TimeseriesConfig.propTypes = { fields: PropTypes.object, diff --git a/src/core_plugins/metrics/public/components/vis_types/timeseries/series.js b/src/core_plugins/metrics/public/components/vis_types/timeseries/series.js index 23a349aaac39e..f4eaf628a3500 100644 --- a/src/core_plugins/metrics/public/components/vis_types/timeseries/series.js +++ b/src/core_plugins/metrics/public/components/vis_types/timeseries/series.js @@ -28,8 +28,9 @@ import Split from '../../split'; import createAggRowRender from '../../lib/create_agg_row_render'; import createTextHandler from '../../lib/create_text_handler'; import { createUpDownHandler } from '../../lib/sort_keyhandler'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; -function TimeseriesSeries(props) { +const TimeseriesSeries = injectI18n(function (props) { const { panel, fields, @@ -39,7 +40,8 @@ function TimeseriesSeries(props) { disableAdd, selectedTab, onChange, - visible + visible, + intl } = props; const defaults = { label: '' }; @@ -96,14 +98,20 @@ function TimeseriesSeries(props) { isSelected={selectedTab === 'metrics'} onClick={() => props.switchTab('metrics')} > - Metrics + props.switchTab('options')} > - Options + {seriesBody} @@ -124,11 +132,19 @@ function TimeseriesSeries(props) { if (!props.disableDelete) { dragHandle = ( - + )} + > @@ -149,7 +165,10 @@ function TimeseriesSeries(props) { iconType={caretIcon} color="text" onClick={props.toggleVisible} - aria-label="Toggle series editor" + aria-label={intl.formatMessage({ + id: 'tsvb.timeSeries.toggleSeriesEditorAriaLabel', + defaultMessage: 'Toggle series editor' + })} aria-expanded={props.visible} /> @@ -162,7 +181,7 @@ function TimeseriesSeries(props) { @@ -171,9 +190,9 @@ function TimeseriesSeries(props) { ); -} +}); TimeseriesSeries.propTypes = { className: PropTypes.string, @@ -216,4 +235,4 @@ TimeseriesSeries.propTypes = { visible: PropTypes.bool }; -export default TimeseriesSeries; +export default injectI18n(TimeseriesSeries); diff --git a/src/core_plugins/metrics/public/components/vis_types/top_n/series.js b/src/core_plugins/metrics/public/components/vis_types/top_n/series.js index fa112a41e39c8..754becb788fbc 100644 --- a/src/core_plugins/metrics/public/components/vis_types/top_n/series.js +++ b/src/core_plugins/metrics/public/components/vis_types/top_n/series.js @@ -28,8 +28,9 @@ import { EuiToolTip, EuiTabs, EuiTab, EuiFlexGroup, EuiFlexItem, EuiFieldText, E import createTextHandler from '../../lib/create_text_handler'; import createAggRowRender from '../../lib/create_agg_row_render'; import { createUpDownHandler } from '../../lib/sort_keyhandler'; +import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; -function TopNSeries(props) { +const TopNSeries = injectI18n(function (props) { const { panel, model, @@ -40,7 +41,8 @@ function TopNSeries(props) { disableDelete, disableAdd, selectedTab, - visible + visible, + intl } = props; const handleChange = createTextHandler(onChange); @@ -94,14 +96,20 @@ function TopNSeries(props) { isSelected={selectedTab === 'metrics'} onClick={() => props.switchTab('metrics')} > - Metrics + props.switchTab('options')} > - Options + {seriesBody} @@ -122,11 +130,16 @@ function TopNSeries(props) { if (!props.disableDelete) { dragHandle = ( - + )} + > @@ -147,7 +160,7 @@ function TopNSeries(props) { iconType={caretIcon} color="text" onClick={props.toggleVisible} - aria-label="Toggle series editor" + aria-label={intl.formatMessage({ id: 'tsvb.topN.toggleSeriesEditorAriaLabel', defaultMessage: 'Toggle series editor' })} aria-expanded={props.visible} /> @@ -160,7 +173,7 @@ function TopNSeries(props) { @@ -169,9 +182,9 @@ function TopNSeries(props) { ); -} +}); TopNSeries.propTypes = { className: PropTypes.string, diff --git a/src/core_plugins/metrics/public/components/visualization.js b/src/core_plugins/metrics/public/components/visualization.js index b72e1b047558c..505809afdd800 100644 --- a/src/core_plugins/metrics/public/components/visualization.js +++ b/src/core_plugins/metrics/public/components/visualization.js @@ -63,18 +63,20 @@ function Visualization(props) { const component = types[model.type]; if (component) { - return React.createElement(component, { - dateFormat: props.dateFormat, - reversed: props.reversed, - backgroundColor: props.backgroundColor, - model: props.model, - onBrush: props.onBrush, - onChange: props.onChange, - onUiState: props.onUiState, - uiState: props.uiState, - visData: visData.type === model.type ? visData : {}, - getConfig: props.getConfig - }); + return ( + React.createElement(component, { + dateFormat: props.dateFormat, + reversed: props.reversed, + backgroundColor: props.backgroundColor, + model: props.model, + onBrush: props.onBrush, + onChange: props.onChange, + onUiState: props.onUiState, + uiState: props.uiState, + visData: visData.type === model.type ? visData : {}, + getConfig: props.getConfig + }) + ); } return
; } diff --git a/src/core_plugins/metrics/public/components/yes_no.js b/src/core_plugins/metrics/public/components/yes_no.js index 7a79ac6ca988c..beda91b8d3c04 100644 --- a/src/core_plugins/metrics/public/components/yes_no.js +++ b/src/core_plugins/metrics/public/components/yes_no.js @@ -21,6 +21,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import _ from 'lodash'; import { EuiRadio, htmlIdGenerator } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; function YesNo(props) { const { name, value } = props; @@ -37,7 +38,10 @@ function YesNo(props) {
)} className="eui-displayInlineBlock" name={inputName} checked={Boolean(value)} @@ -49,7 +53,10 @@ function YesNo(props) { )} className="eui-displayInlineBlock" name={inputName} checked={!Boolean(value)} diff --git a/src/core_plugins/metrics/public/components/yes_no.test.js b/src/core_plugins/metrics/public/components/yes_no.test.js index e931ba5ce0775..09d936fde6f1f 100644 --- a/src/core_plugins/metrics/public/components/yes_no.test.js +++ b/src/core_plugins/metrics/public/components/yes_no.test.js @@ -19,14 +19,14 @@ import React from 'react'; import { expect } from 'chai'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import sinon from 'sinon'; import YesNo from './yes_no'; describe('YesNo', () => { it('call onChange={handleChange} on yes', () => { const handleChange = sinon.spy(); - const wrapper = shallow( + const wrapper = shallowWithIntl( ); wrapper.find('EuiRadio').first().simulate('change'); @@ -38,7 +38,7 @@ describe('YesNo', () => { it('call onChange={handleChange} on no', () => { const handleChange = sinon.spy(); - const wrapper = shallow( + const wrapper = shallowWithIntl( ); wrapper.find('EuiRadio').last().simulate('change'); diff --git a/src/core_plugins/metrics/public/kbn_vis_types/editor_controller.js b/src/core_plugins/metrics/public/kbn_vis_types/editor_controller.js index 456a52fe3a4cc..89c859fdd421c 100644 --- a/src/core_plugins/metrics/public/kbn_vis_types/editor_controller.js +++ b/src/core_plugins/metrics/public/kbn_vis_types/editor_controller.js @@ -42,9 +42,7 @@ function ReactEditorControllerProvider(Private, config) { isEditorMode={true} appState={params.appState} /> - , - this.el - ); + , this.el); } resize() { diff --git a/src/core_plugins/metrics/public/visualizations/components/horizontal_legend.js b/src/core_plugins/metrics/public/visualizations/components/horizontal_legend.js index 8f9dccadbe60d..37fb4bab667b7 100644 --- a/src/core_plugins/metrics/public/visualizations/components/horizontal_legend.js +++ b/src/core_plugins/metrics/public/visualizations/components/horizontal_legend.js @@ -22,8 +22,9 @@ import React from 'react'; import createLegendSeries from '../lib/create_legend_series'; import reactcss from 'reactcss'; import { htmlIdGenerator, EuiButtonIcon } from '@elastic/eui'; +import { injectI18n } from '@kbn/i18n/react'; -function HorizontalLegend(props) { +const HorizontalLegend = injectI18n(function (props) { const rows = props.series.map(createLegendSeries(props)); const htmlId = htmlIdGenerator(); const styles = reactcss({ @@ -46,7 +47,7 @@ function HorizontalLegend(props) { color="text" iconSize="s" onClick={props.onClick} - aria-label="Toggle chart legend" + aria-label={props.intl.formatMessage({ id: 'tsvb.horizontalLegend.toggleChartAriaLabel', defaultMessage: 'Toggle chart legend' })} aria-expanded={!!props.showLegend} aria-controls={htmlId('legend')} /> @@ -55,7 +56,7 @@ function HorizontalLegend(props) {
); -} +}); HorizontalLegend.propTypes = { legendPosition: PropTypes.string, diff --git a/src/core_plugins/metrics/public/visualizations/components/vertical_legend.js b/src/core_plugins/metrics/public/visualizations/components/vertical_legend.js index d2183bfbca34f..cfd9fa840f9ec 100644 --- a/src/core_plugins/metrics/public/visualizations/components/vertical_legend.js +++ b/src/core_plugins/metrics/public/visualizations/components/vertical_legend.js @@ -22,8 +22,9 @@ import React from 'react'; import createLegendSeries from '../lib/create_legend_series'; import reactcss from 'reactcss'; import { htmlIdGenerator, EuiButtonIcon } from '@elastic/eui'; +import { injectI18n } from '@kbn/i18n/react'; -function VerticalLegend(props) { +const VerticalLegend = injectI18n(function (props) { const rows = props.series.map(createLegendSeries(props)); const htmlId = htmlIdGenerator(); const hideLegend = !props.showLegend; @@ -56,7 +57,7 @@ function VerticalLegend(props) { color="text" iconSize="s" onClick={props.onClick} - aria-label="Toggle chart legend" + aria-label={props.intl.formatMessage({ id: 'tsvb.verticalLegend.toggleChartAriaLabel', defaultMessage: 'Toggle chart legend' })} aria-expanded={!!props.showLegend} aria-controls={htmlId('legend')} /> @@ -67,7 +68,7 @@ function VerticalLegend(props) { ); -} +}); VerticalLegend.propTypes = { legendPosition: PropTypes.string, diff --git a/src/core_plugins/metrics/server/lib/vis_data/helpers/bucket_transform.js b/src/core_plugins/metrics/server/lib/vis_data/helpers/bucket_transform.js index ce061464cc994..c487e541beb39 100644 --- a/src/core_plugins/metrics/server/lib/vis_data/helpers/bucket_transform.js +++ b/src/core_plugins/metrics/server/lib/vis_data/helpers/bucket_transform.js @@ -21,11 +21,17 @@ import parseSettings from './parse_settings'; import getBucketsPath from './get_buckets_path'; import { parseInterval } from './parse_interval'; import { set } from 'lodash'; +import { i18n } from '@kbn/i18n'; function checkMetric(metric, fields) { fields.forEach(field => { if (!metric[field]) { - throw new Error(`Metric missing ${field}`); + throw new Error( + i18n.translate('tsvb.metricMissingErrorMessage', { + defaultMessage: 'Metric missing {field}', + values: { field } + }) + ); } }); } diff --git a/src/core_plugins/metrics/server/lib/vis_data/series/handle_response_body.js b/src/core_plugins/metrics/server/lib/vis_data/series/handle_response_body.js index 20eb2588ffde1..f732db82f45ed 100644 --- a/src/core_plugins/metrics/server/lib/vis_data/series/handle_response_body.js +++ b/src/core_plugins/metrics/server/lib/vis_data/series/handle_response_body.js @@ -20,6 +20,7 @@ import buildProcessorFunction from '../build_processor_function'; import processors from '../response_processors/series'; import { get } from 'lodash'; +import { i18n } from '@kbn/i18n'; export default function handleResponseBody(panel) { return resp => { @@ -30,12 +31,19 @@ export default function handleResponseBody(panel) { } const aggregations = get(resp, 'aggregations'); if (!aggregations) { - const message = `The aggregations key is missing from the response, - check your permissions for this request.`; + const message = i18n.translate('tsvb.series.missingAggregationKeyErrorMessage', { + defaultMessage: 'The aggregations key is missing from the response, check your permissions for this request.' + }); throw Error(message); } const keys = Object.keys(aggregations); - if (keys.length !== 1) throw Error('There should only be one series per request.'); + if (keys.length !== 1) { + throw Error( + i18n.translate('tsvb.series.shouldOneSeriesPerRequestErrorMessage', { + defaultMessage: 'There should only be one series per request.' + }) + ); + } const seriesId = keys[0]; const series = panel.series.find(s => s.id === seriesId); const processor = buildProcessorFunction(processors, resp, panel, series); From 8f871f941c733533a4dc83df37d0ba76eb1e9f36 Mon Sep 17 00:00:00 2001 From: Nox911 Date: Mon, 26 Nov 2018 17:34:31 +0300 Subject: [PATCH 88/95] [i18n] Translate Agg_types(part_1) (#24259) * translate ui-agg_types-bucket * Fix name of id * Delete extra i18n import * Rename some parameters --- .../agg_types/buckets/_interval_options.js | 41 ++++++++++++++----- .../agg_types/buckets/date_histogram.js | 13 +++++- src/ui/public/agg_types/buckets/date_range.js | 5 ++- src/ui/public/agg_types/buckets/filter.js | 5 ++- src/ui/public/agg_types/buckets/filters.js | 5 ++- src/ui/public/agg_types/buckets/geo_hash.js | 5 ++- src/ui/public/agg_types/buckets/histogram.js | 6 ++- src/ui/public/agg_types/buckets/ip_range.js | 12 +++++- src/ui/public/agg_types/buckets/range.js | 20 +++++++-- .../agg_types/buckets/significant_terms.js | 13 +++++- src/ui/public/agg_types/buckets/terms.js | 31 +++++++++++--- src/ui/public/agg_types/param_types/field.js | 19 ++++++++- 12 files changed, 142 insertions(+), 33 deletions(-) diff --git a/src/ui/public/agg_types/buckets/_interval_options.js b/src/ui/public/agg_types/buckets/_interval_options.js index 959574941dfbb..983daa0ca4335 100644 --- a/src/ui/public/agg_types/buckets/_interval_options.js +++ b/src/ui/public/agg_types/buckets/_interval_options.js @@ -16,10 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +import { i18n } from '@kbn/i18n'; export const intervalOptions = [ { - display: 'Auto', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.autoDisplayName', { + defaultMessage: 'Auto', + }), val: 'auto', enabled: function (agg) { // not only do we need a time field, but the selected field needs @@ -28,39 +31,57 @@ export const intervalOptions = [ } }, { - display: 'Millisecond', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.millisecondDisplayName', { + defaultMessage: 'Millisecond', + }), val: 'ms' }, { - display: 'Second', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.secondDisplayName', { + defaultMessage: 'Second', + }), val: 's' }, { - display: 'Minute', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.minuteDisplayName', { + defaultMessage: 'Minute', + }), val: 'm' }, { - display: 'Hourly', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.hourlyDisplayName', { + defaultMessage: 'Hourly', + }), val: 'h' }, { - display: 'Daily', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.dailyDisplayName', { + defaultMessage: 'Daily', + }), val: 'd' }, { - display: 'Weekly', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.weeklyDisplayName', { + defaultMessage: 'Weekly', + }), val: 'w' }, { - display: 'Monthly', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.monthlyDisplayName', { + defaultMessage: 'Monthly', + }), val: 'M' }, { - display: 'Yearly', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.yearlyDisplayName', { + defaultMessage: 'Yearly', + }), val: 'y' }, { - display: 'Custom', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.customDisplayName', { + defaultMessage: 'Custom', + }), val: 'custom' } ]; diff --git a/src/ui/public/agg_types/buckets/date_histogram.js b/src/ui/public/agg_types/buckets/date_histogram.js index d430c87bdd2fd..1a8b06832e8d9 100644 --- a/src/ui/public/agg_types/buckets/date_histogram.js +++ b/src/ui/public/agg_types/buckets/date_histogram.js @@ -29,6 +29,7 @@ import { intervalOptions } from './_interval_options'; import intervalTemplate from '../controls/time_interval.html'; import { timefilter } from '../../timefilter'; import dropPartialTemplate from '../controls/drop_partials.html'; +import { i18n } from '@kbn/i18n'; const config = chrome.getUiSettingsClient(); const detectedTimezone = moment.tz.guess(); @@ -52,14 +53,22 @@ function setBounds(agg, force) { export const dateHistogramBucketAgg = new BucketAggType({ name: 'date_histogram', - title: 'Date Histogram', + title: i18n.translate('common.ui.aggTypes.buckets.dateHistogramTitle', { + defaultMessage: 'Date Histogram', + }), ordered: { date: true }, makeLabel: function (agg) { const output = this.params.write(agg); const field = agg.getFieldDisplayName(); - return field + ' per ' + (output.metricScaleText || output.bucketInterval.description); + return i18n.translate('common.ui.aggTypes.buckets.dateHistogramLabel', { + defaultMessage: '{fieldName} per {intervalDescription}', + values: { + fieldName: field, + intervalDescription: output.metricScaleText || output.bucketInterval.description, + } + }); }, createFilter: createFilterDateHistogram, decorateAggConfig: function () { diff --git a/src/ui/public/agg_types/buckets/date_range.js b/src/ui/public/agg_types/buckets/date_range.js index c197efb68ddb7..4643f7f6f9c34 100644 --- a/src/ui/public/agg_types/buckets/date_range.js +++ b/src/ui/public/agg_types/buckets/date_range.js @@ -24,10 +24,13 @@ import { BucketAggType } from './_bucket_agg_type'; import { createFilterDateRange } from './create_filter/date_range'; import { fieldFormats } from '../../registry/field_formats'; import dateRangesTemplate from '../controls/date_ranges.html'; +import { i18n } from '@kbn/i18n'; export const dateRangeBucketAgg = new BucketAggType({ name: 'date_range', - title: 'Date Range', + title: i18n.translate('common.ui.aggTypes.buckets.dateRangeTitle', { + defaultMessage: 'Date Range', + }), createFilter: createFilterDateRange, getKey: function (bucket, key, agg) { const formatter = agg.fieldOwnFormatter('text', fieldFormats.getDefaultInstance('date')); diff --git a/src/ui/public/agg_types/buckets/filter.js b/src/ui/public/agg_types/buckets/filter.js index 8ac750fe36239..02b54a63ea794 100644 --- a/src/ui/public/agg_types/buckets/filter.js +++ b/src/ui/public/agg_types/buckets/filter.js @@ -18,10 +18,13 @@ */ import { BucketAggType } from './_bucket_agg_type'; +import { i18n } from '@kbn/i18n'; export const filterBucketAgg = new BucketAggType({ name: 'filter', - title: 'Filter', + title: i18n.translate('common.ui.aggTypes.buckets.filterTitle', { + defaultMessage: 'Filter', + }), params: [ { name: 'geo_bounding_box' diff --git a/src/ui/public/agg_types/buckets/filters.js b/src/ui/public/agg_types/buckets/filters.js index b0b513974a243..a13631d54a637 100644 --- a/src/ui/public/agg_types/buckets/filters.js +++ b/src/ui/public/agg_types/buckets/filters.js @@ -24,12 +24,15 @@ import { BucketAggType } from './_bucket_agg_type'; import { createFilterFilters } from './create_filter/filters'; import { decorateQuery, luceneStringToDsl } from '@kbn/es-query'; import filtersTemplate from '../controls/filters.html'; +import { i18n } from '@kbn/i18n'; import chrome from 'ui/chrome'; export const filtersBucketAgg = new BucketAggType({ name: 'filters', - title: 'Filters', + title: i18n.translate('common.ui.aggTypes.buckets.filtersTitle', { + defaultMessage: 'Filters', + }), createFilter: createFilterFilters, customLabels: false, params: [ diff --git a/src/ui/public/agg_types/buckets/geo_hash.js b/src/ui/public/agg_types/buckets/geo_hash.js index a532b9d6780b5..f3bc503da2d22 100644 --- a/src/ui/public/agg_types/buckets/geo_hash.js +++ b/src/ui/public/agg_types/buckets/geo_hash.js @@ -23,6 +23,7 @@ import { BucketAggType } from './_bucket_agg_type'; import precisionTemplate from '../controls/precision.html'; import { geohashColumns } from '../../utils/decode_geo_hash'; import { geoContains, scaleBounds } from '../../utils/geo_utils'; +import { i18n } from '@kbn/i18n'; const config = chrome.getUiSettingsClient(); @@ -68,7 +69,9 @@ function isOutsideCollar(bounds, collar) { export const geoHashBucketAgg = new BucketAggType({ name: 'geohash_grid', - title: 'Geohash', + title: i18n.translate('common.ui.aggTypes.buckets.geohashGridTitle', { + defaultMessage: 'Geohash', + }), params: [ { name: 'field', diff --git a/src/ui/public/agg_types/buckets/histogram.js b/src/ui/public/agg_types/buckets/histogram.js index 5cbaa3a145b12..aac100b5bffdc 100644 --- a/src/ui/public/agg_types/buckets/histogram.js +++ b/src/ui/public/agg_types/buckets/histogram.js @@ -19,7 +19,6 @@ import _ from 'lodash'; -import { i18n } from '@kbn/i18n'; import { toastNotifications } from 'ui/notify'; import '../../validate_date_interval'; import chrome from '../../chrome'; @@ -28,11 +27,14 @@ import { createFilterHistogram } from './create_filter/histogram'; import intervalTemplate from '../controls/number_interval.html'; import minDocCountTemplate from '../controls/min_doc_count.html'; import extendedBoundsTemplate from '../controls/extended_bounds.html'; +import { i18n } from '@kbn/i18n'; const config = chrome.getUiSettingsClient(); export const histogramBucketAgg = new BucketAggType({ name: 'histogram', - title: 'Histogram', + title: i18n.translate('common.ui.aggTypes.buckets.histogramTitle', { + defaultMessage: 'Histogram', + }), ordered: {}, makeLabel: function (aggConfig) { return aggConfig.getFieldDisplayName(); diff --git a/src/ui/public/agg_types/buckets/ip_range.js b/src/ui/public/agg_types/buckets/ip_range.js index 8e8c724c87533..e124ad69ee94a 100644 --- a/src/ui/public/agg_types/buckets/ip_range.js +++ b/src/ui/public/agg_types/buckets/ip_range.js @@ -23,10 +23,13 @@ import '../../directives/validate_cidr_mask'; import { BucketAggType } from './_bucket_agg_type'; import { createFilterIpRange } from './create_filter/ip_range'; import ipRangesTemplate from '../controls/ip_ranges.html'; +import { i18n } from '@kbn/i18n'; export const ipRangeBucketAgg = new BucketAggType({ name: 'ip_range', - title: 'IPv4 Range', + title: i18n.translate('common.ui.aggTypes.buckets.ipRangeTitle', { + defaultMessage: 'IPv4 Range', + }), createFilter: createFilterIpRange, getKey: function (bucket, key) { if (key) return key; @@ -35,7 +38,12 @@ export const ipRangeBucketAgg = new BucketAggType({ return `${from} to ${to}`; }, makeLabel: function (aggConfig) { - return aggConfig.getFieldDisplayName() + ' IP ranges'; + return i18n.translate('common.ui.aggTypes.buckets.ipRangeLabel', { + defaultMessage: '{fieldName} IP ranges', + values: { + fieldName: aggConfig.getFieldDisplayName() + } + }); }, params: [ { diff --git a/src/ui/public/agg_types/buckets/range.js b/src/ui/public/agg_types/buckets/range.js index d51e315084bc8..20d0de4b4f02d 100644 --- a/src/ui/public/agg_types/buckets/range.js +++ b/src/ui/public/agg_types/buckets/range.js @@ -22,16 +22,24 @@ import { createFilterRange } from './create_filter/range'; import { FieldFormat } from '../../../field_formats/field_format'; import { RangeKey } from './range_key'; import rangesTemplate from '../controls/ranges.html'; +import { i18n } from '@kbn/i18n'; const keyCaches = new WeakMap(); const formats = new WeakMap(); export const rangeBucketAgg = new BucketAggType({ name: 'range', - title: 'Range', + title: i18n.translate('common.ui.aggTypes.buckets.rangeTitle', { + defaultMessage: 'Range', + }), createFilter: createFilterRange, makeLabel: function (aggConfig) { - return aggConfig.getFieldDisplayName() + ' ranges'; + return i18n.translate('common.ui.aggTypes.buckets.rangesLabel', { + defaultMessage: '{fieldName} ranges', + values: { + fieldName: aggConfig.getFieldDisplayName() + } + }); }, getKey: function (bucket, key, agg) { let keys = keyCaches.get(agg); @@ -57,7 +65,13 @@ export const rangeBucketAgg = new BucketAggType({ const RangeFormat = FieldFormat.from(function (range) { const format = agg.fieldOwnFormatter(); - return `${format(range.gte)} to ${format(range.lt)}`; + return i18n.translate('common.ui.aggTypes.buckets.ranges.rangesFormatMessage', { + defaultMessage: '{from} to {to}', + values: { + from: format(range.gte), + to: format(range.lt) + } + }); }); format = new RangeFormat(); diff --git a/src/ui/public/agg_types/buckets/significant_terms.js b/src/ui/public/agg_types/buckets/significant_terms.js index 544a85123cc0d..77e8a0f80a506 100644 --- a/src/ui/public/agg_types/buckets/significant_terms.js +++ b/src/ui/public/agg_types/buckets/significant_terms.js @@ -20,12 +20,21 @@ import { BucketAggType } from './_bucket_agg_type'; import { createFilterTerms } from './create_filter/terms'; import orderAndSizeTemplate from '../controls/order_and_size.html'; +import { i18n } from '@kbn/i18n'; export const significantTermsBucketAgg = new BucketAggType({ name: 'significant_terms', - title: 'Significant Terms', + title: i18n.translate('common.ui.aggTypes.buckets.significantTermsTitle', { + defaultMessage: 'Significant Terms', + }), makeLabel: function (aggConfig) { - return 'Top ' + aggConfig.params.size + ' unusual terms in ' + aggConfig.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.buckets.significantTermsLabel', { + defaultMessage: 'Top {size} unusual terms in {fieldName}', + values: { + size: aggConfig.params.size, + fieldName: aggConfig.getFieldDisplayName(), + } + }); }, createFilter: createFilterTerms, params: [ diff --git a/src/ui/public/agg_types/buckets/terms.js b/src/ui/public/agg_types/buckets/terms.js index 848c37ff355ab..55e0625cec694 100644 --- a/src/ui/public/agg_types/buckets/terms.js +++ b/src/ui/public/agg_types/buckets/terms.js @@ -26,6 +26,7 @@ import { createFilterTerms } from './create_filter/terms'; import orderAggTemplate from '../controls/order_agg.html'; import orderAndSizeTemplate from '../controls/order_and_size.html'; import otherBucketTemplate from '../controls/other_bucket.html'; +import { i18n } from '@kbn/i18n'; import { getRequestInspectorStats, getResponseInspectorStats } from '../../courier/utils/courier_inspector_utils'; import { buildOtherBucketAgg, mergeOtherBucketAggResponse, updateMissingBucket } from './_terms_other_bucket_helper'; @@ -40,7 +41,9 @@ const orderAggSchema = (new Schemas([ { group: 'none', name: 'orderAgg', - title: 'Order Agg', + title: i18n.translate('common.ui.aggTypes.buckets.terms.orderAggTitle', { + defaultMessage: 'Order Agg', + }), hideCustomLabel: true, aggFilter: aggFilter } @@ -70,7 +73,9 @@ const migrateIncludeExcludeFormat = { export const termsBucketAgg = new BucketAggType({ name: 'terms', - title: 'Terms', + title: i18n.translate('common.ui.aggTypes.buckets.termsTitle', { + defaultMessage: 'Terms', + }), makeLabel: function (agg) { const params = agg.params; return agg.getFieldDisplayName() + ': ' + params.order.display; @@ -254,8 +259,18 @@ export const termsBucketAgg = new BucketAggType({ default: 'desc', editor: orderAndSizeTemplate, options: [ - { display: 'Descending', val: 'desc' }, - { display: 'Ascending', val: 'asc' } + { + display: i18n.translate('common.ui.aggTypes.buckets.terms.orderDescendingTitle', { + defaultMessage: 'Descending', + }), + val: 'desc' + }, + { + display: i18n.translate('common.ui.aggTypes.buckets.terms.orderAscendingTitle', { + defaultMessage: 'Ascending', + }), + val: 'asc' + } ], write: _.noop // prevent default write, it's handled by orderAgg }, @@ -270,7 +285,9 @@ export const termsBucketAgg = new BucketAggType({ write: _.noop }, { name: 'otherBucketLabel', - default: 'Other', + default: i18n.translate('common.ui.aggTypes.buckets.terms.otherBucketLabel', { + defaultMessage: 'Other', + }), write: _.noop }, { name: 'missingBucket', @@ -278,7 +295,9 @@ export const termsBucketAgg = new BucketAggType({ write: _.noop }, { name: 'missingBucketLabel', - default: 'Missing', + default: i18n.translate('common.ui.aggTypes.buckets.terms.missingBucketLabel', { + defaultMessage: 'Missing', + }), write: _.noop }, { diff --git a/src/ui/public/agg_types/param_types/field.js b/src/ui/public/agg_types/param_types/field.js index 8fd330d1d1eff..38eaa75d43ec9 100644 --- a/src/ui/public/agg_types/param_types/field.js +++ b/src/ui/public/agg_types/param_types/field.js @@ -26,6 +26,7 @@ import { IndexedArray } from '../../indexed_array'; import { toastNotifications } from '../../notify'; import { createLegacyClass } from '../../utils/legacy_class'; import { propFilter } from '../../filters/_prop_filter'; +import { i18n } from '@kbn/i18n'; const filterByType = propFilter('type'); @@ -67,7 +68,14 @@ FieldParamType.prototype.deserialize = function (fieldName, aggConfig) { const validField = this.getAvailableFields(aggConfig.getIndexPattern().fields).byName[fieldName]; if (!validField) { - toastNotifications.addDanger(`Saved "field" parameter is now invalid. Please select a new field.`); + toastNotifications.addDanger( + i18n.translate('common.ui.aggTypes.paramTypes.field.invalidSavedFieldParameterErrorMessage', { + defaultMessage: 'Saved {fieldParameter} parameter is now invalid. Please select a new field.', + values: { + fieldParameter: '"field"' + } + }) + ); } return validField; @@ -112,7 +120,14 @@ FieldParamType.prototype.write = function (aggConfig, output) { const field = aggConfig.getField(); if (!field) { - throw new TypeError('"field" is a required parameter'); + throw new TypeError( + i18n.translate('common.ui.aggTypes.paramTypes.field.requiredFieldParameterErrorMessage', { + defaultMessage: '{fieldParameter} is a required parameter', + values: { + fieldParameter: '"field"' + } + }) + ); } if (field.scripted) { From 13eccd522a54f6b13ada96f53f452950954a8060 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 26 Nov 2018 08:04:43 -0700 Subject: [PATCH 89/95] add timestamp to inspector request stats (#25667) * add timestamp to inspector request stats * remove if wrapper, internationalize --- .../inspector/adapters/request/request_responder.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ui/public/inspector/adapters/request/request_responder.ts b/src/ui/public/inspector/adapters/request/request_responder.ts index c46078262a7e0..00d3bd0da6202 100644 --- a/src/ui/public/inspector/adapters/request/request_responder.ts +++ b/src/ui/public/inspector/adapters/request/request_responder.ts @@ -17,6 +17,7 @@ * under the License. */ +import { i18n } from '@kbn/i18n'; import { Request, RequestStatistics, RequestStatus, Response } from './types'; /** @@ -43,6 +44,18 @@ export class RequestResponder { ...(this.request.stats || {}), ...stats, }; + + const startDate = new Date(this.request.startTime); + const timestampKey = i18n.translate('common.ui.inspector.reqTimestampKey', { + defaultMessage: 'Request timestamp', + }); + this.request.stats[timestampKey] = { + value: startDate.toISOString(), + description: i18n.translate('common.ui.inspector.reqTimestampDescription', { + defaultMessage: 'Time when the start of the request has been logged', + }), + }; + this.onChange(); return this; } From a3414c98f0411232f27caccf638d3174dbd35410 Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Mon, 26 Nov 2018 07:28:09 -0800 Subject: [PATCH 90/95] [DOCS] Adds screenshots for CCR monitoring (#25979) --- .../monitoring/elasticsearch-details.asciidoc | 24 +++++++++++++++++- .../images/monitoring-ccr-shard.png | Bin 0 -> 160080 bytes docs/monitoring/images/monitoring-ccr.png | Bin 0 -> 53426 bytes 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 docs/monitoring/images/monitoring-ccr-shard.png create mode 100644 docs/monitoring/images/monitoring-ccr.png diff --git a/docs/monitoring/elasticsearch-details.asciidoc b/docs/monitoring/elasticsearch-details.asciidoc index 9af2a08363ca7..c75b2880f85ae 100644 --- a/docs/monitoring/elasticsearch-details.asciidoc +++ b/docs/monitoring/elasticsearch-details.asciidoc @@ -107,4 +107,26 @@ To view {ml} job metrics, click **Jobs**. For each job in your cluster, it shows information such as its status, the number of records processed, the size of the model, the number of forecasts, and the node that runs the job. -image::monitoring/images/monitoring-jobs.png["Machine learning jobs",link="images/monitoring-jobs.png"] \ No newline at end of file +image::monitoring/images/monitoring-jobs.png["Machine learning jobs",link="images/monitoring-jobs.png"] + +[float] +[[ccr-overview-page]] +==== CCR + +beta[] + +To view {ccr} metrics, click **CCR**. For each follower index on the cluster, it +shows information such as the leader index, an indication of how much the +follower index is lagging behind the leader index, the last fetch time, the +number of operations synced, and error messages. If you select a follower index, +you can view the same information for each shard. For example: + +image::monitoring/images/monitoring-ccr.png["Cross-cluster replication",link="images/monitoring-ccr.png"] + +If you select a shard, you can see graphs for the fetch and operation delays. +You can also see advanced information, which contains the results from the +{ref}/ccr-get-follow-stats.html[get follower stats API]. For example: + +image::monitoring/images/monitoring-ccr-shard.png["Cross-cluster replication shard details",link="images/monitoring-ccr-shard.png"] + +For more information, see {stack-ov}/xpack-ccr.html[Cross-cluster replication]. diff --git a/docs/monitoring/images/monitoring-ccr-shard.png b/docs/monitoring/images/monitoring-ccr-shard.png new file mode 100644 index 0000000000000000000000000000000000000000..1fb7f4dfebd261b31da56a2fa5681902fea83154 GIT binary patch literal 160080 zcmZ_0cUV)~w*M^uKsgT`aymRZ;Ewbm&6kp%E1-QI* z3x5!J8#mI}AJB;#V0fpXpkb$=qTpoj}UGy)!Xb7 zZr1gt2Y#I@lU@jxO`2q@zTf$|xt435<}sgL?!0eyo#oJG8-{i0C>T!3 zk_p{6GrZt=!nLua+4=J4r!3`5;If^AUk%gZY+_nGrR?pvIaF%tH_ClQ!=hQDpUqkM z#nm6#{Wn5Iv5%K|;lpAZeQ(;3g+D+4N^kS*tbL+?cqj#Ejc71PJ?M75aCnn>xUshV zB(>kiTk-N7;r;B`&oxV8cguGZ8=A;Vbon(YA%vzg1Rjv1{PcKZ`MP}W1qA`ad&afr z0eqkG$PM^cj2ymg4!)I_87>n{Tful4Q$#y%bx;^)Xh9|G|5yxP_C5pK-RY2FW1;8A z@h(Dm9Nr%xs>h$1DyS^?&yg?em5d=`lUIl+;n&~Nl;$O>8naDrgde>!d^1(_n7jtY z+5hl@(5UIM%cR_J>#>+-%`!tqgU-;I$=S}O&@s>D`~1a#Rh@%c*KYlR#)?-RXnS2Z zFD*ug+bgt~(Ue~iznHNu2dg?DW&gz9l#S9OBZ!_8AGvZ-65;v#Gi?U7XvLzVkfZRb z$4%UR53ahJ2L1Z{2K|Qo+KlkyrTQ~gnwR*TS=~&!j^AS$^%s0-z3FRhwi4}%Ua)i8 z)3D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je(!{-@c6%$caty;G Date: Mon, 26 Nov 2018 16:37:17 +0100 Subject: [PATCH 91/95] kbn-interpreter package should not import from ui (#26161) --- .../kbn-interpreter/src/public/browser_registries.js | 11 +++++------ .../interpreter/public/load_browser_plugins.js | 3 ++- x-pack/plugins/canvas/public/components/app/index.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/kbn-interpreter/src/public/browser_registries.js b/packages/kbn-interpreter/src/public/browser_registries.js index 778a0b03a7624..312c934cdedec 100644 --- a/packages/kbn-interpreter/src/public/browser_registries.js +++ b/packages/kbn-interpreter/src/public/browser_registries.js @@ -17,7 +17,6 @@ * under the License. */ -import chrome from 'ui/chrome'; import $script from 'scriptjs'; let resolvePromise = null; @@ -31,7 +30,7 @@ export const getBrowserRegistries = () => { return populatePromise; }; -const loadBrowserRegistries = (registries) => { +const loadBrowserRegistries = (registries, basePath) => { const remainingTypes = Object.keys(registries); const populatedTypes = {}; @@ -47,7 +46,7 @@ const loadBrowserRegistries = (registries) => { // Load plugins one at a time because each needs a different loader function // $script will only load each of these once, we so can call this as many times as we need? - const pluginPath = chrome.addBasePath(`/api/canvas/plugins?type=${type}`); + const pluginPath = `${basePath}/api/canvas/plugins?type=${type}`; $script(pluginPath, () => { populatedTypes[type] = registries[type]; loadType(); @@ -58,7 +57,7 @@ const loadBrowserRegistries = (registries) => { }); }; -export const populateBrowserRegistries = (registries) => { +export const populateBrowserRegistries = (registries, basePath) => { if (called) { const oldPromise = populatePromise; let newResolve; @@ -66,7 +65,7 @@ export const populateBrowserRegistries = (registries) => { newResolve = _resolve; }); oldPromise.then(oldTypes => { - loadBrowserRegistries(registries).then(newTypes => { + loadBrowserRegistries(registries, basePath).then(newTypes => { newResolve({ ...oldTypes, ...newTypes, @@ -76,7 +75,7 @@ export const populateBrowserRegistries = (registries) => { return populatePromise; } called = true; - loadBrowserRegistries(registries).then(registries => { + loadBrowserRegistries(registries, basePath).then(registries => { resolvePromise(registries); }); return populatePromise; diff --git a/src/core_plugins/interpreter/public/load_browser_plugins.js b/src/core_plugins/interpreter/public/load_browser_plugins.js index 6034dae00238c..de550f5c6a351 100644 --- a/src/core_plugins/interpreter/public/load_browser_plugins.js +++ b/src/core_plugins/interpreter/public/load_browser_plugins.js @@ -17,6 +17,7 @@ * under the License. */ +import chrome from 'ui/chrome'; import { populateBrowserRegistries } from '@kbn/interpreter/public'; import { typesRegistry, functionsRegistry } from '@kbn/interpreter/common'; @@ -26,4 +27,4 @@ const types = { types: typesRegistry }; -populateBrowserRegistries(types); +populateBrowserRegistries(types, chrome.getBasePath()); diff --git a/x-pack/plugins/canvas/public/components/app/index.js b/x-pack/plugins/canvas/public/components/app/index.js index 6fc4a107f719a..f5fc65e029f36 100644 --- a/x-pack/plugins/canvas/public/components/app/index.js +++ b/x-pack/plugins/canvas/public/components/app/index.js @@ -53,7 +53,7 @@ const mapDispatchToProps = dispatch => ({ // initialize the socket and interpreter await createSocket(basePath); loadPrivateBrowserFunctions(); - await populateBrowserRegistries(types); + await populateBrowserRegistries(types, basePath); await initializeInterpreter(); // set app state to ready From cf04d179e4bece77d179d53c80bfd3968641317a Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Mon, 5 Nov 2018 15:23:55 -0500 Subject: [PATCH 92/95] Restructure user profile for granular app privs (#23750) merging to feature branch for further development --- .../console/server/proxy_route.js | 1 + src/core_plugins/kibana/index.js | 2 +- .../public/discover/controllers/discover.js | 206 ++++++++++-------- .../kibana/public/discover/discover_config.js | 32 +++ .../kibana/public/discover/index.js | 2 + src/core_plugins/kibana/public/kibana.js | 1 + src/ui/public/chrome/api/config.js | 34 +++ src/ui/public/chrome/api/nav.js | 1 + src/ui/public/chrome/chrome.js | 2 + .../global_nav/app_switcher/app_switcher.js | 5 +- x-pack/plugins/monitoring/init.js | 7 + x-pack/plugins/security/index.js | 41 ++++ .../edit_role/components/edit_role_page.tsx | 2 +- .../kibana/impacted_spaces_flyout.test.tsx | 4 +- .../kibana/impacted_spaces_flyout.tsx | 2 +- .../kibana/kibana_privileges.test.tsx | 3 +- .../privileges/kibana/kibana_privileges.tsx | 2 +- .../kibana/space_aware_privilege_form.tsx | 2 +- .../views/management/edit_role/index.js | 4 +- .../server/lib/authorization/privileges.js | 146 ++++++++++++- .../register_privileges_with_cluster.js | 14 ++ .../server/lib/capability_decorator.ts | 61 ++++++ x-pack/plugins/spaces/index.ts | 18 -- .../components/manage_spaces_button.test.tsx | 9 +- .../components/manage_spaces_button.tsx | 2 +- .../secure_space_message.test.tsx | 19 +- .../secure_space_message.tsx | 10 +- .../edit_space/manage_space_page.test.tsx | 11 - .../edit_space/manage_space_page.tsx | 2 +- .../public/views/management/page_routes.tsx | 20 +- .../spaces_grid/spaces_grid_page.tsx | 2 +- .../spaces_grid/spaces_grid_pages.test.tsx | 7 - .../components/spaces_description.test.tsx | 8 +- .../components/spaces_description.tsx | 2 +- .../nav_control/components/spaces_menu.tsx | 2 +- .../public/views/nav_control/nav_control.tsx | 10 +- .../nav_control/nav_control_popover.test.tsx | 5 +- .../views/nav_control/nav_control_popover.tsx | 2 +- x-pack/plugins/xpack_main/common/index.ts | 7 + .../common/user_profile/capabilities.ts | 9 + .../xpack_main/common/user_profile/index.ts | 7 + .../user_profile}/user_profile.test.ts | 16 +- .../common/user_profile/user_profile.ts | 38 ++++ x-pack/plugins/xpack_main/index.js | 7 +- .../xpack_main/public/hacks/user_profile.ts | 17 ++ .../hacks/user_profile_config_decorators.js | 52 +++++ .../public/services/user_profile.ts | 31 --- .../lib/__tests__/replace_injected_vars.js | 17 +- .../lib/feature_registry/feature_registry.ts | 30 +++ .../server/lib/feature_registry/index.ts | 7 + .../feature_registry/register_oss_features.ts | 54 +++++ .../server/lib/replace_injected_vars.js | 3 +- .../xpack_main/server/lib/setup_xpack_main.js | 2 + .../server/lib/user_profile/index.ts | 8 + .../lib/user_profile/priority_collection.ts | 31 +++ .../user_profile_capability_registry.ts | 55 +++++ .../lib/user_profile/user_profile_mixin.ts | 28 +++ .../server/lib/user_profile_registry.test.ts | 36 --- .../server/lib/user_profile_registry.ts | 32 --- 59 files changed, 855 insertions(+), 335 deletions(-) create mode 100644 src/core_plugins/kibana/public/discover/discover_config.js create mode 100644 src/ui/public/chrome/api/config.js create mode 100644 x-pack/plugins/security/server/lib/capability_decorator.ts create mode 100644 x-pack/plugins/xpack_main/common/index.ts create mode 100644 x-pack/plugins/xpack_main/common/user_profile/capabilities.ts create mode 100644 x-pack/plugins/xpack_main/common/user_profile/index.ts rename x-pack/plugins/xpack_main/{public/services => common/user_profile}/user_profile.test.ts (81%) create mode 100644 x-pack/plugins/xpack_main/common/user_profile/user_profile.ts create mode 100644 x-pack/plugins/xpack_main/public/hacks/user_profile.ts create mode 100644 x-pack/plugins/xpack_main/public/hacks/user_profile_config_decorators.js delete mode 100644 x-pack/plugins/xpack_main/public/services/user_profile.ts create mode 100644 x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts create mode 100644 x-pack/plugins/xpack_main/server/lib/feature_registry/index.ts create mode 100644 x-pack/plugins/xpack_main/server/lib/feature_registry/register_oss_features.ts create mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile/index.ts create mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile/priority_collection.ts create mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_capability_registry.ts create mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_mixin.ts delete mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile_registry.test.ts delete mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile_registry.ts diff --git a/src/core_plugins/console/server/proxy_route.js b/src/core_plugins/console/server/proxy_route.js index a7062133dcd36..4335a5d849107 100644 --- a/src/core_plugins/console/server/proxy_route.js +++ b/src/core_plugins/console/server/proxy_route.js @@ -66,6 +66,7 @@ export const createProxyRoute = ({ path: '/api/console/proxy', method: 'POST', config: { + tags: ['access:execute'], payload: { output: 'stream', parse: false diff --git a/src/core_plugins/kibana/index.js b/src/core_plugins/kibana/index.js index c7a44ac2b04bd..7f9db00078314 100644 --- a/src/core_plugins/kibana/index.js +++ b/src/core_plugins/kibana/index.js @@ -130,7 +130,7 @@ export default function (kibana) { injectDefaultVars(server, options) { return { kbnIndex: options.index, - kbnBaseUrl + kbnBaseUrl, }; }, diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index a10ef78da11c4..14793352de456 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -190,105 +190,123 @@ function discoverController( dirty: !savedSearch.id }; - $scope.topNavMenu = [{ - key: i18n('kbn.discover.localMenu.localMenu.newSearchTitle', { - defaultMessage: 'new', - }), - description: i18n('kbn.discover.localMenu.newSearchDescription', { - defaultMessage: 'New Search', - }), - run: function () { kbnUrl.change('/discover'); }, - testId: 'discoverNewButton', - }, { - key: i18n('kbn.discover.localMenu.saveTitle', { - defaultMessage: 'save', - }), - description: i18n('kbn.discover.localMenu.saveSearchDescription', { - defaultMessage: 'Save Search', - }), - testId: 'discoverSaveButton', - run: async () => { - const onSave = ({ newTitle, newCopyOnSave, isTitleDuplicateConfirmed, onTitleDuplicate }) => { - const currentTitle = savedSearch.title; - savedSearch.title = newTitle; - savedSearch.copyOnSave = newCopyOnSave; - const saveOptions = { - confirmOverwrite: false, - isTitleDuplicateConfirmed, - onTitleDuplicate, + const getTopNavLinks = () => { + const newSearch = { + key: i18n('kbn.discover.localMenu.localMenu.newSearchTitle', { + defaultMessage: 'new', + }), + description: i18n('kbn.discover.localMenu.newSearchDescription', { + defaultMessage: 'New Search', + }), + run: function () { kbnUrl.change('/discover'); }, + testId: 'discoverNewButton', + }; + + const saveSearch = { + key: i18n('kbn.discover.localMenu.saveTitle', { + defaultMessage: 'save', + }), + description: i18n('kbn.discover.localMenu.saveSearchDescription', { + defaultMessage: 'Save Search', + }), + testId: 'discoverSaveButton', + run: async () => { + const onSave = ({ newTitle, newCopyOnSave, isTitleDuplicateConfirmed, onTitleDuplicate }) => { + const currentTitle = savedSearch.title; + savedSearch.title = newTitle; + savedSearch.copyOnSave = newCopyOnSave; + const saveOptions = { + confirmOverwrite: false, + isTitleDuplicateConfirmed, + onTitleDuplicate, + }; + return saveDataSource(saveOptions).then(({ id, error }) => { + // If the save wasn't successful, put the original values back. + if (!id || error) { + savedSearch.title = currentTitle; + } + return { id, error }; + }); }; - return saveDataSource(saveOptions).then(({ id, error }) => { - // If the save wasn't successful, put the original values back. - if (!id || error) { - savedSearch.title = currentTitle; + + const saveModal = ( + { }} + title={savedSearch.title} + showCopyOnSave={savedSearch.id ? true : false} + objectType="search" + />); + showSaveModal(saveModal); + } + }; + const openSearch = { + key: i18n('kbn.discover.localMenu.openTitle', { + defaultMessage: 'open', + }), + description: i18n('kbn.discover.localMenu.openSavedSearchDescription', { + defaultMessage: 'Open Saved Search', + }), + testId: 'discoverOpenButton', + run: () => { + showOpenSearchPanel({ + makeUrl: (searchId) => { + return kbnUrl.eval('#/discover/{{id}}', { id: searchId }); } - return { id, error }; }); - }; + } + }; - const saveModal = ( - {}} - title={savedSearch.title} - showCopyOnSave={savedSearch.id ? true : false} - objectType="search" - />); - showSaveModal(saveModal); - } - }, { - key: i18n('kbn.discover.localMenu.openTitle', { - defaultMessage: 'open', - }), - description: i18n('kbn.discover.localMenu.openSavedSearchDescription', { - defaultMessage: 'Open Saved Search', - }), - testId: 'discoverOpenButton', - run: () => { - showOpenSearchPanel({ - makeUrl: (searchId) => { - return kbnUrl.eval('#/discover/{{id}}', { id: searchId }); - } - }); - } - }, { - key: i18n('kbn.discover.localMenu.shareTitle', { - defaultMessage: 'share', - }), - description: i18n('kbn.discover.localMenu.shareSearchDescription', { - defaultMessage: 'Share Search', - }), - testId: 'shareTopNavButton', - run: async (menuItem, navController, anchorElement) => { - const sharingData = await this.getSharingData(); - showShareContextMenu({ - anchorElement, - allowEmbed: false, - getUnhashableStates, - objectId: savedSearch.id, - objectType: 'search', - shareContextMenuExtensions, - sharingData: { - ...sharingData, - title: savedSearch.title, - }, - isDirty: $appStatus.dirty, - }); - } - }, { - key: i18n('kbn.discover.localMenu.inspectTitle', { - defaultMessage: 'inspect', - }), - description: i18n('kbn.discover.localMenu.openInspectorForSearchDescription', { - defaultMessage: 'Open Inspector for search', - }), - testId: 'openInspectorButton', - run() { - Inspector.open(inspectorAdapters, { - title: savedSearch.title - }); + const shareSearch = { + key: i18n('kbn.discover.localMenu.shareTitle', { + defaultMessage: 'share', + }), + description: i18n('kbn.discover.localMenu.shareSearchDescription', { + defaultMessage: 'Share Search', + }), + testId: 'shareTopNavButton', + run: async (menuItem, navController, anchorElement) => { + const sharingData = await this.getSharingData(); + showShareContextMenu({ + anchorElement, + allowEmbed: false, + getUnhashableStates, + objectId: savedSearch.id, + objectType: 'search', + shareContextMenuExtensions, + sharingData: { + ...sharingData, + title: savedSearch.title, + }, + isDirty: $appStatus.dirty, + }); + } + }; + + const inspectSearch = { + key: i18n('kbn.discover.localMenu.inspectTitle', { + defaultMessage: 'inspect', + }), + description: i18n('kbn.discover.localMenu.openInspectorForSearchDescription', { + defaultMessage: 'Open Inspector for search', + }), + testId: 'openInspectorButton', + run() { + Inspector.open(inspectorAdapters, { + title: savedSearch.title + }); + } + }; + + const hideSave = false; + + if (hideSave) { + return [newSearch, openSearch, shareSearch, inspectSearch]; } - }]; + return [newSearch, saveSearch, openSearch, shareSearch, inspectSearch]; + }; + + $scope.topNavMenu = getTopNavLinks(); // the actual courier.SearchSource $scope.searchSource = savedSearch.searchSource; diff --git a/src/core_plugins/kibana/public/discover/discover_config.js b/src/core_plugins/kibana/public/discover/discover_config.js new file mode 100644 index 0000000000000..d98a309370481 --- /dev/null +++ b/src/core_plugins/kibana/public/discover/discover_config.js @@ -0,0 +1,32 @@ +/* + * 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 { uiModules } from 'ui/modules'; + +uiModules.get('kibana') + .provider('discoverConfig', () => { + return { + $get() { + return { + getHideWriteControls() { + return false; + } + }; + } + }; + }); diff --git a/src/core_plugins/kibana/public/discover/index.js b/src/core_plugins/kibana/public/discover/index.js index 68685a9d5b28b..45d62fed5a47a 100644 --- a/src/core_plugins/kibana/public/discover/index.js +++ b/src/core_plugins/kibana/public/discover/index.js @@ -17,12 +17,14 @@ * under the License. */ +import './discover_config'; import './saved_searches/saved_searches'; import './directives'; import 'ui/collapsible_sidebar'; import './components/field_chooser/field_chooser'; import './controllers/discover'; import 'ui/doc_table/components/table_row'; + import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue'; FeatureCatalogueRegistryProvider.register(i18n => { diff --git a/src/core_plugins/kibana/public/kibana.js b/src/core_plugins/kibana/public/kibana.js index ed88791241d13..ca3bc5d42e96c 100644 --- a/src/core_plugins/kibana/public/kibana.js +++ b/src/core_plugins/kibana/public/kibana.js @@ -64,6 +64,7 @@ import 'leaflet'; routes.enable(); + routes .otherwise({ redirectTo: `/${chrome.getInjected('kbnDefaultAppId', 'discover')}` diff --git a/src/ui/public/chrome/api/config.js b/src/ui/public/chrome/api/config.js new file mode 100644 index 0000000000000..fe12384c58a52 --- /dev/null +++ b/src/ui/public/chrome/api/config.js @@ -0,0 +1,34 @@ +/* + * 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 { uiModules } from '../../modules'; + +export function initConfig() { + uiModules.get('kibana') + .provider('chromeConfig', () => { + return { + $get() { + return { + shouldHideNavLink() { + return false; + } + }; + } + }; + }); +} diff --git a/src/ui/public/chrome/api/nav.js b/src/ui/public/chrome/api/nav.js index 329d1c463884d..772f4254533b4 100644 --- a/src/ui/public/chrome/api/nav.js +++ b/src/ui/public/chrome/api/nav.js @@ -22,6 +22,7 @@ import { relativeToAbsolute } from '../../url/relative_to_absolute'; import { absoluteToParsedUrl } from '../../url/absolute_to_parsed_url'; export function initChromeNavApi(chrome, internals) { + chrome.getNavLinks = function () { return internals.nav; }; diff --git a/src/ui/public/chrome/chrome.js b/src/ui/public/chrome/chrome.js index 7eba951076803..d17155fe473d3 100644 --- a/src/ui/public/chrome/chrome.js +++ b/src/ui/public/chrome/chrome.js @@ -38,6 +38,7 @@ import { initChromeNavApi } from './api/nav'; import { initBreadcrumbsApi } from './api/breadcrumbs'; import templateApi from './api/template'; import { initChromeThemeApi } from './api/theme'; +import { initConfig } from './api/config'; import { initChromeXsrfApi } from './api/xsrf'; import { initUiSettingsApi } from './api/ui_settings'; import { initLoadingCountApi } from './api/loading_count'; @@ -61,6 +62,7 @@ const internals = _.defaults( } ); +initConfig(); initUiSettingsApi(chrome); initSavedObjectClient(chrome); appsApi(chrome, internals); diff --git a/src/ui/public/chrome/directives/global_nav/app_switcher/app_switcher.js b/src/ui/public/chrome/directives/global_nav/app_switcher/app_switcher.js index b349435da17c9..52d94c3efc218 100644 --- a/src/ui/public/chrome/directives/global_nav/app_switcher/app_switcher.js +++ b/src/ui/public/chrome/directives/global_nav/app_switcher/app_switcher.js @@ -69,12 +69,13 @@ uiModules }, template: appSwitcherTemplate, controllerAs: 'switcher', - controller($scope, appSwitcherEnsureNavigation, globalNavState) { + controller($scope, appSwitcherEnsureNavigation, globalNavState, chromeConfig) { if (!$scope.chrome || !$scope.chrome.getNavLinks) { throw new TypeError('appSwitcher directive requires the "chrome" config-object'); } - this.links = $scope.chrome.getNavLinks(); + this.links = $scope.chrome.getNavLinks() + .filter(navLink => !chromeConfig.shouldHideNavLink(navLink)); // links don't cause full-navigation events in certain scenarios // so we force them when needed diff --git a/x-pack/plugins/monitoring/init.js b/x-pack/plugins/monitoring/init.js index 24aecb4a604d3..53f5f4df11a38 100644 --- a/x-pack/plugins/monitoring/init.js +++ b/x-pack/plugins/monitoring/init.js @@ -54,6 +54,13 @@ export const init = (monitoringPlugin, server) => { } }); + xpackMainPlugin.registerFeature({ + id: 'monitoring', + name: 'Monitoring', + type: 'app', + icon: 'monitoringApp' + }); + const bulkUploader = initBulkUploader(kbnServer, server); const kibanaCollectionEnabled = config.get('xpack.monitoring.kibana.collection.enabled'); const { info: xpackMainInfo } = xpackMainPlugin; diff --git a/x-pack/plugins/security/index.js b/x-pack/plugins/security/index.js index 5baba2c222329..fd8939ba62e6d 100644 --- a/x-pack/plugins/security/index.js +++ b/x-pack/plugins/security/index.js @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import Boom from 'boom'; import { resolve } from 'path'; import { getUserProvider } from './server/lib/get_user'; import { initAuthenticateApi } from './server/routes/api/v1/authenticate'; @@ -23,6 +24,8 @@ import { createAuthorizationService, registerPrivilegesWithCluster } from './ser import { watchStatusAndLicenseToInitialize } from '../../server/lib/watch_status_and_license_to_initialize'; import { SecureSavedObjectsClientWrapper } from './server/lib/saved_objects_client/secure_saved_objects_client_wrapper'; import { deepFreeze } from './server/lib/deep_freeze'; +import { capabilityDecorator } from './server/lib/capability_decorator'; +import { registerUserProfileCapabilityDecorator } from '../xpack_main/server/lib/user_profile'; export const security = (kibana) => new kibana.Plugin({ id: 'security', @@ -124,6 +127,8 @@ export const security = (kibana) => new kibana.Plugin({ } }); + registerUserProfileCapabilityDecorator(Number.MIN_SAFE_INTEGER, capabilityDecorator); + const auditLogger = new SecurityAuditLogger(server.config(), new AuditLogger(server, 'security')); const { savedObjects } = server; @@ -186,5 +191,41 @@ export const security = (kibana) => new kibana.Plugin({ } }; }); + + + server.ext('onPostAuth', async function (req, h) { + const path = req.path; + + // Enforce app restrictions + if (path.startsWith('/app/')) { + const appId = path.split('/', 3)[2]; + const userProfile = await req.getUserProfile(); + if (!userProfile.canAccessFeature(appId)) { + return Boom.notFound(); + } + } + + // Enforce API restrictions for associated applications + if (path.startsWith('/api/')) { + const { tags = [] } = req.route.settings; + + const actionTags = tags.filter(tag => tag.startsWith('access:')); + + if (actionTags.length > 0) { + const feature = path.split('/', 3)[2]; + const actions = actionTags.map(tag => `api:${feature}/${tag.split(':', 2)[1]}`); + + const { checkPrivilegesWithRequest } = server.plugins.security.authorization; + const checkPrivileges = checkPrivilegesWithRequest(req); + const canExecute = await checkPrivileges.globally(actions); + + if (!canExecute.hasAllRequested) { + return Boom.notFound(); + } + } + } + + return h.continue; + }); } }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx index a3b6b58d09d06..ddf3a10146e3a 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx @@ -25,7 +25,7 @@ import { get } from 'lodash'; import React, { ChangeEvent, Component, Fragment, HTMLProps } from 'react'; import { toastNotifications } from 'ui/notify'; import { Space } from '../../../../../../spaces/common/model/space'; -import { UserProfile } from '../../../../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../../../../xpack_main/common/user_profile'; import { IndexPrivilege } from '../../../../../common/model/index_privilege'; import { KibanaPrivilege } from '../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../common/model/role'; diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx index 8a103ff493165..dbf6db220607c 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx @@ -35,9 +35,7 @@ const buildProps = (customProps = {}) => { name: 'Marketing', }, ], - userProfile: { - hasCapability: () => true, - }, + userProfile: new UserProfile(), kibanaAppPrivileges: [ { name: 'all', diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx index f811912e6148f..0ca928b2e5f77 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx @@ -18,7 +18,7 @@ import { PrivilegeSpaceTable } from './privilege_space_table'; import { Space } from '../../../../../../../../spaces/common/model/space'; import { ManageSpacesButton } from '../../../../../../../../spaces/public/components'; -import { UserProfile } from '../../../../../../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../../../../../../xpack_main/common/user_profile'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../../../common/model/role'; import { NO_PRIVILEGE_VALUE } from '../../../lib/constants'; diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.test.tsx index 07dd40c5de8a5..56bf1f0af8a0d 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.test.tsx @@ -7,6 +7,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import { KibanaPrivilege } from '../../../../../../../../security/common/model/kibana_privilege'; +import { UserProfile } from '../../../../../../../../xpack_main/common/user_profile'; import { RoleValidator } from '../../../lib/validate_role'; import { KibanaPrivileges } from './kibana_privileges'; import { SimplePrivilegeForm } from './simple_privilege_form'; @@ -38,7 +39,7 @@ const buildProps = (customProps = {}) => { name: 'Marketing', }, ], - userProfile: { hasCapability: () => true }, + userProfile: new UserProfile(), editable: true, kibanaAppPrivileges: ['all' as KibanaPrivilege], onChange: jest.fn(), diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx index 12783ecd150bf..2248a75ad5539 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx @@ -7,7 +7,7 @@ import { I18nProvider } from '@kbn/i18n/react'; import React, { Component } from 'react'; import { Space } from '../../../../../../../../spaces/common/model/space'; -import { UserProfile } from '../../../../../../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../../../../../../xpack_main/common/user_profile'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../../../common/model/role'; import { RoleValidator } from '../../../lib/validate_role'; diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx index cd4bdb2f41b44..5465d4db427ab 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx @@ -19,7 +19,7 @@ import { import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; import { Space } from '../../../../../../../../spaces/common/model/space'; -import { UserProfile } from '../../../../../../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../../../../../../xpack_main/common/user_profile'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../../../common/model/role'; import { isReservedRole } from '../../../../../../lib/role'; diff --git a/x-pack/plugins/security/public/views/management/edit_role/index.js b/x-pack/plugins/security/public/views/management/edit_role/index.js index 2377542834ed7..b473a975e5561 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/index.js +++ b/x-pack/plugins/security/public/views/management/edit_role/index.js @@ -19,7 +19,6 @@ import 'plugins/security/services/shield_indices'; import { IndexPatternsProvider } from 'ui/index_patterns/index_patterns'; import { XPackInfoProvider } from 'plugins/xpack_main/services/xpack_info'; import { SpacesManager } from '../../../../../spaces/public/lib'; -import { UserProfileProvider } from 'plugins/xpack_main/services/user_profile'; import { checkLicenseError } from 'plugins/security/lib/check_license_error'; import { EDIT_ROLES_PATH, ROLES_PATH } from '../management_urls'; @@ -87,14 +86,13 @@ routes.when(`${EDIT_ROLES_PATH}/:name?`, { } }, controllerAs: 'editRole', - controller($injector, $scope, $http, enableSpaceAwarePrivileges) { + controller($injector, $scope, $http, enableSpaceAwarePrivileges, userProfile) { const $route = $injector.get('$route'); const Private = $injector.get('Private'); const role = $route.current.locals.role; const xpackInfo = Private(XPackInfoProvider); - const userProfile = Private(UserProfileProvider); const allowDocumentLevelSecurity = xpackInfo.get('features.security.allowRoleDocumentLevelSecurity'); const allowFieldLevelSecurity = xpackInfo.get('features.security.allowRoleFieldLevelSecurity'); const rbacApplication = chrome.getInjected('rbacApplication'); diff --git a/x-pack/plugins/security/server/lib/authorization/privileges.js b/x-pack/plugins/security/server/lib/authorization/privileges.js index 7e9f53f873a0d..611a36b99402a 100644 --- a/x-pack/plugins/security/server/lib/authorization/privileges.js +++ b/x-pack/plugins/security/server/lib/authorization/privileges.js @@ -7,36 +7,168 @@ import { IGNORED_TYPES } from '../../../common/constants'; export function buildPrivilegeMap(savedObjectTypes, actions) { - const buildSavedObjectsActions = (savedObjectActions) => { - return savedObjectTypes + + const buildAccessFeatureAction = (feature) => `ui:${feature}/read`; + + const buildSavedObjectsActions = (types, savedObjectActions) => { + return types .filter(type => !IGNORED_TYPES.includes(type)) .map(type => savedObjectActions.map(savedObjectAction => actions.getSavedObjectAction(type, savedObjectAction))) .reduce((acc, types) => [...acc, ...types], []); }; + const buildSavedObjectsReadActions = (types) => buildSavedObjectsActions(types, ['get', 'bulk_get', 'find']); + const buildSavedObjectsWriteActions = (types) => buildSavedObjectsActions(types, ['create', 'bulk_create', 'update', 'delete']); + const buildAllSavedObjectsActions = (types) => [...buildSavedObjectsReadActions(types), ...buildSavedObjectsWriteActions(types)]; + // the following list of privileges should only be added to, you can safely remove actions, but not privileges as // it's a backwards compatibility issue and we'll have to at least adjust registerPrivilegesWithCluster to support it return { global: { all: [ actions.version, - 'action:*' + 'action:*', + 'ui:kibana*', + 'api:*', ], read: [ actions.version, actions.login, - ...buildSavedObjectsActions([ + 'ui:*', + 'api:console/proxy/execute', + ...buildSavedObjectsActions(savedObjectTypes, [ 'get', 'bulk_get', 'find' ]) ], }, + features: { + discover: { + read_write: [ + buildAccessFeatureAction(`kibana`), + buildAccessFeatureAction(`kibana:discover`), + ...buildSavedObjectsReadActions(['index-pattern']), + ...buildAllSavedObjectsActions(['search']) + ], + read: [ + buildAccessFeatureAction(`kibana`), + buildAccessFeatureAction(`kibana:discover`), + ...buildSavedObjectsReadActions(['index-pattern', 'search']), + ], + share: [ + 'action:saved_objects/search/share', + ] + }, + visualize: { + all: [ + buildAccessFeatureAction(`kibana`), + buildAccessFeatureAction(`kibana:visualize`), + ...buildSavedObjectsReadActions(['index-pattern', 'search']), + ...buildAllSavedObjectsActions(['visualization']) + ], + read: [ + buildAccessFeatureAction(`kibana`), + buildAccessFeatureAction(`kibana:visualize`), + ...buildSavedObjectsReadActions(['index-pattern', 'search', 'visualization']), + ] + }, + dashboard: { + all: [ + buildAccessFeatureAction(`kibana`), + buildAccessFeatureAction(`kibana:dashboard`), + ...buildSavedObjectsReadActions(['index-pattern', 'search', 'visualization', 'timelion', 'canvas']), + ...buildAllSavedObjectsActions(['dashboard']) + ], + read: [ + buildAccessFeatureAction(`kibana`), + buildAccessFeatureAction(`kibana:dashboard`), + ...buildSavedObjectsReadActions(['index-pattern', 'search', 'visualization', 'timelion', 'canvas', 'dashboard']), + ] + }, + timelion: { + all: [ + buildAccessFeatureAction(`timelion`), + ...buildSavedObjectsReadActions(['index-pattern' ]), + ...buildAllSavedObjectsActions(['timelion']) + ], + read: [ + buildAccessFeatureAction(`timelion`), + ...buildSavedObjectsReadActions(['index-pattern', 'timelion']), + ] + }, + canvas: { + all: [ + buildAccessFeatureAction(`canvas`), + ...buildSavedObjectsReadActions(['index-pattern']), + ...buildAllSavedObjectsActions(['canvas']) + ], + read: [ + buildAccessFeatureAction(`canvas`), + ...buildSavedObjectsReadActions(['index-pattern', 'canvas']), + ] + }, + apm: { + all: [ + buildAccessFeatureAction(`apm`), + ] + }, + ml: { + all: [ + buildAccessFeatureAction(`ml`), + ] + }, + graph: { + all: [ + buildAccessFeatureAction(`graph`), + ...buildSavedObjectsReadActions(['index-pattern']), + ...buildAllSavedObjectsActions(['graph']) + ], + read: [ + buildAccessFeatureAction(`graph`), + ...buildSavedObjectsReadActions(['index-pattern', 'graph']), + ] + }, + devTools: { + all: [ + buildAccessFeatureAction(`kibana`), + buildAccessFeatureAction('kibana:dev_tools'), + 'api:console/proxy/execute' + ], + }, + monitoring: { + all: [ + buildAccessFeatureAction(`monitoring`), + ] + }, + // This is a subfeature of a feature within an application + // it feels strange to put the feature at the same level as a full-featured application + advancedSettings: { + all: [ + buildAccessFeatureAction(`kibana:management:advancedSettings`), + ...buildAllSavedObjectsActions(['config']) + ], + read: [ + // not being able to write config makes some things hard: + // automatic assignment of default index pattern + buildAccessFeatureAction(`kibana:management:advancedSettings`), + ...buildSavedObjectsReadActions(['config']) + ] + }, + management: { + all: [ + buildAccessFeatureAction(`kibana`), + buildAccessFeatureAction(`kibana:management`), + ] + }, + }, space: { all: [ actions.version, actions.login, - ...buildSavedObjectsActions([ + 'ui:*', + 'api:*', + ...buildSavedObjectsActions(savedObjectTypes, [ 'create', 'bulk_create', 'delete', @@ -49,7 +181,9 @@ export function buildPrivilegeMap(savedObjectTypes, actions) { read: [ actions.version, actions.login, - ...buildSavedObjectsActions([ + 'ui:*', + 'api:console/proxy/execute', + ...buildSavedObjectsActions(savedObjectTypes, [ 'get', 'bulk_get', 'find']) diff --git a/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.js b/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.js index 6845dd7590e2d..12bea327b0fc9 100644 --- a/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.js +++ b/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.js @@ -29,6 +29,20 @@ const serializePrivileges = (application, privilegeMap) => { actions: privilegeActions, metadata: {}, }; + return acc; + }, {}), + ...Object.entries(privilegeMap.features).reduce((acc, [featureName, featurePrivileges]) => { + + Object.entries(featurePrivileges).forEach(([privilegeName, privilegeActions]) => { + const name = `feature_${featureName}_${privilegeName}`; + acc[name] = { + application, + name, + actions: privilegeActions, + metadata: {}, + }; + }); + return acc; }, {}) } diff --git a/x-pack/plugins/security/server/lib/capability_decorator.ts b/x-pack/plugins/security/server/lib/capability_decorator.ts new file mode 100644 index 0000000000000..9f9be0a96fbe8 --- /dev/null +++ b/x-pack/plugins/security/server/lib/capability_decorator.ts @@ -0,0 +1,61 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import _ from 'lodash'; +import { Capabilities } from 'x-pack/plugins/xpack_main/common'; + +export async function capabilityDecorator( + server: Record, + request: Record, + capabilities: Capabilities +) { + if (!isAuthenticatedRoute(request)) { + return capabilities; + } + + const { checkPrivilegesWithRequest, actions } = server.plugins.security.authorization; + + const checkPrivileges = checkPrivilegesWithRequest(request); + + const privilegedActions = getPrivilegedActions(server, actions); + + const { spaces } = server.plugins; + + let result; + if (spaces) { + result = await checkPrivileges.atSpace(spaces.getSpaceId(request), privilegedActions); + } else { + result = await checkPrivileges.globally(privilegedActions); + } + + return { + ...capabilities, + ...result.privileges, + }; +} + +function isAuthenticatedRoute(request: Record) { + const { settings } = request.route; + return settings.auth !== false; +} + +function getPrivilegedActions(server: Record, actions: Record) { + const uiApps = server.getAllUiApps(); + + const navLinkSpecs = server.getUiNavLinks(); + + const uiCapabilityActions = [...uiApps, ...navLinkSpecs].map(entry => `ui:${entry._id}/read`); + + const { types } = server.savedObjects; + + const savedObjectsActions = _.flatten( + types.map((type: string) => [ + actions.getSavedObjectAction(type, 'read'), + actions.getSavedObjectAction(type, 'create'), + ]) + ); + + return [...uiCapabilityActions, ...savedObjectsActions]; +} diff --git a/x-pack/plugins/spaces/index.ts b/x-pack/plugins/spaces/index.ts index 1a23f9b55404d..052b3a2ff6ce6 100644 --- a/x-pack/plugins/spaces/index.ts +++ b/x-pack/plugins/spaces/index.ts @@ -9,7 +9,6 @@ import { resolve } from 'path'; import { AuditLogger } from '../../server/lib/audit_logger'; // @ts-ignore import { watchStatusAndLicenseToInitialize } from '../../server/lib/watch_status_and_license_to_initialize'; -import { registerUserProfileCapabilityFactory } from '../xpack_main/server/lib/user_profile_registry'; import mappings from './mappings.json'; import { SpacesAuditLogger } from './server/lib/audit_logger'; import { checkLicense } from './server/lib/check_license'; @@ -145,23 +144,6 @@ export const spaces = (kibana: any) => initSpacesRequestInterceptors(server); - registerUserProfileCapabilityFactory(async request => { - const spacesClient = server.plugins.spaces.spacesClient.getScopedClient(request); - - let manageSecurity = false; - - if (server.plugins.security) { - const { showLinks = false } = - xpackMainPlugin.info.feature('security').getLicenseCheckResults() || {}; - manageSecurity = showLinks; - } - - return { - manageSpaces: await spacesClient.canEnumerateSpaces(), - manageSecurity, - }; - }); - // Register a function with server to manage the collection of usage stats server.usage.collectorSet.register(getSpacesUsageCollector(server)); }, diff --git a/x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx b/x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx index 2c0c42f953ab8..cdef0a9e7f9de 100644 --- a/x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx +++ b/x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx @@ -5,21 +5,16 @@ */ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import { UserProfileProvider } from '../../../xpack_main/public/services/user_profile'; import { ManageSpacesButton } from './manage_spaces_button'; -const buildUserProfile = (canManageSpaces: boolean) => { - return UserProfileProvider({ manageSpaces: canManageSpaces }); -}; - describe('ManageSpacesButton', () => { it('renders as expected', () => { - const component = ; + const component = ; expect(shallowWithIntl(component)).toMatchSnapshot(); }); it(`doesn't render if user profile forbids managing spaces`, () => { - const component = ; + const component = ; expect(shallowWithIntl(component)).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/spaces/public/components/manage_spaces_button.tsx b/x-pack/plugins/spaces/public/components/manage_spaces_button.tsx index a9e40a89edacf..55f5b48ddb2b6 100644 --- a/x-pack/plugins/spaces/public/components/manage_spaces_button.tsx +++ b/x-pack/plugins/spaces/public/components/manage_spaces_button.tsx @@ -7,7 +7,7 @@ import { EuiButton } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component, CSSProperties } from 'react'; -import { UserProfile } from '../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../xpack_main/common/user_profile'; import { MANAGE_SPACES_URL } from '../lib/constants'; interface Props { diff --git a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.test.tsx b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.test.tsx index 95aa3b37cf24c..e6a4ebc161fb4 100644 --- a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.test.tsx +++ b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.test.tsx @@ -9,27 +9,14 @@ import { SecureSpaceMessage } from './secure_space_message'; describe('SecureSpaceMessage', () => { it(`doesn't render if user profile does not allow security to be managed`, () => { - const userProfile = { - hasCapability: (key: string) => { - if (key === 'manageSecurity') { - return false; - } - throw new Error(`unexpected capability ${key}`); - }, - }; expect(shallowWithIntl()).toMatchSnapshot(); }); it(`renders if user profile allows security to be managed`, () => { - const userProfile = { - hasCapability: (key: string) => { - if (key === 'manageSecurity') { - return true; - } - throw new Error(`unexpected capability ${key}`); - }, - }; + const userProfile = new UserProfile({ + manageSecurity: true, + }); expect(shallowWithIntl()).toMatchSnapshot(); }); diff --git a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.tsx b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.tsx index 30fb1f1458355..83ac70715f5c9 100644 --- a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.tsx +++ b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.tsx @@ -6,15 +6,11 @@ import { EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { UserProfile } from 'plugins/xpack_main/services/user_profile'; import React, { Fragment } from 'react'; +import { uiCapabilities } from 'ui/capabilities'; -interface Props { - userProfile: UserProfile; -} - -export const SecureSpaceMessage = (props: Props) => { - if (props.userProfile.hasCapability('manageSecurity')) { +export const SecureSpaceMessage = (props: {}) => { + if (uiCapabilities.security.manage) { return ( diff --git a/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.test.tsx b/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.test.tsx index e89f08d167e6f..9bb4ad3be2dbe 100644 --- a/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.test.tsx +++ b/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.test.tsx @@ -6,7 +6,6 @@ import React from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; -import { UserProfileProvider } from '../../../../../xpack_main/public/services/user_profile'; import { SpacesManager } from '../../../lib'; import { SpacesNavState } from '../../nav_control'; import { ManageSpacePage } from './manage_space_page'; @@ -21,10 +20,6 @@ const buildMockChrome = () => { }; }; -const buildUserProfile = (canManageSpaces: boolean) => { - return UserProfileProvider({ manageSpaces: canManageSpaces }); -}; - describe('ManageSpacePage', () => { it('allows a space to be created', async () => { const mockHttp = { @@ -40,12 +35,9 @@ describe('ManageSpacePage', () => { refreshSpacesList: jest.fn(), }; - const userProfile = buildUserProfile(true); - const wrapper = mountWithIntl( @@ -95,13 +87,10 @@ describe('ManageSpacePage', () => { refreshSpacesList: jest.fn(), }; - const userProfile = buildUserProfile(true); - const wrapper = mountWithIntl( diff --git a/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.tsx b/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.tsx index 8a2398e695dd2..38a383a13a928 100644 --- a/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.tsx +++ b/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.tsx @@ -25,9 +25,9 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { ChangeEvent, Component, Fragment } from 'react'; import { SpacesNavState } from 'plugins/spaces/views/nav_control'; -import { UserProfile } from 'plugins/xpack_main/services/user_profile'; // @ts-ignore import { toastNotifications } from 'ui/notify'; +import { UserProfile } from '../../../../../xpack_main/common/user_profile'; import { isReservedSpace } from '../../../../common'; import { Space } from '../../../../common/model/space'; import { SpaceAvatar } from '../../../components'; diff --git a/x-pack/plugins/spaces/public/views/management/page_routes.tsx b/x-pack/plugins/spaces/public/views/management/page_routes.tsx index 1577aaf0481c9..cbfaf19898cc3 100644 --- a/x-pack/plugins/spaces/public/views/management/page_routes.tsx +++ b/x-pack/plugins/spaces/public/views/management/page_routes.tsx @@ -7,8 +7,6 @@ import { I18nProvider } from '@kbn/i18n/react'; // @ts-ignore import template from 'plugins/spaces/views/management/template.html'; -// @ts-ignore -import { UserProfileProvider } from 'plugins/xpack_main/services/user_profile'; import 'ui/autoload/styles'; import { SpacesNavState } from 'plugins/spaces/views/nav_control'; @@ -16,6 +14,7 @@ import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; // @ts-ignore import routes from 'ui/routes'; +import { UserProfile } from '../../../../xpack_main/common/user_profile'; import { SpacesManager } from '../../lib/spaces_manager'; import { ManageSpacePage } from './edit_space'; import { SpacesGridPage } from './spaces_grid'; @@ -28,12 +27,10 @@ routes.when('/management/spaces/list', { $scope: any, $http: any, chrome: any, - Private: any, spacesNavState: SpacesNavState, - spaceSelectorURL: string + spaceSelectorURL: string, + userProfile: UserProfile ) { - const userProfile = Private(UserProfileProvider); - $scope.$$postDigest(() => { const domNode = document.getElementById(reactRootNodeId); @@ -66,12 +63,10 @@ routes.when('/management/spaces/create', { $scope: any, $http: any, chrome: any, - Private: any, spacesNavState: SpacesNavState, - spaceSelectorURL: string + spaceSelectorURL: string, + userProfile: UserProfile ) { - const userProfile = Private(UserProfileProvider); - $scope.$$postDigest(() => { const domNode = document.getElementById(reactRootNodeId); @@ -111,10 +106,9 @@ routes.when('/management/spaces/edit/:spaceId', { chrome: any, Private: any, spacesNavState: SpacesNavState, - spaceSelectorURL: string + spaceSelectorURL: string, + userProfile: UserProfile ) { - const userProfile = Private(UserProfileProvider); - $scope.$$postDigest(() => { const domNode = document.getElementById(reactRootNodeId); diff --git a/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx b/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx index 6a840680104aa..a117662f7eaf7 100644 --- a/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx +++ b/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx @@ -24,7 +24,7 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import { toastNotifications } from 'ui/notify'; import { SpacesNavState } from 'plugins/spaces/views/nav_control'; -import { UserProfile } from '../../../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../../../xpack_main/common/user_profile'; import { isReservedSpace } from '../../../../common'; import { Space } from '../../../../common/model/space'; import { SpaceAvatar } from '../../../components'; diff --git a/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_pages.test.tsx b/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_pages.test.tsx index 7bf41e6da33a8..41aba6bc3afe4 100644 --- a/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_pages.test.tsx +++ b/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_pages.test.tsx @@ -5,16 +5,11 @@ */ import React from 'react'; import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; -import { UserProfileProvider } from '../../../../../xpack_main/public/services/user_profile'; import { SpaceAvatar } from '../../../components'; import { SpacesManager } from '../../../lib'; import { SpacesNavState } from '../../nav_control'; import { SpacesGridPage } from './spaces_grid_page'; -const buildUserProfile = (canManageSpaces: boolean) => { - return UserProfileProvider({ manageSpaces: canManageSpaces }); -}; - const spaces = [ { id: 'default', @@ -58,7 +53,6 @@ describe('SpacesGridPage', () => { ) @@ -70,7 +64,6 @@ describe('SpacesGridPage', () => { ); diff --git a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx index d8aca1a9a4833..864d15bc43d4b 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx @@ -6,17 +6,13 @@ import { shallow } from 'enzyme'; import React from 'react'; +import { UserProfile } from '../../../../../xpack_main/common/user_profile'; import { SpacesDescription } from './spaces_description'; describe('SpacesDescription', () => { it('renders without crashing', () => { expect( - shallow( - true }} - onManageSpacesClick={jest.fn()} - /> - ) + shallow() ).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.tsx b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.tsx index f851200fefdf6..3a60bfe4c453b 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.tsx @@ -6,7 +6,7 @@ import { EuiContextMenuPanel, EuiText } from '@elastic/eui'; import React, { SFC } from 'react'; -import { UserProfile } from '../../../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../../../xpack_main/common/user_profile'; import { ManageSpacesButton } from '../../../components'; import { SPACES_FEATURE_DESCRIPTION } from '../../../lib/constants'; diff --git a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_menu.tsx b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_menu.tsx index 322af5670cd64..42685556bf243 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_menu.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_menu.tsx @@ -7,7 +7,7 @@ import { EuiContextMenuItem, EuiContextMenuPanel, EuiFieldSearch, EuiText } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component } from 'react'; -import { UserProfile } from '../../../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../../../xpack_main/common/user_profile'; import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../../../common/constants'; import { Space } from '../../../../common/model/space'; import { ManageSpacesButton, SpaceAvatar } from '../../../components'; diff --git a/x-pack/plugins/spaces/public/views/nav_control/nav_control.tsx b/x-pack/plugins/spaces/public/views/nav_control/nav_control.tsx index 1c03e1a85db95..0c2dff2cbc71d 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/nav_control.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/nav_control.tsx @@ -11,10 +11,9 @@ import template from 'plugins/spaces/views/nav_control/nav_control.html'; import { NavControlPopover } from 'plugins/spaces/views/nav_control/nav_control_popover'; // @ts-ignore import { PathProvider } from 'plugins/xpack_main/services/path'; -import { UserProfileProvider } from 'plugins/xpack_main/services/user_profile'; import React from 'react'; -import ReactDOM from 'react-dom'; import { render, unmountComponentAtNode } from 'react-dom'; +import ReactDOM from 'react-dom'; import { NavControlSide } from 'ui/chrome/directives/header_global_nav'; // @ts-ignore import { uiModules } from 'ui/modules'; @@ -22,6 +21,7 @@ import { uiModules } from 'ui/modules'; import { chromeHeaderNavControlsRegistry } from 'ui/registry/chrome_header_nav_controls'; // @ts-ignore import { chromeNavControlsRegistry } from 'ui/registry/chrome_nav_controls'; +import { UserProfile } from '../../../../xpack_main/common/user_profile'; import { Space } from '../../../common/model/space'; import { SpacesGlobalNavButton } from './components/spaces_global_nav_button'; import { SpacesHeaderNavButton } from './components/spaces_header_nav_button'; @@ -46,7 +46,6 @@ let spacesManager: SpacesManager; module.controller( 'spacesNavController', ($scope: any, $http: any, chrome: any, Private: any, activeSpace: any) => { - const userProfile = Private(UserProfileProvider); const pathProvider = Private(PathProvider); const domNode = document.getElementById(`spacesNavReactRoot`); @@ -62,7 +61,6 @@ module.controller( , @@ -96,12 +94,11 @@ module.service('spacesNavState', (activeSpace: any) => { }); chromeHeaderNavControlsRegistry.register( - ($http: any, chrome: any, Private: any, activeSpace: any) => ({ + ($http: any, chrome: any, Private: any, activeSpace: any, userProfile: UserProfile) => ({ name: 'spaces', order: 1000, side: NavControlSide.Left, render(el: HTMLElement) { - const userProfile = Private(UserProfileProvider); const pathProvider = Private(PathProvider); if (pathProvider.isUnauthenticated()) { @@ -116,7 +113,6 @@ chromeHeaderNavControlsRegistry.register( , diff --git a/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.test.tsx b/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.test.tsx index a1088ba91801a..14b843f6eb9c8 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.test.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.test.tsx @@ -6,6 +6,7 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; +import { UserProfile } from '../../../../xpack_main/common/user_profile'; import { SpaceAvatar } from '../../components'; import { SpacesManager } from '../../lib/spaces_manager'; import { SpacesGlobalNavButton } from './components/spaces_global_nav_button'; @@ -52,7 +53,7 @@ describe('NavControlPopover', () => { true }} + userProfile={new UserProfile()} anchorPosition={'downRight'} buttonClass={SpacesGlobalNavButton} /> @@ -74,7 +75,7 @@ describe('NavControlPopover', () => { true }} + userProfile={new UserProfile()} anchorPosition={'rightCenter'} buttonClass={SpacesGlobalNavButton} /> diff --git a/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.tsx b/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.tsx index b80ea65053b69..c64277e7846d7 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.tsx @@ -7,7 +7,7 @@ import { EuiAvatar, EuiPopover, PopoverAnchorPosition } from '@elastic/eui'; import { I18nProvider } from '@kbn/i18n/react'; import React, { Component, ComponentClass } from 'react'; -import { UserProfile } from '../../../../xpack_main/public/services/user_profile'; +import { UserProfile } from '../../../../xpack_main/common/user_profile'; import { Space } from '../../../common/model/space'; import { SpaceAvatar } from '../../components'; import { SpacesManager } from '../../lib/spaces_manager'; diff --git a/x-pack/plugins/xpack_main/common/index.ts b/x-pack/plugins/xpack_main/common/index.ts new file mode 100644 index 0000000000000..23c27385776c2 --- /dev/null +++ b/x-pack/plugins/xpack_main/common/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { Capabilities, UserProfile } from './user_profile'; diff --git a/x-pack/plugins/xpack_main/common/user_profile/capabilities.ts b/x-pack/plugins/xpack_main/common/user_profile/capabilities.ts new file mode 100644 index 0000000000000..c1e893d5a1bc1 --- /dev/null +++ b/x-pack/plugins/xpack_main/common/user_profile/capabilities.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export interface Capabilities { + [capability: string]: boolean; +} diff --git a/x-pack/plugins/xpack_main/common/user_profile/index.ts b/x-pack/plugins/xpack_main/common/user_profile/index.ts new file mode 100644 index 0000000000000..ef5c9c037ebae --- /dev/null +++ b/x-pack/plugins/xpack_main/common/user_profile/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +export { Capabilities } from './capabilities'; +export { UserProfile } from './user_profile'; diff --git a/x-pack/plugins/xpack_main/public/services/user_profile.test.ts b/x-pack/plugins/xpack_main/common/user_profile/user_profile.test.ts similarity index 81% rename from x-pack/plugins/xpack_main/public/services/user_profile.test.ts rename to x-pack/plugins/xpack_main/common/user_profile/user_profile.test.ts index 45507ab604284..4ef1f1d3b577f 100644 --- a/x-pack/plugins/xpack_main/public/services/user_profile.test.ts +++ b/x-pack/plugins/xpack_main/common/user_profile/user_profile.test.ts @@ -3,39 +3,31 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { UserProfileProvider } from './user_profile'; +import { UserProfile } from './user_profile'; describe('UserProfile', () => { it('should return true when the specified capability is enabled', () => { const capabilities = { test1: true, test2: false, }; - - const userProfile = UserProfileProvider(capabilities); - + const userProfile = new UserProfile(capabilities); expect(userProfile.hasCapability('test1')).toEqual(true); }); - it('should return false when the specified capability is disabled', () => { const capabilities = { test1: true, test2: false, }; - - const userProfile = UserProfileProvider(capabilities); - + const userProfile = new UserProfile(capabilities); expect(userProfile.hasCapability('test2')).toEqual(false); }); - it('should return the default value when the specified capability is not defined', () => { const capabilities = { test1: true, test2: false, }; - - const userProfile = UserProfileProvider(capabilities); - + const userProfile = new UserProfile(capabilities); expect(userProfile.hasCapability('test3')).toEqual(true); expect(userProfile.hasCapability('test3', false)).toEqual(false); }); diff --git a/x-pack/plugins/xpack_main/common/user_profile/user_profile.ts b/x-pack/plugins/xpack_main/common/user_profile/user_profile.ts new file mode 100644 index 0000000000000..7d657b0f3ccf9 --- /dev/null +++ b/x-pack/plugins/xpack_main/common/user_profile/user_profile.ts @@ -0,0 +1,38 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Capabilities } from './capabilities'; + +export class UserProfile { + private capabilities: Capabilities; + constructor(profileData: Capabilities = {}) { + this.capabilities = { + ...profileData, + }; + } + + public hasCapability(capability: string, defaultValue: boolean = true): boolean { + return capability in this.capabilities ? this.capabilities[capability] : defaultValue; + } + + public canAccessFeature(feature: string, defaultValue: boolean = true): boolean { + return this.hasCapability(`ui:${feature}/read`, defaultValue); + } + + public canReadSavedObject(savedObjectType: string, defaultValue: boolean = true): boolean { + return this.hasCapability(`saved_objects/${savedObjectType}/get`, defaultValue); + } + + public canWriteSavedObject(savedObjectType: string, defaultValue: boolean = true): boolean { + return this.hasCapability(`saved_objects/${savedObjectType}/create`, defaultValue); + } + + public toJSON() { + return { + ...this.capabilities, + }; + } +} diff --git a/x-pack/plugins/xpack_main/index.js b/x-pack/plugins/xpack_main/index.js index 28ef9a49f165d..b04d3d1deeb8d 100644 --- a/x-pack/plugins/xpack_main/index.js +++ b/x-pack/plugins/xpack_main/index.js @@ -22,6 +22,7 @@ import { CONFIG_TELEMETRY_DESC, } from './common/constants'; import { settingsRoute } from './server/routes/api/v1/settings'; +import { userProfileMixin } from './server/lib/user_profile'; import mappings from './mappings.json'; export { callClusterFactory } from './server/lib/call_cluster_factory'; @@ -95,13 +96,15 @@ export const xpackMain = (kibana) => { telemetryOptedIn: null, activeSpace: null, spacesEnabled: config.get('xpack.spaces.enabled'), - userProfile: {}, + userProfileData: {}, }; }, hacks: [ 'plugins/xpack_main/hacks/check_xpack_info_change', 'plugins/xpack_main/hacks/telemetry_opt_in', 'plugins/xpack_main/hacks/telemetry_trigger', + 'plugins/xpack_main/hacks/user_profile', + 'plugins/xpack_main/hacks/user_profile_config_decorators', ], replaceInjectedVars, __webpackPluginProvider__(webpack) { @@ -121,6 +124,8 @@ export const xpackMain = (kibana) => { setupXPackMain(server); + userProfileMixin(this.kbnServer, server); + // register routes xpackInfoRoute(server); telemetryRoute(server); diff --git a/x-pack/plugins/xpack_main/public/hacks/user_profile.ts b/x-pack/plugins/xpack_main/public/hacks/user_profile.ts new file mode 100644 index 0000000000000..91cdcb419e545 --- /dev/null +++ b/x-pack/plugins/xpack_main/public/hacks/user_profile.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import chrome from 'ui/chrome'; +// @ts-ignore +import { uiModules } from 'ui/modules'; +import { UserProfile } from '../../common'; + +uiModules.get('userProfile').provider('userProfile', function userProfileProvider() { + // @ts-ignore + this.$get = () => { + return new UserProfile(chrome.getInjected('userProfileData')); + }; +}); diff --git a/x-pack/plugins/xpack_main/public/hacks/user_profile_config_decorators.js b/x-pack/plugins/xpack_main/public/hacks/user_profile_config_decorators.js new file mode 100644 index 0000000000000..851a3a2e18950 --- /dev/null +++ b/x-pack/plugins/xpack_main/public/hacks/user_profile_config_decorators.js @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { uiModules } from 'ui/modules'; + +uiModules.get('kibana') + .config(($provide, $injector) => { + if ($injector.has('dashboardConfig')) { + $provide.decorator('dashboardConfig', function ($delegate, userProfile) { + return { + getHideWriteControls() { + if (!userProfile.canWriteSavedObject('dashboard')) { + return true; + } + + return $delegate.getHideWriteControls(); + } + }; + }); + } + + if ($injector.has('discoverConfig')) { + $provide.decorator('discoverConfig', function ($delegate, userProfile) { + return { + getHideWriteControls() { + if (!userProfile.canWriteSavedObject('search')) { + return true; + } + + return $delegate.getHideWriteControls(); + } + }; + }); + } + + if ($injector.has('chromeConfig')) { + $provide.decorator('chromeConfig', function ($delegate, userProfile) { + return { + shouldHideNavLink(navLink) { + if (!userProfile.canAccessFeature(navLink.id)) { + return true; + } + + return $delegate.shouldHideNavLink(navLink); + } + }; + }); + } + }); diff --git a/x-pack/plugins/xpack_main/public/services/user_profile.ts b/x-pack/plugins/xpack_main/public/services/user_profile.ts deleted file mode 100644 index 09b257aa80e3f..0000000000000 --- a/x-pack/plugins/xpack_main/public/services/user_profile.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -interface Capabilities { - [capability: string]: boolean; -} - -export interface UserProfile { - hasCapability: (capability: string) => boolean; -} - -export function UserProfileProvider(userProfile: Capabilities) { - class UserProfileClass implements UserProfile { - private capabilities: Capabilities; - - constructor(profileData: Capabilities = {}) { - this.capabilities = { - ...profileData, - }; - } - - public hasCapability(capability: string, defaultValue: boolean = true): boolean { - return capability in this.capabilities ? this.capabilities[capability] : defaultValue; - } - } - - return new UserProfileClass(userProfile); -} diff --git a/x-pack/plugins/xpack_main/server/lib/__tests__/replace_injected_vars.js b/x-pack/plugins/xpack_main/server/lib/__tests__/replace_injected_vars.js index 863f07725ad29..461d6a6f93e7b 100644 --- a/x-pack/plugins/xpack_main/server/lib/__tests__/replace_injected_vars.js +++ b/x-pack/plugins/xpack_main/server/lib/__tests__/replace_injected_vars.js @@ -19,6 +19,9 @@ const buildRequest = (telemetryOptedIn = null, path = '/app/kibana') => { return { path, + getUserProfile: async () => ({ + toJSON: () => ({}) + }), getSavedObjectsClient: () => { return { get, @@ -47,7 +50,7 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfile: {}, + userProfileData: {} }); sinon.assert.calledOnce(server.plugins.security.isAuthenticated); @@ -67,7 +70,7 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfile: {}, + userProfileData: {} }); }); @@ -84,7 +87,7 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfile: {}, + userProfileData: {} }); }); @@ -101,7 +104,7 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfile: {}, + userProfileData: {} }); }); @@ -118,7 +121,7 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfile: {}, + userProfileData: {} }); }); @@ -135,7 +138,7 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfile: {}, + userProfileData: {} }); }); @@ -171,7 +174,7 @@ describe('replaceInjectedVars uiExport', () => { a: 1, telemetryOptedIn: null, xpackInitialInfo: undefined, - userProfile: {}, + userProfileData: {}, }); }); diff --git a/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts b/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts new file mode 100644 index 0000000000000..554f1115c2ee9 --- /dev/null +++ b/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { IconType } from '@elastic/eui'; +import _ from 'lodash'; +export interface Feature { + id: string; + name: string; + type: 'app' | 'subFeature'; + validLicenses?: Array<'basic' | 'gold' | 'platinum'>; + icon?: IconType; + description?: string; +} + +const features: Record = {}; + +export function registerFeature(feature: Feature) { + if (feature.id in features) { + throw new Error(`Feature with id ${feature.id} is already registered.`); + } + + features[feature.id] = feature; +} + +export function getFeatures(): Feature[] { + return _.cloneDeep(Object.values(features)); +} diff --git a/x-pack/plugins/xpack_main/server/lib/feature_registry/index.ts b/x-pack/plugins/xpack_main/server/lib/feature_registry/index.ts new file mode 100644 index 0000000000000..4a5d2db9f88ba --- /dev/null +++ b/x-pack/plugins/xpack_main/server/lib/feature_registry/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { registerFeature, getFeatures } from './feature_registry'; diff --git a/x-pack/plugins/xpack_main/server/lib/feature_registry/register_oss_features.ts b/x-pack/plugins/xpack_main/server/lib/feature_registry/register_oss_features.ts new file mode 100644 index 0000000000000..a64e130253f9f --- /dev/null +++ b/x-pack/plugins/xpack_main/server/lib/feature_registry/register_oss_features.ts @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Feature, registerFeature } from './feature_registry'; + +const kibanaFeatures: Feature[] = [ + { + id: 'kibana:discover', + name: 'Discover', + type: 'app', + icon: 'discoverApp', + }, + { + id: 'kibana:visualize', + name: 'Visualize', + type: 'app', + icon: 'visualizeApp', + }, + { + id: 'kibana:dashboard', + name: 'Dashboard', + type: 'app', + icon: 'dashboardApp', + }, + { + id: 'kibana:dev_tools', + name: 'Dev Tools', + type: 'app', + icon: 'devToolsApp', + }, + { + id: 'kibana:management', + name: 'Management', + type: 'app', + icon: 'managementApp', + }, +]; + +const timelionFeatures: Feature[] = [ + { + id: 'timelion', + name: 'Timelion', + type: 'app', + icon: 'timelionApp', + }, +]; + +export function registerOssFeatures() { + kibanaFeatures.forEach(registerFeature); + timelionFeatures.forEach(registerFeature); +} diff --git a/x-pack/plugins/xpack_main/server/lib/replace_injected_vars.js b/x-pack/plugins/xpack_main/server/lib/replace_injected_vars.js index b8362c6549e16..909b151983cdc 100644 --- a/x-pack/plugins/xpack_main/server/lib/replace_injected_vars.js +++ b/x-pack/plugins/xpack_main/server/lib/replace_injected_vars.js @@ -5,7 +5,6 @@ */ import { getTelemetryOptIn } from "./get_telemetry_opt_in"; -import { buildUserProfile } from './user_profile_registry'; export async function replaceInjectedVars(originalInjectedVars, request, server) { const xpackInfo = server.plugins.xpack_main.info; @@ -13,7 +12,7 @@ export async function replaceInjectedVars(originalInjectedVars, request, server) ...originalInjectedVars, telemetryOptedIn: await getTelemetryOptIn(request), xpackInitialInfo: xpackInfo.isAvailable() ? xpackInfo.toJSON() : undefined, - userProfile: await buildUserProfile(request), + userProfileData: (await request.getUserProfile()).toJSON(), }); // security feature is disabled diff --git a/x-pack/plugins/xpack_main/server/lib/setup_xpack_main.js b/x-pack/plugins/xpack_main/server/lib/setup_xpack_main.js index 125e481c384a1..4ac18a0d7b8e2 100644 --- a/x-pack/plugins/xpack_main/server/lib/setup_xpack_main.js +++ b/x-pack/plugins/xpack_main/server/lib/setup_xpack_main.js @@ -6,6 +6,7 @@ import { injectXPackInfoSignature } from './inject_xpack_info_signature'; import { XPackInfo } from './xpack_info'; +import { registerFeature } from './feature_registry'; /** * Setup the X-Pack Main plugin. This is fired every time that the Elasticsearch plugin becomes Green. @@ -22,6 +23,7 @@ export function setupXPackMain(server) { server.expose('info', info); server.expose('createXPackInfo', (options) => new XPackInfo(server, options)); + server.expose('registerFeature', registerFeature); server.ext('onPreResponse', (request, h) => injectXPackInfoSignature(info, request, h)); const setPluginStatus = () => { diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile/index.ts b/x-pack/plugins/xpack_main/server/lib/user_profile/index.ts new file mode 100644 index 0000000000000..73880d8c0e81b --- /dev/null +++ b/x-pack/plugins/xpack_main/server/lib/user_profile/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { userProfileMixin } from './user_profile_mixin'; +export { registerUserProfileCapabilityDecorator } from './user_profile_capability_registry'; diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile/priority_collection.ts b/x-pack/plugins/xpack_main/server/lib/user_profile/priority_collection.ts new file mode 100644 index 0000000000000..2bb4337f04525 --- /dev/null +++ b/x-pack/plugins/xpack_main/server/lib/user_profile/priority_collection.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +interface PriorityCollectionEntry { + priority: number; + value: T; +} + +export class PriorityCollection { + private readonly array: Array> = []; + + public add(priority: number, value: T) { + const foundIndex = this.array.findIndex(current => { + if (priority === current.priority) { + throw new Error('Already have entry with this priority'); + } + + return priority < current.priority; + }); + + const spliceIndex = foundIndex === -1 ? this.array.length : foundIndex; + this.array.splice(spliceIndex, 0, { priority, value }); + } + + public toPrioritizedArray(): T[] { + return this.array.map(entry => entry.value); + } +} diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_capability_registry.ts b/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_capability_registry.ts new file mode 100644 index 0000000000000..ec07ec66d7d7f --- /dev/null +++ b/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_capability_registry.ts @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Capabilities } from 'x-pack/plugins/xpack_main/common'; +import { PriorityCollection } from './priority_collection'; + +export type CapabilityDecorator = ( + server: Record, + request: Record, + capabilities: Capabilities +) => Promise; + +const decorators: PriorityCollection = new PriorityCollection(); + +export function registerUserProfileCapabilityDecorator( + priority: number, + decorator: CapabilityDecorator +) { + decorators.add(priority, decorator); +} + +export async function buildUserCapabilities( + server: Record, + request: Record +): Promise { + const decoratedCapabilities = await executeDecorators(server, request, {}); + + return decoratedCapabilities; +} + +async function executeDecorators( + server: Record, + request: Record, + capabilities: Capabilities +): Promise { + return await asyncForEach(decorators.toPrioritizedArray(), server, request, capabilities); +} + +async function asyncForEach( + array: CapabilityDecorator[], + server: Record, + request: Record, + initialCapabilities: Capabilities +) { + let capabilities = initialCapabilities; + + for (const callback of array) { + capabilities = await callback(server, request, capabilities); + } + + return capabilities; +} diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_mixin.ts b/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_mixin.ts new file mode 100644 index 0000000000000..b0aadb201f470 --- /dev/null +++ b/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_mixin.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { UserProfile } from '../../../common'; +import { buildUserCapabilities } from './user_profile_capability_registry'; + +export function userProfileMixin(kbnServer: Record, server: Record) { + const profileCache = new WeakMap(); + + server.decorate('request', 'getUserProfile', async function getUserProfile() { + // @ts-ignore + const request: Record = this; + + if (profileCache.has(request)) { + return profileCache.get(request); + } + + const userCapabilities = await buildUserCapabilities(server, request); + const profile = new UserProfile(userCapabilities); + + profileCache.set(request, profile); + + return profile; + }); +} diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile_registry.test.ts b/x-pack/plugins/xpack_main/server/lib/user_profile_registry.test.ts deleted file mode 100644 index 22a0b58b60c2a..0000000000000 --- a/x-pack/plugins/xpack_main/server/lib/user_profile_registry.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { - buildUserProfile, - registerUserProfileCapabilityFactory, - removeAllFactories, -} from './user_profile_registry'; - -describe('UserProfileRegistry', () => { - beforeEach(() => removeAllFactories()); - - it('should produce an empty user profile', async () => { - expect(await buildUserProfile(null)).toEqual({}); - }); - - it('should accumulate the results of all registered factories', async () => { - registerUserProfileCapabilityFactory(async () => ({ - foo: true, - bar: false, - })); - - registerUserProfileCapabilityFactory(async () => ({ - anotherCapability: true, - })); - - expect(await buildUserProfile(null)).toEqual({ - foo: true, - bar: false, - anotherCapability: true, - }); - }); -}); diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile_registry.ts b/x-pack/plugins/xpack_main/server/lib/user_profile_registry.ts deleted file mode 100644 index 417341165fde4..0000000000000 --- a/x-pack/plugins/xpack_main/server/lib/user_profile_registry.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export type CapabilityFactory = (request: any) => Promise<{ [capability: string]: boolean }>; - -let factories: CapabilityFactory[] = []; - -export function removeAllFactories() { - factories = []; -} - -export function registerUserProfileCapabilityFactory(factory: CapabilityFactory) { - factories.push(factory); -} - -export async function buildUserProfile(request: any) { - const factoryPromises = factories.map(async factory => ({ - ...(await factory(request)), - })); - - const factoryResults = await Promise.all(factoryPromises); - - return factoryResults.reduce((acc, capabilities) => { - return { - ...acc, - ...capabilities, - }; - }, {}); -} From aae0858487f8a16ecc1fc460588424d81baefc0b Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Wed, 14 Nov 2018 11:54:49 -0500 Subject: [PATCH 93/95] Introducing uiCapabilities, removing config providers & user profile (#25387) ## Summary Introduces the concept of "UI Capabilities", which allows Kibana applications to declare capabilities via the `uiCapabilities` injected var, and then use them client-side via the `ui/capabilities` module to inform their rendering decisions. --- .../injected_metadata_service.ts | 2 +- .../frozen_object_mutation/index.ts | 0 .../frozen_object_mutation/tsconfig.json | 0 .../deep_freeze.test.ts | 0 .../deep_freeze.ts | 0 src/core_plugins/kibana/index.js | 18 ++++++ .../public/dashboard/dashboard_config.js | 4 +- .../public/discover/controllers/discover.js | 9 +-- .../kibana/public/discover/index.js | 1 - src/core_plugins/timelion/index.js | 13 ++++- .../public/capabilities/index.ts} | 14 +---- .../capabilities/ui_capabilities.test.ts | 50 +++++++++++++++++ .../ui_capabilities.ts} | 21 +++---- src/ui/public/chrome/chrome.js | 2 - .../global_nav/app_switcher/app_switcher.js | 6 +- x-pack/plugins/__mocks__/ui/capabilities.ts | 27 +++++++++ x-pack/plugins/__mocks__/ui/chrome.js | 4 ++ x-pack/plugins/security/index.js | 11 +--- .../edit_role/components/edit_role_page.tsx | 6 +- .../kibana_privileges.test.tsx.snap | 13 ++++- .../space_aware_privilege_form.test.tsx.snap | 5 -- .../kibana/impacted_spaces_flyout.test.tsx | 1 - .../kibana/impacted_spaces_flyout.tsx | 4 +- .../kibana/kibana_privileges.test.tsx | 8 ++- .../privileges/kibana/kibana_privileges.tsx | 8 +-- .../space_aware_privilege_form.test.tsx | 17 +++--- .../kibana/space_aware_privilege_form.tsx | 14 ++--- .../views/management/edit_role/index.js | 5 +- .../server/lib/capability_decorator.ts | 4 +- x-pack/plugins/spaces/index.ts | 20 ++++++- .../components/manage_spaces_button.test.tsx | 15 +++++ .../components/manage_spaces_button.tsx | 5 +- .../secure_space_message.test.tsx.snap | 2 +- .../secure_space_message.test.tsx | 18 +++--- .../secure_space_message.tsx | 4 +- .../edit_space/manage_space_page.test.tsx | 1 - .../edit_space/manage_space_page.tsx | 9 ++- .../public/views/management/page_routes.tsx | 23 ++------ .../spaces_grid_pages.test.tsx.snap | 10 +--- .../spaces_grid/spaces_grid_page.tsx | 8 +-- .../nav_control_popover.test.tsx.snap | 5 -- .../spaces_description.test.tsx.snap | 5 -- .../components/spaces_description.test.tsx | 5 +- .../components/spaces_description.tsx | 3 - .../nav_control/components/spaces_menu.tsx | 3 - .../public/views/nav_control/nav_control.tsx | 3 +- .../nav_control/nav_control_popover.test.tsx | 3 - .../views/nav_control/nav_control_popover.tsx | 10 +--- .../lib/toggle_ui_capabilities.test.ts} | 6 +- .../server/lib/toggle_ui_capabilities.ts | 37 +++++++++++++ x-pack/plugins/xpack_main/common/index.ts | 7 --- .../common/user_profile/capabilities.ts | 9 --- .../xpack_main/common/user_profile/index.ts | 7 --- .../common/user_profile/user_profile.test.ts | 34 ------------ .../common/user_profile/user_profile.ts | 38 ------------- x-pack/plugins/xpack_main/index.js | 6 -- .../xpack_main/public/hacks/user_profile.ts | 17 ------ .../hacks/user_profile_config_decorators.js | 52 ------------------ .../lib/__tests__/replace_injected_vars.js | 10 ---- .../server/lib/replace_injected_vars.js | 1 - .../lib/user_profile/priority_collection.ts | 31 ----------- .../user_profile_capability_registry.ts | 55 ------------------- .../lib/user_profile/user_profile_mixin.ts | 28 ---------- 63 files changed, 286 insertions(+), 471 deletions(-) rename src/core/public/{injected_metadata => utils}/__fixtures__/frozen_object_mutation/index.ts (100%) rename src/core/public/{injected_metadata => utils}/__fixtures__/frozen_object_mutation/tsconfig.json (100%) rename src/core/public/{injected_metadata => utils}/deep_freeze.test.ts (100%) rename src/core/public/{injected_metadata => utils}/deep_freeze.ts (100%) rename src/{core_plugins/kibana/public/discover/discover_config.js => ui/public/capabilities/index.ts} (76%) create mode 100644 src/ui/public/capabilities/ui_capabilities.test.ts rename src/ui/public/{chrome/api/config.js => capabilities/ui_capabilities.ts} (72%) create mode 100644 x-pack/plugins/__mocks__/ui/capabilities.ts rename x-pack/plugins/{xpack_main/server/lib/user_profile/index.ts => spaces/server/lib/toggle_ui_capabilities.test.ts} (60%) create mode 100644 x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts delete mode 100644 x-pack/plugins/xpack_main/common/index.ts delete mode 100644 x-pack/plugins/xpack_main/common/user_profile/capabilities.ts delete mode 100644 x-pack/plugins/xpack_main/common/user_profile/index.ts delete mode 100644 x-pack/plugins/xpack_main/common/user_profile/user_profile.test.ts delete mode 100644 x-pack/plugins/xpack_main/common/user_profile/user_profile.ts delete mode 100644 x-pack/plugins/xpack_main/public/hacks/user_profile.ts delete mode 100644 x-pack/plugins/xpack_main/public/hacks/user_profile_config_decorators.js delete mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile/priority_collection.ts delete mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_capability_registry.ts delete mode 100644 x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_mixin.ts diff --git a/src/core/public/injected_metadata/injected_metadata_service.ts b/src/core/public/injected_metadata/injected_metadata_service.ts index ed50067db9a02..6695de989aae1 100644 --- a/src/core/public/injected_metadata/injected_metadata_service.ts +++ b/src/core/public/injected_metadata/injected_metadata_service.ts @@ -19,7 +19,7 @@ import { get } from 'lodash'; import { UiSettingsState } from '../ui_settings'; -import { deepFreeze } from './deep_freeze'; +import { deepFreeze } from '../utils/deep_freeze'; export interface InjectedMetadataParams { injectedMetadata: { diff --git a/src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/index.ts b/src/core/public/utils/__fixtures__/frozen_object_mutation/index.ts similarity index 100% rename from src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/index.ts rename to src/core/public/utils/__fixtures__/frozen_object_mutation/index.ts diff --git a/src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/tsconfig.json b/src/core/public/utils/__fixtures__/frozen_object_mutation/tsconfig.json similarity index 100% rename from src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/tsconfig.json rename to src/core/public/utils/__fixtures__/frozen_object_mutation/tsconfig.json diff --git a/src/core/public/injected_metadata/deep_freeze.test.ts b/src/core/public/utils/deep_freeze.test.ts similarity index 100% rename from src/core/public/injected_metadata/deep_freeze.test.ts rename to src/core/public/utils/deep_freeze.test.ts diff --git a/src/core/public/injected_metadata/deep_freeze.ts b/src/core/public/utils/deep_freeze.ts similarity index 100% rename from src/core/public/injected_metadata/deep_freeze.ts rename to src/core/public/utils/deep_freeze.ts diff --git a/src/core_plugins/kibana/index.js b/src/core_plugins/kibana/index.js index 7f9db00078314..984c31c5a0f91 100644 --- a/src/core_plugins/kibana/index.js +++ b/src/core_plugins/kibana/index.js @@ -131,6 +131,24 @@ export default function (kibana) { return { kbnIndex: options.index, kbnBaseUrl, + uiCapabilities: { + navLinks: { + 'kibana:discover': true, + 'kibana:visualize': true, + 'kibana:dashboard': true, + 'kibana:dev_tools': true, + 'kibana:management': true, + }, + discover: { + showWriteControls: true + }, + visualize: { + showWriteControls: true + }, + dashboard: { + showWriteControls: true + }, + } }; }, diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_config.js b/src/core_plugins/kibana/public/dashboard/dashboard_config.js index 8267e7626fb91..7179f810db084 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_config.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard_config.js @@ -18,9 +18,11 @@ */ import { uiModules } from 'ui/modules'; +import { uiCapabilities } from 'ui/capabilities'; + uiModules.get('kibana') .provider('dashboardConfig', () => { - let hideWriteControls = false; + let hideWriteControls = !uiCapabilities.dashboard.showWriteControls; return { /** diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 14793352de456..697fe149c7af2 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -157,6 +157,7 @@ function discoverController( kbnUrl, localStorage, i18n, + uiCapabilities, ) { const Vis = Private(VisProvider); const docTitle = Private(DocTitleProvider); @@ -298,12 +299,12 @@ function discoverController( } }; - const hideSave = false; + const { showWriteControls } = uiCapabilities.discover; - if (hideSave) { - return [newSearch, openSearch, shareSearch, inspectSearch]; + if (showWriteControls) { + return [newSearch, saveSearch, openSearch, shareSearch, inspectSearch]; } - return [newSearch, saveSearch, openSearch, shareSearch, inspectSearch]; + return [newSearch, openSearch, shareSearch, inspectSearch]; }; $scope.topNavMenu = getTopNavLinks(); diff --git a/src/core_plugins/kibana/public/discover/index.js b/src/core_plugins/kibana/public/discover/index.js index 45d62fed5a47a..5b23bbd4c01c6 100644 --- a/src/core_plugins/kibana/public/discover/index.js +++ b/src/core_plugins/kibana/public/discover/index.js @@ -17,7 +17,6 @@ * under the License. */ -import './discover_config'; import './saved_searches/saved_searches'; import './directives'; import 'ui/collapsible_sidebar'; diff --git a/src/core_plugins/timelion/index.js b/src/core_plugins/timelion/index.js index 3a1284eaacf90..e949223348aaf 100644 --- a/src/core_plugins/timelion/index.js +++ b/src/core_plugins/timelion/index.js @@ -41,7 +41,18 @@ export default function (kibana) { 'plugins/timelion/register_feature' ], mappings: require('./mappings.json'), - + injectDefaultVars() { + return { + uiCapabilities: { + navLinks: { + timelion: true + }, + timelion: { + showWriteControls: true, + } + } + }; + }, uiSettingDefaults: { 'timelion:showTutorial': { name: 'Show tutorial', diff --git a/src/core_plugins/kibana/public/discover/discover_config.js b/src/ui/public/capabilities/index.ts similarity index 76% rename from src/core_plugins/kibana/public/discover/discover_config.js rename to src/ui/public/capabilities/index.ts index d98a309370481..6723d18f40ce9 100644 --- a/src/core_plugins/kibana/public/discover/discover_config.js +++ b/src/ui/public/capabilities/index.ts @@ -16,17 +16,5 @@ * specific language governing permissions and limitations * under the License. */ -import { uiModules } from 'ui/modules'; -uiModules.get('kibana') - .provider('discoverConfig', () => { - return { - $get() { - return { - getHideWriteControls() { - return false; - } - }; - } - }; - }); +export { uiCapabilities, UICapabilities } from './ui_capabilities'; diff --git a/src/ui/public/capabilities/ui_capabilities.test.ts b/src/ui/public/capabilities/ui_capabilities.test.ts new file mode 100644 index 0000000000000..5f8989a378779 --- /dev/null +++ b/src/ui/public/capabilities/ui_capabilities.test.ts @@ -0,0 +1,50 @@ +/* + * 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. + */ + +jest.mock( + 'ui/chrome', + () => ({ + getInjected: (key: string) => { + if (key !== 'uiCapabilities') { + throw new Error(`Unexpected key for test: ${key}`); + } + + return { + navLinks: {}, + app1: { + feature1: true, + feature2: false, + }, + app2: { + feature1: true, + feature3: true, + }, + }; + }, + }), + { virtual: true } +); + +import { uiCapabilities } from './ui_capabilities'; + +describe('uiCapabilities', () => { + it('allows a nested property to be accessed', () => { + expect(uiCapabilities.app1.feature2).toEqual(false); + }); +}); diff --git a/src/ui/public/chrome/api/config.js b/src/ui/public/capabilities/ui_capabilities.ts similarity index 72% rename from src/ui/public/chrome/api/config.js rename to src/ui/public/capabilities/ui_capabilities.ts index fe12384c58a52..7b16bb7af08db 100644 --- a/src/ui/public/chrome/api/config.js +++ b/src/ui/public/capabilities/ui_capabilities.ts @@ -16,19 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -import { uiModules } from '../../modules'; +import chrome from 'ui/chrome'; +import { deepFreeze } from '../../../core/public/utils/deep_freeze'; -export function initConfig() { - uiModules.get('kibana') - .provider('chromeConfig', () => { - return { - $get() { - return { - shouldHideNavLink() { - return false; - } - }; - } - }; - }); +export interface UICapabilities { + navLinks: Record; + [key: string]: Record; } + +export const uiCapabilities: UICapabilities = deepFreeze(chrome.getInjected('uiCapabilities')); diff --git a/src/ui/public/chrome/chrome.js b/src/ui/public/chrome/chrome.js index d17155fe473d3..7eba951076803 100644 --- a/src/ui/public/chrome/chrome.js +++ b/src/ui/public/chrome/chrome.js @@ -38,7 +38,6 @@ import { initChromeNavApi } from './api/nav'; import { initBreadcrumbsApi } from './api/breadcrumbs'; import templateApi from './api/template'; import { initChromeThemeApi } from './api/theme'; -import { initConfig } from './api/config'; import { initChromeXsrfApi } from './api/xsrf'; import { initUiSettingsApi } from './api/ui_settings'; import { initLoadingCountApi } from './api/loading_count'; @@ -62,7 +61,6 @@ const internals = _.defaults( } ); -initConfig(); initUiSettingsApi(chrome); initSavedObjectClient(chrome); appsApi(chrome, internals); diff --git a/src/ui/public/chrome/directives/global_nav/app_switcher/app_switcher.js b/src/ui/public/chrome/directives/global_nav/app_switcher/app_switcher.js index 52d94c3efc218..2e8be802e1a98 100644 --- a/src/ui/public/chrome/directives/global_nav/app_switcher/app_switcher.js +++ b/src/ui/public/chrome/directives/global_nav/app_switcher/app_switcher.js @@ -69,13 +69,15 @@ uiModules }, template: appSwitcherTemplate, controllerAs: 'switcher', - controller($scope, appSwitcherEnsureNavigation, globalNavState, chromeConfig) { + controller($scope, appSwitcherEnsureNavigation, globalNavState, uiCapabilities) { if (!$scope.chrome || !$scope.chrome.getNavLinks) { throw new TypeError('appSwitcher directive requires the "chrome" config-object'); } + const { navLinks: navLinkCapabilities = {} } = uiCapabilities; + this.links = $scope.chrome.getNavLinks() - .filter(navLink => !chromeConfig.shouldHideNavLink(navLink)); + .filter(navLink => navLinkCapabilities[navLink.id]); // links don't cause full-navigation events in certain scenarios // so we force them when needed diff --git a/x-pack/plugins/__mocks__/ui/capabilities.ts b/x-pack/plugins/__mocks__/ui/capabilities.ts new file mode 100644 index 0000000000000..d35d9c3aea0c9 --- /dev/null +++ b/x-pack/plugins/__mocks__/ui/capabilities.ts @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { UICapabilities } from 'ui/capabilities'; + +let internals: UICapabilities = { + navLinks: {}, + spaces: { + manage: true, + }, +}; + +export const uiCapabilities = new Proxy( + {}, + { + get: (target, property) => { + return internals[String(property)] as any; + }, + } +); + +export function setMockCapabilities(mockCapabilities: UICapabilities) { + internals = mockCapabilities; +} diff --git a/x-pack/plugins/__mocks__/ui/chrome.js b/x-pack/plugins/__mocks__/ui/chrome.js index 73f48348ae326..f73facd818e93 100644 --- a/x-pack/plugins/__mocks__/ui/chrome.js +++ b/x-pack/plugins/__mocks__/ui/chrome.js @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { uiCapabilities } from './capabilities'; + function getUiSettingsClient() { return { get: key => { @@ -29,6 +31,8 @@ function getInjected(key) { return 'apm*'; case 'mlEnabled': return true; + case 'uiCapabilities': + return uiCapabilities; default: throw new Error(`Unexpected config key: ${key}`); } diff --git a/x-pack/plugins/security/index.js b/x-pack/plugins/security/index.js index fd8939ba62e6d..cf04a5cf91d7f 100644 --- a/x-pack/plugins/security/index.js +++ b/x-pack/plugins/security/index.js @@ -24,8 +24,6 @@ import { createAuthorizationService, registerPrivilegesWithCluster } from './ser import { watchStatusAndLicenseToInitialize } from '../../server/lib/watch_status_and_license_to_initialize'; import { SecureSavedObjectsClientWrapper } from './server/lib/saved_objects_client/secure_saved_objects_client_wrapper'; import { deepFreeze } from './server/lib/deep_freeze'; -import { capabilityDecorator } from './server/lib/capability_decorator'; -import { registerUserProfileCapabilityDecorator } from '../xpack_main/server/lib/user_profile'; export const security = (kibana) => new kibana.Plugin({ id: 'security', @@ -127,8 +125,6 @@ export const security = (kibana) => new kibana.Plugin({ } }); - registerUserProfileCapabilityDecorator(Number.MIN_SAFE_INTEGER, capabilityDecorator); - const auditLogger = new SecurityAuditLogger(server.config(), new AuditLogger(server, 'security')); const { savedObjects } = server; @@ -198,11 +194,8 @@ export const security = (kibana) => new kibana.Plugin({ // Enforce app restrictions if (path.startsWith('/app/')) { - const appId = path.split('/', 3)[2]; - const userProfile = await req.getUserProfile(); - if (!userProfile.canAccessFeature(appId)) { - return Boom.notFound(); - } + // const appId = path.split('/', 3)[2]; + // TODO: feature access check } // Enforce API restrictions for associated applications diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx index ddf3a10146e3a..8f97a4c97de2f 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx @@ -23,9 +23,9 @@ import { import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import { get } from 'lodash'; import React, { ChangeEvent, Component, Fragment, HTMLProps } from 'react'; +import { UICapabilities } from 'ui/capabilities'; import { toastNotifications } from 'ui/notify'; import { Space } from '../../../../../../spaces/common/model/space'; -import { UserProfile } from '../../../../../../xpack_main/common/user_profile'; import { IndexPrivilege } from '../../../../../common/model/index_privilege'; import { KibanaPrivilege } from '../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../common/model/role'; @@ -48,8 +48,8 @@ interface Props { kibanaAppPrivileges: KibanaPrivilege[]; spaces?: Space[]; spacesEnabled: boolean; - userProfile: UserProfile; intl: InjectedIntl; + uiCapabilities: UICapabilities; } interface State { @@ -252,7 +252,7 @@ class EditRolePageUI extends Component { kibanaAppPrivileges={this.props.kibanaAppPrivileges} spaces={this.props.spaces} spacesEnabled={this.props.spacesEnabled} - userProfile={this.props.userProfile} + uiCapabilities={this.props.uiCapabilities} editable={!isReservedRole(this.state.role)} role={this.state.role} onChange={this.onRoleChange} diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap index 82d0190ad54cc..6f9841fbc213b 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap @@ -43,8 +43,17 @@ exports[` renders without crashing 1`] = ` } userProfile={ Object { - "hasCapability": [Function], - } + "id": "marketing", + "name": "Marketing", + }, + ] + } + uiCapabilities={ + Object { + "navLinks": Object {}, + "spaces": Object { + "manage": true, + }, } validator={ RoleValidator { diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/space_aware_privilege_form.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/space_aware_privilege_form.test.tsx.snap index da21290b11e24..af729cddc0f96 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/space_aware_privilege_form.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/space_aware_privilege_form.test.tsx.snap @@ -369,11 +369,6 @@ exports[` renders without crashing 1`] = ` }, ] } - userProfile={ - Object { - "hasCapability": [Function], - } - } /> diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx index dbf6db220607c..0b329ebbdfffe 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx @@ -35,7 +35,6 @@ const buildProps = (customProps = {}) => { name: 'Marketing', }, ], - userProfile: new UserProfile(), kibanaAppPrivileges: [ { name: 'all', diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx index 0ca928b2e5f77..f34a36ebb2915 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.tsx @@ -18,7 +18,6 @@ import { PrivilegeSpaceTable } from './privilege_space_table'; import { Space } from '../../../../../../../../spaces/common/model/space'; import { ManageSpacesButton } from '../../../../../../../../spaces/public/components'; -import { UserProfile } from '../../../../../../../../xpack_main/common/user_profile'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../../../common/model/role'; import { NO_PRIVILEGE_VALUE } from '../../../lib/constants'; @@ -26,7 +25,6 @@ import { NO_PRIVILEGE_VALUE } from '../../../lib/constants'; interface Props { role: Role; spaces: Space[]; - userProfile: UserProfile; intl: InjectedIntl; } @@ -139,7 +137,7 @@ class ImpactedSpacesFlyoutUI extends Component { {/* TODO: Hide footer if button is not available */} - + ); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.test.tsx index 56bf1f0af8a0d..27dfc263e5732 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.test.tsx @@ -7,7 +7,6 @@ import { shallow } from 'enzyme'; import React from 'react'; import { KibanaPrivilege } from '../../../../../../../../security/common/model/kibana_privilege'; -import { UserProfile } from '../../../../../../../../xpack_main/common/user_profile'; import { RoleValidator } from '../../../lib/validate_role'; import { KibanaPrivileges } from './kibana_privileges'; import { SimplePrivilegeForm } from './simple_privilege_form'; @@ -39,7 +38,12 @@ const buildProps = (customProps = {}) => { name: 'Marketing', }, ], - userProfile: new UserProfile(), + uiCapabilities: { + navLinks: {}, + spaces: { + manage: true, + }, + }, editable: true, kibanaAppPrivileges: ['all' as KibanaPrivilege], onChange: jest.fn(), diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx index 2248a75ad5539..ba377af2ce474 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges.tsx @@ -6,8 +6,8 @@ import { I18nProvider } from '@kbn/i18n/react'; import React, { Component } from 'react'; +import { UICapabilities } from 'ui/capabilities'; import { Space } from '../../../../../../../../spaces/common/model/space'; -import { UserProfile } from '../../../../../../../../xpack_main/common/user_profile'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../../../common/model/role'; import { RoleValidator } from '../../../lib/validate_role'; @@ -19,7 +19,7 @@ interface Props { role: Role; spacesEnabled: boolean; spaces?: Space[]; - userProfile: UserProfile; + uiCapabilities: UICapabilities; editable: boolean; kibanaAppPrivileges: KibanaPrivilege[]; onChange: (role: Role) => void; @@ -43,7 +43,7 @@ export class KibanaPrivileges extends Component { role, spacesEnabled, spaces = [], - userProfile, + uiCapabilities, onChange, editable, validator, @@ -55,7 +55,7 @@ export class KibanaPrivileges extends Component { kibanaAppPrivileges={kibanaAppPrivileges} role={role} spaces={spaces} - userProfile={userProfile} + uiCapabilities={uiCapabilities} onChange={onChange} editable={editable} validator={validator} diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.test.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.test.tsx index a1925da9e4849..3b5ac6b8e54d2 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.test.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.test.tsx @@ -37,7 +37,12 @@ const buildProps = (customProps: any = {}) => { name: 'Marketing', }, ], - userProfile: { hasCapability: () => true }, + uiCapabilities: { + navLinks: {}, + spaces: { + manage: true, + }, + }, editable: true, kibanaAppPrivileges: ['all', 'read'], onChange: jest.fn(), @@ -236,13 +241,9 @@ describe('', () => { describe('with user profile disabling "manageSpaces"', () => { it('renders a warning message instead of the privilege form', () => { const props = buildProps({ - userProfile: { - hasCapability: (capability: string) => { - if (capability === 'manageSpaces') { - return false; - } - throw new Error(`unexpected call to hasCapability: ${capability}`); - }, + uiCapabilities: { + navLinks: {}, + spaces: { manage: false }, }, }); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx index 5465d4db427ab..d87a0f61a3a17 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_form.tsx @@ -18,8 +18,8 @@ import { } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; +import { UICapabilities } from 'ui/capabilities'; import { Space } from '../../../../../../../../spaces/common/model/space'; -import { UserProfile } from '../../../../../../../../xpack_main/common/user_profile'; import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege'; import { Role } from '../../../../../../../common/model/role'; import { isReservedRole } from '../../../../../../lib/role'; @@ -40,8 +40,8 @@ interface Props { onChange: (role: Role) => void; editable: boolean; validator: RoleValidator; - userProfile: UserProfile; intl: InjectedIntl; + uiCapabilities: UICapabilities; } interface PrivilegeForm { @@ -75,9 +75,9 @@ class SpaceAwarePrivilegeFormUI extends Component { } public render() { - const { kibanaAppPrivileges, role, userProfile, intl } = this.props; + const { kibanaAppPrivileges, role, uiCapabilities, intl } = this.props; - if (!userProfile.hasCapability('manageSpaces')) { + if (!uiCapabilities.spaces.manage) { return ( { )} - + diff --git a/x-pack/plugins/security/public/views/management/edit_role/index.js b/x-pack/plugins/security/public/views/management/edit_role/index.js index b473a975e5561..9a9f01d16ef1a 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/index.js +++ b/x-pack/plugins/security/public/views/management/edit_role/index.js @@ -7,6 +7,7 @@ import _ from 'lodash'; import chrome from 'ui/chrome'; import routes from 'ui/routes'; +import { uiCapabilities } from 'ui/capabilities'; import { fatalError } from 'ui/notify'; import template from 'plugins/security/views/management/edit_role/edit_role.html'; import 'angular-ui-select'; @@ -86,7 +87,7 @@ routes.when(`${EDIT_ROLES_PATH}/:name?`, { } }, controllerAs: 'editRole', - controller($injector, $scope, $http, enableSpaceAwarePrivileges, userProfile) { + controller($injector, $scope, $http, enableSpaceAwarePrivileges) { const $route = $injector.get('$route'); const Private = $injector.get('Private'); @@ -139,7 +140,7 @@ routes.when(`${EDIT_ROLES_PATH}/:name?`, { allowFieldLevelSecurity={allowFieldLevelSecurity} spaces={spaces} spacesEnabled={enableSpaceAwarePrivileges} - userProfile={userProfile} + uiCapabilities={uiCapabilities} /> , domNode); diff --git a/x-pack/plugins/security/server/lib/capability_decorator.ts b/x-pack/plugins/security/server/lib/capability_decorator.ts index 9f9be0a96fbe8..f98852f7090a3 100644 --- a/x-pack/plugins/security/server/lib/capability_decorator.ts +++ b/x-pack/plugins/security/server/lib/capability_decorator.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ import _ from 'lodash'; -import { Capabilities } from 'x-pack/plugins/xpack_main/common'; +import { UICapabilities } from 'ui/capabilities'; export async function capabilityDecorator( server: Record, request: Record, - capabilities: Capabilities + capabilities: UICapabilities ) { if (!isAuthenticatedRoute(request)) { return capabilities; diff --git a/x-pack/plugins/spaces/index.ts b/x-pack/plugins/spaces/index.ts index 052b3a2ff6ce6..69cf3dd58fef7 100644 --- a/x-pack/plugins/spaces/index.ts +++ b/x-pack/plugins/spaces/index.ts @@ -22,6 +22,7 @@ import { spacesSavedObjectsClientWrapperFactory } from './server/lib/saved_objec import { initSpacesRequestInterceptors } from './server/lib/space_request_interceptors'; import { SpacesClient } from './server/lib/spaces_client'; import { createSpacesTutorialContextFactory } from './server/lib/spaces_tutorial_context_factory'; +import { toggleUiCapabilities } from './server/lib/toggle_ui_capabilities'; import { initPublicSpacesApi } from './server/routes/api/public'; import { initPrivateApis } from './server/routes/api/v1'; @@ -65,9 +66,18 @@ export const spaces = (kibana: any) => spaces: [], activeSpace: null, spaceSelectorURL: getSpaceSelectorUrl(server.config()), + uiCapabilities: { + spaces: { + manage: true, + }, + }, }; }, - async replaceInjectedVars(vars: any, request: any, server: any) { + async replaceInjectedVars( + vars: Record, + request: Record, + server: Record + ) { const spacesClient = server.plugins.spaces.spacesClient.getScopedClient(request); try { vars.activeSpace = { @@ -84,6 +94,14 @@ export const spaces = (kibana: any) => error: wrapError(e).output.payload, }; } + + if (vars.activeSpace.space) { + vars.uiCapabilities = await toggleUiCapabilities( + vars.uiCapabilities, + vars.activeSpace.space + ); + } + return vars; }, }, diff --git a/x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx b/x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx index cdef0a9e7f9de..69a99106e2dfb 100644 --- a/x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx +++ b/x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx @@ -5,15 +5,30 @@ */ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { setMockCapabilities } from 'x-pack/plugins/__mocks__/ui/capabilities'; import { ManageSpacesButton } from './manage_spaces_button'; describe('ManageSpacesButton', () => { it('renders as expected', () => { + setMockCapabilities({ + navLinks: {}, + spaces: { + manage: true, + }, + }); + const component = ; expect(shallowWithIntl(component)).toMatchSnapshot(); }); it(`doesn't render if user profile forbids managing spaces`, () => { + setMockCapabilities({ + navLinks: {}, + spaces: { + manage: false, + }, + }); + const component = ; expect(shallowWithIntl(component)).toMatchSnapshot(); }); diff --git a/x-pack/plugins/spaces/public/components/manage_spaces_button.tsx b/x-pack/plugins/spaces/public/components/manage_spaces_button.tsx index 55f5b48ddb2b6..3fe340cfba98f 100644 --- a/x-pack/plugins/spaces/public/components/manage_spaces_button.tsx +++ b/x-pack/plugins/spaces/public/components/manage_spaces_button.tsx @@ -7,7 +7,7 @@ import { EuiButton } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component, CSSProperties } from 'react'; -import { UserProfile } from '../../../xpack_main/common/user_profile'; +import { uiCapabilities } from 'ui/capabilities'; import { MANAGE_SPACES_URL } from '../lib/constants'; interface Props { @@ -15,13 +15,12 @@ interface Props { className?: string; size?: 's' | 'l'; style?: CSSProperties; - userProfile: UserProfile; onClick?: () => void; } export class ManageSpacesButton extends Component { public render() { - if (!this.props.userProfile.hasCapability('manageSpaces')) { + if (!uiCapabilities.spaces.manage) { return null; } diff --git a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/__snapshots__/secure_space_message.test.tsx.snap b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/__snapshots__/secure_space_message.test.tsx.snap index a18d45e2d6518..65d17e1fde70e 100644 --- a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/__snapshots__/secure_space_message.test.tsx.snap +++ b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/__snapshots__/secure_space_message.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SecureSpaceMessage doesn't render if user profile does not allow security to be managed 1`] = `""`; +exports[`SecureSpaceMessage doesn't render if UI Capabilities does not allow security to be managed 1`] = `""`; exports[`SecureSpaceMessage renders if user profile allows security to be managed 1`] = ` diff --git a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.test.tsx b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.test.tsx index e6a4ebc161fb4..33e801aca7d94 100644 --- a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.test.tsx +++ b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.test.tsx @@ -5,19 +5,23 @@ */ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { setMockCapabilities } from 'x-pack/plugins/__mocks__/ui/capabilities'; import { SecureSpaceMessage } from './secure_space_message'; describe('SecureSpaceMessage', () => { - it(`doesn't render if user profile does not allow security to be managed`, () => { - - expect(shallowWithIntl()).toMatchSnapshot(); + it(`doesn't render if UI Capabilities does not allow security to be managed`, () => { + setMockCapabilities({ + navLinks: {}, + spaces: { manage: false }, + }); + expect(shallowWithIntl()).toMatchSnapshot(); }); it(`renders if user profile allows security to be managed`, () => { - const userProfile = new UserProfile({ - manageSecurity: true, + setMockCapabilities({ + navLinks: {}, + spaces: { manage: true }, }); - - expect(shallowWithIntl()).toMatchSnapshot(); + expect(shallowWithIntl()).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.tsx b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.tsx index 83ac70715f5c9..6c8d3e301e917 100644 --- a/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.tsx +++ b/x-pack/plugins/spaces/public/views/management/components/secure_space_message/secure_space_message.tsx @@ -9,8 +9,8 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { Fragment } from 'react'; import { uiCapabilities } from 'ui/capabilities'; -export const SecureSpaceMessage = (props: {}) => { - if (uiCapabilities.security.manage) { +export const SecureSpaceMessage = ({}) => { + if (uiCapabilities.spaces.manage) { return ( diff --git a/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.test.tsx b/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.test.tsx index 9bb4ad3be2dbe..8462a4b6ab508 100644 --- a/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.test.tsx +++ b/x-pack/plugins/spaces/public/views/management/edit_space/manage_space_page.test.tsx @@ -86,7 +86,6 @@ describe('ManageSpacePage', () => { getActiveSpace: () => space, refreshSpacesList: jest.fn(), }; - const wrapper = mountWithIntl( { }; public getForm = () => { - const { userProfile, intl } = this.props; + const { intl } = this.props; - if (!userProfile.hasCapability('manageSpaces')) { + if (!uiCapabilities.spaces.manage) { return ; } @@ -251,7 +250,7 @@ class ManageSpacePageUI extends Component { public maybeGetSecureSpacesMessage = () => { if (this.editingExistingSpace()) { - return ; + return ; } return null; }; diff --git a/x-pack/plugins/spaces/public/views/management/page_routes.tsx b/x-pack/plugins/spaces/public/views/management/page_routes.tsx index cbfaf19898cc3..1263d1beead45 100644 --- a/x-pack/plugins/spaces/public/views/management/page_routes.tsx +++ b/x-pack/plugins/spaces/public/views/management/page_routes.tsx @@ -14,7 +14,6 @@ import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; // @ts-ignore import routes from 'ui/routes'; -import { UserProfile } from '../../../../xpack_main/common/user_profile'; import { SpacesManager } from '../../lib/spaces_manager'; import { ManageSpacePage } from './edit_space'; import { SpacesGridPage } from './spaces_grid'; @@ -28,8 +27,7 @@ routes.when('/management/spaces/list', { $http: any, chrome: any, spacesNavState: SpacesNavState, - spaceSelectorURL: string, - userProfile: UserProfile + spaceSelectorURL: string ) { $scope.$$postDigest(() => { const domNode = document.getElementById(reactRootNodeId); @@ -38,11 +36,7 @@ routes.when('/management/spaces/list', { render( - + , domNode ); @@ -64,8 +58,7 @@ routes.when('/management/spaces/create', { $http: any, chrome: any, spacesNavState: SpacesNavState, - spaceSelectorURL: string, - userProfile: UserProfile + spaceSelectorURL: string ) { $scope.$$postDigest(() => { const domNode = document.getElementById(reactRootNodeId); @@ -74,11 +67,7 @@ routes.when('/management/spaces/create', { render( - + , domNode ); @@ -106,8 +95,7 @@ routes.when('/management/spaces/edit/:spaceId', { chrome: any, Private: any, spacesNavState: SpacesNavState, - spaceSelectorURL: string, - userProfile: UserProfile + spaceSelectorURL: string ) { $scope.$$postDigest(() => { const domNode = document.getElementById(reactRootNodeId); @@ -122,7 +110,6 @@ routes.when('/management/spaces/edit/:spaceId', { spaceId={spaceId} spacesManager={spacesManager} spacesNavState={spacesNavState} - userProfile={userProfile} /> , domNode diff --git a/x-pack/plugins/spaces/public/views/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap b/x-pack/plugins/spaces/public/views/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap index bebda86fa9721..5c750e50b6870 100644 --- a/x-pack/plugins/spaces/public/views/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap +++ b/x-pack/plugins/spaces/public/views/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap @@ -135,15 +135,7 @@ exports[`SpacesGridPage renders as expected 1`] = ` /> - + `; diff --git a/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx b/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx index a117662f7eaf7..b198bd467b6ba 100644 --- a/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx +++ b/x-pack/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx @@ -24,7 +24,7 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import { toastNotifications } from 'ui/notify'; import { SpacesNavState } from 'plugins/spaces/views/nav_control'; -import { UserProfile } from '../../../../../xpack_main/common/user_profile'; +import { uiCapabilities } from 'ui/capabilities'; import { isReservedSpace } from '../../../../common'; import { Space } from '../../../../common/model/space'; import { SpaceAvatar } from '../../../components'; @@ -36,7 +36,6 @@ import { UnauthorizedPrompt } from '../components/unauthorized_prompt'; interface Props { spacesManager: SpacesManager; spacesNavState: SpacesNavState; - userProfile: UserProfile; intl: InjectedIntl; } @@ -69,7 +68,7 @@ class SpacesGridPageUI extends Component { {this.getPageContent()} - + {this.getConfirmDeleteModal()} @@ -78,7 +77,8 @@ class SpacesGridPageUI extends Component { public getPageContent() { const { intl } = this.props; - if (!this.props.userProfile.hasCapability('manageSpaces')) { + + if (!uiCapabilities.spaces.manage) { return ; } diff --git a/x-pack/plugins/spaces/public/views/nav_control/__snapshots__/nav_control_popover.test.tsx.snap b/x-pack/plugins/spaces/public/views/nav_control/__snapshots__/nav_control_popover.test.tsx.snap index a36ce538c3f21..396e62aa8e217 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/__snapshots__/nav_control_popover.test.tsx.snap +++ b/x-pack/plugins/spaces/public/views/nav_control/__snapshots__/nav_control_popover.test.tsx.snap @@ -34,11 +34,6 @@ exports[`NavControlPopover renders without crashing 1`] = ` > `; diff --git a/x-pack/plugins/spaces/public/views/nav_control/components/__snapshots__/spaces_description.test.tsx.snap b/x-pack/plugins/spaces/public/views/nav_control/components/__snapshots__/spaces_description.test.tsx.snap index 68c035c7d86d6..3568a124dc9a5 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/components/__snapshots__/spaces_description.test.tsx.snap +++ b/x-pack/plugins/spaces/public/views/nav_control/components/__snapshots__/spaces_description.test.tsx.snap @@ -28,11 +28,6 @@ exports[`SpacesDescription renders without crashing 1`] = ` "width": "100%", } } - userProfile={ - Object { - "hasCapability": [Function], - } - } /> diff --git a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx index 864d15bc43d4b..4a2fd34665866 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx @@ -6,13 +6,10 @@ import { shallow } from 'enzyme'; import React from 'react'; -import { UserProfile } from '../../../../../xpack_main/common/user_profile'; import { SpacesDescription } from './spaces_description'; describe('SpacesDescription', () => { it('renders without crashing', () => { - expect( - shallow() - ).toMatchSnapshot(); + expect(shallow()).toMatchSnapshot(); }); }); diff --git a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.tsx b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.tsx index 3a60bfe4c453b..51db5e89f6b50 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.tsx @@ -6,12 +6,10 @@ import { EuiContextMenuPanel, EuiText } from '@elastic/eui'; import React, { SFC } from 'react'; -import { UserProfile } from '../../../../../xpack_main/common/user_profile'; import { ManageSpacesButton } from '../../../components'; import { SPACES_FEATURE_DESCRIPTION } from '../../../lib/constants'; interface Props { - userProfile: UserProfile; onManageSpacesClick: () => void; } @@ -30,7 +28,6 @@ export const SpacesDescription: SFC = (props: Props) => { diff --git a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_menu.tsx b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_menu.tsx index 42685556bf243..74a0df338aaae 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/components/spaces_menu.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/components/spaces_menu.tsx @@ -7,7 +7,6 @@ import { EuiContextMenuItem, EuiContextMenuPanel, EuiFieldSearch, EuiText } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component } from 'react'; -import { UserProfile } from '../../../../../xpack_main/common/user_profile'; import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../../../common/constants'; import { Space } from '../../../../common/model/space'; import { ManageSpacesButton, SpaceAvatar } from '../../../components'; @@ -16,7 +15,6 @@ interface Props { spaces: Space[]; onSelectSpace: (space: Space) => void; onManageSpacesClick: () => void; - userProfile: UserProfile; intl: InjectedIntl; } @@ -150,7 +148,6 @@ class SpacesMenuUI extends Component { key="manageSpacesButton" className="spcMenu__manageButton" size="s" - userProfile={this.props.userProfile} onClick={this.props.onManageSpacesClick} /> ); diff --git a/x-pack/plugins/spaces/public/views/nav_control/nav_control.tsx b/x-pack/plugins/spaces/public/views/nav_control/nav_control.tsx index 0c2dff2cbc71d..180d9114ee40b 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/nav_control.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/nav_control.tsx @@ -21,7 +21,6 @@ import { uiModules } from 'ui/modules'; import { chromeHeaderNavControlsRegistry } from 'ui/registry/chrome_header_nav_controls'; // @ts-ignore import { chromeNavControlsRegistry } from 'ui/registry/chrome_nav_controls'; -import { UserProfile } from '../../../../xpack_main/common/user_profile'; import { Space } from '../../../common/model/space'; import { SpacesGlobalNavButton } from './components/spaces_global_nav_button'; import { SpacesHeaderNavButton } from './components/spaces_header_nav_button'; @@ -94,7 +93,7 @@ module.service('spacesNavState', (activeSpace: any) => { }); chromeHeaderNavControlsRegistry.register( - ($http: any, chrome: any, Private: any, activeSpace: any, userProfile: UserProfile) => ({ + ($http: any, chrome: any, Private: any, activeSpace: any) => ({ name: 'spaces', order: 1000, side: NavControlSide.Left, diff --git a/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.test.tsx b/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.test.tsx index 14b843f6eb9c8..1f743bfba7e5a 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.test.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.test.tsx @@ -6,7 +6,6 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; -import { UserProfile } from '../../../../xpack_main/common/user_profile'; import { SpaceAvatar } from '../../components'; import { SpacesManager } from '../../lib/spaces_manager'; import { SpacesGlobalNavButton } from './components/spaces_global_nav_button'; @@ -53,7 +52,6 @@ describe('NavControlPopover', () => { @@ -75,7 +73,6 @@ describe('NavControlPopover', () => { diff --git a/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.tsx b/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.tsx index c64277e7846d7..a5d1e66d9a986 100644 --- a/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.tsx +++ b/x-pack/plugins/spaces/public/views/nav_control/nav_control_popover.tsx @@ -7,7 +7,6 @@ import { EuiAvatar, EuiPopover, PopoverAnchorPosition } from '@elastic/eui'; import { I18nProvider } from '@kbn/i18n/react'; import React, { Component, ComponentClass } from 'react'; -import { UserProfile } from '../../../../xpack_main/common/user_profile'; import { Space } from '../../../common/model/space'; import { SpaceAvatar } from '../../components'; import { SpacesManager } from '../../lib/spaces_manager'; @@ -22,7 +21,6 @@ interface Props { error?: string; space: Space; }; - userProfile: UserProfile; anchorPosition: PopoverAnchorPosition; buttonClass: ComponentClass; } @@ -63,19 +61,13 @@ export class NavControlPopover extends Component { let element: React.ReactNode; if (this.state.spaces.length < 2) { - element = ( - - ); + element = ; } else { element = ( diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile/index.ts b/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.test.ts similarity index 60% rename from x-pack/plugins/xpack_main/server/lib/user_profile/index.ts rename to x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.test.ts index 73880d8c0e81b..a6b3796bf9424 100644 --- a/x-pack/plugins/xpack_main/server/lib/user_profile/index.ts +++ b/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.test.ts @@ -4,5 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -export { userProfileMixin } from './user_profile_mixin'; -export { registerUserProfileCapabilityDecorator } from './user_profile_capability_registry'; +describe('toggleUiCapabilities', () => { + // TODO: implement tests once spaces have the concept of disabled features + it('should be tested', () => null); +}); diff --git a/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts b/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts new file mode 100644 index 0000000000000..67eb48f4030d8 --- /dev/null +++ b/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.ts @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { UICapabilities } from 'ui/capabilities'; +import { Space } from '../../common/model/space'; + +export async function toggleUiCapabilities(uiCapabilities: UICapabilities, activeSpace: Space) { + toggleDisabledFeatures(uiCapabilities, activeSpace); + + return uiCapabilities; +} + +function toggleDisabledFeatures(uiCapabilities: UICapabilities, activeSpace: Space) { + // TODO: get disabled features from active space + // @ts-ignore + const disabledFeatures: string[] = activeSpace.disabledFeatures || []; + + const navLinks: Record = uiCapabilities.navLinks as Record; + + for (const feature of disabledFeatures) { + // Disable associated navLink, if one exists + if (uiCapabilities.navLinks.hasOwnProperty(feature)) { + navLinks[feature] = false; + } + + // Disable "sub features" that match the disabled feature + if (uiCapabilities.hasOwnProperty(feature)) { + const capability = uiCapabilities[feature]; + Object.keys(capability).forEach(featureKey => { + capability[featureKey] = false; + }); + } + } +} diff --git a/x-pack/plugins/xpack_main/common/index.ts b/x-pack/plugins/xpack_main/common/index.ts deleted file mode 100644 index 23c27385776c2..0000000000000 --- a/x-pack/plugins/xpack_main/common/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { Capabilities, UserProfile } from './user_profile'; diff --git a/x-pack/plugins/xpack_main/common/user_profile/capabilities.ts b/x-pack/plugins/xpack_main/common/user_profile/capabilities.ts deleted file mode 100644 index c1e893d5a1bc1..0000000000000 --- a/x-pack/plugins/xpack_main/common/user_profile/capabilities.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export interface Capabilities { - [capability: string]: boolean; -} diff --git a/x-pack/plugins/xpack_main/common/user_profile/index.ts b/x-pack/plugins/xpack_main/common/user_profile/index.ts deleted file mode 100644 index ef5c9c037ebae..0000000000000 --- a/x-pack/plugins/xpack_main/common/user_profile/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -export { Capabilities } from './capabilities'; -export { UserProfile } from './user_profile'; diff --git a/x-pack/plugins/xpack_main/common/user_profile/user_profile.test.ts b/x-pack/plugins/xpack_main/common/user_profile/user_profile.test.ts deleted file mode 100644 index 4ef1f1d3b577f..0000000000000 --- a/x-pack/plugins/xpack_main/common/user_profile/user_profile.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { UserProfile } from './user_profile'; -describe('UserProfile', () => { - it('should return true when the specified capability is enabled', () => { - const capabilities = { - test1: true, - test2: false, - }; - const userProfile = new UserProfile(capabilities); - expect(userProfile.hasCapability('test1')).toEqual(true); - }); - it('should return false when the specified capability is disabled', () => { - const capabilities = { - test1: true, - test2: false, - }; - const userProfile = new UserProfile(capabilities); - expect(userProfile.hasCapability('test2')).toEqual(false); - }); - it('should return the default value when the specified capability is not defined', () => { - const capabilities = { - test1: true, - test2: false, - }; - const userProfile = new UserProfile(capabilities); - expect(userProfile.hasCapability('test3')).toEqual(true); - expect(userProfile.hasCapability('test3', false)).toEqual(false); - }); -}); diff --git a/x-pack/plugins/xpack_main/common/user_profile/user_profile.ts b/x-pack/plugins/xpack_main/common/user_profile/user_profile.ts deleted file mode 100644 index 7d657b0f3ccf9..0000000000000 --- a/x-pack/plugins/xpack_main/common/user_profile/user_profile.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Capabilities } from './capabilities'; - -export class UserProfile { - private capabilities: Capabilities; - constructor(profileData: Capabilities = {}) { - this.capabilities = { - ...profileData, - }; - } - - public hasCapability(capability: string, defaultValue: boolean = true): boolean { - return capability in this.capabilities ? this.capabilities[capability] : defaultValue; - } - - public canAccessFeature(feature: string, defaultValue: boolean = true): boolean { - return this.hasCapability(`ui:${feature}/read`, defaultValue); - } - - public canReadSavedObject(savedObjectType: string, defaultValue: boolean = true): boolean { - return this.hasCapability(`saved_objects/${savedObjectType}/get`, defaultValue); - } - - public canWriteSavedObject(savedObjectType: string, defaultValue: boolean = true): boolean { - return this.hasCapability(`saved_objects/${savedObjectType}/create`, defaultValue); - } - - public toJSON() { - return { - ...this.capabilities, - }; - } -} diff --git a/x-pack/plugins/xpack_main/index.js b/x-pack/plugins/xpack_main/index.js index b04d3d1deeb8d..40af54d7fb647 100644 --- a/x-pack/plugins/xpack_main/index.js +++ b/x-pack/plugins/xpack_main/index.js @@ -22,7 +22,6 @@ import { CONFIG_TELEMETRY_DESC, } from './common/constants'; import { settingsRoute } from './server/routes/api/v1/settings'; -import { userProfileMixin } from './server/lib/user_profile'; import mappings from './mappings.json'; export { callClusterFactory } from './server/lib/call_cluster_factory'; @@ -96,15 +95,12 @@ export const xpackMain = (kibana) => { telemetryOptedIn: null, activeSpace: null, spacesEnabled: config.get('xpack.spaces.enabled'), - userProfileData: {}, }; }, hacks: [ 'plugins/xpack_main/hacks/check_xpack_info_change', 'plugins/xpack_main/hacks/telemetry_opt_in', 'plugins/xpack_main/hacks/telemetry_trigger', - 'plugins/xpack_main/hacks/user_profile', - 'plugins/xpack_main/hacks/user_profile_config_decorators', ], replaceInjectedVars, __webpackPluginProvider__(webpack) { @@ -124,8 +120,6 @@ export const xpackMain = (kibana) => { setupXPackMain(server); - userProfileMixin(this.kbnServer, server); - // register routes xpackInfoRoute(server); telemetryRoute(server); diff --git a/x-pack/plugins/xpack_main/public/hacks/user_profile.ts b/x-pack/plugins/xpack_main/public/hacks/user_profile.ts deleted file mode 100644 index 91cdcb419e545..0000000000000 --- a/x-pack/plugins/xpack_main/public/hacks/user_profile.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; -// @ts-ignore -import { uiModules } from 'ui/modules'; -import { UserProfile } from '../../common'; - -uiModules.get('userProfile').provider('userProfile', function userProfileProvider() { - // @ts-ignore - this.$get = () => { - return new UserProfile(chrome.getInjected('userProfileData')); - }; -}); diff --git a/x-pack/plugins/xpack_main/public/hacks/user_profile_config_decorators.js b/x-pack/plugins/xpack_main/public/hacks/user_profile_config_decorators.js deleted file mode 100644 index 851a3a2e18950..0000000000000 --- a/x-pack/plugins/xpack_main/public/hacks/user_profile_config_decorators.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { uiModules } from 'ui/modules'; - -uiModules.get('kibana') - .config(($provide, $injector) => { - if ($injector.has('dashboardConfig')) { - $provide.decorator('dashboardConfig', function ($delegate, userProfile) { - return { - getHideWriteControls() { - if (!userProfile.canWriteSavedObject('dashboard')) { - return true; - } - - return $delegate.getHideWriteControls(); - } - }; - }); - } - - if ($injector.has('discoverConfig')) { - $provide.decorator('discoverConfig', function ($delegate, userProfile) { - return { - getHideWriteControls() { - if (!userProfile.canWriteSavedObject('search')) { - return true; - } - - return $delegate.getHideWriteControls(); - } - }; - }); - } - - if ($injector.has('chromeConfig')) { - $provide.decorator('chromeConfig', function ($delegate, userProfile) { - return { - shouldHideNavLink(navLink) { - if (!userProfile.canAccessFeature(navLink.id)) { - return true; - } - - return $delegate.shouldHideNavLink(navLink); - } - }; - }); - } - }); diff --git a/x-pack/plugins/xpack_main/server/lib/__tests__/replace_injected_vars.js b/x-pack/plugins/xpack_main/server/lib/__tests__/replace_injected_vars.js index 461d6a6f93e7b..f44e11b876676 100644 --- a/x-pack/plugins/xpack_main/server/lib/__tests__/replace_injected_vars.js +++ b/x-pack/plugins/xpack_main/server/lib/__tests__/replace_injected_vars.js @@ -19,9 +19,6 @@ const buildRequest = (telemetryOptedIn = null, path = '/app/kibana') => { return { path, - getUserProfile: async () => ({ - toJSON: () => ({}) - }), getSavedObjectsClient: () => { return { get, @@ -50,7 +47,6 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfileData: {} }); sinon.assert.calledOnce(server.plugins.security.isAuthenticated); @@ -70,7 +66,6 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfileData: {} }); }); @@ -87,7 +82,6 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfileData: {} }); }); @@ -104,7 +98,6 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfileData: {} }); }); @@ -121,7 +114,6 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfileData: {} }); }); @@ -138,7 +130,6 @@ describe('replaceInjectedVars uiExport', () => { xpackInitialInfo: { b: 1 }, - userProfileData: {} }); }); @@ -174,7 +165,6 @@ describe('replaceInjectedVars uiExport', () => { a: 1, telemetryOptedIn: null, xpackInitialInfo: undefined, - userProfileData: {}, }); }); diff --git a/x-pack/plugins/xpack_main/server/lib/replace_injected_vars.js b/x-pack/plugins/xpack_main/server/lib/replace_injected_vars.js index 909b151983cdc..4acf78224bf99 100644 --- a/x-pack/plugins/xpack_main/server/lib/replace_injected_vars.js +++ b/x-pack/plugins/xpack_main/server/lib/replace_injected_vars.js @@ -12,7 +12,6 @@ export async function replaceInjectedVars(originalInjectedVars, request, server) ...originalInjectedVars, telemetryOptedIn: await getTelemetryOptIn(request), xpackInitialInfo: xpackInfo.isAvailable() ? xpackInfo.toJSON() : undefined, - userProfileData: (await request.getUserProfile()).toJSON(), }); // security feature is disabled diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile/priority_collection.ts b/x-pack/plugins/xpack_main/server/lib/user_profile/priority_collection.ts deleted file mode 100644 index 2bb4337f04525..0000000000000 --- a/x-pack/plugins/xpack_main/server/lib/user_profile/priority_collection.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -interface PriorityCollectionEntry { - priority: number; - value: T; -} - -export class PriorityCollection { - private readonly array: Array> = []; - - public add(priority: number, value: T) { - const foundIndex = this.array.findIndex(current => { - if (priority === current.priority) { - throw new Error('Already have entry with this priority'); - } - - return priority < current.priority; - }); - - const spliceIndex = foundIndex === -1 ? this.array.length : foundIndex; - this.array.splice(spliceIndex, 0, { priority, value }); - } - - public toPrioritizedArray(): T[] { - return this.array.map(entry => entry.value); - } -} diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_capability_registry.ts b/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_capability_registry.ts deleted file mode 100644 index ec07ec66d7d7f..0000000000000 --- a/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_capability_registry.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Capabilities } from 'x-pack/plugins/xpack_main/common'; -import { PriorityCollection } from './priority_collection'; - -export type CapabilityDecorator = ( - server: Record, - request: Record, - capabilities: Capabilities -) => Promise; - -const decorators: PriorityCollection = new PriorityCollection(); - -export function registerUserProfileCapabilityDecorator( - priority: number, - decorator: CapabilityDecorator -) { - decorators.add(priority, decorator); -} - -export async function buildUserCapabilities( - server: Record, - request: Record -): Promise { - const decoratedCapabilities = await executeDecorators(server, request, {}); - - return decoratedCapabilities; -} - -async function executeDecorators( - server: Record, - request: Record, - capabilities: Capabilities -): Promise { - return await asyncForEach(decorators.toPrioritizedArray(), server, request, capabilities); -} - -async function asyncForEach( - array: CapabilityDecorator[], - server: Record, - request: Record, - initialCapabilities: Capabilities -) { - let capabilities = initialCapabilities; - - for (const callback of array) { - capabilities = await callback(server, request, capabilities); - } - - return capabilities; -} diff --git a/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_mixin.ts b/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_mixin.ts deleted file mode 100644 index b0aadb201f470..0000000000000 --- a/x-pack/plugins/xpack_main/server/lib/user_profile/user_profile_mixin.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { UserProfile } from '../../../common'; -import { buildUserCapabilities } from './user_profile_capability_registry'; - -export function userProfileMixin(kbnServer: Record, server: Record) { - const profileCache = new WeakMap(); - - server.decorate('request', 'getUserProfile', async function getUserProfile() { - // @ts-ignore - const request: Record = this; - - if (profileCache.has(request)) { - return profileCache.get(request); - } - - const userCapabilities = await buildUserCapabilities(server, request); - const profile = new UserProfile(userCapabilities); - - profileCache.set(request, profile); - - return profile; - }); -} From c4f7e7da9e71f46c42c7220077ce6d9691fb0508 Mon Sep 17 00:00:00 2001 From: Brandon Kobel Date: Fri, 16 Nov 2018 08:27:31 -0800 Subject: [PATCH 94/95] GAP - Actions Restructured and Extensible (#25347) * Restructure user profile for granular app privs (#23750) merging to feature branch for further development * Fixing saved object capability checking * Beginning to restructure actions to be used for all action building * Using actions to build ui capabilities * dropping /read from client-side userprovide ui capabilities * Adding some actions * Using different syntax which will hopefully help with allowing apps to specify the privileges themselves * Exposing all saved object operations in the capabilities * Using actions in security's onPostAuth * Only loading the default index pattern when it's required * Only using the navlinks for the "ui capabilities" * Redirecting from the discover application if the user can't access kibana:discover * Redirecting from dashboard if they're hidden * Features register their privileges now * Introducing a FeaturesPrivilegesBuilder * REmoving app from the feature definition * Adding navlink specific ations * Beginning to break out the serializer * Exposing privileges from the authorization service * Restructuring the privilege/resource serialization to support features * Adding actions unit tests * Adding features privileges builders tests * Adding PrivilegeSerializer tests * Renaming missed usages * Adding tests for the privileges serializer * Adding privileges tests * Adding registerPrivilegesWithCluster tests * Better tests * Fixing authorization service tests * Adding ResourceSerializer tests * Fixing Privileges tests * Some PUT role tests * Fixing read ui/api actions * Exposing features from xpackMainPlugin * Adding navlink:* to the "reserved privileges" * navlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_link * Automatically determining navlink based ui capabilities * Backing out changes that got left behind * Using ui actions for navlinks * Adding TODOs * Ui -> UI * Deleting unused file * Removing api: [] as it's not necessary anymore * Fixing graph saved object privileges * Privileges are now async * Pushing the asycnchronicity to the privileges "service" * Adding TODO * Providing initial value for reduce * adds uiCapabilities to test_entry_template * Adding config to APM/ML feature privileges * Commenting out obviously failing test so we can get CI greeenn * Fixing browser tests * Goodbyyeee * Adding app actions to the reserved privileges --- docs/development/security/rbac.asciidoc | 12 +- src/core_plugins/kibana/index.js | 7 - .../tests_bundle/tests_entry_template.js | 18 + src/core_plugins/timelion/index.js | 3 - .../app_switcher/__tests__/app_switcher.js | 12 +- src/ui/ui_render/ui_render_mixin.js | 15 +- x-pack/plugins/apm/index.js | 17 + x-pack/plugins/canvas/init.js | 25 + x-pack/plugins/graph/index.js | 25 + x-pack/plugins/ml/index.js | 17 + x-pack/plugins/monitoring/init.js | 14 +- .../common/{constants.js => constants.ts} | 0 x-pack/plugins/security/index.js | 28 +- .../security/server/lib/audit_logger.test.js | 2 +- .../__snapshots__/actions.test.js.snap | 25 - .../check_privileges.test.js.snap | 8 +- .../privilege_serializer.test.ts.snap | 11 + .../privileges_serializer.test.ts.snap | 7 + .../resource_serializer.test.ts.snap | 3 + ...ication_privileges_serializer.test.js.snap | 5 - .../server/lib/authorization/actions.js | 27 - .../server/lib/authorization/actions.test.js | 79 --- .../actions/__snapshots__/api.test.ts.snap | 13 + .../actions/__snapshots__/app.test.ts.snap | 13 + .../__snapshots__/saved_object.test.ts.snap | 97 ++++ .../actions/__snapshots__/ui.test.ts.snap | 25 + .../lib/authorization/actions/actions.test.ts | 38 ++ .../lib/authorization/actions/actions.ts | 32 ++ .../lib/authorization/actions/api.test.ts | 28 ++ .../server/lib/authorization/actions/api.ts | 20 + .../lib/authorization/actions/app.test.ts | 28 ++ .../server/lib/authorization/actions/app.ts | 19 + .../lib/authorization/actions/index.ts} | 5 +- .../actions/saved_object.test.ts | 169 +++++++ .../lib/authorization/actions/saved_object.ts | 55 ++ .../lib/authorization/actions/space.test.ts | 14 + .../server/lib/authorization/actions/space.ts | 9 + .../lib/authorization/actions/ui.test.ts | 42 ++ .../server/lib/authorization/actions/ui.ts | 24 + .../lib/authorization/check_privileges.js | 11 +- .../authorization/check_privileges.test.js | 168 +++---- .../features_privileges_builder.ts | 77 +++ .../features_privileges_builders.test.ts | 350 +++++++++++++ .../server/lib/authorization/index.js | 4 +- .../privilege_serializer.test.ts | 136 +++++ .../lib/authorization/privilege_serializer.ts | 78 +++ .../server/lib/authorization/privileges.js | 193 ------- .../lib/authorization/privileges.test.ts | 218 ++++++++ .../server/lib/authorization/privileges.ts | 85 ++++ .../privileges_serializer.test.ts | 162 ++++++ .../authorization/privileges_serializer.ts | 78 +++ .../register_privileges_with_cluster.js | 55 +- .../register_privileges_with_cluster.test.js | 474 +++++++++++++++--- .../authorization/resource_serializer.test.ts | 25 + .../lib/authorization/resource_serializer.ts | 21 + .../server/lib/authorization/service.js | 5 +- .../server/lib/authorization/service.test.js | 27 +- ...space_application_privileges_serializer.js | 35 -- ..._application_privileges_serializer.test.js | 51 -- .../secure_saved_objects_client_wrapper.js | 2 +- ...ecure_saved_objects_client_wrapper.test.js | 226 ++++----- .../server/routes/api/public/roles/get.js | 11 +- .../server/routes/api/public/roles/index.js | 8 +- .../server/routes/api/public/roles/put.js | 41 +- .../routes/api/public/roles/put.test.js | 92 ++-- .../spaces/server/lib/spaces_client.test.ts | 24 +- .../spaces/server/lib/spaces_client.ts | 8 +- x-pack/plugins/xpack_main/index.js | 2 + .../lib/feature_registry/feature_registry.ts | 16 +- .../server/lib/feature_registry/index.ts | 2 +- .../feature_registry/register_oss_features.ts | 54 -- .../server/lib/register_oss_features.ts | 155 ++++++ .../xpack_main/server/lib/setup_xpack_main.js | 3 +- x-pack/plugins/xpack_main/types.ts | 7 + .../common/suites/bulk_create.ts | 2 +- .../common/suites/bulk_get.ts | 2 +- .../common/suites/create.ts | 2 +- .../common/suites/delete.ts | 2 +- .../common/suites/find.ts | 2 +- .../common/suites/get.ts | 4 +- .../common/suites/update.ts | 2 +- 81 files changed, 2985 insertions(+), 926 deletions(-) rename x-pack/plugins/security/common/{constants.js => constants.ts} (100%) delete mode 100644 x-pack/plugins/security/server/lib/authorization/__snapshots__/actions.test.js.snap create mode 100644 x-pack/plugins/security/server/lib/authorization/__snapshots__/privilege_serializer.test.ts.snap create mode 100644 x-pack/plugins/security/server/lib/authorization/__snapshots__/privileges_serializer.test.ts.snap create mode 100644 x-pack/plugins/security/server/lib/authorization/__snapshots__/resource_serializer.test.ts.snap delete mode 100644 x-pack/plugins/security/server/lib/authorization/__snapshots__/space_application_privileges_serializer.test.js.snap delete mode 100644 x-pack/plugins/security/server/lib/authorization/actions.js delete mode 100644 x-pack/plugins/security/server/lib/authorization/actions.test.js create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/api.test.ts.snap create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/app.test.ts.snap create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/saved_object.test.ts.snap create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/ui.test.ts.snap create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/actions.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/actions.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/api.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/api.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/app.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/app.ts rename x-pack/plugins/{spaces/server/lib/toggle_ui_capabilities.test.ts => security/server/lib/authorization/actions/index.ts} (60%) create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/saved_object.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/saved_object.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/space.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/space.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/ui.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/actions/ui.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/features_privileges_builder.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/features_privileges_builders.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/privilege_serializer.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/privilege_serializer.ts delete mode 100644 x-pack/plugins/security/server/lib/authorization/privileges.js create mode 100644 x-pack/plugins/security/server/lib/authorization/privileges.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/privileges.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/privileges_serializer.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/privileges_serializer.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/resource_serializer.test.ts create mode 100644 x-pack/plugins/security/server/lib/authorization/resource_serializer.ts delete mode 100644 x-pack/plugins/security/server/lib/authorization/space_application_privileges_serializer.js delete mode 100644 x-pack/plugins/security/server/lib/authorization/space_application_privileges_serializer.test.js delete mode 100644 x-pack/plugins/xpack_main/server/lib/feature_registry/register_oss_features.ts create mode 100644 x-pack/plugins/xpack_main/server/lib/register_oss_features.ts create mode 100644 x-pack/plugins/xpack_main/types.ts diff --git a/docs/development/security/rbac.asciidoc b/docs/development/security/rbac.asciidoc index 5651c776360c1..cd11c2310fc99 100644 --- a/docs/development/security/rbac.asciidoc +++ b/docs/development/security/rbac.asciidoc @@ -32,9 +32,9 @@ Authorization: Basic kibana changeme "actions":[ "version:7.0.0-alpha1-SNAPSHOT", "action:login", - "action:saved_objects/dashboard/get", - "action:saved_objects/dashboard/bulk_get", - "action:saved_objects/dashboard/find", + "saved_object:dashboard/get", + "saved_object:dashboard/bulk_get", + "saved_object:dashboard/find", ... ],"metadata":{}} } @@ -90,7 +90,7 @@ Authorization: Basic foo_read_only_user password "application":"kibana-.kibana", "resources":["*"], "privileges":[ - "action:saved_objects/dashboard/save", + "saved_object:dashboard/save", ] } ] @@ -120,7 +120,7 @@ Authorization: Basic foo_legacy_user password "application":"kibana-.kibana", "resources":["*"], "privileges":[ - "action:saved_objects/dashboard/save" + "saved_object:dashboard/save" ] } ], @@ -152,7 +152,7 @@ Here is an example response if the user does not have application privileges, bu "application": { "kibana-.kibana": { "*": { - "action:saved_objects/dashboard/save": false + "saved_object:dashboard/save": false } } } diff --git a/src/core_plugins/kibana/index.js b/src/core_plugins/kibana/index.js index 984c31c5a0f91..ed7a0b5417eca 100644 --- a/src/core_plugins/kibana/index.js +++ b/src/core_plugins/kibana/index.js @@ -132,13 +132,6 @@ export default function (kibana) { kbnIndex: options.index, kbnBaseUrl, uiCapabilities: { - navLinks: { - 'kibana:discover': true, - 'kibana:visualize': true, - 'kibana:dashboard': true, - 'kibana:dev_tools': true, - 'kibana:management': true, - }, discover: { showWriteControls: true }, diff --git a/src/core_plugins/tests_bundle/tests_entry_template.js b/src/core_plugins/tests_bundle/tests_entry_template.js index aabe01734cc9e..f98477b407524 100644 --- a/src/core_plugins/tests_bundle/tests_entry_template.js +++ b/src/core_plugins/tests_bundle/tests_entry_template.js @@ -80,6 +80,24 @@ new CoreSystem({ enabled: true, enableExternalUrls: true }, + uiCapabilities: { + navLinks: { + myLink: true, + notMyLink: true, + }, + discover: { + showWriteControls: true + }, + visualize: { + showWriteControls: true + }, + dashboard: { + showWriteControls: true + }, + timelion: { + showWriteControls: true + }, + } }, }, rootDomElement, diff --git a/src/core_plugins/timelion/index.js b/src/core_plugins/timelion/index.js index e949223348aaf..f7ec695aaf4d7 100644 --- a/src/core_plugins/timelion/index.js +++ b/src/core_plugins/timelion/index.js @@ -44,9 +44,6 @@ export default function (kibana) { injectDefaultVars() { return { uiCapabilities: { - navLinks: { - timelion: true - }, timelion: { showWriteControls: true, } diff --git a/src/ui/public/chrome/directives/global_nav/app_switcher/__tests__/app_switcher.js b/src/ui/public/chrome/directives/global_nav/app_switcher/__tests__/app_switcher.js index dbb5efe1b06c6..c50bfa7129124 100644 --- a/src/ui/public/chrome/directives/global_nav/app_switcher/__tests__/app_switcher.js +++ b/src/ui/public/chrome/directives/global_nav/app_switcher/__tests__/app_switcher.js @@ -65,6 +65,7 @@ describe('appSwitcher directive', function () { const myLink = { active: true, title: 'myLink', + id: 'myLink', url: 'http://localhost:555/app/myApp', lastSubUrl: 'http://localhost:555/app/myApp#/lastSubUrl' }; @@ -72,6 +73,7 @@ describe('appSwitcher directive', function () { const notMyLink = { active: false, title: 'notMyLink', + id: 'notMyLink', url: 'http://localhost:555/app/notMyApp', lastSubUrl: 'http://localhost:555/app/notMyApp#/lastSubUrl' }; @@ -95,6 +97,7 @@ describe('appSwitcher directive', function () { const myLink = { active: false, title: 'myLink', + id: 'myLink', url: 'http://localhost:555/app/myApp', lastSubUrl: 'http://localhost:555/app/myApp#/lastSubUrl' }; @@ -102,6 +105,7 @@ describe('appSwitcher directive', function () { const notMyLink = { active: false, title: 'notMyLink', + id: 'notMyLink', url: 'http://localhost:555/app/notMyApp', lastSubUrl: 'http://localhost:555/app/notMyApp#/lastSubUrl' }; @@ -124,7 +128,7 @@ describe('appSwitcher directive', function () { describe('clicking a link with matching href but missing hash', function () { const url = 'http://localhost:555/app/myApp?query=1'; beforeEach(setup(url + '#/lastSubUrl', [ - { url: url } + { url: url, id: 'myLink' } ])); it('just prevents propagation (no reload)', function () { @@ -147,7 +151,7 @@ describe('appSwitcher directive', function () { describe('clicking a link that matches entire url', function () { const url = 'http://localhost:555/app/myApp#/lastSubUrl'; beforeEach(setup(url, [ - { url: url } + { url: url, id: 'myLink' } ])); it('calls window.location.reload and prevents propagation', function () { @@ -172,7 +176,7 @@ describe('appSwitcher directive', function () { const url = rootUrl + '#/lastSubUrl2'; beforeEach(setup(url + '#/lastSubUrl', [ - { url: url } + { url: url, id: 'myLink' } ])); it('calls window.location.reload and prevents propagation', function () { @@ -195,6 +199,7 @@ describe('appSwitcher directive', function () { describe('clicking a link with matching host', function () { beforeEach(setup('http://localhost:555/someOtherPath', [ { + id: 'myLink', active: true, url: 'http://localhost:555/app/myApp' } @@ -216,6 +221,7 @@ describe('appSwitcher directive', function () { describe('clicking a link with matching host and path', function () { beforeEach(setup('http://localhost:555/app/myApp?someQuery=true', [ { + id: 'myLink', active: true, url: 'http://localhost:555/app/myApp?differentQuery=true' } diff --git a/src/ui/ui_render/ui_render_mixin.js b/src/ui/ui_render/ui_render_mixin.js index 09e25f01b2fa9..963d2d0a5a8d5 100644 --- a/src/ui/ui_render/ui_render_mixin.js +++ b/src/ui/ui_render/ui_render_mixin.js @@ -35,6 +35,19 @@ export function uiRenderMixin(kbnServer, server, config) { ); } + function getInitialDefaultInjectedVars() { + const navLinkSpecs = server.getUiNavLinks(); + + return { + uiCapabilities: { + navLinks: navLinkSpecs.reduce((acc, navLinkSpec) => ({ + ...acc, + [navLinkSpec._id]: true + }), {}) + } + }; + } + let defaultInjectedVars = {}; kbnServer.afterPluginsInit(() => { const { defaultInjectedVarProviders = [] } = kbnServer.uiExports; @@ -44,7 +57,7 @@ export function uiRenderMixin(kbnServer, server, config) { allDefaults, fn(kbnServer.server, pluginSpec.readConfigValue(kbnServer.config, [])) ) - ), {}); + ), getInitialDefaultInjectedVars()); }); // render all views from ./views diff --git a/x-pack/plugins/apm/index.js b/x-pack/plugins/apm/index.js index f9685467b655d..f7eecc4d39531 100644 --- a/x-pack/plugins/apm/index.js +++ b/x-pack/plugins/apm/index.js @@ -63,6 +63,23 @@ export function apm(kibana) { }, init(server) { + server.plugins.xpack_main.registerFeature({ + id: 'apm', + name: 'APM', + icon: 'apmApp', + navLinkId: 'apm', + privileges: { + all: { + app: ['apm'], + savedObject: { + all: [], + read: ['config'] + }, + ui: [] + } + } + }); + initTransactionsApi(server); initTracesApi(server); initServicesApi(server); diff --git a/x-pack/plugins/canvas/init.js b/x-pack/plugins/canvas/init.js index 4ce65ff683024..3565db88ef92e 100644 --- a/x-pack/plugins/canvas/init.js +++ b/x-pack/plugins/canvas/init.js @@ -27,6 +27,31 @@ export default async function(server /*options*/) { }; }); + server.plugins.xpack_main.registerFeature({ + id: 'canvas', + name: 'Canvas', + icon: 'canvasApp', + navLinkId: 'canvas', + privileges: { + all: { + app: ['canvas'], + savedObject: { + all: ['canvas'], + read: ['config', 'index-pattern'], + }, + ui: [], + }, + read: { + app: ['canvas'], + savedObject: { + all: [], + read: ['config', 'index-pattern', 'canvas'], + }, + ui: [], + }, + }, + }); + // There are some common functions that use private APIs, load them here commonFunctions.forEach(func => functionsRegistry.register(func)); diff --git a/x-pack/plugins/graph/index.js b/x-pack/plugins/graph/index.js index b87bd3f37deeb..959ded232ec11 100644 --- a/x-pack/plugins/graph/index.js +++ b/x-pack/plugins/graph/index.js @@ -50,6 +50,31 @@ export function graph(kibana) { }; }); + server.plugins.xpack_main.registerFeature({ + id: 'graph', + name: 'Graph', + icon: 'graphApp', + navLinkId: 'graph', + privileges: { + all: { + app: ['graph'], + savedObject: { + all: ['graph-workspace'], + read: ['config', 'index-pattern'], + }, + ui: [], + }, + read: { + app: ['graph'], + savedObject: { + all: [], + read: ['config', 'index-pattern', 'graph-workspace'], + }, + ui: [], + } + } + }); + initServer(server); }, }); diff --git a/x-pack/plugins/ml/index.js b/x-pack/plugins/ml/index.js index c84bf9d56eb5b..bbbf9826bf5ab 100644 --- a/x-pack/plugins/ml/index.js +++ b/x-pack/plugins/ml/index.js @@ -63,6 +63,23 @@ export const ml = (kibana) => { xpackMainPlugin.info.feature(thisPlugin.id).registerLicenseCheckResultsGenerator(checkLicense); }); + xpackMainPlugin.registerFeature({ + id: 'ml', + name: 'Machine Learning', + icon: 'mlApp', + navLinkId: 'ml', + privileges: { + all: { + app: ['ml'], + savedObject: { + all: [], + read: ['config'] + }, + ui: [], + }, + } + }); + // Add server routes and initialize the plugin here const commonRouteConfig = { pre: [ diff --git a/x-pack/plugins/monitoring/init.js b/x-pack/plugins/monitoring/init.js index 53f5f4df11a38..4027ec3e804b6 100644 --- a/x-pack/plugins/monitoring/init.js +++ b/x-pack/plugins/monitoring/init.js @@ -57,8 +57,18 @@ export const init = (monitoringPlugin, server) => { xpackMainPlugin.registerFeature({ id: 'monitoring', name: 'Monitoring', - type: 'app', - icon: 'monitoringApp' + icon: 'monitoringApp', + navLinkId: 'monitoring', + privileges: { + all: { + app: ['monitoring'], + savedObject: { + all: [], + read: ['config'], + }, + ui: [], + }, + } }); const bulkUploader = initBulkUploader(kbnServer, server); diff --git a/x-pack/plugins/security/common/constants.js b/x-pack/plugins/security/common/constants.ts similarity index 100% rename from x-pack/plugins/security/common/constants.js rename to x-pack/plugins/security/common/constants.ts diff --git a/x-pack/plugins/security/index.js b/x-pack/plugins/security/index.js index cf04a5cf91d7f..c4a7b9080fc10 100644 --- a/x-pack/plugins/security/index.js +++ b/x-pack/plugins/security/index.js @@ -115,8 +115,10 @@ export const security = (kibana) => new kibana.Plugin({ // automatically assigned to all routes that don't contain an auth config. server.auth.default('session'); + const { savedObjects } = server; + // exposes server.plugins.security.authorization - const authorization = createAuthorizationService(server, xpackInfoFeature); + const authorization = createAuthorizationService(server, xpackInfoFeature, savedObjects.types, xpackMainPlugin); server.expose('authorization', deepFreeze(authorization)); watchStatusAndLicenseToInitialize(xpackMainPlugin, plugin, async (license) => { @@ -127,7 +129,6 @@ export const security = (kibana) => new kibana.Plugin({ const auditLogger = new SecurityAuditLogger(server.config(), new AuditLogger(server, 'security')); - const { savedObjects } = server; savedObjects.setScopedSavedObjectsClientFactory(({ request, }) => { @@ -192,10 +193,19 @@ export const security = (kibana) => new kibana.Plugin({ server.ext('onPostAuth', async function (req, h) { const path = req.path; + const { actions, checkPrivilegesWithRequest } = server.plugins.security.authorization; + const checkPrivileges = checkPrivilegesWithRequest(req); + // Enforce app restrictions if (path.startsWith('/app/')) { - // const appId = path.split('/', 3)[2]; - // TODO: feature access check + const appId = path.split('/', 3)[2]; + const appAction = actions.app.get(appId); + + // TODO: Check this at the specific space + const checkPrivilegesResponse = await checkPrivileges.globally(appAction); + if (!checkPrivilegesResponse.hasAllRequested) { + return Boom.notFound(); + } } // Enforce API restrictions for associated applications @@ -206,13 +216,11 @@ export const security = (kibana) => new kibana.Plugin({ if (actionTags.length > 0) { const feature = path.split('/', 3)[2]; - const actions = actionTags.map(tag => `api:${feature}/${tag.split(':', 2)[1]}`); - - const { checkPrivilegesWithRequest } = server.plugins.security.authorization; - const checkPrivileges = checkPrivilegesWithRequest(req); - const canExecute = await checkPrivileges.globally(actions); + const apiActions = actionTags.map(tag => actions.api.get(`${feature}/${tag.split(':', 2)[1]}`)); - if (!canExecute.hasAllRequested) { + // TODO: Check this at the specific space + const checkPrivilegesResponse = await checkPrivileges.globally(apiActions); + if (!checkPrivilegesResponse.hasAllRequested) { return Boom.notFound(); } } diff --git a/x-pack/plugins/security/server/lib/audit_logger.test.js b/x-pack/plugins/security/server/lib/audit_logger.test.js index 2157cf514755b..90294306999b8 100644 --- a/x-pack/plugins/security/server/lib/audit_logger.test.js +++ b/x-pack/plugins/security/server/lib/audit_logger.test.js @@ -46,7 +46,7 @@ describe(`#savedObjectsAuthorizationFailure`, () => { const username = 'foo-user'; const action = 'foo-action'; const types = [ 'foo-type-1', 'foo-type-2' ]; - const missing = [`action:saved_objects/${types[0]}/foo-action`, `action:saved_objects/${types[1]}/foo-action`]; + const missing = [`saved_object:${types[0]}/foo-action`, `saved_object:${types[1]}/foo-action`]; const args = { 'foo': 'bar', 'baz': 'quz', diff --git a/x-pack/plugins/security/server/lib/authorization/__snapshots__/actions.test.js.snap b/x-pack/plugins/security/server/lib/authorization/__snapshots__/actions.test.js.snap deleted file mode 100644 index d65733feb37d4..0000000000000 --- a/x-pack/plugins/security/server/lib/authorization/__snapshots__/actions.test.js.snap +++ /dev/null @@ -1,25 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`#getSavedObjectAction() action of "" throws error 1`] = `"action is required and must be a string"`; - -exports[`#getSavedObjectAction() action of {} throws error 1`] = `"action is required and must be a string"`; - -exports[`#getSavedObjectAction() action of 1 throws error 1`] = `"action is required and must be a string"`; - -exports[`#getSavedObjectAction() action of null throws error 1`] = `"action is required and must be a string"`; - -exports[`#getSavedObjectAction() action of true throws error 1`] = `"action is required and must be a string"`; - -exports[`#getSavedObjectAction() action of undefined throws error 1`] = `"action is required and must be a string"`; - -exports[`#getSavedObjectAction() type of "" throws error 1`] = `"type is required and must be a string"`; - -exports[`#getSavedObjectAction() type of {} throws error 1`] = `"type is required and must be a string"`; - -exports[`#getSavedObjectAction() type of 1 throws error 1`] = `"type is required and must be a string"`; - -exports[`#getSavedObjectAction() type of null throws error 1`] = `"type is required and must be a string"`; - -exports[`#getSavedObjectAction() type of true throws error 1`] = `"type is required and must be a string"`; - -exports[`#getSavedObjectAction() type of undefined throws error 1`] = `"type is required and must be a string"`; diff --git a/x-pack/plugins/security/server/lib/authorization/__snapshots__/check_privileges.test.js.snap b/x-pack/plugins/security/server/lib/authorization/__snapshots__/check_privileges.test.js.snap index 6a03134dc32ac..be5794d393be7 100644 --- a/x-pack/plugins/security/server/lib/authorization/__snapshots__/check_privileges.test.js.snap +++ b/x-pack/plugins/security/server/lib/authorization/__snapshots__/check_privileges.test.js.snap @@ -2,9 +2,9 @@ exports[`#checkPrivilegesAtSpace throws error when checking for login and user has login but doesn't have version 1`] = `[Error: Multiple versions of Kibana are running against the same Elasticsearch cluster, unable to authorize user.]`; -exports[`#checkPrivilegesAtSpace with a malformed Elasticsearch response throws a validation error when an extra privilege is present in the response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "space:space_1" fails because ["action:saved_objects/bar-type/get" is not allowed]]]]`; +exports[`#checkPrivilegesAtSpace with a malformed Elasticsearch response throws a validation error when an extra privilege is present in the response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "space:space_1" fails because ["saved_object:bar-type/get" is not allowed]]]]`; -exports[`#checkPrivilegesAtSpace with a malformed Elasticsearch response throws a validation error when privileges are missing in the response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "space:space_1" fails because [child "action:saved_objects/foo-type/get" fails because ["action:saved_objects/foo-type/get" is required]]]]]`; +exports[`#checkPrivilegesAtSpace with a malformed Elasticsearch response throws a validation error when privileges are missing in the response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "space:space_1" fails because [child "saved_object:foo-type/get" fails because ["saved_object:foo-type/get" is required]]]]]`; exports[`#checkPrivilegesAtSpaces throws error when Elasticsearch returns malformed response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "space:space_1" fails because [child "mock-action:version" fails because ["mock-action:version" is required]]]]]`; @@ -22,6 +22,6 @@ exports[`#checkPrivilegesGlobally throws error when Elasticsearch returns malfor exports[`#checkPrivilegesGlobally throws error when checking for login and user has login but doesn't have version 1`] = `[Error: Multiple versions of Kibana are running against the same Elasticsearch cluster, unable to authorize user.]`; -exports[`#checkPrivilegesGlobally with a malformed Elasticsearch response throws a validation error when an extra privilege is present in the response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "*" fails because ["action:saved_objects/bar-type/get" is not allowed]]]]`; +exports[`#checkPrivilegesGlobally with a malformed Elasticsearch response throws a validation error when an extra privilege is present in the response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "*" fails because ["saved_object:bar-type/get" is not allowed]]]]`; -exports[`#checkPrivilegesGlobally with a malformed Elasticsearch response throws a validation error when privileges are missing in the response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "*" fails because [child "action:saved_objects/foo-type/get" fails because ["action:saved_objects/foo-type/get" is required]]]]]`; +exports[`#checkPrivilegesGlobally with a malformed Elasticsearch response throws a validation error when privileges are missing in the response 1`] = `[Error: Invalid response received from Elasticsearch has_privilege endpoint. ValidationError: child "application" fails because [child "kibana-our_application" fails because [child "*" fails because [child "saved_object:foo-type/get" fails because ["saved_object:foo-type/get" is required]]]]]`; diff --git a/x-pack/plugins/security/server/lib/authorization/__snapshots__/privilege_serializer.test.ts.snap b/x-pack/plugins/security/server/lib/authorization/__snapshots__/privilege_serializer.test.ts.snap new file mode 100644 index 0000000000000..21b8108923a20 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/__snapshots__/privilege_serializer.test.ts.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`#deserializePrivilegeAssignedAtSpace throws Error if not prefixed with space_ 1`] = `"Unable to deserialize all, should have started with space_ or feature_"`; + +exports[`#deserializePrivilegeAssignedAtSpace throws Error if prefixed with space_ but not a reserved privilege 1`] = `"Unrecognized privilege assigned at space"`; + +exports[`#deserializePrivilegeAssignedGlobally throws Error if not prefixed with feature_ and isn't a reserved privilege 1`] = `"Unrecognized privilege assigned globally"`; + +exports[`#serializeGlobalPrivilege throws Error if unrecognized privilege used 1`] = `"Unrecognized global reserved privilege"`; + +exports[`#serializeSpaceReservedPrivilege throws Error if unrecognized privilege used 1`] = `"Unrecognized space reserved privilege"`; diff --git a/x-pack/plugins/security/server/lib/authorization/__snapshots__/privileges_serializer.test.ts.snap b/x-pack/plugins/security/server/lib/authorization/__snapshots__/privileges_serializer.test.ts.snap new file mode 100644 index 0000000000000..e3b35497622b9 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/__snapshots__/privileges_serializer.test.ts.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`features throws error if feature privileges would conflict 1`] = `"Detected conflicting feature privilege name: feature_foo_bar_baz"`; + +exports[`global throws Error if unrecognized global privilege is specified 1`] = `"Unrecognized global reserved privilege"`; + +exports[`space throws Error if unrecognized space privilege is specified 1`] = `"Unrecognized space reserved privilege"`; diff --git a/x-pack/plugins/security/server/lib/authorization/__snapshots__/resource_serializer.test.ts.snap b/x-pack/plugins/security/server/lib/authorization/__snapshots__/resource_serializer.test.ts.snap new file mode 100644 index 0000000000000..4cfdd5cce868a --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/__snapshots__/resource_serializer.test.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`#deserializeSpaceResource throws error if resource doesn't start with space: 1`] = `"Resource should have started with space:"`; diff --git a/x-pack/plugins/security/server/lib/authorization/__snapshots__/space_application_privileges_serializer.test.js.snap b/x-pack/plugins/security/server/lib/authorization/__snapshots__/space_application_privileges_serializer.test.js.snap deleted file mode 100644 index 0a943137989ec..0000000000000 --- a/x-pack/plugins/security/server/lib/authorization/__snapshots__/space_application_privileges_serializer.test.js.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`#privilege #deserialize throws error if privilege doesn't start with space_ 1`] = `"Space privilege should have started with space_"`; - -exports[`#resource #deserialize throws error if resource doesn't start with space: 1`] = `"Resource should have started with space:"`; diff --git a/x-pack/plugins/security/server/lib/authorization/actions.js b/x-pack/plugins/security/server/lib/authorization/actions.js deleted file mode 100644 index e47e1edd5d4c4..0000000000000 --- a/x-pack/plugins/security/server/lib/authorization/actions.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import { isString } from 'lodash'; - -export function actionsFactory(config) { - const kibanaVersion = config.get('pkg.version'); - - return { - getSavedObjectAction(type, action) { - if (!type || !isString(type)) { - throw new Error('type is required and must be a string'); - } - - if (!action || !isString(action)) { - throw new Error('action is required and must be a string'); - } - - return `action:saved_objects/${type}/${action}`; - }, - login: `action:login`, - version: `version:${kibanaVersion}`, - manageSpaces: 'action:manage_spaces/*', - }; -} diff --git a/x-pack/plugins/security/server/lib/authorization/actions.test.js b/x-pack/plugins/security/server/lib/authorization/actions.test.js deleted file mode 100644 index 9ae2265557d21..0000000000000 --- a/x-pack/plugins/security/server/lib/authorization/actions.test.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { actionsFactory } from './actions'; - -const createMockConfig = (settings = {}) => { - const mockConfig = { - get: jest.fn() - }; - - mockConfig.get.mockImplementation(key => settings[key]); - - return mockConfig; -}; - -describe('#login', () => { - test('returns action:login', () => { - const mockConfig = createMockConfig(); - - const actions = actionsFactory(mockConfig); - - expect(actions.login).toEqual('action:login'); - }); -}); - -describe('#version', () => { - test(`returns version:\${config.get('pkg.version')}`, () => { - const version = 'mock-version'; - const mockConfig = createMockConfig({ 'pkg.version': version }); - - const actions = actionsFactory(mockConfig); - - expect(actions.version).toEqual(`version:${version}`); - }); -}); - -describe('#getSavedObjectAction()', () => { - test('uses type and action to build action', () => { - const mockConfig = createMockConfig(); - const actions = actionsFactory(mockConfig); - const type = 'saved-object-type'; - const action = 'saved-object-action'; - - const result = actions.getSavedObjectAction(type, action); - - expect(result).toEqual(`action:saved_objects/${type}/${action}`); - }); - - [null, undefined, '', 1, true, {}].forEach(type => { - test(`type of ${JSON.stringify(type)} throws error`, () => { - const mockConfig = createMockConfig(); - const actions = actionsFactory(mockConfig); - - expect(() => actions.getSavedObjectAction(type, 'saved-object-action')).toThrowErrorMatchingSnapshot(); - }); - }); - - [null, undefined, '', 1, true, {}].forEach(action => { - test(`action of ${JSON.stringify(action)} throws error`, () => { - const mockConfig = createMockConfig(); - const actions = actionsFactory(mockConfig); - - expect(() => actions.getSavedObjectAction('saved-object-type', action)).toThrowErrorMatchingSnapshot(); - }); - }); - - describe('#manageSpaces', () => { - test('returns action:manage_spaces/*', () => { - const mockConfig = createMockConfig(); - - const actions = actionsFactory(mockConfig); - - expect(actions.manageSpaces).toEqual('action:manage_spaces/*'); - }); - }); -}); diff --git a/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/api.test.ts.snap b/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/api.test.ts.snap new file mode 100644 index 0000000000000..b2af716907e7f --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/api.test.ts.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`#get operation of "" throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of {} throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of 1 throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of null throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of true throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of undefined throws error 1`] = `"operation is required and must be a string"`; diff --git a/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/app.test.ts.snap b/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/app.test.ts.snap new file mode 100644 index 0000000000000..3981e4cd2c767 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/app.test.ts.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`#get appId of "" throws error 1`] = `"appId is required and must be a string"`; + +exports[`#get appId of {} throws error 1`] = `"appId is required and must be a string"`; + +exports[`#get appId of 1 throws error 1`] = `"appId is required and must be a string"`; + +exports[`#get appId of null throws error 1`] = `"appId is required and must be a string"`; + +exports[`#get appId of true throws error 1`] = `"appId is required and must be a string"`; + +exports[`#get appId of undefined throws error 1`] = `"appId is required and must be a string"`; diff --git a/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/saved_object.test.ts.snap b/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/saved_object.test.ts.snap new file mode 100644 index 0000000000000..45cd5067f6ef4 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/saved_object.test.ts.snap @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`#allOperations if type of "" included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations if type of {} included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations if type of 1 included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations if type of null included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations if type of true included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations if type of undefined included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations type of "" throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations type of {} throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations type of 1 throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations type of null throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations type of true throws error 1`] = `"type is required and must be a string"`; + +exports[`#allOperations type of undefined throws error 1`] = `"type is required and must be a string"`; + +exports[`#get operation of "" throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of {} throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of 1 throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of null throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of true throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get operation of undefined throws error 1`] = `"operation is required and must be a string"`; + +exports[`#get type of "" throws error 1`] = `"type is required and must be a string"`; + +exports[`#get type of {} throws error 1`] = `"type is required and must be a string"`; + +exports[`#get type of 1 throws error 1`] = `"type is required and must be a string"`; + +exports[`#get type of null throws error 1`] = `"type is required and must be a string"`; + +exports[`#get type of true throws error 1`] = `"type is required and must be a string"`; + +exports[`#get type of undefined throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations if type of "" included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations if type of {} included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations if type of 1 included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations if type of null included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations if type of true included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations if type of undefined included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations type of "" throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations type of {} throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations type of 1 throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations type of null throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations type of true throws error 1`] = `"type is required and must be a string"`; + +exports[`#readOperations type of undefined throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations if type of "" included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations if type of {} included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations if type of 1 included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations if type of null included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations if type of true included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations if type of undefined included in types throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations type of "" throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations type of {} throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations type of 1 throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations type of null throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations type of true throws error 1`] = `"type is required and must be a string"`; + +exports[`#writeOperations type of undefined throws error 1`] = `"type is required and must be a string"`; diff --git a/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/ui.test.ts.snap b/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/ui.test.ts.snap new file mode 100644 index 0000000000000..558dbabd0c3fe --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/__snapshots__/ui.test.ts.snap @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`#get featureId of "" throws error 1`] = `"featureId is required and must be a string"`; + +exports[`#get featureId of {} throws error 1`] = `"featureId is required and must be a string"`; + +exports[`#get featureId of 1 throws error 1`] = `"featureId is required and must be a string"`; + +exports[`#get featureId of null throws error 1`] = `"featureId is required and must be a string"`; + +exports[`#get featureId of true throws error 1`] = `"featureId is required and must be a string"`; + +exports[`#get featureId of undefined throws error 1`] = `"featureId is required and must be a string"`; + +exports[`#get uiCapability of "" throws error 1`] = `"uiCapability is required and must be a string"`; + +exports[`#get uiCapability of {} throws error 1`] = `"uiCapability is required and must be a string"`; + +exports[`#get uiCapability of 1 throws error 1`] = `"uiCapability is required and must be a string"`; + +exports[`#get uiCapability of null throws error 1`] = `"uiCapability is required and must be a string"`; + +exports[`#get uiCapability of true throws error 1`] = `"uiCapability is required and must be a string"`; + +exports[`#get uiCapability of undefined throws error 1`] = `"uiCapability is required and must be a string"`; diff --git a/x-pack/plugins/security/server/lib/authorization/actions/actions.test.ts b/x-pack/plugins/security/server/lib/authorization/actions/actions.test.ts new file mode 100644 index 0000000000000..51c88c2f87668 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/actions.test.ts @@ -0,0 +1,38 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { actionsFactory } from '.'; + +const createMockConfig = (settings: Record = {}) => { + const mockConfig = { + get: jest.fn(), + }; + + mockConfig.get.mockImplementation(key => settings[key]); + + return mockConfig; +}; + +describe('#login', () => { + test('returns login:', () => { + const mockConfig = createMockConfig(); + + const actions = actionsFactory(mockConfig); + + expect(actions.login).toBe('login:'); + }); +}); + +describe('#version', () => { + test("returns `version:${config.get('pkg.version')}`", () => { + const version = 'mock-version'; + const mockConfig = createMockConfig({ 'pkg.version': version }); + + const actions = actionsFactory(mockConfig); + + expect(actions.version).toBe(`version:${version}`); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/actions/actions.ts b/x-pack/plugins/security/server/lib/authorization/actions/actions.ts new file mode 100644 index 0000000000000..66fee5736c344 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/actions.ts @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ApiActions } from './api'; +import { AppActions } from './app'; +import { SavedObjectActions } from './saved_object'; +import { SpaceActions } from './space'; +import { UIActions } from './ui'; + +export class Actions { + public api = new ApiActions(); + + public app = new AppActions(); + + public login = 'login:'; + + public savedObject = new SavedObjectActions(); + + public space = new SpaceActions(); + + public ui = new UIActions(); + + public version = `version:${this.versionNumber}`; + constructor(private versionNumber: string) {} +} + +export function actionsFactory(config: any) { + return new Actions(config.get('pkg.version')); +} diff --git a/x-pack/plugins/security/server/lib/authorization/actions/api.test.ts b/x-pack/plugins/security/server/lib/authorization/actions/api.test.ts new file mode 100644 index 0000000000000..1cf5ba0c9444e --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/api.test.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ApiActions } from './api'; + +describe('#all', () => { + test(`returns api:*`, () => { + const apiActions = new ApiActions(); + expect(apiActions.all).toBe('api:*'); + }); +}); + +describe('#get', () => { + [null, undefined, '', 1, true, {}].forEach((operation: any) => { + test(`operation of ${JSON.stringify(operation)} throws error`, () => { + const apiActions = new ApiActions(); + expect(() => apiActions.get(operation)).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns `api:${operation}`', () => { + const apiActions = new ApiActions(); + expect(apiActions.get('foo-operation')).toBe('api:foo-operation'); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/actions/api.ts b/x-pack/plugins/security/server/lib/authorization/actions/api.ts new file mode 100644 index 0000000000000..a86f586a6aa48 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/api.ts @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { isString } from 'lodash'; + +const prefix = 'api:'; + +export class ApiActions { + public all = `${prefix}*`; + + public get(operation: string) { + if (!operation || !isString(operation)) { + throw new Error('operation is required and must be a string'); + } + + return `${prefix}${operation}`; + } +} diff --git a/x-pack/plugins/security/server/lib/authorization/actions/app.test.ts b/x-pack/plugins/security/server/lib/authorization/actions/app.test.ts new file mode 100644 index 0000000000000..3461ad9953ab0 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/app.test.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { AppActions } from './app'; + +describe('#all', () => { + test(`returns app:*`, () => { + const appActions = new AppActions(); + expect(appActions.all).toBe('app:*'); + }); +}); + +describe('#get', () => { + [null, undefined, '', 1, true, {}].forEach((appid: any) => { + test(`appId of ${JSON.stringify(appid)} throws error`, () => { + const appActions = new AppActions(); + expect(() => appActions.get(appid)).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns `app:${appId}`', () => { + const appActions = new AppActions(); + expect(appActions.get('foo-app')).toBe('app:foo-app'); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/actions/app.ts b/x-pack/plugins/security/server/lib/authorization/actions/app.ts new file mode 100644 index 0000000000000..ac3fcc4ff5380 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/app.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { isString } from 'lodash'; +const prefix = `app:`; + +export class AppActions { + public all = `${prefix}*`; + + public get(appId: string) { + if (!appId || !isString(appId)) { + throw new Error('appId is required and must be a string'); + } + + return `${prefix}${appId}`; + } +} diff --git a/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.test.ts b/x-pack/plugins/security/server/lib/authorization/actions/index.ts similarity index 60% rename from x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.test.ts rename to x-pack/plugins/security/server/lib/authorization/actions/index.ts index a6b3796bf9424..34af70cd479e3 100644 --- a/x-pack/plugins/spaces/server/lib/toggle_ui_capabilities.test.ts +++ b/x-pack/plugins/security/server/lib/authorization/actions/index.ts @@ -4,7 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -describe('toggleUiCapabilities', () => { - // TODO: implement tests once spaces have the concept of disabled features - it('should be tested', () => null); -}); +export { Actions, actionsFactory } from './actions'; diff --git a/x-pack/plugins/security/server/lib/authorization/actions/saved_object.test.ts b/x-pack/plugins/security/server/lib/authorization/actions/saved_object.test.ts new file mode 100644 index 0000000000000..f03c8f85687a1 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/saved_object.test.ts @@ -0,0 +1,169 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { SavedObjectActions } from './saved_object'; + +describe('#all', () => { + test(`returns saved_object:*`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(savedObjectActions.all).toBe('saved_object:*'); + }); +}); + +describe('#get', () => { + [null, undefined, '', 1, true, {}].forEach((type: any) => { + test(`type of ${JSON.stringify(type)} throws error`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(() => savedObjectActions.get(type, 'foo-action')).toThrowErrorMatchingSnapshot(); + }); + }); + + [null, undefined, '', 1, true, {}].forEach((operation: any) => { + test(`operation of ${JSON.stringify(operation)} throws error`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(() => savedObjectActions.get('foo-type', operation)).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns `saved_object:${type}/${operation}`', () => { + const savedObjectActions = new SavedObjectActions(); + expect(savedObjectActions.get('foo-type', 'bar-operation')).toBe( + 'saved_object:foo-type/bar-operation' + ); + }); +}); + +describe('#allOperations', () => { + [null, undefined, '', 1, true, {}].forEach((type: any) => { + test(`type of ${JSON.stringify(type)} throws error`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(() => savedObjectActions.allOperations(type)).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns all operations for a singular type', () => { + const savedObjectActions = new SavedObjectActions(); + expect(savedObjectActions.allOperations('foo-type')).toEqual([ + 'saved_object:foo-type/bulk_get', + 'saved_object:foo-type/get', + 'saved_object:foo-type/find', + 'saved_object:foo-type/create', + 'saved_object:foo-type/bulk_create', + 'saved_object:foo-type/update', + 'saved_object:foo-type/delete', + ]); + }); + + [null, undefined, '', 1, true, {}].forEach((type: any) => { + test(`if type of ${JSON.stringify(type)} included in types throws error`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(() => + savedObjectActions.allOperations([type, 'foo-type']) + ).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns all operations for multiple types', () => { + const savedObjectActions = new SavedObjectActions(); + expect(savedObjectActions.allOperations(['foo-type', 'bar-type'])).toEqual([ + 'saved_object:foo-type/bulk_get', + 'saved_object:foo-type/get', + 'saved_object:foo-type/find', + 'saved_object:foo-type/create', + 'saved_object:foo-type/bulk_create', + 'saved_object:foo-type/update', + 'saved_object:foo-type/delete', + 'saved_object:bar-type/bulk_get', + 'saved_object:bar-type/get', + 'saved_object:bar-type/find', + 'saved_object:bar-type/create', + 'saved_object:bar-type/bulk_create', + 'saved_object:bar-type/update', + 'saved_object:bar-type/delete', + ]); + }); +}); + +describe('#readOperations', () => { + [null, undefined, '', 1, true, {}].forEach((type: any) => { + test(`type of ${JSON.stringify(type)} throws error`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(() => savedObjectActions.readOperations(type)).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns read operations for a singular type', () => { + const savedObjectActions = new SavedObjectActions(); + expect(savedObjectActions.readOperations('foo-type')).toEqual([ + 'saved_object:foo-type/bulk_get', + 'saved_object:foo-type/get', + 'saved_object:foo-type/find', + ]); + }); + + [null, undefined, '', 1, true, {}].forEach((type: any) => { + test(`if type of ${JSON.stringify(type)} included in types throws error`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(() => + savedObjectActions.readOperations([type, 'foo-type']) + ).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns read operations for multiple types', () => { + const savedObjectActions = new SavedObjectActions(); + expect(savedObjectActions.readOperations(['foo-type', 'bar-type'])).toEqual([ + 'saved_object:foo-type/bulk_get', + 'saved_object:foo-type/get', + 'saved_object:foo-type/find', + 'saved_object:bar-type/bulk_get', + 'saved_object:bar-type/get', + 'saved_object:bar-type/find', + ]); + }); +}); + +describe('#writeOperations', () => { + [null, undefined, '', 1, true, {}].forEach((type: any) => { + test(`type of ${JSON.stringify(type)} throws error`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(() => savedObjectActions.writeOperations(type)).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns write operations for a singular type', () => { + const savedObjectActions = new SavedObjectActions(); + expect(savedObjectActions.writeOperations('foo-type')).toEqual([ + 'saved_object:foo-type/create', + 'saved_object:foo-type/bulk_create', + 'saved_object:foo-type/update', + 'saved_object:foo-type/delete', + ]); + }); + + [null, undefined, '', 1, true, {}].forEach((type: any) => { + test(`if type of ${JSON.stringify(type)} included in types throws error`, () => { + const savedObjectActions = new SavedObjectActions(); + expect(() => + savedObjectActions.writeOperations([type, 'foo-type']) + ).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns write operations for multiple types', () => { + const savedObjectActions = new SavedObjectActions(); + expect(savedObjectActions.writeOperations(['foo-type', 'bar-type'])).toEqual([ + 'saved_object:foo-type/create', + 'saved_object:foo-type/bulk_create', + 'saved_object:foo-type/update', + 'saved_object:foo-type/delete', + 'saved_object:bar-type/create', + 'saved_object:bar-type/bulk_create', + 'saved_object:bar-type/update', + 'saved_object:bar-type/delete', + ]); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/actions/saved_object.ts b/x-pack/plugins/security/server/lib/authorization/actions/saved_object.ts new file mode 100644 index 0000000000000..2920c9950372c --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/saved_object.ts @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { isString } from 'lodash'; + +const coerceToArray = (itemOrItems: T | T[]): T[] => { + return Array.isArray(itemOrItems) ? itemOrItems : [itemOrItems]; +}; + +export class SavedObjectActions { + private static readOperations: string[] = ['bulk_get', 'get', 'find']; + private static writeOperations: string[] = ['create', 'bulk_create', 'update', 'delete']; + private static allOperations: string[] = [ + ...SavedObjectActions.readOperations, + ...SavedObjectActions.writeOperations, + ]; + + public all = `saved_object:*`; + + public get(type: string, operation: string): string { + if (!type || !isString(type)) { + throw new Error('type is required and must be a string'); + } + + if (!operation || !isString(operation)) { + throw new Error('operation is required and must be a string'); + } + + return `saved_object:${type}/${operation}`; + } + + public allOperations(typeOrTypes: string | string[]): string[] { + const types = coerceToArray(typeOrTypes); + return this.build(types, SavedObjectActions.allOperations); + } + + public readOperations(typeOrTypes: string | string[]): string[] { + const types = coerceToArray(typeOrTypes); + return this.build(types, SavedObjectActions.readOperations); + } + + public writeOperations(typeOrTypes: string | string[]): string[] { + const types = coerceToArray(typeOrTypes); + return this.build(types, SavedObjectActions.writeOperations); + } + + private build(types: string[], methods: string[]) { + return types + .map(type => methods.map(method => this.get(type, method))) + .reduce((acc, typeActions) => [...acc, ...typeActions], []); + } +} diff --git a/x-pack/plugins/security/server/lib/authorization/actions/space.test.ts b/x-pack/plugins/security/server/lib/authorization/actions/space.test.ts new file mode 100644 index 0000000000000..63f905fbed5f6 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/space.test.ts @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { SpaceActions } from './space'; + +describe(`#manage`, () => { + test(`returns space:manage`, () => { + const spaceActions = new SpaceActions(); + expect(spaceActions.manage).toBe('space:manage'); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/actions/space.ts b/x-pack/plugins/security/server/lib/authorization/actions/space.ts new file mode 100644 index 0000000000000..3d17f56606dda --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/space.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export class SpaceActions { + public manage = `space:manage`; +} diff --git a/x-pack/plugins/security/server/lib/authorization/actions/ui.test.ts b/x-pack/plugins/security/server/lib/authorization/actions/ui.test.ts new file mode 100644 index 0000000000000..0b02dccf3fe52 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/ui.test.ts @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { UIActions } from './ui'; + +describe('#all', () => { + test('returns ui:*', () => { + const uiActions = new UIActions(); + expect(uiActions.all).toBe('ui:*'); + }); +}); + +describe('#allNavlinks', () => { + test('returns ui:navLinks/*', () => { + const uiActions = new UIActions(); + expect(uiActions.allNavLinks).toBe('ui:navLinks/*'); + }); +}); + +describe('#get', () => { + [null, undefined, '', 1, true, {}].forEach((featureId: any) => { + test(`featureId of ${JSON.stringify(featureId)} throws error`, () => { + const uiActions = new UIActions(); + expect(() => uiActions.get(featureId, 'foo-capability')).toThrowErrorMatchingSnapshot(); + }); + }); + + [null, undefined, '', 1, true, {}].forEach((uiCapability: any) => { + test(`uiCapability of ${JSON.stringify(uiCapability)} throws error`, () => { + const uiActions = new UIActions(); + expect(() => uiActions.get('foo', uiCapability)).toThrowErrorMatchingSnapshot(); + }); + }); + + test('returns `ui:${featureId}/${uiCapaility}`', () => { + const uiActions = new UIActions(); + expect(uiActions.get('foo', 'foo-capability')).toBe('ui:foo/foo-capability'); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/actions/ui.ts b/x-pack/plugins/security/server/lib/authorization/actions/ui.ts new file mode 100644 index 0000000000000..e2c5c35ac9510 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/actions/ui.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { isString } from 'lodash'; +const prefix = 'ui:'; + +export class UIActions { + public all = `${prefix}*`; + public allNavLinks = `${prefix}navLinks/*`; + + public get(featureId: string, uiCapability: string) { + if (!featureId || !isString(featureId)) { + throw new Error('featureId is required and must be a string'); + } + + if (!uiCapability || !isString(uiCapability)) { + throw new Error('uiCapability is required and must be a string'); + } + + return `${prefix}${featureId}/${uiCapability}`; + } +} diff --git a/x-pack/plugins/security/server/lib/authorization/check_privileges.js b/x-pack/plugins/security/server/lib/authorization/check_privileges.js index bdd9781f97771..d7038ac1c3edf 100644 --- a/x-pack/plugins/security/server/lib/authorization/check_privileges.js +++ b/x-pack/plugins/security/server/lib/authorization/check_privileges.js @@ -6,7 +6,7 @@ import { pick, transform, uniq } from 'lodash'; import { GLOBAL_RESOURCE } from '../../../common/constants'; -import { spaceApplicationPrivilegesSerializer } from './space_application_privileges_serializer'; +import { ResourceSerializer } from './resource_serializer'; import { validateEsPrivilegeResponse } from './validate_es_response'; export function checkPrivilegesWithRequestFactory(actions, application, shieldClient) { @@ -60,22 +60,19 @@ export function checkPrivilegesWithRequestFactory(actions, application, shieldCl }; return { - // TODO: checkPrivileges.atResources isn't necessary once we have the ES API to list all privileges - // this should be removed when we switch to this API, and is not covered by unit tests currently - atResources: checkPrivilegesAtResources, async atSpace(spaceId, privilegeOrPrivileges) { - const spaceResource = spaceApplicationPrivilegesSerializer.resource.serialize(spaceId); + const spaceResource = ResourceSerializer.serializeSpaceResource(spaceId); return await checkPrivilegesAtResource(spaceResource, privilegeOrPrivileges); }, async atSpaces(spaceIds, privilegeOrPrivileges) { - const spaceResources = spaceIds.map(spaceId => spaceApplicationPrivilegesSerializer.resource.serialize(spaceId)); + const spaceResources = spaceIds.map(spaceId => ResourceSerializer.serializeSpaceResource(spaceId)); const { hasAllRequested, username, resourcePrivileges } = await checkPrivilegesAtResources(spaceResources, privilegeOrPrivileges); return { hasAllRequested, username, // we need to turn the resource responses back into the space ids spacePrivileges: transform(resourcePrivileges, (result, value, key) => { - result[spaceApplicationPrivilegesSerializer.resource.deserialize(key)] = value; + result[ResourceSerializer.deserializeSpaceResource(key)] = value; }), }; diff --git a/x-pack/plugins/security/server/lib/authorization/check_privileges.test.js b/x-pack/plugins/security/server/lib/authorization/check_privileges.test.js index f74528d4fd20d..49b8e104c54d1 100644 --- a/x-pack/plugins/security/server/lib/authorization/check_privileges.test.js +++ b/x-pack/plugins/security/server/lib/authorization/check_privileges.test.js @@ -142,7 +142,7 @@ describe('#checkPrivilegesAtSpace', () => { checkPrivilegesAtSpaceTest(`successful when checking for two actions and the user has both`, { spaceId: 'space_1', - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: true, username: 'foo-username', @@ -151,8 +151,8 @@ describe('#checkPrivilegesAtSpace', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -161,15 +161,15 @@ describe('#checkPrivilegesAtSpace', () => { hasAllRequested: true, username: 'foo-username', privileges: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } }, }); checkPrivilegesAtSpaceTest(`failure when checking for two actions and the user has only one`, { spaceId: 'space_1', - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -178,8 +178,8 @@ describe('#checkPrivilegesAtSpace', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -188,8 +188,8 @@ describe('#checkPrivilegesAtSpace', () => { hasAllRequested: false, username: 'foo-username', privileges: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } }, }); @@ -197,7 +197,7 @@ describe('#checkPrivilegesAtSpace', () => { describe('with a malformed Elasticsearch response', () => { checkPrivilegesAtSpaceTest(`throws a validation error when an extra privilege is present in the response`, { spaceId: 'space_1', - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -206,8 +206,8 @@ describe('#checkPrivilegesAtSpace', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -217,7 +217,7 @@ describe('#checkPrivilegesAtSpace', () => { checkPrivilegesAtSpaceTest(`throws a validation error when privileges are missing in the response`, { spaceId: 'space_1', - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -372,19 +372,19 @@ describe('#checkPrivilegesAtSpaces', () => { checkPrivilegesAtSpacesTest(`throws error when Elasticsearch returns malformed response`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: true, username: 'foo-username', application: { [application]: { 'space:space_1': { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, }, 'space:space_2': { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -394,7 +394,7 @@ describe('#checkPrivilegesAtSpaces', () => { checkPrivilegesAtSpacesTest(`successful when checking for two actions at two spaces and user has it all`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: true, username: 'foo-username', @@ -403,14 +403,14 @@ describe('#checkPrivilegesAtSpaces', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, }, 'space:space_2': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -420,12 +420,12 @@ describe('#checkPrivilegesAtSpaces', () => { username: 'foo-username', spacePrivileges: { space_1: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, }, space_2: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } }, @@ -433,7 +433,7 @@ describe('#checkPrivilegesAtSpaces', () => { checkPrivilegesAtSpacesTest(`failure when checking for two actions at two spaces and user has one action at one space`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -442,14 +442,14 @@ describe('#checkPrivilegesAtSpaces', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: false, }, 'space:space_2': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: false, } } } @@ -459,12 +459,12 @@ describe('#checkPrivilegesAtSpaces', () => { username: 'foo-username', spacePrivileges: { space_1: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: false, }, space_2: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: false, } } }, @@ -472,7 +472,7 @@ describe('#checkPrivilegesAtSpaces', () => { checkPrivilegesAtSpacesTest(`failure when checking for two actions at two spaces and user has two actions at one space`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -481,14 +481,14 @@ describe('#checkPrivilegesAtSpaces', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, }, 'space:space_2': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: false, } } } @@ -498,12 +498,12 @@ describe('#checkPrivilegesAtSpaces', () => { username: 'foo-username', spacePrivileges: { space_1: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, }, space_2: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: false, } } }, @@ -512,7 +512,7 @@ describe('#checkPrivilegesAtSpaces', () => { checkPrivilegesAtSpacesTest( `failure when checking for two actions at two spaces and user has two actions at one space & one action at the other`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -521,14 +521,14 @@ describe('#checkPrivilegesAtSpaces', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, }, 'space:space_2': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: false, } } } @@ -538,12 +538,12 @@ describe('#checkPrivilegesAtSpaces', () => { username: 'foo-username', spacePrivileges: { space_1: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, }, space_2: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: false, } } }, @@ -552,7 +552,7 @@ describe('#checkPrivilegesAtSpaces', () => { describe('with a malformed Elasticsearch response', () => { checkPrivilegesAtSpacesTest(`throws a validation error when an extra privilege is present in the response`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -561,13 +561,13 @@ describe('#checkPrivilegesAtSpaces', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: true, }, 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, } } } @@ -577,7 +577,7 @@ describe('#checkPrivilegesAtSpaces', () => { checkPrivilegesAtSpacesTest(`throws a validation error when privileges are missing in the response`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -590,7 +590,7 @@ describe('#checkPrivilegesAtSpaces', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, } } } @@ -600,7 +600,7 @@ describe('#checkPrivilegesAtSpaces', () => { checkPrivilegesAtSpacesTest(`throws a validation error when an extra space is present in the response`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -609,17 +609,17 @@ describe('#checkPrivilegesAtSpaces', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, }, 'space:space_2': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, }, 'space:space_3': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, }, } } @@ -629,7 +629,7 @@ describe('#checkPrivilegesAtSpaces', () => { checkPrivilegesAtSpacesTest(`throws a validation error when an a space is missing in the response`, { spaceIds: ['space_1', 'space_2'], - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -638,7 +638,7 @@ describe('#checkPrivilegesAtSpaces', () => { 'space:space_1': { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[0]}/get`]: false, } } } @@ -759,15 +759,15 @@ describe('#checkPrivilegesGlobally', () => { }); checkPrivilegesGloballyTest(`throws error when Elasticsearch returns malformed response`, { - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', application: { [application]: { [GLOBAL_RESOURCE]: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -776,7 +776,7 @@ describe('#checkPrivilegesGlobally', () => { }); checkPrivilegesGloballyTest(`successful when checking for two actions and the user has both`, { - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: true, username: 'foo-username', @@ -785,8 +785,8 @@ describe('#checkPrivilegesGlobally', () => { [GLOBAL_RESOURCE]: { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -795,14 +795,14 @@ describe('#checkPrivilegesGlobally', () => { hasAllRequested: true, username: 'foo-username', privileges: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: true, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: true, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } }, }); checkPrivilegesGloballyTest(`failure when checking for two actions and the user has only one`, { - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`, `action:saved_objects/${savedObjectTypes[1]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`, `saved_object:${savedObjectTypes[1]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -811,8 +811,8 @@ describe('#checkPrivilegesGlobally', () => { [GLOBAL_RESOURCE]: { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -821,15 +821,15 @@ describe('#checkPrivilegesGlobally', () => { hasAllRequested: false, username: 'foo-username', privileges: { - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } }, }); describe('with a malformed Elasticsearch response', () => { checkPrivilegesGloballyTest(`throws a validation error when an extra privilege is present in the response`, { - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', @@ -838,8 +838,8 @@ describe('#checkPrivilegesGlobally', () => { [GLOBAL_RESOURCE]: { [mockActions.login]: true, [mockActions.version]: true, - [`action:saved_objects/${savedObjectTypes[0]}/get`]: false, - [`action:saved_objects/${savedObjectTypes[1]}/get`]: true, + [`saved_object:${savedObjectTypes[0]}/get`]: false, + [`saved_object:${savedObjectTypes[1]}/get`]: true, } } } @@ -848,7 +848,7 @@ describe('#checkPrivilegesGlobally', () => { }); checkPrivilegesGloballyTest(`throws a validation error when privileges are missing in the response`, { - privilegeOrPrivileges: [`action:saved_objects/${savedObjectTypes[0]}/get`], + privilegeOrPrivileges: [`saved_object:${savedObjectTypes[0]}/get`], esHasPrivilegesResponse: { has_all_requested: false, username: 'foo-username', diff --git a/x-pack/plugins/security/server/lib/authorization/features_privileges_builder.ts b/x-pack/plugins/security/server/lib/authorization/features_privileges_builder.ts new file mode 100644 index 0000000000000..c17ca8d9d9320 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/features_privileges_builder.ts @@ -0,0 +1,77 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Dictionary, flatten, mapValues } from 'lodash'; +import { Feature } from '../../../../xpack_main/types'; +import { Actions } from './actions'; + +export type FeaturesPrivileges = Record>; + +export class FeaturesPrivilegesBuilder { + private actions: Actions; + + constructor(actions: Actions) { + this.actions = actions; + } + + public buildFeaturesPrivileges(features: Feature[]): FeaturesPrivileges { + return features.reduce((acc: FeaturesPrivileges, feature: Feature) => { + acc[feature.id] = this.buildFeaturePrivileges(feature); + return acc; + }, {}); + } + + public getApiReadActions(features: Feature[]): string[] { + return flatten( + features.map(feature => { + const { privileges } = feature; + if (!privileges || !privileges.read || !privileges.read.api) { + return []; + } + + return feature.privileges.read.api!.map(api => this.actions.api.get(api)); + }) + ); + } + + public getUIReadActions(features: Feature[]): string[] { + return flatten( + features.map(feature => { + const { privileges } = feature; + if (!privileges || !privileges.read || !privileges.read.ui) { + return []; + } + + return feature.privileges.read.ui!.map(uiCapability => + this.actions.ui.get(feature.id, uiCapability) + ); + }) + ); + } + + private buildFeaturePrivileges(feature: Feature): Dictionary { + return mapValues(feature.privileges, privilegeDefinition => [ + this.actions.login, + this.actions.version, + ...(privilegeDefinition.api + ? privilegeDefinition.api.map(api => this.actions.api.get(api)) + : []), + ...privilegeDefinition.app.map(appId => this.actions.app.get(appId)), + ...flatten( + privilegeDefinition.savedObject.all.map(types => + this.actions.savedObject.allOperations(types) + ) + ), + ...flatten( + privilegeDefinition.savedObject.read.map(types => + this.actions.savedObject.readOperations(types) + ) + ), + ...privilegeDefinition.ui.map(ui => this.actions.ui.get(feature.id, ui)), + ...(feature.navLinkId ? [this.actions.ui.get('navLinks', feature.navLinkId)] : []), + ]); + } +} diff --git a/x-pack/plugins/security/server/lib/authorization/features_privileges_builders.test.ts b/x-pack/plugins/security/server/lib/authorization/features_privileges_builders.test.ts new file mode 100644 index 0000000000000..7226e41a7866b --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/features_privileges_builders.test.ts @@ -0,0 +1,350 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Feature } from '../../../../xpack_main/types'; +import { Actions } from './actions'; +import { FeaturesPrivilegesBuilder } from './features_privileges_builder'; + +const versionNumber = '1.0.0-zeta1'; + +describe('#buildFeaturesPrivileges', () => { + test('specifies key for each feature', () => { + const builder = new FeaturesPrivilegesBuilder(new Actions(versionNumber)); + const features = [ + { + id: 'foo', + name: '', + privileges: {}, + }, + { + id: 'bar', + name: '', + privileges: {}, + }, + ]; + const result = builder.buildFeaturesPrivileges(features); + expect(result).toEqual({ + foo: expect.anything(), + bar: expect.anything(), + }); + }); + + test('always includes login and version action', () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features = [ + { + id: 'foo', + name: '', + privileges: { + bar: { + app: [], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, + }, + ]; + const result = builder.buildFeaturesPrivileges(features); + expect(result).toEqual({ + foo: { + bar: [actions.login, actions.version], + }, + }); + }); + + test('includes api actions when specified', () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features = [ + { + id: 'foo', + name: '', + privileges: { + bar: { + api: ['foo/operation', 'bar/operation'], + app: [], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, + }, + ]; + const result = builder.buildFeaturesPrivileges(features); + expect(result).toEqual({ + foo: { + bar: [ + actions.login, + actions.version, + actions.api.get('foo/operation'), + actions.api.get('bar/operation'), + ], + }, + }); + }); + + test('includes app actions when specified', () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features = [ + { + id: 'foo', + name: '', + privileges: { + bar: { + app: ['foo-app', 'bar-app'], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, + }, + ]; + const result = builder.buildFeaturesPrivileges(features); + expect(result).toEqual({ + foo: { + bar: [ + actions.login, + actions.version, + actions.app.get('foo-app'), + actions.app.get('bar-app'), + ], + }, + }); + }); + + test('includes savedObject all actions when specified', () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features = [ + { + id: 'foo', + name: '', + privileges: { + bar: { + app: [], + savedObject: { + all: ['foo-type', 'bar-type'], + read: [], + }, + ui: [], + }, + }, + }, + ]; + const result = builder.buildFeaturesPrivileges(features); + expect(result).toEqual({ + foo: { + bar: [ + actions.login, + actions.version, + ...actions.savedObject.allOperations(['foo-type', 'bar-type']), + ], + }, + }); + }); + + test('includes savedObject read actions when specified', () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features = [ + { + id: 'foo', + name: '', + privileges: { + bar: { + app: [], + savedObject: { + all: [], + read: ['foo-type', 'bar-type'], + }, + ui: [], + }, + }, + }, + ]; + const result = builder.buildFeaturesPrivileges(features); + expect(result).toEqual({ + foo: { + bar: [ + actions.login, + actions.version, + ...actions.savedObject.readOperations(['foo-type', 'bar-type']), + ], + }, + }); + }); + + test('includes ui capabilities actions when specified', () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features = [ + { + id: 'foo', + name: '', + privileges: { + bar: { + app: [], + savedObject: { + all: [], + read: [], + }, + ui: ['foo-ui-capability', 'bar-ui-capability'], + }, + }, + }, + ]; + const result = builder.buildFeaturesPrivileges(features); + expect(result).toEqual({ + foo: { + bar: [ + actions.login, + actions.version, + actions.ui.get('foo', 'foo-ui-capability'), + actions.ui.get('foo', 'bar-ui-capability'), + ], + }, + }); + }); + + test('includes navlink ui capability action when specified', () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features = [ + { + id: 'foo', + name: '', + navLinkId: 'foo-navlink', + privileges: { + bar: { + app: [], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, + }, + ]; + const result = builder.buildFeaturesPrivileges(features); + expect(result).toEqual({ + foo: { + bar: [actions.login, actions.version, actions.ui.get('navLinks', 'foo-navlink')], + }, + }); + }); +}); + +describe('#getApiReadActions', () => { + test(`includes api actions from the read privileges`, () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features: Feature[] = [ + { + id: 'foo', + name: '', + privileges: { + // wrong privilege name + bar: { + app: [], + api: ['foo/api'], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + // no api read privileges + read: { + app: [], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, + }, + { + id: 'bar', + name: '', + privileges: { + // this one should show up in the results + read: { + app: [], + api: ['foo/api'], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, + }, + ]; + const result = builder.getApiReadActions(features); + expect(result).toEqual([actions.api.get('foo/api')]); + }); +}); + +describe('#getUIReadActions', () => { + test(`includes ui actions from the read privileges`, () => { + const actions = new Actions(versionNumber); + const builder = new FeaturesPrivilegesBuilder(actions); + const features: Feature[] = [ + { + id: 'foo', + name: '', + privileges: { + // wrong privilege name + bar: { + app: [], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + // no ui read privileges + read: { + app: [], + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, + }, + { + id: 'bar', + name: '', + privileges: { + // this ui capability should show up in the results + read: { + app: [], + savedObject: { + all: [], + read: [], + }, + ui: ['bar-ui-capability'], + }, + }, + }, + ]; + const result = builder.getUIReadActions(features); + expect(result).toEqual([actions.ui.get('bar', 'bar-ui-capability')]); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/index.js b/x-pack/plugins/security/server/lib/authorization/index.js index 1fb754202832f..8bf109547f188 100644 --- a/x-pack/plugins/security/server/lib/authorization/index.js +++ b/x-pack/plugins/security/server/lib/authorization/index.js @@ -5,6 +5,6 @@ */ export { registerPrivilegesWithCluster } from './register_privileges_with_cluster'; -export { buildPrivilegeMap } from './privileges'; export { createAuthorizationService } from './service'; -export { spaceApplicationPrivilegesSerializer } from './space_application_privileges_serializer'; +export { PrivilegeSerializer } from './privilege_serializer'; +export { ResourceSerializer } from './resource_serializer'; diff --git a/x-pack/plugins/security/server/lib/authorization/privilege_serializer.test.ts b/x-pack/plugins/security/server/lib/authorization/privilege_serializer.test.ts new file mode 100644 index 0000000000000..945ce33c49bfa --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/privilege_serializer.test.ts @@ -0,0 +1,136 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { PrivilegeSerializer } from './privilege_serializer'; + +describe('#serializeGlobalPrivilege', () => { + test('throws Error if unrecognized privilege used', () => { + expect(() => + PrivilegeSerializer.serializeGlobalReservedPrivilege('foo') + ).toThrowErrorMatchingSnapshot(); + }); + + test('returns all unmodified', () => { + const allResult = PrivilegeSerializer.serializeGlobalReservedPrivilege('all'); + expect(allResult).toBe('all'); + }); + + test('returns read unmodified', () => { + const readResult = PrivilegeSerializer.serializeGlobalReservedPrivilege('read'); + expect(readResult).toBe('read'); + }); +}); + +describe('#serializeSpaceReservedPrivilege', () => { + test('throws Error if unrecognized privilege used', () => { + expect(() => + PrivilegeSerializer.serializeSpaceReservedPrivilege('foo') + ).toThrowErrorMatchingSnapshot(); + }); + + test('returns all prefixed with space_', () => { + const allResult = PrivilegeSerializer.serializeSpaceReservedPrivilege('all'); + expect(allResult).toBe('space_all'); + }); + + test('returns read prefixed with space_', () => { + const readResult = PrivilegeSerializer.serializeSpaceReservedPrivilege('read'); + expect(readResult).toBe('space_read'); + }); +}); + +describe('#serializeFeaturePrivilege', () => { + test('returns `feature_${featureName}_${privilegeName}`', () => { + const result = PrivilegeSerializer.serializeFeaturePrivilege('foo', 'bar'); + expect(result).toBe('feature_foo_bar'); + }); +}); + +describe('#serializePrivilegeAssignedGlobally', () => { + test(`returns 'all' when 'all' is provided`, () => { + const result = PrivilegeSerializer.serializePrivilegeAssignedGlobally('all'); + expect(result).toBe('all'); + }); + + test(`returns 'read' when 'read' is provided`, () => { + const result = PrivilegeSerializer.serializePrivilegeAssignedGlobally('read'); + expect(result).toBe('read'); + }); + + test('returns `feature_${privilege}` otherwise', () => { + const result = PrivilegeSerializer.serializePrivilegeAssignedGlobally('foo'); + expect(result).toBe('feature_foo'); + }); +}); + +describe('#serializePrivilegeAssignedAtSpace', () => { + test(`returns 'space_all' when 'all' is provided`, () => { + const result = PrivilegeSerializer.serializePrivilegeAssignedAtSpace('all'); + expect(result).toBe('space_all'); + }); + + test(`returns 'space_read' when 'read' is provided`, () => { + const result = PrivilegeSerializer.serializePrivilegeAssignedAtSpace('read'); + expect(result).toBe('space_read'); + }); + + test('returns `feature_${privilege}` otherwise', () => { + const result = PrivilegeSerializer.serializePrivilegeAssignedAtSpace('foo'); + expect(result).toBe('feature_foo'); + }); +}); + +describe('#deserializePrivilegeAssignedGlobally', () => { + test(`if prefixed with 'feature_' removes the prefix`, () => { + const result = PrivilegeSerializer.deserializePrivilegeAssignedGlobally('feature_foo'); + expect(result).toBe('foo'); + }); + + test(`throws Error if not prefixed with feature_ and isn't a reserved privilege`, () => { + expect(() => + PrivilegeSerializer.deserializePrivilegeAssignedGlobally('foo') + ).toThrowErrorMatchingSnapshot(); + }); + + test(`returns 'all' unprefixed if provided 'all'`, () => { + const result = PrivilegeSerializer.deserializePrivilegeAssignedGlobally('all'); + expect(result).toBe('all'); + }); + + test(`returns 'read' unprefixed if provided 'read'`, () => { + const result = PrivilegeSerializer.deserializePrivilegeAssignedGlobally('read'); + expect(result).toBe('read'); + }); +}); + +describe('#deserializePrivilegeAssignedAtSpace', () => { + test(`if prefixed with 'feature_' removes the prefix`, () => { + const result = PrivilegeSerializer.deserializePrivilegeAssignedAtSpace('feature_foo'); + expect(result).toBe('foo'); + }); + + test(`throws Error if not prefixed with space_`, () => { + expect(() => + PrivilegeSerializer.deserializePrivilegeAssignedAtSpace('all') + ).toThrowErrorMatchingSnapshot(); + }); + + test(`throws Error if prefixed with space_ but not a reserved privilege`, () => { + expect(() => + PrivilegeSerializer.deserializePrivilegeAssignedAtSpace('space_foo') + ).toThrowErrorMatchingSnapshot(); + }); + + test(`returns 'all' unprefixed if provided 'space_all'`, () => { + const result = PrivilegeSerializer.deserializePrivilegeAssignedAtSpace('space_all'); + expect(result).toBe('all'); + }); + + test(`returns 'read' unprefixed if provided 'space_read'`, () => { + const result = PrivilegeSerializer.deserializePrivilegeAssignedAtSpace('space_read'); + expect(result).toBe('read'); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/privilege_serializer.ts b/x-pack/plugins/security/server/lib/authorization/privilege_serializer.ts new file mode 100644 index 0000000000000..537172c69c625 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/privilege_serializer.ts @@ -0,0 +1,78 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +const featurePrefix = 'feature_'; +const spacePrefix = 'space_'; +const reservedPrivilegeNames = ['all', 'read']; + +export class PrivilegeSerializer { + public static serializeGlobalReservedPrivilege(privilegeName: string) { + if (!reservedPrivilegeNames.includes(privilegeName)) { + throw new Error('Unrecognized global reserved privilege'); + } + + return privilegeName; + } + + public static serializeSpaceReservedPrivilege(privilegeName: string) { + if (!reservedPrivilegeNames.includes(privilegeName)) { + throw new Error('Unrecognized space reserved privilege'); + } + + return `${spacePrefix}${privilegeName}`; + } + + public static serializeFeaturePrivilege(featureName: string, privilegeName: string) { + return `${featurePrefix}${featureName}_${privilegeName}`; + } + + public static serializePrivilegeAssignedGlobally(privilege: string) { + if (reservedPrivilegeNames.includes(privilege)) { + return privilege; + } + + return `${featurePrefix}${privilege}`; + } + + public static serializePrivilegeAssignedAtSpace(privilege: string) { + if (reservedPrivilegeNames.includes(privilege)) { + return `${spacePrefix}${privilege}`; + } + + return `${featurePrefix}${privilege}`; + } + + public static deserializePrivilegeAssignedGlobally(privilege: string) { + if (privilege.startsWith(featurePrefix)) { + return privilege.slice(featurePrefix.length); + } + + if (reservedPrivilegeNames.includes(privilege)) { + return privilege; + } + + throw new Error('Unrecognized privilege assigned globally'); + } + + public static deserializePrivilegeAssignedAtSpace(privilege: string) { + if (privilege.startsWith(featurePrefix)) { + return privilege.slice(featurePrefix.length); + } + + if (!privilege.startsWith(spacePrefix)) { + throw new Error( + `Unable to deserialize ${privilege}, should have started with ${spacePrefix} or ${featurePrefix}` + ); + } + + const privilegeName = privilege.slice(spacePrefix.length); + if (reservedPrivilegeNames.includes(privilegeName)) { + return privilegeName; + } + + throw new Error('Unrecognized privilege assigned at space'); + } +} diff --git a/x-pack/plugins/security/server/lib/authorization/privileges.js b/x-pack/plugins/security/server/lib/authorization/privileges.js deleted file mode 100644 index 611a36b99402a..0000000000000 --- a/x-pack/plugins/security/server/lib/authorization/privileges.js +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { IGNORED_TYPES } from '../../../common/constants'; - -export function buildPrivilegeMap(savedObjectTypes, actions) { - - const buildAccessFeatureAction = (feature) => `ui:${feature}/read`; - - const buildSavedObjectsActions = (types, savedObjectActions) => { - return types - .filter(type => !IGNORED_TYPES.includes(type)) - .map(type => savedObjectActions.map(savedObjectAction => actions.getSavedObjectAction(type, savedObjectAction))) - .reduce((acc, types) => [...acc, ...types], []); - }; - - const buildSavedObjectsReadActions = (types) => buildSavedObjectsActions(types, ['get', 'bulk_get', 'find']); - const buildSavedObjectsWriteActions = (types) => buildSavedObjectsActions(types, ['create', 'bulk_create', 'update', 'delete']); - const buildAllSavedObjectsActions = (types) => [...buildSavedObjectsReadActions(types), ...buildSavedObjectsWriteActions(types)]; - - // the following list of privileges should only be added to, you can safely remove actions, but not privileges as - // it's a backwards compatibility issue and we'll have to at least adjust registerPrivilegesWithCluster to support it - return { - global: { - all: [ - actions.version, - 'action:*', - 'ui:kibana*', - 'api:*', - ], - read: [ - actions.version, - actions.login, - 'ui:*', - 'api:console/proxy/execute', - ...buildSavedObjectsActions(savedObjectTypes, [ - 'get', - 'bulk_get', - 'find' - ]) - ], - }, - features: { - discover: { - read_write: [ - buildAccessFeatureAction(`kibana`), - buildAccessFeatureAction(`kibana:discover`), - ...buildSavedObjectsReadActions(['index-pattern']), - ...buildAllSavedObjectsActions(['search']) - ], - read: [ - buildAccessFeatureAction(`kibana`), - buildAccessFeatureAction(`kibana:discover`), - ...buildSavedObjectsReadActions(['index-pattern', 'search']), - ], - share: [ - 'action:saved_objects/search/share', - ] - }, - visualize: { - all: [ - buildAccessFeatureAction(`kibana`), - buildAccessFeatureAction(`kibana:visualize`), - ...buildSavedObjectsReadActions(['index-pattern', 'search']), - ...buildAllSavedObjectsActions(['visualization']) - ], - read: [ - buildAccessFeatureAction(`kibana`), - buildAccessFeatureAction(`kibana:visualize`), - ...buildSavedObjectsReadActions(['index-pattern', 'search', 'visualization']), - ] - }, - dashboard: { - all: [ - buildAccessFeatureAction(`kibana`), - buildAccessFeatureAction(`kibana:dashboard`), - ...buildSavedObjectsReadActions(['index-pattern', 'search', 'visualization', 'timelion', 'canvas']), - ...buildAllSavedObjectsActions(['dashboard']) - ], - read: [ - buildAccessFeatureAction(`kibana`), - buildAccessFeatureAction(`kibana:dashboard`), - ...buildSavedObjectsReadActions(['index-pattern', 'search', 'visualization', 'timelion', 'canvas', 'dashboard']), - ] - }, - timelion: { - all: [ - buildAccessFeatureAction(`timelion`), - ...buildSavedObjectsReadActions(['index-pattern' ]), - ...buildAllSavedObjectsActions(['timelion']) - ], - read: [ - buildAccessFeatureAction(`timelion`), - ...buildSavedObjectsReadActions(['index-pattern', 'timelion']), - ] - }, - canvas: { - all: [ - buildAccessFeatureAction(`canvas`), - ...buildSavedObjectsReadActions(['index-pattern']), - ...buildAllSavedObjectsActions(['canvas']) - ], - read: [ - buildAccessFeatureAction(`canvas`), - ...buildSavedObjectsReadActions(['index-pattern', 'canvas']), - ] - }, - apm: { - all: [ - buildAccessFeatureAction(`apm`), - ] - }, - ml: { - all: [ - buildAccessFeatureAction(`ml`), - ] - }, - graph: { - all: [ - buildAccessFeatureAction(`graph`), - ...buildSavedObjectsReadActions(['index-pattern']), - ...buildAllSavedObjectsActions(['graph']) - ], - read: [ - buildAccessFeatureAction(`graph`), - ...buildSavedObjectsReadActions(['index-pattern', 'graph']), - ] - }, - devTools: { - all: [ - buildAccessFeatureAction(`kibana`), - buildAccessFeatureAction('kibana:dev_tools'), - 'api:console/proxy/execute' - ], - }, - monitoring: { - all: [ - buildAccessFeatureAction(`monitoring`), - ] - }, - // This is a subfeature of a feature within an application - // it feels strange to put the feature at the same level as a full-featured application - advancedSettings: { - all: [ - buildAccessFeatureAction(`kibana:management:advancedSettings`), - ...buildAllSavedObjectsActions(['config']) - ], - read: [ - // not being able to write config makes some things hard: - // automatic assignment of default index pattern - buildAccessFeatureAction(`kibana:management:advancedSettings`), - ...buildSavedObjectsReadActions(['config']) - ] - }, - management: { - all: [ - buildAccessFeatureAction(`kibana`), - buildAccessFeatureAction(`kibana:management`), - ] - }, - }, - space: { - all: [ - actions.version, - actions.login, - 'ui:*', - 'api:*', - ...buildSavedObjectsActions(savedObjectTypes, [ - 'create', - 'bulk_create', - 'delete', - 'get', - 'bulk_get', - 'find', - 'update' - ]) - ], - read: [ - actions.version, - actions.login, - 'ui:*', - 'api:console/proxy/execute', - ...buildSavedObjectsActions(savedObjectTypes, [ - 'get', - 'bulk_get', - 'find']) - ], - }, - }; -} diff --git a/x-pack/plugins/security/server/lib/authorization/privileges.test.ts b/x-pack/plugins/security/server/lib/authorization/privileges.test.ts new file mode 100644 index 0000000000000..7775b63fff060 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/privileges.test.ts @@ -0,0 +1,218 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// @ts-ignore +import { Feature } from '../../../../xpack_main/types'; +import { IGNORED_TYPES } from '../../../common/constants'; +import { Actions } from './actions'; +import { privilegesFactory } from './privileges'; + +test(`builds privileges correctly`, () => { + const actions = new Actions('1.0.0-zeta1'); + + const savedObjectTypes = ['foo-saved-object-type', 'bar-saved-object-type', ...IGNORED_TYPES]; + + const features: Feature[] = [ + { + id: 'foo-feature', + name: 'Foo Feature', + icon: 'arrowDown', + navLinkId: 'kibana:foo-feature', + privileges: { + all: { + app: ['foo-app'], + savedObject: { + all: ['foo-saved-object-type'], + read: ['bad-saved-object-type'], + }, + ui: ['show', 'showSaveButton', 'showCreateButton'], + }, + read: { + app: ['foo-app'], + api: ['foo/read/api'], + savedObject: { + all: [], + read: ['foo-saved-object-type', 'bar-saved-object-type'], + }, + ui: ['show'], + }, + }, + }, + { + id: 'bar-feature', + name: 'Bar Feature', + icon: 'arrowUp', + privileges: { + all: { + app: ['bar-app'], + savedObject: { + all: ['bar-saved-object-type'], + read: ['foo-saved-object-type'], + }, + ui: ['show', 'showSaveButton', 'showCreateButton'], + }, + read: { + app: ['bar-app'], + api: ['bar/read/api'], + savedObject: { + all: [], + read: ['foo-saved-object-type', 'bar-saved-object-type'], + }, + ui: ['show'], + }, + }, + }, + ]; + + const mockXPackMainPlugin = { + getFeatures: jest.fn().mockReturnValue(features), + }; + + const privileges = privilegesFactory(savedObjectTypes, actions, mockXPackMainPlugin); + + // we want to make sure we don't call `xpackMainPlugin.getFeatures` until `get` is called + // to ensure that plugins have the time to register their features before we build the privilegeMap + expect(mockXPackMainPlugin.getFeatures).not.toHaveBeenCalled(); + expect(privileges.get()).toEqual({ + features: { + 'bar-feature': { + all: [ + 'login:', + 'version:1.0.0-zeta1', + 'app:bar-app', + 'saved_object:bar-saved-object-type/bulk_get', + 'saved_object:bar-saved-object-type/get', + 'saved_object:bar-saved-object-type/find', + 'saved_object:bar-saved-object-type/create', + 'saved_object:bar-saved-object-type/bulk_create', + 'saved_object:bar-saved-object-type/update', + 'saved_object:bar-saved-object-type/delete', + 'saved_object:foo-saved-object-type/bulk_get', + 'saved_object:foo-saved-object-type/get', + 'saved_object:foo-saved-object-type/find', + 'ui:bar-feature/show', + 'ui:bar-feature/showSaveButton', + 'ui:bar-feature/showCreateButton', + ], + read: [ + 'login:', + 'version:1.0.0-zeta1', + 'api:bar/read/api', + 'app:bar-app', + 'saved_object:foo-saved-object-type/bulk_get', + 'saved_object:foo-saved-object-type/get', + 'saved_object:foo-saved-object-type/find', + 'saved_object:bar-saved-object-type/bulk_get', + 'saved_object:bar-saved-object-type/get', + 'saved_object:bar-saved-object-type/find', + 'ui:bar-feature/show', + ], + }, + 'foo-feature': { + all: [ + 'login:', + 'version:1.0.0-zeta1', + 'app:foo-app', + 'saved_object:foo-saved-object-type/bulk_get', + 'saved_object:foo-saved-object-type/get', + 'saved_object:foo-saved-object-type/find', + 'saved_object:foo-saved-object-type/create', + 'saved_object:foo-saved-object-type/bulk_create', + 'saved_object:foo-saved-object-type/update', + 'saved_object:foo-saved-object-type/delete', + 'saved_object:bad-saved-object-type/bulk_get', + 'saved_object:bad-saved-object-type/get', + 'saved_object:bad-saved-object-type/find', + 'ui:foo-feature/show', + 'ui:foo-feature/showSaveButton', + 'ui:foo-feature/showCreateButton', + 'ui:navLinks/kibana:foo-feature', + ], + read: [ + 'login:', + 'version:1.0.0-zeta1', + 'api:foo/read/api', + 'app:foo-app', + 'saved_object:foo-saved-object-type/bulk_get', + 'saved_object:foo-saved-object-type/get', + 'saved_object:foo-saved-object-type/find', + 'saved_object:bar-saved-object-type/bulk_get', + 'saved_object:bar-saved-object-type/get', + 'saved_object:bar-saved-object-type/find', + 'ui:foo-feature/show', + 'ui:navLinks/kibana:foo-feature', + ], + }, + }, + global: { + all: [ + 'login:', + 'version:1.0.0-zeta1', + 'api:*', + 'app:*', + 'saved_object:*', + 'space:manage', + 'ui:*', + ], + read: [ + 'login:', + 'version:1.0.0-zeta1', + 'api:foo/read/api', + 'api:bar/read/api', + 'app:*', + 'saved_object:foo-saved-object-type/bulk_get', + 'saved_object:foo-saved-object-type/get', + 'saved_object:foo-saved-object-type/find', + 'saved_object:bar-saved-object-type/bulk_get', + 'saved_object:bar-saved-object-type/get', + 'saved_object:bar-saved-object-type/find', + 'ui:foo-feature/show', + 'ui:bar-feature/show', + 'ui:navLinks/*', + ], + }, + space: { + all: [ + 'login:', + 'version:1.0.0-zeta1', + 'api:*', + 'app:*', + 'saved_object:foo-saved-object-type/bulk_get', + 'saved_object:foo-saved-object-type/get', + 'saved_object:foo-saved-object-type/find', + 'saved_object:foo-saved-object-type/create', + 'saved_object:foo-saved-object-type/bulk_create', + 'saved_object:foo-saved-object-type/update', + 'saved_object:foo-saved-object-type/delete', + 'saved_object:bar-saved-object-type/bulk_get', + 'saved_object:bar-saved-object-type/get', + 'saved_object:bar-saved-object-type/find', + 'saved_object:bar-saved-object-type/create', + 'saved_object:bar-saved-object-type/bulk_create', + 'saved_object:bar-saved-object-type/update', + 'saved_object:bar-saved-object-type/delete', + 'ui:*', + ], + read: [ + 'login:', + 'version:1.0.0-zeta1', + 'api:foo/read/api', + 'api:bar/read/api', + 'app:*', + 'saved_object:foo-saved-object-type/bulk_get', + 'saved_object:foo-saved-object-type/get', + 'saved_object:foo-saved-object-type/find', + 'saved_object:bar-saved-object-type/bulk_get', + 'saved_object:bar-saved-object-type/get', + 'saved_object:bar-saved-object-type/find', + 'ui:foo-feature/show', + 'ui:bar-feature/show', + 'ui:navLinks/*', + ], + }, + }); + expect(mockXPackMainPlugin.getFeatures).toHaveBeenCalled(); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/privileges.ts b/x-pack/plugins/security/server/lib/authorization/privileges.ts new file mode 100644 index 0000000000000..f9a27faddf65d --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/privileges.ts @@ -0,0 +1,85 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Feature } from '../../../../xpack_main/types'; +import { IGNORED_TYPES } from '../../../common/constants'; +import { Actions } from './actions'; +import { FeaturesPrivileges, FeaturesPrivilegesBuilder } from './features_privileges_builder'; + +export interface PrivilegeMap { + global: Record; + features: FeaturesPrivileges; + space: Record; +} + +export interface PrivilegesService { + get(): PrivilegeMap; +} + +interface XPackMainPlugin { + getFeatures(): Feature[]; +} + +export function privilegesFactory( + allSavedObjectTypes: string[], + actions: Actions, + xpackMainPlugin: XPackMainPlugin +) { + return { + get() { + // TODO: I'd like to ensure an explicit Error is thrown here if all + // plugins haven't had a chance to register their features yet + const features = xpackMainPlugin.getFeatures(); + const validSavedObjectTypes = allSavedObjectTypes.filter( + type => !IGNORED_TYPES.includes(type) + ); + const featuresPrivilegesBuilder = new FeaturesPrivilegesBuilder(actions); + + return { + features: featuresPrivilegesBuilder.buildFeaturesPrivileges(features), + global: { + all: [ + actions.login, + actions.version, + actions.api.all, + actions.app.all, + actions.savedObject.all, + actions.space.manage, + actions.ui.all, + ], + read: [ + actions.login, + actions.version, + ...featuresPrivilegesBuilder.getApiReadActions(features), + actions.app.all, + ...actions.savedObject.readOperations(validSavedObjectTypes), + ...featuresPrivilegesBuilder.getUIReadActions(features), + actions.ui.allNavLinks, + ], + }, + space: { + all: [ + actions.login, + actions.version, + actions.api.all, + actions.app.all, + ...actions.savedObject.allOperations(validSavedObjectTypes), + actions.ui.all, + ], + read: [ + actions.login, + actions.version, + ...featuresPrivilegesBuilder.getApiReadActions(features), + actions.app.all, + ...actions.savedObject.readOperations(validSavedObjectTypes), + ...featuresPrivilegesBuilder.getUIReadActions(features), + actions.ui.allNavLinks, + ], + }, + }; + }, + }; +} diff --git a/x-pack/plugins/security/server/lib/authorization/privileges_serializer.test.ts b/x-pack/plugins/security/server/lib/authorization/privileges_serializer.test.ts new file mode 100644 index 0000000000000..0fdaadb2172c5 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/privileges_serializer.test.ts @@ -0,0 +1,162 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { serializePrivileges } from './privileges_serializer'; + +test(`uses application as top-level key`, () => { + const result = serializePrivileges('foo-application', { + global: {}, + space: {}, + features: {}, + }); + expect(Object.keys(result)).toEqual(['foo-application']); +}); + +describe('global', () => { + test(`includes global privileges without any prefix`, () => { + const application = 'foo-application'; + const result = serializePrivileges(application, { + global: { + all: ['action-1', 'action-2'], + read: ['action-3', 'action-4'], + }, + space: {}, + features: {}, + }); + expect(result[application]).toEqual({ + all: { + application, + name: 'all', + actions: ['action-1', 'action-2'], + metadata: {}, + }, + read: { + application, + name: 'read', + actions: ['action-3', 'action-4'], + metadata: {}, + }, + }); + }); + + test(`throws Error if unrecognized global privilege is specified`, () => { + const application = 'foo-application'; + expect(() => { + serializePrivileges(application, { + global: { + foo: ['action-1', 'action-2'], + }, + space: {}, + features: {}, + }); + }).toThrowErrorMatchingSnapshot(); + }); +}); + +describe('space', () => { + test(`includes space privileges with a space_ prefix`, () => { + const application = 'foo-application'; + const result = serializePrivileges(application, { + global: {}, + space: { + all: ['action-1', 'action-2'], + read: ['action-3', 'action-4'], + }, + features: {}, + }); + expect(result[application]).toEqual({ + space_all: { + application, + name: 'space_all', + actions: ['action-1', 'action-2'], + metadata: {}, + }, + space_read: { + application, + name: 'space_read', + actions: ['action-3', 'action-4'], + metadata: {}, + }, + }); + }); + + test(`throws Error if unrecognized space privilege is specified`, () => { + const application = 'foo-application'; + expect(() => { + serializePrivileges(application, { + global: {}, + space: { + foo: ['action-1', 'action-2'], + }, + features: {}, + }); + }).toThrowErrorMatchingSnapshot(); + }); +}); + +describe('features', () => { + test(`includes feature privileges by combining featureName and privilegeName with a feature_ prefix`, () => { + const application = 'foo-application'; + const result = serializePrivileges(application, { + global: {}, + space: {}, + features: { + foo: { + quz: ['action-1', 'action-2'], + qux: ['action-3', 'action-4'], + }, + bar: { + quz: ['action-1', 'action-2'], + qux: ['action-3', 'action-4'], + }, + }, + }); + expect(result[application]).toEqual({ + feature_foo_quz: { + application, + name: 'feature_foo_quz', + actions: ['action-1', 'action-2'], + metadata: {}, + }, + feature_foo_qux: { + application, + name: 'feature_foo_qux', + actions: ['action-3', 'action-4'], + metadata: {}, + }, + feature_bar_quz: { + application, + name: 'feature_bar_quz', + actions: ['action-1', 'action-2'], + metadata: {}, + }, + feature_bar_qux: { + application, + name: 'feature_bar_qux', + actions: ['action-3', 'action-4'], + metadata: {}, + }, + }); + }); + + test(`throws error if feature privileges would conflict`, () => { + const application = 'foo-application'; + expect(() => { + serializePrivileges(application, { + global: {}, + space: {}, + features: { + foo_bar: { + baz: ['action-1', 'action-2'], + }, + foo: { + bar_baz: ['action-1', 'action-2'], + }, + }, + }); + }).toThrowErrorMatchingSnapshot(); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/privileges_serializer.ts b/x-pack/plugins/security/server/lib/authorization/privileges_serializer.ts new file mode 100644 index 0000000000000..4b8afd04a8e19 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/privileges_serializer.ts @@ -0,0 +1,78 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { PrivilegeSerializer } from './privilege_serializer'; +import { PrivilegeMap } from './privileges'; + +interface SerializedPrivilege { + application: string; + name: string; + actions: string[]; + metadata: Record; +} + +interface SerializedApplicationPrivileges { + [key: string]: SerializedPrivilege; +} + +interface SerializedPrivileges { + [key: string]: SerializedApplicationPrivileges; +} + +export const serializePrivileges = ( + application: string, + privilegeMap: PrivilegeMap +): SerializedPrivileges => { + return { + [application]: { + ...Object.entries(privilegeMap.global).reduce( + (acc, [privilegeName, privilegeActions]) => { + const name = PrivilegeSerializer.serializeGlobalReservedPrivilege(privilegeName); + acc[name] = { + application, + name: privilegeName, + actions: privilegeActions, + metadata: {}, + }; + return acc; + }, + {} as Record + ), + ...Object.entries(privilegeMap.space).reduce( + (acc, [privilegeName, privilegeActions]) => { + const name = PrivilegeSerializer.serializeSpaceReservedPrivilege(privilegeName); + acc[name] = { + application, + name, + actions: privilegeActions, + metadata: {}, + }; + return acc; + }, + {} as Record + ), + ...Object.entries(privilegeMap.features).reduce( + (acc, [featureName, featurePrivileges]) => { + Object.entries(featurePrivileges).forEach(([privilegeName, privilegeActions]) => { + const name = PrivilegeSerializer.serializeFeaturePrivilege(featureName, privilegeName); + if (Object.keys(acc).includes(name)) { + throw new Error(`Detected conflicting feature privilege name: ${name}`); + } + acc[name] = { + application, + name, + actions: privilegeActions, + metadata: {}, + }; + }); + + return acc; + }, + {} as Record + ), + }, + }; +}; diff --git a/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.js b/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.js index 12bea327b0fc9..8f468bfdb7a7c 100644 --- a/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.js +++ b/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.js @@ -5,62 +5,22 @@ */ import { difference, isEmpty, isEqual } from 'lodash'; -import { buildPrivilegeMap } from './privileges'; import { getClient } from '../../../../../server/lib/get_client_shield'; -import { spaceApplicationPrivilegesSerializer } from './space_application_privileges_serializer'; - -const serializePrivileges = (application, privilegeMap) => { - return { - [application]: { - ...Object.entries(privilegeMap.global).reduce((acc, [privilegeName, privilegeActions]) => { - acc[privilegeName] = { - application, - name: privilegeName, - actions: privilegeActions, - metadata: {}, - }; - return acc; - }, {}), - ...Object.entries(privilegeMap.space).reduce((acc, [privilegeName, privilegeActions]) => { - const name = spaceApplicationPrivilegesSerializer.privilege.serialize(privilegeName); - acc[name] = { - application, - name, - actions: privilegeActions, - metadata: {}, - }; - return acc; - }, {}), - ...Object.entries(privilegeMap.features).reduce((acc, [featureName, featurePrivileges]) => { - - Object.entries(featurePrivileges).forEach(([privilegeName, privilegeActions]) => { - const name = `feature_${featureName}_${privilegeName}`; - acc[name] = { - application, - name, - actions: privilegeActions, - metadata: {}, - }; - }); - - return acc; - }, {}) - } - }; -}; +import { serializePrivileges } from './privileges_serializer'; export async function registerPrivilegesWithCluster(server) { - const { authorization } = server.plugins.security; - const { types: savedObjectTypes } = server.savedObjects; - const { actions, application } = authorization; + const { application, privileges } = server.plugins.security.authorization; const arePrivilegesEqual = (existingPrivileges, expectedPrivileges) => { // when comparing privileges, the order of the actions doesn't matter, lodash's isEqual // doesn't know how to compare Sets return isEqual(existingPrivileges, expectedPrivileges, (value, other, key) => { if (key === 'actions' && Array.isArray(value) && Array.isArray(other)) { - return isEqual(value.sort(), other.sort()); + // Array.sort() is in-place, and we don't want to be modifying the actual order + // of the arrays permanently, and there's potential they're frozen, so we're copying + // before comparing. + return isEqual([...value].sort(), [...other].sort()); } }); }; @@ -73,8 +33,7 @@ export async function registerPrivilegesWithCluster(server) { return difference(Object.keys(existingPrivileges[application]), Object.keys(expectedPrivileges[application])).length > 0; }; - const privilegeMap = buildPrivilegeMap(savedObjectTypes, actions); - const expectedPrivileges = serializePrivileges(application, privilegeMap); + const expectedPrivileges = serializePrivileges(application, privileges.get()); server.log(['security', 'debug'], `Registering Kibana Privileges with Elasticsearch for ${application}`); diff --git a/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.test.js b/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.test.js index b2a391aa49573..84e83d469cb31 100644 --- a/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.test.js +++ b/x-pack/plugins/security/server/lib/authorization/register_privileges_with_cluster.test.js @@ -35,7 +35,7 @@ const registerPrivilegesWithClusterTest = (description, { const defaultVersion = 'default-version'; - const createMockServer = () => { + const createMockServer = ({ privilegeMap }) => { const mockServer = { config: jest.fn().mockReturnValue({ get: jest.fn(), @@ -45,7 +45,10 @@ const registerPrivilegesWithClusterTest = (description, { security: { authorization: { actions: Symbol(), - application + application, + privileges: { + get: () => privilegeMap + } } } } @@ -124,7 +127,9 @@ const registerPrivilegesWithClusterTest = (description, { }; test(description, async () => { - const mockServer = createMockServer(); + const mockServer = createMockServer({ + privilegeMap + }); const mockCallWithInternalUser = registerMockCallWithInternalUser() .mockImplementationOnce(async () => { if (throwErrorWhenGettingPrivileges) { @@ -144,8 +149,6 @@ const registerPrivilegesWithClusterTest = (description, { } }); - buildPrivilegeMap.mockReturnValue(privilegeMap); - let error; try { await registerPrivilegesWithCluster(mockServer); @@ -165,42 +168,50 @@ const registerPrivilegesWithClusterTest = (description, { }); }; -registerPrivilegesWithClusterTest(`passes saved object types, and actions to buildPrivilegeMap`, { - savedObjectTypes: [ - 'foo-type', - 'bar-type', - ], - assert: ({ mocks }) => { - expect(mocks.buildPrivilegeMap).toHaveBeenCalledWith( - ['foo-type', 'bar-type'], - mocks.server.plugins.security.authorization.actions, - ); - }, -}); - registerPrivilegesWithClusterTest(`inserts privileges when we don't have any existing privileges`, { privilegeMap: { + features: {}, global: { - foo: ['action:foo'] + all: ['action:all'] }, space: { - bar: ['action:bar'] + read: ['action:read'] + }, + features: { + foo: { + all: ['action:foo_all'], + }, + bar: { + read: ['action:bar_read'], + } } }, existingPrivileges: null, assert: ({ expectUpdatedPrivileges }) => { expectUpdatedPrivileges({ [application]: { - foo: { + all: { application, - name: 'foo', - actions: ['action:foo'], + name: 'all', + actions: ['action:all'], metadata: {}, }, - space_bar: { + space_read: { application, - name: 'space_bar', - actions: ['action:bar'], + name: 'space_read', + actions: ['action:read'], + metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:foo_all'], + metadata: {}, + }, + feature_bar_read: { + application, + name: 'feature_bar_read', + actions: ['action:bar_read'], metadata: {}, } } @@ -210,30 +221,31 @@ registerPrivilegesWithClusterTest(`inserts privileges when we don't have any exi registerPrivilegesWithClusterTest(`throws error when we should be removing privilege`, { privilegeMap: { + features: {}, global: { - foo: ['action:foo'], + all: ['action:foo'], }, space: { - bar: ['action:bar'] + read: ['action:bar'] } }, existingPrivileges: { [application]: { - foo: { + all: { application, - name: 'foo', + name: 'all', actions: ['action:not-foo'], metadata: {}, }, - quz: { + read: { application, - name: 'quz', + name: 'read', actions: ['action:not-quz'], metadata: {}, }, - space_bar: { + space_read: { application, - name: 'space_bar', + name: 'space_read', actions: ['action:not-bar'], metadata: {}, } @@ -244,45 +256,228 @@ registerPrivilegesWithClusterTest(`throws error when we should be removing privi } }); -registerPrivilegesWithClusterTest(`updates privileges when actions don't match`, { +registerPrivilegesWithClusterTest(`updates privileges when global actions don't match`, { privilegeMap: { + features: {}, global: { - foo: ['action:foo'] + all: ['action:foo'] }, space: { - bar: ['action:bar'] + read: ['action:bar'] + }, + features: { + foo: { + all: ['action:baz'] + }, + bar: { + read: ['action:quz'] + } } }, existingPrivileges: { [application]: { + all: { + application, + name: 'all', + actions: ['action:foo'], + metadata: {}, + }, + space_read: { + application, + name: 'space_read', + actions: ['action:bar'], + metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:baz'], + }, + feature_bar_read: { + application, + name: 'feature_bar_read', + actions: ['action:not-quz'], + } + } + }, + assert: ({ expectUpdatedPrivileges }) => { + expectUpdatedPrivileges({ + [application]: { + all: { + application, + name: 'all', + actions: ['action:foo'], + metadata: {}, + }, + space_read: { + application, + name: 'space_read', + actions: ['action:bar'], + metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:baz'], + metadata: {}, + }, + feature_bar_read: { + application, + name: 'feature_bar_read', + actions: ['action:quz'], + metadata: {}, + } + } + }); + } +}); + +registerPrivilegesWithClusterTest(`updates privileges when space actions don't match`, { + privilegeMap: { + features: {}, + global: { + all: ['action:foo'] + }, + space: { + read: ['action:bar'] + }, + features: { foo: { + all: ['action:baz'] + }, + bar: { + read: ['action:quz'] + } + } + }, + existingPrivileges: { + [application]: { + all: { application, - name: 'foo', - actions: ['action:not-foo'], + name: 'all', + actions: ['action:foo'], metadata: {}, }, - space_bar: { + space_read: { application, - name: 'space_bar', + name: 'space_read', actions: ['action:not-bar'], metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:baz'], + }, + feature_bar_read: { + application, + name: 'feature_bar_read', + actions: ['action:quz'], } } }, assert: ({ expectUpdatedPrivileges }) => { expectUpdatedPrivileges({ [application]: { - foo: { + all: { application, - name: 'foo', + name: 'all', actions: ['action:foo'], metadata: {}, }, - space_bar: { + space_read: { application, - name: 'space_bar', + name: 'space_read', actions: ['action:bar'], metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:baz'], + metadata: {}, + }, + feature_bar_read: { + application, + name: 'feature_bar_read', + actions: ['action:quz'], + metadata: {}, + } + } + }); + } +}); + +registerPrivilegesWithClusterTest(`updates privileges when feature actions don't match`, { + privilegeMap: { + features: {}, + global: { + all: ['action:foo'] + }, + space: { + read: ['action:bar'] + }, + features: { + foo: { + all: ['action:baz'] + }, + bar: { + read: ['action:quz'] + } + } + }, + existingPrivileges: { + [application]: { + all: { + application, + name: 'all', + actions: ['action:foo'], + metadata: {}, + }, + space_read: { + application, + name: 'space_read', + actions: ['action:bar'], + metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:baz'], + }, + feature_bar_read: { + application, + name: 'feature_bar_read', + actions: ['action:not-quz'], + } + } + }, + assert: ({ expectUpdatedPrivileges }) => { + expectUpdatedPrivileges({ + [application]: { + all: { + application, + name: 'all', + actions: ['action:foo'], + metadata: {}, + }, + space_read: { + application, + name: 'space_read', + actions: ['action:bar'], + metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:baz'], + metadata: {}, + }, + feature_bar_read: { + application, + name: 'feature_bar_read', + actions: ['action:quz'], + metadata: {}, } } }); @@ -291,49 +486,137 @@ registerPrivilegesWithClusterTest(`updates privileges when actions don't match`, registerPrivilegesWithClusterTest(`updates privileges when global privilege added`, { privilegeMap: { + features: {}, global: { - foo: ['action:foo'], - quz: ['action:quz'] + all: ['action:foo'], + read: ['action:quz'] }, space: { - bar: ['action:bar'] + read: ['action:bar'] + }, + features: { + foo: { + all: ['action:foo-all'] + } } }, existingPrivileges: { [application]: { + all: { + application, + name: 'all', + actions: ['action:foo'], + metadata: {}, + }, + space_read: { + application, + name: 'space_read', + actions: ['action:bar'], + metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:foo-all'], + metadata: {}, + } + } + }, + assert: ({ expectUpdatedPrivileges }) => { + expectUpdatedPrivileges({ + [application]: { + all: { + application, + name: 'all', + actions: ['action:foo'], + metadata: {}, + }, + read: { + application, + name: 'read', + actions: ['action:quz'], + metadata: {}, + }, + space_read: { + application, + name: 'space_read', + actions: ['action:bar'], + metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:foo-all'], + metadata: {}, + } + } + }); + } +}); + +registerPrivilegesWithClusterTest(`updates privileges when space privilege added`, { + privilegeMap: { + features: {}, + global: { + all: ['action:foo'], + }, + space: { + all: ['action:bar'], + read: ['action:quz'] + }, + features: { foo: { + all: ['action:foo-all'] + } + } + }, + existingPrivileges: { + [application]: { + all: { application, name: 'foo', actions: ['action:not-foo'], metadata: {}, }, - space_bar: { + space_read: { application, - name: 'space_bar', + name: 'space_read', actions: ['action:not-bar'], metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:foo-all'], + metadata: {}, } } }, assert: ({ expectUpdatedPrivileges }) => { expectUpdatedPrivileges({ [application]: { - foo: { + all: { application, - name: 'foo', + name: 'all', actions: ['action:foo'], metadata: {}, }, - quz: { + space_all: { application, - name: 'quz', + name: 'space_all', + actions: ['action:bar'], + metadata: {}, + }, + space_read: { + application, + name: 'space_read', actions: ['action:quz'], metadata: {}, }, - space_bar: { + feature_foo_all: { application, - name: 'space_bar', - actions: ['action:bar'], + name: 'feature_foo_all', + actions: ['action:foo-all'], metadata: {}, } } @@ -341,53 +624,71 @@ registerPrivilegesWithClusterTest(`updates privileges when global privilege adde } }); -registerPrivilegesWithClusterTest(`updates privileges when space privilege added`, { +registerPrivilegesWithClusterTest(`updates privileges when feature privilege added`, { privilegeMap: { + features: {}, global: { - foo: ['action:foo'], + all: ['action:foo'], }, space: { - bar: ['action:bar'], - quz: ['action:quz'] + all: ['action:bar'], + }, + features: { + foo: { + all: ['action:foo-all'], + read: ['action:foo-read'] + } } }, existingPrivileges: { [application]: { - foo: { + all: { application, name: 'foo', actions: ['action:not-foo'], metadata: {}, }, - space_bar: { + space_all: { application, - name: 'space_bar', + name: 'space_all', actions: ['action:not-bar'], metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:foo-all'], + metadata: {}, } } }, assert: ({ expectUpdatedPrivileges }) => { expectUpdatedPrivileges({ [application]: { - foo: { + all: { application, - name: 'foo', + name: 'all', actions: ['action:foo'], metadata: {}, }, - space_bar: { + space_all: { application, - name: 'space_bar', + name: 'space_all', actions: ['action:bar'], metadata: {}, }, - space_quz: { + feature_foo_all: { application, - name: 'space_quz', - actions: ['action:quz'], + name: 'feature_foo_all', + actions: ['action:foo-all'], metadata: {}, }, + feature_foo_read: { + application, + name: 'feature_foo_read', + actions: ['action:foo-read'], + metadata: {}, + } } }); } @@ -396,24 +697,35 @@ registerPrivilegesWithClusterTest(`updates privileges when space privilege added registerPrivilegesWithClusterTest(`doesn't update privileges when order of actions differ`, { privilegeMap: { global: { - foo: ['action:foo', 'action:quz'] + all: ['action:foo', 'action:quz'] }, space: { - bar: ['action:bar'] + read: ['action:bar', 'action:quz'] + }, + features: { + foo: { + all: ['action:foo-all', 'action:bar-all'] + } } }, existingPrivileges: { [application]: { - foo: { + all: { application, - name: 'foo', + name: 'all', actions: ['action:quz', 'action:foo'], metadata: {}, }, - space_bar: { + space_read: { application, - name: 'space_bar', - actions: ['action:bar'], + name: 'space_read', + actions: ['action:quz', 'action:bar'], + metadata: {}, + }, + feature_foo_all: { + application, + name: 'feature_foo_all', + actions: ['action:bar-all', 'action:foo-all'], metadata: {}, } } @@ -425,6 +737,7 @@ registerPrivilegesWithClusterTest(`doesn't update privileges when order of actio registerPrivilegesWithClusterTest(`throws and logs error when errors getting privileges`, { privilegeMap: { + features: {}, global: {}, space: {} }, @@ -436,11 +749,12 @@ registerPrivilegesWithClusterTest(`throws and logs error when errors getting pri registerPrivilegesWithClusterTest(`throws and logs error when errors putting privileges`, { privilegeMap: { + features: {}, global: { - foo: [] + all: [] }, space: { - bar: [] + read: [] } }, existingPrivileges: null, diff --git a/x-pack/plugins/security/server/lib/authorization/resource_serializer.test.ts b/x-pack/plugins/security/server/lib/authorization/resource_serializer.test.ts new file mode 100644 index 0000000000000..e500e39ea2255 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/resource_serializer.test.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ResourceSerializer } from './resource_serializer'; + +describe('#serializeSpaceResource', () => { + test('returns `space:${spaceId}`', () => { + expect(ResourceSerializer.serializeSpaceResource('foo-space')).toBe('space:foo-space'); + }); +}); + +describe('#deserializeSpaceResource', () => { + test(`throws error if resource doesn't start with space:`, () => { + expect(() => { + ResourceSerializer.deserializeSpaceResource('foo-space'); + }).toThrowErrorMatchingSnapshot(); + }); + + test(`returns spaceId without the space: prefix`, () => { + expect(ResourceSerializer.deserializeSpaceResource(`space:foo-space`)).toBe('foo-space'); + }); +}); diff --git a/x-pack/plugins/security/server/lib/authorization/resource_serializer.ts b/x-pack/plugins/security/server/lib/authorization/resource_serializer.ts new file mode 100644 index 0000000000000..0d11085f4ef65 --- /dev/null +++ b/x-pack/plugins/security/server/lib/authorization/resource_serializer.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +const spaceResourcePrefix = `space:`; + +export class ResourceSerializer { + public static serializeSpaceResource(spaceId: string) { + return `${spaceResourcePrefix}${spaceId}`; + } + + public static deserializeSpaceResource(resource: string) { + if (!resource.startsWith(spaceResourcePrefix)) { + throw new Error(`Resource should have started with ${spaceResourcePrefix}`); + } + + return resource.slice(spaceResourcePrefix.length); + } +} diff --git a/x-pack/plugins/security/server/lib/authorization/service.js b/x-pack/plugins/security/server/lib/authorization/service.js index d7ce77a03fd33..a081e17a9a96f 100644 --- a/x-pack/plugins/security/server/lib/authorization/service.js +++ b/x-pack/plugins/security/server/lib/authorization/service.js @@ -6,10 +6,11 @@ import { actionsFactory } from './actions'; import { authorizationModeFactory } from './mode'; +import { privilegesFactory } from './privileges'; import { checkPrivilegesWithRequestFactory } from './check_privileges'; import { getClient } from '../../../../../server/lib/get_client_shield'; -export function createAuthorizationService(server, xpackInfoFeature) { +export function createAuthorizationService(server, xpackInfoFeature, savedObjectTypes, xpackMainPlugin) { const shieldClient = getClient(server); const config = server.config(); @@ -23,11 +24,13 @@ export function createAuthorizationService(server, xpackInfoFeature) { shieldClient, xpackInfoFeature, ); + const privileges = privilegesFactory(savedObjectTypes, actions, xpackMainPlugin); return { actions, application, checkPrivilegesWithRequest, mode, + privileges, }; } diff --git a/x-pack/plugins/security/server/lib/authorization/service.test.js b/x-pack/plugins/security/server/lib/authorization/service.test.js index f753e1170fc91..7fdccacc41362 100644 --- a/x-pack/plugins/security/server/lib/authorization/service.test.js +++ b/x-pack/plugins/security/server/lib/authorization/service.test.js @@ -6,6 +6,7 @@ import { createAuthorizationService } from './service'; import { actionsFactory } from './actions'; +import { privilegesFactory } from './privileges'; import { checkPrivilegesWithRequestFactory } from './check_privileges'; import { getClient } from '../../../../../server/lib/get_client_shield'; import { authorizationModeFactory } from './mode'; @@ -22,6 +23,10 @@ jest.mock('./actions', () => ({ actionsFactory: jest.fn(), })); +jest.mock('./privileges', () => ({ + privilegesFactory: jest.fn() +})); + jest.mock('./mode', () => ({ authorizationModeFactory: jest.fn(), })); @@ -36,7 +41,7 @@ const createMockConfig = (settings = {}) => { return mockConfig; }; -test(`calls server.expose with exposed services`, () => { +test(`returns exposed services`, () => { const kibanaIndex = '.a-kibana-index'; const mockConfig = createMockConfig({ 'kibana.index': kibanaIndex @@ -56,13 +61,23 @@ test(`calls server.expose with exposed services`, () => { actionsFactory.mockReturnValue(mockActions); mockConfig.get.mock; const mockXpackInfoFeature = Symbol(); + const mockSavedObjectTypes = Symbol(); + const mockFeatures = Symbol(); + const mockXpackMainPlugin = { + getFeatures: () => mockFeatures + }; + const mockPrivilegesService = Symbol(); + privilegesFactory.mockReturnValue(mockPrivilegesService); + const mockAuthorizationMode = Symbol(); + authorizationModeFactory.mockReturnValue(mockAuthorizationMode); - createAuthorizationService(mockServer, mockXpackInfoFeature); + const authorization = createAuthorizationService(mockServer, mockXpackInfoFeature, mockSavedObjectTypes, mockXpackMainPlugin); const application = `kibana-${kibanaIndex}`; expect(getClient).toHaveBeenCalledWith(mockServer); expect(actionsFactory).toHaveBeenCalledWith(mockConfig); expect(checkPrivilegesWithRequestFactory).toHaveBeenCalledWith(mockActions, application, mockShieldClient); + expect(privilegesFactory).toHaveBeenCalledWith(mockSavedObjectTypes, mockActions, mockXpackMainPlugin); expect(authorizationModeFactory).toHaveBeenCalledWith( application, mockConfig, @@ -70,4 +85,12 @@ test(`calls server.expose with exposed services`, () => { mockShieldClient, mockXpackInfoFeature, ); + + expect(authorization).toEqual({ + actions: mockActions, + application, + checkPrivilegesWithRequest: mockCheckPrivilegesWithRequest, + mode: mockAuthorizationMode, + privileges: mockPrivilegesService, + }); }); diff --git a/x-pack/plugins/security/server/lib/authorization/space_application_privileges_serializer.js b/x-pack/plugins/security/server/lib/authorization/space_application_privileges_serializer.js deleted file mode 100644 index 2906f07e9f5ce..0000000000000 --- a/x-pack/plugins/security/server/lib/authorization/space_application_privileges_serializer.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -const privilegePrefix = `space_`; -const resourcePrefix = `space:`; - -export const spaceApplicationPrivilegesSerializer = { - privilege: { - serialize(privilege) { - return `${privilegePrefix}${privilege}`; - }, - deserialize(privilege) { - if (!privilege.startsWith(privilegePrefix)) { - throw new Error(`Space privilege should have started with ${privilegePrefix}`); - } - - return privilege.slice(privilegePrefix.length); - }, - }, - resource: { - serialize(spaceId) { - return `${resourcePrefix}${spaceId}`; - }, - deserialize(resource) { - if (!resource.startsWith(resourcePrefix)) { - throw new Error(`Resource should have started with ${resourcePrefix}`); - } - - return resource.slice(resourcePrefix.length); - } - }, -}; diff --git a/x-pack/plugins/security/server/lib/authorization/space_application_privileges_serializer.test.js b/x-pack/plugins/security/server/lib/authorization/space_application_privileges_serializer.test.js deleted file mode 100644 index 2277d09e498db..0000000000000 --- a/x-pack/plugins/security/server/lib/authorization/space_application_privileges_serializer.test.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { spaceApplicationPrivilegesSerializer } from './space_application_privileges_serializer'; - -describe('#privilege', () => { - describe('#serialize', () => { - test(`prepends privilege with space_`, () => { - const result = spaceApplicationPrivilegesSerializer.privilege.serialize('all'); - expect(result).toBe('space_all'); - }); - }); - - describe('#deserialize', () => { - test(`throws error if privilege doesn't start with space_`, () => { - expect( - () => spaceApplicationPrivilegesSerializer.privilege.deserialize('foo_space_all') - ).toThrowErrorMatchingSnapshot(); - }); - - test(`removes space_ from the start`, () => { - const result = spaceApplicationPrivilegesSerializer.privilege.deserialize('space_all'); - expect(result).toBe('all'); - }); - }); -}); - -describe('#resource', () => { - describe('#serialize', () => { - test(`prepends resource with space:`, () => { - const result = spaceApplicationPrivilegesSerializer.resource.serialize('marketing'); - expect(result).toBe('space:marketing'); - }); - }); - - describe('#deserialize', () => { - test(`throws error if resource doesn't start with space:`, () => { - expect( - () => spaceApplicationPrivilegesSerializer.resource.deserialize('foo:space:something') - ).toThrowErrorMatchingSnapshot(); - }); - - test(`removes space: from the start`, () => { - const result = spaceApplicationPrivilegesSerializer.resource.deserialize('space:marketing'); - expect(result).toBe('marketing'); - }); - }); -}); diff --git a/x-pack/plugins/security/server/lib/saved_objects_client/secure_saved_objects_client_wrapper.js b/x-pack/plugins/security/server/lib/saved_objects_client/secure_saved_objects_client_wrapper.js index 01c41551a0344..90e2305298901 100644 --- a/x-pack/plugins/security/server/lib/saved_objects_client/secure_saved_objects_client_wrapper.js +++ b/x-pack/plugins/security/server/lib/saved_objects_client/secure_saved_objects_client_wrapper.js @@ -118,7 +118,7 @@ export class SecureSavedObjectsClientWrapper { async _ensureAuthorized(typeOrTypes, action, args) { const types = Array.isArray(typeOrTypes) ? typeOrTypes : [typeOrTypes]; - const actions = types.map(type => this._actions.getSavedObjectAction(type, action)); + const actions = types.map(type => this._actions.savedObject.get(type, action)); const { hasAllRequested, username, privileges } = await this._checkSavedObjectPrivileges(actions); if (hasAllRequested) { diff --git a/x-pack/plugins/security/server/lib/saved_objects_client/secure_saved_objects_client_wrapper.test.js b/x-pack/plugins/security/server/lib/saved_objects_client/secure_saved_objects_client_wrapper.test.js index f4b3d31b8da0c..bb53fc20d80eb 100644 --- a/x-pack/plugins/security/server/lib/saved_objects_client/secure_saved_objects_client_wrapper.test.js +++ b/x-pack/plugins/security/server/lib/saved_objects_client/secure_saved_objects_client_wrapper.test.js @@ -27,8 +27,10 @@ const createMockAuditLogger = () => { const createMockActions = () => { return { - getSavedObjectAction(type, action) { - return `mock-action:saved_objects/${type}/${action}`; + savedObject: { + get(type, action) { + return `mock-saved_object:${type}/${action}`; + } } }; }; @@ -73,7 +75,7 @@ describe(`spaces disabled`, () => { await expect(client.create(type)).rejects.toThrowError(mockErrors.generalError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'create')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'create')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -89,7 +91,7 @@ describe(`spaces disabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'create')]: false, + [mockActions.savedObject.get(type, 'create')]: false, } })) }; @@ -112,13 +114,13 @@ describe(`spaces disabled`, () => { await expect(client.create(type, attributes, options)).rejects.toThrowError(mockErrors.forbiddenError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'create')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'create')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'create', [type], - [mockActions.getSavedObjectAction(type, 'create')], + [mockActions.savedObject.get(type, 'create')], { type, attributes, @@ -141,7 +143,7 @@ describe(`spaces disabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'create')]: true, + [mockActions.savedObject.get(type, 'create')]: true, } })) }; @@ -165,7 +167,7 @@ describe(`spaces disabled`, () => { expect(result).toBe(returnValue); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'create')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'create')]); expect(mockBaseClient.create).toHaveBeenCalledWith(type, attributes, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'create', [type], { @@ -203,7 +205,7 @@ describe(`spaces disabled`, () => { await expect(client.bulkCreate([{ type }])).rejects.toThrowError(mockErrors.generalError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'bulk_create')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'bulk_create')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -220,8 +222,8 @@ describe(`spaces disabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'bulk_create')]: false, - [mockActions.getSavedObjectAction(type2, 'bulk_create')]: true, + [mockActions.savedObject.get(type1, 'bulk_create')]: false, + [mockActions.savedObject.get(type2, 'bulk_create')]: true, } })) }; @@ -249,15 +251,15 @@ describe(`spaces disabled`, () => { expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([ - mockActions.getSavedObjectAction(type1, 'bulk_create'), - mockActions.getSavedObjectAction(type2, 'bulk_create'), + mockActions.savedObject.get(type1, 'bulk_create'), + mockActions.savedObject.get(type2, 'bulk_create'), ]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'bulk_create', [type1, type2], - [mockActions.getSavedObjectAction(type1, 'bulk_create')], + [mockActions.savedObject.get(type1, 'bulk_create')], { objects, options, @@ -279,8 +281,8 @@ describe(`spaces disabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'bulk_create')]: true, - [mockActions.getSavedObjectAction(type2, 'bulk_create')]: true, + [mockActions.savedObject.get(type1, 'bulk_create')]: true, + [mockActions.savedObject.get(type2, 'bulk_create')]: true, } })) }; @@ -308,8 +310,8 @@ describe(`spaces disabled`, () => { expect(result).toBe(returnValue); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([ - mockActions.getSavedObjectAction(type1, 'bulk_create'), - mockActions.getSavedObjectAction(type2, 'bulk_create'), + mockActions.savedObject.get(type1, 'bulk_create'), + mockActions.savedObject.get(type2, 'bulk_create'), ]); expect(mockBaseClient.bulkCreate).toHaveBeenCalledWith(objects, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); @@ -347,7 +349,7 @@ describe(`spaces disabled`, () => { await expect(client.delete(type)).rejects.toThrowError(mockErrors.generalError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'delete')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'delete')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -363,7 +365,7 @@ describe(`spaces disabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'delete')]: false, + [mockActions.savedObject.get(type, 'delete')]: false, } })) }; @@ -385,13 +387,13 @@ describe(`spaces disabled`, () => { await expect(client.delete(type, id)).rejects.toThrowError(mockErrors.forbiddenError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'delete')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'delete')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'delete', [type], - [mockActions.getSavedObjectAction(type, 'delete')], + [mockActions.savedObject.get(type, 'delete')], { type, id, @@ -413,7 +415,7 @@ describe(`spaces disabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'delete')]: true, + [mockActions.savedObject.get(type, 'delete')]: true, } })) }; @@ -437,7 +439,7 @@ describe(`spaces disabled`, () => { expect(result).toBe(returnValue); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'delete')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'delete')]); expect(mockBaseClient.delete).toHaveBeenCalledWith(type, id, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'delete', [type], { @@ -475,7 +477,7 @@ describe(`spaces disabled`, () => { await expect(client.find({ type })).rejects.toThrowError(mockErrors.generalError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'find')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'find')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -491,7 +493,7 @@ describe(`spaces disabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'find')]: false, + [mockActions.savedObject.get(type, 'find')]: false, } })) }; @@ -513,13 +515,13 @@ describe(`spaces disabled`, () => { await expect(client.find(options)).rejects.toThrowError(mockErrors.forbiddenError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'find')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'find')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'find', [type], - [mockActions.getSavedObjectAction(type, 'find')], + [mockActions.savedObject.get(type, 'find')], { options } @@ -538,8 +540,8 @@ describe(`spaces disabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'find')]: false, - [mockActions.getSavedObjectAction(type2, 'find')]: true, + [mockActions.savedObject.get(type1, 'find')]: false, + [mockActions.savedObject.get(type2, 'find')]: true, } })) }; @@ -563,15 +565,15 @@ describe(`spaces disabled`, () => { expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([ - mockActions.getSavedObjectAction(type1, 'find'), - mockActions.getSavedObjectAction(type2, 'find') + mockActions.savedObject.get(type1, 'find'), + mockActions.savedObject.get(type2, 'find') ]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'find', [type1, type2], - [mockActions.getSavedObjectAction(type1, 'find')], + [mockActions.savedObject.get(type1, 'find')], { options } @@ -592,7 +594,7 @@ describe(`spaces disabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'find')]: true, + [mockActions.savedObject.get(type, 'find')]: true, } })) }; @@ -615,7 +617,7 @@ describe(`spaces disabled`, () => { expect(result).toBe(returnValue); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'find')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'find')]); expect(mockBaseClient.find).toHaveBeenCalledWith({ type }); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'find', [type], { @@ -651,7 +653,7 @@ describe(`spaces disabled`, () => { await expect(client.bulkGet([{ type }])).rejects.toThrowError(mockErrors.generalError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'bulk_get')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'bulk_get')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -668,8 +670,8 @@ describe(`spaces disabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'bulk_get')]: false, - [mockActions.getSavedObjectAction(type2, 'bulk_get')]: true, + [mockActions.savedObject.get(type1, 'bulk_get')]: false, + [mockActions.savedObject.get(type2, 'bulk_get')]: true, } })) }; @@ -697,15 +699,15 @@ describe(`spaces disabled`, () => { expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([ - mockActions.getSavedObjectAction(type1, 'bulk_get'), - mockActions.getSavedObjectAction(type2, 'bulk_get'), + mockActions.savedObject.get(type1, 'bulk_get'), + mockActions.savedObject.get(type2, 'bulk_get'), ]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'bulk_get', [type1, type2], - [mockActions.getSavedObjectAction(type1, 'bulk_get')], + [mockActions.savedObject.get(type1, 'bulk_get')], { objects, options, @@ -728,8 +730,8 @@ describe(`spaces disabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'bulk_get')]: true, - [mockActions.getSavedObjectAction(type2, 'bulk_get')]: true, + [mockActions.savedObject.get(type1, 'bulk_get')]: true, + [mockActions.savedObject.get(type2, 'bulk_get')]: true, } })) }; @@ -757,8 +759,8 @@ describe(`spaces disabled`, () => { expect(result).toBe(returnValue); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([ - mockActions.getSavedObjectAction(type1, 'bulk_get'), - mockActions.getSavedObjectAction(type2, 'bulk_get'), + mockActions.savedObject.get(type1, 'bulk_get'), + mockActions.savedObject.get(type2, 'bulk_get'), ]); expect(mockBaseClient.bulkGet).toHaveBeenCalledWith(objects, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); @@ -796,7 +798,7 @@ describe(`spaces disabled`, () => { await expect(client.get(type)).rejects.toThrowError(mockErrors.generalError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'get')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'get')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -812,7 +814,7 @@ describe(`spaces disabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'get')]: false, + [mockActions.savedObject.get(type, 'get')]: false, } })) }; @@ -835,13 +837,13 @@ describe(`spaces disabled`, () => { await expect(client.get(type, id, options)).rejects.toThrowError(mockErrors.forbiddenError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'get')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'get')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'get', [type], - [mockActions.getSavedObjectAction(type, 'get')], + [mockActions.savedObject.get(type, 'get')], { type, id, @@ -864,7 +866,7 @@ describe(`spaces disabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'get')]: true, + [mockActions.savedObject.get(type, 'get')]: true, } })) }; @@ -888,7 +890,7 @@ describe(`spaces disabled`, () => { expect(result).toBe(returnValue); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'get')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'get')]); expect(mockBaseClient.get).toHaveBeenCalledWith(type, id, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'get', [type], { @@ -926,7 +928,7 @@ describe(`spaces disabled`, () => { await expect(client.update(type)).rejects.toThrowError(mockErrors.generalError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'update')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'update')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -942,7 +944,7 @@ describe(`spaces disabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'update')]: false, + [mockActions.savedObject.get(type, 'update')]: false, } })) }; @@ -966,13 +968,13 @@ describe(`spaces disabled`, () => { await expect(client.update(type, id, attributes, options)).rejects.toThrowError(mockErrors.forbiddenError); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'update')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'update')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'update', [type], - [mockActions.getSavedObjectAction(type, 'update')], + [mockActions.savedObject.get(type, 'update')], { type, id, @@ -996,7 +998,7 @@ describe(`spaces disabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'update')]: true, + [mockActions.savedObject.get(type, 'update')]: true, } })) }; @@ -1021,7 +1023,7 @@ describe(`spaces disabled`, () => { expect(result).toBe(returnValue); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.getSavedObjectAction(type, 'update')]); + expect(mockCheckPrivileges.globally).toHaveBeenCalledWith([mockActions.savedObject.get(type, 'update')]); expect(mockBaseClient.update).toHaveBeenCalledWith(type, id, attributes, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'update', [type], { @@ -1066,7 +1068,7 @@ describe(`spaces enabled`, () => { await expect(client.create(type)).rejects.toThrowError(mockErrors.generalError); expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'create')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'create')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -1083,7 +1085,7 @@ describe(`spaces enabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'create')]: false, + [mockActions.savedObject.get(type, 'create')]: false, } })) }; @@ -1110,13 +1112,13 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'create')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'create')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'create', [type], - [mockActions.getSavedObjectAction(type, 'create')], + [mockActions.savedObject.get(type, 'create')], { type, attributes, @@ -1140,7 +1142,7 @@ describe(`spaces enabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'create')]: true, + [mockActions.savedObject.get(type, 'create')]: true, } })) }; @@ -1168,7 +1170,7 @@ describe(`spaces enabled`, () => { expect(result).toBe(returnValue); expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'create')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'create')]); expect(mockBaseClient.create).toHaveBeenCalledWith(type, attributes, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'create', [type], { @@ -1211,7 +1213,7 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'bulk_create')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'bulk_create')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -1229,8 +1231,8 @@ describe(`spaces enabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'bulk_create')]: false, - [mockActions.getSavedObjectAction(type2, 'bulk_create')]: true, + [mockActions.savedObject.get(type1, 'bulk_create')]: false, + [mockActions.savedObject.get(type2, 'bulk_create')]: true, } })) }; @@ -1262,15 +1264,15 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [ - mockActions.getSavedObjectAction(type1, 'bulk_create'), - mockActions.getSavedObjectAction(type2, 'bulk_create'), + mockActions.savedObject.get(type1, 'bulk_create'), + mockActions.savedObject.get(type2, 'bulk_create'), ]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'bulk_create', [type1, type2], - [mockActions.getSavedObjectAction(type1, 'bulk_create')], + [mockActions.savedObject.get(type1, 'bulk_create')], { objects, options, @@ -1293,8 +1295,8 @@ describe(`spaces enabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'bulk_create')]: true, - [mockActions.getSavedObjectAction(type2, 'bulk_create')]: true, + [mockActions.savedObject.get(type1, 'bulk_create')]: true, + [mockActions.savedObject.get(type2, 'bulk_create')]: true, } })) }; @@ -1326,8 +1328,8 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [ - mockActions.getSavedObjectAction(type1, 'bulk_create'), - mockActions.getSavedObjectAction(type2, 'bulk_create'), + mockActions.savedObject.get(type1, 'bulk_create'), + mockActions.savedObject.get(type2, 'bulk_create'), ]); expect(mockBaseClient.bulkCreate).toHaveBeenCalledWith(objects, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); @@ -1370,7 +1372,7 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'delete')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'delete')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -1387,7 +1389,7 @@ describe(`spaces enabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'delete')]: false, + [mockActions.savedObject.get(type, 'delete')]: false, } })) }; @@ -1413,13 +1415,13 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'delete')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'delete')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'delete', [type], - [mockActions.getSavedObjectAction(type, 'delete')], + [mockActions.savedObject.get(type, 'delete')], { type, id, @@ -1442,7 +1444,7 @@ describe(`spaces enabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'delete')]: true, + [mockActions.savedObject.get(type, 'delete')]: true, } })) }; @@ -1470,7 +1472,7 @@ describe(`spaces enabled`, () => { expect(result).toBe(returnValue); expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'delete')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'delete')]); expect(mockBaseClient.delete).toHaveBeenCalledWith(type, id, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'delete', [type], { @@ -1513,7 +1515,7 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'find')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'find')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -1530,7 +1532,7 @@ describe(`spaces enabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'find')]: false, + [mockActions.savedObject.get(type, 'find')]: false, } })) }; @@ -1556,13 +1558,13 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'find')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'find')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'find', [type], - [mockActions.getSavedObjectAction(type, 'find')], + [mockActions.savedObject.get(type, 'find')], { options } @@ -1582,8 +1584,8 @@ describe(`spaces enabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'find')]: false, - [mockActions.getSavedObjectAction(type2, 'find')]: true, + [mockActions.savedObject.get(type1, 'find')]: false, + [mockActions.savedObject.get(type2, 'find')]: true, } })) }; @@ -1611,15 +1613,15 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [ - mockActions.getSavedObjectAction(type1, 'find'), - mockActions.getSavedObjectAction(type2, 'find') + mockActions.savedObject.get(type1, 'find'), + mockActions.savedObject.get(type2, 'find') ]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'find', [type1, type2], - [mockActions.getSavedObjectAction(type1, 'find')], + [mockActions.savedObject.get(type1, 'find')], { options } @@ -1641,7 +1643,7 @@ describe(`spaces enabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'find')]: true, + [mockActions.savedObject.get(type, 'find')]: true, } })) }; @@ -1668,7 +1670,7 @@ describe(`spaces enabled`, () => { expect(result).toBe(returnValue); expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'find')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'find')]); expect(mockBaseClient.find).toHaveBeenCalledWith({ type }); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'find', [type], { @@ -1709,7 +1711,7 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'bulk_get')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'bulk_get')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -1727,8 +1729,8 @@ describe(`spaces enabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'bulk_get')]: false, - [mockActions.getSavedObjectAction(type2, 'bulk_get')]: true, + [mockActions.savedObject.get(type1, 'bulk_get')]: false, + [mockActions.savedObject.get(type2, 'bulk_get')]: true, } })) }; @@ -1760,15 +1762,15 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [ - mockActions.getSavedObjectAction(type1, 'bulk_get'), - mockActions.getSavedObjectAction(type2, 'bulk_get'), + mockActions.savedObject.get(type1, 'bulk_get'), + mockActions.savedObject.get(type2, 'bulk_get'), ]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'bulk_get', [type1, type2], - [mockActions.getSavedObjectAction(type1, 'bulk_get')], + [mockActions.savedObject.get(type1, 'bulk_get')], { objects, options, @@ -1792,8 +1794,8 @@ describe(`spaces enabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type1, 'bulk_get')]: true, - [mockActions.getSavedObjectAction(type2, 'bulk_get')]: true, + [mockActions.savedObject.get(type1, 'bulk_get')]: true, + [mockActions.savedObject.get(type2, 'bulk_get')]: true, } })) }; @@ -1825,8 +1827,8 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [ - mockActions.getSavedObjectAction(type1, 'bulk_get'), - mockActions.getSavedObjectAction(type2, 'bulk_get'), + mockActions.savedObject.get(type1, 'bulk_get'), + mockActions.savedObject.get(type2, 'bulk_get'), ]); expect(mockBaseClient.bulkGet).toHaveBeenCalledWith(objects, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); @@ -1869,7 +1871,7 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'get')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'get')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -1886,7 +1888,7 @@ describe(`spaces enabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'get')]: false, + [mockActions.savedObject.get(type, 'get')]: false, } })) }; @@ -1913,13 +1915,13 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'get')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'get')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'get', [type], - [mockActions.getSavedObjectAction(type, 'get')], + [mockActions.savedObject.get(type, 'get')], { type, id, @@ -1943,7 +1945,7 @@ describe(`spaces enabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'get')]: true, + [mockActions.savedObject.get(type, 'get')]: true, } })) }; @@ -1971,7 +1973,7 @@ describe(`spaces enabled`, () => { expect(result).toBe(returnValue); expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'get')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'get')]); expect(mockBaseClient.get).toHaveBeenCalledWith(type, id, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'get', [type], { @@ -2014,7 +2016,7 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'update')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'update')]); expect(mockErrors.decorateGeneralError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).not.toHaveBeenCalled(); @@ -2031,7 +2033,7 @@ describe(`spaces enabled`, () => { hasAllRequested: false, username, privileges: { - [mockActions.getSavedObjectAction(type, 'update')]: false, + [mockActions.savedObject.get(type, 'update')]: false, } })) }; @@ -2059,13 +2061,13 @@ describe(`spaces enabled`, () => { expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'update')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'update')]); expect(mockErrors.decorateForbiddenError).toHaveBeenCalledTimes(1); expect(mockAuditLogger.savedObjectsAuthorizationFailure).toHaveBeenCalledWith( username, 'update', [type], - [mockActions.getSavedObjectAction(type, 'update')], + [mockActions.savedObject.get(type, 'update')], { type, id, @@ -2090,7 +2092,7 @@ describe(`spaces enabled`, () => { hasAllRequested: true, username, privileges: { - [mockActions.getSavedObjectAction(type, 'update')]: true, + [mockActions.savedObject.get(type, 'update')]: true, } })) }; @@ -2119,7 +2121,7 @@ describe(`spaces enabled`, () => { expect(result).toBe(returnValue); expect(mockSpaces.getSpaceId).toHaveBeenCalledWith(mockRequest); expect(mockCheckPrivilegesWithRequest).toHaveBeenCalledWith(mockRequest); - expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.getSavedObjectAction(type, 'update')]); + expect(mockCheckPrivileges.atSpace).toHaveBeenCalledWith(spaceId, [mockActions.savedObject.get(type, 'update')]); expect(mockBaseClient.update).toHaveBeenCalledWith(type, id, attributes, options); expect(mockAuditLogger.savedObjectsAuthorizationFailure).not.toHaveBeenCalled(); expect(mockAuditLogger.savedObjectsAuthorizationSuccess).toHaveBeenCalledWith(username, 'update', [type], { diff --git a/x-pack/plugins/security/server/routes/api/public/roles/get.js b/x-pack/plugins/security/server/routes/api/public/roles/get.js index 145d06f74fb40..8c32763bb74f7 100644 --- a/x-pack/plugins/security/server/routes/api/public/roles/get.js +++ b/x-pack/plugins/security/server/routes/api/public/roles/get.js @@ -7,7 +7,7 @@ import _ from 'lodash'; import Boom from 'boom'; import { GLOBAL_RESOURCE } from '../../../../../common/constants'; import { wrapError } from '../../../../lib/errors'; -import { spaceApplicationPrivilegesSerializer } from '../../../../lib/authorization'; +import { PrivilegeSerializer, ResourceSerializer } from '../../../../lib/authorization'; export function initGetRolesApi(server, callWithRequest, routePreCheckLicenseFn, application) { @@ -21,14 +21,17 @@ export function initGetRolesApi(server, callWithRequest, routePreCheckLicenseFn, return resourcePrivileges.reduce((result, { resource, privileges }) => { if (resource === GLOBAL_RESOURCE) { - result.global = _.uniq([...result.global, ...privileges]); + result.global = _.uniq([ + ...result.global, + ...privileges.map(privilege => PrivilegeSerializer.deserializePrivilegeAssignedGlobally(privilege)) + ]); return result; } - const spaceId = spaceApplicationPrivilegesSerializer.resource.deserialize(resource); + const spaceId = ResourceSerializer.deserializeSpaceResource(resource); result.space[spaceId] = _.uniq([ ...result.space[spaceId] || [], - ...privileges.map(privilege => spaceApplicationPrivilegesSerializer.privilege.deserialize(privilege)) + ...privileges.map(privilege => PrivilegeSerializer.deserializePrivilegeAssignedAtSpace(privilege)) ]); return result; }, { diff --git a/x-pack/plugins/security/server/routes/api/public/roles/index.js b/x-pack/plugins/security/server/routes/api/public/roles/index.js index 8bdde88123ee4..04b39867e86a7 100644 --- a/x-pack/plugins/security/server/routes/api/public/roles/index.js +++ b/x-pack/plugins/security/server/routes/api/public/roles/index.js @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { buildPrivilegeMap } from '../../../../lib/authorization'; import { getClient } from '../../../../../../../server/lib/get_client_shield'; import { routePreCheckLicense } from '../../../../lib/route_pre_check_license'; import { initGetRolesApi } from './get'; @@ -15,11 +14,10 @@ export function initPublicRolesApi(server) { const callWithRequest = getClient(server).callWithRequest; const routePreCheckLicenseFn = routePreCheckLicense(server); - const { application, actions } = server.plugins.security.authorization; - const savedObjectTypes = server.savedObjects.types; - const privilegeMap = buildPrivilegeMap(savedObjectTypes, actions); + const { authorization } = server.plugins.security; + const { application } = authorization; initGetRolesApi(server, callWithRequest, routePreCheckLicenseFn, application); - initPutRolesApi(server, callWithRequest, routePreCheckLicenseFn, privilegeMap, application); + initPutRolesApi(server, callWithRequest, routePreCheckLicenseFn, authorization, application); initDeleteRolesApi(server, callWithRequest, routePreCheckLicenseFn); } diff --git a/x-pack/plugins/security/server/routes/api/public/roles/put.js b/x-pack/plugins/security/server/routes/api/public/roles/put.js index 65dd78ed2d4b1..8f10a1773527c 100644 --- a/x-pack/plugins/security/server/routes/api/public/roles/put.js +++ b/x-pack/plugins/security/server/routes/api/public/roles/put.js @@ -4,17 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import { pick, identity } from 'lodash'; +import { flatten, pick, identity } from 'lodash'; import Joi from 'joi'; import { GLOBAL_RESOURCE } from '../../../../../common/constants'; import { wrapError } from '../../../../lib/errors'; -import { spaceApplicationPrivilegesSerializer } from '../../../../lib/authorization'; +import { PrivilegeSerializer, ResourceSerializer } from '../../../../lib/authorization'; export function initPutRolesApi( server, callWithRequest, routePreCheckLicenseFn, - privilegeMap, + authorization, application ) { @@ -22,7 +22,7 @@ export function initPutRolesApi( const kibanaApplicationPrivileges = []; if (kibanaPrivileges.global && kibanaPrivileges.global.length) { kibanaApplicationPrivileges.push({ - privileges: kibanaPrivileges.global, + privileges: kibanaPrivileges.global.map(privilege => PrivilegeSerializer.serializePrivilegeAssignedGlobally(privilege)), application, resources: [GLOBAL_RESOURCE], }); @@ -31,9 +31,9 @@ export function initPutRolesApi( if (kibanaPrivileges.space) { for(const [spaceId, privileges] of Object.entries(kibanaPrivileges.space)) { kibanaApplicationPrivileges.push({ - privileges: privileges.map(privilege => spaceApplicationPrivilegesSerializer.privilege.serialize(privilege)), + privileges: privileges.map(privilege => PrivilegeSerializer.serializePrivilegeAssignedAtSpace(privilege)), application, - resources: [spaceApplicationPrivilegesSerializer.resource.serialize(spaceId)] + resources: [ResourceSerializer.serializeSpaceResource(spaceId)] }); } } @@ -62,6 +62,31 @@ export function initPutRolesApi( }, identity); }; + // this should be short-lived once we refactor the way that these APIs work, hence the ugly string concatenation + // if you see this code in master, please yell at Brandon + const getFeaturePrivileges = (features) => { + return flatten(Object.entries(features).map( + ([featureName, featurePrivileges]) => { + return Object.keys(featurePrivileges).map( + (privilegeName) => { + return `${featureName}_${privilegeName}`; + }); + }) + ); + }; + + const getGlobalItemsSchema = () => { + const privileges = authorization.privileges.get(); + const validPrivileges = [...Object.keys(privileges.global), ...getFeaturePrivileges(privileges.features)]; + return Joi.string().valid(validPrivileges); + }; + + const getSpaceItemsSchema = () => { + const privileges = authorization.privileges.get(); + const validPrivileges = [...Object.keys(privileges.space), ...getFeaturePrivileges(privileges.features)]; + return Joi.string().valid(validPrivileges); + }; + const schema = Joi.object().keys({ metadata: Joi.object().optional(), elasticsearch: Joi.object().keys({ @@ -78,8 +103,8 @@ export function initPutRolesApi( run_as: Joi.array().items(Joi.string()), }), kibana: Joi.object().keys({ - global: Joi.array().items(Joi.string().valid(Object.keys(privilegeMap.global))), - space: Joi.object().pattern(/^[a-z0-9_-]+$/, Joi.array().items(Joi.string().valid(Object.keys(privilegeMap.space)))) + global: Joi.array().items(Joi.lazy(() => getGlobalItemsSchema())), + space: Joi.object().pattern(/^[a-z0-9_-]+$/, Joi.array().items(Joi.lazy(() => getSpaceItemsSchema()))) }) }); diff --git a/x-pack/plugins/security/server/routes/api/public/roles/put.test.js b/x-pack/plugins/security/server/routes/api/public/roles/put.test.js index 26d6eb1966ead..110701cbf1751 100644 --- a/x-pack/plugins/security/server/routes/api/public/roles/put.test.js +++ b/x-pack/plugins/security/server/routes/api/public/roles/put.test.js @@ -29,14 +29,22 @@ const defaultPreCheckLicenseImpl = () => null; const privilegeMap = { global: { - 'test-global-privilege-1': [], - 'test-global-privilege-2': [], - 'test-global-privilege-3': [], + all: [], + read: [], }, space: { - 'test-space-privilege-1': [], - 'test-space-privilege-2': [], - 'test-space-privilege-3': [], + all: [], + read: [], + }, + features: { + foo: { + 'foo-privilege-1': [], + 'foo-privilege-2': [], + }, + bar: { + 'bar-privilege-1': [], + 'bar-privilege-2': [], + } } }; @@ -53,11 +61,16 @@ const putRoleTest = ( for (const impl of callWithRequestImpls) { mockCallWithRequest.mockImplementationOnce(impl); } + const mockAuthorization = { + privileges: { + get: () => privilegeMap + } + }; initPutRolesApi( mockServer, mockCallWithRequest, mockPreCheckLicense, - privilegeMap, + mockAuthorization, application, ); const headers = { @@ -129,7 +142,7 @@ describe('PUT role', () => { }, }); - putRoleTest(`only allows known Kibana global privileges`, { + putRoleTest(`only allows known Kibana global or feature privileges`, { name: 'foo-role', payload: { kibana: { @@ -141,7 +154,7 @@ describe('PUT role', () => { result: { error: 'Bad Request', //eslint-disable-next-line max-len - message: `child \"kibana\" fails because [child \"global\" fails because [\"global\" at position 0 fails because [\"0\" must be one of [test-global-privilege-1, test-global-privilege-2, test-global-privilege-3]]]]`, + message: `child \"kibana\" fails because [child \"global\" fails because [\"global\" at position 0 fails because [\"0\" must be one of [all, read, foo_foo-privilege-1, foo_foo-privilege-2, bar_bar-privilege-1, bar_bar-privilege-2]]]]`, statusCode: 400, validation: { keys: ['kibana.global.0'], @@ -151,7 +164,7 @@ describe('PUT role', () => { }, }); - putRoleTest(`only allows known Kibana space privileges`, { + putRoleTest(`only allows known Kibana space or feature privileges`, { name: 'foo-role', payload: { kibana: { @@ -165,7 +178,7 @@ describe('PUT role', () => { result: { error: 'Bad Request', //eslint-disable-next-line max-len - message: `child \"kibana\" fails because [child \"space\" fails because [child \"quz\" fails because [\"quz\" at position 0 fails because [\"0\" must be one of [test-space-privilege-1, test-space-privilege-2, test-space-privilege-3]]]]]`, + message: `child \"kibana\" fails because [child \"space\" fails because [child \"quz\" fails because [\"quz\" at position 0 fails because [\"0\" must be one of [all, read, foo_foo-privilege-1, foo_foo-privilege-2, bar_bar-privilege-1, bar_bar-privilege-2]]]]]`, statusCode: 400, validation: { keys: ['kibana.space.quz.0'], @@ -285,11 +298,11 @@ describe('PUT role', () => { run_as: ['test-run-as-1', 'test-run-as-2'], }, kibana: { - global: ['test-global-privilege-1', 'test-global-privilege-2', 'test-global-privilege-3'], + global: ['all', 'read', 'foo_foo-privilege-1', 'foo_foo-privilege-2', 'bar_bar-privilege-1', 'bar_bar-privilege-2'], space: { - 'test-space-1': ['test-space-privilege-1', 'test-space-privilege-2'], - 'test-space-2': ['test-space-privilege-3'], - } + 'test-space-1': ['all', 'read', 'bar_bar-privilege-1', 'bar_bar-privilege-2'], + 'test-space-2': ['all', 'read', 'foo_foo-privilege-1', 'foo_foo-privilege-2'], + }, }, }, preCheckLicenseImpl: defaultPreCheckLicenseImpl, @@ -306,24 +319,32 @@ describe('PUT role', () => { { application, privileges: [ - 'test-global-privilege-1', - 'test-global-privilege-2', - 'test-global-privilege-3' + 'all', + 'read', + 'feature_foo_foo-privilege-1', + 'feature_foo_foo-privilege-2', + 'feature_bar_bar-privilege-1', + 'feature_bar_bar-privilege-2', ], resources: [GLOBAL_RESOURCE], }, { application, privileges: [ - 'space_test-space-privilege-1', - 'space_test-space-privilege-2' + 'space_all', + 'space_read', + 'feature_bar_bar-privilege-1', + 'feature_bar_bar-privilege-2', ], resources: ['space:test-space-1'] }, { application, privileges: [ - 'space_test-space-privilege-3', + 'space_all', + 'space_read', + 'feature_foo_foo-privilege-1', + 'feature_foo_foo-privilege-2', ], resources: ['space:test-space-2'] }, @@ -376,10 +397,10 @@ describe('PUT role', () => { run_as: ['test-run-as-1', 'test-run-as-2'], }, kibana: { - global: ['test-global-privilege-1', 'test-global-privilege-2', 'test-global-privilege-3'], + global: ['all', 'foo_foo-privilege-1', 'bar_bar-privilege-1'], space: { - 'test-space-1': ['test-space-privilege-1', 'test-space-privilege-2'], - 'test-space-2': ['test-space-privilege-3'], + 'test-space-1': ['all', 'foo_foo-privilege-2'], + 'test-space-2': ['read', 'bar_bar-privilege-2'], } }, }, @@ -429,24 +450,25 @@ describe('PUT role', () => { { application, privileges: [ - 'test-global-privilege-1', - 'test-global-privilege-2', - 'test-global-privilege-3' + 'all', + 'feature_foo_foo-privilege-1', + 'feature_bar_bar-privilege-1' ], resources: [GLOBAL_RESOURCE], }, { application, privileges: [ - 'space_test-space-privilege-1', - 'space_test-space-privilege-2' + 'space_all', + 'feature_foo_foo-privilege-2' ], resources: ['space:test-space-1'] }, { application, privileges: [ - 'space_test-space-privilege-3', + 'space_read', + 'feature_bar_bar-privilege-2', ], resources: ['space:test-space-2'] }, @@ -500,9 +522,8 @@ describe('PUT role', () => { }, kibana: { global: [ - 'test-global-privilege-1', - 'test-global-privilege-2', - 'test-global-privilege-3' + 'all', + 'read', ], }, }, @@ -557,9 +578,8 @@ describe('PUT role', () => { { application, privileges: [ - 'test-global-privilege-1', - 'test-global-privilege-2', - 'test-global-privilege-3' + 'all', + 'read', ], resources: [GLOBAL_RESOURCE], }, diff --git a/x-pack/plugins/spaces/server/lib/spaces_client.test.ts b/x-pack/plugins/spaces/server/lib/spaces_client.test.ts index eaf2e2bc5590c..65034265d6dc3 100644 --- a/x-pack/plugins/spaces/server/lib/spaces_client.test.ts +++ b/x-pack/plugins/spaces/server/lib/spaces_client.test.ts @@ -21,7 +21,9 @@ const createMockAuthorization = () => { const mockAuthorization = { actions: { login: 'action:login', - manageSpaces: 'action:manageSpaces', + space: { + manage: 'space:manage', + }, }, checkPrivilegesWithRequest: jest.fn(() => ({ atSpaces: mockCheckPrivilegesAtSpaces, @@ -349,7 +351,7 @@ describe('#canEnumerateSpaces', () => { expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockAuditLogger.spacesAuthorizationFailure).toHaveBeenCalledTimes(0); @@ -381,7 +383,7 @@ describe('#canEnumerateSpaces', () => { expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockAuditLogger.spacesAuthorizationFailure).toHaveBeenCalledTimes(0); @@ -750,7 +752,7 @@ describe('#create', () => { expect(mockAuthorization.mode.useRbacForRequest).toHaveBeenCalledWith(request); expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockAuditLogger.spacesAuthorizationFailure).toHaveBeenCalledWith(username, 'create'); expect(mockAuditLogger.spacesAuthorizationSuccess).toHaveBeenCalledTimes(0); @@ -800,7 +802,7 @@ describe('#create', () => { expect(mockAuthorization.mode.useRbacForRequest).toHaveBeenCalledWith(request); expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockAuditLogger.spacesAuthorizationFailure).toHaveBeenCalledTimes(0); expect(mockAuditLogger.spacesAuthorizationSuccess).toHaveBeenCalledWith(username, 'create'); @@ -847,7 +849,7 @@ describe('#create', () => { expect(mockAuthorization.mode.useRbacForRequest).toHaveBeenCalledWith(request); expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockAuditLogger.spacesAuthorizationFailure).toHaveBeenCalledTimes(0); expect(mockAuditLogger.spacesAuthorizationSuccess).toHaveBeenCalledWith(username, 'create'); @@ -973,7 +975,7 @@ describe('#update', () => { expect(mockAuthorization.mode.useRbacForRequest).toHaveBeenCalledWith(request); expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockAuditLogger.spacesAuthorizationFailure).toHaveBeenCalledWith(username, 'update'); expect(mockAuditLogger.spacesAuthorizationSuccess).toHaveBeenCalledTimes(0); @@ -1009,7 +1011,7 @@ describe('#update', () => { expect(mockAuthorization.mode.useRbacForRequest).toHaveBeenCalledWith(request); expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockInternalRepository.update).toHaveBeenCalledWith('space', id, attributes); expect(mockInternalRepository.get).toHaveBeenCalledWith('space', id); @@ -1180,7 +1182,7 @@ describe('#delete', () => { expect(mockAuthorization.mode.useRbacForRequest).toHaveBeenCalledWith(request); expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockAuditLogger.spacesAuthorizationFailure).toHaveBeenCalledWith(username, 'delete'); expect(mockAuditLogger.spacesAuthorizationSuccess).toHaveBeenCalledTimes(0); @@ -1213,7 +1215,7 @@ describe('#delete', () => { expect(mockAuthorization.mode.useRbacForRequest).toHaveBeenCalledWith(request); expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockInternalRepository.get).toHaveBeenCalledWith('space', id); expect(mockAuditLogger.spacesAuthorizationFailure).toHaveBeenCalledTimes(0); @@ -1250,7 +1252,7 @@ describe('#delete', () => { expect(mockAuthorization.mode.useRbacForRequest).toHaveBeenCalledWith(request); expect(mockAuthorization.checkPrivilegesWithRequest).toHaveBeenCalledWith(request); expect(mockCheckPrivilegesGlobally).toHaveBeenCalledWith( - mockAuthorization.actions.manageSpaces + mockAuthorization.actions.space.manage ); expect(mockInternalRepository.get).toHaveBeenCalledWith('space', id); expect(mockInternalRepository.delete).toHaveBeenCalledWith('space', id); diff --git a/x-pack/plugins/spaces/server/lib/spaces_client.ts b/x-pack/plugins/spaces/server/lib/spaces_client.ts index f4fcc88c7e6f0..c5341da51f487 100644 --- a/x-pack/plugins/spaces/server/lib/spaces_client.ts +++ b/x-pack/plugins/spaces/server/lib/spaces_client.ts @@ -23,7 +23,7 @@ export class SpacesClient { if (this.useRbac()) { const checkPrivileges = this.authorization.checkPrivilegesWithRequest(this.request); const { hasAllRequested } = await checkPrivileges.globally( - this.authorization.actions.manageSpaces + this.authorization.actions.space.manage ); return hasAllRequested; } @@ -93,7 +93,7 @@ export class SpacesClient { public async create(space: Space) { if (this.useRbac()) { await this.ensureAuthorizedGlobally( - this.authorization.actions.manageSpaces, + this.authorization.actions.space.manage, 'create', 'Unauthorized to create spaces' ); @@ -122,7 +122,7 @@ export class SpacesClient { public async update(id: string, space: Space) { if (this.useRbac()) { await this.ensureAuthorizedGlobally( - this.authorization.actions.manageSpaces, + this.authorization.actions.space.manage, 'update', 'Unauthorized to update spaces' ); @@ -140,7 +140,7 @@ export class SpacesClient { public async delete(id: string) { if (this.useRbac()) { await this.ensureAuthorizedGlobally( - this.authorization.actions.manageSpaces, + this.authorization.actions.space.manage, 'delete', 'Unauthorized to delete spaces' ); diff --git a/x-pack/plugins/xpack_main/index.js b/x-pack/plugins/xpack_main/index.js index 40af54d7fb647..448a08f528b8c 100644 --- a/x-pack/plugins/xpack_main/index.js +++ b/x-pack/plugins/xpack_main/index.js @@ -25,6 +25,7 @@ import { settingsRoute } from './server/routes/api/v1/settings'; import mappings from './mappings.json'; export { callClusterFactory } from './server/lib/call_cluster_factory'; +import { registerOssFeatures } from './server/lib/register_oss_features'; /** * Determine if Telemetry is enabled. @@ -119,6 +120,7 @@ export const xpackMain = (kibana) => { mirrorPluginStatus(server.plugins.elasticsearch, this, 'yellow', 'red'); setupXPackMain(server); + registerOssFeatures(); // register routes xpackInfoRoute(server); diff --git a/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts b/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts index 554f1115c2ee9..49a19a9329ef8 100644 --- a/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts +++ b/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts @@ -6,13 +6,27 @@ import { IconType } from '@elastic/eui'; import _ from 'lodash'; + +export interface FeaturePrivilegeDefinition { + api?: string[]; + app: string[]; + savedObject: { + all: string[]; + read: string[]; + }; + ui: string[]; +} + export interface Feature { id: string; name: string; - type: 'app' | 'subFeature'; validLicenses?: Array<'basic' | 'gold' | 'platinum'>; icon?: IconType; description?: string; + navLinkId?: string; + privileges: { + [key: string]: FeaturePrivilegeDefinition; + }; } const features: Record = {}; diff --git a/x-pack/plugins/xpack_main/server/lib/feature_registry/index.ts b/x-pack/plugins/xpack_main/server/lib/feature_registry/index.ts index 4a5d2db9f88ba..2456ac0516ef2 100644 --- a/x-pack/plugins/xpack_main/server/lib/feature_registry/index.ts +++ b/x-pack/plugins/xpack_main/server/lib/feature_registry/index.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { registerFeature, getFeatures } from './feature_registry'; +export { Feature, registerFeature, getFeatures } from './feature_registry'; diff --git a/x-pack/plugins/xpack_main/server/lib/feature_registry/register_oss_features.ts b/x-pack/plugins/xpack_main/server/lib/feature_registry/register_oss_features.ts deleted file mode 100644 index a64e130253f9f..0000000000000 --- a/x-pack/plugins/xpack_main/server/lib/feature_registry/register_oss_features.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Feature, registerFeature } from './feature_registry'; - -const kibanaFeatures: Feature[] = [ - { - id: 'kibana:discover', - name: 'Discover', - type: 'app', - icon: 'discoverApp', - }, - { - id: 'kibana:visualize', - name: 'Visualize', - type: 'app', - icon: 'visualizeApp', - }, - { - id: 'kibana:dashboard', - name: 'Dashboard', - type: 'app', - icon: 'dashboardApp', - }, - { - id: 'kibana:dev_tools', - name: 'Dev Tools', - type: 'app', - icon: 'devToolsApp', - }, - { - id: 'kibana:management', - name: 'Management', - type: 'app', - icon: 'managementApp', - }, -]; - -const timelionFeatures: Feature[] = [ - { - id: 'timelion', - name: 'Timelion', - type: 'app', - icon: 'timelionApp', - }, -]; - -export function registerOssFeatures() { - kibanaFeatures.forEach(registerFeature); - timelionFeatures.forEach(registerFeature); -} diff --git a/x-pack/plugins/xpack_main/server/lib/register_oss_features.ts b/x-pack/plugins/xpack_main/server/lib/register_oss_features.ts new file mode 100644 index 0000000000000..4f7ecfbf901bf --- /dev/null +++ b/x-pack/plugins/xpack_main/server/lib/register_oss_features.ts @@ -0,0 +1,155 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Feature, registerFeature } from './feature_registry'; + +const kibanaFeatures: Feature[] = [ + { + id: 'discover', + name: 'Discover', + icon: 'discoverApp', + navLinkId: 'kibana:discover', + privileges: { + all: { + app: ['kibana'], + savedObject: { + all: ['search'], + read: ['config', 'index-pattern'], + }, + ui: ['kibana:discover'], + }, + read: { + app: ['kibana'], + savedObject: { + all: [], + read: ['config', 'index-pattern', 'search'], + }, + ui: [], + }, + }, + }, + { + id: 'visualize', + name: 'Visualize', + icon: 'visualizeApp', + navLinkId: 'kibana:visualize', + privileges: { + all: { + app: ['kibana'], + savedObject: { + all: ['visualization'], + read: ['config', 'index-pattern', 'search'], + }, + ui: ['kibana:visualize'], + }, + read: { + app: ['kibana'], + savedObject: { + all: [], + read: ['config', 'index-pattern', 'search', 'visualization'], + }, + ui: [], + }, + }, + }, + { + id: 'dashboard', + name: 'Dashboard', + icon: 'dashboardApp', + navLinkId: 'kibana:dashboard', + privileges: { + all: { + app: ['kibana'], + savedObject: { + all: ['dashboard'], + read: ['config', 'index-pattern', 'search', 'visualization', 'timelion', 'canvas'], + }, + ui: ['kibana:dashboard'], + }, + read: { + app: ['kibana'], + savedObject: { + all: [], + read: [ + 'config', + 'index-pattern', + 'search', + 'visualization', + 'timelion', + 'canvas', + 'dashboard', + ], + }, + ui: [], + }, + }, + }, + { + id: 'dev_tools', + name: 'Dev Tools', + icon: 'devToolsApp', + navLinkId: 'kibana:dev_tools', + privileges: { + all: { + api: ['console/execute'], + app: ['kibana'], + savedObject: { + all: [], + read: ['config'], + }, + ui: [], + }, + }, + }, + { + id: 'advancedSettings', + name: 'Advanced Settings', + icon: 'managementApp', + navLinkId: 'kibana:management:advancedSettings', + privileges: { + all: { + app: ['kibana'], + savedObject: { + all: ['config'], + read: [], + }, + ui: [], + }, + }, + }, +]; + +const timelionFeatures: Feature[] = [ + { + id: 'timelion', + name: 'Timelion', + icon: 'timelionApp', + navLinkId: 'timelion', + privileges: { + all: { + app: ['timelion'], + savedObject: { + all: ['timelion'], + read: ['config', 'index-pattern'], + }, + ui: [], + }, + read: { + app: ['timelion'], + savedObject: { + all: [], + read: ['config', 'index-pattern', 'timelion'], + }, + ui: [], + }, + }, + }, +]; + +export function registerOssFeatures() { + kibanaFeatures.forEach(registerFeature); + timelionFeatures.forEach(registerFeature); +} diff --git a/x-pack/plugins/xpack_main/server/lib/setup_xpack_main.js b/x-pack/plugins/xpack_main/server/lib/setup_xpack_main.js index 4ac18a0d7b8e2..2b7f7025e612e 100644 --- a/x-pack/plugins/xpack_main/server/lib/setup_xpack_main.js +++ b/x-pack/plugins/xpack_main/server/lib/setup_xpack_main.js @@ -6,7 +6,7 @@ import { injectXPackInfoSignature } from './inject_xpack_info_signature'; import { XPackInfo } from './xpack_info'; -import { registerFeature } from './feature_registry'; +import { registerFeature, getFeatures } from './feature_registry'; /** * Setup the X-Pack Main plugin. This is fired every time that the Elasticsearch plugin becomes Green. @@ -24,6 +24,7 @@ export function setupXPackMain(server) { server.expose('info', info); server.expose('createXPackInfo', (options) => new XPackInfo(server, options)); server.expose('registerFeature', registerFeature); + server.expose('getFeatures', getFeatures); server.ext('onPreResponse', (request, h) => injectXPackInfoSignature(info, request, h)); const setPluginStatus = () => { diff --git a/x-pack/plugins/xpack_main/types.ts b/x-pack/plugins/xpack_main/types.ts new file mode 100644 index 0000000000000..b6077c3d08698 --- /dev/null +++ b/x-pack/plugins/xpack_main/types.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { Feature } from './server/lib/feature_registry'; diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts index cb93afedcb1d9..df83adb1bae04 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts @@ -143,7 +143,7 @@ export function bulkCreateTestSuiteFactory(es: any, esArchiver: any, supertest: expect(resp.body).to.eql({ statusCode: 403, error: 'Forbidden', - message: `Unable to bulk_create dashboard,globaltype,visualization, missing action:saved_objects/dashboard/bulk_create,action:saved_objects/globaltype/bulk_create,action:saved_objects/visualization/bulk_create`, + message: `Unable to bulk_create dashboard,globaltype,visualization, missing saved_object:dashboard/bulk_create,saved_object:globaltype/bulk_create,saved_object:visualization/bulk_create`, }); }; diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts index dc5b7eaf3c75e..a309216b98b93 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts @@ -87,7 +87,7 @@ export function bulkGetTestSuiteFactory(esArchiver: any, supertest: SuperTest) const createExpectRbacForbidden = (type?: string) => (resp: { [key: string]: any }) => { const message = type - ? `Unable to find ${type}, missing action:saved_objects/${type}/find` + ? `Unable to find ${type}, missing saved_object:${type}/find` : `Not authorized to find saved_object`; expect(resp.body).to.eql({ diff --git a/x-pack/test/saved_object_api_integration/common/suites/get.ts b/x-pack/test/saved_object_api_integration/common/suites/get.ts index 593bf098b0801..16380ad54a116 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/get.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/get.ts @@ -62,7 +62,7 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) const createExpectNotSpaceAwareRbacForbidden = () => (resp: { [key: string]: any }) => { expect(resp.body).to.eql({ error: 'Forbidden', - message: `Unable to get globaltype, missing action:saved_objects/globaltype/get`, + message: `Unable to get globaltype, missing saved_object:globaltype/get`, statusCode: 403, }); }; @@ -84,7 +84,7 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) const createExpectRbacForbidden = (type: string) => (resp: { [key: string]: any }) => { expect(resp.body).to.eql({ error: 'Forbidden', - message: `Unable to get ${type}, missing action:saved_objects/${type}/get`, + message: `Unable to get ${type}, missing saved_object:${type}/get`, statusCode: 403, }); }; diff --git a/x-pack/test/saved_object_api_integration/common/suites/update.ts b/x-pack/test/saved_object_api_integration/common/suites/update.ts index e45fa1928b809..b6a100746c0bc 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/update.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/update.ts @@ -60,7 +60,7 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest Date: Mon, 26 Nov 2018 14:28:01 -0500 Subject: [PATCH 95/95] update snapshot --- .../kibana_privileges.test.tsx.snap | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap index 6f9841fbc213b..ac6c19e7f639b 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/__snapshots__/kibana_privileges.test.tsx.snap @@ -41,19 +41,13 @@ exports[` renders without crashing 1`] = ` }, ] } - userProfile={ + uiCapabilities={ Object { - "id": "marketing", - "name": "Marketing", - }, - ] - } - uiCapabilities={ - Object { - "navLinks": Object {}, - "spaces": Object { - "manage": true, - }, + "navLinks": Object {}, + "spaces": Object { + "manage": true, + }, + } } validator={ RoleValidator {