From 4888649d930524311069f146e05f5c07988b21f9 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 20 Feb 2025 13:06:57 -0700 Subject: [PATCH 1/8] [discover] lazy load actions --- .../public/embeddable/actions/constants.ts | 10 ++++ ...s => view_discover_session_action.test.ts} | 16 ++--- .../actions/view_discover_session_action.ts | 59 +++++++++++++++++++ .../actions/view_saved_search_action.ts | 59 ------------------- .../view_saved_search_compatibility_check.ts | 36 ----------- .../plugins/shared/discover/public/index.ts | 7 ++- .../plugins/shared/discover/public/plugin.tsx | 9 +-- .../shared/discover/public/utils/index.ts | 2 +- 8 files changed, 89 insertions(+), 109 deletions(-) create mode 100644 src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts rename src/platform/plugins/shared/discover/public/embeddable/actions/{view_saved_search_action.test.ts => view_discover_session_action.test.ts} (80%) create mode 100644 src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts delete mode 100644 src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_action.ts delete mode 100644 src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_compatibility_check.ts diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts new file mode 100644 index 0000000000000..7cd901d5460b0 --- /dev/null +++ b/src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts @@ -0,0 +1,10 @@ +/* + * 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". + */ + +export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH'; \ No newline at end of file diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_action.test.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.test.ts similarity index 80% rename from src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_action.test.ts rename to src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.test.ts index 324b73682d5f5..b7b782387ed0e 100644 --- a/src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_action.test.ts +++ b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.test.ts @@ -16,7 +16,7 @@ import { discoverServiceMock } from '../../__mocks__/services'; import { createStartContractMock } from '../../__mocks__/start_contract'; import { SearchEmbeddableApi } from '../types'; import { getDiscoverLocatorParams } from '../utils/get_discover_locator_params'; -import { ViewSavedSearchAction } from './view_saved_search_action'; +import { getViewDiscoverSessionAction } from './view_discover_session_action'; const applicationMock = createStartContractMock(); const services = discoverServiceMock; @@ -37,30 +37,30 @@ jest describe('view saved search action', () => { it('is compatible when embeddable is of type saved search, in view mode && appropriate permissions are set', async () => { - const action = new ViewSavedSearchAction(applicationMock, services.locator); - expect(await action.isCompatible({ embeddable: compatibleEmbeddableApi })).toBe(true); + const action = getViewDiscoverSessionAction(applicationMock, services.locator); + expect(await action.isCompatible?.({ embeddable: compatibleEmbeddableApi })).toBe(true); }); it('is not compatible when embeddable not of type saved search', async () => { - const action = new ViewSavedSearchAction(applicationMock, services.locator); + const action = getViewDiscoverSessionAction(applicationMock, services.locator); expect( - await action.isCompatible({ + await action.isCompatible?.({ embeddable: { ...compatibleEmbeddableApi, type: 'CONTACT_CARD_EMBEDDABLE' }, }) ).toBe(false); }); it('is not visible when in edit mode', async () => { - const action = new ViewSavedSearchAction(applicationMock, services.locator); + const action = getViewDiscoverSessionAction(applicationMock, services.locator); expect( - await action.isCompatible({ + await action.isCompatible?.({ embeddable: { ...compatibleEmbeddableApi, viewMode$: new BehaviorSubject(ViewMode.EDIT) }, }) ).toBe(false); }); it('execute navigates to a saved search', async () => { - const action = new ViewSavedSearchAction(applicationMock, services.locator); + const action = getViewDiscoverSessionAction(applicationMock, services.locator); await new Promise((resolve) => setTimeout(resolve, 0)); await action.execute({ embeddable: compatibleEmbeddableApi }); expect(discoverServiceMock.locator.navigate).toHaveBeenCalledWith( diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts new file mode 100644 index 0000000000000..cc3ee23675710 --- /dev/null +++ b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts @@ -0,0 +1,59 @@ +/* + * 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 { ApplicationStart } from '@kbn/core/public'; +import { i18n } from '@kbn/i18n'; +import { apiCanAccessViewMode, getInheritedViewMode, type EmbeddableApiContext, apiIsOfType, CanAccessViewMode, HasType } from '@kbn/presentation-publishing'; +import { IncompatibleActionError, type Action } from '@kbn/ui-actions-plugin/public'; + +import type { DiscoverAppLocator } from '../../../common'; +import { getDiscoverLocatorParams } from '../utils/get_discover_locator_params'; +import { ACTION_VIEW_SAVED_SEARCH } from './constants'; +import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils'; +import { PublishesSavedSearch, apiPublishesSavedSearch } from '../types'; +import { ActionDefinition } from '@kbn/ui-actions-plugin/public/actions'; + +type ViewSavedSearchActionApi = CanAccessViewMode & HasType & PublishesSavedSearch; + +export const compatibilityCheck = ( + api: EmbeddableApiContext['embeddable'] +): api is ViewSavedSearchActionApi => { + return ( + apiCanAccessViewMode(api) && + getInheritedViewMode(api) === 'view' && + apiIsOfType(api, SEARCH_EMBEDDABLE_TYPE) && + apiPublishesSavedSearch(api) + ); +}; + +export function getViewDiscoverSessionAction(application: ApplicationStart, locator: DiscoverAppLocator) { + return { + id: ACTION_VIEW_SAVED_SEARCH, + type: ACTION_VIEW_SAVED_SEARCH, + order: 20, // Same order as ACTION_OPEN_IN_DISCOVER + execute: async ({ embeddable }: EmbeddableApiContext) => { + if (!compatibilityCheck(embeddable)) throw new IncompatibleActionError(); + + const locatorParams = getDiscoverLocatorParams(embeddable); + await locator.navigate(locatorParams); + }, + getDisplayName: () => i18n.translate('discover.savedSearchEmbeddable.action.viewSavedSearch.displayName', { + defaultMessage: 'Open in Discover', + }), + getIconType: () => 'discoverApp', + isCompatible: async ({ embeddable }: EmbeddableApiContext) => { + const { capabilities } = application; + const hasDiscoverPermissions = + (capabilities.discover_v2.show as boolean) || (capabilities.discover_v2.save as boolean); + + if (!hasDiscoverPermissions) return false; + return compatibilityCheck(embeddable); + } + } as ActionDefinition +} diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_action.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_action.ts deleted file mode 100644 index 3511e298e4827..0000000000000 --- a/src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_action.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 { ApplicationStart } from '@kbn/core/public'; -import { i18n } from '@kbn/i18n'; -import type { EmbeddableApiContext } from '@kbn/presentation-publishing'; -import type { Action } from '@kbn/ui-actions-plugin/public'; - -import type { DiscoverAppLocator } from '../../../common'; -import { getDiscoverLocatorParams } from '../utils/get_discover_locator_params'; - -export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH'; - -export class ViewSavedSearchAction implements Action { - public id = ACTION_VIEW_SAVED_SEARCH; - public readonly type = ACTION_VIEW_SAVED_SEARCH; - public readonly order = 20; // Same order as ACTION_OPEN_IN_DISCOVER - - constructor( - private readonly application: ApplicationStart, - private readonly locator: DiscoverAppLocator - ) {} - - async execute({ embeddable }: EmbeddableApiContext): Promise { - const { compatibilityCheck } = await import('./view_saved_search_compatibility_check'); - if (!compatibilityCheck(embeddable)) { - return; - } - - const locatorParams = getDiscoverLocatorParams(embeddable); - await this.locator.navigate(locatorParams); - } - - getDisplayName(): string { - return i18n.translate('discover.savedSearchEmbeddable.action.viewSavedSearch.displayName', { - defaultMessage: 'Open in Discover', - }); - } - - getIconType(): string | undefined { - return 'discoverApp'; - } - - async isCompatible({ embeddable }: EmbeddableApiContext) { - const { capabilities } = this.application; - const hasDiscoverPermissions = - (capabilities.discover_v2.show as boolean) || (capabilities.discover_v2.save as boolean); - - if (!hasDiscoverPermissions) return false; // early return to delay async import until absolutely necessary - const { compatibilityCheck } = await import('./view_saved_search_compatibility_check'); - return compatibilityCheck(embeddable); - } -} diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_compatibility_check.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_compatibility_check.ts deleted file mode 100644 index 3619bb41280f0..0000000000000 --- a/src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_compatibility_check.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils'; -import { ViewMode } from '@kbn/embeddable-plugin/public'; -import { - apiCanAccessViewMode, - apiHasType, - apiIsOfType, - CanAccessViewMode, - EmbeddableApiContext, - getInheritedViewMode, - HasType, -} from '@kbn/presentation-publishing'; - -import { apiPublishesSavedSearch, PublishesSavedSearch } from '../types'; - -type ViewSavedSearchActionApi = CanAccessViewMode & HasType & PublishesSavedSearch; - -export const compatibilityCheck = ( - api: EmbeddableApiContext['embeddable'] -): api is ViewSavedSearchActionApi => { - return ( - apiCanAccessViewMode(api) && - getInheritedViewMode(api) === ViewMode.VIEW && - apiHasType(api) && - apiIsOfType(api, SEARCH_EMBEDDABLE_TYPE) && - apiPublishesSavedSearch(api) - ); -}; diff --git a/src/platform/plugins/shared/discover/public/index.ts b/src/platform/plugins/shared/discover/public/index.ts index a359184f3b4a6..9bad7df5ac0b5 100644 --- a/src/platform/plugins/shared/discover/public/index.ts +++ b/src/platform/plugins/shared/discover/public/index.ts @@ -39,5 +39,10 @@ export { type SearchEmbeddableApi, type NonPersistedDisplayOptions, } from './embeddable'; -export { loadSharingDataHelpers } from './utils'; + + +export async function loadSharingDataHelpers() { + return await import('./utils/get_sharing_data'); +} + export type { DiscoverServices } from './build_services'; diff --git a/src/platform/plugins/shared/discover/public/plugin.tsx b/src/platform/plugins/shared/discover/public/plugin.tsx index d108ed9f717bc..4d84b9beb8514 100644 --- a/src/platform/plugins/shared/discover/public/plugin.tsx +++ b/src/platform/plugins/shared/discover/public/plugin.tsx @@ -27,7 +27,6 @@ import { i18n } from '@kbn/i18n'; import { PLUGIN_ID } from '../common'; import { registerFeature } from './register_feature'; import { buildServices, UrlTracker } from './build_services'; -import { ViewSavedSearchAction } from './embeddable/actions/view_saved_search_action'; import { initializeKbnUrlTracking } from './utils/initialize_kbn_url_tracking'; import { DiscoverContextAppLocator, @@ -59,6 +58,7 @@ import { DataSourceProfileService } from './context_awareness/profiles/data_sour import { DocumentProfileService } from './context_awareness/profiles/document_profile'; import { ProfilesManager } from './context_awareness/profiles_manager'; import { DiscoverEBTManager } from './services/discover_ebt_manager'; +import { ACTION_VIEW_SAVED_SEARCH } from './embeddable/actions/constants'; /** * Contains Discover, one of the oldest parts of Kibana @@ -254,9 +254,10 @@ export class DiscoverPlugin } start(core: CoreStart, plugins: DiscoverStartPlugins): DiscoverStart { - const viewSavedSearchAction = new ViewSavedSearchAction(core.application, this.locator!); - - plugins.uiActions.addTriggerAction('CONTEXT_MENU_TRIGGER', viewSavedSearchAction); + plugins.uiActions.addTriggerActionAsync('CONTEXT_MENU_TRIGGER', ACTION_VIEW_SAVED_SEARCH, async () => { + const { getViewDiscoverSessionAction } = await import('./embeddable/actions/view_discover_session_action'); + return getViewDiscoverSessionAction(core.application, this.locator!); + }); plugins.uiActions.registerTrigger(SEARCH_EMBEDDABLE_CELL_ACTIONS_TRIGGER); plugins.uiActions.registerTrigger(DISCOVER_CELL_ACTIONS_TRIGGER); diff --git a/src/platform/plugins/shared/discover/public/utils/index.ts b/src/platform/plugins/shared/discover/public/utils/index.ts index 61935bcc15cac..3af32cafaf9b5 100644 --- a/src/platform/plugins/shared/discover/public/utils/index.ts +++ b/src/platform/plugins/shared/discover/public/utils/index.ts @@ -14,4 +14,4 @@ export async function loadSharingDataHelpers() { return await import('./get_sharing_data'); } -export { getSortForEmbeddable } from './sorting'; +//export { getSortForEmbeddable } from './sorting'; From fcec3038e5476c24d83afca2b0673149c0e6bf00 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 20 Feb 2025 13:08:22 -0700 Subject: [PATCH 2/8] update limits --- packages/kbn-optimizer/limits.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 369a660856c97..ddabae1015cb1 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -35,7 +35,7 @@ pageLoadAssetSize: dataViews: 65000 dataVisualizer: 30000 devTools: 38637 - discover: 99999 + discover: 41000 discoverEnhanced: 42730 discoverShared: 17111 embeddable: 24000 From dbf2dfbb3a4226c024d90674b204cbd75a96b38d Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 20 Feb 2025 13:09:38 -0700 Subject: [PATCH 3/8] clean up --- .../public/embeddable/actions/view_discover_session_action.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts index cc3ee23675710..91cd29b563825 100644 --- a/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts +++ b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts @@ -51,9 +51,7 @@ export function getViewDiscoverSessionAction(application: ApplicationStart, loca const { capabilities } = application; const hasDiscoverPermissions = (capabilities.discover_v2.show as boolean) || (capabilities.discover_v2.save as boolean); - - if (!hasDiscoverPermissions) return false; - return compatibilityCheck(embeddable); + return hasDiscoverPermissions && compatibilityCheck(embeddable); } } as ActionDefinition } From 9d7916188713f67dd3e1e518095005829a1e09f8 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 20 Feb 2025 13:10:32 -0700 Subject: [PATCH 4/8] clean up --- .../plugins/shared/discover/public/utils/index.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/platform/plugins/shared/discover/public/utils/index.ts b/src/platform/plugins/shared/discover/public/utils/index.ts index 3af32cafaf9b5..27080889c3fc7 100644 --- a/src/platform/plugins/shared/discover/public/utils/index.ts +++ b/src/platform/plugins/shared/discover/public/utils/index.ts @@ -7,11 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -/* - * Allows the getSharingData function to be lazy loadable - */ -export async function loadSharingDataHelpers() { - return await import('./get_sharing_data'); -} - -//export { getSortForEmbeddable } from './sorting'; +export { getSortForEmbeddable } from './sorting'; From 9208e612a2465993b28ca5a2634db9b6006be047 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 20 Feb 2025 20:35:52 +0000 Subject: [PATCH 5/8] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../public/embeddable/actions/constants.ts | 2 +- .../actions/view_discover_session_action.ts | 31 +++++++++++++------ .../plugins/shared/discover/public/index.ts | 1 - .../plugins/shared/discover/public/plugin.tsx | 14 ++++++--- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts index 7cd901d5460b0..dca2bfc833d74 100644 --- a/src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts +++ b/src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts @@ -7,4 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH'; \ No newline at end of file +export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH'; diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts index 91cd29b563825..31cc37b4dfff5 100644 --- a/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts +++ b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts @@ -9,15 +9,22 @@ import type { ApplicationStart } from '@kbn/core/public'; import { i18n } from '@kbn/i18n'; -import { apiCanAccessViewMode, getInheritedViewMode, type EmbeddableApiContext, apiIsOfType, CanAccessViewMode, HasType } from '@kbn/presentation-publishing'; -import { IncompatibleActionError, type Action } from '@kbn/ui-actions-plugin/public'; +import { + apiCanAccessViewMode, + getInheritedViewMode, + type EmbeddableApiContext, + apiIsOfType, + CanAccessViewMode, + HasType, +} from '@kbn/presentation-publishing'; +import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; +import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils'; +import { ActionDefinition } from '@kbn/ui-actions-plugin/public/actions'; import type { DiscoverAppLocator } from '../../../common'; import { getDiscoverLocatorParams } from '../utils/get_discover_locator_params'; import { ACTION_VIEW_SAVED_SEARCH } from './constants'; -import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils'; import { PublishesSavedSearch, apiPublishesSavedSearch } from '../types'; -import { ActionDefinition } from '@kbn/ui-actions-plugin/public/actions'; type ViewSavedSearchActionApi = CanAccessViewMode & HasType & PublishesSavedSearch; @@ -32,7 +39,10 @@ export const compatibilityCheck = ( ); }; -export function getViewDiscoverSessionAction(application: ApplicationStart, locator: DiscoverAppLocator) { +export function getViewDiscoverSessionAction( + application: ApplicationStart, + locator: DiscoverAppLocator +) { return { id: ACTION_VIEW_SAVED_SEARCH, type: ACTION_VIEW_SAVED_SEARCH, @@ -43,15 +53,16 @@ export function getViewDiscoverSessionAction(application: ApplicationStart, loca const locatorParams = getDiscoverLocatorParams(embeddable); await locator.navigate(locatorParams); }, - getDisplayName: () => i18n.translate('discover.savedSearchEmbeddable.action.viewSavedSearch.displayName', { - defaultMessage: 'Open in Discover', - }), + getDisplayName: () => + i18n.translate('discover.savedSearchEmbeddable.action.viewSavedSearch.displayName', { + defaultMessage: 'Open in Discover', + }), getIconType: () => 'discoverApp', isCompatible: async ({ embeddable }: EmbeddableApiContext) => { const { capabilities } = application; const hasDiscoverPermissions = (capabilities.discover_v2.show as boolean) || (capabilities.discover_v2.save as boolean); return hasDiscoverPermissions && compatibilityCheck(embeddable); - } - } as ActionDefinition + }, + } as ActionDefinition; } diff --git a/src/platform/plugins/shared/discover/public/index.ts b/src/platform/plugins/shared/discover/public/index.ts index 9bad7df5ac0b5..376a369e803f2 100644 --- a/src/platform/plugins/shared/discover/public/index.ts +++ b/src/platform/plugins/shared/discover/public/index.ts @@ -40,7 +40,6 @@ export { type NonPersistedDisplayOptions, } from './embeddable'; - export async function loadSharingDataHelpers() { return await import('./utils/get_sharing_data'); } diff --git a/src/platform/plugins/shared/discover/public/plugin.tsx b/src/platform/plugins/shared/discover/public/plugin.tsx index 4d84b9beb8514..03c705dcde8dd 100644 --- a/src/platform/plugins/shared/discover/public/plugin.tsx +++ b/src/platform/plugins/shared/discover/public/plugin.tsx @@ -254,10 +254,16 @@ export class DiscoverPlugin } start(core: CoreStart, plugins: DiscoverStartPlugins): DiscoverStart { - plugins.uiActions.addTriggerActionAsync('CONTEXT_MENU_TRIGGER', ACTION_VIEW_SAVED_SEARCH, async () => { - const { getViewDiscoverSessionAction } = await import('./embeddable/actions/view_discover_session_action'); - return getViewDiscoverSessionAction(core.application, this.locator!); - }); + plugins.uiActions.addTriggerActionAsync( + 'CONTEXT_MENU_TRIGGER', + ACTION_VIEW_SAVED_SEARCH, + async () => { + const { getViewDiscoverSessionAction } = await import( + './embeddable/actions/view_discover_session_action' + ); + return getViewDiscoverSessionAction(core.application, this.locator!); + } + ); plugins.uiActions.registerTrigger(SEARCH_EMBEDDABLE_CELL_ACTIONS_TRIGGER); plugins.uiActions.registerTrigger(DISCOVER_CELL_ACTIONS_TRIGGER); From 6d6bad9019663ed3af150f3eb94991ca52604c93 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 20 Feb 2025 14:41:52 -0700 Subject: [PATCH 6/8] limits --- packages/kbn-optimizer/limits.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index ddabae1015cb1..def343e5422d0 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -35,7 +35,7 @@ pageLoadAssetSize: dataViews: 65000 dataVisualizer: 30000 devTools: 38637 - discover: 41000 + discover: 42000 discoverEnhanced: 42730 discoverShared: 17111 embeddable: 24000 From 68a9eef71bd3068f7dfc33c6b8ebb0b845b5b505 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Wed, 5 Mar 2025 14:27:06 -0700 Subject: [PATCH 7/8] discoverEnhanced --- packages/kbn-optimizer/limits.yml | 2 +- .../abstract_explore_data_action.ts | 2 -- .../explore_data/{index.ts => constants.ts} | 4 ++-- .../explore_data/explore_data_chart_action.ts | 3 +-- .../explore_data_context_menu_action.ts | 3 +-- .../{index.ts => explore_data/module.ts} | 3 ++- .../private/discover_enhanced/public/index.ts | 2 -- .../private/discover_enhanced/public/plugin.ts | 18 +++++++++++++----- 8 files changed, 20 insertions(+), 17 deletions(-) rename x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/{index.ts => constants.ts} (66%) rename x-pack/platform/plugins/private/discover_enhanced/public/actions/{index.ts => explore_data/module.ts} (62%) diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index bcbaf338dcdea..abbb11ff0c7bc 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -36,7 +36,7 @@ pageLoadAssetSize: dataVisualizer: 30000 devTools: 38637 discover: 42000 - discoverEnhanced: 42730 + discoverEnhanced: 6000 discoverShared: 17111 embeddable: 24000 embeddableEnhanced: 22107 diff --git a/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/abstract_explore_data_action.ts b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/abstract_explore_data_action.ts index afee162ad8257..a2f3ead98e077 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/abstract_explore_data_action.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/abstract_explore_data_action.ts @@ -28,8 +28,6 @@ import { KibanaLocation } from '@kbn/share-plugin/public'; import * as shared from './shared'; -export const ACTION_EXPLORE_DATA = 'ACTION_EXPLORE_DATA'; - export interface PluginDeps { discover: Pick; } diff --git a/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/index.ts b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/constants.ts similarity index 66% rename from x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/index.ts rename to x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/constants.ts index 71a7f57057988..5b638a27951df 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/index.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/constants.ts @@ -5,5 +5,5 @@ * 2.0. */ -export * from './explore_data_context_menu_action'; -export * from './explore_data_chart_action'; +export const ACTION_EXPLORE_DATA_CHART = 'ACTION_EXPLORE_DATA_CHART'; +export const ACTION_EXPLORE_DATA = 'ACTION_EXPLORE_DATA'; diff --git a/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/explore_data_chart_action.ts b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/explore_data_chart_action.ts index 668ec9bffbe5f..a4ec8af18fa56 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/explore_data_chart_action.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/explore_data_chart_action.ts @@ -15,8 +15,7 @@ import { KibanaLocation } from '@kbn/share-plugin/public'; import { Action } from '@kbn/ui-actions-plugin/public'; import { ApplyGlobalFilterActionContext } from '@kbn/unified-search-plugin/public'; import { AbstractExploreDataAction } from './abstract_explore_data_action'; - -export const ACTION_EXPLORE_DATA_CHART = 'ACTION_EXPLORE_DATA_CHART'; +import { ACTION_EXPLORE_DATA_CHART } from './constants'; export interface ExploreDataChartActionContext extends ApplyGlobalFilterActionContext { embeddable: Partial & diff --git a/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/explore_data_context_menu_action.ts b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/explore_data_context_menu_action.ts index 0ea8534c1f88a..92b8116d93f91 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/explore_data_context_menu_action.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/explore_data_context_menu_action.ts @@ -7,8 +7,7 @@ import { EmbeddableApiContext } from '@kbn/presentation-publishing'; import { Action } from '@kbn/ui-actions-plugin/public'; import { AbstractExploreDataAction } from './abstract_explore_data_action'; - -export const ACTION_EXPLORE_DATA = 'ACTION_EXPLORE_DATA'; +import { ACTION_EXPLORE_DATA } from './constants'; /** * This is "Explore underlying data" action which appears in the context diff --git a/x-pack/platform/plugins/private/discover_enhanced/public/actions/index.ts b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/module.ts similarity index 62% rename from x-pack/platform/plugins/private/discover_enhanced/public/actions/index.ts rename to x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/module.ts index 00751a44494b6..3cd4d01fa77a9 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/public/actions/index.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/public/actions/explore_data/module.ts @@ -5,4 +5,5 @@ * 2.0. */ -export * from './explore_data'; +export { ExploreDataChartAction } from './explore_data_chart_action'; +export { ExploreDataContextMenuAction } from './explore_data_context_menu_action'; diff --git a/x-pack/platform/plugins/private/discover_enhanced/public/index.ts b/x-pack/platform/plugins/private/discover_enhanced/public/index.ts index da1a00bc059ca..abc946d7fcd1d 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/public/index.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/public/index.ts @@ -8,8 +8,6 @@ import type { PluginInitializerContext } from '@kbn/core/public'; import { DiscoverEnhancedPlugin } from './plugin'; -export type { ExploreDataContextMenuAction, ExploreDataChartAction } from './actions'; - export type { DiscoverEnhancedPlugin, DiscoverEnhancedSetupDependencies, diff --git a/x-pack/platform/plugins/private/discover_enhanced/public/plugin.ts b/x-pack/platform/plugins/private/discover_enhanced/public/plugin.ts index e1fd9e0c74951..ac8bb03b60dab 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/public/plugin.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/public/plugin.ts @@ -17,8 +17,8 @@ import { EmbeddableStart, CONTEXT_MENU_TRIGGER, } from '@kbn/embeddable-plugin/public'; -import { ExploreDataContextMenuAction, ExploreDataChartAction } from './actions'; import { Config } from '../common'; +import { ACTION_EXPLORE_DATA, ACTION_EXPLORE_DATA_CHART } from './actions/explore_data/constants'; export interface DiscoverEnhancedSetupDependencies { discover: DiscoverSetup; @@ -55,13 +55,21 @@ export class DiscoverEnhancedPlugin const params = { start }; if (this.config.actions.exploreDataInContextMenu.enabled) { - const exploreDataAction = new ExploreDataContextMenuAction(params); - uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, exploreDataAction); + uiActions.addTriggerActionAsync(CONTEXT_MENU_TRIGGER, ACTION_EXPLORE_DATA, async () => { + const { ExploreDataContextMenuAction } = await import('./actions/explore_data/module'); + return new ExploreDataContextMenuAction(params); + }); } if (this.config.actions.exploreDataInChart.enabled) { - const exploreDataChartAction = new ExploreDataChartAction(params); - uiActions.addTriggerAction(APPLY_FILTER_TRIGGER, exploreDataChartAction); + uiActions.addTriggerActionAsync( + APPLY_FILTER_TRIGGER, + ACTION_EXPLORE_DATA_CHART, + async () => { + const { ExploreDataChartAction } = await import('./actions/explore_data/module'); + return new ExploreDataChartAction(params); + } + ); } } } From 33ea4313c288ec85cb924a3fdcae8265f1cd8811 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 5 Mar 2025 21:51:10 +0000 Subject: [PATCH 8/8] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../embeddable/actions/view_discover_session_action.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.test.ts b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.test.ts index 7d292d840f875..de42c4aa14d13 100644 --- a/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.test.ts +++ b/src/platform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.test.ts @@ -53,7 +53,7 @@ describe('view saved search action', () => { const action = getViewDiscoverSessionAction(applicationMock, services.locator); expect( await action.isCompatible?.({ - embeddable: { ...compatibleEmbeddableApi, viewMode$: new BehaviorSubject('edit') } + embeddable: { ...compatibleEmbeddableApi, viewMode$: new BehaviorSubject('edit') }, }) ).toBe(false); });