Skip to content

Commit 3f685d1

Browse files
committed
[embeddable] folder cleanup (elastic#205219)
Clean up embeddable folder structure. PR also splits `COMMON_EMBEDDABLE_GROUPING` into `ADD_PANEL_ANNOTATION_GROUP`, `ADD_PANEL_LEGACY_GROUP`, and `ADD_PANEL_OTHER_GROUP` to provide a more contextually relevant name. --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit fd702ef)
1 parent 833ef86 commit 3f685d1

File tree

24 files changed

+85
-175
lines changed

24 files changed

+85
-175
lines changed

src/platform/plugins/private/image_embeddable/public/actions/create_image_action.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { i18n } from '@kbn/i18n';
1111
import { CanAddNewPanel } from '@kbn/presentation-containers';
1212
import { EmbeddableApiContext } from '@kbn/presentation-publishing';
13-
import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public';
13+
import { ADD_PANEL_ANNOTATION_GROUP } from '@kbn/embeddable-plugin/public';
1414
import { IncompatibleActionError, ADD_PANEL_TRIGGER } from '@kbn/ui-actions-plugin/public';
1515
import {
1616
ADD_IMAGE_EMBEDDABLE_ACTION_ID,
@@ -48,7 +48,7 @@ export const registerCreateImageAction = () => {
4848
// swallow the rejection, since this just means the user closed without saving
4949
}
5050
},
51-
grouping: [COMMON_EMBEDDABLE_GROUPING.annotation],
51+
grouping: [ADD_PANEL_ANNOTATION_GROUP],
5252
getDisplayName: () =>
5353
i18n.translate('imageEmbeddable.imageEmbeddableFactory.displayName', {
5454
defaultMessage: 'Image',

src/platform/plugins/private/links/public/actions/create_links_panel_action.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import { EmbeddableApiContext } from '@kbn/presentation-publishing';
1111
import { ADD_PANEL_TRIGGER, IncompatibleActionError } from '@kbn/ui-actions-plugin/public';
12-
import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public';
12+
import { ADD_PANEL_ANNOTATION_GROUP } from '@kbn/embeddable-plugin/public';
1313
import { APP_ICON, APP_NAME, CONTENT_ID } from '../../common';
1414
import { uiActions } from '../services/kibana_services';
1515

@@ -38,7 +38,7 @@ export const registerCreateLinksPanelAction = () => {
3838
initialState: runtimeState,
3939
});
4040
},
41-
grouping: [COMMON_EMBEDDABLE_GROUPING.annotation],
41+
grouping: [ADD_PANEL_ANNOTATION_GROUP],
4242
getDisplayName: () => APP_NAME,
4343
});
4444
uiActions.attachAction(ADD_PANEL_TRIGGER, ADD_LINKS_PANEL_ACTION_ID);

src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/add_panel_action_menu_items.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
addPanelMenuTrigger,
1414
} from '@kbn/ui-actions-plugin/public';
1515
import { PresentationContainer } from '@kbn/presentation-containers';
16-
import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public';
16+
import { ADD_PANEL_OTHER_GROUP } from '@kbn/embeddable-plugin/public';
1717
import type { IconType, CommonProps } from '@elastic/eui';
1818
import React, { type MouseEventHandler } from 'react';
1919

