Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into chrome-service/expo…
Browse files Browse the repository at this point in the history
…rt-handler-toggle-sidenav
  • Loading branch information
sebelga committed Sep 17, 2024
2 parents e9c4926 + ac07c21 commit 2e085ee
Show file tree
Hide file tree
Showing 474 changed files with 9,207 additions and 19,312 deletions.
3 changes: 1 addition & 2 deletions .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ enabled:
- test/api_integration/config.js
- test/examples/config.js
- test/functional/apps/bundles/config.ts
- test/functional/apps/console/monaco/config.ts
- test/functional/apps/console/ace/config.ts
- test/functional/apps/console/config.ts
- test/functional/apps/context/config.ts
- test/functional/apps/dashboard_elements/controls/common/config.ts
- test/functional/apps/dashboard_elements/controls/options_list/config.ts
Expand Down
1 change: 0 additions & 1 deletion .buildkite/scripts/steps/storybooks/build_and_upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const STORYBOOKS = [
'coloring',
'chart_icons',
'content_management_examples',
'controls',
'custom_integrations',
'dashboard_enhanced',
'dashboard',
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ x-pack/plugins/security_solution/server/lib/security_integrations @elastic/secur
/x-pack/plugins/monitoring/**/*.scss @elastic/observability-design

# Ent. Search design
/x-pack/plugins/enterprise_search/**/*.scss @elastic/ent-search-design
/x-pack/plugins/enterprise_search/**/*.scss @elastic/search-design

# Security design
/x-pack/plugins/endpoint/**/*.scss @elastic/security-design
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,32 @@

import { pickBy } from 'lodash';
import React, { useEffect, useState } from 'react';

import {
EuiButton,
EuiButtonEmpty,
EuiButtonGroup,
EuiFlexGroup,
EuiFlexItem,
EuiPanel,
EuiSkeletonRectangle,
EuiSpacer,
EuiText,
EuiTitle,
EuiSkeletonRectangle,
} from '@elastic/eui';
import { ViewMode } from '@kbn/embeddable-plugin/public';
import { OPTIONS_LIST_CONTROL, RANGE_SLIDER_CONTROL } from '@kbn/controls-plugin/common';
import { ControlGroupRuntimeState, ControlStateTransform } from '@kbn/controls-plugin/public';
import {
OPTIONS_LIST_CONTROL,
RANGE_SLIDER_CONTROL,
type ControlGroupRuntimeState,
} from '@kbn/controls-plugin/common';
import {
ACTION_DELETE_CONTROL,
ACTION_EDIT_CONTROL,
ControlGroupRenderer,
ControlGroupRendererApi,
type ControlStateTransform,
} from '@kbn/controls-plugin/public';
import { ControlGroupRendererApi } from '@kbn/controls-plugin/public';
import { ViewMode } from '@kbn/embeddable-plugin/public';

const INPUT_KEY = 'kbnControls:saveExample:input';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
*/

import React, { useEffect, useState } from 'react';
import { v4 as uuidv4 } from 'uuid';
import { lastValueFrom } from 'rxjs';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import { v4 as uuidv4 } from 'uuid';

import {
EuiCallOut,
EuiLoadingSpinner,
Expand All @@ -23,6 +20,11 @@ import {
EuiTitle,
} from '@elastic/eui';
import { ControlGroupRenderer, ControlGroupRendererApi } from '@kbn/controls-plugin/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import type { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public';

import { PLUGIN_ID } from '../../constants';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { ControlGroupRuntimeState } from '@kbn/controls-plugin/public';
import { ControlGroupRuntimeState } from '@kbn/controls-plugin/common';

const RUNTIME_STATE_SESSION_STORAGE_KEY =
'kibana.examples.controls.reactControlExample.controlGroupRuntimeState';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { SerializedPanelState } from '@kbn/presentation-containers';
import { ControlGroupSerializedState } from '@kbn/controls-plugin/public';
import type { SerializedPanelState } from '@kbn/presentation-containers';
import type { ControlGroupSerializedState } from '@kbn/controls-plugin/common';
import {
OPTIONS_LIST_CONTROL,
RANGE_SLIDER_CONTROL,
Expand Down
6 changes: 3 additions & 3 deletions examples/discover_customization_examples/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import ReactDOM from 'react-dom';
import useObservable from 'react-use/lib/useObservable';
import { ControlGroupRendererApi, ControlGroupRenderer } from '@kbn/controls-plugin/public';
import { css } from '@emotion/react';
import type { ControlsPanels } from '@kbn/controls-plugin/common';
import type { ControlPanelsState } from '@kbn/controls-plugin/common';
import { Route, Router, Routes } from '@kbn/shared-ux-router';
import { I18nProvider } from '@kbn/i18n-react';
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
Expand Down Expand Up @@ -357,7 +357,7 @@ export class DiscoverCustomizationExamplesPlugin implements Plugin {
}

const stateSubscription = stateStorage
.change$<ControlsPanels>('controlPanels')
.change$<ControlPanelsState>('controlPanels')
.subscribe((panels) =>
controlGroupAPI.updateInput({ initialChildControlState: panels ?? undefined })
);
Expand Down Expand Up @@ -410,7 +410,7 @@ export class DiscoverCustomizationExamplesPlugin implements Plugin {
<ControlGroupRenderer
onApiAvailable={setControlGroupAPI}
getCreationOptions={async (initialState, builder) => {
const panels = stateStorage.get<ControlsPanels>('controlPanels');
const panels = stateStorage.get<ControlPanelsState>('controlPanels');

if (!panels) {
builder.addOptionsListControl(initialState, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
export const query1 = `
from kibana_sample_data_logs
| EVAL timestamp=DATE_TRUNC(3 hour, @timestamp), status = CASE( to_integer(response.keyword) >= 200 and to_integer(response.keyword) < 400, "HTTP 2xx and 3xx", to_integer(response.keyword) >= 400 and to_integer(response.keyword) < 500, "HTTP 4xx", "HTTP 5xx")
| stats results = count(*) by \`Over time\` = BUCKET(timestamp, 50, ?t_start, ?t_end), status
| stats results = count(*) by \`Over time\` = BUCKET(timestamp, 50, ?_tstart, ?_tend), status
`;

export const query2 = `
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-esql-ast/src/walker/walker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ describe('Walker.params()', () => {

test('can collect all params from grouping functions', () => {
const query =
'ROW x=1, time=2024-07-10 | stats z = avg(x) by bucket(time, 20, ?t_start,?t_end)';
'ROW x=1, time=2024-07-10 | stats z = avg(x) by bucket(time, 20, ?_tstart,?_tend)';
const { ast } = getAstAndSyntaxErrors(query);
const params = Walker.params(ast);

Expand All @@ -802,13 +802,13 @@ describe('Walker.params()', () => {
type: 'literal',
literalType: 'param',
paramType: 'named',
value: 't_start',
value: '_tstart',
},
{
type: 'literal',
literalType: 'param',
paramType: 'named',
value: 't_end',
value: '_tend',
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('getInitialESQLQuery', () => {
] as DataView['fields'];
const dataView = getDataView('logs*', fields, '@custom_timestamp');
expect(getInitialESQLQuery(dataView)).toBe(
'FROM logs* | WHERE @custom_timestamp >= ?t_start AND @custom_timestamp <= ?t_end | LIMIT 10'
'FROM logs* | WHERE @custom_timestamp >= ?_tstart AND @custom_timestamp <= ?_tend | LIMIT 10'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getInitialESQLQuery(dataView: DataView): string {
const timeFieldName = dataView?.timeFieldName;
const filterByTimeParams =
!hasAtTimestampField && timeFieldName
? ` | WHERE ${timeFieldName} >= ?t_start AND ${timeFieldName} <= ?t_end`
? ` | WHERE ${timeFieldName} >= ?_tstart AND ${timeFieldName} <= ?_tend`
: '';
return `FROM ${dataView.getIndexPattern()}${filterByTimeParams} | LIMIT 10`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,27 @@ describe('esql query helpers', () => {
});

it('should return the time field if there is at least one time param', () => {
expect(getTimeFieldFromESQLQuery('from a | eval b = 1 | where time >= ?t_start')).toBe(
expect(getTimeFieldFromESQLQuery('from a | eval b = 1 | where time >= ?_tstart')).toBe(
'time'
);
});

it('should return undefined if there is one named param but is not ?t_start or ?t_end', () => {
it('should return undefined if there is one named param but is not ?_tstart or ?_tend', () => {
expect(
getTimeFieldFromESQLQuery('from a | eval b = 1 | where time >= ?late')
).toBeUndefined();
});

it('should return undefined if there is one named param but is used without a time field', () => {
expect(
getTimeFieldFromESQLQuery('from a | eval b = DATE_TRUNC(1 day, ?t_start)')
getTimeFieldFromESQLQuery('from a | eval b = DATE_TRUNC(1 day, ?_tstart)')
).toBeUndefined();
});

it('should return the time field if there is at least one time param in the bucket function', () => {
expect(
getTimeFieldFromESQLQuery(
'from a | stats meow = avg(bytes) by bucket(event.timefield, 200, ?t_start, ?t_end)'
'from a | stats meow = avg(bytes) by bucket(event.timefield, 200, ?_tstart, ?_tend)'
)
).toBe('event.timefield');
});
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-esql-utils/src/utils/query_parsing_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function removeDropCommandsFromESQLQuery(esql?: string): string {
}

/**
* When the ?t_start and ?t_end params are used, we want to retrieve the timefield from the query.
* When the ?_tstart and ?_tend params are used, we want to retrieve the timefield from the query.
* @param esql:string
* @returns string
*/
Expand All @@ -91,7 +91,7 @@ export const getTimeFieldFromESQLQuery = (esql: string) => {

const params = Walker.params(ast);
const timeNamedParam = params.find(
(param) => param.value === 't_start' || param.value === 't_end'
(param) => param.value === '_tstart' || param.value === '_tend'
);
if (!timeNamedParam || !functions.length) {
return undefined;
Expand Down
14 changes: 7 additions & 7 deletions packages/kbn-esql-utils/src/utils/run_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ describe('getStartEndParams', () => {

it('should return an array with the start param if exists at the query', () => {
const time = { from: 'Jul 5, 2024 @ 08:03:56.849', to: 'Jul 5, 2024 @ 10:03:56.849' };
const query = 'FROM foo | where time > ?t_start';
const query = 'FROM foo | where time > ?_tstart';
const params = getStartEndParams(query, time);
expect(params).toHaveLength(1);
expect(params[0]).toHaveProperty('t_start');
expect(params[0]).toHaveProperty('_tstart');
});

it('should return an array with the end param if exists at the query', () => {
const time = { from: 'Jul 5, 2024 @ 08:03:56.849', to: 'Jul 5, 2024 @ 10:03:56.849' };
const query = 'FROM foo | where time < ?t_end';
const query = 'FROM foo | where time < ?_tend';
const params = getStartEndParams(query, time);
expect(params).toHaveLength(1);
expect(params[0]).toHaveProperty('t_end');
expect(params[0]).toHaveProperty('_tend');
});

it('should return an array with the end and start params if exist at the query', () => {
const time = { from: 'Jul 5, 2024 @ 08:03:56.849', to: 'Jul 5, 2024 @ 10:03:56.849' };
const query = 'FROM foo | where time < ?t_end amd time > ?t_start';
const query = 'FROM foo | where time < ?_tend amd time > ?_tstart';
const params = getStartEndParams(query, time);
expect(params).toHaveLength(2);
expect(params[0]).toHaveProperty('t_start');
expect(params[1]).toHaveProperty('t_end');
expect(params[0]).toHaveProperty('_tstart');
expect(params[1]).toHaveProperty('_tend');
});
});
10 changes: 5 additions & 5 deletions packages/kbn-esql-utils/src/utils/run_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
import type { ESQLColumn, ESQLSearchResponse, ESQLSearchParams } from '@kbn/es-types';
import { lastValueFrom } from 'rxjs';

export const hasStartEndParams = (query: string) => /\?t_start|\?t_end/i.test(query);
export const hasStartEndParams = (query: string) => /\?_tstart|\?_tend/i.test(query);

export const getStartEndParams = (query: string, time?: TimeRange) => {
const startNamedParams = /\?t_start/i.test(query);
const endNamedParams = /\?t_end/i.test(query);
const startNamedParams = /\?_tstart/i.test(query);
const endNamedParams = /\?_tend/i.test(query);
if (time && (startNamedParams || endNamedParams)) {
const timeParams = {
start: startNamedParams ? dateMath.parse(time.from)?.toISOString() : undefined,
end: endNamedParams ? dateMath.parse(time.to)?.toISOString() : undefined,
};
const namedParams = [];
if (timeParams?.start) {
namedParams.push({ t_start: timeParams.start });
namedParams.push({ _tstart: timeParams.start });
}
if (timeParams?.end) {
namedParams.push({ t_end: timeParams.end });
namedParams.push({ _tend: timeParams.end });
}
return namedParams;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ describe('autocomplete.suggest', () => {
});
test('on space within bucket()', async () => {
const { assertSuggestions } = await setup();
await assertSuggestions('from a | stats avg(b) by BUCKET(/, 50, ?t_start, ?t_end)', [
await assertSuggestions('from a | stats avg(b) by BUCKET(/, 50, ?_tstart, ?_tend)', [
// Note there's no space or comma in the suggested field names
...getFieldNamesByType(['date', ...ESQL_COMMON_NUMERIC_TYPES]),
...getFunctionSignaturesByReturnType('eval', ['date', ...ESQL_COMMON_NUMERIC_TYPES], {
scalar: true,
}),
]);
await assertSuggestions('from a | stats avg(b) by BUCKET( / , 50, ?t_start, ?t_end)', [
await assertSuggestions('from a | stats avg(b) by BUCKET( / , 50, ?_tstart, ?_tend)', [
// Note there's no space or comma in the suggested field names
...getFieldNamesByType(['date', ...ESQL_COMMON_NUMERIC_TYPES]),
...getFunctionSignaturesByReturnType('eval', ['date', ...ESQL_COMMON_NUMERIC_TYPES], {
Expand All @@ -308,7 +308,7 @@ describe('autocomplete.suggest', () => {
]);

await assertSuggestions(
'from a | stats avg(b) by BUCKET(dateField, /50, ?t_start, ?t_end)',
'from a | stats avg(b) by BUCKET(dateField, /50, ?_tstart, ?_tend)',
[
...getLiteralsByType('time_literal'),
...getFunctionSignaturesByReturnType('eval', ['integer', 'date_period'], {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const allFunctions = aggregationFunctionDefinitions
.concat(scalarFunctionDefinitions)
.concat(groupingFunctionDefinitions);

export const TIME_SYSTEM_PARAMS = ['?t_start', '?t_end'];
export const TIME_SYSTEM_PARAMS = ['?_tstart', '?_tend'];

export const getAddDateHistogramSnippet = (histogramBarTarget = 50) => {
return `BUCKET($0, ${histogramBarTarget}, ${TIME_SYSTEM_PARAMS.join(', ')})`;
Expand Down Expand Up @@ -442,13 +442,13 @@ export function getCompatibleLiterals(
}

export const TIME_SYSTEM_DESCRIPTIONS = {
'?t_start': i18n.translate(
'?_tstart': i18n.translate(
'kbn-esql-validation-autocomplete.esql.autocomplete.timeSystemParamStart',
{
defaultMessage: 'The start time from the date picker',
}
),
'?t_end': i18n.translate(
'?_tend': i18n.translate(
'kbn-esql-validation-autocomplete.esql.autocomplete.timeSystemParamEnd',
{
defaultMessage: 'The end time from the date picker',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ test('should allow param inside agg function argument', async () => {
test('allow params in WHERE command expressions', async () => {
const { validate } = await setup();

const res1 = await validate('FROM index | WHERE textField >= ?t_start');
const res1 = await validate('FROM index | WHERE textField >= ?_tstart');
const res2 = await validate(`
FROM index
| WHERE textField >= ?t_start
| WHERE textField >= ?_tstart
| WHERE textField <= ?0
| WHERE textField == ?
`);
const res3 = await validate(`
FROM index
| WHERE textField >= ?t_start
| WHERE textField >= ?_tstart
AND textField <= ?0
AND textField == ?
`);
Expand Down
2 changes: 0 additions & 2 deletions packages/kbn-management/settings/setting_ids/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ export const OBSERVABILITY_LOGS_EXPLORER_ALLOWED_DATA_VIEWS_ID =
'observability:logsExplorer:allowedDataViews';
export const OBSERVABILITY_ENTITY_CENTRIC_EXPERIENCE = 'observability:entityCentricExperience';
export const OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID = 'observability:logSources';
export const OBSERVABILITY_AI_ASSISTANT_LOGS_INDEX_PATTERN_ID =
'observability:aiAssistantLogsIndexPattern';
export const OBSERVABILITY_AI_ASSISTANT_SIMULATED_FUNCTION_CALLING =
'observability:aiAssistantSimulatedFunctionCalling';
export const OBSERVABILITY_AI_ASSISTANT_SEARCH_CONNECTOR_INDEX_PATTERN =
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-monaco/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export {
CONSOLE_THEME_ID,
getParsedRequestsProvider,
ConsoleParsedRequestsProvider,
createOutputParser,
} from './src/console';

export type { ParsedRequest } from './src/console';
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-monaco/src/console/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ export const ConsoleOutputLang: LangModuleType = {
export type { ParsedRequest } from './types';
export { getParsedRequestsProvider } from './language';
export { ConsoleParsedRequestsProvider } from './console_parsed_requests_provider';

export { createOutputParser } from './output_parser';
Loading

0 comments on commit 2e085ee

Please sign in to comment.