diff --git a/.buildkite/scripts/steps/storybooks/build_and_upload.ts b/.buildkite/scripts/steps/storybooks/build_and_upload.ts index 4e3ff3c75c576..c91eb6a9b8375 100644 --- a/.buildkite/scripts/steps/storybooks/build_and_upload.ts +++ b/.buildkite/scripts/steps/storybooks/build_and_upload.ts @@ -17,6 +17,7 @@ const STORYBOOKS = [ 'ci_composite', 'cloud', 'coloring', + 'chart_icons', 'controls', 'custom_integrations', 'dashboard_enhanced', diff --git a/NOTICE.txt b/NOTICE.txt index b150cf5673b42..cb1205f317655 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -253,6 +253,32 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Portions of this code are licensed under the following license: For license information please see https://edge.fullstory.com/s/fs.js.LICENSE.txt +--- +This code includes a copy of the `normalize-path` +https://github.com/jonschlinkert/normalize-path/blob/52c3a95ebebc2d98c1ad7606cbafa7e658656899/index.js + +The MIT License (MIT) + +Copyright (c) 2014-2018, Jon Schlinkert. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + --- This product bundles bootstrap@3.3.6 which is available under a "MIT" license. diff --git a/package.json b/package.json index 40eb9ce8aa793..73f979aedc2d0 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,7 @@ "@kbn/analytics-shippers-fullstory": "link:bazel-bin/packages/analytics/shippers/fullstory", "@kbn/apm-config-loader": "link:bazel-bin/packages/kbn-apm-config-loader", "@kbn/apm-utils": "link:bazel-bin/packages/kbn-apm-utils", + "@kbn/chart-icons": "link:bazel-bin/packages/kbn-chart-icons", "@kbn/coloring": "link:bazel-bin/packages/kbn-coloring", "@kbn/config": "link:bazel-bin/packages/kbn-config", "@kbn/config-mocks": "link:bazel-bin/packages/kbn-config-mocks", @@ -779,6 +780,7 @@ "@types/kbn__axe-config": "link:bazel-bin/packages/kbn-axe-config/npm_module_types", "@types/kbn__bazel-packages": "link:bazel-bin/packages/kbn-bazel-packages/npm_module_types", "@types/kbn__bazel-runner": "link:bazel-bin/packages/kbn-bazel-runner/npm_module_types", + "@types/kbn__chart-icons": "link:bazel-bin/packages/kbn-chart-icons/npm_module_types", "@types/kbn__ci-stats-core": "link:bazel-bin/packages/kbn-ci-stats-core/npm_module_types", "@types/kbn__ci-stats-performance-metrics": "link:bazel-bin/packages/kbn-ci-stats-performance-metrics/npm_module_types", "@types/kbn__ci-stats-reporter": "link:bazel-bin/packages/kbn-ci-stats-reporter/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index c0957f7ee2bb8..48977f7ef4fc8 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -133,6 +133,7 @@ filegroup( "//packages/kbn-babel-preset:build", "//packages/kbn-bazel-packages:build", "//packages/kbn-bazel-runner:build", + "//packages/kbn-chart-icons:build", "//packages/kbn-ci-stats-core:build", "//packages/kbn-ci-stats-performance-metrics:build", "//packages/kbn-ci-stats-reporter:build", @@ -393,6 +394,7 @@ filegroup( "//packages/kbn-axe-config:build_types", "//packages/kbn-bazel-packages:build_types", "//packages/kbn-bazel-runner:build_types", + "//packages/kbn-chart-icons:build_types", "//packages/kbn-ci-stats-core:build_types", "//packages/kbn-ci-stats-performance-metrics:build_types", "//packages/kbn-ci-stats-reporter:build_types", diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/icons/index.ts b/packages/kbn-chart-icons/.storybook/main.js similarity index 65% rename from src/plugins/chart_expressions/expression_partition_vis/public/icons/index.ts rename to packages/kbn-chart-icons/.storybook/main.js index e61bd6557d581..8dc3c5d1518f4 100644 --- a/src/plugins/chart_expressions/expression_partition_vis/public/icons/index.ts +++ b/packages/kbn-chart-icons/.storybook/main.js @@ -6,8 +6,4 @@ * Side Public License, v 1. */ -export { PieIcon } from './pie'; -export { DonutIcon } from './donut'; -export { TreemapIcon } from './treemap'; -export { MosaicIcon } from './mosaic'; -export { WaffleIcon } from './waffle'; +module.exports = require('@kbn/storybook').defaultConfig; diff --git a/packages/kbn-chart-icons/BUILD.bazel b/packages/kbn-chart-icons/BUILD.bazel new file mode 100644 index 0000000000000..b3afcf893fd2e --- /dev/null +++ b/packages/kbn-chart-icons/BUILD.bazel @@ -0,0 +1,138 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") + +PKG_DIRNAME = "kbn-chart-icons" +PKG_REQUIRE_NAME = "@kbn/chart-icons" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + "src/**/*.tsx" + ], + exclude = [ + "**/*.test.*", + "**/*.stories.*" + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +# In this array place runtime dependencies, including other packages and NPM packages +# which must be available for this code to run. +# +# To reference other packages use: +# "//repo/relative/path/to/package" +# eg. "//packages/kbn-utils" +# +# To reference a NPM package use: +# "@npm//name-of-package" +# eg. "@npm//lodash" +RUNTIME_DEPS = [ + "//packages/kbn-ui-theme", + "@npm//react", + "@npm//@elastic/eui", + "@npm//@emotion/css", +] + +# In this array place dependencies necessary to build the types, which will include the +# :npm_module_types target of other packages and packages from NPM, including @types/* +# packages. +# +# To reference the types for another package use: +# "//repo/relative/path/to/package:npm_module_types" +# eg. "//packages/kbn-utils:npm_module_types" +# +# References to NPM packages work the same as RUNTIME_DEPS +TYPES_DEPS = [ + "//packages/kbn-ui-theme:npm_module_types", + "@npm//@types/node", + "@npm//@types/jest", + "@npm//@types/react", + "@npm//@elastic/eui", + "@npm//@emotion/css", +] + +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), + root_input_dir = "src", +) + +jsts_transpiler( + name = "target_web", + srcs = SRCS, + build_pkg_name = package_name(), + root_input_dir = "src", + web = True, + additional_args = [ + "--copy-files", + "--quiet" + ], +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + "//:tsconfig.bazel.json", + ], +) + +ts_project( + name = "tsc_types", + args = ['--pretty'], + srcs = SRCS, + deps = TYPES_DEPS, + declaration = True, + declaration_map = True, + emit_declaration_only = True, + out_dir = "target_types", + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_DIRNAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = RUNTIME_DEPS + [":target_node", ":target_web"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [":" + PKG_DIRNAME], +) + +filegroup( + name = "build", + srcs = [":npm_module"], + visibility = ["//visibility:public"], +) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [":npm_module_types"], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-chart-icons/README.md b/packages/kbn-chart-icons/README.md new file mode 100644 index 0000000000000..9e6f13e428e5a --- /dev/null +++ b/packages/kbn-chart-icons/README.md @@ -0,0 +1,5 @@ +# @kbn/chart-icons + +This package contains svg shared assets used in charts + +It can be removes when the [EuiIllustrations](https://github.com/elastic/eui/discussions/5546) initiative is shipped. diff --git a/packages/kbn-chart-icons/jest.config.js b/packages/kbn-chart-icons/jest.config.js new file mode 100644 index 0000000000000..771b3dd8ff9b8 --- /dev/null +++ b/packages/kbn-chart-icons/jest.config.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test/jest_node', + rootDir: '../..', + roots: ['/packages/kbn-chart-icons'], +}; diff --git a/packages/kbn-chart-icons/package.json b/packages/kbn-chart-icons/package.json new file mode 100644 index 0000000000000..c1f5912c1269e --- /dev/null +++ b/packages/kbn-chart-icons/package.json @@ -0,0 +1,8 @@ +{ + "name": "@kbn/chart-icons", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "browser": "./target_web/index.js", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/packages/kbn-chart-icons/src/__stories__/icons.stories.tsx b/packages/kbn-chart-icons/src/__stories__/icons.stories.tsx new file mode 100644 index 0000000000000..a9910001eb923 --- /dev/null +++ b/packages/kbn-chart-icons/src/__stories__/icons.stories.tsx @@ -0,0 +1,221 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React, { FC, ComponentType } from 'react'; +import { EuiFlexItem, EuiFlexGroup, EuiEmptyPrompt, EuiForm, IconType } from '@elastic/eui'; +import { ComponentStory } from '@storybook/react'; + +import { + IconCircle, + IconTriangle, + EuiIconAxisBottom, + EuiIconAxisLeft, + EuiIconAxisRight, + EuiIconAxisTop, + IconChartArea, + IconChartAreaPercentage, + IconChartAreaStacked, + IconChartBar, + IconChartBarAnnotations, + IconChartBarHorizontal, + IconChartBarHorizontalPercentage, + IconChartBarHorizontalStacked, + IconChartBarPercentage, + IconChartBarReferenceLine, + IconChartBarStacked, + IconChartDatatable, + IconChartDonut, + IconChartLine, + IconChartMetric, + IconChartMixedXy, + IconChartMosaic, + IconChartPie, + IconChartTreemap, + IconChartWaffle, + DropIllustration, + GlobeIllustration, + EuiIconLegend, + IconRegionMap, + IconChartHeatmap, + IconChartHorizontalBullet, + IconChartVerticalBullet, +} from '..'; + +export default { + title: 'Chart Icons', + decorators: [(story: Function) => {story()}], +}; + +const IconsArray: Array<{ + title: string; + Component: ComponentType<{ title: string; titleId: string }>; +}> = [ + { + title: 'EuiIconAxisBottom', + Component: EuiIconAxisBottom, + }, + { + title: 'EuiIconAxisLeft', + Component: EuiIconAxisLeft, + }, + { + title: 'EuiIconAxisRight', + Component: EuiIconAxisRight, + }, + { + title: 'EuiIconAxisTop', + Component: EuiIconAxisTop, + }, + { + title: 'IconChartArea', + Component: IconChartArea, + }, + { + title: 'IconChartAreaPercentage', + Component: IconChartAreaPercentage, + }, + { + title: 'IconChartAreaStacked', + Component: IconChartAreaStacked, + }, + { + title: 'IconChartBar', + Component: IconChartBar, + }, + { + title: 'IconChartBarAnnotations', + Component: IconChartBarAnnotations, + }, + { + title: 'IconChartBarHorizontal', + Component: IconChartBarHorizontal, + }, + { + title: 'IconChartBarHorizontalPercentage', + Component: IconChartBarHorizontalPercentage, + }, + { + title: 'IconChartBarHorizontalStacked', + Component: IconChartBarHorizontalStacked, + }, + { + title: 'IconChartBarPercentage', + Component: IconChartBarPercentage, + }, + { + title: 'IconChartBarReferenceLine', + Component: IconChartBarReferenceLine, + }, + { + title: 'IconChartBarStacked', + Component: IconChartBarStacked, + }, + { + title: 'IconChartDatatable', + Component: IconChartDatatable, + }, + { + title: 'IconChartDonut', + Component: IconChartDonut, + }, + { + title: 'IconChartLine', + Component: IconChartLine, + }, + { + title: 'IconChartMetric', + Component: IconChartMetric, + }, + { + title: 'IconChartMixedXy', + Component: IconChartMixedXy, + }, + { + title: 'IconChartMosaic', + Component: IconChartMosaic, + }, + { + title: 'IconChartPie', + Component: IconChartPie, + }, + { + title: 'IconChartTreemap', + Component: IconChartTreemap, + }, + { + title: 'IconChartWaffle', + Component: IconChartWaffle, + }, + { + title: 'DropIllustration', + Component: DropIllustration, + }, + { + title: 'GlobeIllustration', + Component: GlobeIllustration, + }, + { + title: 'EuiIconLegend', + Component: EuiIconLegend, + }, + { + title: 'IconCircle', + Component: IconCircle, + }, + { + title: 'IconTriangle', + Component: IconTriangle, + }, + { + title: 'IconRegionMap', + Component: IconRegionMap, + }, + { + title: 'IconChartHeatmap', + Component: IconChartHeatmap, + }, + { + title: 'IconChartHorizontalBullet', + Component: IconChartHorizontalBullet, + }, + { + title: 'IconChartVerticalBullet', + Component: IconChartVerticalBullet, + }, +]; + +interface RootComponentProps { + icons: typeof IconsArray; +} + +function RootComponent(props: RootComponentProps) { + return ( + + {props.icons.map((i) => ( + + {i.title}} + titleSize={'s'} + /> + + ))} + + ); +} + +const Template: ComponentStory> = (args) => ; + +export const Default = Template.bind({}); + +Default.args = { + icons: IconsArray, +}; diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/circle.tsx b/packages/kbn-chart-icons/src/assets/annotation_icons/circle.tsx similarity index 80% rename from src/plugins/chart_expressions/expression_xy/public/icons/circle.tsx rename to packages/kbn-chart-icons/src/assets/annotation_icons/circle.tsx index 39bbe5cde74de..d3cb3789138f1 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/circle.tsx +++ b/packages/kbn-chart-icons/src/assets/annotation_icons/circle.tsx @@ -8,9 +8,10 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; -import classnames from 'classnames'; +import { cx } from '@emotion/css'; +import { noFill } from '../common_styles'; -export const CircleIcon = ({ title, titleId, ...props }: Omit) => ( +export const IconCircle = ({ title, titleId, ...props }: Omit) => ( diff --git a/x-pack/plugins/lens/public/assets/annotation_icons/index.tsx b/packages/kbn-chart-icons/src/assets/annotation_icons/index.tsx similarity index 56% rename from x-pack/plugins/lens/public/assets/annotation_icons/index.tsx rename to packages/kbn-chart-icons/src/assets/annotation_icons/index.tsx index 9e641d495582f..a776717cfe3c5 100644 --- a/x-pack/plugins/lens/public/assets/annotation_icons/index.tsx +++ b/packages/kbn-chart-icons/src/assets/annotation_icons/index.tsx @@ -1,8 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ export { IconCircle } from './circle'; diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/triangle.tsx b/packages/kbn-chart-icons/src/assets/annotation_icons/triangle.tsx similarity index 83% rename from src/plugins/chart_expressions/expression_xy/public/icons/triangle.tsx rename to packages/kbn-chart-icons/src/assets/annotation_icons/triangle.tsx index 8ffb8c490d9a4..227dc84335821 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/triangle.tsx +++ b/packages/kbn-chart-icons/src/assets/annotation_icons/triangle.tsx @@ -8,9 +8,10 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; -import classnames from 'classnames'; +import { cx } from '@emotion/css'; +import { noFill } from '../common_styles'; -export const TriangleIcon = ({ title, titleId, ...props }: Omit) => ( +export const IconTriangle = ({ title, titleId, ...props }: Omit) => ( ); diff --git a/x-pack/plugins/lens/public/assets/axis_bottom.tsx b/packages/kbn-chart-icons/src/assets/axis_bottom.tsx similarity index 82% rename from x-pack/plugins/lens/public/assets/axis_bottom.tsx rename to packages/kbn-chart-icons/src/assets/axis_bottom.tsx index 309d41bf24221..c2ad925a962de 100644 --- a/x-pack/plugins/lens/public/assets/axis_bottom.tsx +++ b/packages/kbn-chart-icons/src/assets/axis_bottom.tsx @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import * as React from 'react'; +import React from 'react'; export const EuiIconAxisBottom = ({ title, diff --git a/x-pack/plugins/lens/public/assets/axis_left.tsx b/packages/kbn-chart-icons/src/assets/axis_left.tsx similarity index 84% rename from x-pack/plugins/lens/public/assets/axis_left.tsx rename to packages/kbn-chart-icons/src/assets/axis_left.tsx index 9a39a2f43a74d..e4d4361ecfe75 100644 --- a/x-pack/plugins/lens/public/assets/axis_left.tsx +++ b/packages/kbn-chart-icons/src/assets/axis_left.tsx @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import * as React from 'react'; +import React from 'react'; export const EuiIconAxisLeft = ({ title, diff --git a/x-pack/plugins/lens/public/assets/axis_right.tsx b/packages/kbn-chart-icons/src/assets/axis_right.tsx similarity index 84% rename from x-pack/plugins/lens/public/assets/axis_right.tsx rename to packages/kbn-chart-icons/src/assets/axis_right.tsx index 4db6fc06d82fa..8316fbe713388 100644 --- a/x-pack/plugins/lens/public/assets/axis_right.tsx +++ b/packages/kbn-chart-icons/src/assets/axis_right.tsx @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import * as React from 'react'; +import React from 'react'; export const EuiIconAxisRight = ({ title, diff --git a/x-pack/plugins/lens/public/assets/axis_top.tsx b/packages/kbn-chart-icons/src/assets/axis_top.tsx similarity index 92% rename from x-pack/plugins/lens/public/assets/axis_top.tsx rename to packages/kbn-chart-icons/src/assets/axis_top.tsx index 2c3dc0744c068..d78dfcc113aad 100644 --- a/x-pack/plugins/lens/public/assets/axis_top.tsx +++ b/packages/kbn-chart-icons/src/assets/axis_top.tsx @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import * as React from 'react'; +import React from 'react'; export const EuiIconAxisTop = ({ title, diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/area.tsx b/packages/kbn-chart-icons/src/assets/chart_area.tsx similarity index 83% rename from src/plugins/chart_expressions/expression_xy/public/icons/area.tsx rename to packages/kbn-chart-icons/src/assets/chart_area.tsx index 010ffaf1fb7ec..a09a9cab956ad 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/area.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_area.tsx @@ -8,8 +8,9 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const AreaIcon = ({ title, titleId, ...props }: Omit) => ( +export const IconChartArea = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_area_percentage.tsx b/packages/kbn-chart-icons/src/assets/chart_area_percentage.tsx similarity index 82% rename from x-pack/plugins/lens/public/assets/chart_area_percentage.tsx rename to packages/kbn-chart-icons/src/assets/chart_area_percentage.tsx index 910d5dc817289..07917b1bcabc2 100644 --- a/x-pack/plugins/lens/public/assets/chart_area_percentage.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_area_percentage.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartAreaPercentage = ({ +export const IconChartAreaPercentage = ({ title, titleId, ...props @@ -25,11 +27,11 @@ export const LensIconChartAreaPercentage = ({ {title ? {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_area_stacked.tsx b/packages/kbn-chart-icons/src/assets/chart_area_stacked.tsx similarity index 79% rename from x-pack/plugins/lens/public/assets/chart_area_stacked.tsx rename to packages/kbn-chart-icons/src/assets/chart_area_stacked.tsx index 16e1ff849b609..3bfe3cd92b85b 100644 --- a/x-pack/plugins/lens/public/assets/chart_area_stacked.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_area_stacked.tsx @@ -1,18 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartAreaStacked = ({ - title, - titleId, - ...props -}: Omit) => ( +export const IconChartAreaStacked = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/bar.tsx b/packages/kbn-chart-icons/src/assets/chart_bar.tsx similarity index 83% rename from src/plugins/chart_expressions/expression_xy/public/icons/bar.tsx rename to packages/kbn-chart-icons/src/assets/chart_bar.tsx index f134d7871bfde..f33b83fca5362 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/bar.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_bar.tsx @@ -8,8 +8,9 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const BarIcon = ({ title, titleId, ...props }: Omit) => ( +export const IconChartBar = ({ title, titleId, ...props }: Omit) => ( {title ? {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_bar_annotations.tsx b/packages/kbn-chart-icons/src/assets/chart_bar_annotations.tsx similarity index 73% rename from x-pack/plugins/lens/public/assets/chart_bar_annotations.tsx rename to packages/kbn-chart-icons/src/assets/chart_bar_annotations.tsx index 63fc9023533f6..9472cbc0cd762 100644 --- a/x-pack/plugins/lens/public/assets/chart_bar_annotations.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_bar_annotations.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartBarAnnotations = ({ +export const IconChartBarAnnotations = ({ title, titleId, ...props @@ -25,11 +27,11 @@ export const LensIconChartBarAnnotations = ({ {title ? {title} : null} diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal.tsx b/packages/kbn-chart-icons/src/assets/chart_bar_horizontal.tsx similarity index 80% rename from src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal.tsx rename to packages/kbn-chart-icons/src/assets/chart_bar_horizontal.tsx index a2fb843cb095d..dc113a8ab4ad9 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_bar_horizontal.tsx @@ -8,8 +8,13 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const BarHorizontalIcon = ({ title, titleId, ...props }: Omit) => ( +export const IconChartBarHorizontal = ({ + title, + titleId, + ...props +}: Omit) => ( {title} : null} ); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal_percentage.tsx b/packages/kbn-chart-icons/src/assets/chart_bar_horizontal_percentage.tsx similarity index 87% rename from src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal_percentage.tsx rename to packages/kbn-chart-icons/src/assets/chart_bar_horizontal_percentage.tsx index 6b2bb61a246e1..91e8f2639bfa5 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal_percentage.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_bar_horizontal_percentage.tsx @@ -8,8 +8,9 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const BarHorizontalPercentageIcon = ({ +export const IconChartBarHorizontalPercentage = ({ title, titleId, ...props @@ -26,11 +27,11 @@ export const BarHorizontalPercentageIcon = ({ {title ? {title} : null} ); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal_stacked.tsx b/packages/kbn-chart-icons/src/assets/chart_bar_horizontal_stacked.tsx similarity index 87% rename from src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal_stacked.tsx rename to packages/kbn-chart-icons/src/assets/chart_bar_horizontal_stacked.tsx index b399c47d3fc7d..6e5e61e386467 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/bar_horizontal_stacked.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_bar_horizontal_stacked.tsx @@ -8,8 +8,9 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const BarHorizontalStackedIcon = ({ +export const IconChartBarHorizontalStacked = ({ title, titleId, ...props @@ -26,11 +27,11 @@ export const BarHorizontalStackedIcon = ({ {title ? {title} : null} ); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/bar_percentage.tsx b/packages/kbn-chart-icons/src/assets/chart_bar_percentage.tsx similarity index 82% rename from src/plugins/chart_expressions/expression_xy/public/icons/bar_percentage.tsx rename to packages/kbn-chart-icons/src/assets/chart_bar_percentage.tsx index 64514cea6c012..82a59ebc9be32 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/bar_percentage.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_bar_percentage.tsx @@ -8,8 +8,13 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const BarPercentageIcon = ({ title, titleId, ...props }: Omit) => ( +export const IconChartBarPercentage = ({ + title, + titleId, + ...props +}: Omit) => ( {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_bar_reference_line.tsx b/packages/kbn-chart-icons/src/assets/chart_bar_reference_line.tsx similarity index 79% rename from x-pack/plugins/lens/public/assets/chart_bar_reference_line.tsx rename to packages/kbn-chart-icons/src/assets/chart_bar_reference_line.tsx index 447641540a284..d8cca5a3f1192 100644 --- a/x-pack/plugins/lens/public/assets/chart_bar_reference_line.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_bar_reference_line.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartBarReferenceLine = ({ +export const IconChartBarReferenceLine = ({ title, titleId, ...props @@ -25,16 +27,10 @@ export const LensIconChartBarReferenceLine = ({ {title ? {title} : null} - + ); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/bar_stacked.tsx b/packages/kbn-chart-icons/src/assets/chart_bar_stacked.tsx similarity index 83% rename from src/plugins/chart_expressions/expression_xy/public/icons/bar_stacked.tsx rename to packages/kbn-chart-icons/src/assets/chart_bar_stacked.tsx index 833f3d0e816e6..933be6d5dea7a 100644 --- a/src/plugins/chart_expressions/expression_xy/public/icons/bar_stacked.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_bar_stacked.tsx @@ -8,8 +8,9 @@ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const BarStackedIcon = ({ title, titleId, ...props }: Omit) => ( +export const IconChartBarStacked = ({ title, titleId, ...props }: Omit) => ( {title ? {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_datatable.tsx b/packages/kbn-chart-icons/src/assets/chart_datatable.tsx similarity index 75% rename from x-pack/plugins/lens/public/assets/chart_datatable.tsx rename to packages/kbn-chart-icons/src/assets/chart_datatable.tsx index d6a5cb733e1e1..144d6ddb906f5 100644 --- a/x-pack/plugins/lens/public/assets/chart_datatable.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_datatable.tsx @@ -1,18 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartDatatable = ({ - title, - titleId, - ...props -}: Omit) => ( +export const IconChartDatatable = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_donut.tsx b/packages/kbn-chart-icons/src/assets/chart_donut.tsx similarity index 71% rename from x-pack/plugins/lens/public/assets/chart_donut.tsx rename to packages/kbn-chart-icons/src/assets/chart_donut.tsx index f2ce65a1f2e19..bd9e3f59e72a1 100644 --- a/x-pack/plugins/lens/public/assets/chart_donut.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_donut.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartDonut = ({ title, titleId, ...props }: Omit) => ( +export const IconChartDonut = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_icon.tsx b/packages/kbn-chart-icons/src/assets/chart_heatmap.tsx similarity index 85% rename from src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_icon.tsx rename to packages/kbn-chart-icons/src/assets/chart_heatmap.tsx index 7a49d53222946..0609c7263f202 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_icon.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_heatmap.tsx @@ -8,11 +8,9 @@ import { EuiIconProps } from '@elastic/eui'; import React from 'react'; -import { useCommonChartStyles } from '@kbn/charts-plugin/public'; - -export const HeatmapIcon = ({ title, titleId, ...props }: Omit) => { - const { chartIcon } = useCommonChartStyles(); +import { colors } from './common_styles'; +export const IconChartHeatmap = ({ title, titleId, ...props }: Omit) => { return ( {title ? {title} : null} diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/icons/horizontal_bullet_icon.tsx b/packages/kbn-chart-icons/src/assets/chart_horizontal_bullet.tsx similarity index 80% rename from src/plugins/chart_expressions/expression_gauge/public/components/icons/horizontal_bullet_icon.tsx rename to packages/kbn-chart-icons/src/assets/chart_horizontal_bullet.tsx index 5074f00801109..0765444e857a6 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/icons/horizontal_bullet_icon.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_horizontal_bullet.tsx @@ -8,11 +8,13 @@ import React from 'react'; import type { EuiIconProps } from '@elastic/eui'; -import { useCommonChartStyles } from '@kbn/charts-plugin/public'; - -export const HorizontalBulletIcon = ({ title, titleId, ...props }: Omit) => { - const { chartIcon } = useCommonChartStyles(); +import { colors } from './common_styles'; +export const IconChartHorizontalBullet = ({ + title, + titleId, + ...props +}: Omit) => { return ( {title ? {title} : null} diff --git a/x-pack/plugins/lens/public/assets/chart_line.tsx b/packages/kbn-chart-icons/src/assets/chart_line.tsx similarity index 83% rename from x-pack/plugins/lens/public/assets/chart_line.tsx rename to packages/kbn-chart-icons/src/assets/chart_line.tsx index 82df68d8fd43c..afaf31b708621 100644 --- a/x-pack/plugins/lens/public/assets/chart_line.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_line.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartLine = ({ title, titleId, ...props }: Omit) => ( +export const IconChartLine = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_metric.tsx b/packages/kbn-chart-icons/src/assets/chart_metric.tsx similarity index 75% rename from x-pack/plugins/lens/public/assets/chart_metric.tsx rename to packages/kbn-chart-icons/src/assets/chart_metric.tsx index d15be760eec60..4feb162a4607c 100644 --- a/x-pack/plugins/lens/public/assets/chart_metric.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_metric.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartMetric = ({ title, titleId, ...props }: Omit) => ( +export const IconChartMetric = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_mixed_xy.tsx b/packages/kbn-chart-icons/src/assets/chart_mixed_xy.tsx similarity index 84% rename from x-pack/plugins/lens/public/assets/chart_mixed_xy.tsx rename to packages/kbn-chart-icons/src/assets/chart_mixed_xy.tsx index bb213217a9fa9..af86b96852dc9 100644 --- a/x-pack/plugins/lens/public/assets/chart_mixed_xy.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_mixed_xy.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartMixedXy = ({ title, titleId, ...props }: Omit) => ( +export const IconChartMixedXy = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_mosaic.tsx b/packages/kbn-chart-icons/src/assets/chart_mosaic.tsx similarity index 73% rename from x-pack/plugins/lens/public/assets/chart_mosaic.tsx rename to packages/kbn-chart-icons/src/assets/chart_mosaic.tsx index c385f0df1a008..23fe548074d5a 100644 --- a/x-pack/plugins/lens/public/assets/chart_mosaic.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_mosaic.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import type { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartMosaic = ({ title, titleId, ...props }: Omit) => ( +export const IconChartMosaic = ({ title, titleId, ...props }: Omit) => ( {title ? : null} diff --git a/x-pack/plugins/lens/public/assets/chart_pie.tsx b/packages/kbn-chart-icons/src/assets/chart_pie.tsx similarity index 68% rename from x-pack/plugins/lens/public/assets/chart_pie.tsx rename to packages/kbn-chart-icons/src/assets/chart_pie.tsx index 56a18b9d61624..16d59e73603ca 100644 --- a/x-pack/plugins/lens/public/assets/chart_pie.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_pie.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartPie = ({ title, titleId, ...props }: Omit) => ( +export const IconChartPie = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/x-pack/plugins/lens/public/assets/chart_treemap.tsx b/packages/kbn-chart-icons/src/assets/chart_treemap.tsx similarity index 64% rename from x-pack/plugins/lens/public/assets/chart_treemap.tsx rename to packages/kbn-chart-icons/src/assets/chart_treemap.tsx index c56fdedfebdf7..587682994102a 100644 --- a/x-pack/plugins/lens/public/assets/chart_treemap.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_treemap.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartTreemap = ({ title, titleId, ...props }: Omit) => ( +export const IconChartTreemap = ({ title, titleId, ...props }: Omit) => ( {title} : null} ); diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/icons/vertical_bullet_icon.tsx b/packages/kbn-chart-icons/src/assets/chart_vertical_bullet.tsx similarity index 77% rename from src/plugins/chart_expressions/expression_gauge/public/components/icons/vertical_bullet_icon.tsx rename to packages/kbn-chart-icons/src/assets/chart_vertical_bullet.tsx index 49a1e2a817cf7..5cf427af7d238 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/icons/vertical_bullet_icon.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_vertical_bullet.tsx @@ -8,11 +8,13 @@ import React from 'react'; import type { EuiIconProps } from '@elastic/eui'; -import { useCommonChartStyles } from '@kbn/charts-plugin/public'; - -export const VerticalBulletIcon = ({ title, titleId, ...props }: Omit) => { - const { chartIcon } = useCommonChartStyles(); +import { colors } from './common_styles'; +export const IconChartVerticalBullet = ({ + title, + titleId, + ...props +}: Omit) => { return ( {title ? {title} : null} diff --git a/x-pack/plugins/lens/public/assets/chart_waffle.tsx b/packages/kbn-chart-icons/src/assets/chart_waffle.tsx similarity index 80% rename from x-pack/plugins/lens/public/assets/chart_waffle.tsx rename to packages/kbn-chart-icons/src/assets/chart_waffle.tsx index b9ee0557faea9..aeeca67a1a511 100644 --- a/x-pack/plugins/lens/public/assets/chart_waffle.tsx +++ b/packages/kbn-chart-icons/src/assets/chart_waffle.tsx @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import React from 'react'; import type { EuiIconProps } from '@elastic/eui'; +import { colors } from './common_styles'; -export const LensIconChartWaffle = ({ title, titleId, ...props }: Omit) => ( +export const IconChartWaffle = ({ title, titleId, ...props }: Omit) => ( {title ? : null} diff --git a/packages/kbn-chart-icons/src/assets/common_styles.tsx b/packages/kbn-chart-icons/src/assets/common_styles.tsx new file mode 100644 index 0000000000000..21409b5cb6670 --- /dev/null +++ b/packages/kbn-chart-icons/src/assets/common_styles.tsx @@ -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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { css } from '@emotion/css'; +import { euiThemeVars } from '@kbn/ui-theme'; + +export const colors = { + subdued: css` + fill: ${euiThemeVars.euiTextSubduedColor}; + `, + accent: css` + fill: ${euiThemeVars.euiColorVis0}; + `, +}; + +export const noFill = css` + fill: none; +`; diff --git a/x-pack/plugins/lens/public/assets/drop_illustration.tsx b/packages/kbn-chart-icons/src/assets/drop_illustration.tsx similarity index 99% rename from x-pack/plugins/lens/public/assets/drop_illustration.tsx rename to packages/kbn-chart-icons/src/assets/drop_illustration.tsx index acd6d7bf31324..c35d46f48c758 100644 --- a/x-pack/plugins/lens/public/assets/drop_illustration.tsx +++ b/packages/kbn-chart-icons/src/assets/drop_illustration.tsx @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import * as React from 'react'; +import React from 'react'; import { EuiIconProps } from '@elastic/eui'; export const DropIllustration = ({ title, titleId, ...props }: Omit) => ( diff --git a/x-pack/plugins/lens/public/assets/globe_illustration.tsx b/packages/kbn-chart-icons/src/assets/globe_illustration.tsx similarity index 98% rename from x-pack/plugins/lens/public/assets/globe_illustration.tsx rename to packages/kbn-chart-icons/src/assets/globe_illustration.tsx index af2f2c7a48e46..b84d39705f632 100644 --- a/x-pack/plugins/lens/public/assets/globe_illustration.tsx +++ b/packages/kbn-chart-icons/src/assets/globe_illustration.tsx @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import * as React from 'react'; +import React from 'react'; import { EuiIconProps } from '@elastic/eui'; export const GlobeIllustration = ({ title, titleId, ...props }: Omit) => ( diff --git a/packages/kbn-chart-icons/src/assets/index.ts b/packages/kbn-chart-icons/src/assets/index.ts new file mode 100644 index 0000000000000..d3d2f968cdcc5 --- /dev/null +++ b/packages/kbn-chart-icons/src/assets/index.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { IconCircle, IconTriangle } from './annotation_icons'; + +export { EuiIconAxisBottom } from './axis_bottom'; +export { EuiIconAxisLeft } from './axis_left'; +export { EuiIconAxisRight } from './axis_right'; +export { EuiIconAxisTop } from './axis_top'; + +export { IconChartArea } from './chart_area'; +export { IconChartAreaPercentage } from './chart_area_percentage'; +export { IconChartAreaStacked } from './chart_area_stacked'; +export { IconChartBar } from './chart_bar'; +export { IconChartBarAnnotations } from './chart_bar_annotations'; +export { IconChartBarHorizontal } from './chart_bar_horizontal'; +export { IconChartBarHorizontalPercentage } from './chart_bar_horizontal_percentage'; +export { IconChartBarHorizontalStacked } from './chart_bar_horizontal_stacked'; +export { IconChartBarPercentage } from './chart_bar_percentage'; +export { IconChartBarReferenceLine } from './chart_bar_reference_line'; +export { IconChartBarStacked } from './chart_bar_stacked'; +export { IconChartDatatable } from './chart_datatable'; +export { IconChartDonut } from './chart_donut'; +export { IconChartLine } from './chart_line'; +export { IconChartMetric } from './chart_metric'; +export { IconChartMixedXy } from './chart_mixed_xy'; +export { IconChartMosaic } from './chart_mosaic'; +export { IconChartPie } from './chart_pie'; +export { IconChartTreemap } from './chart_treemap'; +export { IconChartWaffle } from './chart_waffle'; +export { DropIllustration } from './drop_illustration'; +export { GlobeIllustration } from './globe_illustration'; +export { EuiIconLegend } from './legend'; +export { IconRegionMap } from './region_map'; +export { IconChartHeatmap } from './chart_heatmap'; +export { IconChartHorizontalBullet } from './chart_horizontal_bullet'; +export { IconChartVerticalBullet } from './chart_vertical_bullet'; diff --git a/x-pack/plugins/lens/public/assets/legend.tsx b/packages/kbn-chart-icons/src/assets/legend.tsx similarity index 84% rename from x-pack/plugins/lens/public/assets/legend.tsx rename to packages/kbn-chart-icons/src/assets/legend.tsx index cde39b222cdd4..ce1a8ef9dcbc4 100644 --- a/x-pack/plugins/lens/public/assets/legend.tsx +++ b/packages/kbn-chart-icons/src/assets/legend.tsx @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import * as React from 'react'; +import React from 'react'; export const EuiIconLegend = ({ title, titleId, ...props }: { title: string; titleId: string }) => ( {title ? : null} diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/icons/index.ts b/packages/kbn-chart-icons/src/index.ts similarity index 73% rename from src/plugins/chart_expressions/expression_gauge/public/components/icons/index.ts rename to packages/kbn-chart-icons/src/index.ts index 79ef0dcad9d7a..f279aa93de165 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/icons/index.ts +++ b/packages/kbn-chart-icons/src/index.ts @@ -6,5 +6,4 @@ * Side Public License, v 1. */ -export { HorizontalBulletIcon } from './horizontal_bullet_icon'; -export { VerticalBulletIcon } from './vertical_bullet_icon'; +export * from './assets'; diff --git a/packages/kbn-chart-icons/tsconfig.json b/packages/kbn-chart-icons/tsconfig.json new file mode 100644 index 0000000000000..1984d8ed8bbef --- /dev/null +++ b/packages/kbn-chart-icons/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "rootDir": "src", + "types": [ + "jest", + "node", + "react", + "@emotion/css/types" + ], + }, + "include": [ + "src/**/*", + ] +} diff --git a/packages/kbn-ui-shared-deps-npm/webpack.config.js b/packages/kbn-ui-shared-deps-npm/webpack.config.js index ddcb71fdb2c86..d3739f26e1e38 100644 --- a/packages/kbn-ui-shared-deps-npm/webpack.config.js +++ b/packages/kbn-ui-shared-deps-npm/webpack.config.js @@ -71,9 +71,9 @@ module.exports = (_, argv) => { // modules from npm '@elastic/charts', '@elastic/eui', + '@elastic/eui/optimize/es/services', + '@elastic/eui/optimize/es/services/format', '@elastic/eui/dist/eui_charts_theme', - '@elastic/eui/lib/services', - '@elastic/eui/lib/services/format', '@elastic/eui/dist/eui_theme_light.json', '@elastic/eui/dist/eui_theme_dark.json', '@elastic/numeral', diff --git a/packages/kbn-ui-shared-deps-src/src/entry.js b/packages/kbn-ui-shared-deps-src/src/entry.js index bc521a2d72ecc..9114a472ba53e 100644 --- a/packages/kbn-ui-shared-deps-src/src/entry.js +++ b/packages/kbn-ui-shared-deps-src/src/entry.js @@ -39,8 +39,8 @@ export const RxjsOperators = require('rxjs/operators'); export const ElasticNumeral = require('@elastic/numeral'); export const ElasticCharts = require('@elastic/charts'); export const ElasticEui = require('@elastic/eui'); -export const ElasticEuiLibServices = require('@elastic/eui/lib/services'); -export const ElasticEuiLibServicesFormat = require('@elastic/eui/lib/services/format'); +export const ElasticEuiLibServices = require('@elastic/eui/optimize/es/services'); +export const ElasticEuiLibServicesFormat = require('@elastic/eui/optimize/es/services/format'); export const ElasticEuiChartsTheme = require('@elastic/eui/dist/eui_charts_theme'); export const KbnDatemath = require('@kbn/datemath'); export const ReactBeautifulDnD = require('react-beautiful-dnd'); diff --git a/src/dev/build/build_distributables.ts b/src/dev/build/build_distributables.ts index a3c2737857a68..fd61eca075a11 100644 --- a/src/dev/build/build_distributables.ts +++ b/src/dev/build/build_distributables.ts @@ -83,9 +83,14 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions await run(Tasks.CreatePackageJson); await run(Tasks.InstallDependencies); await run(Tasks.GeneratePackagesOptimizedAssets); - await run(Tasks.DeleteBazelPackagesFromBuildRoot); + + // Run on all source files + // **/packages need to be read + // before DeleteBazelPackagesFromBuildRoot await run(Tasks.CreateNoticeFile); await run(Tasks.CreateXPackNoticeFile); + + await run(Tasks.DeleteBazelPackagesFromBuildRoot); await run(Tasks.UpdateLicenseFile); await run(Tasks.RemovePackageJsonDeps); await run(Tasks.CleanPackageManagerRelatedFiles); diff --git a/src/dev/notice/generate_notice_from_source.ts b/src/dev/notice/generate_notice_from_source.ts index 8d162154bc5f0..7abfce7891c1a 100644 --- a/src/dev/notice/generate_notice_from_source.ts +++ b/src/dev/notice/generate_notice_from_source.ts @@ -6,7 +6,10 @@ * Side Public License, v 1. */ -import vfs from 'vinyl-fs'; +import { readFile } from 'fs/promises'; +import { relative } from 'path'; +import globby from 'globby'; + import { ToolingLog } from '@kbn/tooling-log'; const NOTICE_COMMENT_RE = /\/\*[\s\n\*]*@notice([\w\W]+?)\*\//g; @@ -30,45 +33,37 @@ interface Options { * into the repository. */ export async function generateNoticeFromSource({ productName, directory, log }: Options) { - const globs = ['**/*.{js,less,css,ts,tsx}']; - - const options = { - cwd: directory, - nodir: true, - ignore: [ - '{node_modules,build,dist,data,built_assets}/**', - 'packages/*/{node_modules,build,dist}/**', - 'src/plugins/*/{node_modules,build,dist}/**', - 'x-pack/{node_modules,build,dist,data}/**', - 'x-pack/packages/*/{node_modules,build,dist}/**', - 'x-pack/plugins/**/{node_modules,build,dist}/**', - '**/target/**', - ], - }; + const select = [ + '**/*.{js,mjs,scss,css,ts,tsx}', + '!{node_modules,build,dist,data,built_assets,shared_built_assets}/**', + '!packages/*/{node_modules,build,dist}/**', + '!src/plugins/*/{node_modules,build,dist}/**', + '!x-pack/{node_modules,build,dist,data}/**', + '!x-pack/packages/*/{node_modules,build,dist}/**', + '!x-pack/plugins/**/{node_modules,build,dist}/**', + '!**/target/**', + ]; - log.debug('vfs.src globs', globs); - log.debug('vfs.src options', options); log.info(`Searching ${directory} for multi-line comments starting with @notice`); - const files = vfs.src(globs, options); - const noticeComments: string[] = []; - await new Promise((resolve, reject) => { - files - .on('data', (file) => { - log.verbose(`Checking for @notice comments in ${file.relative}`); - - const source = file.contents.toString('utf8'); - let match; - while ((match = NOTICE_COMMENT_RE.exec(source)) !== null) { - log.info(`Found @notice comment in ${file.relative}`); - if (!noticeComments.includes(match[1])) { - noticeComments.push(match[1]); - } - } - }) - .on('error', reject) - .on('end', resolve); + const files = globby.stream(select, { + cwd: directory, + followSymbolicLinks: false, + absolute: true, }); + const noticeComments: string[] = []; + for await (const file of files) { + const source = await readFile(file, 'utf-8'); + const relativeFile = relative(directory, file.toString()); + log.verbose(`Checking for @notice comments in ${relativeFile}`); + let match; + while ((match = NOTICE_COMMENT_RE.exec(source)) !== null) { + log.info(`Found @notice comment in ${relativeFile}`); + if (!noticeComments.includes(match[1])) { + noticeComments.push(match[1]); + } + } + } let noticeText = ''; noticeText += `${productName}\n`; diff --git a/src/dev/storybook/aliases.ts b/src/dev/storybook/aliases.ts index 89e78848a1366..65035c0c95f72 100644 --- a/src/dev/storybook/aliases.ts +++ b/src/dev/storybook/aliases.ts @@ -13,6 +13,7 @@ export const storybookAliases = { ci_composite: '.ci/.storybook', cloud: 'x-pack/plugins/cloud/.storybook', coloring: 'packages/kbn-coloring/.storybook', + chart_icons: 'packages/kbn-chart-icons/.storybook', controls: 'src/plugins/controls/storybook', custom_integrations: 'src/plugins/custom_integrations/storybook', dashboard_enhanced: 'x-pack/plugins/dashboard_enhanced/.storybook', diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx b/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx index 232b522838b8e..b75d613f814a7 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx +++ b/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx @@ -21,7 +21,6 @@ import { } from '../../common'; import { getAccessorsFromArgs, - getIcons, getMaxValue, getMinValue, getValueFromAccessor, @@ -29,6 +28,7 @@ import { getGoalConfig, computeMinMax, } from './utils'; +import { getIcons } from './utils/icons'; import './index.scss'; import { GaugeCentralMajorMode } from '../../common/types'; import { isBulletShape, isRoundShape } from '../../common/utils'; diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/utils/icons.ts b/src/plugins/chart_expressions/expression_gauge/public/components/utils/icons.ts index 734c64d579da3..33d8427892392 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/utils/icons.ts +++ b/src/plugins/chart_expressions/expression_gauge/public/components/utils/icons.ts @@ -6,13 +6,13 @@ * Side Public License, v 1. */ +import { IconChartHorizontalBullet, IconChartVerticalBullet } from '@kbn/chart-icons'; import { GaugeShape, GaugeShapes } from '../../../common'; -import { HorizontalBulletIcon } from '../icons'; export const getIcons = (type: GaugeShape) => ({ - [GaugeShapes.HORIZONTAL_BULLET]: HorizontalBulletIcon, - [GaugeShapes.VERTICAL_BULLET]: HorizontalBulletIcon, + [GaugeShapes.HORIZONTAL_BULLET]: IconChartHorizontalBullet, + [GaugeShapes.VERTICAL_BULLET]: IconChartVerticalBullet, [GaugeShapes.ARC]: 'visGoal', [GaugeShapes.CIRCLE]: 'visGoal', }[type]); diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/utils/index.ts b/src/plugins/chart_expressions/expression_gauge/public/components/utils/index.ts index 87f6a520ff9eb..639c2a7821b55 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/utils/index.ts +++ b/src/plugins/chart_expressions/expression_gauge/public/components/utils/index.ts @@ -7,7 +7,6 @@ */ export * from './accessors'; -export * from './icons'; export * from './gauge_types'; export * from './goal_config'; diff --git a/src/plugins/chart_expressions/expression_gauge/public/index.ts b/src/plugins/chart_expressions/expression_gauge/public/index.ts index 6f9924759e4c4..fc40382a8702a 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/index.ts +++ b/src/plugins/chart_expressions/expression_gauge/public/index.ts @@ -13,4 +13,3 @@ export function plugin() { } export { getGoalValue, getMaxValue, getMinValue, getValueFromAccessor } from './components/utils'; -export { VerticalBulletIcon, HorizontalBulletIcon } from './components/icons'; diff --git a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx index 35a3d54fe58c0..f2db5a25ff429 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx +++ b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx @@ -35,6 +35,7 @@ import { LegendSizeToPixels, } from '@kbn/visualizations-plugin/common/constants'; import { DatatableColumn } from '@kbn/expressions-plugin/public'; +import { IconChartHeatmap } from '@kbn/chart-icons'; import type { HeatmapRenderProps, FilterEvent, BrushEvent } from '../../common'; import { applyPaletteParams, @@ -47,7 +48,6 @@ import { LegendColorPickerWrapper, } from '../utils/get_color_picker'; import { defaultPaletteParams } from '../constants'; -import { HeatmapIcon } from './heatmap_icon'; import './index.scss'; declare global { @@ -366,7 +366,7 @@ export const HeatmapComponent: FC = memo( ); if (!chartData || !chartData.length) { - return ; + return ; } if (!yAxisColumn) { @@ -567,7 +567,9 @@ export const HeatmapComponent: FC = memo( } + noResults={ + + } onElementClick={interactive ? (onElementClick as ElementClickListener) : undefined} showLegend={showLegend ?? args.legend.isVisible} legendPosition={args.legend.position} diff --git a/src/plugins/chart_expressions/expression_heatmap/public/index.ts b/src/plugins/chart_expressions/expression_heatmap/public/index.ts index f6aa926a8fef2..fbbf8027eb343 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/index.ts +++ b/src/plugins/chart_expressions/expression_heatmap/public/index.ts @@ -11,5 +11,3 @@ import { ExpressionHeatmapPlugin } from './plugin'; export function plugin() { return new ExpressionHeatmapPlugin(); } - -export { HeatmapIcon } from './components/heatmap_icon'; diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/icons/donut.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/icons/donut.tsx deleted file mode 100644 index 3101164bfe88d..0000000000000 --- a/src/plugins/chart_expressions/expression_partition_vis/public/icons/donut.tsx +++ /dev/null @@ -1,37 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; -import { useCommonChartStyles } from '@kbn/charts-plugin/public'; - -export const DonutIcon = ({ title, titleId, ...props }: Omit) => { - const { chartIcon } = useCommonChartStyles(); - - return ( - - {title ? {title} : null} - - - - ); -}; diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/icons/mosaic.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/icons/mosaic.tsx deleted file mode 100644 index 1f5c99702f869..0000000000000 --- a/src/plugins/chart_expressions/expression_partition_vis/public/icons/mosaic.tsx +++ /dev/null @@ -1,37 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import type { EuiIconProps } from '@elastic/eui'; -import { useCommonChartStyles } from '@kbn/charts-plugin/public'; - -export const MosaicIcon = ({ title, titleId, ...props }: Omit) => { - const { chartIcon } = useCommonChartStyles(); - - return ( - - {title ? : null} - - - - ); -}; diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/icons/pie.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/icons/pie.tsx deleted file mode 100644 index 5824b8f40b6e6..0000000000000 --- a/src/plugins/chart_expressions/expression_partition_vis/public/icons/pie.tsx +++ /dev/null @@ -1,37 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; -import { useCommonChartStyles } from '@kbn/charts-plugin/public'; - -export const PieIcon = ({ title, titleId, ...props }: Omit) => { - const { chartIcon } = useCommonChartStyles(); - - return ( - - {title ? {title} : null} - - - - ); -}; diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/icons/treemap.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/icons/treemap.tsx deleted file mode 100644 index 781b79505384d..0000000000000 --- a/src/plugins/chart_expressions/expression_partition_vis/public/icons/treemap.tsx +++ /dev/null @@ -1,41 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; -import { useCommonChartStyles } from '@kbn/charts-plugin/public'; - -export const TreemapIcon = ({ title, titleId, ...props }: Omit) => { - const { chartIcon } = useCommonChartStyles(); - - return ( - - {title ? {title} : null} - - - - - ); -}; diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/icons/waffle.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/icons/waffle.tsx deleted file mode 100644 index 21e26facd8e15..0000000000000 --- a/src/plugins/chart_expressions/expression_partition_vis/public/icons/waffle.tsx +++ /dev/null @@ -1,37 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import type { EuiIconProps } from '@elastic/eui'; -import { useCommonChartStyles } from '@kbn/charts-plugin/public'; - -export const WaffleIcon = ({ title, titleId, ...props }: Omit) => { - const { chartIcon } = useCommonChartStyles(); - - return ( - - {title ? : null} - - - - ); -}; diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/utils/get_icon.ts b/src/plugins/chart_expressions/expression_partition_vis/public/utils/get_icon.ts index cac282553af11..d8b5ad858d764 100644 --- a/src/plugins/chart_expressions/expression_partition_vis/public/utils/get_icon.ts +++ b/src/plugins/chart_expressions/expression_partition_vis/public/utils/get_icon.ts @@ -6,14 +6,20 @@ * Side Public License, v 1. */ +import { + IconChartWaffle, + IconChartMosaic, + IconChartPie, + IconChartDonut, + IconChartTreemap, +} from '@kbn/chart-icons'; import { ChartTypes } from '../../common/types'; -import { PieIcon, DonutIcon, TreemapIcon, MosaicIcon, WaffleIcon } from '../icons'; export const getIcon = (chart: ChartTypes) => ({ - [ChartTypes.PIE]: PieIcon, - [ChartTypes.DONUT]: DonutIcon, - [ChartTypes.TREEMAP]: TreemapIcon, - [ChartTypes.MOSAIC]: MosaicIcon, - [ChartTypes.WAFFLE]: WaffleIcon, + [ChartTypes.PIE]: IconChartPie, + [ChartTypes.DONUT]: IconChartDonut, + [ChartTypes.TREEMAP]: IconChartTreemap, + [ChartTypes.MOSAIC]: IconChartMosaic, + [ChartTypes.WAFFLE]: IconChartWaffle, }[chart]); diff --git a/src/plugins/chart_expressions/expression_xy/common/index.ts b/src/plugins/chart_expressions/expression_xy/common/index.ts index d9c415f488839..da4c969f47a0c 100755 --- a/src/plugins/chart_expressions/expression_xy/common/index.ts +++ b/src/plugins/chart_expressions/expression_xy/common/index.ts @@ -47,6 +47,7 @@ export type { ReferenceLineLayerArgs, CommonXYDataLayerConfig, ReferenceLineLayerConfig, + DataDecorationConfigResult, AvailableReferenceLineIcon, XYExtendedLayerConfigResult, CommonXYAnnotationLayerConfig, diff --git a/src/plugins/chart_expressions/expression_xy/public/definitions/visualizations.ts b/src/plugins/chart_expressions/expression_xy/public/definitions/visualizations.ts index bb4acd7fa50de..4f4d8aeb69959 100644 --- a/src/plugins/chart_expressions/expression_xy/public/definitions/visualizations.ts +++ b/src/plugins/chart_expressions/expression_xy/public/definitions/visualizations.ts @@ -6,30 +6,33 @@ * Side Public License, v 1. */ -import { SeriesTypes } from '../../common/constants'; import { - BarIcon, - LineIcon, - AreaIcon, - BarStackedIcon, - AreaStackedIcon, - BarHorizontalIcon, - BarPercentageIcon, - AreaPercentageIcon, - BarHorizontalStackedIcon, - BarHorizontalPercentageIcon, -} from '../icons'; + IconChartBarHorizontalPercentage, + IconChartBarHorizontalStacked, + IconChartBarPercentage, + IconChartBarHorizontal, + IconChartAreaStacked, + IconChartBarStacked, + IconChartLine, + IconChartBar, + IconChartArea, + IconChartAreaPercentage, +} from '@kbn/chart-icons'; +import { SeriesTypes } from '../../common/constants'; export const visualizationDefinitions = [ - { id: SeriesTypes.BAR, icon: BarIcon }, - { id: `${SeriesTypes.BAR}_stacked`, icon: BarStackedIcon }, - { id: `${SeriesTypes.BAR}_horizontal`, icon: BarHorizontalIcon }, - { id: `${SeriesTypes.BAR}_percentage_stacked`, icon: BarPercentageIcon }, - { id: `${SeriesTypes.BAR}_horizontal_stacked`, icon: BarHorizontalStackedIcon }, - { id: `${SeriesTypes.BAR}_horizontal_percentage_stacked`, icon: BarHorizontalPercentageIcon }, - { id: SeriesTypes.LINE, icon: LineIcon }, - { id: `${SeriesTypes.LINE}_stacked`, icon: LineIcon }, - { id: SeriesTypes.AREA, icon: AreaIcon }, - { id: `${SeriesTypes.AREA}_stacked`, icon: AreaStackedIcon }, - { id: `${SeriesTypes.AREA}_percentage_stacked`, icon: AreaPercentageIcon }, + { id: SeriesTypes.BAR, icon: IconChartBar }, + { id: `${SeriesTypes.BAR}_stacked`, icon: IconChartBarStacked }, + { id: `${SeriesTypes.BAR}_horizontal`, icon: IconChartBarHorizontal }, + { id: `${SeriesTypes.BAR}_percentage_stacked`, icon: IconChartBarPercentage }, + { id: `${SeriesTypes.BAR}_horizontal_stacked`, icon: IconChartBarHorizontalStacked }, + { + id: `${SeriesTypes.BAR}_horizontal_percentage_stacked`, + icon: IconChartBarHorizontalPercentage, + }, + { id: `${SeriesTypes.LINE}_stacked`, icon: IconChartLine }, + { id: SeriesTypes.LINE, icon: IconChartLine }, + { id: SeriesTypes.AREA, icon: IconChartArea }, + { id: `${SeriesTypes.AREA}_stacked`, icon: IconChartAreaStacked }, + { id: `${SeriesTypes.AREA}_percentage_stacked`, icon: IconChartAreaPercentage }, ]; diff --git a/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.test.ts b/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.test.ts index 35019d75e0554..183a798056edb 100644 --- a/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.test.ts +++ b/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.test.ts @@ -7,7 +7,7 @@ */ import { FieldFormat } from '@kbn/field-formats-plugin/common'; -import { DataLayerConfig, YAxisConfigResult } from '../../common'; +import { DataLayerConfig, YAxisConfigResult, DataDecorationConfigResult } from '../../common'; import { LayerTypes } from '../../common/constants'; import { Datatable } from '@kbn/expressions-plugin/public'; import { getAxesConfiguration } from './axes_configuration'; @@ -218,6 +218,20 @@ describe('axes_configuration', () => { params: { id: 'currency' }, }, }, + { + id: 'yAccessorId5', + name: 'Other column', + meta: { + type: 'number', + source: 'esaggs', + index: 'indexPatternId', + sourceParams: { + indexPatternId: 'indexPatternId', + type: 'count', + }, + params: { id: 'number' }, + }, + }, ], }, }; @@ -228,6 +242,11 @@ describe('axes_configuration', () => { position: 'right', type: 'yAxisConfig', }, + { + id: '2', + position: 'left', + type: 'yAxisConfig', + }, ]; const sampleLayer: DataLayerConfig = { @@ -256,6 +275,7 @@ describe('axes_configuration', () => { yAccessorId: { id: 'number', params: {} }, yAccessorId3: { id: 'currency', params: {} }, yAccessorId4: { id: 'currency', params: {} }, + yAccessorId5: { id: 'number', params: {} }, }, splitSeriesAccessors: { d: { format: { id: 'number', params: {} }, formatter: {} as FieldFormat }, @@ -269,11 +289,35 @@ describe('axes_configuration', () => { const formatFactory = jest.fn(); const groups = getAxesConfiguration([sampleLayer], false, formatFactory, fieldFormats, []); expect(groups.length).toEqual(1); + expect(groups[0].groupId).toEqual('left'); expect(groups[0].position).toEqual('left'); expect(groups[0].series[0].accessor).toEqual('yAccessorId'); expect(groups[0].series[0].layer).toEqual('first'); }); + it('should map auto series to defined left axis if formatters match', () => { + const formatFactory = jest.fn(); + const groups = getAxesConfiguration( + [ + { + ...sampleLayer, + accessors: ['yAccessorId', 'yAccessorId5'], + decorations: [{ type: 'dataDecorationConfig', forAccessor: 'yAccessorId', axisId: '2' }], + }, + ], + false, + formatFactory, + fieldFormats, + yAxisConfigs + ); + expect(groups.length).toEqual(1); + expect(groups[0].groupId).toEqual('axis-2'); + expect(groups[0].position).toEqual('left'); + expect(groups[0].series[0].accessor).toEqual('yAccessorId'); + expect(groups[0].series[1].accessor).toEqual('yAccessorId5'); + expect(groups[0].series[0].layer).toEqual('first'); + }); + it('should map auto series to right axis if formatters do not match', () => { const formatFactory = jest.fn(); const twoSeriesLayer = { ...sampleLayer, accessors: ['yAccessorId', 'yAccessorId2'] }; @@ -285,13 +329,72 @@ describe('axes_configuration', () => { expect(groups[1].series[0].accessor).toEqual('yAccessorId2'); }); - it('should map auto series to left if left and right are already filled with non-matching series', () => { + it('should map auto series to left axis if formatters do not match with defined left axis', () => { + const formatFactory = jest.fn(); + const groups = getAxesConfiguration( + [ + { + ...sampleLayer, + accessors: ['yAccessorId', 'yAccessorId3'], + decorations: [{ type: 'dataDecorationConfig', forAccessor: 'yAccessorId', axisId: '2' }], + }, + ], + false, + formatFactory, + fieldFormats, + yAxisConfigs + ); + expect(groups.length).toEqual(2); + expect(groups[0].groupId).toEqual('axis-2'); + expect(groups[0].position).toEqual('left'); + expect(groups[0].series[0].accessor).toEqual('yAccessorId'); + expect(groups[0].series[0].layer).toEqual('first'); + expect(groups[1].groupId).toEqual('right'); + expect(groups[1].position).toEqual('right'); + expect(groups[1].series[0].accessor).toEqual('yAccessorId3'); + expect(groups[1].series[0].layer).toEqual('first'); + }); + + it('should map auto series to defined left axis if defined left and right are already filled with non-matching series', () => { + const formatFactory = jest.fn(); + const threeSeriesLayer = { + ...sampleLayer, + accessors: ['yAccessorId', 'yAccessorId2', 'yAccessorId3'], + decorations: [ + { type: 'dataDecorationConfig', forAccessor: 'yAccessorId', axisId: '1' }, + { type: 'dataDecorationConfig', forAccessor: 'yAccessorId2', axisId: '2' }, + ] as DataDecorationConfigResult[], + }; + const groups = getAxesConfiguration( + [threeSeriesLayer], + false, + formatFactory, + fieldFormats, + yAxisConfigs + ); + expect(groups.length).toEqual(2); + expect(groups[0].groupId).toEqual('axis-1'); + expect(groups[0].position).toEqual('right'); + expect(groups[1].groupId).toEqual('axis-2'); + expect(groups[1].position).toEqual('left'); + expect(groups[0].series[0].accessor).toEqual('yAccessorId'); + expect(groups[1].series[0].accessor).toEqual('yAccessorId2'); + expect(groups[1].series[1].accessor).toEqual('yAccessorId3'); + }); + + it('should map auto series to left if not-defined left and right are already filled with non-matching series', () => { const formatFactory = jest.fn(); const threeSeriesLayer = { ...sampleLayer, accessors: ['yAccessorId', 'yAccessorId2', 'yAccessorId3'], }; - const groups = getAxesConfiguration([threeSeriesLayer], false, formatFactory, fieldFormats, []); + const groups = getAxesConfiguration( + [threeSeriesLayer], + false, + formatFactory, + fieldFormats, + yAxisConfigs + ); expect(groups.length).toEqual(2); expect(groups[0].position).toEqual('left'); expect(groups[1].position).toEqual('right'); diff --git a/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.ts b/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.ts index f95423ea83854..7f9f6c49824b8 100644 --- a/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.ts +++ b/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.ts @@ -113,8 +113,13 @@ export function groupAxesByType( const tablesExist = layers.filter(({ table }) => Boolean(table)).length > 0; - leftSeriesKeys.push(LEFT_GLOBAL_AXIS_ID); - rightSeriesKeys.push(RIGHT_GLOBAL_AXIS_ID); + if (!leftSeriesKeys.length) { + leftSeriesKeys.push(LEFT_GLOBAL_AXIS_ID); + } + + if (!rightSeriesKeys.length) { + rightSeriesKeys.push(RIGHT_GLOBAL_AXIS_ID); + } series.auto.forEach((currentSeries) => { const leftAxisGroupId = tablesExist @@ -129,16 +134,23 @@ export function groupAxesByType( ) : undefined; - let axisGroupId = LEFT_GLOBAL_AXIS_ID; - - if (series[LEFT_GLOBAL_AXIS_ID].length === 0 || leftAxisGroupId) { - axisGroupId = leftAxisGroupId || LEFT_GLOBAL_AXIS_ID; - } else if (series[RIGHT_GLOBAL_AXIS_ID].length === 0 || rightAxisGroupId) { - axisGroupId = rightAxisGroupId || RIGHT_GLOBAL_AXIS_ID; - } else if (series[RIGHT_GLOBAL_AXIS_ID].length >= series[LEFT_GLOBAL_AXIS_ID].length) { - axisGroupId = LEFT_GLOBAL_AXIS_ID; + const rightSeriesCount = rightSeriesKeys.reduce((acc, key) => { + return acc + series[key].length; + }, 0); + const leftSeriesCount = leftSeriesKeys.reduce((acc, key) => { + return acc + series[key].length; + }, 0); + + let axisGroupId; + + if (leftSeriesCount === 0 || leftAxisGroupId) { + axisGroupId = leftAxisGroupId || leftSeriesKeys[0]; + } else if (rightSeriesCount === 0 || rightAxisGroupId) { + axisGroupId = rightAxisGroupId || rightSeriesKeys[0]; + } else if (rightSeriesCount >= leftSeriesCount) { + axisGroupId = leftSeriesKeys[0]; } else { - axisGroupId = RIGHT_GLOBAL_AXIS_ID; + axisGroupId = rightSeriesKeys[0]; } series[axisGroupId].push(currentSeries); diff --git a/src/plugins/chart_expressions/expression_xy/public/helpers/icon.ts b/src/plugins/chart_expressions/expression_xy/public/helpers/icon.ts index 8b4113b3ada11..a74d4196f487d 100644 --- a/src/plugins/chart_expressions/expression_xy/public/helpers/icon.ts +++ b/src/plugins/chart_expressions/expression_xy/public/helpers/icon.ts @@ -7,7 +7,7 @@ */ import { i18n } from '@kbn/i18n'; -import { TriangleIcon, CircleIcon } from '../icons'; +import { IconTriangle, IconCircle } from '@kbn/chart-icons'; import { AvailableReferenceLineIcons } from '../../common/constants'; export function hasIcon(icon: string | undefined): icon is string { @@ -56,7 +56,7 @@ export const iconSet = [ label: i18n.translate('expressionXY.xyChart.iconSelect.circleIconLabel', { defaultMessage: 'Circle', }), - icon: CircleIcon, + icon: IconCircle, canFill: true, }, @@ -105,7 +105,7 @@ export const iconSet = [ label: i18n.translate('expressionXY.xyChart.iconSelect.triangleIconLabel', { defaultMessage: 'Triangle', }), - icon: TriangleIcon, + icon: IconTriangle, shouldRotate: true, canFill: true, }, diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/area_percentage.tsx b/src/plugins/chart_expressions/expression_xy/public/icons/area_percentage.tsx deleted file mode 100644 index a51e66b68ba93..0000000000000 --- a/src/plugins/chart_expressions/expression_xy/public/icons/area_percentage.tsx +++ /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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const AreaPercentageIcon = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/area_stacked.tsx b/src/plugins/chart_expressions/expression_xy/public/icons/area_stacked.tsx deleted file mode 100644 index c2b9fbe926328..0000000000000 --- a/src/plugins/chart_expressions/expression_xy/public/icons/area_stacked.tsx +++ /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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const AreaStackedIcon = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/bar_reference_line.tsx b/src/plugins/chart_expressions/expression_xy/public/icons/bar_reference_line.tsx deleted file mode 100644 index 95bd8e2a8d0a2..0000000000000 --- a/src/plugins/chart_expressions/expression_xy/public/icons/bar_reference_line.tsx +++ /dev/null @@ -1,37 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const BarReferenceLineIcon = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - - - - -); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/index.ts b/src/plugins/chart_expressions/expression_xy/public/icons/index.ts deleted file mode 100644 index 4ca0b640a3d89..0000000000000 --- a/src/plugins/chart_expressions/expression_xy/public/icons/index.ts +++ /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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export { BarHorizontalPercentageIcon } from './bar_horizontal_percentage'; -export { BarHorizontalStackedIcon } from './bar_horizontal_stacked'; -export { BarReferenceLineIcon } from './bar_reference_line'; -export { AreaPercentageIcon } from './area_percentage'; -export { BarHorizontalIcon } from './bar_horizontal'; -export { BarPercentageIcon } from './bar_percentage'; -export { AreaStackedIcon } from './area_stacked'; -export { BarStackedIcon } from './bar_stacked'; -export { TriangleIcon } from './triangle'; -export { MixedXyIcon } from './mixed_xy'; -export { CircleIcon } from './circle'; -export { AreaIcon } from './area'; -export { LineIcon } from './line'; -export { BarIcon } from './bar'; diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/line.tsx b/src/plugins/chart_expressions/expression_xy/public/icons/line.tsx deleted file mode 100644 index 6735f58b734ec..0000000000000 --- a/src/plugins/chart_expressions/expression_xy/public/icons/line.tsx +++ /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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const LineIcon = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/src/plugins/chart_expressions/expression_xy/public/icons/mixed_xy.tsx b/src/plugins/chart_expressions/expression_xy/public/icons/mixed_xy.tsx deleted file mode 100644 index e16b7f6bed76f..0000000000000 --- a/src/plugins/chart_expressions/expression_xy/public/icons/mixed_xy.tsx +++ /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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const MixedXyIcon = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - - - -); diff --git a/src/plugins/embeddable/public/lib/attribute_service/attribute_service.tsx b/src/plugins/embeddable/public/lib/attribute_service/attribute_service.tsx index cb93ef13b918d..17a41e841abff 100644 --- a/src/plugins/embeddable/public/lib/attribute_service/attribute_service.tsx +++ b/src/plugins/embeddable/public/lib/attribute_service/attribute_service.tsx @@ -45,7 +45,7 @@ export interface AttributeServiceOptions< attributes: SavedObjectAttributes, savedObjectId?: string ) => Promise<{ id?: string } | { error: Error }>; - checkForDuplicateTitle: (props: OnSaveProps) => Promise; + checkForDuplicateTitle: (props: OnSaveProps) => Promise; unwrapMethod?: ( savedObjectId: string ) => Promise>; diff --git a/x-pack/plugins/fleet/common/services/agent_status.ts b/x-pack/plugins/fleet/common/services/agent_status.ts index 59ec2b9babd70..7dbfb88192da8 100644 --- a/x-pack/plugins/fleet/common/services/agent_status.ts +++ b/x-pack/plugins/fleet/common/services/agent_status.ts @@ -6,11 +6,11 @@ */ import { AGENT_POLLING_THRESHOLD_MS } from '../constants'; -import type { Agent, AgentStatus } from '../types'; +import type { Agent, AgentStatus, FleetServerAgent } from '../types'; const offlineTimeoutIntervalCount = 10; // 30s*10 = 5m timeout -export function getAgentStatus(agent: Agent): AgentStatus { +export function getAgentStatus(agent: Agent | FleetServerAgent): AgentStatus { const { last_checkin: lastCheckIn } = agent; if (!agent.active) { @@ -33,7 +33,15 @@ export function getAgentStatus(agent: Agent): AgentStatus { if (agent.last_checkin_status === 'degraded') { return 'degraded'; } - if (agent.upgrade_started_at && !agent.upgraded_at) { + + const policyRevision = + 'policy_revision' in agent + ? agent.policy_revision + : 'policy_revision_idx' in agent + ? agent.policy_revision_idx + : undefined; + + if (!policyRevision || (agent.upgrade_started_at && !agent.upgraded_at)) { return 'updating'; } if (intervalsSinceLastCheckIn >= offlineTimeoutIntervalCount) { @@ -76,7 +84,7 @@ export function buildKueryForUpgradingAgents(path: string = '') { export function buildKueryForUpdatingAgents(path: string = '') { return `(${buildKueryForUpgradingAgents(path)}) or (${buildKueryForEnrollingAgents( path - )}) or (${buildKueryForUnenrollingAgents(path)})`; + )}) or (${buildKueryForUnenrollingAgents(path)}) or (not ${path}policy_revision_idx:*)`; } export function buildKueryForInactiveAgents(path: string = '') { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx index b87b09c7f58c4..f3023e718eacf 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx @@ -69,7 +69,7 @@ export const AgentDetailsOverviewSection: React.FunctionComponent<{ defaultMessage: 'Agent policy', }), description: agentPolicy ? ( - + ) : ( agent.policy_id || '-' ), diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx index 471c26f89123d..a9e3429732b3c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx @@ -449,7 +449,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => { return ( - {agentPolicy && } + {agentPolicy && } {showWarning && ( diff --git a/x-pack/plugins/fleet/public/components/link_and_revision.test.tsx b/x-pack/plugins/fleet/public/components/link_and_revision.test.tsx new file mode 100644 index 0000000000000..f2d0a8970cfa3 --- /dev/null +++ b/x-pack/plugins/fleet/public/components/link_and_revision.test.tsx @@ -0,0 +1,51 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import type { TestRenderer } from '../mock'; +import { createFleetTestRendererMock } from '../mock'; + +import type { AgentPolicy, Agent } from '../types'; + +import { AgentPolicySummaryLine } from './link_and_revision'; + +jest.mock('../hooks/use_fleet_status', () => ({ + FleetStatusProvider: (props: any) => { + return props.children; + }, + useFleetStatus: jest.fn().mockReturnValue({}), +})); + +describe('AgentPolicySummaryLine', () => { + let testRenderer: TestRenderer; + + const render = (agentPolicy: AgentPolicy, agent?: Agent) => + testRenderer.render(); + + beforeEach(() => { + testRenderer = createFleetTestRendererMock(); + }); + + test('it should render policy and revision if no agent is provided', async () => { + const results = render({ name: 'test', revision: 2 } as AgentPolicy); + expect(results.container.textContent).toBe('testrev. 2'); + }); + + test('it should render policy without revision if the agent do not have revision', async () => { + const results = render({ name: 'test', revision: 1 } as AgentPolicy, {} as Agent); + expect(results.container.textContent).toBe('test'); + }); + + test('it should render policy with agent revision if an agent is provided', async () => { + const results = render( + { name: 'test', revision: 2 } as AgentPolicy, + { policy_revision: 1 } as Agent + ); + expect(results.container.textContent).toBe('testrev. 1'); + }); +}); diff --git a/x-pack/plugins/fleet/public/components/link_and_revision.tsx b/x-pack/plugins/fleet/public/components/link_and_revision.tsx index b56787fbb399c..64d4fa043e160 100644 --- a/x-pack/plugins/fleet/public/components/link_and_revision.tsx +++ b/x-pack/plugins/fleet/public/components/link_and_revision.tsx @@ -11,49 +11,54 @@ import { FormattedMessage } from '@kbn/i18n-react'; import type { CSSProperties } from 'react'; import React, { memo } from 'react'; -import type { AgentPolicy } from '../../common/types'; +import type { AgentPolicy, Agent } from '../../common/types'; import { useLink } from '../hooks'; const MIN_WIDTH: CSSProperties = { minWidth: 0 }; const NO_WRAP_WHITE_SPACE: CSSProperties = { whiteSpace: 'nowrap' }; -export const AgentPolicySummaryLine = memo<{ policy: AgentPolicy }>(({ policy }) => { - const { getHref } = useLink(); - const { name, id, revision, is_managed: isManaged } = policy; - return ( - - - - {name || id} - - - {isManaged && ( - - )} - {revision && ( - - - - +export const AgentPolicySummaryLine = memo<{ policy: AgentPolicy; agent?: Agent }>( + ({ policy, agent }) => { + const { getHref } = useLink(); + const { name, id, is_managed: isManaged } = policy; + + const revision = agent ? agent.policy_revision : policy.revision; + + return ( + + + + {name || id} + - )} - - ); -}); + {isManaged && ( + + )} + {revision && ( + + + + + + )} + + ); + } +); diff --git a/x-pack/plugins/fleet/server/services/agents/status.test.ts b/x-pack/plugins/fleet/server/services/agents/status.test.ts index 8b30edeb5b5f8..7c598bf783c14 100644 --- a/x-pack/plugins/fleet/server/services/agents/status.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/status.test.ts @@ -37,6 +37,7 @@ describe('Agent status service', () => { _id: 'id', _source: { active: true, + policy_revision_idx: 1, last_checkin: new Date().toISOString(), local_metadata: {}, user_provided_metadata: {}, @@ -92,6 +93,7 @@ describe('Agent status service', () => { _source: { active: true, last_checkin: new Date(Date.now() - 10 * AGENT_POLLING_THRESHOLD_MS - 1000).toISOString(), + policy_revision_idx: 2, local_metadata: {}, user_provided_metadata: {}, }, diff --git a/x-pack/plugins/lens/public/app_plugin/app.scss b/x-pack/plugins/lens/public/app_plugin/app.scss index 58ecce5592937..3aa98ca1640b9 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.scss +++ b/x-pack/plugins/lens/public/app_plugin/app.scss @@ -19,25 +19,6 @@ flex-grow: 1; } -.lensChartIcon__subdued { - fill: $euiTextSubduedColor; - - .lnsLayerChartSwitch__item-isSelected & { - fill: currentColor; - } -} - -.lensChartIcon__accent { - fill: $euiColorVis0; - - .lnsLayerChartSwitch__item-isSelected & { - fill: makeGraphicContrastColor($euiColorVis0, $euiColorDarkShade); - } -} -.lensAnnotationIconNoFill { - fill: none; -} - .lensAnnotationIconFill { fill: $euiColorEmptyShade; } diff --git a/x-pack/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/plugins/lens/public/app_plugin/app.test.tsx index a2e247cc427c8..03cf38f141f0d 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.test.tsx @@ -882,8 +882,7 @@ describe('Lens App', () => { }); }); expect(checkForDuplicateTitle).toHaveBeenCalledWith( - expect.objectContaining({ id: '123' }), - false, + expect.objectContaining({ id: '123', isTitleDuplicateConfirmed: false }), onTitleDuplicate, expect.anything() ); diff --git a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx index 6769010d8f721..373d632b2d51e 100644 --- a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx +++ b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx @@ -251,15 +251,13 @@ export const runSaveLensVisualization = async ( { id: originalSavedObjectId, title: docToSave.title, - copyOnSave: saveProps.newCopyOnSave, + displayName: i18n.translate('xpack.lens.app.saveModalType', { + defaultMessage: 'Lens visualization', + }), lastSavedTitle: lastKnownDoc.title, - getEsType: () => 'lens', - getDisplayName: () => - i18n.translate('xpack.lens.app.saveModalType', { - defaultMessage: 'Lens visualization', - }), + copyOnSave: saveProps.newCopyOnSave, + isTitleDuplicateConfirmed: saveProps.isTitleDuplicateConfirmed, }, - saveProps.isTitleDuplicateConfirmed, saveProps.onTitleDuplicate, { savedObjectsClient, diff --git a/x-pack/plugins/lens/public/assets/annotation_icons/circle.tsx b/x-pack/plugins/lens/public/assets/annotation_icons/circle.tsx deleted file mode 100644 index fe19dc7e4c8fc..0000000000000 --- a/x-pack/plugins/lens/public/assets/annotation_icons/circle.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as React from 'react'; -import { EuiIconProps } from '@elastic/eui'; -import classnames from 'classnames'; - -export const IconCircle = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - -); diff --git a/x-pack/plugins/lens/public/assets/annotation_icons/triangle.tsx b/x-pack/plugins/lens/public/assets/annotation_icons/triangle.tsx deleted file mode 100644 index 9924c049004cf..0000000000000 --- a/x-pack/plugins/lens/public/assets/annotation_icons/triangle.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as React from 'react'; -import { EuiIconProps } from '@elastic/eui'; -import classnames from 'classnames'; - -export const IconTriangle = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - -); diff --git a/x-pack/plugins/lens/public/assets/chart_area.tsx b/x-pack/plugins/lens/public/assets/chart_area.tsx deleted file mode 100644 index 664735205d97e..0000000000000 --- a/x-pack/plugins/lens/public/assets/chart_area.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const LensIconChartArea = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/x-pack/plugins/lens/public/assets/chart_bar.tsx b/x-pack/plugins/lens/public/assets/chart_bar.tsx deleted file mode 100644 index 991c9a6c74ced..0000000000000 --- a/x-pack/plugins/lens/public/assets/chart_bar.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const LensIconChartBar = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/x-pack/plugins/lens/public/assets/chart_bar_horizontal.tsx b/x-pack/plugins/lens/public/assets/chart_bar_horizontal.tsx deleted file mode 100644 index dfd25158cc295..0000000000000 --- a/x-pack/plugins/lens/public/assets/chart_bar_horizontal.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const LensIconChartBarHorizontal = ({ - title, - titleId, - ...props -}: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/x-pack/plugins/lens/public/assets/chart_bar_horizontal_percentage.tsx b/x-pack/plugins/lens/public/assets/chart_bar_horizontal_percentage.tsx deleted file mode 100644 index a3c79991f2aff..0000000000000 --- a/x-pack/plugins/lens/public/assets/chart_bar_horizontal_percentage.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const LensIconChartBarHorizontalPercentage = ({ - title, - titleId, - ...props -}: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/x-pack/plugins/lens/public/assets/chart_bar_horizontal_stacked.tsx b/x-pack/plugins/lens/public/assets/chart_bar_horizontal_stacked.tsx deleted file mode 100644 index d6abbaa37aaa0..0000000000000 --- a/x-pack/plugins/lens/public/assets/chart_bar_horizontal_stacked.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const LensIconChartBarHorizontalStacked = ({ - title, - titleId, - ...props -}: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/x-pack/plugins/lens/public/assets/chart_bar_percentage.tsx b/x-pack/plugins/lens/public/assets/chart_bar_percentage.tsx deleted file mode 100644 index c297ee831f27c..0000000000000 --- a/x-pack/plugins/lens/public/assets/chart_bar_percentage.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const LensIconChartBarPercentage = ({ - title, - titleId, - ...props -}: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/x-pack/plugins/lens/public/assets/chart_bar_stacked.tsx b/x-pack/plugins/lens/public/assets/chart_bar_stacked.tsx deleted file mode 100644 index c5775ce4bf859..0000000000000 --- a/x-pack/plugins/lens/public/assets/chart_bar_stacked.tsx +++ /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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const LensIconChartBarStacked = ({ - title, - titleId, - ...props -}: Omit) => ( - - {title ? {title} : null} - - - -); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx index 7eff9a5961e83..7f0034ad73366 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx @@ -19,7 +19,7 @@ import { ReactExpressionRendererType } from '@kbn/expressions-plugin/public'; import { SuggestionPanel, SuggestionPanelProps, SuggestionPanelWrapper } from './suggestion_panel'; import { getSuggestions } from './suggestion_helpers'; import { EuiIcon, EuiPanel, EuiToolTip, EuiAccordion } from '@elastic/eui'; -import { LensIconChartDatatable } from '../../assets/chart_datatable'; +import { IconChartDatatable } from '@kbn/chart-icons'; import { mountWithProvider } from '../../mocks'; import { applyChanges, @@ -286,7 +286,7 @@ describe('suggestion_panel', () => { getSuggestionsMock.mockReturnValue([ { datasourceState: {}, - previewIcon: LensIconChartDatatable, + previewIcon: IconChartDatatable, score: 0.5, visualizationState: suggestion1State, visualizationId: 'testVis', @@ -317,7 +317,7 @@ describe('suggestion_panel', () => { expect(instance.find(SELECTORS.SUGGESTIONS_PANEL).find(EuiIcon)).toHaveLength(1); expect(instance.find(SELECTORS.SUGGESTIONS_PANEL).find(EuiIcon).prop('type')).toEqual( - LensIconChartDatatable + IconChartDatatable ); }); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx index 8f32ff75c51f0..1d575d9809ad4 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx @@ -10,9 +10,9 @@ import { EuiPageContentBody, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { UiActionsStart, VISUALIZE_GEO_FIELD_TRIGGER } from '@kbn/ui-actions-plugin/public'; +import { GlobeIllustration } from '@kbn/chart-icons'; import { getVisualizeGeoFieldMessage } from '../../../utils'; import { DragDrop } from '../../../drag_drop'; -import { GlobeIllustration } from '../../../assets/globe_illustration'; import { APP_ID } from '../../../../common/constants'; import './geo_field_workspace_panel.scss'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index 8ab88da685cf0..07e5b0a3e8c1f 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -35,6 +35,7 @@ import type { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { VIS_EVENT_TO_TRIGGER } from '@kbn/visualizations-plugin/public'; import type { DefaultInspectorAdapters } from '@kbn/expressions-plugin/common'; import type { Datatable } from '@kbn/expressions-plugin/public'; +import { DropIllustration } from '@kbn/chart-icons'; import { trackUiCounterEvents } from '../../../lens_ui_telemetry'; import { FramePublicAPI, @@ -51,7 +52,6 @@ import { DragDrop, DragContext, DragDropIdentifier } from '../../../drag_drop'; import { switchToSuggestion } from '../suggestion_helpers'; import { buildExpression } from '../expression_helpers'; import { WorkspacePanelWrapper } from './workspace_panel_wrapper'; -import { DropIllustration } from '../../../assets/drop_illustration'; import applyChangesIllustrationDark from '../../../assets/render_dark@2x.png'; import applyChangesIllustrationLight from '../../../assets/render_light@2x.png'; import { diff --git a/x-pack/plugins/lens/public/lens_attribute_service.ts b/x-pack/plugins/lens/public/lens_attribute_service.ts index 6181fbf22ab26..7fe4065ede66d 100644 --- a/x-pack/plugins/lens/public/lens_attribute_service.ts +++ b/x-pack/plugins/lens/public/lens_attribute_service.ts @@ -80,12 +80,11 @@ export function getLensAttributeService( return checkForDuplicateTitle( { title: props.newTitle, - copyOnSave: false, + displayName: DOC_TYPE, + isTitleDuplicateConfirmed: props.isTitleDuplicateConfirmed, lastSavedTitle: '', - getEsType: () => DOC_TYPE, - getDisplayName: () => DOC_TYPE, + copyOnSave: false, }, - props.isTitleDuplicateConfirmed, props.onTitleDuplicate, { savedObjectsClient, diff --git a/x-pack/plugins/lens/public/persistence/saved_objects_utils/check_for_duplicate_title.ts b/x-pack/plugins/lens/public/persistence/saved_objects_utils/check_for_duplicate_title.ts index 8d6ca5c3b7640..c04db1f39ac61 100644 --- a/x-pack/plugins/lens/public/persistence/saved_objects_utils/check_for_duplicate_title.ts +++ b/x-pack/plugins/lens/public/persistence/saved_objects_utils/check_for_duplicate_title.ts @@ -6,26 +6,24 @@ */ import type { OverlayStart, SavedObjectsClientContract } from '@kbn/core/public'; -import type { SavedObject } from '@kbn/saved-objects-plugin/public'; +import { DOC_TYPE } from '../../../common'; import { SAVE_DUPLICATE_REJECTED } from './constants'; import { findObjectByTitle } from './find_object_by_title'; import { displayDuplicateTitleConfirmModal } from './display_duplicate_title_confirm_modal'; +import type { ConfirmModalSavedObjectMeta } from './types'; /** - * check for an existing SavedObject with the same title in ES + * check for an existing saved object with the same title in ES * returns Promise when it's no duplicate, or the modal displaying the warning * that's there's a duplicate is confirmed, else it returns a rejected Promise */ export async function checkForDuplicateTitle( - savedObject: Pick< - SavedObject, - 'id' | 'title' | 'getDisplayName' | 'lastSavedTitle' | 'copyOnSave' | 'getEsType' - >, - isTitleDuplicateConfirmed: boolean, + savedObjectMeta: ConfirmModalSavedObjectMeta, onTitleDuplicate: (() => void) | undefined, services: { savedObjectsClient: SavedObjectsClientContract; overlays: OverlayStart } -): Promise { +): Promise { const { savedObjectsClient, overlays } = services; + const { id, title, isTitleDuplicateConfirmed, lastSavedTitle, copyOnSave } = savedObjectMeta; // Don't check for duplicates if user has already confirmed save with duplicate title if (isTitleDuplicateConfirmed) { @@ -34,17 +32,13 @@ export async function checkForDuplicateTitle( // Don't check if the user isn't updating the title, otherwise that would become very annoying to have // to confirm the save every time, except when copyOnSave is true, then we do want to check. - if (savedObject.title === savedObject.lastSavedTitle && !savedObject.copyOnSave) { + if (title === lastSavedTitle && !copyOnSave) { return true; } - const duplicate = await findObjectByTitle( - savedObjectsClient, - savedObject.getEsType(), - savedObject.title - ); + const duplicate = await findObjectByTitle(savedObjectsClient, DOC_TYPE, title); - if (!duplicate || duplicate.id === savedObject.id) { + if (!duplicate || duplicate.id === id) { return true; } @@ -55,5 +49,5 @@ export async function checkForDuplicateTitle( // TODO: make onTitleDuplicate a required prop and remove UI components from this class // Need to leave here until all users pass onTitleDuplicate. - return displayDuplicateTitleConfirmModal(savedObject, overlays); + return displayDuplicateTitleConfirmModal(savedObjectMeta, overlays); } diff --git a/x-pack/plugins/lens/public/persistence/saved_objects_utils/confirm_modal_promise.tsx b/x-pack/plugins/lens/public/persistence/saved_objects_utils/confirm_modal_promise.tsx index c788660eea647..9b24a2be54ce2 100644 --- a/x-pack/plugins/lens/public/persistence/saved_objects_utils/confirm_modal_promise.tsx +++ b/x-pack/plugins/lens/public/persistence/saved_objects_utils/confirm_modal_promise.tsx @@ -16,7 +16,7 @@ export function confirmModalPromise( title = '', confirmBtnText = '', overlays: OverlayStart -): Promise { +): Promise { return new Promise((resolve, reject) => { const cancelButtonText = i18n.translate('xpack.lens.confirmModal.cancelButtonLabel', { defaultMessage: 'Cancel', diff --git a/x-pack/plugins/lens/public/persistence/saved_objects_utils/display_duplicate_title_confirm_modal.ts b/x-pack/plugins/lens/public/persistence/saved_objects_utils/display_duplicate_title_confirm_modal.ts index 6c5a94c8c3216..e0c61d202da72 100644 --- a/x-pack/plugins/lens/public/persistence/saved_objects_utils/display_duplicate_title_confirm_modal.ts +++ b/x-pack/plugins/lens/public/persistence/saved_objects_utils/display_duplicate_title_confirm_modal.ts @@ -7,25 +7,25 @@ import { i18n } from '@kbn/i18n'; import type { OverlayStart } from '@kbn/core/public'; -import type { SavedObject } from '@kbn/saved-objects-plugin/public'; +import type { ConfirmModalSavedObjectMeta } from './types'; import { SAVE_DUPLICATE_REJECTED } from './constants'; import { confirmModalPromise } from './confirm_modal_promise'; export function displayDuplicateTitleConfirmModal( - savedObject: Pick, + { title, displayName }: ConfirmModalSavedObjectMeta, overlays: OverlayStart -): Promise { +): Promise { const confirmMessage = i18n.translate( 'xpack.lens.confirmModal.saveDuplicateConfirmationMessage', { defaultMessage: `A {name} with the title '{title}' already exists. Would you like to save anyway?`, - values: { title: savedObject.title, name: savedObject.getDisplayName() }, + values: { title, name: displayName }, } ); const confirmButtonText = i18n.translate('xpack.lens.confirmModal.saveDuplicateButtonLabel', { defaultMessage: 'Save {name}', - values: { name: savedObject.getDisplayName() }, + values: { name: displayName }, }); try { return confirmModalPromise(confirmMessage, '', confirmButtonText, overlays); diff --git a/x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.test.ts b/x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.test.ts index 0d117220b895b..0e71b30b042e5 100644 --- a/x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.test.ts +++ b/x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.test.ts @@ -6,7 +6,7 @@ */ import { findObjectByTitle } from './find_object_by_title'; -import { SavedObjectsClientContract, SavedObject } from '@kbn/core/public'; +import { SavedObjectsClientContract, SimpleSavedObject } from '@kbn/core/public'; import { simpleSavedObjectMock } from '@kbn/core/public/mocks'; describe('findObjectByTitle', () => { @@ -24,7 +24,8 @@ describe('findObjectByTitle', () => { it('matches any case', async () => { const indexPattern = simpleSavedObjectMock.create(savedObjectsClient, { attributes: { title: 'foo' }, - } as SavedObject); + } as SimpleSavedObject); + savedObjectsClient.find = jest.fn().mockImplementation(() => Promise.resolve({ savedObjects: [indexPattern], diff --git a/x-pack/plugins/lens/public/persistence/saved_objects_utils/types.ts b/x-pack/plugins/lens/public/persistence/saved_objects_utils/types.ts new file mode 100644 index 0000000000000..49772c2db90a2 --- /dev/null +++ b/x-pack/plugins/lens/public/persistence/saved_objects_utils/types.ts @@ -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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +/** @internal */ +export interface ConfirmModalSavedObjectMeta { + id?: string; + title: string; + displayName: string; + lastSavedTitle: string; + copyOnSave: boolean; + isTitleDuplicateConfirmed: boolean; +} diff --git a/x-pack/plugins/lens/public/shared_components/toolbar_popover.tsx b/x-pack/plugins/lens/public/shared_components/toolbar_popover.tsx index 9d806b79f8311..dbb3d69588624 100644 --- a/x-pack/plugins/lens/public/shared_components/toolbar_popover.tsx +++ b/x-pack/plugins/lens/public/shared_components/toolbar_popover.tsx @@ -9,7 +9,7 @@ import './toolbar_popover.scss'; import React, { useState } from 'react'; import { EuiFlexItem, EuiPopover, EuiIcon, EuiPopoverTitle, IconType } from '@elastic/eui'; import { ToolbarButton, ToolbarButtonProps } from '@kbn/kibana-react-plugin/public'; -import { EuiIconLegend } from '../assets/legend'; +import { EuiIconLegend } from '@kbn/chart-icons'; const typeToIconMap: { [type: string]: string | IconType } = { legend: EuiIconLegend as IconType, diff --git a/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.test.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.test.tsx index e40b7b0c079ec..c1986b9ff7ef5 100644 --- a/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.test.tsx @@ -14,7 +14,7 @@ import { IAggType } from '@kbn/data-plugin/public'; import { IFieldFormat, SerializedFieldFormat } from '@kbn/field-formats-plugin/common'; import { VisualizationContainer } from '../../../visualization_container'; import { EmptyPlaceholder } from '@kbn/charts-plugin/public'; -import { LensIconChartDatatable } from '../../../assets/chart_datatable'; +import { IconChartDatatable } from '@kbn/chart-icons'; import { DataContext, DatatableComponent } from './table_basic'; import { DatatableProps } from '../../../../common/expressions'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; @@ -369,7 +369,7 @@ describe('DatatableComponent', () => { /> ); expect(component.find(VisualizationContainer)).toHaveLength(1); - expect(component.find(EmptyPlaceholder).prop('icon')).toEqual(LensIconChartDatatable); + expect(component.find(EmptyPlaceholder).prop('icon')).toEqual(IconChartDatatable); }); test('it renders the table with the given sorting', () => { diff --git a/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx index 0262d3d7cab40..fe0a7da701f2a 100644 --- a/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx @@ -29,12 +29,12 @@ import { } from '@elastic/eui'; import { EmptyPlaceholder } from '@kbn/charts-plugin/public'; import { ClickTriggerEvent } from '@kbn/charts-plugin/public'; +import { IconChartDatatable } from '@kbn/chart-icons'; import type { LensTableRowContextMenuEvent } from '../../../types'; import type { FormatFactory } from '../../../../common'; import type { LensGridDirection } from '../../../../common/expressions'; import { VisualizationContainer } from '../../../visualization_container'; import { findMinMaxByColumnId } from '../../../shared_components'; -import { LensIconChartDatatable } from '../../../assets/chart_datatable'; import type { DataContextType, DatatableRenderProps, @@ -413,7 +413,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => { if (isEmpty) { return ( - + ); } diff --git a/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx b/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx index 36be3492680ea..8b9f2fe4bc4ed 100644 --- a/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx @@ -14,13 +14,13 @@ import { PaletteRegistry, CUSTOM_PALETTE } from '@kbn/coloring'; import { ThemeServiceStart } from '@kbn/core/public'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { VIS_EVENT_TO_TRIGGER } from '@kbn/visualizations-plugin/public'; +import { IconChartDatatable } from '@kbn/chart-icons'; import type { SuggestionRequest, Visualization, VisualizationSuggestion, DatasourceLayers, } from '../../types'; -import { LensIconChartDatatable } from '../../assets/chart_datatable'; import { TableDimensionEditor } from './components/dimension_editor'; import { TableDimensionEditorAdditionalSection } from './components/dimension_editor_addtional_section'; import { LayerType, layerTypes } from '../../../common'; @@ -56,7 +56,7 @@ export const getDatatableVisualization = ({ visualizationTypes: [ { id: 'lnsDatatable', - icon: LensIconChartDatatable, + icon: IconChartDatatable, label: visualizationLabel, groupLabel: i18n.translate('xpack.lens.datatable.groupLabel', { defaultMessage: 'Tabular', @@ -82,7 +82,7 @@ export const getDatatableVisualization = ({ getDescription() { return { - icon: LensIconChartDatatable, + icon: IconChartDatatable, label: visualizationLabel, }; }, @@ -164,7 +164,7 @@ export const getDatatableVisualization = ({ columnId: col.columnId, })), }, - previewIcon: LensIconChartDatatable, + previewIcon: IconChartDatatable, // tables are hidden from suggestion bar, but used for drag & drop and chart switching hide: true, }, diff --git a/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx b/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx index a531181a2cba5..8c35a44242955 100644 --- a/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx @@ -21,9 +21,8 @@ import { getMaxValue, getMinValue, getValueFromAccessor, - VerticalBulletIcon, - HorizontalBulletIcon, } from '@kbn/expression-gauge-plugin/public'; +import { IconChartHorizontalBullet, IconChartVerticalBullet } from '@kbn/chart-icons'; import type { DatasourceLayers, OperationMetadata, Visualization } from '../../types'; import { getSuggestions } from './suggestions'; import { @@ -56,14 +55,14 @@ export const isNumericDynamicMetric = (op: OperationMetadata) => export const CHART_NAMES = { horizontalBullet: { - icon: HorizontalBulletIcon, + icon: IconChartHorizontalBullet, label: i18n.translate('xpack.lens.gaugeHorizontal.gaugeLabel', { defaultMessage: 'Gauge horizontal', }), groupLabel: groupLabelForGauge, }, verticalBullet: { - icon: VerticalBulletIcon, + icon: IconChartVerticalBullet, label: i18n.translate('xpack.lens.gaugeVertical.gaugeLabel', { defaultMessage: 'Gauge vertical', }), diff --git a/x-pack/plugins/lens/public/visualizations/heatmap/constants.ts b/x-pack/plugins/lens/public/visualizations/heatmap/constants.ts index 270d45ce3cec5..51e674048e873 100644 --- a/x-pack/plugins/lens/public/visualizations/heatmap/constants.ts +++ b/x-pack/plugins/lens/public/visualizations/heatmap/constants.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { HeatmapIcon } from '@kbn/expression-heatmap-plugin/public'; +import { IconChartHeatmap } from '@kbn/chart-icons'; export const LENS_HEATMAP_RENDERER = 'lens_heatmap_renderer'; @@ -24,7 +24,7 @@ export const CHART_SHAPES = { export const CHART_NAMES = { heatmap: { shapeType: CHART_SHAPES.HEATMAP, - icon: HeatmapIcon, + icon: IconChartHeatmap, label: i18n.translate('xpack.lens.heatmap.heatmapLabel', { defaultMessage: 'Heat map', }), diff --git a/x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.tsx b/x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.tsx index b0a80ca297a0a..d14bf621df08e 100644 --- a/x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.tsx +++ b/x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.tsx @@ -10,6 +10,7 @@ import { EuiFlexGroup, EuiFlexItem, IconType } from '@elastic/eui'; import { Position } from '@elastic/charts'; import { i18n } from '@kbn/i18n'; import { LegendSize } from '@kbn/visualizations-plugin/public'; +import { EuiIconAxisLeft, EuiIconAxisBottom } from '@kbn/chart-icons'; import type { VisualizationToolbarProps } from '../../types'; import { LegendSettingsPopover, @@ -18,8 +19,6 @@ import { AxisTitleSettings, TooltipWrapper, } from '../../shared_components'; -import { EuiIconAxisLeft } from '../../assets/axis_left'; -import { EuiIconAxisBottom } from '../../assets/axis_bottom'; import type { HeatmapVisualizationState } from './types'; import { getDefaultVisualValuesForLayer } from '../../shared_components/datasource_default_values'; import './toolbar_component.scss'; diff --git a/x-pack/plugins/lens/public/visualizations/heatmap/visualization.tsx b/x-pack/plugins/lens/public/visualizations/heatmap/visualization.tsx index 2f08a31151401..09548df0a67e4 100644 --- a/x-pack/plugins/lens/public/visualizations/heatmap/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/heatmap/visualization.tsx @@ -11,11 +11,11 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n-react'; import { Ast } from '@kbn/interpreter'; import { Position } from '@elastic/charts'; +import { IconChartHeatmap } from '@kbn/chart-icons'; import { CUSTOM_PALETTE, PaletteRegistry, CustomPaletteParams } from '@kbn/coloring'; import { ThemeServiceStart } from '@kbn/core/public'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { VIS_EVENT_TO_TRIGGER } from '@kbn/visualizations-plugin/public'; -import { HeatmapIcon } from '@kbn/expression-heatmap-plugin/public'; import type { OperationMetadata, Visualization } from '../../types'; import type { HeatmapVisualizationState } from './types'; import { getSuggestions } from './suggestions'; @@ -105,7 +105,7 @@ export const getHeatmapVisualization = ({ visualizationTypes: [ { id: 'heatmap', - icon: HeatmapIcon, + icon: IconChartHeatmap, label: i18n.translate('xpack.lens.heatmapVisualization.heatmapLabel', { defaultMessage: 'Heat map', }), diff --git a/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.ts b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.ts index 32a5831618251..6fa35a8a17821 100644 --- a/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.ts @@ -5,10 +5,10 @@ * 2.0. */ +import { IconChartMetric } from '@kbn/chart-icons'; import { SuggestionRequest, VisualizationSuggestion, TableSuggestion } from '../../types'; import type { MetricState } from '../../../common/types'; import { layerTypes } from '../../../common'; -import { LensIconChartMetric } from '../../assets/chart_metric'; import { legacyMetricSupportedTypes } from './visualization'; /** @@ -49,7 +49,7 @@ function getSuggestion(table: TableSuggestion): VisualizationSuggestion { }, title: 'Metric', hide: true, - previewIcon: LensIconChartMetric, + previewIcon: IconChartMetric, score: 0.51, }, ]); @@ -182,7 +182,7 @@ describe('metric suggestions', () => { }, title: 'Metric', hide: true, - previewIcon: LensIconChartMetric, + previewIcon: IconChartMetric, score: 0.51, }, ]); @@ -214,7 +214,7 @@ describe('metric suggestions', () => { }, title: 'Metric', hide: true, - previewIcon: LensIconChartMetric, + previewIcon: IconChartMetric, score: 0.51, }, ]); @@ -287,7 +287,7 @@ describe('metric suggestions', () => { }, title: 'Metric', hide: true, - previewIcon: LensIconChartMetric, + previewIcon: IconChartMetric, score: 0.52, }, ]); @@ -319,7 +319,7 @@ describe('metric suggestions', () => { }, title: 'Metric', hide: true, - previewIcon: LensIconChartMetric, + previewIcon: IconChartMetric, score: 0.52, }, ]); @@ -350,7 +350,7 @@ describe('metric suggestions', () => { }, title: 'Metric', hide: true, - previewIcon: LensIconChartMetric, + previewIcon: IconChartMetric, score: 0.52, }, ]); diff --git a/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts b/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts index cdb11812bc4b8..ae40bf83574f4 100644 --- a/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts @@ -5,8 +5,8 @@ * 2.0. */ +import { IconChartMetric } from '@kbn/chart-icons'; import type { TableSuggestion, Visualization } from '../../types'; -import { LensIconChartMetric } from '../../assets/chart_metric'; import { layerTypes } from '../../../common'; import { metricLabel, MetricVisualizationState, supportedDataTypes } from './visualization'; @@ -59,7 +59,7 @@ export const getSuggestions: Visualization['getSuggest layerType: layerTypes.DATA, }, title: metricLabel, - previewIcon: LensIconChartMetric, + previewIcon: IconChartMetric, score: 0.5, // don't show suggestions since we're in tech preview hide: true, diff --git a/x-pack/plugins/lens/public/visualizations/metric/visualization.tsx b/x-pack/plugins/lens/public/visualizations/metric/visualization.tsx index 8651d4b76e95b..596d2596dd5d8 100644 --- a/x-pack/plugins/lens/public/visualizations/metric/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/metric/visualization.tsx @@ -16,9 +16,9 @@ import { VIS_EVENT_TO_TRIGGER } from '@kbn/visualizations-plugin/public'; import { LayoutDirection } from '@elastic/charts'; import { euiLightVars, euiThemeVars } from '@kbn/ui-theme'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { IconChartMetric } from '@kbn/chart-icons'; import { LayerType } from '../../../common'; import { getSuggestions } from './suggestions'; -import { LensIconChartMetric } from '../../assets/chart_metric'; import { Visualization, OperationMetadata, DatasourceLayers, AccessorConfig } from '../../types'; import { layerTypes } from '../../../common'; import { GROUP_ID, LENS_METRIC_ID } from './constants'; @@ -166,7 +166,7 @@ export const getMetricVisualization = ({ visualizationTypes: [ { id: LENS_METRIC_ID, - icon: LensIconChartMetric, + icon: IconChartMetric, label: metricLabel, groupLabel: metricGroupLabel, showExperimentalBadge: true, @@ -197,7 +197,7 @@ export const getMetricVisualization = ({ getDescription() { return { - icon: LensIconChartMetric, + icon: IconChartMetric, label: metricLabel, }; }, diff --git a/x-pack/plugins/lens/public/visualizations/partition/partition_charts_meta.ts b/x-pack/plugins/lens/public/visualizations/partition/partition_charts_meta.ts index 6d948ce4332fc..888fe7853b27b 100644 --- a/x-pack/plugins/lens/public/visualizations/partition/partition_charts_meta.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/partition_charts_meta.ts @@ -9,11 +9,13 @@ import { i18n } from '@kbn/i18n'; import type { EuiIconProps } from '@elastic/eui'; import type { DatatableColumn } from '@kbn/expressions-plugin/common'; -import { LensIconChartDonut } from '../../assets/chart_donut'; -import { LensIconChartPie } from '../../assets/chart_pie'; -import { LensIconChartTreemap } from '../../assets/chart_treemap'; -import { LensIconChartMosaic } from '../../assets/chart_mosaic'; -import { LensIconChartWaffle } from '../../assets/chart_waffle'; +import { + IconChartDonut, + IconChartPie, + IconChartTreemap, + IconChartMosaic, + IconChartWaffle, +} from '@kbn/chart-icons'; import { CategoryDisplay, NumberDisplay, @@ -140,7 +142,7 @@ const emptySizeRatioOptions: PartitionChartMeta['toolbarPopover']['emptySizeRati export const PartitionChartsMeta: Record = { donut: { - icon: LensIconChartDonut, + icon: IconChartDonut, label: i18n.translate('xpack.lens.pie.donutLabel', { defaultMessage: 'Donut', }), @@ -156,7 +158,7 @@ export const PartitionChartsMeta: Record = { }, }, pie: { - icon: LensIconChartPie, + icon: IconChartPie, label: i18n.translate('xpack.lens.pie.pielabel', { defaultMessage: 'Pie', }), @@ -171,7 +173,7 @@ export const PartitionChartsMeta: Record = { }, }, treemap: { - icon: LensIconChartTreemap, + icon: IconChartTreemap, label: i18n.translate('xpack.lens.pie.treemaplabel', { defaultMessage: 'Treemap', }), @@ -186,7 +188,7 @@ export const PartitionChartsMeta: Record = { }, }, mosaic: { - icon: LensIconChartMosaic, + icon: IconChartMosaic, label: i18n.translate('xpack.lens.pie.mosaiclabel', { defaultMessage: 'Mosaic', }), @@ -203,7 +205,7 @@ export const PartitionChartsMeta: Record = { requiredMinDimensionCount: 2, }, waffle: { - icon: LensIconChartWaffle, + icon: IconChartWaffle, label: i18n.translate('xpack.lens.pie.wafflelabel', { defaultMessage: 'Waffle', }), diff --git a/x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.tsx b/x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.tsx index 480417ab2cbad..4c60934ef9114 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.tsx @@ -13,6 +13,7 @@ import { isRangeAnnotation, } from '@kbn/event-annotation-plugin/public'; import { EventAnnotationConfig } from '@kbn/event-annotation-plugin/common'; +import { IconChartBarAnnotations } from '@kbn/chart-icons'; import { layerTypes } from '../../../../common'; import type { FramePublicAPI, Visualization } from '../../../types'; import { isHorizontalChart } from '../state_helpers'; @@ -24,7 +25,6 @@ import { getDataLayers, isAnnotationsLayer, } from '../visualization_helpers'; -import { LensIconChartBarAnnotations } from '../../../assets/chart_bar_annotations'; import { generateId } from '../../../id_generator'; const MAX_DATE = 8640000000000000; @@ -106,7 +106,7 @@ export const getAnnotationsSupportedLayer = ( label: i18n.translate('xpack.lens.xyChart.addAnnotationsLayerLabel', { defaultMessage: 'Annotations', }), - icon: LensIconChartBarAnnotations, + icon: IconChartBarAnnotations, disabled: !hasDateHistogram, toolTipContent: !hasDateHistogram ? i18n.translate('xpack.lens.xyChart.addAnnotationsLayerLabelDisabledHelp', { diff --git a/x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.tsx b/x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.tsx index 293dd8e67db8f..362b63c46eb2d 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.tsx @@ -8,6 +8,7 @@ import { groupBy, partition } from 'lodash'; import { i18n } from '@kbn/i18n'; import { Datatable } from '@kbn/expressions-plugin/public'; +import { IconChartBarReferenceLine } from '@kbn/chart-icons'; import { layerTypes } from '../../../common'; import type { DatasourceLayers, FramePublicAPI, Visualization } from '../../types'; import { groupAxesByType } from './axes_configuration'; @@ -28,7 +29,6 @@ import { isReferenceLayer, } from './visualization_helpers'; import { generateId } from '../../id_generator'; -import { LensIconChartBarReferenceLine } from '../../assets/chart_bar_reference_line'; import { defaultReferenceLineColor } from './color_assignment'; export interface ReferenceLineBase { @@ -318,7 +318,7 @@ export const getReferenceSupportedLayer = ( label: i18n.translate('xpack.lens.xyChart.addReferenceLineLayerLabel', { defaultMessage: 'Reference lines', }), - icon: LensIconChartBarReferenceLine, + icon: IconChartBarReferenceLine, disabled: !filledDataLayers.length || (!dataLayers.some(layerHasNumberHistogram) && diff --git a/x-pack/plugins/lens/public/visualizations/xy/types.ts b/x-pack/plugins/lens/public/visualizations/xy/types.ts index c2ca25c61c42e..8e140b83cb552 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/types.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/types.ts @@ -22,16 +22,18 @@ import type { YAxisConfig, } from '@kbn/expression-xy-plugin/common'; import { EventAnnotationConfig } from '@kbn/event-annotation-plugin/common'; -import { LensIconChartArea } from '../../assets/chart_area'; -import { LensIconChartAreaStacked } from '../../assets/chart_area_stacked'; -import { LensIconChartAreaPercentage } from '../../assets/chart_area_percentage'; -import { LensIconChartBar } from '../../assets/chart_bar'; -import { LensIconChartBarStacked } from '../../assets/chart_bar_stacked'; -import { LensIconChartBarPercentage } from '../../assets/chart_bar_percentage'; -import { LensIconChartBarHorizontal } from '../../assets/chart_bar_horizontal'; -import { LensIconChartBarHorizontalStacked } from '../../assets/chart_bar_horizontal_stacked'; -import { LensIconChartBarHorizontalPercentage } from '../../assets/chart_bar_horizontal_percentage'; -import { LensIconChartLine } from '../../assets/chart_line'; +import { + IconChartArea, + IconChartLine, + IconChartAreaStacked, + IconChartBarHorizontalStacked, + IconChartBarHorizontalPercentage, + IconChartAreaPercentage, + IconChartBar, + IconChartBarStacked, + IconChartBarPercentage, + IconChartBarHorizontal, +} from '@kbn/chart-icons'; import type { VisualizationType, Suggestion } from '../../types'; import type { ValueLabelConfig } from '../../../common/types'; @@ -168,7 +170,7 @@ const groupLabelForLineAndArea = i18n.translate('xpack.lens.xyVisualization.line export const visualizationTypes: VisualizationType[] = [ { id: 'bar', - icon: LensIconChartBar, + icon: IconChartBar, label: i18n.translate('xpack.lens.xyVisualization.barLabel', { defaultMessage: 'Bar vertical', }), @@ -177,7 +179,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'bar_horizontal', - icon: LensIconChartBarHorizontal, + icon: IconChartBarHorizontal, label: i18n.translate('xpack.lens.xyVisualization.barHorizontalLabel', { defaultMessage: 'H. Bar', }), @@ -188,7 +190,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'bar_stacked', - icon: LensIconChartBarStacked, + icon: IconChartBarStacked, label: i18n.translate('xpack.lens.xyVisualization.stackedBarLabel', { defaultMessage: 'Bar vertical stacked', }), @@ -196,7 +198,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'bar_percentage_stacked', - icon: LensIconChartBarPercentage, + icon: IconChartBarPercentage, label: i18n.translate('xpack.lens.xyVisualization.stackedPercentageBarLabel', { defaultMessage: 'Bar vertical percentage', }), @@ -204,7 +206,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'bar_horizontal_stacked', - icon: LensIconChartBarHorizontalStacked, + icon: IconChartBarHorizontalStacked, label: i18n.translate('xpack.lens.xyVisualization.stackedBarHorizontalLabel', { defaultMessage: 'H. Stacked bar', }), @@ -215,7 +217,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'bar_horizontal_percentage_stacked', - icon: LensIconChartBarHorizontalPercentage, + icon: IconChartBarHorizontalPercentage, label: i18n.translate('xpack.lens.xyVisualization.stackedPercentageBarHorizontalLabel', { defaultMessage: 'H. Percentage bar', }), @@ -229,7 +231,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'area', - icon: LensIconChartArea, + icon: IconChartArea, label: i18n.translate('xpack.lens.xyVisualization.areaLabel', { defaultMessage: 'Area', }), @@ -237,7 +239,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'area_stacked', - icon: LensIconChartAreaStacked, + icon: IconChartAreaStacked, label: i18n.translate('xpack.lens.xyVisualization.stackedAreaLabel', { defaultMessage: 'Area stacked', }), @@ -245,7 +247,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'area_percentage_stacked', - icon: LensIconChartAreaPercentage, + icon: IconChartAreaPercentage, label: i18n.translate('xpack.lens.xyVisualization.stackedPercentageAreaLabel', { defaultMessage: 'Area percentage', }), @@ -253,7 +255,7 @@ export const visualizationTypes: VisualizationType[] = [ }, { id: 'line', - icon: LensIconChartLine, + icon: IconChartLine, label: i18n.translate('xpack.lens.xyVisualization.lineLabel', { defaultMessage: 'Line', }), diff --git a/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts b/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts index b1313d765ae92..6817046864783 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts @@ -25,7 +25,7 @@ import type { } from './types'; import { layerTypes } from '../../../common'; import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; -import { LensIconChartBar } from '../../assets/chart_bar'; +import { IconChartBar } from '@kbn/chart-icons'; import type { VisualizeEditorLayersContext } from '@kbn/visualizations-plugin/public'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; @@ -109,7 +109,7 @@ describe('xy_visualization', () => { it('should show the preferredSeriesType if there are no layers', () => { const desc = xyVisualization.getDescription(mixedState()); - expect(desc.icon).toEqual(LensIconChartBar); + expect(desc.icon).toEqual(IconChartBar); expect(desc.label).toEqual('Bar vertical'); }); diff --git a/x-pack/plugins/lens/public/visualizations/xy/visualization_helpers.tsx b/x-pack/plugins/lens/public/visualizations/xy/visualization_helpers.tsx index c36916f7f0306..46bc1ba8dc551 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/visualization_helpers.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/visualization_helpers.tsx @@ -7,6 +7,7 @@ import { i18n } from '@kbn/i18n'; import { uniq } from 'lodash'; +import { IconChartBarHorizontal, IconChartBarStacked, IconChartMixedXy } from '@kbn/chart-icons'; import { DatasourceLayers, OperationMetadata, VisualizationType } from '../../types'; import { State, @@ -20,9 +21,6 @@ import { } from './types'; import { isHorizontalChart } from './state_helpers'; import { layerTypes } from '../..'; -import { LensIconChartBarHorizontal } from '../../assets/chart_bar_horizontal'; -import { LensIconChartMixedXy } from '../../assets/chart_mixed_xy'; -import { LensIconChartBarStacked } from '../../assets/chart_bar_stacked'; import { LayerType } from '../../../common'; export function getAxisName( @@ -192,7 +190,7 @@ export function getDescription(state?: State) { if (visualizationType === 'mixed' && isHorizontalChart(state.layers)) { return { - icon: LensIconChartBarHorizontal, + icon: IconChartBarHorizontal, label: i18n.translate('xpack.lens.xyVisualization.mixedBarHorizontalLabel', { defaultMessage: 'Mixed bar horizontal', }), @@ -201,7 +199,7 @@ export function getDescription(state?: State) { if (visualizationType === 'mixed') { return { - icon: LensIconChartMixedXy, + icon: IconChartMixedXy, label: i18n.translate('xpack.lens.xyVisualization.mixedLabel', { defaultMessage: 'Mixed XY', }), @@ -214,7 +212,7 @@ export function getDescription(state?: State) { }; } -export const defaultIcon = LensIconChartBarStacked; +export const defaultIcon = IconChartBarStacked; export const defaultSeriesType = 'bar_stacked'; export const supportedDataLayer = { @@ -222,7 +220,7 @@ export const supportedDataLayer = { label: i18n.translate('xpack.lens.xyChart.addDataLayerLabel', { defaultMessage: 'Visualization', }), - icon: LensIconChartMixedXy, + icon: IconChartMixedXy, }; // i18n ids cannot be dynamically generated, hence the function below diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/icon_set.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/icon_set.ts index 80cf7eccc9622..23a4b6fb52610 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/icon_set.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/icon_set.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { AvailableAnnotationIcon } from '@kbn/event-annotation-plugin/common'; -import { IconTriangle, IconCircle } from '../../../../assets/annotation_icons'; +import { IconTriangle, IconCircle } from '@kbn/chart-icons'; import { IconSet } from '../shared/icon_select'; export const annotationsIconSet: IconSet = [ diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx index 65d7b94281486..cb02bb796a3aa 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx @@ -18,7 +18,13 @@ import { i18n } from '@kbn/i18n'; import { isEqual } from 'lodash'; import { AxisExtentConfig, YScaleType } from '@kbn/expression-xy-plugin/common'; import { ToolbarButtonProps } from '@kbn/kibana-react-plugin/public'; -import { XYLayerConfig, AxesSettingsConfig } from '../types'; +import { + EuiIconAxisBottom, + EuiIconAxisLeft, + EuiIconAxisRight, + EuiIconAxisTop, +} from '@kbn/chart-icons'; +import { isHorizontalChart } from '../state_helpers'; import { ToolbarPopover, useDebouncedValue, @@ -26,11 +32,7 @@ import { RangeInputField, BucketAxisBoundsControl, } from '../../../shared_components'; -import { isHorizontalChart } from '../state_helpers'; -import { EuiIconAxisBottom } from '../../../assets/axis_bottom'; -import { EuiIconAxisLeft } from '../../../assets/axis_left'; -import { EuiIconAxisRight } from '../../../assets/axis_right'; -import { EuiIconAxisTop } from '../../../assets/axis_top'; +import { XYLayerConfig, AxesSettingsConfig } from '../types'; import { validateExtent } from '../axes_configuration'; import './axis_settings_popover.scss'; diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/layer_header.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/layer_header.tsx index 44d9f342cfcd7..d55aa0aa12133 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/layer_header.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/layer_header.tsx @@ -9,12 +9,11 @@ import React, { useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiIcon, EuiPopover, EuiSelectable, EuiText, EuiPopoverTitle } from '@elastic/eui'; import { ToolbarButton } from '@kbn/kibana-react-plugin/public'; +import { IconChartBarReferenceLine, IconChartBarAnnotations } from '@kbn/chart-icons'; import type { VisualizationLayerWidgetProps, VisualizationType } from '../../../types'; import { State, visualizationTypes, SeriesType } from '../types'; import { isHorizontalChart, isHorizontalSeries } from '../state_helpers'; import { StaticHeader } from '../../../shared_components'; -import { LensIconChartBarReferenceLine } from '../../../assets/chart_bar_reference_line'; -import { LensIconChartBarAnnotations } from '../../../assets/chart_bar_annotations'; import { updateLayer } from '.'; import { isAnnotationsLayer, isDataLayer, isReferenceLayer } from '../visualization_helpers'; @@ -34,7 +33,7 @@ export function LayerHeader(props: VisualizationLayerWidgetProps) { function ReferenceLayerHeader() { return ( { must: [ { bool: { - filter: [ - { - terms: { - 'united.agent.policy_id': [], - }, - }, - { - exists: { - field: 'united.endpoint.agent.id', - }, - }, - { - exists: { - field: 'united.agent.agent.id', - }, - }, - { - term: { - 'united.agent.active': { - value: true, - }, - }, - }, - ], must_not: { terms: { 'agent.id': [ @@ -280,6 +256,12 @@ describe('test endpoint routes', () => { ], }, }, + filter: [ + { terms: { 'united.agent.policy_id': [] } }, + { exists: { field: 'united.endpoint.agent.id' } }, + { exists: { field: 'united.agent.agent.id' } }, + { term: { 'united.agent.active': { value: true } } }, + ], }, }, { @@ -290,13 +272,7 @@ describe('test endpoint routes', () => { filter: [ { bool: { - should: [ - { - exists: { - field: 'united.agent.upgrade_started_at', - }, - }, - ], + should: [{ exists: { field: 'united.agent.upgrade_started_at' } }], minimum_should_match: 1, }, }, @@ -304,13 +280,7 @@ describe('test endpoint routes', () => { bool: { must_not: { bool: { - should: [ - { - exists: { - field: 'united.agent.upgraded_at', - }, - }, - ], + should: [{ exists: { field: 'united.agent.upgraded_at' } }], minimum_should_match: 1, }, }, @@ -323,13 +293,7 @@ describe('test endpoint routes', () => { bool: { must_not: { bool: { - should: [ - { - exists: { - field: 'united.agent.last_checkin', - }, - }, - ], + should: [{ exists: { field: 'united.agent.last_checkin' } }], minimum_should_match: 1, }, }, @@ -337,16 +301,20 @@ describe('test endpoint routes', () => { }, { bool: { - should: [ - { - exists: { - field: 'united.agent.unenrollment_started_at', - }, - }, - ], + should: [{ exists: { field: 'united.agent.unenrollment_started_at' } }], minimum_should_match: 1, }, }, + { + bool: { + must_not: { + bool: { + should: [{ exists: { field: 'united.agent.policy_revision_idx' } }], + minimum_should_match: 1, + }, + }, + }, + }, ], minimum_should_match: 1, }, @@ -355,13 +323,7 @@ describe('test endpoint routes', () => { bool: { must_not: { bool: { - should: [ - { - match: { - 'host.ip': '10.140.73.246', - }, - }, - ], + should: [{ match: { 'host.ip': '10.140.73.246' } }], minimum_should_match: 1, }, }, diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/query_builders.fixtures.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/query_builders.fixtures.ts index 31b383f2a033e..30189459ff167 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/query_builders.fixtures.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/query_builders.fixtures.ts @@ -18,28 +18,10 @@ export const expectedCompleteUnitedIndexQuery = { }, }, filter: [ - { - terms: { - 'united.agent.policy_id': ['test-endpoint-policy-id'], - }, - }, - { - exists: { - field: 'united.endpoint.agent.id', - }, - }, - { - exists: { - field: 'united.agent.agent.id', - }, - }, - { - term: { - 'united.agent.active': { - value: true, - }, - }, - }, + { terms: { 'united.agent.policy_id': ['test-endpoint-policy-id'] } }, + { exists: { field: 'united.endpoint.agent.id' } }, + { exists: { field: 'united.agent.agent.id' } }, + { term: { 'united.agent.active': { value: true } } }, ], }, }, @@ -53,15 +35,7 @@ export const expectedCompleteUnitedIndexQuery = { filter: [ { bool: { - should: [ - { - range: { - 'united.agent.last_checkin': { - lt: 'now-300s', - }, - }, - }, - ], + should: [{ range: { 'united.agent.last_checkin': { lt: 'now-300s' } } }], minimum_should_match: 1, }, }, @@ -168,6 +142,22 @@ export const expectedCompleteUnitedIndexQuery = { minimum_should_match: 1, }, }, + { + bool: { + must_not: { + bool: { + should: [ + { + exists: { + field: 'united.agent.policy_revision_idx', + }, + }, + ], + minimum_should_match: 1, + }, + }, + }, + }, ], minimum_should_match: 1, }, @@ -191,9 +181,7 @@ export const expectedCompleteUnitedIndexQuery = { bool: { should: [ { - exists: { - field: 'united.agent.upgrade_started_at', - }, + exists: { field: 'united.agent.upgrade_started_at' }, }, ], minimum_should_match: 1, @@ -204,11 +192,7 @@ export const expectedCompleteUnitedIndexQuery = { must_not: { bool: { should: [ - { - exists: { - field: 'united.agent.upgraded_at', - }, - }, + { exists: { field: 'united.agent.upgraded_at' } }, ], minimum_should_match: 1, }, @@ -223,11 +207,7 @@ export const expectedCompleteUnitedIndexQuery = { must_not: { bool: { should: [ - { - exists: { - field: 'united.agent.last_checkin', - }, - }, + { exists: { field: 'united.agent.last_checkin' } }, ], minimum_should_match: 1, }, @@ -237,15 +217,23 @@ export const expectedCompleteUnitedIndexQuery = { { bool: { should: [ - { - exists: { - field: 'united.agent.unenrollment_started_at', - }, - }, + { exists: { field: 'united.agent.unenrollment_started_at' } }, ], minimum_should_match: 1, }, }, + { + bool: { + must_not: { + bool: { + should: [ + { exists: { field: 'united.agent.policy_revision_idx' } }, + ], + minimum_should_match: 1, + }, + }, + }, + }, ], minimum_should_match: 1, }, @@ -268,11 +256,7 @@ export const expectedCompleteUnitedIndexQuery = { { bool: { should: [ - { - match: { - 'united.agent.last_checkin_status': 'error', - }, - }, + { match: { 'united.agent.last_checkin_status': 'error' } }, ], minimum_should_match: 1, }, @@ -280,11 +264,7 @@ export const expectedCompleteUnitedIndexQuery = { { bool: { should: [ - { - match: { - 'united.agent.last_checkin_status': 'degraded', - }, - }, + { match: { 'united.agent.last_checkin_status': 'degraded' } }, ], minimum_should_match: 1, }, @@ -305,9 +285,7 @@ export const expectedCompleteUnitedIndexQuery = { bool: { should: [ { - exists: { - field: 'united.agent.upgrade_started_at', - }, + exists: { field: 'united.agent.upgrade_started_at' }, }, ], minimum_should_match: 1, @@ -318,11 +296,7 @@ export const expectedCompleteUnitedIndexQuery = { must_not: { bool: { should: [ - { - exists: { - field: 'united.agent.upgraded_at', - }, - }, + { exists: { field: 'united.agent.upgraded_at' } }, ], minimum_should_match: 1, }, @@ -337,11 +311,7 @@ export const expectedCompleteUnitedIndexQuery = { must_not: { bool: { should: [ - { - exists: { - field: 'united.agent.last_checkin', - }, - }, + { exists: { field: 'united.agent.last_checkin' } }, ], minimum_should_match: 1, }, @@ -351,15 +321,23 @@ export const expectedCompleteUnitedIndexQuery = { { bool: { should: [ - { - exists: { - field: 'united.agent.unenrollment_started_at', - }, - }, + { exists: { field: 'united.agent.unenrollment_started_at' } }, ], minimum_should_match: 1, }, }, + { + bool: { + must_not: { + bool: { + should: [ + { exists: { field: 'united.agent.policy_revision_idx' } }, + ], + minimum_should_match: 1, + }, + }, + }, + }, ], minimum_should_match: 1, }, @@ -381,13 +359,7 @@ export const expectedCompleteUnitedIndexQuery = { filter: [ { bool: { - should: [ - { - exists: { - field: 'united.agent.upgrade_started_at', - }, - }, - ], + should: [{ exists: { field: 'united.agent.upgrade_started_at' } }], minimum_should_match: 1, }, }, @@ -395,13 +367,7 @@ export const expectedCompleteUnitedIndexQuery = { bool: { must_not: { bool: { - should: [ - { - exists: { - field: 'united.agent.upgraded_at', - }, - }, - ], + should: [{ exists: { field: 'united.agent.upgraded_at' } }], minimum_should_match: 1, }, }, @@ -414,13 +380,7 @@ export const expectedCompleteUnitedIndexQuery = { bool: { must_not: { bool: { - should: [ - { - exists: { - field: 'united.agent.last_checkin', - }, - }, - ], + should: [{ exists: { field: 'united.agent.last_checkin' } }], minimum_should_match: 1, }, }, @@ -428,16 +388,20 @@ export const expectedCompleteUnitedIndexQuery = { }, { bool: { - should: [ - { - exists: { - field: 'united.agent.unenrollment_started_at', - }, - }, - ], + should: [{ exists: { field: 'united.agent.unenrollment_started_at' } }], minimum_should_match: 1, }, }, + { + bool: { + must_not: { + bool: { + should: [{ exists: { field: 'united.agent.policy_revision_idx' } }], + minimum_should_match: 1, + }, + }, + }, + }, ], minimum_should_match: 1, }, @@ -449,13 +413,7 @@ export const expectedCompleteUnitedIndexQuery = { }, { bool: { - should: [ - { - exists: { - field: 'united.endpoint.host.os.name', - }, - }, - ], + should: [{ exists: { field: 'united.endpoint.host.os.name' } }], minimum_should_match: 1, }, }, diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/agent_status.test.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/agent_status.test.ts index f3c5c6b542de5..7f89444b21fa5 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/agent_status.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/agent_status.test.ts @@ -93,7 +93,7 @@ describe('test filtering endpoint hosts by agent status', () => { const status = ['healthy']; const kuery = buildStatusesKuery(status); const expected = - '(not (united.agent.last_checkin < now-300s AND not ((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*))) AND not ( ((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) )) AND not ((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*))) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*)))'; + '(not (united.agent.last_checkin < now-300s AND not ((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*))) AND not ( ((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*) )) AND not ((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*))) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*)))'; expect(kuery).toEqual(expected); }); @@ -101,7 +101,7 @@ describe('test filtering endpoint hosts by agent status', () => { const status = ['offline']; const kuery = buildStatusesKuery(status); const expected = - '(united.agent.last_checkin < now-300s AND not ((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*))) AND not ( ((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) ))'; + '(united.agent.last_checkin < now-300s AND not ((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*))) AND not ( ((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*) ))'; expect(kuery).toEqual(expected); }); @@ -109,7 +109,7 @@ describe('test filtering endpoint hosts by agent status', () => { const status = ['unhealthy']; const kuery = buildStatusesKuery(status); const expected = - '((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*)))'; + '((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*)))'; expect(kuery).toEqual(expected); }); @@ -117,7 +117,7 @@ describe('test filtering endpoint hosts by agent status', () => { const status = ['updating']; const kuery = buildStatusesKuery(status); const expected = - '(((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*))'; + '(((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*))'; expect(kuery).toEqual(expected); }); @@ -132,7 +132,7 @@ describe('test filtering endpoint hosts by agent status', () => { const statuses = ['offline', 'unhealthy']; const kuery = buildStatusesKuery(statuses); const expected = - '(united.agent.last_checkin < now-300s AND not ((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*))) AND not ( ((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) ) OR (united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*)))'; + '(united.agent.last_checkin < now-300s AND not ((united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*))) AND not ( ((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*) ) OR (united.agent.last_checkin_status:error or united.agent.last_checkin_status:degraded) AND not (((united.agent.upgrade_started_at:*) and not (united.agent.upgraded_at:*)) or (not (united.agent.last_checkin:*)) or (united.agent.unenrollment_started_at:*) or (not united.agent.policy_revision_idx:*)))'; expect(kuery).toEqual(expected); }); }); diff --git a/x-pack/plugins/synthetics/e2e/journeys/alerts/default_email_settings.ts b/x-pack/plugins/synthetics/e2e/journeys/alerts/default_email_settings.ts index f2504e690965f..ce19d8442d056 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/alerts/default_email_settings.ts +++ b/x-pack/plugins/synthetics/e2e/journeys/alerts/default_email_settings.ts @@ -43,7 +43,6 @@ journey('DefaultEmailSettings', async ({ page, params }) => { }); step('clear existing settings', async () => { - await settings.dismissSyntheticsCallout(); await page.waitForSelector(byTestId('"default-connectors-input-loaded"')); await page.waitForTimeout(10 * 1000); const toEmailInput = await page.$(byTestId('toEmailAddressInput')); diff --git a/x-pack/plugins/synthetics/e2e/journeys/step_duration.journey.ts b/x-pack/plugins/synthetics/e2e/journeys/step_duration.journey.ts index 1193409d0df94..ba62da5d4a4d7 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/step_duration.journey.ts +++ b/x-pack/plugins/synthetics/e2e/journeys/step_duration.journey.ts @@ -30,7 +30,6 @@ journey('StepsDuration', async ({ page, params }) => { }); step('Go to monitor details', async () => { - await page.click('text=Dismiss'); await page.click('button:has-text("test-monitor - inline")'); expect(page.url()).toBe(`${baseUrl}/monitor/dGVzdC1tb25pdG9yLWlubGluZQ==/?${queryParams}`); }); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/getting_started.journey.ts b/x-pack/plugins/synthetics/e2e/journeys/synthetics/getting_started.journey.ts index 40035e9c70923..2d9f1f888a936 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/getting_started.journey.ts +++ b/x-pack/plugins/synthetics/e2e/journeys/synthetics/getting_started.journey.ts @@ -46,8 +46,4 @@ journey(`Getting Started Page`, async ({ page, params }: { page: Page; params: a await createBasicMonitor(); await syntheticsApp.confirmAndSave(); }); - - step('it navigates to details page after saving', async () => { - await page.click('text=Dismiss'); - }); }); diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime.journey.ts b/x-pack/plugins/synthetics/e2e/journeys/uptime.journey.ts index 5896b609cf76d..15cca32983e1d 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/uptime.journey.ts +++ b/x-pack/plugins/synthetics/e2e/journeys/uptime.journey.ts @@ -28,12 +28,6 @@ journey('uptime', ({ page, params }) => { await page.click('[data-test-subj=loginSubmit]'); }); - step('dismiss synthetics notice', async () => { - await page.click('[data-test-subj=uptimeDismissSyntheticsCallout]', { - timeout: 60 * 1000, - }); - }); - step('change uptime index pattern', async () => { await page.click(byTestId('settings-page-link')); diff --git a/x-pack/plugins/synthetics/e2e/page_objects/utils.tsx b/x-pack/plugins/synthetics/e2e/page_objects/utils.tsx index 024609e2f69ef..74fa8f6c8ce54 100644 --- a/x-pack/plugins/synthetics/e2e/page_objects/utils.tsx +++ b/x-pack/plugins/synthetics/e2e/page_objects/utils.tsx @@ -19,12 +19,6 @@ export function utilsPageProvider({ page }: { page: Page }) { } }, - async dismissSyntheticsCallout() { - await page.click('[data-test-subj=uptimeDismissSyntheticsCallout]', { - timeout: 60 * 1000, - }); - }, - async assertText({ text }: { text: string }) { await page.waitForSelector(`text=${text}`); expect(await page.$(`text=${text}`)).toBeTruthy(); diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/synthetics_callout.test.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/synthetics_callout.test.tsx deleted file mode 100644 index d5b82a562be3b..0000000000000 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/synthetics_callout.test.tsx +++ /dev/null @@ -1,133 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { shallowWithIntl } from '@kbn/test-jest-helpers'; -import React from 'react'; -import { SyntheticsCallout } from './synthetics_callout'; - -describe('SyntheticsCallout', () => { - let setItemMock; - let localStorageMock: any; - - beforeEach(() => { - setItemMock = jest.fn(); - localStorageMock = { - getItem: jest.fn().mockImplementation(() => null), - setItem: setItemMock, - }; - - global.localStorage = localStorageMock; - }); - - it('renders component if dismissal flag is unset', () => { - expect(shallowWithIntl()).toMatchInlineSnapshot(` - - -

- -

- - - - - - - - - - - - -
-
- `); - }); - - it('returns null if callout has been dismissed', () => { - localStorageMock.getItem = jest.fn().mockImplementation(() => 'true'); - expect(shallowWithIntl()).toEqual({}); - }); - - it('renders the component, and then returns null when dismiss button clicked', () => { - localStorageMock.getItem = jest - .fn() - .mockImplementationOnce(() => null) - .mockImplementationOnce(() => 'true'); - const wrapper = shallowWithIntl(); - expect(wrapper).toMatchInlineSnapshot(` - - -

- -

- - - - - - - - - - - - -
-
- `); - wrapper.find('EuiButton').simulate('click'); - expect(wrapper).toEqual({}); - }); -}); diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/synthetics_callout.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/synthetics_callout.tsx deleted file mode 100644 index a6c4f06d31c27..0000000000000 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/synthetics_callout.tsx +++ /dev/null @@ -1,72 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { EuiButton, EuiButtonEmpty, EuiCallOut, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import React, { useState } from 'react'; -import { i18n } from '@kbn/i18n'; -import { FormattedMessage } from '@kbn/i18n-react'; - -const SYNTHETICS_CALLOUT_LS_KEY = 'xpack.uptime.syntheticsCallout.display'; -const shouldShowSyntheticsCallout = () => { - let value = localStorage.getItem(SYNTHETICS_CALLOUT_LS_KEY); - if (value === null) { - localStorage.setItem(SYNTHETICS_CALLOUT_LS_KEY, 'true'); - value = 'true'; - } - return value === 'true'; -}; -const hideSyntheticsCallout = () => localStorage.setItem(SYNTHETICS_CALLOUT_LS_KEY, 'false'); - -export const SyntheticsCallout = () => { - const [shouldShow, setShouldShow] = useState(shouldShowSyntheticsCallout()); - if (!shouldShow) { - return null; - } - return ( - <> - -

- -

- - - - - - - - { - if (shouldShow) { - hideSyntheticsCallout(); - setShouldShow(false); - } - }} - > - - - - -
- - ); -}; diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/routes.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/routes.tsx index b32144750705b..6fd6ee19534b5 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/routes.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/routes.tsx @@ -49,7 +49,6 @@ import { MonitorPageTitle, MonitorPageTitleContent } from './components/monitor/ import { UptimeDatePicker } from './components/common/uptime_date_picker'; import { CertRefreshBtn } from './components/certificates/cert_refresh_btn'; import { CertificateTitle } from './components/certificates/certificate_title'; -import { SyntheticsCallout } from './components/overview/synthetics_callout'; import { StepDetailPageChildren, StepDetailPageHeader, @@ -314,7 +313,6 @@ export const PageRouter: FC = () => { }) => (
- { - if (!esQueryResponse) return {}; + if (!esQueryResponse?.aggregations) return {}; const { hasFetchStartField: { backEnd, totalPageLoadDuration }, - } = esQueryResponse.aggregations!; + } = esQueryResponse.aggregations; const pkey = percentile.toFixed(1); diff --git a/x-pack/test/fleet_api_integration/apis/agents/status.ts b/x-pack/test/fleet_api_integration/apis/agents/status.ts index 0d22eeeae6228..63445845f6612 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/status.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/status.ts @@ -25,6 +25,7 @@ export default function ({ getService }: FtrProviderContext) { index: AGENTS_INDEX, body: { doc: { + policy_revision_idx: 1, last_checkin: new Date().toISOString(), }, }, @@ -35,6 +36,7 @@ export default function ({ getService }: FtrProviderContext) { index: AGENTS_INDEX, body: { doc: { + policy_revision_idx: 1, last_checkin: new Date(Date.now() - 1000 * 60 * 3).toISOString(), // 2m online }, }, @@ -46,6 +48,7 @@ export default function ({ getService }: FtrProviderContext) { index: AGENTS_INDEX, body: { doc: { + policy_revision_idx: 1, last_checkin: new Date(Date.now() - 1000 * 60 * 6).toISOString(), // 6m offline }, }, @@ -57,27 +60,45 @@ export default function ({ getService }: FtrProviderContext) { index: AGENTS_INDEX, body: { doc: { + policy_revision_idx: 1, last_checkin: new Date().toISOString(), upgrade_started_at: new Date().toISOString(), }, }, }); - // 1 agent inactive + // 1 agent reassigned to a new policy await es.create({ id: 'agent5', refresh: 'wait_for', index: AGENTS_INDEX, - body: { - doc: { - active: false, - access_api_key_id: 'api-key-4', - policy_id: 'policy1', - type: 'PERMANENT', - local_metadata: { host: { hostname: 'host5' } }, - user_provided_metadata: {}, - enrolled_at: '2022-06-21T12:17:25Z', - last_checkin: '2022-06-27T12:29:29Z', - }, + document: { + active: true, + access_api_key_id: 'api-key-4', + policy_id: 'policy1', + type: 'PERMANENT', + local_metadata: { host: { hostname: 'host5' } }, + user_provided_metadata: {}, + enrolled_at: '2022-06-21T12:17:25Z', + last_checkin: new Date().toISOString(), + policy_revision_idx: null, + }, + }); + + // 1 agent inactive + await es.create({ + id: 'agent6', + refresh: 'wait_for', + index: AGENTS_INDEX, + document: { + active: false, + access_api_key_id: 'api-key-4', + policy_id: 'policy1', + type: 'PERMANENT', + policy_revision_idx: 1, + local_metadata: { host: { hostname: 'host6' } }, + user_provided_metadata: {}, + enrolled_at: '2022-06-21T12:17:25Z', + last_checkin: '2022-06-27T12:29:29Z', }, }); }); @@ -87,16 +108,15 @@ export default function ({ getService }: FtrProviderContext) { it('should return the status of agents', async () => { const { body: apiResponse } = await supertest.get(`/api/fleet/agent_status`).expect(200); - expect(apiResponse).to.eql({ results: { events: 0, - total: 4, + total: 5, online: 2, error: 0, offline: 1, - updating: 1, - other: 2, + updating: 2, + other: 3, inactive: 1, }, }); diff --git a/x-pack/test/fleet_api_integration/helpers.ts b/x-pack/test/fleet_api_integration/helpers.ts index 6e1a2edaf9f75..552c83d3ca890 100644 --- a/x-pack/test/fleet_api_integration/helpers.ts +++ b/x-pack/test/fleet_api_integration/helpers.ts @@ -47,23 +47,24 @@ export async function generateAgent( switch (status) { case 'error': - data = { last_checkin_status: 'error' }; + data = { policy_revision_idx: 1, last_checkin_status: 'error' }; break; case 'degraded': - data = { last_checkin_status: 'degraded' }; + data = { policy_revision_idx: 1, last_checkin_status: 'degraded' }; break; case 'offline': - data = { last_checkin: '2017-06-07T18:59:04.498Z' }; + data = { policy_revision_idx: 1, last_checkin: '2017-06-07T18:59:04.498Z' }; break; // Agent with last checkin status as error and currently unenrolling => should displayd updating status case 'error-unenrolling': data = { + policy_revision_idx: 1, last_checkin_status: 'error', unenrollment_started_at: '2017-06-07T18:59:04.498Z', }; break; default: - data = { last_checkin: new Date().toISOString() }; + data = { policy_revision_idx: 1, last_checkin: new Date().toISOString() }; } await es.index({ diff --git a/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts b/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts index 963acca117881..ddfbac948d0fa 100644 --- a/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts +++ b/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts @@ -47,7 +47,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('displays to define default connector', async () => { - await testSubjects.click('uptimeDismissSyntheticsCallout'); await hideErrorToast(); await testSubjects.click('uptimeDisplayDefineConnector'); await testSubjects.existOrFail('uptimeSettingsDefineConnector'); diff --git a/yarn.lock b/yarn.lock index 0b584c52076c4..605a9619eb39a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3021,6 +3021,10 @@ version "0.0.0" uid "" +"@kbn/chart-icons@link:bazel-bin/packages/kbn-chart-icons": + version "0.0.0" + uid "" + "@kbn/ci-stats-core@link:bazel-bin/packages/kbn-ci-stats-core": version "0.0.0" uid "" @@ -6933,6 +6937,10 @@ version "0.0.0" uid "" +"@types/kbn__chart-icons@link:bazel-bin/packages/kbn-chart-icons/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__ci-stats-core@link:bazel-bin/packages/kbn-ci-stats-core/npm_module_types": version "0.0.0" uid ""