Skip to content

Commit 078399f

Browse files
author
Thomas Watson
authored
Merge branch 'main' into fix/x-pack-test-types
2 parents 7b58719 + 354efc2 commit 078399f

51 files changed

Lines changed: 1479 additions & 1337 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ x-pack/plugins/metrics_data_access @elastic/infra-monitoring-ui
502502
x-pack/packages/ml/agg_utils @elastic/ml-ui
503503
x-pack/packages/ml/anomaly_utils @elastic/ml-ui
504504
x-pack/packages/ml/category_validator @elastic/ml-ui
505+
x-pack/packages/ml/chi2test @elastic/ml-ui
505506
x-pack/packages/ml/data_frame_analytics_utils @elastic/ml-ui
506507
x-pack/packages/ml/data_grid @elastic/ml-ui
507508
x-pack/packages/ml/date_picker @elastic/ml-ui

config/serverless.oblt.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ xpack.legacy_uptime.enabled: false
1212
xpack.serverless.observability.enabled: true
1313

1414
## Configure plugins
15-
xpack.infra.logs.app_target: discover
1615

1716
## Set the home route
1817
uiSettings.overrides.defaultRoute: /app/observability/landing

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@
523523
"@kbn/ml-agg-utils": "link:x-pack/packages/ml/agg_utils",
524524
"@kbn/ml-anomaly-utils": "link:x-pack/packages/ml/anomaly_utils",
525525
"@kbn/ml-category-validator": "link:x-pack/packages/ml/category_validator",
526+
"@kbn/ml-chi2test": "link:x-pack/packages/ml/chi2test",
526527
"@kbn/ml-data-frame-analytics-utils": "link:x-pack/packages/ml/data_frame_analytics_utils",
527528
"@kbn/ml-data-grid": "link:x-pack/packages/ml/data_grid",
528529
"@kbn/ml-date-picker": "link:x-pack/packages/ml/date_picker",

packages/kbn-es-query/src/es_query/es_aggregate_query.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ describe('sql query helpers', () => {
3333
expect(flag).toBe(false);
3434
});
3535

