Skip to content

Commit

Permalink
Merge branch 'main' into fix-grep-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsonpl authored Sep 12, 2023
2 parents 70016a2 + bfa334c commit a66b0c0
Show file tree
Hide file tree
Showing 68 changed files with 1,039 additions and 243 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ disabled:
- x-pack/test_serverless/functional/test_suites/search/config.ts
- x-pack/test_serverless/functional/test_suites/search/config.feature_flags.ts
- x-pack/test_serverless/functional/test_suites/search/config.examples.ts
- x-pack/test_serverless/functional/test_suites/search/config.screenshots.ts
- x-pack/test_serverless/functional/test_suites/security/config.ts
- x-pack/test_serverless/functional/test_suites/security/config.feature_flags.ts
- x-pack/test_serverless/functional/test_suites/security/config.examples.ts
Expand Down
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/plugins/security_solution/server/lists_integration/endpoint/ @elastic/security-defend-workflows
/x-pack/plugins/security_solution/server/lib/license/ @elastic/security-defend-workflows
/x-pack/plugins/security_solution/server/fleet_integration/ @elastic/security-defend-workflows
/x-pack/plugins/security_solution/scripts/endpoint/event_filters/ @elastic/security-defend-workflows
/x-pack/plugins/security_solution/scripts/endpoint/trusted_apps/ @elastic/security-defend-workflows
/x-pack/plugins/security_solution/scripts/endpoint/ @elastic/security-defend-workflows
/x-pack/test/security_solution_endpoint/ @elastic/security-defend-workflows
/x-pack/test/security_solution_endpoint_api_int/ @elastic/security-defend-workflows
/x-pack/test_serverless/shared/lib/security/kibana_roles/ @elastic/security-defend-workflows
Expand Down
2 changes: 1 addition & 1 deletion dev_docs/contributing/code_walkthrough.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ This code primarily belongs to the Core team and contains the plugin infrastruct

### [src/dev](https://github.com/elastic/kibana/tree/main/src/dev)

Maintained by the Operations team, this code contains build and development tooling related code. This folder existed before `packages`, so contains mostly older code that hasn't been migrated to packages. Prefer creating a `package` if possible. Can be ignored for the most part if you are not on the Ops team. Prefer
Maintained by the Operations team, this code contains build and development tooling related code. This folder existed before `packages`, so contains mostly older code that hasn't been migrated to packages. Prefer creating a `package` if possible. Can be ignored for the most part if you are not on the Ops team.

### [src/plugins](https://github.com/elastic/kibana/tree/main/src/plugins)

Expand Down
11 changes: 6 additions & 5 deletions dev_docs/contributing/standards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ Every public API should have a release tag specified at the top of it’s docume
#### Release tags

| Type | Description | Documentation | Asciidoc Tag |
| Undocumented | Every public API should be documented, but if it isn’t, we make no guarantees about it. These need to be eliminated and should become internal or documented. |
| Experimental | A public API that may break or be removed at any time. | experimental[] |
| Beta | A public API that we make a best effort not to break or remove. However, there are no guarantees. | beta[] |
| Stable | No breaking changes outside of a Major\* | stable[] |
| Deprecated | Do not use, will be removed. | deprecated[] |
| -----| ------------| ------------- | ------------ |
| Undocumented | Every public API should be documented, but if it isn’t, we make no guarantees about it. These need to be eliminated and should become internal or documented. | | |
| Experimental | A public API that may break or be removed at any time. | experimental[] | |
| Beta | A public API that we make a best effort not to break or remove. However, there are no guarantees. | beta[] | |
| Stable | No breaking changes outside of a Major\* | stable[] | |
| Deprecated | Do not use, will be removed. | deprecated[] | |

