diff --git a/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/layers.test.ts b/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/layers.test.ts index dd4926e7aeb7e..6c94971397d3e 100644 --- a/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/layers.test.ts +++ b/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/layers.test.ts @@ -309,6 +309,27 @@ describe('getLayers', () => { ], series: [createSeries({ metrics: staticValueMetric })], }); + const panelWithSingleAnnotationDefaultDataView = createPanel({ + annotations: [ + { + fields: 'geo.src,host', + template: 'Security Error from {{geo.src}} on {{host}}', + query_string: { + query: 'tags:error AND tags:security', + language: 'lucene', + }, + id: 'ann1', + color: 'rgba(211,49,21,0.7)', + time_field: 'timestamp', + icon: 'fa-asterisk', + ignore_global_filters: 1, + ignore_panel_filters: 1, + hidden: true, + index_pattern: '', + }, + ], + series: [createSeries({ metrics: staticValueMetric })], + }); test.each<[string, [Record, Panel], Array>]>([ [ @@ -521,6 +542,14 @@ describe('getLayers', () => { timeField: 'timestamp', type: 'query', }, + ], + indexPatternId: 'test', + }, + { + layerId: 'test-id', + layerType: 'annotations', + ignoreGlobalFilters: false, + annotations: [ { color: '#0000FF', filter: { @@ -567,6 +596,51 @@ describe('getLayers', () => { }, ], ], + [ + 'annotation layer gets correct dataView when none is defined', + [dataSourceLayersWithStatic, panelWithSingleAnnotationDefaultDataView], + [ + { + layerType: 'referenceLine', + accessors: ['column-id-1'], + layerId: 'test-layer-1', + yConfig: [ + { + forAccessor: 'column-id-1', + axisMode: 'right', + color: '#68BC00', + fill: 'below', + }, + ], + }, + { + layerId: 'test-id', + layerType: 'annotations', + ignoreGlobalFilters: true, + annotations: [ + { + color: '#D33115', + extraFields: ['geo.src'], + filter: { + language: 'lucene', + query: 'tags:error AND tags:security', + type: 'kibana_query', + }, + icon: 'asterisk', + id: 'ann1', + isHidden: true, + key: { + type: 'point_in_time', + }, + label: 'Event', + timeField: 'timestamp', + type: 'query', + }, + ], + indexPatternId: 'default', + }, + ], + ], ])('should return %s', async (_, input, expected) => { const layers = await getLayers(...input, indexPatternsService as DataViewsPublicPluginStart); expect(layers).toEqual(expected.map(expect.objectContaining)); @@ -583,8 +657,14 @@ const mockedIndices = [ ] as unknown as DataView[]; const indexPatternsService = { - getDefault: jest.fn(() => Promise.resolve({ id: 'default', title: 'index' })), - get: jest.fn(() => Promise.resolve(mockedIndices[0])), + getDefault: jest.fn(() => + Promise.resolve({ + id: 'default', + title: 'index', + getFieldByName: (name: string) => ({ aggregatable: name !== 'host' }), + }) + ), + get: jest.fn((id) => Promise.resolve({ ...mockedIndices[0], id })), find: jest.fn((search: string, size: number) => { if (size !== 1) { // shouldn't request more than one data view since there is a significant performance penalty diff --git a/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/layers.ts b/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/layers.ts index 7cc2aea19cbd9..ec0e24e2db873 100644 --- a/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/layers.ts +++ b/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/layers.ts @@ -63,7 +63,7 @@ function getColor( } function nonNullable(value: T): value is NonNullable { - return value !== null && value !== undefined; + return value != null; } export const getLayers = async ( @@ -132,16 +132,22 @@ export const getLayers = async ( return nonAnnotationsLayers; } - const annotationsByIndexPattern = groupBy( - model.annotations, - (a) => typeof a.index_pattern === 'object' && 'id' in a.index_pattern && a.index_pattern.id - ); + const annotationsByIndexPatternAndIgnoreFlag = groupBy(model.annotations, (a) => { + const id = typeof a.index_pattern === 'object' && 'id' in a.index_pattern && a.index_pattern.id; + return `${id}-${Boolean(a.ignore_global_filters)}`; + }); try { const annotationsLayers: Array = await Promise.all( - Object.entries(annotationsByIndexPattern).map(async ([indexPatternId, annotations]) => { + Object.values(annotationsByIndexPatternAndIgnoreFlag).map(async (annotations) => { + const [firstAnnotation] = annotations; + const indexPatternId = + typeof firstAnnotation.index_pattern === 'string' + ? firstAnnotation.index_pattern + : firstAnnotation.index_pattern?.id; const convertedAnnotations: EventAnnotationConfig[] = []; - const { indexPattern } = (await fetchIndexPattern({ id: indexPatternId }, dataViews)) || {}; + const { indexPattern } = + (await fetchIndexPattern(indexPatternId && { id: indexPatternId }, dataViews)) || {}; if (indexPattern) { annotations.forEach((a: Annotation) => { @@ -153,9 +159,9 @@ export const getLayers = async ( return { layerId: v4(), layerType: 'annotations', - ignoreGlobalFilters: true, + ignoreGlobalFilters: Boolean(firstAnnotation.ignore_global_filters), annotations: convertedAnnotations, - indexPatternId, + indexPatternId: indexPattern.id!, }; } }) @@ -173,7 +179,7 @@ const convertAnnotation = ( ): EventAnnotationConfig | undefined => { const extraFields = annotation.fields ?.replace(/\s/g, '') - ?.split(',') + .split(',') .map((field) => { const dataViewField = dataView.getFieldByName(field); return dataViewField && dataViewField.aggregatable ? field : undefined; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/clone_layer_action.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/clone_layer_action.tsx index 26d4c1f04f41a..97d0cf73b80dd 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/clone_layer_action.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/clone_layer_action.tsx @@ -6,8 +6,8 @@ */ import { i18n } from '@kbn/i18n'; -import { Visualization } from '../../../..'; -import { LayerAction } from './types'; +import type { LayerAction } from '../../../../types'; +import type { Visualization } from '../../../..'; interface CloneLayerAction { execute: () => void; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/layer_actions.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/layer_actions.tsx index b9ca695882ef2..bc1c41caa650b 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/layer_actions.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/layer_actions.tsx @@ -5,9 +5,8 @@ * 2.0. */ -import React, { useState, useCallback, useMemo } from 'react'; +import React, { useState, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; -import type { CoreStart } from '@kbn/core/public'; import { EuiButtonIcon, EuiContextMenuPanel, @@ -18,13 +17,28 @@ import { EuiText, EuiOutsideClickDetector, } from '@elastic/eui'; -import type { LayerType, Visualization } from '../../../..'; -import type { LayerAction } from './types'; - +import type { CoreStart } from '@kbn/core/public'; +import type { LayerType } from '../../../..'; +import type { LayerAction, Visualization } from '../../../../types'; import { getCloneLayerAction } from './clone_layer_action'; import { getRemoveLayerAction } from './remove_layer_action'; export interface LayerActionsProps { + layerIndex: number; + actions: LayerAction[]; +} + +/** @internal **/ +export const getSharedActions = ({ + core, + layerIndex, + layerType, + activeVisualization, + isOnlyLayer, + isTextBasedLanguage, + onCloneLayer, + onRemoveLayer, +}: { onRemoveLayer: () => void; onCloneLayer: () => void; layerIndex: number; @@ -33,14 +47,25 @@ export interface LayerActionsProps { layerType?: LayerType; isTextBasedLanguage?: boolean; core: Pick; -} +}) => [ + getCloneLayerAction({ + execute: onCloneLayer, + layerIndex, + activeVisualization, + isTextBasedLanguage, + }), + getRemoveLayerAction({ + execute: onRemoveLayer, + layerIndex, + activeVisualization, + layerType, + isOnlyLayer, + core, + }), +]; /** @internal **/ -const InContextMenuActions = ( - props: LayerActionsProps & { - actions: LayerAction[]; - } -) => { +const InContextMenuActions = (props: LayerActionsProps) => { const dataTestSubject = `lnsLayerSplitButton--${props.layerIndex}`; const [isPopoverOpen, setPopover] = useState(false); const splitButtonPopoverId = useGeneratedHtmlId({ @@ -105,47 +130,24 @@ const InContextMenuActions = ( }; export const LayerActions = (props: LayerActionsProps) => { - const compatibleActions = useMemo( - () => - [ - getCloneLayerAction({ - execute: props.onCloneLayer, - layerIndex: props.layerIndex, - activeVisualization: props.activeVisualization, - isTextBasedLanguage: props.isTextBasedLanguage, - }), - getRemoveLayerAction({ - execute: props.onRemoveLayer, - layerIndex: props.layerIndex, - activeVisualization: props.activeVisualization, - layerType: props.layerType, - isOnlyLayer: props.isOnlyLayer, - core: props.core, - }), - ].filter((i) => i.isCompatible), - [props] - ); - - if (!compatibleActions.length) { + if (!props.actions.length) { return null; } - if (compatibleActions.length > 1) { - return ; - } else { - const [{ displayName, execute, icon, color, 'data-test-subj': dataTestSubj }] = - compatibleActions; - - return ( - - ); + if (props.actions.length > 1) { + return ; } + const [{ displayName, execute, icon, color, 'data-test-subj': dataTestSubj }] = props.actions; + + return ( + + ); }; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/remove_layer_action.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/remove_layer_action.tsx index 32a18d1535697..58a4248b51857 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/remove_layer_action.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/remove_layer_action.tsx @@ -22,10 +22,9 @@ import { import { i18n } from '@kbn/i18n'; import { toMountPoint } from '@kbn/kibana-react-plugin/public'; import { Storage } from '@kbn/kibana-utils-plugin/public'; -import { LayerAction } from './types'; -import { Visualization } from '../../../../types'; +import type { LayerAction, Visualization } from '../../../../types'; import { LOCAL_STORAGE_LENS_KEY } from '../../../../settings_storage'; -import { LayerType, layerTypes } from '../../../..'; +import { type LayerType, layerTypes } from '../../../..'; interface RemoveLayerAction { execute: () => void; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/types.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/types.ts deleted file mode 100644 index 4614874777cc2..0000000000000 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_actions/types.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -import type { IconType, EuiButtonIconColor } from '@elastic/eui'; - -/** @internal **/ -export interface LayerAction { - displayName: string; - execute: () => void | Promise; - icon: IconType; - color?: EuiButtonIconColor; - isCompatible: boolean; - 'data-test-subj'?: string; -} diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index e40281fa1f3ea..3d1068ebd521f 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -43,6 +43,7 @@ import { selectDatasourceStates, } from '../../../state_management'; import { onDropForVisualization } from './buttons/drop_targets_utils'; +import { getSharedActions } from './layer_actions/layer_actions'; const initialActiveDimensionState = { isNew: false, @@ -310,6 +311,39 @@ export function LayerPanel( const [datasource] = Object.values(framePublicAPI.datasourceLayers); const isTextBasedLanguage = Boolean(datasource?.isTextBasedLanguage()); + const compatibleActions = useMemo( + () => + [ + ...(activeVisualization.getSupportedActionsForLayer?.( + layerId, + visualizationState, + updateVisualization + ) || []), + ...getSharedActions({ + activeVisualization, + core, + layerIndex, + layerType: activeVisualization.getLayerType(layerId, visualizationState), + isOnlyLayer, + isTextBasedLanguage, + onCloneLayer, + onRemoveLayer, + }), + ].filter((i) => i.isCompatible), + [ + activeVisualization, + core, + isOnlyLayer, + isTextBasedLanguage, + layerId, + layerIndex, + onCloneLayer, + onRemoveLayer, + updateVisualization, + visualizationState, + ] + ); + return ( <>
@@ -332,16 +366,7 @@ export function LayerPanel( /> - + {(layerDatasource || activeVisualization.renderLayerPanel) && } diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts index 486ddef88ee99..2ccc393a09326 100644 --- a/x-pack/plugins/lens/public/types.ts +++ b/x-pack/plugins/lens/public/types.ts @@ -30,6 +30,7 @@ import type { IndexPatternAggRestrictions } from '@kbn/data-plugin/public'; import type { FieldSpec, DataViewSpec } from '@kbn/data-views-plugin/common'; import type { FieldFormatParams } from '@kbn/field-formats-plugin/common'; import { SearchResponseWarning } from '@kbn/data-plugin/public/search/types'; +import type { EuiButtonIconColor } from '@elastic/eui'; import type { DraggingIdentifier, DragDropIdentifier, DragContextState } from './drag_drop'; import type { DateRange, LayerType, SortingHint } from '../common'; import type { @@ -506,6 +507,17 @@ export interface DatasourceDataPanelProps { usedIndexPatterns?: string[]; } +/** @internal **/ +export interface LayerAction { + displayName: string; + description?: string; + execute: () => void | Promise; + icon: IconType; + color?: EuiButtonIconColor; + isCompatible: boolean; + 'data-test-subj'?: string; +} + interface SharedDimensionProps { /** Visualizations can restrict operations based on their own rules. * For example, limiting to only bucketed or only numeric operations. @@ -962,6 +974,16 @@ export interface Visualization { staticValue?: unknown; }>; }>; + /** + * returns a list of custom actions supported by the visualization layer. + * Default actions like delete/clear are not included in this list and are managed by the editor frame + * */ + getSupportedActionsForLayer?: ( + layerId: string, + state: T, + setState: StateSetter + ) => LayerAction[]; + /** returns the type string of the given layer */ getLayerType: (layerId: string, state?: T) => LayerType | undefined; /* returns the type of removal operation to perform for the specific layer in the current state */ getRemoveOperation?: (state: T, layerId: string) => 'remove' | 'clear'; diff --git a/x-pack/plugins/lens/public/visualizations/xy/annotations/actions.ts b/x-pack/plugins/lens/public/visualizations/xy/annotations/actions.ts new file mode 100644 index 0000000000000..d7d3c9ca8a56a --- /dev/null +++ b/x-pack/plugins/lens/public/visualizations/xy/annotations/actions.ts @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { i18n } from '@kbn/i18n'; +import type { LayerAction, StateSetter } from '../../../types'; +import type { XYState, XYAnnotationLayerConfig } from '../types'; + +export const createAnnotationActions = ({ + state, + layer, + layerIndex, + setState, +}: { + state: XYState; + layer: XYAnnotationLayerConfig; + layerIndex: number; + setState: StateSetter; +}): LayerAction[] => { + const label = !layer.ignoreGlobalFilters + ? i18n.translate('xpack.lens.xyChart.annotations.ignoreGlobalFiltersLabel', { + defaultMessage: 'Ignore global filters', + }) + : i18n.translate('xpack.lens.xyChart.annotations.keepGlobalFiltersLabel', { + defaultMessage: 'Keep global filters', + }); + return [ + { + displayName: label, + description: !layer.ignoreGlobalFilters + ? i18n.translate('xpack.lens.xyChart.annotations.ignoreGlobalFiltersDescription', { + defaultMessage: + 'All the dimensions configured in this layer ignore filters defined at kibana level.', + }) + : i18n.translate('xpack.lens.xyChart.annotations.keepGlobalFiltersDescription', { + defaultMessage: + 'All the dimensions configured in this layer respect filters defined at kibana level.', + }), + execute: () => { + const newLayers = [...state.layers]; + newLayers[layerIndex] = { ...layer, ignoreGlobalFilters: !layer.ignoreGlobalFilters }; + return setState({ ...state, layers: newLayers }); + }, + icon: !layer.ignoreGlobalFilters ? 'eyeClosed' : 'eye', + isCompatible: true, + 'data-test-subj': !layer.ignoreGlobalFilters + ? 'lnsXY_annotationLayer_ignoreFilters' + : 'lnsXY_annotationLayer_keepFilters', + }, + ]; +}; diff --git a/x-pack/plugins/lens/public/visualizations/xy/to_expression.ts b/x-pack/plugins/lens/public/visualizations/xy/to_expression.ts index 345e8ffcb5b19..bf75018f111ee 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/to_expression.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/to_expression.ts @@ -190,7 +190,10 @@ export const buildExpression = ( annotations: layer.annotations.map((c) => ({ ...c, label: uniqueLabels[c.id], - ignoreGlobalFilters: layer.ignoreGlobalFilters, + ...(c.type === 'query' + ? // Move the ignore flag at the event level + { ignoreGlobalFilters: layer.ignoreGlobalFilters } + : {}), })), }; }); 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 c62d2c1195e5f..e76633b349924 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts @@ -2857,4 +2857,81 @@ describe('xy_visualization', () => { }); }); }); + + describe('getSupportedActionsForLayer', () => { + it('should return no actions for a data layer', () => { + expect( + xyVisualization.getSupportedActionsForLayer?.('first', exampleState(), jest.fn()) + ).toHaveLength(0); + }); + + it('should return one action for an annotation layer', () => { + const baseState = exampleState(); + expect( + xyVisualization.getSupportedActionsForLayer?.( + 'annotation', + { + ...baseState, + layers: [ + ...baseState.layers, + { + layerId: 'annotation', + layerType: layerTypes.ANNOTATIONS, + annotations: [exampleAnnotation2], + ignoreGlobalFilters: true, + indexPatternId: 'myIndexPattern', + }, + ], + }, + jest.fn() + ) + ).toEqual([ + expect.objectContaining({ + displayName: 'Keep global filters', + description: + 'All the dimensions configured in this layer respect filters defined at kibana level.', + icon: 'eye', + isCompatible: true, + 'data-test-subj': 'lnsXY_annotationLayer_keepFilters', + }), + ]); + }); + + it('should return an action that performs a state update on click', () => { + const baseState = exampleState(); + const setState = jest.fn(); + const [action] = xyVisualization.getSupportedActionsForLayer?.( + 'annotation', + { + ...baseState, + layers: [ + ...baseState.layers, + { + layerId: 'annotation', + layerType: layerTypes.ANNOTATIONS, + annotations: [exampleAnnotation2], + ignoreGlobalFilters: true, + indexPatternId: 'myIndexPattern', + }, + ], + }, + setState + )!; + action.execute(); + + expect(setState).toHaveBeenCalledWith( + expect.objectContaining({ + layers: expect.arrayContaining([ + { + layerId: 'annotation', + layerType: layerTypes.ANNOTATIONS, + annotations: [exampleAnnotation2], + ignoreGlobalFilters: false, + indexPatternId: 'myIndexPattern', + }, + ]), + }) + ); + }); + }); }); diff --git a/x-pack/plugins/lens/public/visualizations/xy/visualization.tsx b/x-pack/plugins/lens/public/visualizations/xy/visualization.tsx index 6184e3c607a82..417d42abbbf43 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/visualization.tsx @@ -32,13 +32,13 @@ import { DimensionEditor } from './xy_config_panel/dimension_editor'; import { LayerHeader, LayerHeaderContent } from './xy_config_panel/layer_header'; import { Visualization, AccessorConfig, FramePublicAPI } from '../../types'; import { - State, + type State, + type XYLayerConfig, + type XYDataLayerConfig, + type SeriesType, + type XYSuggestion, + type PersistedState, visualizationTypes, - XYLayerConfig, - XYDataLayerConfig, - SeriesType, - XYSuggestion, - PersistedState, } from './types'; import { layerTypes } from '../../../common'; import { @@ -84,12 +84,13 @@ import { validateLayersForDimension, } from './visualization_helpers'; import { groupAxesByType } from './axes_configuration'; -import { XYState } from './types'; +import type { XYState } from './types'; import { ReferenceLinePanel } from './xy_config_panel/reference_line_config_panel'; import { AnnotationsPanel } from './xy_config_panel/annotations_config_panel'; import { DimensionTrigger } from '../../shared_components/dimension_trigger'; import { defaultAnnotationLabel } from './annotations/helpers'; import { onDropForVisualization } from '../../editor_frame_service/editor_frame/config_panel/buttons/drop_targets_utils'; +import { createAnnotationActions } from './annotations/actions'; const XY_ID = 'lnsXY'; export const getXyVisualization = ({ @@ -240,6 +241,16 @@ export const getXyVisualization = ({ ]; }, + getSupportedActionsForLayer(layerId, state, setState) { + const layerIndex = state.layers.findIndex((l) => l.layerId === layerId); + const layer = state.layers[layerIndex]; + const actions = []; + if (isAnnotationsLayer(layer)) { + actions.push(...createAnnotationActions({ state, layerIndex, layer, setState })); + } + return actions; + }, + onIndexPatternChange(state, indexPatternId, layerId) { const layerIndex = state.layers.findIndex((l) => l.layerId === layerId); const layer = state.layers[layerIndex]; diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/annotations_panel.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/annotations_panel.tsx index a6e1cd6b2ac34..480c0773f4520 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/annotations_panel.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/annotations_panel.tsx @@ -352,7 +352,11 @@ export const AnnotationsPanel = ( defaultMessage: 'Color', })} /> - setAnnotations({ isHidden: ev.target.checked })} /> @@ -384,31 +388,25 @@ export const AnnotationsPanel = ( ); }; -const ConfigPanelHideSwitch = ({ +const ConfigPanelGenericSwitch = ({ + label, + ['data-test-subj']: dataTestSubj, value, onChange, }: { + label: string; + 'data-test-subj': string; value: boolean; onChange: (event: EuiSwitchEvent) => void; -}) => { - return ( - - - - ); -}; +}) => ( + + + +); diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/helpers.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/helpers.ts index 2ca0f9530bbe1..89fbdfd38fcf1 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/helpers.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/helpers.ts @@ -97,6 +97,7 @@ export const sanitizeProperties = (annotation: EventAnnotationConfig) => { 'textField', 'filter', 'extraFields', + 'ignoreGlobalFilters', ]); return lineAnnotation; }