From 05a4281faae3e08a1feae321823f0af61c9a3a89 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 27 Dec 2024 12:07:47 -0700 Subject: [PATCH 1/6] [embeddable] folder cleanup --- .../plugins/shared/embeddable/public/index.ts | 3 +- .../embeddables/diff_embeddable_input.test.ts | 2 +- .../shared/embeddable/public/lib/index.ts | 1 - .../shared/embeddable/public/lib/types.ts | 29 ------------------- .../embeddable/public/lib/ui_actions.ts | 10 ------- 5 files changed, 2 insertions(+), 43 deletions(-) delete mode 100644 src/platform/plugins/shared/embeddable/public/lib/types.ts delete mode 100644 src/platform/plugins/shared/embeddable/public/lib/ui_actions.ts diff --git a/src/platform/plugins/shared/embeddable/public/index.ts b/src/platform/plugins/shared/embeddable/public/index.ts index 4ec1c43df2dbb..fbf73302c4fda 100644 --- a/src/platform/plugins/shared/embeddable/public/index.ts +++ b/src/platform/plugins/shared/embeddable/public/index.ts @@ -36,8 +36,8 @@ export { PANEL_NOTIFICATION_TRIGGER, SELECT_RANGE_TRIGGER, VALUE_CLICK_TRIGGER, - ViewMode, } from './lib'; +export { ViewMode } from '../common/types'; export type { CellValueContext, ChartActionContext, @@ -48,7 +48,6 @@ export type { EmbeddablePackageState, IEmbeddable, MultiValueClickContext, - PropertySpec, RangeSelectContext, ValueClickContext, } from './lib'; diff --git a/src/platform/plugins/shared/embeddable/public/lib/embeddables/diff_embeddable_input.test.ts b/src/platform/plugins/shared/embeddable/public/lib/embeddables/diff_embeddable_input.test.ts index b4b8a2a1da920..311392ad28b96 100644 --- a/src/platform/plugins/shared/embeddable/public/lib/embeddables/diff_embeddable_input.test.ts +++ b/src/platform/plugins/shared/embeddable/public/lib/embeddables/diff_embeddable_input.test.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { ViewMode } from '..'; +import { ViewMode } from '../../../common/types'; import { KibanaExecutionContext } from '@kbn/core/types'; import { EmbeddableInput } from '.'; import { omitGenericEmbeddableInput, genericEmbeddableInputIsEqual } from './diff_embeddable_input'; diff --git a/src/platform/plugins/shared/embeddable/public/lib/index.ts b/src/platform/plugins/shared/embeddable/public/lib/index.ts index 60f8a3638816d..680e93b5009f7 100644 --- a/src/platform/plugins/shared/embeddable/public/lib/index.ts +++ b/src/platform/plugins/shared/embeddable/public/lib/index.ts @@ -9,6 +9,5 @@ export * from './errors'; export * from './embeddables'; -export * from './types'; export * from './triggers'; export * from './state_transfer'; diff --git a/src/platform/plugins/shared/embeddable/public/lib/types.ts b/src/platform/plugins/shared/embeddable/public/lib/types.ts deleted file mode 100644 index 9a3f98891235d..0000000000000 --- a/src/platform/plugins/shared/embeddable/public/lib/types.ts +++ /dev/null @@ -1,29 +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 interface Trigger { - id: string; - title?: string; - description?: string; -} - -export interface PropertySpec { - displayName: string; - accessPath: string; - id: string; - description: string; - value?: string; -} -export { ViewMode } from '../../common/types'; - -export interface CommonlyUsedRange { - from: string; - to: string; - display: string; -} diff --git a/src/platform/plugins/shared/embeddable/public/lib/ui_actions.ts b/src/platform/plugins/shared/embeddable/public/lib/ui_actions.ts deleted file mode 100644 index 27c7992cea05e..0000000000000 --- a/src/platform/plugins/shared/embeddable/public/lib/ui_actions.ts +++ /dev/null @@ -1,10 +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 * from '@kbn/ui-actions-plugin/public'; From 038f9651f56ae354f2e711cf52ebb3832211cac1 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 2 Jan 2025 12:06:12 -0700 Subject: [PATCH 2/6] revert test removal --- .../embeddable/diff_embeddable_input.test.ts | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/plugins/visualizations/public/legacy/embeddable/diff_embeddable_input.test.ts diff --git a/src/plugins/visualizations/public/legacy/embeddable/diff_embeddable_input.test.ts b/src/plugins/visualizations/public/legacy/embeddable/diff_embeddable_input.test.ts new file mode 100644 index 0000000000000..2f1bdd010e45b --- /dev/null +++ b/src/plugins/visualizations/public/legacy/embeddable/diff_embeddable_input.test.ts @@ -0,0 +1,114 @@ +/* + * 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 { KibanaExecutionContext } from '@kbn/core/types'; +import { EmbeddableInput, ViewMode } from '@kbn/embeddable-plugin/common'; +import { omitGenericEmbeddableInput, genericEmbeddableInputIsEqual } from './diff_embeddable_input'; + +const getGenericEmbeddableState = (state?: Partial): EmbeddableInput => { + const defaultState: EmbeddableInput = { + lastReloadRequestTime: 1, + executionContext: {} as KibanaExecutionContext, + searchSessionId: 'what a session', + hidePanelTitles: false, + disabledActions: [], + disableTriggers: false, + enhancements: undefined, + syncColors: false, + syncTooltips: false, + syncCursor: true, + viewMode: ViewMode.VIEW, + title: 'So Very Generic', + id: 'soVeryGeneric', + }; + return { ...defaultState, ...state }; +}; + +test('Omitting generic embeddable input omits all generic input keys', () => { + const superEmbeddableSpecificInput = { + SuperInputKeyA: 'I am so specific', + SuperInputKeyB: 'I am extremely specific', + }; + const fullInput = { ...getGenericEmbeddableState(), ...superEmbeddableSpecificInput }; + const omittedState = omitGenericEmbeddableInput(fullInput); + + const genericInputKeysToRemove: Array = [ + 'lastReloadRequestTime', + 'executionContext', + 'searchSessionId', + 'hidePanelTitles', + 'disabledActions', + 'disableTriggers', + 'enhancements', + 'syncColors', + 'syncTooltips', + 'syncCursor', + 'viewMode', + 'title', + 'id', + ]; + for (const key of genericInputKeysToRemove) { + expect((omittedState as unknown as EmbeddableInput)[key]).toBeUndefined(); + } + + expect(omittedState.SuperInputKeyA).toBeDefined(); + expect(omittedState.SuperInputKeyB).toBeDefined(); +}); + +describe('Generic embeddable input diff function', () => { + it('considers blank string title to be distinct from undefined title', () => { + const genericInputWithUndefinedTitle = getGenericEmbeddableState(); + genericInputWithUndefinedTitle.title = undefined; + expect( + genericEmbeddableInputIsEqual( + getGenericEmbeddableState({ title: '' }), + genericInputWithUndefinedTitle + ) + ).toBe(false); + }); + + it('considers missing title key to be equal to input with undefined title', () => { + const genericInputWithUndefinedTitle = getGenericEmbeddableState(); + genericInputWithUndefinedTitle.title = undefined; + const genericInputWithDeletedTitle = getGenericEmbeddableState(); + delete genericInputWithDeletedTitle.title; + expect( + genericEmbeddableInputIsEqual(genericInputWithDeletedTitle, genericInputWithUndefinedTitle) + ).toBe(true); + }); + + it('considers hide panel titles false to be equal to hide panel titles undefined', () => { + const genericInputWithUndefinedShowPanelTitles = getGenericEmbeddableState(); + genericInputWithUndefinedShowPanelTitles.hidePanelTitles = undefined; + expect( + genericEmbeddableInputIsEqual( + getGenericEmbeddableState(), + genericInputWithUndefinedShowPanelTitles + ) + ).toBe(true); + }); + + it('ignores differences in viewMode', () => { + expect( + genericEmbeddableInputIsEqual( + getGenericEmbeddableState(), + getGenericEmbeddableState({ viewMode: ViewMode.EDIT }) + ) + ).toBe(true); + }); + + it('ignores differences in searchSessionId', () => { + expect( + genericEmbeddableInputIsEqual( + getGenericEmbeddableState(), + getGenericEmbeddableState({ searchSessionId: 'What a lovely session!' }) + ) + ).toBe(true); + }); +}); \ No newline at end of file From ee1dd40618038c4a50f583d6c7050f9b657078d4 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 2 Jan 2025 12:22:08 -0700 Subject: [PATCH 3/6] remove lib folder --- .../actions/create_links_panel_action.ts | 4 +- .../add_panel_action_menu_items.ts | 4 +- .../use_get_dashboard_panels.test.ts | 6 +-- .../add_new_panel/use_get_dashboard_panels.ts | 6 +-- .../embeddable/public/add_panel_groups.ts | 38 ++++++++++++++++++ .../plugins/shared/embeddable/public/index.ts | 18 +++++---- .../lib/embeddables/common/constants.ts | 39 ------------------- .../embeddable/public/lib/errors.test.ts | 35 ----------------- .../shared/embeddable/public/lib/index.ts | 12 ------ .../shared/embeddable/public/plugin.tsx | 6 +-- .../public/react_embeddable_system/index.ts | 2 + .../panel_incompatible_error.ts} | 13 ------- .../panel_not_found_error.ts} | 14 ++++++- .../embeddable_state_transfer.test.ts | 0 .../embeddable_state_transfer.ts | 0 .../public/{lib => }/state_transfer/index.ts | 0 .../public/{lib => }/state_transfer/types.ts | 0 .../register_triggers.ts} | 8 +--- .../public/{lib => }/triggers/triggers.ts | 0 .../plugins/shared/embeddable/public/types.ts | 2 +- .../public/actions/create_image_action.ts | 4 +- .../public/actions/add_agg_vis_action.ts | 4 +- 22 files changed, 83 insertions(+), 132 deletions(-) create mode 100644 src/platform/plugins/shared/embeddable/public/add_panel_groups.ts delete mode 100644 src/platform/plugins/shared/embeddable/public/lib/embeddables/common/constants.ts delete mode 100644 src/platform/plugins/shared/embeddable/public/lib/errors.test.ts delete mode 100644 src/platform/plugins/shared/embeddable/public/lib/index.ts rename src/platform/plugins/shared/embeddable/public/{lib/errors.ts => react_embeddable_system/panel_incompatible_error.ts} (73%) rename src/platform/plugins/shared/embeddable/public/{lib/triggers/index.ts => react_embeddable_system/panel_not_found_error.ts} (63%) rename src/platform/plugins/shared/embeddable/public/{lib => }/state_transfer/embeddable_state_transfer.test.ts (100%) rename src/platform/plugins/shared/embeddable/public/{lib => }/state_transfer/embeddable_state_transfer.ts (100%) rename src/platform/plugins/shared/embeddable/public/{lib => }/state_transfer/index.ts (100%) rename src/platform/plugins/shared/embeddable/public/{lib => }/state_transfer/types.ts (100%) rename src/platform/plugins/shared/embeddable/public/{bootstrap.ts => triggers/register_triggers.ts} (86%) rename src/platform/plugins/shared/embeddable/public/{lib => }/triggers/triggers.ts (100%) diff --git a/src/platform/plugins/private/links/public/actions/create_links_panel_action.ts b/src/platform/plugins/private/links/public/actions/create_links_panel_action.ts index 666e650d6d586..3fa64383eb797 100644 --- a/src/platform/plugins/private/links/public/actions/create_links_panel_action.ts +++ b/src/platform/plugins/private/links/public/actions/create_links_panel_action.ts @@ -9,7 +9,7 @@ import { EmbeddableApiContext } from '@kbn/presentation-publishing'; import { ADD_PANEL_TRIGGER, IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; -import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public'; +import { ADD_PANEL_ANNOTATION_GROUP } from '@kbn/embeddable-plugin/public'; import { APP_ICON, APP_NAME, CONTENT_ID } from '../../common'; import { uiActions } from '../services/kibana_services'; @@ -38,7 +38,7 @@ export const registerCreateLinksPanelAction = () => { initialState: runtimeState, }); }, - grouping: [COMMON_EMBEDDABLE_GROUPING.annotation], + grouping: [ADD_PANEL_ANNOTATION_GROUP], getDisplayName: () => APP_NAME, }); uiActions.attachAction(ADD_PANEL_TRIGGER, ADD_LINKS_PANEL_ACTION_ID); diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts b/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts index b91320e321f88..fd17016d0a5eb 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts @@ -13,7 +13,7 @@ import { addPanelMenuTrigger, } from '@kbn/ui-actions-plugin/public'; import { PresentationContainer } from '@kbn/presentation-containers'; -import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public'; +import { ADD_PANEL_OTHER_GROUP } from '@kbn/embeddable-plugin/public'; import type { IconType, CommonProps } from '@elastic/eui'; import React, { type MouseEventHandler } from 'react'; @@ -98,7 +98,7 @@ export const getAddPanelActionMenuItemsGroup = ( }); } else { // use other group as the default for definitions that don't have a group - const fallbackGroup = COMMON_EMBEDDABLE_GROUPING.other; + const fallbackGroup = ADD_PANEL_OTHER_GROUP; if (!grouped[fallbackGroup.id]) { grouped[fallbackGroup.id] = { diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.test.ts b/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.test.ts index 0bd8d95dc7916..7965403a6b01a 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.test.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.test.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public'; +import { ADD_PANEL_ANNOTATION_GROUP, ADD_PANEL_LEGACY_GROUP } from '@kbn/embeddable-plugin/public'; import type { PresentationContainer } from '@kbn/presentation-containers'; import type { Action, UiActionsService } from '@kbn/ui-actions-plugin/public'; import { ADD_PANEL_TRIGGER } from '@kbn/ui-actions-plugin/public'; @@ -92,8 +92,8 @@ describe('Get dashboard panels hook', () => { describe('augmenting ui action group items with dashboard visualization types', () => { it.each([ ['visualizations', VisGroups.PROMOTED], - [COMMON_EMBEDDABLE_GROUPING.legacy.id, VisGroups.LEGACY], - [COMMON_EMBEDDABLE_GROUPING.annotation.id, VisGroups.TOOLS], + [ADD_PANEL_LEGACY_GROUP.id, VisGroups.LEGACY], + [ADD_PANEL_ANNOTATION_GROUP.id, VisGroups.TOOLS], ])( 'includes in the ui action %s group, %s dashboard visualization group types', async (uiActionGroupId, dashboardVisualizationGroupId) => { diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.ts b/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.ts index 4556991816c99..8d26c2a3b5708 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.ts @@ -10,7 +10,7 @@ import { useCallback, useMemo, useRef } from 'react'; import { AsyncSubject, defer, from, lastValueFrom, map, type Subscription } from 'rxjs'; -import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public'; +import { ADD_PANEL_ANNOTATION_GROUP, ADD_PANEL_LEGACY_GROUP } from '@kbn/embeddable-plugin/public'; import { PresentationContainer } from '@kbn/presentation-containers'; import { ADD_PANEL_TRIGGER } from '@kbn/ui-actions-plugin/public'; import { VisGroups, type BaseVisType, type VisTypeAlias } from '@kbn/visualizations-plugin/public'; @@ -155,7 +155,7 @@ export const useGetDashboardPanels = ({ api, createNewVisType }: UseGetDashboard ), }; } - case COMMON_EMBEDDABLE_GROUPING.legacy.id: { + case ADD_PANEL_LEGACY_GROUP.id: { return { ...panelGroup, items: sortGroupPanelsByOrder( @@ -165,7 +165,7 @@ export const useGetDashboardPanels = ({ api, createNewVisType }: UseGetDashboard ), }; } - case COMMON_EMBEDDABLE_GROUPING.annotation.id: { + case ADD_PANEL_ANNOTATION_GROUP.id: { return { ...panelGroup, items: sortGroupPanelsByOrder( diff --git a/src/platform/plugins/shared/embeddable/public/add_panel_groups.ts b/src/platform/plugins/shared/embeddable/public/add_panel_groups.ts new file mode 100644 index 0000000000000..d1111bb5d5a5f --- /dev/null +++ b/src/platform/plugins/shared/embeddable/public/add_panel_groups.ts @@ -0,0 +1,38 @@ +/* + * 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 { i18n } from '@kbn/i18n'; + +export const ADD_PANEL_ANNOTATION_GROUP = { + id: 'annotation-and-navigation', + getDisplayName: () => + i18n.translate('embeddableApi.common.constants.grouping.annotations', { + defaultMessage: 'Annotations and Navigation', + }), + order: 900, // This is the order of the group in the context menu +}; + +export const ADD_PANEL_OTHER_GROUP = { + id: 'other', + getDisplayName: () => + i18n.translate('embeddableApi.common.constants.grouping.other', { + defaultMessage: 'Other', + }), + getIconType: () => 'empty', + order: -1, // Given an item that doesn't specify a group is assigned zero, this forces other to come after all intentionally grouped section +}; + +export const ADD_PANEL_LEGACY_GROUP = { + id: 'legacy', + getDisplayName: () => + i18n.translate('embeddableApi.common.constants.grouping.legacy', { + defaultMessage: 'Legacy', + }), + order: -2, // Given an item that doesn't specify a group is assigned zero, this forces it to the bottom of the list +}; diff --git a/src/platform/plugins/shared/embeddable/public/index.ts b/src/platform/plugins/shared/embeddable/public/index.ts index daccb30291698..1de2ac4f91be8 100644 --- a/src/platform/plugins/shared/embeddable/public/index.ts +++ b/src/platform/plugins/shared/embeddable/public/index.ts @@ -12,12 +12,13 @@ import { EmbeddablePublicPlugin } from './plugin'; export { useAddFromLibraryTypes } from './add_from_library/registry'; export { openAddFromLibraryFlyout } from './add_from_library/open_add_from_library_flyout'; +export { PanelNotFoundError, PanelIncompatibleError } from './react_embeddable_system'; +export { EmbeddableStateTransfer } from './state_transfer'; export { cellValueTrigger, CELL_VALUE_TRIGGER, contextMenuTrigger, CONTEXT_MENU_TRIGGER, - EmbeddableStateTransfer, isMultiValueClickTriggerContext, isRangeSelectTriggerContext, isRowClickTriggerContext, @@ -25,25 +26,22 @@ export { MULTI_VALUE_CLICK_TRIGGER, panelBadgeTrigger, panelHoverTrigger, - PanelNotFoundError, - PanelIncompatibleError, panelNotificationTrigger, PANEL_BADGE_TRIGGER, PANEL_HOVER_TRIGGER, PANEL_NOTIFICATION_TRIGGER, SELECT_RANGE_TRIGGER, VALUE_CLICK_TRIGGER, -} from './lib'; +} from './triggers/triggers'; export { ViewMode } from '../common/types'; export type { CellValueContext, ChartActionContext, - EmbeddableEditorState, - EmbeddablePackageState, MultiValueClickContext, RangeSelectContext, ValueClickContext, -} from './lib'; +} from './triggers/triggers'; +export type { EmbeddableEditorState, EmbeddablePackageState } from './state_transfer'; export type { EmbeddableSetup, EmbeddableStart } from './types'; export type { EnhancementRegistryDefinition } from './enhancements/types'; @@ -57,4 +55,8 @@ export function plugin(initializerContext: PluginInitializerContext) { return new EmbeddablePublicPlugin(initializerContext); } -export { COMMON_EMBEDDABLE_GROUPING } from './lib/embeddables/common/constants'; +export { + ADD_PANEL_ANNOTATION_GROUP, + ADD_PANEL_OTHER_GROUP, + ADD_PANEL_LEGACY_GROUP, +} from './add_panel_groups'; diff --git a/src/platform/plugins/shared/embeddable/public/lib/embeddables/common/constants.ts b/src/platform/plugins/shared/embeddable/public/lib/embeddables/common/constants.ts deleted file mode 100644 index eec876216da47..0000000000000 --- a/src/platform/plugins/shared/embeddable/public/lib/embeddables/common/constants.ts +++ /dev/null @@ -1,39 +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 { i18n } from '@kbn/i18n'; -import { UiActionsPresentableGroup } from '@kbn/ui-actions-plugin/public'; - -export const COMMON_EMBEDDABLE_GROUPING: { [key: string]: UiActionsPresentableGroup } = { - annotation: { - id: 'annotation-and-navigation', - getDisplayName: () => - i18n.translate('embeddableApi.common.constants.grouping.annotations', { - defaultMessage: 'Annotations and Navigation', - }), - order: 900, // This is the order of the group in the context menu - }, - other: { - id: 'other', - getDisplayName: () => - i18n.translate('embeddableApi.common.constants.grouping.other', { - defaultMessage: 'Other', - }), - getIconType: () => 'empty', - order: -1, // Given an item that doesn't specify a group is assigned zero, this forces other to come after all intentionally grouped section - }, - legacy: { - id: 'legacy', - getDisplayName: () => - i18n.translate('embeddableApi.common.constants.grouping.legacy', { - defaultMessage: 'Legacy', - }), - order: -2, // Given an item that doesn't specify a group is assigned zero, this forces it to the bottom of the list - }, -}; diff --git a/src/platform/plugins/shared/embeddable/public/lib/errors.test.ts b/src/platform/plugins/shared/embeddable/public/lib/errors.test.ts deleted file mode 100644 index ebac7371acd51..0000000000000 --- a/src/platform/plugins/shared/embeddable/public/lib/errors.test.ts +++ /dev/null @@ -1,35 +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 { IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; -import { PanelNotFoundError } from './errors'; - -describe('IncompatibleActionError', () => { - test('is instance of error', () => { - const error = new IncompatibleActionError(); - expect(error).toBeInstanceOf(Error); - }); - - test('has INCOMPATIBLE_ACTION code', () => { - const error = new IncompatibleActionError(); - expect(error.code).toBe('INCOMPATIBLE_ACTION'); - }); -}); - -describe('PanelNotFoundError', () => { - test('is instance of error', () => { - const error = new PanelNotFoundError(); - expect(error).toBeInstanceOf(Error); - }); - - test('has PANEL_NOT_FOUND code', () => { - const error = new PanelNotFoundError(); - expect(error.code).toBe('PANEL_NOT_FOUND'); - }); -}); diff --git a/src/platform/plugins/shared/embeddable/public/lib/index.ts b/src/platform/plugins/shared/embeddable/public/lib/index.ts deleted file mode 100644 index 749a9dfb83867..0000000000000 --- a/src/platform/plugins/shared/embeddable/public/lib/index.ts +++ /dev/null @@ -1,12 +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 * from './errors'; -export * from './triggers'; -export * from './state_transfer'; diff --git a/src/platform/plugins/shared/embeddable/public/plugin.tsx b/src/platform/plugins/shared/embeddable/public/plugin.tsx index 84ea1676dd018..402ab1b3c1e84 100644 --- a/src/platform/plugins/shared/embeddable/public/plugin.tsx +++ b/src/platform/plugins/shared/embeddable/public/plugin.tsx @@ -17,8 +17,8 @@ import { } from '@kbn/core/public'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { migrateToLatest } from '@kbn/kibana-utils-plugin/common'; -import { bootstrap } from './bootstrap'; -import { EmbeddableStateTransfer } from './lib/state_transfer'; +import { registerTriggers } from './triggers/register_triggers'; +import { EmbeddableStateTransfer } from './state_transfer'; import { EmbeddableStateWithType, CommonEmbeddableStartContract } from '../common/types'; import { getExtractFunction, @@ -47,7 +47,7 @@ export class EmbeddablePublicPlugin implements Plugin { +export const registerTriggers = (uiActions: UiActionsSetup) => { uiActions.registerTrigger(contextMenuTrigger); uiActions.registerTrigger(panelHoverTrigger); uiActions.registerTrigger(panelBadgeTrigger); diff --git a/src/platform/plugins/shared/embeddable/public/lib/triggers/triggers.ts b/src/platform/plugins/shared/embeddable/public/triggers/triggers.ts similarity index 100% rename from src/platform/plugins/shared/embeddable/public/lib/triggers/triggers.ts rename to src/platform/plugins/shared/embeddable/public/triggers/triggers.ts diff --git a/src/platform/plugins/shared/embeddable/public/types.ts b/src/platform/plugins/shared/embeddable/public/types.ts index 2d97adfc2b8e0..3902b20ece715 100644 --- a/src/platform/plugins/shared/embeddable/public/types.ts +++ b/src/platform/plugins/shared/embeddable/public/types.ts @@ -17,7 +17,7 @@ import type { Storage } from '@kbn/kibana-utils-plugin/public'; import type { PersistableStateService } from '@kbn/kibana-utils-plugin/common'; import type { registerAddFromLibraryType } from './add_from_library/registry'; import type { registerReactEmbeddableFactory } from './react_embeddable_system'; -import type { EmbeddableStateTransfer } from './lib'; +import type { EmbeddableStateTransfer } from './state_transfer'; import type { EmbeddableStateWithType } from '../common'; import { EnhancementRegistryDefinition } from './enhancements/types'; diff --git a/src/plugins/image_embeddable/public/actions/create_image_action.ts b/src/plugins/image_embeddable/public/actions/create_image_action.ts index c18b25f7a8179..62e542697dd74 100644 --- a/src/plugins/image_embeddable/public/actions/create_image_action.ts +++ b/src/plugins/image_embeddable/public/actions/create_image_action.ts @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { CanAddNewPanel } from '@kbn/presentation-containers'; import { EmbeddableApiContext } from '@kbn/presentation-publishing'; -import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public'; +import { ADD_PANEL_ANNOTATION_GROUP } from '@kbn/embeddable-plugin/public'; import { IncompatibleActionError, ADD_PANEL_TRIGGER } from '@kbn/ui-actions-plugin/public'; import { ADD_IMAGE_EMBEDDABLE_ACTION_ID, @@ -48,7 +48,7 @@ export const registerCreateImageAction = () => { // swallow the rejection, since this just means the user closed without saving } }, - grouping: [COMMON_EMBEDDABLE_GROUPING.annotation], + grouping: [ADD_PANEL_ANNOTATION_GROUP], getDisplayName: () => i18n.translate('imageEmbeddable.imageEmbeddableFactory.displayName', { defaultMessage: 'Image', diff --git a/src/plugins/visualizations/public/actions/add_agg_vis_action.ts b/src/plugins/visualizations/public/actions/add_agg_vis_action.ts index f3dfe8807be27..cd3faa92d7787 100644 --- a/src/plugins/visualizations/public/actions/add_agg_vis_action.ts +++ b/src/plugins/visualizations/public/actions/add_agg_vis_action.ts @@ -14,7 +14,7 @@ import { HasType, HasAppContext, } from '@kbn/presentation-publishing'; -import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public'; +import { ADD_PANEL_LEGACY_GROUP } from '@kbn/embeddable-plugin/public'; import { Action, IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; import { apiHasType } from '@kbn/presentation-publishing'; import { apiCanAddNewPanel, CanAddNewPanel } from '@kbn/presentation-containers'; @@ -33,7 +33,7 @@ const isApiCompatible = (api: unknown | null): api is AddAggVisualizationPanelAc export class AddAggVisualizationPanelAction implements Action { public readonly type = ADD_AGG_VIS_ACTION_ID; public readonly id = ADD_AGG_VIS_ACTION_ID; - public readonly grouping = [COMMON_EMBEDDABLE_GROUPING.legacy]; + public readonly grouping = [ADD_PANEL_LEGACY_GROUP]; private readonly aggVisualizationCreationEnabled: boolean; public readonly order = 20; From 32cb7fa404c4a7f06d892fda3ea640e000d91216 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:45:09 +0000 Subject: [PATCH 4/6] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../public/legacy/embeddable/diff_embeddable_input.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/visualizations/public/legacy/embeddable/diff_embeddable_input.test.ts b/src/plugins/visualizations/public/legacy/embeddable/diff_embeddable_input.test.ts index 2f1bdd010e45b..80724cca7cd9f 100644 --- a/src/plugins/visualizations/public/legacy/embeddable/diff_embeddable_input.test.ts +++ b/src/plugins/visualizations/public/legacy/embeddable/diff_embeddable_input.test.ts @@ -111,4 +111,4 @@ describe('Generic embeddable input diff function', () => { ) ).toBe(true); }); -}); \ No newline at end of file +}); From fd284829221d4fee80fa1c939d507c0f25becbef Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 2 Jan 2025 13:05:31 -0700 Subject: [PATCH 5/6] eslint --- .../top_nav/add_new_panel/add_panel_action_menu_items.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts b/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts index fd17016d0a5eb..fe1d1e73e5a96 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts @@ -103,7 +103,7 @@ export const getAddPanelActionMenuItemsGroup = ( if (!grouped[fallbackGroup.id]) { grouped[fallbackGroup.id] = { id: fallbackGroup.id, - title: fallbackGroup.getDisplayName?.({ embeddable: api }) || '', + title: fallbackGroup.getDisplayName?.() || '', 'data-test-subj': `dashboardEditorMenu-${fallbackGroup.id}Group`, order: fallbackGroup.order || 0, items: [], From 92652d4620fadabe8952b92bbaf28666d529bb14 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 3 Jan 2025 10:28:01 -0700 Subject: [PATCH 6/6] ui_actions folder --- src/platform/plugins/shared/embeddable/public/index.ts | 6 +++--- src/platform/plugins/shared/embeddable/public/plugin.tsx | 2 +- .../embeddable/public/{ => ui_actions}/add_panel_groups.ts | 0 .../public/{triggers => ui_actions}/register_triggers.ts | 0 .../embeddable/public/{triggers => ui_actions}/triggers.ts | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/platform/plugins/shared/embeddable/public/{ => ui_actions}/add_panel_groups.ts (100%) rename src/platform/plugins/shared/embeddable/public/{triggers => ui_actions}/register_triggers.ts (100%) rename src/platform/plugins/shared/embeddable/public/{triggers => ui_actions}/triggers.ts (100%) diff --git a/src/platform/plugins/shared/embeddable/public/index.ts b/src/platform/plugins/shared/embeddable/public/index.ts index 1de2ac4f91be8..88dafd108e5ea 100644 --- a/src/platform/plugins/shared/embeddable/public/index.ts +++ b/src/platform/plugins/shared/embeddable/public/index.ts @@ -32,7 +32,7 @@ export { PANEL_NOTIFICATION_TRIGGER, SELECT_RANGE_TRIGGER, VALUE_CLICK_TRIGGER, -} from './triggers/triggers'; +} from './ui_actions/triggers'; export { ViewMode } from '../common/types'; export type { CellValueContext, @@ -40,7 +40,7 @@ export type { MultiValueClickContext, RangeSelectContext, ValueClickContext, -} from './triggers/triggers'; +} from './ui_actions/triggers'; export type { EmbeddableEditorState, EmbeddablePackageState } from './state_transfer'; export type { EmbeddableSetup, EmbeddableStart } from './types'; export type { EnhancementRegistryDefinition } from './enhancements/types'; @@ -59,4 +59,4 @@ export { ADD_PANEL_ANNOTATION_GROUP, ADD_PANEL_OTHER_GROUP, ADD_PANEL_LEGACY_GROUP, -} from './add_panel_groups'; +} from './ui_actions/add_panel_groups'; diff --git a/src/platform/plugins/shared/embeddable/public/plugin.tsx b/src/platform/plugins/shared/embeddable/public/plugin.tsx index 402ab1b3c1e84..288f91f2145fd 100644 --- a/src/platform/plugins/shared/embeddable/public/plugin.tsx +++ b/src/platform/plugins/shared/embeddable/public/plugin.tsx @@ -17,7 +17,7 @@ import { } from '@kbn/core/public'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { migrateToLatest } from '@kbn/kibana-utils-plugin/common'; -import { registerTriggers } from './triggers/register_triggers'; +import { registerTriggers } from './ui_actions/register_triggers'; import { EmbeddableStateTransfer } from './state_transfer'; import { EmbeddableStateWithType, CommonEmbeddableStartContract } from '../common/types'; import { diff --git a/src/platform/plugins/shared/embeddable/public/add_panel_groups.ts b/src/platform/plugins/shared/embeddable/public/ui_actions/add_panel_groups.ts similarity index 100% rename from src/platform/plugins/shared/embeddable/public/add_panel_groups.ts rename to src/platform/plugins/shared/embeddable/public/ui_actions/add_panel_groups.ts diff --git a/src/platform/plugins/shared/embeddable/public/triggers/register_triggers.ts b/src/platform/plugins/shared/embeddable/public/ui_actions/register_triggers.ts similarity index 100% rename from src/platform/plugins/shared/embeddable/public/triggers/register_triggers.ts rename to src/platform/plugins/shared/embeddable/public/ui_actions/register_triggers.ts diff --git a/src/platform/plugins/shared/embeddable/public/triggers/triggers.ts b/src/platform/plugins/shared/embeddable/public/ui_actions/triggers.ts similarity index 100% rename from src/platform/plugins/shared/embeddable/public/triggers/triggers.ts rename to src/platform/plugins/shared/embeddable/public/ui_actions/triggers.ts