Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2b71b1b
Backfill H H H H H H …
lukasolson Jul 15, 2025
22bc461
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Jul 16, 2025
b0236b7
i18n fix
lukasolson Jul 16, 2025
01631af
Merge branch 'discover_tabs_schema_backfill' of github.com:lukasolson…
lukasolson Jul 16, 2025
6e62622
Fix jest tests
lukasolson Jul 16, 2025
fdf796a
Merge branch 'main' into discover_tabs_schema_backfill
davismcphee Jul 18, 2025
7d51849
Merge branch 'main' into discover_tabs_schema_backfill
lukasolson Jul 21, 2025
883cc2c
Merge branch 'main' into discover_tabs_schema_backfill
lukasolson Jul 22, 2025
e04293b
Call extractTabs in embeddable transforms
lukasolson Jul 22, 2025
0239ce9
Merge branch 'discover_tabs_schema_backfill' of github.com:lukasolson…
lukasolson Jul 22, 2025
aa26598
Pull in changes from #228511
lukasolson Jul 22, 2025
3f6431b
Move transforms to common, use in public, add tests
lukasolson Jul 23, 2025
db2e62d
Limit async imports
lukasolson Jul 24, 2025
d6ed1ae
Merge branch 'main' into discover_tabs_schema_backfill
lukasolson Jul 24, 2025
3f8913d
Merge branch 'main' into discover_tabs_schema_backfill
lukasolson Jul 24, 2025
a7db027
Merge branch 'main' into discover_tabs_schema_backfill
lukasolson Jul 24, 2025
fd0f1ad
Merge branch 'main' into discover_tabs_schema_backfill
lukasolson Jul 25, 2025
4cf4120
Merge branch 'main' into discover_tabs_schema_backfill
kertal Jul 25, 2025
2c9ba35
Merge branch 'main' into discover_tabs_schema_backfill
lukasolson Jul 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"risk-engine-configuration": "533a0a3f2dbef1c95129146ec4d5714de305be1a",
"rules-settings": "53f94e5ce61f5e75d55ab8adbc1fb3d0937d2e0b",
"sample-data-telemetry": "c38daf1a49ed24f2a4fb091e6e1e833fccf19935",
"search": "33a40cd7fc42cbeabe8e4237fc8377727ae375f7",
"search": "edb9e325564c504e6c49f94115509dc28ccc4b81",
"search-session": "fae0dfc63274d6a3b90ca583802c48cab8760637",
"search-telemetry": "1bbaf2db531b97fa04399440fa52d46e86d54dd8",
"search_playground": "3eba7e7c4563f03f76aea02f5dd3a7a739bf51a3",
Expand Down Expand Up @@ -999,6 +999,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"search|global: ce649a79d99c5ff5eb68d544635428ef87946d84",
"search|mappings: 432d4dfdb5a33ce29d00ccdcfcda70d7c5f94b52",
"search|schemas: 8d6477e08dfdf20335752a69994646f9da90741f",
"search|10.6.0: 4f14cdd86c1bdf96f5390706142438c940236220",
"search|10.5.0: 976f308f7d6c229d3ff39eee58f0322aa945e0ae",
"search|10.4.0: 53bcea1cfac6ec3826e47ddf2ef85b3e3d428bd1",
"search|10.3.0: df30d50a6e40e7b0ed137b7a4517fa4848fee785",
Expand Down Expand Up @@ -1327,7 +1328,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"risk-engine-configuration": "10.2.0",
"rules-settings": "10.1.0",
"sample-data-telemetry": "10.0.0",
"search": "10.5.0",
"search": "10.6.0",
"search-session": "10.0.0",
"search-telemetry": "10.0.0",
"search_playground": "10.1.0",
Expand Down Expand Up @@ -1474,7 +1475,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"risk-engine-configuration": "10.2.0",
"rules-settings": "10.1.0",
"sample-data-telemetry": "0.0.0",
"search": "10.5.0",
"search": "10.6.0",
"search-session": "8.6.0",
"search-telemetry": "7.12.0",
"search_playground": "10.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*/