@@ -98,12 +98,12 @@ export const getAddPanelActionMenuItemsGroup = (
9898
});
9999
} else {
100100
// use other group as the default for definitions that don't have a group
101-
const fallbackGroup = COMMON_EMBEDDABLE_GROUPING.other;
101+
const fallbackGroup = ADD_PANEL_OTHER_GROUP;
102102

103103
if (!grouped[fallbackGroup.id]) {
104104
grouped[fallbackGroup.id] = {
105105
id: fallbackGroup.id,
106-
title: fallbackGroup.getDisplayName?.({ embeddable: api }) || '',
106+
title: fallbackGroup.getDisplayName?.() || '',
107107
'data-test-subj': `dashboardEditorMenu-${fallbackGroup.id}Group`,
108108
order: fallbackGroup.order || 0,
109109
items: [],

src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public';
10+
import { ADD_PANEL_ANNOTATION_GROUP, ADD_PANEL_LEGACY_GROUP } from '@kbn/embeddable-plugin/public';
1111
import type { PresentationContainer } from '@kbn/presentation-containers';
1212
import type { Action, UiActionsService } from '@kbn/ui-actions-plugin/public';
1313
import { ADD_PANEL_TRIGGER } from '@kbn/ui-actions-plugin/public';
@@ -92,8 +92,8 @@ describe('Get dashboard panels hook', () => {
9292
describe('augmenting ui action group items with dashboard visualization types', () => {
9393
it.each([
9494
['visualizations', VisGroups.PROMOTED],
95-
[COMMON_EMBEDDABLE_GROUPING.legacy.id, VisGroups.LEGACY],
96-
[COMMON_EMBEDDABLE_GROUPING.annotation.id, VisGroups.TOOLS],
95+
[ADD_PANEL_LEGACY_GROUP.id, VisGroups.LEGACY],
96+
[ADD_PANEL_ANNOTATION_GROUP.id, VisGroups.TOOLS],
9797
])(
9898
'includes in the ui action %s group, %s dashboard visualization group types',
9999
async (uiActionGroupId, dashboardVisualizationGroupId) => {

src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/add_new_panel/use_get_dashboard_panels.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { useCallback, useMemo, useRef } from 'react';
1111
import { AsyncSubject, defer, from, lastValueFrom, map, type Subscription } from 'rxjs';
1212

13-
import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public';
13+
import { ADD_PANEL_ANNOTATION_GROUP, ADD_PANEL_LEGACY_GROUP } from '@kbn/embeddable-plugin/public';
1414
import { PresentationContainer } from '@kbn/presentation-containers';
1515
import { ADD_PANEL_TRIGGER } from '@kbn/ui-actions-plugin/public';
1616
import { VisGroups, type BaseVisType, type VisTypeAlias } from '@kbn/visualizations-plugin/public';
@@ -155,7 +155,7 @@ export const useGetDashboardPanels = ({ api, createNewVisType }: UseGetDashboard
155155
),
156156
};
157157
}
158-
case COMMON_EMBEDDABLE_GROUPING.legacy.id: {
158+
case ADD_PANEL_LEGACY_GROUP.id: {
159159
return {
160160
...panelGroup,
161161
items: sortGroupPanelsByOrder<PanelSelectionMenuItem>(
@@ -165,7 +165,7 @@ export const useGetDashboardPanels = ({ api, createNewVisType }: UseGetDashboard
165165
),
166166
};
167167
}
168-
case COMMON_EMBEDDABLE_GROUPING.annotation.id: {
168+
case ADD_PANEL_ANNOTATION_GROUP.id: {
169169
return {
170170
...panelGroup,
171171
items: sortGroupPanelsByOrder<PanelSelectionMenuItem>(

src/platform/plugins/shared/embeddable/public/index.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,36 @@ import { EmbeddablePublicPlugin } from './plugin';
1212

1313
export { useAddFromLibraryTypes } from './add_from_library/registry';
1414
export { openAddFromLibraryFlyout } from './add_from_library/open_add_from_library_flyout';
15+
export { PanelNotFoundError, PanelIncompatibleError } from './react_embeddable_system';
16+
export { EmbeddableStateTransfer } from './state_transfer';
1517
export {
1618
cellValueTrigger,
1719
CELL_VALUE_TRIGGER,
1820
contextMenuTrigger,
1921
CONTEXT_MENU_TRIGGER,
20-
EmbeddableStateTransfer,
2122
isMultiValueClickTriggerContext,
2223
isRangeSelectTriggerContext,
2324
isRowClickTriggerContext,
2425
isValueClickTriggerContext,
2526
MULTI_VALUE_CLICK_TRIGGER,
2627
panelBadgeTrigger,
2728
panelHoverTrigger,
28-
PanelNotFoundError,
29-
PanelIncompatibleError,
3029
panelNotificationTrigger,
3130
PANEL_BADGE_TRIGGER,
3231
PANEL_HOVER_TRIGGER,
3332
PANEL_NOTIFICATION_TRIGGER,
3433
SELECT_RANGE_TRIGGER,
3534
VALUE_CLICK_TRIGGER,
36-
ViewMode,
37-
} from './lib';
35+
} from './ui_actions/triggers';
36+
export { ViewMode } from '../common/types';
3837
export type {
3938
CellValueContext,
4039
ChartActionContext,
41-
EmbeddableEditorState,
42-
EmbeddablePackageState,
4340
MultiValueClickContext,
44-
PropertySpec,
4541
RangeSelectContext,
4642
ValueClickContext,
47-
} from './lib';
43+
} from './ui_actions/triggers';
44+
export type { EmbeddableEditorState, EmbeddablePackageState } from './state_transfer';
4845
export type { EmbeddableSetup, EmbeddableStart } from './types';
4946
export type { EnhancementRegistryDefinition } from './enhancements/types';
5047

@@ -58,4 +55,8 @@ export function plugin(initializerContext: PluginInitializerContext) {
5855
return new EmbeddablePublicPlugin(initializerContext);
5956
}
6057

61-
export { COMMON_EMBEDDABLE_GROUPING } from './lib/embeddables/common/constants';
58+
export {
59+
ADD_PANEL_ANNOTATION_GROUP,
60+
ADD_PANEL_OTHER_GROUP,
61+
ADD_PANEL_LEGACY_GROUP,
62+
} from './ui_actions/add_panel_groups';

src/platform/plugins/shared/embeddable/public/lib/embeddables/common/constants.ts

-39
This file was deleted.

src/platform/plugins/shared/embeddable/public/lib/errors.test.ts

-35
This file was deleted.

src/platform/plugins/shared/embeddable/public/lib/index.ts

-13
This file was deleted.

src/platform/plugins/shared/embeddable/public/lib/types.ts

-29
This file was deleted.

src/platform/plugins/shared/embeddable/public/lib/ui_actions.ts

-10
This file was deleted.

src/platform/plugins/shared/embeddable/public/plugin.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import {
1717
} from '@kbn/core/public';
1818
import { Storage } from '@kbn/kibana-utils-plugin/public';
1919
import { migrateToLatest } from '@kbn/kibana-utils-plugin/common';
20-
import { bootstrap } from './bootstrap';
21-
import { EmbeddableStateTransfer } from './lib/state_transfer';
20+
import { registerTriggers } from './ui_actions/register_triggers';
21+
import { EmbeddableStateTransfer } from './state_transfer';
2222
import { EmbeddableStateWithType, CommonEmbeddableStartContract } from '../common/types';
2323
import {
2424
getExtractFunction,
@@ -47,7 +47,7 @@ export class EmbeddablePublicPlugin implements Plugin<EmbeddableSetup, Embeddabl
4747
constructor(initializerContext: PluginInitializerContext) {}
4848

4949
public setup(core: CoreSetup, { uiActions }: EmbeddableSetupDependencies) {
50-
bootstrap(uiActions);
50+
registerTriggers(uiActions);
5151

5252
return {
5353
registerReactEmbeddableFactory,

src/platform/plugins/shared/embeddable/public/react_embeddable_system/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10+
export { PanelIncompatibleError } from './panel_incompatible_error';
11+
export { PanelNotFoundError } from './panel_not_found_error';
1012
export { registerReactEmbeddableFactory } from './react_embeddable_registry';
1113
export { ReactEmbeddableRenderer } from './react_embeddable_renderer';
1214
export type { DefaultEmbeddableApi, ReactEmbeddableFactory } from './types';

src/platform/plugins/shared/embeddable/public/lib/errors.ts src/platform/plugins/shared/embeddable/public/react_embeddable_system/panel_incompatible_error.ts

-13
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,8 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
/* eslint-disable max-classes-per-file */
1110
import { i18n } from '@kbn/i18n';
1211

13-
export class PanelNotFoundError extends Error {
14-
code = 'PANEL_NOT_FOUND';
15-
16-
constructor() {
17-
super(
18-
i18n.translate('embeddableApi.errors.paneldoesNotExist', {
19-
defaultMessage: 'Panel not found',
20-
})
21-
);
22-
}
23-
}
24-
2512
export class PanelIncompatibleError extends Error {
2613
code = 'PANEL_INCOMPATIBLE';
2714

src/platform/plugins/shared/embeddable/public/lib/triggers/index.ts src/platform/plugins/shared/embeddable/public/react_embeddable_system/panel_not_found_error.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,16 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
export * from './triggers';
10+
import { i18n } from '@kbn/i18n';
11+
12+
export class PanelNotFoundError extends Error {
13+
code = 'PANEL_NOT_FOUND';
14+
15+
constructor() {
16+
super(
17+
i18n.translate('embeddableApi.errors.paneldoesNotExist', {
18+
defaultMessage: 'Panel not found',
19+
})
20+
);
21+
}
22+
}

src/platform/plugins/shared/embeddable/public/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type { Storage } from '@kbn/kibana-utils-plugin/public';
1717
import type { PersistableStateService } from '@kbn/kibana-utils-plugin/common';
1818
import type { registerAddFromLibraryType } from './add_from_library/registry';
1919
import type { registerReactEmbeddableFactory } from './react_embeddable_system';
20-
import type { EmbeddableStateTransfer } from './lib';
20+
import type { EmbeddableStateTransfer } from './state_transfer';
2121
import type { EmbeddableStateWithType } from '../common';
2222
import { EnhancementRegistryDefinition } from './enhancements/types';
2323

0 commit comments

Comments
 (0)