Skip to content

Commit

Permalink
Merge branch '8.14' into backport/8.14/pr-187303
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 9, 2024
2 parents e8987ff + 465f500 commit bf78c95
Show file tree
Hide file tree
Showing 18 changed files with 320 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
spec:
env:
SLACK_NOTIFICATIONS_CHANNEL: '#kibana-operations-alerts'
GITHUB_BUILD_COMMIT_STATUS_ENABLED: 'true'
ELASTIC_GITHUB_BUILD_COMMIT_STATUS_ENABLED: 'true'
GITHUB_COMMIT_STATUS_CONTEXT: buildkite/on-merge
REPORT_FAILED_TESTS_TO_GITHUB: 'true'
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/pipeline-resource-definitions/kibana-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ spec:
spec:
env:
ELASTIC_PR_COMMENTS_ENABLED: 'true'
GITHUB_BUILD_COMMIT_STATUS_ENABLED: 'true'
ELASTIC_GITHUB_BUILD_COMMIT_STATUS_ENABLED: 'true'
ELASTIC_GITHUB_STEP_COMMIT_STATUS_ENABLED: 'true'
GITHUB_BUILD_COMMIT_STATUS_CONTEXT: kibana-ci
GITHUB_STEP_COMMIT_STATUS_ENABLED: 'true'
allow_rebuilds: true
branch_configuration: ''
cancel_intermediate_builds: true
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/lifecycle/post_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
BUILD_SUCCESSFUL=$(ts-node "$(dirname "${0}")/build_status.ts")
export BUILD_SUCCESSFUL

if [[ "${GITHUB_BUILD_COMMIT_STATUS_ENABLED:-}" != "true" ]]; then
if [[ "${ELASTIC_GITHUB_BUILD_COMMIT_STATUS_ENABLED:-}" != "true" ]]; then
"$(dirname "${0}")/commit_status_complete.sh"
fi

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/lifecycle/pre_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

source .buildkite/scripts/common/util.sh

if [[ "${GITHUB_BUILD_COMMIT_STATUS_ENABLED:-}" != "true" ]]; then
if [[ "${ELASTIC_GITHUB_BUILD_COMMIT_STATUS_ENABLED:-}" != "true" ]]; then
"$(dirname "${0}")/commit_status_start.sh"
fi

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dashboarding"
],
"private": true,
"version": "8.14.2",
"version": "8.14.3",
"branch": "8.14",
"types": "./kibana.d.ts",
"tsdocMetadata": "./build/tsdoc-metadata.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import { Position } from '@elastic/charts';
import type { PaletteOutput } from '@kbn/coloring';
import { Datatable, DatatableRow } from '@kbn/expressions-plugin/common';
import { LayerTypes } from '../constants';
import { DataLayerConfig, ExtendedDataLayerConfig, XYProps } from '../types';
import {
AnnotationLayerConfig,
CommonXYLayerConfig,
DataLayerConfig,
ExtendedDataLayerConfig,
ReferenceLineLayerConfig,
XYProps,
} from '../types';

export const mockPaletteOutput: PaletteOutput = {
type: 'palette',
Expand Down Expand Up @@ -46,6 +53,36 @@ export const createSampleDatatableWithRows = (rows: DatatableRow[]): Datatable =
rows,
});

export const sampleAnnotationLayer: AnnotationLayerConfig = {
layerId: 'first',
type: 'annotationLayer',
layerType: LayerTypes.ANNOTATIONS,
annotations: [
{
type: 'manual_point_event_annotation',
id: 'ann1',
time: '2021-01-01T00:00:00.000Z',
label: 'Manual annotation point',
},
{
type: 'query_point_event_annotation',
id: 'ann2',
filter: { type: 'kibana_query', language: 'kql', query: 'a: *' },
label: 'Query annotation point',
},
],
};

