From 4c4cb1e1678130c300c93e00061f0478047aff28 Mon Sep 17 00:00:00 2001 From: Linghao Su Date: Mon, 14 Oct 2024 15:54:11 +0800 Subject: [PATCH 1/2] [Lens] Disable config axis side and color picker when groupid is breakdown and collaseFn enable (#195845) ## Summary Fixes https://github.com/elastic/kibana/issues/195481 For XY charts only, when opening the breakdown dimension editor, we disable the color picker and axis side configuration. ## Before ![image](https://github.com/user-attachments/assets/62f03481-45aa-402c-8d53-d30a8b02d11c) ## After ![image](https://github.com/user-attachments/assets/f48abdca-ab3f-40bb-b9fa-8266416b915c) ![image](https://github.com/user-attachments/assets/c0f62b62-b9ef-4fe4-917f-77246fd0066b) https://github.com/user-attachments/assets/05ee0e8e-713b-4eb3-a1ef-bf7418226409 --------- Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com> Co-authored-by: Nick Partridge --- .../xy_config_panel/dimension_editor.test.tsx | 60 +++++++++++++++++++ .../xy/xy_config_panel/dimension_editor.tsx | 6 +- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.test.tsx index 3d675883ec6bf..08a83ef7e0176 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.test.tsx @@ -7,6 +7,7 @@ import React from 'react'; import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; +import { render, screen } from '@testing-library/react'; import { EuiButtonGroupProps, EuiButtonGroup } from '@elastic/eui'; import { DataDimensionEditor } from './dimension_editor'; import { FramePublicAPI, DatasourcePublicAPI } from '../../../types'; @@ -195,6 +196,65 @@ describe('XY Config panels', () => { expect(component.find(EuiColorPicker).prop('color')).toEqual('red'); }); + test.each<{ collapseFn?: string; shouldDisplay?: boolean }>([ + // should display color picker + { shouldDisplay: true }, + // should not display color picker + { collapseFn: 'sum', shouldDisplay: false }, + ])( + 'should only show color picker when collapseFn is defined for breakdown group', + ({ collapseFn = undefined, shouldDisplay = true }) => { + const state = { + ...testState(), + layers: [ + { + collapseFn, + seriesType: 'bar', + layerType: LayerTypes.DATA, + layerId: 'first', + splitAccessor: 'breakdownAccessor', + xAccessor: 'foo', + accessors: ['bar'], + yConfig: [{ forAccessor: 'bar', color: 'red' }], + }, + ], + } as XYState; + + render( + + ); + const colorPickerUi = screen.queryByLabelText('Edit colors'); + + if (shouldDisplay) { + expect(colorPickerUi).toBeInTheDocument(); + } else { + expect(colorPickerUi).not.toBeInTheDocument(); + } + } + ); test('does not apply incorrect color', () => { jest.useFakeTimers(); const setState = jest.fn(); diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.tsx index c0916b823466e..f06f2d861d865 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.tsx @@ -134,8 +134,8 @@ export function DataDimensionEditor( const { splitAccessor } = layer; const splitCategories = getColorCategories(table?.rows ?? [], splitAccessor); - if (props.groupId === 'breakdown' && !layer.collapseFn) { - return ( + if (props.groupId === 'breakdown') { + return !layer.collapseFn ? ( - ); + ) : null; } const isHorizontal = isHorizontalChart(state.layers); From 08715c679ae7b573a8ba6631e40eb95e85fba114 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:00:47 +1100 Subject: [PATCH 2/2] [ES|QL] Update function metadata (#196047) This PR updates the function definitions and inline docs based on the latest metadata from Elasticsearch. Co-authored-by: Stratoula Kalafateli --- .../definitions/generated/scalar_functions.ts | 258 ++++++++++++++++++ .../sections/generated/scalar_functions.tsx | 34 +++ 2 files changed, 292 insertions(+) diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts index e860ff932f3dc..b25d3ad8b6563 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts @@ -2015,6 +2015,263 @@ const greatestDefinition: FunctionDefinition = { examples: ['ROW a = 10, b = 20\n| EVAL g = GREATEST(a, b)'], }; +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const hypotDefinition: FunctionDefinition = { + type: 'eval', + name: 'hypot', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.hypot', { + defaultMessage: + 'Returns the hypotenuse of two numbers. The input can be any numeric values, the return value is always a double.\nHypotenuses of infinities are null.', + }), + alias: undefined, + signatures: [ + { + params: [ + { + name: 'number1', + type: 'double', + optional: false, + }, + { + name: 'number2', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'double', + optional: false, + }, + { + name: 'number2', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'double', + optional: false, + }, + { + name: 'number2', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'double', + optional: false, + }, + { + name: 'number2', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'integer', + optional: false, + }, + { + name: 'number2', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'integer', + optional: false, + }, + { + name: 'number2', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'integer', + optional: false, + }, + { + name: 'number2', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'integer', + optional: false, + }, + { + name: 'number2', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'long', + optional: false, + }, + { + name: 'number2', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'long', + optional: false, + }, + { + name: 'number2', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'long', + optional: false, + }, + { + name: 'number2', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'long', + optional: false, + }, + { + name: 'number2', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'unsigned_long', + optional: false, + }, + { + name: 'number2', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'unsigned_long', + optional: false, + }, + { + name: 'number2', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'unsigned_long', + optional: false, + }, + { + name: 'number2', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'number1', + type: 'unsigned_long', + optional: false, + }, + { + name: 'number2', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'double', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: ['ROW a = 3.0, b = 4.0\n| EVAL c = HYPOT(a, b)'], +}; + // Do not edit this manually... generated by scripts/generate_function_definitions.ts const ipPrefixDefinition: FunctionDefinition = { type: 'eval', @@ -8811,6 +9068,7 @@ export const scalarFunctionDefinitions = [ floorDefinition, fromBase64Definition, greatestDefinition, + hypotDefinition, ipPrefixDefinition, leastDefinition, leftDefinition, diff --git a/packages/kbn-language-documentation/src/sections/generated/scalar_functions.tsx b/packages/kbn-language-documentation/src/sections/generated/scalar_functions.tsx index e9d6edcbcb544..3b74c73cd2a9a 100644 --- a/packages/kbn-language-documentation/src/sections/generated/scalar_functions.tsx +++ b/packages/kbn-language-documentation/src/sections/generated/scalar_functions.tsx @@ -834,6 +834,40 @@ export const functions = { | EVAL g = GREATEST(a, b) \`\`\` Note: When run on \`keyword\` or \`text\` fields, this returns the last string in alphabetical order. When run on \`boolean\` columns this will return \`true\` if any values are \`true\`. + `, + description: + 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)', + ignoreTag: true, + } + )} + /> + ), + }, + // Do not edit manually... automatically generated by scripts/generate_esql_docs.ts + { + label: i18n.translate('languageDocumentation.documentationESQL.hypot', { + defaultMessage: 'HYPOT', + }), + description: ( + + + ### HYPOT + Returns the hypotenuse of two numbers. The input can be any numeric values, the return value is always a double. + Hypotenuses of infinities are null. + + \`\`\` + ROW a = 3.0, b = 4.0 + | EVAL c = HYPOT(a, b) + \`\`\` `, description: 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',