From 4a737da5188bebfaa1eeced9f0f20b7024c114ac Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 07:19:19 -0700 Subject: [PATCH 01/16] lazy load visualizations actions --- .../public/actions/actions_module.ts | 11 ++++++++ .../public/actions/constants.ts | 0 .../public/actions/edit_in_lens_action.tsx | 3 +-- .../public/actions/register_actions.ts | 26 +++++++++++++++++++ .../shared/visualizations/public/plugin.ts | 12 +++------ 5 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 src/platform/plugins/shared/visualizations/public/actions/actions_module.ts create mode 100644 src/platform/plugins/shared/visualizations/public/actions/constants.ts create mode 100644 src/platform/plugins/shared/visualizations/public/actions/register_actions.ts diff --git a/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts b/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts new file mode 100644 index 0000000000000..647d6b4cb582a --- /dev/null +++ b/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts @@ -0,0 +1,11 @@ +/* + * 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 { EditInLensAction } from './edit_in_lens_action'; +export { AddAggVisualizationPanelAction } from './add_agg_vis_action'; \ No newline at end of file diff --git a/src/platform/plugins/shared/visualizations/public/actions/constants.ts b/src/platform/plugins/shared/visualizations/public/actions/constants.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/platform/plugins/shared/visualizations/public/actions/edit_in_lens_action.tsx b/src/platform/plugins/shared/visualizations/public/actions/edit_in_lens_action.tsx index f8ed7a6294dbf..6a68a2b23502e 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/edit_in_lens_action.tsx +++ b/src/platform/plugins/shared/visualizations/public/actions/edit_in_lens_action.tsx @@ -42,8 +42,7 @@ import { getUsageCollection, } from '../services'; import { DASHBOARD_VISUALIZATION_PANEL_TRIGGER } from '../triggers'; - -export const ACTION_EDIT_IN_LENS = 'ACTION_EDIT_IN_LENS'; +import { ACTION_EDIT_IN_LENS } from './constants'; const displayName = i18n.translate('visualizations.actions.editInLens.displayName', { defaultMessage: 'Convert to Lens', diff --git a/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts b/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts new file mode 100644 index 0000000000000..e3256dfbd1af0 --- /dev/null +++ b/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts @@ -0,0 +1,26 @@ +/* + * 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 { DataPublicPluginStart } from "@kbn/data-plugin/public"; +import { CONTEXT_MENU_TRIGGER } from "@kbn/embeddable-plugin/public"; +import { ADD_PANEL_TRIGGER, type UiActionsStart } from "@kbn/ui-actions-plugin/public"; +import { ACTION_EDIT_IN_LENS, ADD_AGG_VIS_ACTION_ID } from "./constants"; +import { TypesStart } from "../vis_types/types_service"; + +export function registerActions(uiActions: UiActionsStart, data: DataPublicPluginStart, types: TypesStart) { + uiActions.addTriggerActionAsync(CONTEXT_MENU_TRIGGER, ACTION_EDIT_IN_LENS, async () => { + const { EditInLensAction } = await import('./actions_module'); + return new EditInLensAction(data.query.timefilter.timefilter); + }); + + uiActions.addTriggerActionAsync(ADD_PANEL_TRIGGER, ADD_AGG_VIS_ACTION_ID, async () => { + const { AddAggVisualizationPanelAction } = await import('./actions_module'); + return new AddAggVisualizationPanelAction(types); + }); +} \ No newline at end of file diff --git a/src/platform/plugins/shared/visualizations/public/plugin.ts b/src/platform/plugins/shared/visualizations/public/plugin.ts index 0dcbf78c399da..fafa7c0ab98aa 100644 --- a/src/platform/plugins/shared/visualizations/public/plugin.ts +++ b/src/platform/plugins/shared/visualizations/public/plugin.ts @@ -37,7 +37,7 @@ import type { ApplicationStart, SavedObjectsClientContract, } from '@kbn/core/public'; -import { UiActionsStart, UiActionsSetup, ADD_PANEL_TRIGGER } from '@kbn/ui-actions-plugin/public'; +import { UiActionsStart, UiActionsSetup } from '@kbn/ui-actions-plugin/public'; import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; import type { Setup as InspectorSetup, @@ -48,7 +48,6 @@ import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plu import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; import type { ExpressionsSetup, ExpressionsStart } from '@kbn/expressions-plugin/public'; import { - CONTEXT_MENU_TRIGGER, EmbeddableSetup, EmbeddableStart, } from '@kbn/embeddable-plugin/public'; @@ -119,16 +118,16 @@ import { setNotifications, } from './services'; import { VisualizeConstants, VISUALIZE_EMBEDDABLE_TYPE } from '../common/constants'; -import { EditInLensAction } from './actions/edit_in_lens_action'; import { ListingViewRegistry } from './types'; import { LATEST_VERSION, CONTENT_ID, VisualizationSavedObjectAttributes, } from '../common/content_management'; -import { AddAggVisualizationPanelAction } from './actions/add_agg_vis_action'; + import type { VisualizeSerializedState } from './embeddable/types'; import { getVisualizeEmbeddableFactoryLazy } from './embeddable'; +import { registerActions } from './actions/register_actions'; /** * Interface for this plugin's returned setup/start contracts. @@ -403,8 +402,6 @@ export class VisualizationsPlugin uiActions.registerTrigger(aggBasedVisualizationTrigger); uiActions.registerTrigger(visualizeEditorTrigger); uiActions.registerTrigger(dashboardVisualizationPanelTrigger); - const editInLensAction = new EditInLensAction(data.query.timefilter.timefilter); - uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, editInLensAction); embeddable.registerReactEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, async () => { const { plugins: { embeddable: embeddableStart, embeddableEnhanced: embeddableEnhancedStart }, @@ -498,8 +495,7 @@ export class VisualizationsPlugin setSavedObjectTagging(savedObjectsTaggingOss); } - const addAggVisAction = new AddAggVisualizationPanelAction(types); - uiActions.addTriggerAction(ADD_PANEL_TRIGGER, addAggVisAction); + registerActions(uiActions, data, types); return { ...types, From d5314620deb0848ddd62b9f10cc1d6f8444301ca Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 07:31:24 -0700 Subject: [PATCH 02/16] remove presenetation publishing page load import --- .../public/actions/actions_module.ts | 2 +- .../visualizations/public/actions/constants.ts | 8 ++++++++ .../public/actions/register_actions.ts | 18 +++++++++++------- .../interfaces/has_visualize_config.ts | 4 ++-- .../shared/visualizations/public/index.ts | 2 +- .../shared/visualizations/public/plugin.ts | 5 +---- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts b/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts index 647d6b4cb582a..be13e44698a04 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts +++ b/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts @@ -8,4 +8,4 @@ */ export { EditInLensAction } from './edit_in_lens_action'; -export { AddAggVisualizationPanelAction } from './add_agg_vis_action'; \ No newline at end of file +export { AddAggVisualizationPanelAction } from './add_agg_vis_action'; diff --git a/src/platform/plugins/shared/visualizations/public/actions/constants.ts b/src/platform/plugins/shared/visualizations/public/actions/constants.ts index e69de29bb2d1d..ad21076a9ca93 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/constants.ts +++ b/src/platform/plugins/shared/visualizations/public/actions/constants.ts @@ -0,0 +1,8 @@ +/* + * 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". + */ diff --git a/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts b/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts index e3256dfbd1af0..9d0a84db9d82e 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts +++ b/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts @@ -7,13 +7,17 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { DataPublicPluginStart } from "@kbn/data-plugin/public"; -import { CONTEXT_MENU_TRIGGER } from "@kbn/embeddable-plugin/public"; -import { ADD_PANEL_TRIGGER, type UiActionsStart } from "@kbn/ui-actions-plugin/public"; -import { ACTION_EDIT_IN_LENS, ADD_AGG_VIS_ACTION_ID } from "./constants"; -import { TypesStart } from "../vis_types/types_service"; +import { DataPublicPluginStart } from '@kbn/data-plugin/public'; +import { CONTEXT_MENU_TRIGGER } from '@kbn/embeddable-plugin/public'; +import { ADD_PANEL_TRIGGER, type UiActionsStart } from '@kbn/ui-actions-plugin/public'; +import { ACTION_EDIT_IN_LENS, ADD_AGG_VIS_ACTION_ID } from './constants'; +import { TypesStart } from '../vis_types/types_service'; -export function registerActions(uiActions: UiActionsStart, data: DataPublicPluginStart, types: TypesStart) { +export function registerActions( + uiActions: UiActionsStart, + data: DataPublicPluginStart, + types: TypesStart +) { uiActions.addTriggerActionAsync(CONTEXT_MENU_TRIGGER, ACTION_EDIT_IN_LENS, async () => { const { EditInLensAction } = await import('./actions_module'); return new EditInLensAction(data.query.timefilter.timefilter); @@ -23,4 +27,4 @@ export function registerActions(uiActions: UiActionsStart, data: DataPublicPlugi const { AddAggVisualizationPanelAction } = await import('./actions_module'); return new AddAggVisualizationPanelAction(types); }); -} \ No newline at end of file +} diff --git a/src/platform/plugins/shared/visualizations/public/embeddable/interfaces/has_visualize_config.ts b/src/platform/plugins/shared/visualizations/public/embeddable/interfaces/has_visualize_config.ts index 5de80db0346cd..cb1b16095846c 100644 --- a/src/platform/plugins/shared/visualizations/public/embeddable/interfaces/has_visualize_config.ts +++ b/src/platform/plugins/shared/visualizations/public/embeddable/interfaces/has_visualize_config.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { type HasType, apiIsOfType } from '@kbn/presentation-publishing'; +import type { HasType } from '@kbn/presentation-publishing'; import { VisParams } from '../../types'; import Vis from '../../vis'; @@ -18,7 +18,7 @@ export type HasVisualizeConfig = HasType<'visualization'> & { export const apiHasVisualizeConfig = (api: unknown): api is HasVisualizeConfig => { return Boolean( api && - apiIsOfType(api, 'visualization') && + (api as HasType)?.type === 'visualization' && typeof (api as HasVisualizeConfig).getVis === 'function' ); }; diff --git a/src/platform/plugins/shared/visualizations/public/index.ts b/src/platform/plugins/shared/visualizations/public/index.ts index 4c3dc07a9eb5d..d6a94e3fbc6dd 100644 --- a/src/platform/plugins/shared/visualizations/public/index.ts +++ b/src/platform/plugins/shared/visualizations/public/index.ts @@ -19,7 +19,7 @@ export function plugin(initializerContext: PluginInitializerContext) { /** @public static code */ export { TypesService } from './vis_types/types_service'; export { VIS_EVENT_TO_TRIGGER } from './embeddable'; -export { apiHasVisualizeConfig } from './embeddable/interfaces/has_visualize_config'; +// export { apiHasVisualizeConfig } from './embeddable/interfaces/has_visualize_config'; export { COMMON_VISUALIZATION_GROUPING } from './legacy/embeddable/constants'; export { VisualizationContainer } from './components'; export { getVisSchemas } from './vis_schemas'; diff --git a/src/platform/plugins/shared/visualizations/public/plugin.ts b/src/platform/plugins/shared/visualizations/public/plugin.ts index fafa7c0ab98aa..14a71247b55d2 100644 --- a/src/platform/plugins/shared/visualizations/public/plugin.ts +++ b/src/platform/plugins/shared/visualizations/public/plugin.ts @@ -47,10 +47,7 @@ import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public'; import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; import type { ExpressionsSetup, ExpressionsStart } from '@kbn/expressions-plugin/public'; -import { - EmbeddableSetup, - EmbeddableStart, -} from '@kbn/embeddable-plugin/public'; +import { EmbeddableSetup, EmbeddableStart } from '@kbn/embeddable-plugin/public'; import type { SavedObjectTaggingOssPluginStart } from '@kbn/saved-objects-tagging-oss-plugin/public'; import type { NavigationPublicPluginStart as NavigationStart } from '@kbn/navigation-plugin/public'; import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; From 38a03275209c78cf5a0f8d2bec7281341ff4fe8e Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 07:40:39 -0700 Subject: [PATCH 03/16] avoid exporting saved_visualize_utils in page load --- .../public/embeddable/initialize_edit_api.ts | 2 +- .../plugins/shared/visualizations/public/index.ts | 9 ++++++++- .../embeddable/create_vis_embeddable_from_object.ts | 2 +- .../visualizations/public/utils/saved_visualize_utils.ts | 9 +-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/platform/plugins/shared/visualizations/public/embeddable/initialize_edit_api.ts b/src/platform/plugins/shared/visualizations/public/embeddable/initialize_edit_api.ts index 818847a6e92d6..5884d8d0cd155 100644 --- a/src/platform/plugins/shared/visualizations/public/embeddable/initialize_edit_api.ts +++ b/src/platform/plugins/shared/visualizations/public/embeddable/initialize_edit_api.ts @@ -15,7 +15,7 @@ import { } from '@kbn/presentation-publishing'; import { TimeRange } from '@kbn/es-query'; import type { Vis } from '../vis'; -import { urlFor } from '../utils/saved_visualize_utils'; +import { urlFor } from '..'; import { getCapabilities, getEmbeddable } from '../services'; export function initializeEditApi({ diff --git a/src/platform/plugins/shared/visualizations/public/index.ts b/src/platform/plugins/shared/visualizations/public/index.ts index d6a94e3fbc6dd..a5f1536351193 100644 --- a/src/platform/plugins/shared/visualizations/public/index.ts +++ b/src/platform/plugins/shared/visualizations/public/index.ts @@ -73,7 +73,14 @@ export type { FakeParams, HistogramParams, } from '../common/expression_functions/xy_dimension'; -export { urlFor, getFullPath } from './utils/saved_visualize_utils'; + +export function getFullPath(id: string) { + return `/app/visualize#/edit/${id}`; +} + +export function urlFor(id: string) { + return `#/edit/${encodeURIComponent(id)}`; +} export type { IEditorController, EditorRenderProps } from './visualize_app/types'; diff --git a/src/platform/plugins/shared/visualizations/public/legacy/embeddable/create_vis_embeddable_from_object.ts b/src/platform/plugins/shared/visualizations/public/legacy/embeddable/create_vis_embeddable_from_object.ts index 843aa51731abc..774c3851dab3d 100644 --- a/src/platform/plugins/shared/visualizations/public/legacy/embeddable/create_vis_embeddable_from_object.ts +++ b/src/platform/plugins/shared/visualizations/public/legacy/embeddable/create_vis_embeddable_from_object.ts @@ -18,7 +18,7 @@ import type { VisualizeEmbeddableDeps, } from './visualize_embeddable'; import { getHttp, getTimeFilter, getCapabilities } from '../../services'; -import { urlFor } from '../../utils/saved_visualize_utils'; +import { urlFor } from '../..'; import { createVisualizeEmbeddableAsync } from './visualize_embeddable_async'; import { AttributeService } from './attribute_service'; import { ErrorEmbeddable } from './error_embeddable'; diff --git a/src/platform/plugins/shared/visualizations/public/utils/saved_visualize_utils.ts b/src/platform/plugins/shared/visualizations/public/utils/saved_visualize_utils.ts index 3c8f17f49e397..a18b9f888b947 100644 --- a/src/platform/plugins/shared/visualizations/public/utils/saved_visualize_utils.ts +++ b/src/platform/plugins/shared/visualizations/public/utils/saved_visualize_utils.ts @@ -36,6 +36,7 @@ import { injectReferences, extractReferences } from './saved_visualization_refer import { OVERWRITE_REJECTED, SAVE_DUPLICATE_REJECTED } from './saved_objects_utils/constants'; import { visualizationsClient } from '../content_management'; import { VisualizationSavedObjectAttributes } from '../../common'; +import { urlFor } from '..'; export const SAVED_VIS_TYPE = 'visualization'; @@ -48,14 +49,6 @@ const getDefaults = (opts: GetVisOptions) => ({ version: 1, }); -export function getFullPath(id: string) { - return `/app/visualize#/edit/${id}`; -} - -export function urlFor(id: string) { - return `#/edit/${encodeURIComponent(id)}`; -} - export function mapHitSource( visTypes: Pick, { From 771686307b810ca09ade1c4ad6b307fe866ab0d2 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 07:48:25 -0700 Subject: [PATCH 04/16] avoid exporting legacy/vis_update_state from page load --- .../timeseries/public/vis_state.test.ts | 6 ++--- .../shared/visualizations/public/index.ts | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts b/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts index b9e3e28f4c42b..e5926a23c95ff 100644 --- a/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts +++ b/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts @@ -17,8 +17,8 @@ import { updateOldState } from '@kbn/visualizations-plugin/public'; * by adding an x prefix. Number ids are never been generated from the editor, only programmatically. * See https://github.com/elastic/kibana/issues/113601. */ -describe('TimeseriesVisState', () => { - test('should format the TSVB visState correctly', () => { +describe('TimeseriesVisState', async () => { + test('should format the TSVB visState correctly', async () => { const visState = { title: 'test', type: 'metrics', @@ -71,7 +71,7 @@ describe('TimeseriesVisState', () => { }, }, }; - const newVisState = updateOldState(visState); + const newVisState = await updateOldState(visState); expect(newVisState).toEqual({ aggs: [], params: { diff --git a/src/platform/plugins/shared/visualizations/public/index.ts b/src/platform/plugins/shared/visualizations/public/index.ts index a5f1536351193..c5157ebfd5f30 100644 --- a/src/platform/plugins/shared/visualizations/public/index.ts +++ b/src/platform/plugins/shared/visualizations/public/index.ts @@ -19,11 +19,24 @@ export function plugin(initializerContext: PluginInitializerContext) { /** @public static code */ export { TypesService } from './vis_types/types_service'; export { VIS_EVENT_TO_TRIGGER } from './embeddable'; -// export { apiHasVisualizeConfig } from './embeddable/interfaces/has_visualize_config'; +export { apiHasVisualizeConfig } from './embeddable/interfaces/has_visualize_config'; export { COMMON_VISUALIZATION_GROUPING } from './legacy/embeddable/constants'; export { VisualizationContainer } from './components'; export { getVisSchemas } from './vis_schemas'; +export function getFullPath(id: string) { + return `/app/visualize#/edit/${id}`; +} + +export function urlFor(id: string) { + return `#/edit/${encodeURIComponent(id)}`; +} + +export async function updateOldState(oldState: unknown) { + const { updateOldState } = await import('./legacy/vis_update_state'); + return updateOldState(oldState); +} + /** @public types */ export type { VisualizationsSetup, VisualizationsStart }; export { VisGroups } from './vis_types/vis_groups_enum'; @@ -40,7 +53,7 @@ export type { VisualizeEditorInput } from './embeddable/types'; export type { Vis, SerializedVis, SerializedVisData, VisData } from './vis'; export type VisualizeEmbeddableContract = PublicContract; export type { SchemaConfig } from '../common/types'; -export { updateOldState } from './legacy/vis_update_state'; + export type { VisualizeInput, VisualizeEmbeddable } from './legacy/embeddable'; export type { HasVisualizeConfig } from './embeddable/interfaces/has_visualize_config'; export type { PersistedState } from './persisted_state'; @@ -74,14 +87,6 @@ export type { HistogramParams, } from '../common/expression_functions/xy_dimension'; -export function getFullPath(id: string) { - return `/app/visualize#/edit/${id}`; -} - -export function urlFor(id: string) { - return `#/edit/${encodeURIComponent(id)}`; -} - export type { IEditorController, EditorRenderProps } from './visualize_app/types'; export { From 12d3a91f718991497b37cef60c06035a6cd24c20 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 07:50:50 -0700 Subject: [PATCH 05/16] unsaved changes --- .../plugins/shared/visualizations/public/actions/constants.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/platform/plugins/shared/visualizations/public/actions/constants.ts b/src/platform/plugins/shared/visualizations/public/actions/constants.ts index ad21076a9ca93..1443548bffafe 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/constants.ts +++ b/src/platform/plugins/shared/visualizations/public/actions/constants.ts @@ -6,3 +6,6 @@ * 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 ADD_AGG_VIS_ACTION_ID = 'ADD_AGG_VIS'; +export const ACTION_EDIT_IN_LENS = 'ACTION_EDIT_IN_LENS'; \ No newline at end of file From a7f89485bf8f97ff5d2193c510d02ce33fc3a0c4 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 07:51:43 -0700 Subject: [PATCH 06/16] more unsaved changes --- .../shared/visualizations/public/actions/add_agg_vis_action.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/platform/plugins/shared/visualizations/public/actions/add_agg_vis_action.ts b/src/platform/plugins/shared/visualizations/public/actions/add_agg_vis_action.ts index cd3faa92d7787..f4379a97a0c62 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/add_agg_vis_action.ts +++ b/src/platform/plugins/shared/visualizations/public/actions/add_agg_vis_action.ts @@ -21,8 +21,7 @@ import { apiCanAddNewPanel, CanAddNewPanel } from '@kbn/presentation-containers' import { VisGroups } from '../vis_types/vis_groups_enum'; import type { TypesStart } from '../vis_types/types_service'; import { showNewVisModal } from '../wizard/show_new_vis'; - -export const ADD_AGG_VIS_ACTION_ID = 'ADD_AGG_VIS'; +import { ADD_AGG_VIS_ACTION_ID } from './constants'; export type AddAggVisualizationPanelActionApi = HasType & CanAddNewPanel & HasAppContext; From 369600f0da100c01d2169e54e346ee3c22d99ff4 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 08:00:55 -0700 Subject: [PATCH 07/16] clean up --- .../get_visualize_embeddable_factory_lazy.ts | 13 ------------- .../visualizations/public/embeddable/index.ts | 11 ----------- .../plugins/shared/visualizations/public/index.ts | 2 +- .../plugins/shared/visualizations/public/plugin.ts | 4 +--- 4 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 src/platform/plugins/shared/visualizations/public/embeddable/get_visualize_embeddable_factory_lazy.ts delete mode 100644 src/platform/plugins/shared/visualizations/public/embeddable/index.ts diff --git a/src/platform/plugins/shared/visualizations/public/embeddable/get_visualize_embeddable_factory_lazy.ts b/src/platform/plugins/shared/visualizations/public/embeddable/get_visualize_embeddable_factory_lazy.ts deleted file mode 100644 index b14d03ec5030c..0000000000000 --- a/src/platform/plugins/shared/visualizations/public/embeddable/get_visualize_embeddable_factory_lazy.ts +++ /dev/null @@ -1,13 +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". - */ - -export const getVisualizeEmbeddableFactoryLazy = async () => { - const { getVisualizeEmbeddableFactory } = await import('./visualize_embeddable'); - return getVisualizeEmbeddableFactory; -}; diff --git a/src/platform/plugins/shared/visualizations/public/embeddable/index.ts b/src/platform/plugins/shared/visualizations/public/embeddable/index.ts deleted file mode 100644 index 6d1649771c8ef..0000000000000 --- a/src/platform/plugins/shared/visualizations/public/embeddable/index.ts +++ /dev/null @@ -1,11 +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". - */ - -export { getVisualizeEmbeddableFactoryLazy } from './get_visualize_embeddable_factory_lazy'; -export { VIS_EVENT_TO_TRIGGER } from './events'; diff --git a/src/platform/plugins/shared/visualizations/public/index.ts b/src/platform/plugins/shared/visualizations/public/index.ts index c5157ebfd5f30..b2302d9fc31e2 100644 --- a/src/platform/plugins/shared/visualizations/public/index.ts +++ b/src/platform/plugins/shared/visualizations/public/index.ts @@ -18,7 +18,7 @@ export function plugin(initializerContext: PluginInitializerContext) { /** @public static code */ export { TypesService } from './vis_types/types_service'; -export { VIS_EVENT_TO_TRIGGER } from './embeddable'; +export { VIS_EVENT_TO_TRIGGER } from './embeddable/events'; export { apiHasVisualizeConfig } from './embeddable/interfaces/has_visualize_config'; export { COMMON_VISUALIZATION_GROUPING } from './legacy/embeddable/constants'; export { VisualizationContainer } from './components'; diff --git a/src/platform/plugins/shared/visualizations/public/plugin.ts b/src/platform/plugins/shared/visualizations/public/plugin.ts index 14a71247b55d2..ca4634fdefe93 100644 --- a/src/platform/plugins/shared/visualizations/public/plugin.ts +++ b/src/platform/plugins/shared/visualizations/public/plugin.ts @@ -121,9 +121,7 @@ import { CONTENT_ID, VisualizationSavedObjectAttributes, } from '../common/content_management'; - import type { VisualizeSerializedState } from './embeddable/types'; -import { getVisualizeEmbeddableFactoryLazy } from './embeddable'; import { registerActions } from './actions/register_actions'; /** @@ -404,7 +402,7 @@ export class VisualizationsPlugin plugins: { embeddable: embeddableStart, embeddableEnhanced: embeddableEnhancedStart }, } = start(); - const getVisualizeEmbeddableFactory = await getVisualizeEmbeddableFactoryLazy(); + const { getVisualizeEmbeddableFactory } = await import('./embeddable/visualize_embeddable'); return getVisualizeEmbeddableFactory({ embeddableStart, embeddableEnhancedStart }); }); embeddable.registerAddFromLibraryType({ From 5b763ade0939b0a4a6dad96e87e326a40d294be2 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 08:09:46 -0700 Subject: [PATCH 08/16] clean up imports --- src/platform/plugins/shared/visualizations/public/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platform/plugins/shared/visualizations/public/index.ts b/src/platform/plugins/shared/visualizations/public/index.ts index b2302d9fc31e2..4b7bd7b8c0cdb 100644 --- a/src/platform/plugins/shared/visualizations/public/index.ts +++ b/src/platform/plugins/shared/visualizations/public/index.ts @@ -23,6 +23,8 @@ export { apiHasVisualizeConfig } from './embeddable/interfaces/has_visualize_con export { COMMON_VISUALIZATION_GROUPING } from './legacy/embeddable/constants'; export { VisualizationContainer } from './components'; export { getVisSchemas } from './vis_schemas'; +export { prepareLogTable } from '../common/utils/prepare_log_table'; +export { XYCurveTypes } from '../common/convert_to_lens/constants'; export function getFullPath(id: string) { return `/app/visualize#/edit/${id}`; @@ -78,7 +80,6 @@ export { VISUALIZE_EMBEDDABLE_TYPE, } from '../common/constants'; export type { SavedVisState, VisParams, Dimension } from '../common'; -export { prepareLogTable, XYCurveTypes } from '../common'; export type { ExpressionValueVisDimension } from '../common/expression_functions/vis_dimension'; export type { ExpressionValueXYDimension, From a6ffda88d47f603f973303f769c7634f24898aee Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 08:12:32 -0700 Subject: [PATCH 09/16] clean up test --- .../shared/vis_types/timeseries/public/vis_state.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts b/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts index e5926a23c95ff..3346eb140ce7d 100644 --- a/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts +++ b/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts @@ -17,7 +17,7 @@ import { updateOldState } from '@kbn/visualizations-plugin/public'; * by adding an x prefix. Number ids are never been generated from the editor, only programmatically. * See https://github.com/elastic/kibana/issues/113601. */ -describe('TimeseriesVisState', async () => { +describe('TimeseriesVisState', () => { test('should format the TSVB visState correctly', async () => { const visState = { title: 'test', From c553c90798d12562f0e0807a1250c35dc318abae Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:36:16 +0000 Subject: [PATCH 10/16] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../plugins/shared/visualizations/public/actions/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/plugins/shared/visualizations/public/actions/constants.ts b/src/platform/plugins/shared/visualizations/public/actions/constants.ts index 1443548bffafe..77ea107e7a867 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/constants.ts +++ b/src/platform/plugins/shared/visualizations/public/actions/constants.ts @@ -8,4 +8,4 @@ */ export const ADD_AGG_VIS_ACTION_ID = 'ADD_AGG_VIS'; -export const ACTION_EDIT_IN_LENS = 'ACTION_EDIT_IN_LENS'; \ No newline at end of file +export const ACTION_EDIT_IN_LENS = 'ACTION_EDIT_IN_LENS'; From 3af143dc547be2662eb73c6ffae3d32e04d34b14 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 09:36:12 -0700 Subject: [PATCH 11/16] tslint --- .../visualizations/public/actions/add_agg_vis_action.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/platform/plugins/shared/visualizations/public/actions/add_agg_vis_action.test.ts b/src/platform/plugins/shared/visualizations/public/actions/add_agg_vis_action.test.ts index e8311224ce32c..f97ed7e4c9e41 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/add_agg_vis_action.test.ts +++ b/src/platform/plugins/shared/visualizations/public/actions/add_agg_vis_action.test.ts @@ -9,7 +9,6 @@ import { AddAggVisualizationPanelAction, - ADD_AGG_VIS_ACTION_ID, type AddAggVisualizationPanelActionApi, } from './add_agg_vis_action'; import type { BaseVisType } from '../vis_types/base_vis_type'; @@ -17,7 +16,7 @@ import { VisGroups } from '../vis_types/vis_groups_enum'; import { TypesService, type TypesStart } from '../vis_types/types_service'; const mockCompatibleEmbeddableAPI: AddAggVisualizationPanelActionApi = { - type: ADD_AGG_VIS_ACTION_ID, + type: 'anyEmbeddable', addNewPanel: jest.fn(), getAppContext: jest.fn(), }; From b67ff3de0da2e6eae5c9b7eaf370dc3bbb62206f Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 09:37:03 -0700 Subject: [PATCH 12/16] limits.yml --- 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 6f31687b36bac..c33cf780a705c 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -195,5 +195,5 @@ pageLoadAssetSize: visTypeVega: 153573 visTypeVislib: 242838 visTypeXy: 46868 - visualizations: 90000 + visualizations: 40000 watcher: 43598 From 0b5e490ad29803a5f01996457474c9aa4d1dce55 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 12:34:32 -0700 Subject: [PATCH 13/16] tslint --- .../shared/vis_types/timeseries/public/vis_state.test.ts | 6 +++--- src/platform/plugins/shared/visualizations/public/index.ts | 5 ----- .../editor_frame/workspace_panel/workspace_panel.test.tsx | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts b/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts index 3346eb140ce7d..b45a777a12467 100644 --- a/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts +++ b/src/platform/plugins/shared/vis_types/timeseries/public/vis_state.test.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { updateOldState } from '@kbn/visualizations-plugin/public'; +import { updateOldState } from '@kbn/visualizations-plugin/public/legacy/vis_update_state'; /** * The reason we add this test is to ensure that `convertNumIdsToStringsForTSVB` of the updateOldState runs correctly @@ -18,7 +18,7 @@ import { updateOldState } from '@kbn/visualizations-plugin/public'; * See https://github.com/elastic/kibana/issues/113601. */ describe('TimeseriesVisState', () => { - test('should format the TSVB visState correctly', async () => { + test('should format the TSVB visState correctly', () => { const visState = { title: 'test', type: 'metrics', @@ -71,7 +71,7 @@ describe('TimeseriesVisState', () => { }, }, }; - const newVisState = await updateOldState(visState); + const newVisState = updateOldState(visState); expect(newVisState).toEqual({ aggs: [], params: { diff --git a/src/platform/plugins/shared/visualizations/public/index.ts b/src/platform/plugins/shared/visualizations/public/index.ts index 4b7bd7b8c0cdb..6ac6cb46eb9c5 100644 --- a/src/platform/plugins/shared/visualizations/public/index.ts +++ b/src/platform/plugins/shared/visualizations/public/index.ts @@ -34,11 +34,6 @@ export function urlFor(id: string) { return `#/edit/${encodeURIComponent(id)}`; } -export async function updateOldState(oldState: unknown) { - const { updateOldState } = await import('./legacy/vis_update_state'); - return updateOldState(oldState); -} - /** @public types */ export type { VisualizationsSetup, VisualizationsStart }; export { VisGroups } from './vis_types/vis_groups_enum'; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index e44e528e5a33c..b57d5dc022a53 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -28,7 +28,7 @@ import { DataView } from '@kbn/data-views-plugin/public'; import type { FieldSpec } from '@kbn/data-plugin/common'; import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; import { TriggerContract } from '@kbn/ui-actions-plugin/public/triggers'; -import { VIS_EVENT_TO_TRIGGER } from '@kbn/visualizations-plugin/public/embeddable'; +import { VIS_EVENT_TO_TRIGGER } from '@kbn/visualizations-plugin/public/embeddable/events'; import { applyChanges, setState, From 17f52e1cb92dc912fca1abf5424d0386a58d9f17 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sat, 18 Jan 2025 14:25:24 -0700 Subject: [PATCH 14/16] 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 c33cf780a705c..80fa0ffc71f4f 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -195,5 +195,5 @@ pageLoadAssetSize: visTypeVega: 153573 visTypeVislib: 242838 visTypeXy: 46868 - visualizations: 40000 + visualizations: 41000 watcher: 43598 From ad4f6e6c04e91fe752841d50cc7d0cce4939310b Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Sun, 19 Jan 2025 08:16:33 -0700 Subject: [PATCH 15/16] fix jest test --- .../shared/visualizations/public/index.ts | 9 +-------- .../public/utils/saved_visualize_utils.ts | 2 +- .../visualizations/public/utils/url_utils.ts | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 src/platform/plugins/shared/visualizations/public/utils/url_utils.ts diff --git a/src/platform/plugins/shared/visualizations/public/index.ts b/src/platform/plugins/shared/visualizations/public/index.ts index 6ac6cb46eb9c5..58b30592ee29e 100644 --- a/src/platform/plugins/shared/visualizations/public/index.ts +++ b/src/platform/plugins/shared/visualizations/public/index.ts @@ -25,14 +25,7 @@ export { VisualizationContainer } from './components'; export { getVisSchemas } from './vis_schemas'; export { prepareLogTable } from '../common/utils/prepare_log_table'; export { XYCurveTypes } from '../common/convert_to_lens/constants'; - -export function getFullPath(id: string) { - return `/app/visualize#/edit/${id}`; -} - -export function urlFor(id: string) { - return `#/edit/${encodeURIComponent(id)}`; -} +export { urlFor, getFullPath } from './utils/url_utils'; /** @public types */ export type { VisualizationsSetup, VisualizationsStart }; diff --git a/src/platform/plugins/shared/visualizations/public/utils/saved_visualize_utils.ts b/src/platform/plugins/shared/visualizations/public/utils/saved_visualize_utils.ts index a18b9f888b947..eed204988d11b 100644 --- a/src/platform/plugins/shared/visualizations/public/utils/saved_visualize_utils.ts +++ b/src/platform/plugins/shared/visualizations/public/utils/saved_visualize_utils.ts @@ -36,7 +36,7 @@ import { injectReferences, extractReferences } from './saved_visualization_refer import { OVERWRITE_REJECTED, SAVE_DUPLICATE_REJECTED } from './saved_objects_utils/constants'; import { visualizationsClient } from '../content_management'; import { VisualizationSavedObjectAttributes } from '../../common'; -import { urlFor } from '..'; +import { urlFor } from './url_utils'; export const SAVED_VIS_TYPE = 'visualization'; diff --git a/src/platform/plugins/shared/visualizations/public/utils/url_utils.ts b/src/platform/plugins/shared/visualizations/public/utils/url_utils.ts new file mode 100644 index 0000000000000..3a39b4126cebd --- /dev/null +++ b/src/platform/plugins/shared/visualizations/public/utils/url_utils.ts @@ -0,0 +1,16 @@ +/* + * 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 function getFullPath(id: string) { + return `/app/visualize#/edit/${id}`; +} + +export function urlFor(id: string) { + return `#/edit/${encodeURIComponent(id)}`; +} From 4bcd8f085f83b14b4d6131d311dbc6ed413641b3 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 23 Jan 2025 08:01:49 -0700 Subject: [PATCH 16/16] remove actions_modules and import directly from actions --- .../visualizations/public/actions/actions_module.ts | 11 ----------- .../visualizations/public/actions/register_actions.ts | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 src/platform/plugins/shared/visualizations/public/actions/actions_module.ts diff --git a/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts b/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts deleted file mode 100644 index be13e44698a04..0000000000000 --- a/src/platform/plugins/shared/visualizations/public/actions/actions_module.ts +++ /dev/null @@ -1,11 +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". - */ - -export { EditInLensAction } from './edit_in_lens_action'; -export { AddAggVisualizationPanelAction } from './add_agg_vis_action'; diff --git a/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts b/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts index 9d0a84db9d82e..3aacb75597870 100644 --- a/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts +++ b/src/platform/plugins/shared/visualizations/public/actions/register_actions.ts @@ -19,12 +19,12 @@ export function registerActions( types: TypesStart ) { uiActions.addTriggerActionAsync(CONTEXT_MENU_TRIGGER, ACTION_EDIT_IN_LENS, async () => { - const { EditInLensAction } = await import('./actions_module'); + const { EditInLensAction } = await import('./edit_in_lens_action'); return new EditInLensAction(data.query.timefilter.timefilter); }); uiActions.addTriggerActionAsync(ADD_PANEL_TRIGGER, ADD_AGG_VIS_ACTION_ID, async () => { - const { AddAggVisualizationPanelAction } = await import('./actions_module'); + const { AddAggVisualizationPanelAction } = await import('./add_agg_vis_action'); return new AddAggVisualizationPanelAction(types); }); }