export const sampleReferenceLineLayer: ReferenceLineLayerConfig = {
layerId: 'first',
type: 'referenceLineLayer',
layerType: LayerTypes.REFERENCELINE,
accessors: ['b', 'c'],
columnToLabel: '{"b": "Label B", "c": "Label C"}',
decorations: [],
table: createSampleDatatableWithRows([]),
};

export const sampleLayer: DataLayerConfig = {
layerId: 'first',
type: 'dataLayer',
Expand Down Expand Up @@ -84,7 +121,7 @@ export const sampleExtendedLayer: ExtendedDataLayerConfig = {
};

export const createArgsWithLayers = (
layers: DataLayerConfig | DataLayerConfig[] = sampleLayer
layers: CommonXYLayerConfig | CommonXYLayerConfig[] = sampleLayer
): XYProps => ({
showTooltip: true,
minBarHeight: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
* 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 { CommonXYLayerConfig, LayerTypes } from '../../common';
import { AnnotationLayerConfig, DataLayerConfig, XYProps } from '../../common/types';
import {
createArgsWithLayers,
sampleAnnotationLayer,
sampleLayer,
sampleReferenceLineLayer,
} from '../../common/__mocks__';
import { getDataLayers } from '../helpers';
import { extractCounterEvents } from './xy_chart_renderer';

type PossibleLayerTypes =
| typeof LayerTypes.DATA
| typeof LayerTypes.ANNOTATIONS
| typeof LayerTypes.REFERENCELINE;

function createLayer(type: PossibleLayerTypes) {
switch (type) {
case LayerTypes.ANNOTATIONS: {
return { ...sampleAnnotationLayer };
}
case LayerTypes.REFERENCELINE: {
return { ...sampleReferenceLineLayer };
}
case LayerTypes.DATA:
default: {
return { ...sampleLayer };
}
}
}
function createLayers(
layerConfigs: Partial<Record<CommonXYLayerConfig['layerType'], { count: number }>>
): CommonXYLayerConfig[] {
const layers = [];
for (const [type, { count }] of Object.entries(layerConfigs)) {
layers.push(
...Array.from({ length: count }, () => createLayer(type as CommonXYLayerConfig['layerType']))
);
}
return layers;
}

function createAnnotations(count: number) {
return Array.from({ length: count }, () => createLayer('annotations') as AnnotationLayerConfig);
}

function getXYProps(
layersConfig: CommonXYLayerConfig[],
annotations?: AnnotationLayerConfig[]
): XYProps {
const args = createArgsWithLayers(layersConfig);
if (annotations?.length) {
if (!args.annotations) {
args.annotations = {
type: 'event_annotations_result',
layers: [],
datatable: {
type: 'datatable',
columns: [],
rows: [],
},
};
}
args.annotations!.layers = annotations;
}
return args;
}

describe('should emit the right telemetry events', () => {
it('should emit the telemetry event for a single data layer', () => {
expect(
extractCounterEvents('lens', getXYProps(createLayers({ data: { count: 1 } })), false, {
getDataLayers,
})
).toMatchInlineSnapshot(`
Array [
"render_lens_line",
]
`);
});

it('should emit the telemetry event for multiple data layers', () => {
expect(
extractCounterEvents('lens', getXYProps(createLayers({ data: { count: 2 } })), false, {
getDataLayers,
})
).toMatchInlineSnapshot(`
Array [
"render_lens_line",
"render_lens_multiple_data_layers",
]
`);
});

it('should emit the telemetry event for multiple data layers with mixed types', () => {
const layers = createLayers({ data: { count: 2 } });
// change layer 2 to be bar stacked
(layers[1] as DataLayerConfig).seriesType = 'bar';
(layers[1] as DataLayerConfig).isStacked = true;
expect(
extractCounterEvents('lens', getXYProps(layers), false, {
getDataLayers,
})
).toMatchInlineSnapshot(`
Array [
"render_lens_line",
"render_lens_multiple_data_layers",
"render_lens_mixed_xy",
]
`);
});

it('should emit the telemetry dedicated event for percentage charts', () => {
const layers = createLayers({ data: { count: 1 } });
// change layer 2 to be bar stacked
(layers[0] as DataLayerConfig).seriesType = 'bar';
(layers[0] as DataLayerConfig).isPercentage = true;
(layers[0] as DataLayerConfig).isStacked = true;
expect(
extractCounterEvents('lens', getXYProps(layers), false, {
getDataLayers,
})
).toMatchInlineSnapshot(`
Array [
"render_lens_vertical_bar_percentage_stacked",
]
`);
});

it('should emit the telemetry event for a data layer and an additonal reference line layer', () => {
expect(
extractCounterEvents(
'lens',
getXYProps(createLayers({ data: { count: 1 }, referenceLine: { count: 1 } })),
false,
{ getDataLayers }
)
).toMatchInlineSnapshot(`
Array [
"render_lens_line",
"render_lens_reference_layer",
]
`);
});

it('should emit the telemetry event for a data layer and an additional annotations layer', () => {
expect(
extractCounterEvents(
'lens',
getXYProps(createLayers({ data: { count: 1 } }), createAnnotations(1)),
false,
{ getDataLayers }
)
).toMatchInlineSnapshot(`
Array [
"render_lens_line",
"render_lens_annotation_layer",
]
`);
});

it('should emit the telemetry event for a scenario with the navigate to lens feature', () => {
expect(
extractCounterEvents(
'lens',
getXYProps(
createLayers({ data: { count: 1 }, referenceLine: { count: 1 } }),
createAnnotations(1)
),
true,
{ getDataLayers }
)
).toMatchInlineSnapshot(`
Array [
"render_lens_line",
"render_lens_reference_layer",
"render_lens_annotation_layer",
"render_lens_render_line_convertable",
]
`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ interface XyChartRendererDeps {
getStartDeps: GetStartDepsFn;
}

const extractCounterEvents = (
export const extractCounterEvents = (
originatingApp: string,
{ layers, yAxisConfigs }: XYChartProps['args'],
{ annotations, layers, yAxisConfigs }: XYChartProps['args'],
canNavigateToLens: boolean,
services: {
getDataLayers: typeof getDataLayers;
Expand All @@ -78,7 +78,7 @@ const extractCounterEvents = (
? `${dataLayer.isHorizontal ? 'horizontal_bar' : 'vertical_bar'}`
: dataLayer.seriesType;

const byTypes = layers.reduce(
const byTypes = layers.concat(annotations?.layers || []).reduce(
(acc, item) => {
if (
!acc.mixedXY &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,11 @@ test('creates new embeddable with specified size if size is provided', async ()
expect(dashboard!.getState().explicitInput.panels.new_panel.gridData.h).toBe(1);
});

test('creates a control group from the control group factory and waits for it to be initialized', async () => {
test('creates a control group from the control group factory', async () => {
const mockControlGroupContainer = {
destroy: jest.fn(),
render: jest.fn(),
updateInput: jest.fn(),
untilInitialized: jest.fn(),
getInput: jest.fn().mockReturnValue({}),
getInput$: jest.fn().mockReturnValue(new Observable()),
getOutput: jest.fn().mockReturnValue({}),
Expand Down Expand Up @@ -455,7 +454,6 @@ test('creates a control group from the control group factory and waits for it to
undefined,
{ lastSavedInput: expect.objectContaining({ controlStyle: 'oneLine' }) }
);
expect(mockControlGroupContainer.untilInitialized).toHaveBeenCalled();
});

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ export const initializeDashboard = async ({
dashboardContainer.controlGroup = controlGroup;
startSyncingDashboardControlGroup.bind(dashboardContainer)();
});
await controlGroup.untilInitialized();
}

// --------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "x-pack",
"version": "8.14.2",
"version": "8.14.3",
"author": "Elastic",
"private": true,
"license": "Elastic-License",
Expand Down
Loading

0 comments on commit bf78c95

Please sign in to comment.