export { inject, extract } from './search_inject_extract';
export { searchEmbeddableTransforms } from './search_embeddable_transforms';
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { searchEmbeddableTransforms } from './search_embeddable_transforms';
import type { SearchEmbeddableSerializedState } from '../../public';

describe('searchEmbeddableTransforms', () => {
describe('transformOut', () => {
it('returns the state unchanged if attributes are not present', () => {
const state: SearchEmbeddableSerializedState = {
title: 'Test Title',
description: 'Test Description',
};
const result = searchEmbeddableTransforms.transformOut?.(state);
expect(result).toEqual(state);
});

it('transforms the state by extracting tabs if attributes are present', () => {
const state = {
title: 'Test Title',
description: 'Test Description',
attributes: {
title: 'Test Title',
description: 'Test Description',
columns: ['column1', 'column2'],
},
} as SearchEmbeddableSerializedState;
const expectedAttributes = {
title: 'Test Title',
description: 'Test Description',
columns: ['column1', 'column2'],
tabs: [
{
id: expect.any(String),
label: 'Untitled',
attributes: {
columns: ['column1', 'column2'],
},
},
],
};
const result = searchEmbeddableTransforms.transformOut?.(state);
expect(result).toEqual({
...state,
attributes: expectedAttributes,
});
});

it('handles empty attributes gracefully', () => {
const state = {
title: 'Test Title',
description: 'Test Description',
attributes: {},
} as SearchEmbeddableSerializedState;
const expectedAttributes = {
tabs: [
{
id: expect.any(String),
label: 'Untitled',
attributes: {},
},
],
};
const result = searchEmbeddableTransforms.transformOut?.(state);
expect(result).toEqual({
...state,
attributes: expectedAttributes,
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { EmbeddableTransforms } from '@kbn/embeddable-plugin/common';
import { extractTabs } from '@kbn/saved-search-plugin/common';
import type { SearchEmbeddableSerializedState } from '../../public';

export const searchEmbeddableTransforms: EmbeddableTransforms<SearchEmbeddableSerializedState> = {
transformOut: (state) => {
if (!state.attributes) return state;
const attributes = extractTabs(state.attributes);
return { ...state, attributes };
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export const getSearchEmbeddableFactory = ({
timeRestore: 'skip',
usesAdHocDataView: 'skip',
visContext: 'skip',
tabs: 'skip',
};
},
onReset: async (lastSaved) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,22 @@ describe('Serialization utils', () => {
serializeDynamicActions: jest.fn(),
});

const attributes = toSavedSearchAttributes(
savedSearch,
searchSource.serialize().searchSourceJSON
);

expect(serializedState).toEqual({
rawState: {
type: 'search',
attributes: {
...toSavedSearchAttributes(savedSearch, searchSource.serialize().searchSourceJSON),
...attributes,
tabs: [
{
...attributes.tabs![0]!,
id: expect.any(String),
},
],
references: mockedSavedSearchAttributes.references,
},
},
Expand Down
5 changes: 5 additions & 0 deletions src/platform/plugins/shared/discover/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ export class DiscoverPlugin
discoverServices,
});
});

plugins.embeddable.registerTransforms(SEARCH_EMBEDDABLE_TYPE, async () => {
const { searchEmbeddableTransforms } = await getEmbeddableServices();
return searchEmbeddableTransforms;
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
export { ViewSavedSearchAction } from '../embeddable/actions/view_saved_search_action';
export { getSearchEmbeddableFactory } from '../embeddable/get_search_embeddable_factory';
export { getLegacyLogStreamEmbeddableFactory } from '../embeddable/get_legacy_log_stream_embeddable_factory';
export { searchEmbeddableTransforms } from '../../common/embeddable';
3 changes: 3 additions & 0 deletions src/platform/plugins/shared/discover/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { HomeServerPluginSetup } from '@kbn/home-plugin/server';
import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/common';
import type { SharePluginSetup } from '@kbn/share-plugin/server';
import type { PluginInitializerContext } from '@kbn/core/server';
import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils';
import type { DiscoverServerPluginStart, DiscoverServerPluginStartDeps } from '.';
import { DISCOVER_APP_LOCATOR } from '../common';
import { capabilitiesProvider } from './capabilities_provider';
Expand All @@ -24,6 +25,7 @@ import { getUiSettings } from './ui_settings';
import type { ConfigSchema } from './config';
import { appLocatorGetLocationCommon } from '../common/app_locator_get_location';
import { TRACES_PRODUCT_FEATURE_ID } from '../common/constants';
import { searchEmbeddableTransforms } from '../common/embeddable';

export class DiscoverServerPlugin
implements Plugin<object, DiscoverServerPluginStart, object, DiscoverServerPluginStartDeps>
Expand Down Expand Up @@ -60,6 +62,7 @@ export class DiscoverServerPlugin
}

plugins.embeddable.registerEmbeddableFactory(createSearchEmbeddableFactory());
plugins.embeddable.registerTransforms(SEARCH_EMBEDDABLE_TYPE, searchEmbeddableTransforms);

core.pricing.registerProductFeatures([
{
Expand Down
14 changes: 11 additions & 3 deletions src/platform/plugins/shared/embeddable/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
} from './persistable_state';
import { getAllMigrations } from './persistable_state/get_all_migrations';
import { EmbeddableTransforms } from '../common';
import { getTransforms, registerTransforms } from './transforms_registry';

export interface EmbeddableSetup extends PersistableStateService<EmbeddableStateWithType> {
registerEmbeddableFactory: (factory: EmbeddableRegistryDefinition) => void;
Expand All @@ -49,12 +48,19 @@ export class EmbeddableServerPlugin implements Plugin<EmbeddableSetup, Embeddabl
private readonly embeddableFactories: EmbeddableFactoryRegistry = new Map();
private readonly enhancements: EnhancementsRegistry = new Map();
private migrateFn: PersistableStateMigrateFn | undefined;
private transformsRegistry: { [key: string]: EmbeddableTransforms<any, any> } = {};

public setup(core: CoreSetup) {
this.migrateFn = getMigrateFunction(this.getEmbeddableFactory, this.getEnhancement);
return {
registerEmbeddableFactory: this.registerEmbeddableFactory,
registerTransforms,
registerTransforms: (type: string, transforms: EmbeddableTransforms<any, any>) => {
if (this.transformsRegistry[type]) {
throw new Error(`Embeddable transforms for type "${type}" are already registered.`);
}

this.transformsRegistry[type] = transforms;
},
registerEnhancement: this.registerEnhancement,
telemetry: getTelemetryFunction(this.getEmbeddableFactory, this.getEnhancement),
extract: getExtractFunction(this.getEmbeddableFactory, this.getEnhancement),
Expand All @@ -70,7 +76,9 @@ export class EmbeddableServerPlugin implements Plugin<EmbeddableSetup, Embeddabl

public start(core: CoreStart) {
return {
getTransforms,
getTransforms: (type: string) => {
return this.transformsRegistry[type];
},
telemetry: getTelemetryFunction(this.getEmbeddableFactory, this.getEnhancement),
extract: getExtractFunction(this.getEmbeddableFactory, this.getEnhancement),
inject: getInjectFunction(this.getEmbeddableFactory, this.getEnhancement),
Expand Down
1 change: 1 addition & 0 deletions src/platform/plugins/shared/saved_search/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

export { getSavedSearchUrl, getSavedSearchFullPathUrl } from './saved_searches_url';
export { fromSavedSearchAttributes } from './saved_searches_utils';
export { extractTabs, extractTabsBackfillFn } from './service/extract_tabs';

export type {
DiscoverGridSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ export const fromSavedSearchAttributes = <
breakdownField: attributes.breakdownField,
visContext: attributes.visContext,
density: attributes.density,
tabs: attributes.tabs,
managed,
} as ReturnType);
Loading