36+
it('should return false for an undefined query', () => {
37+
const flag = isOfAggregateQueryType(undefined);
38+
expect(flag).toBe(false);
39+
});
40+
3641
it('should return true for an Aggregate type query', () => {
3742
const flag = isOfAggregateQueryType({ sql: 'SELECT * FROM foo' });
3843
expect(flag).toBe(true);

packages/kbn-es-query/src/es_query/es_aggregate_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function isOfQueryType(arg?: Query | AggregateQuery): arg is Query {
1818
// currently only supports the sql query type
1919
// should be enhanced to support other query types
2020
export function isOfAggregateQueryType(
21-
query: AggregateQuery | Query | { [key: string]: any }
21+
query?: AggregateQuery | Query | { [key: string]: any }
2222
): query is AggregateQuery {
2323
return Boolean(query && ('sql' in query || 'esql' in query));
2424
}

src/plugins/dashboard/public/dashboard_actions/add_to_library_action.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
CONTACT_CARD_EMBEDDABLE,
2222
} from '@kbn/embeddable-plugin/public/lib/test_samples/embeddables';
2323
import { embeddablePluginMock } from '@kbn/embeddable-plugin/public/mocks';
24+
import { type Query, type AggregateQuery, Filter } from '@kbn/es-query';
2425

2526
import { buildMockDashboard } from '../mocks';
2627
import { pluginServices } from '../services/plugin_services';
@@ -82,6 +83,18 @@ test('Add to library is incompatible with Error Embeddables', async () => {
8283
expect(await action.isCompatible({ embeddable: errorEmbeddable })).toBe(false);
8384
});
8485

86+
test('Add to library is incompatible with ES|QL Embeddables', async () => {
87+
const action = new AddToLibraryAction();
88+
const mockGetFilters = jest.fn(async () => [] as Filter[]);
89+
const mockGetQuery = jest.fn(async () => undefined as Query | AggregateQuery | undefined);
90+
const filterableEmbeddable = embeddablePluginMock.mockFilterableEmbeddable(embeddable, {
91+
getFilters: () => mockGetFilters(),
92+
getQuery: () => mockGetQuery(),
93+
});
94+
mockGetQuery.mockResolvedValue({ esql: 'from logstash-* | limit 10' } as AggregateQuery);
95+
expect(await action.isCompatible({ embeddable: filterableEmbeddable })).toBe(false);
96+
});
97+
8598
test('Add to library is incompatible on visualize embeddable without visualize save permissions', async () => {
8699
pluginServices.getServices().application.capabilities = {
87100
...defaultCapabilities,

src/plugins/dashboard/public/dashboard_actions/add_to_library_action.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import {
1414
PanelNotFoundError,
1515
type EmbeddableInput,
1616
isReferenceOrValueEmbeddable,
17+
isFilterableEmbeddable,
1718
} from '@kbn/embeddable-plugin/public';
1819
import { Action, IncompatibleActionError } from '@kbn/ui-actions-plugin/public';
19-
20+
import { type AggregateQuery } from '@kbn/es-query';
2021
import { DashboardPanelState } from '../../common';
2122
import { pluginServices } from '../services/plugin_services';
2223
import { dashboardAddToLibraryActionStrings } from './_dashboard_actions_strings';
@@ -61,7 +62,10 @@ export class AddToLibraryAction implements Action<AddToLibraryActionContext> {
6162
// TODO: Fix this, potentially by adding a 'canSave' function to embeddable interface
6263
const { maps, visualize } = this.applicationCapabilities;
6364
const canSave = embeddable.type === 'map' ? maps.save : visualize.save;
64-
65+
const { isOfAggregateQueryType } = await import('@kbn/es-query');
66+
const query = isFilterableEmbeddable(embeddable) && (await embeddable.getQuery());
67+
// Textbased panels (i.e. ES|QL, SQL) should not save to library
68+
const isTextBasedEmbeddable = isOfAggregateQueryType(query as AggregateQuery);
6569
return Boolean(
6670
canSave &&
6771
!isErrorEmbeddable(embeddable) &&
@@ -70,7 +74,8 @@ export class AddToLibraryAction implements Action<AddToLibraryActionContext> {
7074
embeddable.getRoot().isContainer &&
7175
embeddable.getRoot().type === DASHBOARD_CONTAINER_TYPE &&
7276
isReferenceOrValueEmbeddable(embeddable) &&
73-
!embeddable.inputIsRefType(embeddable.getInput())
77+
!embeddable.inputIsRefType(embeddable.getInput()) &&
78+
!isTextBasedEmbeddable
7479
);
7580
}
7681

test/plugin_functional/test_suites/core_plugins/rendering.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,6 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
250250
'xpack.index_management.dev.enableIndexDetailsPage (boolean)',
251251
'xpack.index_management.enableIndexStats (any)',
252252
'xpack.infra.sources.default.fields.message (array)',
253-
/**
254-
* xpack.infra.logs is conditional and will resolve to an object of properties
255-
* - xpack.infra.logs.app_target (string)
256-
*/
257-
'xpack.infra.logs (any)',
258253
'xpack.license_management.ui.enabled (boolean)',
259254
'xpack.maps.preserveDrawingBuffer (boolean)',
260255
'xpack.maps.showMapsInspectorAdapter (boolean)',

tsconfig.base.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,8 @@
998998
"@kbn/ml-anomaly-utils/*": ["x-pack/packages/ml/anomaly_utils/*"],
999999
"@kbn/ml-category-validator": ["x-pack/packages/ml/category_validator"],
10001000
"@kbn/ml-category-validator/*": ["x-pack/packages/ml/category_validator/*"],
1001+
"@kbn/ml-chi2test": ["x-pack/packages/ml/chi2test"],
1002+
"@kbn/ml-chi2test/*": ["x-pack/packages/ml/chi2test/*"],
10011003
"@kbn/ml-data-frame-analytics-utils": ["x-pack/packages/ml/data_frame_analytics_utils"],
10021004
"@kbn/ml-data-frame-analytics-utils/*": ["x-pack/packages/ml/data_frame_analytics_utils/*"],
10031005
"@kbn/ml-data-grid": ["x-pack/packages/ml/data_grid"],
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# @kbn/ml-chi2test
2+
3+
`computeChi2PValue` computes the p-value for how similar the datasets are.
4+
Returned value ranges from 0 to 1, with 1 meaning the datasets are identical.

0 commit comments

Comments
 (0)