\*This is likely to change with Make it Minor as we move towards a calendar based rolling deprecation and removal policy.

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-unified-data-table/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ROWS_PER_PAGE_OPTIONS = [10, 25, 50, DEFAULT_ROWS_PER_PAGE, 250, 50
export const ROWS_HEIGHT_OPTIONS = {
auto: -1,
single: 0,
default: 3,
default: -1,
};

export const defaultMonacoEditorWidth = 370;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { Storage } from '@kbn/kibana-utils-plugin/public';
import { LocalStorageMock } from '../../__mocks__/local_storage_mock';
import { useRowHeightsOptions } from './use_row_heights_options';

const CONFIG_ROW_HEIGHT = 3;

describe('useRowHeightsOptions', () => {
test('should apply rowHeight from savedSearch', () => {
const { result } = renderHook(() => {
Expand All @@ -32,7 +30,7 @@ describe('useRowHeightsOptions', () => {
storage: new LocalStorageMock({
['discover:dataGridRowHeight']: {
previousRowHeight: 5,
previousConfigRowHeight: 3,
previousConfigRowHeight: -1,
},
}) as unknown as Storage,
consumer: 'discover',
Expand All @@ -52,7 +50,7 @@ describe('useRowHeightsOptions', () => {
});

expect(result.current.defaultHeight).toEqual({
lineCount: CONFIG_ROW_HEIGHT,
lineCount: 3,
});
});

Expand All @@ -61,17 +59,15 @@ describe('useRowHeightsOptions', () => {
return useRowHeightsOptions({
storage: new LocalStorageMock({
['discover:dataGridRowHeight']: {
previousRowHeight: 4,
// different from uiSettings (config), now user changed it to 3, but prev was 4
previousRowHeight: 5,
// different from uiSettings (config), now user changed it to -1, but prev was 4
previousConfigRowHeight: 4,
},
}) as unknown as Storage,
consumer: 'discover',
});
});

expect(result.current.defaultHeight).toEqual({
lineCount: CONFIG_ROW_HEIGHT,
});
expect(result.current.defaultHeight).toEqual('auto');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface UseRowHeightProps {
* Converts rowHeight of EuiDataGrid to rowHeight number (-1 to 20)
*/
const serializeRowHeight = (rowHeight?: EuiDataGridRowHeightOption): number => {
if (rowHeight === 'auto') {
if (rowHeight === 'auto' || rowHeight === ROWS_HEIGHT_OPTIONS.auto) {
return ROWS_HEIGHT_OPTIONS.auto;
} else if (typeof rowHeight === 'object' && rowHeight.lineCount) {
return rowHeight.lineCount; // custom
Expand Down Expand Up @@ -75,11 +75,16 @@ export const useRowHeightsOptions = ({
rowHeight = configRowHeight;
}

const defaultHeight = deserializeRowHeight(rowHeight);

return {
defaultHeight: deserializeRowHeight(rowHeight),
defaultHeight,
lineHeight: '1.6em',
onChange: ({ defaultHeight: newRowHeight }: EuiDataGridRowHeightsOptions) => {
const newSerializedRowHeight = serializeRowHeight(newRowHeight);
const newSerializedRowHeight = serializeRowHeight(
// pressing "Reset to default" triggers onChange with the same value
newRowHeight === defaultHeight ? configRowHeight : newRowHeight
);
updateStoredRowHeight(newSerializedRowHeight, configRowHeight, storage, consumer);
onUpdateRowHeight?.(newSerializedRowHeight);
},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const getUiSettings: (docLinks: DocLinksServiceSetup) => Record<string, U
name: i18n.translate('discover.advancedSettings.params.rowHeightTitle', {
defaultMessage: 'Row height in the Document Explorer',
}),
value: 3,
value: -1,
category: ['discover'],
description: i18n.translate('discover.advancedSettings.params.rowHeightText', {
defaultMessage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function PercentilesEditor({
id={`visEditorPercentileLabel${agg.id}`}
isInvalid={showValidation ? !isValid : false}
display="rowCompressed"
data-test-subj="visEditorPercentile"
>
<NumberList
labelledbyId={`visEditorPercentileLabel${agg.id}-legend`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ const mockGetFieldByName = jest.fn();
const mockGetLabel = jest.fn();
const mockGetLabelForPercentile = jest.fn();

jest.mock('../utils', () => ({
getFieldNameFromField: jest.fn(() => mockGetFieldNameFromField()),
getLabel: jest.fn(() => mockGetLabel()),
getLabelForPercentile: jest.fn(() => mockGetLabelForPercentile()),
}));
jest.mock('../utils', () => {
const utils = jest.requireActual('../utils');
return {
...utils,
getFieldNameFromField: jest.fn(() => mockGetFieldNameFromField()),
getLabel: jest.fn(() => mockGetLabel()),
getLabelForPercentile: jest.fn(() => mockGetLabelForPercentile()),
};
});

describe('convertToPercentileColumn', () => {
const visType = 'heatmap';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { METRIC_TYPES } from '@kbn/data-plugin/common';
import { SchemaConfig } from '../../..';
import { isFieldValid, PercentileParams } from '../..';
import { getFieldNameFromField, getLabelForPercentile } from '../utils';
import { getAggIdAndValue, getFieldNameFromField, getLabelForPercentile } from '../utils';
import { createColumn, getFormat } from './column';
import { PercentileColumn, CommonColumnConverterArgs } from './types';
import { SUPPORTED_METRICS } from './supported_metrics';
Expand Down Expand Up @@ -40,7 +40,7 @@ const getPercent = (

const { percents } = aggParams;

const [, percentStr] = aggId.split('.');
const [, percentStr] = getAggIdAndValue(aggId);

const percent = Number(percentStr);
if (!percents || !percents.length || percentStr === '' || isNaN(percent)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ const mockIsStdDevAgg = jest.fn();
const mockGetFieldByName = jest.fn();
const originalGetFieldByName = stubLogstashDataView.getFieldByName;

jest.mock('../utils', () => ({
getFieldNameFromField: jest.fn((field) => field),
getMetricFromParentPipelineAgg: jest.fn(() => mockGetMetricFromParentPipelineAgg()),
isPercentileAgg: jest.fn(() => mockIsPercentileAgg()),
isPercentileRankAgg: jest.fn(() => mockIsPercentileRankAgg()),
isPipeline: jest.fn(() => mockIsPipeline()),
isStdDevAgg: jest.fn(() => mockIsStdDevAgg()),
}));
jest.mock('../utils', () => {
const utils = jest.requireActual('../utils');
return {
...utils,
getFieldNameFromField: jest.fn((field) => field),
getMetricFromParentPipelineAgg: jest.fn(() => mockGetMetricFromParentPipelineAgg()),
isPercentileAgg: jest.fn(() => mockIsPercentileAgg()),
isPercentileRankAgg: jest.fn(() => mockIsPercentileRankAgg()),
isPipeline: jest.fn(() => mockIsPipeline()),
isStdDevAgg: jest.fn(() => mockIsStdDevAgg()),
};
});

const dataView = stubLogstashDataView;
const visType = 'heatmap';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Operations } from '../../constants';
import { isMetricWithField, getStdDeviationFormula, ExtendedColumnConverterArgs } from '../convert';
import { getFormulaFromMetric, SUPPORTED_METRICS } from '../convert/supported_metrics';
import {
getAggIdAndValue,
getFieldNameFromField,
getMetricFromParentPipelineAgg,
isPercentileAgg,
Expand Down Expand Up @@ -125,7 +126,7 @@ const getFormulaForPercentile = (
selector: string,
reducedTimeRange?: string
) => {
const percentile = Number(agg.aggId?.split('.')[1]);
const percentile = Number(getAggIdAndValue(agg.aggId)[1]);
const op = SUPPORTED_METRICS[agg.aggType];
if (!isValidAgg(visType, agg, dataView) || !op) {
return null;
Expand Down
14 changes: 14 additions & 0 deletions src/plugins/visualizations/common/convert_to_lens/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,17 @@ export const getMetricFromParentPipelineAgg = (

return metric as SchemaConfig<METRIC_TYPES>;
};

const aggIdWithDecimalsRegexp = /^(\w)+\['([0-9]+\.[0-9]+)'\]$/;

export const getAggIdAndValue = (aggId?: string) => {
if (!aggId) {
return [];
}
// agg value contains decimals
if (/\['/.test(aggId)) {
const [_, id, value] = aggId.match(aggIdWithDecimalsRegexp) || [];
return [id, value];
}
return aggId.split('.');
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ jest.mock('../../common/convert_to_lens/lib/buckets', () => ({
convertBucketToColumns: jest.fn(() => mockConvertBucketToColumns()),
}));

jest.mock('../../common/convert_to_lens/lib/utils', () => ({
getCustomBucketsFromSiblingAggs: jest.fn(() => mockGetCutomBucketsFromSiblingAggs()),
}));
jest.mock('../../common/convert_to_lens/lib/utils', () => {
const utils = jest.requireActual('../../common/convert_to_lens/lib/utils');
return {
...utils,
getCustomBucketsFromSiblingAggs: jest.fn(() => mockGetCutomBucketsFromSiblingAggs()),
};
});

jest.mock('../vis_schemas', () => ({
getVisSchemas: jest.fn(() => mockGetVisSchemas()),
Expand Down
10 changes: 7 additions & 3 deletions src/plugins/visualizations/public/convert_to_lens/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import type { DataView } from '@kbn/data-views-plugin/common';
import { IAggConfig, METRIC_TYPES, TimefilterContract } from '@kbn/data-plugin/public';
import { AggBasedColumn, PercentageModeConfig, SchemaConfig } from '../../common';
import { convertMetricToColumns } from '../../common/convert_to_lens/lib/metrics';
import { getCustomBucketsFromSiblingAggs } from '../../common/convert_to_lens/lib/utils';
import {
getAggIdAndValue,
getCustomBucketsFromSiblingAggs,
} from '../../common/convert_to_lens/lib/utils';
import { BucketColumn } from '../../common/convert_to_lens/lib';
import type { Vis } from '../types';
import { getVisSchemas, Schemas } from '../vis_schemas';
Expand Down Expand Up @@ -178,11 +181,12 @@ export const getColumnsFromVis = <T>(

if (series && series.length) {
for (const { metrics: metricAggIds } of series) {
const metricAggIdsLookup = new Set(metricAggIds);
const metrics = aggs.filter(
(agg) => agg.aggId && metricAggIds.includes(agg.aggId.split('.')[0])
(agg) => agg.aggId && metricAggIdsLookup.has(getAggIdAndValue(agg.aggId)[0])
);
const customBucketsForLayer = customBucketsWithMetricIds.filter((c) =>
c.metricIds.some((m) => metricAggIds.includes(m))
c.metricIds.some((m) => metricAggIdsLookup.has(m))
);
const layer = createLayer(
vis.type.name,
Expand Down
4 changes: 1 addition & 3 deletions test/functional/apps/discover/classic/_doc_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const defaultSettings = {
defaultIndex: 'logstash-*',
hideAnnouncements: true,
'doc_table:legacy': true,
};
const testSubjects = getService('testSubjects');

Expand Down Expand Up @@ -75,7 +76,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('classic table in window 900x700', async function () {
before(async () => {
await kibanaServer.uiSettings.update({ 'doc_table:legacy': true });
await browser.setWindowSize(900, 700);
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.waitUntilSearchingHasFinished();
Expand All @@ -95,7 +95,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('classic table in window 600x700', async function () {
before(async () => {
await kibanaServer.uiSettings.update({ 'doc_table:legacy': true });
await browser.setWindowSize(600, 700);
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.waitUntilSearchingHasFinished();
Expand All @@ -115,7 +114,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('legacy', async function () {
before(async () => {
await kibanaServer.uiSettings.update({ 'doc_table:legacy': true });
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.waitUntilSearchingHasFinished();
});
Expand Down
5 changes: 4 additions & 1 deletion test/functional/apps/discover/group2/_data_grid_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'header',
'unifiedFieldList',
]);
const defaultSettings = { defaultIndex: 'logstash-*' };
const defaultSettings = {
defaultIndex: 'logstash-*',
'discover:rowHeightOption': 0, // single line
};
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
const dashboardAddPanel = getService('dashboardAddPanel');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
]);
const defaultSettings = {
defaultIndex: 'logstash-*',
'discover:rowHeightOption': 0, // single line
};
const testSubjects = getService('testSubjects');
const security = getService('security');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const dataGrid = getService('dataGrid');
const PageObjects = getPageObjects(['settings', 'common', 'discover', 'header', 'timePicker']);
const defaultSettings = { defaultIndex: 'logstash-*' };
const defaultSettings = {
defaultIndex: 'logstash-*',
'discover:rowHeightOption': 0, // single line
};
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const security = getService('security');
Expand Down
Loading

0 comments on commit a66b0c0

Please sign in to comment.