Skip to content

Commit

Permalink
[embeddable] folder cleanup (elastic#205219)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
nreese committed Jan 7, 2025
1 parent b456840 commit 3ae450b
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -98,12 +98,12 @@ 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] = {
id: fallbackGroup.id,
title: fallbackGroup.getDisplayName?.({ embeddable: api }) || '',
title: fallbackGroup.getDisplayName?.() || '',
'data-test-subj': `dashboardEditorMenu-${fallbackGroup.id}Group`,
order: fallbackGroup.order || 0,
items: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<PanelSelectionMenuItem>(
Expand All @@ -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<PanelSelectionMenuItem>(
Expand Down
21 changes: 11 additions & 10 deletions src/platform/plugins/shared/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,36 @@ 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,
isValueClickTriggerContext,
MULTI_VALUE_CLICK_TRIGGER,
panelBadgeTrigger,
panelHoverTrigger,
PanelNotFoundError,
PanelIncompatibleError,
panelNotificationTrigger,
PANEL_BADGE_TRIGGER,
PANEL_HOVER_TRIGGER,
PANEL_NOTIFICATION_TRIGGER,
SELECT_RANGE_TRIGGER,
VALUE_CLICK_TRIGGER,
ViewMode,
} from './lib';
} from './ui_actions/triggers';
export { ViewMode } from '../common/types';
export type {
CellValueContext,
ChartActionContext,
EmbeddableEditorState,
EmbeddablePackageState,
MultiValueClickContext,
PropertySpec,
RangeSelectContext,
ValueClickContext,
} from './lib';
} from './ui_actions/triggers';
export type { EmbeddableEditorState, EmbeddablePackageState } from './state_transfer';
export type { EmbeddableSetup, EmbeddableStart } from './types';
export type { EnhancementRegistryDefinition } from './enhancements/types';

Expand All @@ -58,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 './ui_actions/add_panel_groups';

This file was deleted.

35 changes: 0 additions & 35 deletions src/platform/plugins/shared/embeddable/public/lib/errors.test.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/platform/plugins/shared/embeddable/public/lib/index.ts

This file was deleted.

29 changes: 0 additions & 29 deletions src/platform/plugins/shared/embeddable/public/lib/types.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/platform/plugins/shared/embeddable/public/lib/ui_actions.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/platform/plugins/shared/embeddable/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 './ui_actions/register_triggers';
import { EmbeddableStateTransfer } from './state_transfer';
import { EmbeddableStateWithType, CommonEmbeddableStartContract } from '../common/types';
import {
getExtractFunction,
Expand Down Expand Up @@ -47,7 +47,7 @@ export class EmbeddablePublicPlugin implements Plugin<EmbeddableSetup, Embeddabl
constructor(initializerContext: PluginInitializerContext) {}

public setup(core: CoreSetup, { uiActions }: EmbeddableSetupDependencies) {
bootstrap(uiActions);
registerTriggers(uiActions);

return {
registerReactEmbeddableFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { PanelIncompatibleError } from './panel_incompatible_error';
export { PanelNotFoundError } from './panel_not_found_error';
export { registerReactEmbeddableFactory } from './react_embeddable_registry';
export { ReactEmbeddableRenderer } from './react_embeddable_renderer';
export type { DefaultEmbeddableApi, ReactEmbeddableFactory } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

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

export class PanelNotFoundError extends Error {
code = 'PANEL_NOT_FOUND';

constructor() {
super(
i18n.translate('embeddableApi.errors.paneldoesNotExist', {
defaultMessage: 'Panel not found',
})
);
}
}

export class PanelIncompatibleError extends Error {
code = 'PANEL_INCOMPATIBLE';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,16 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export * from './triggers';
import { i18n } from '@kbn/i18n';

export class PanelNotFoundError extends Error {
code = 'PANEL_NOT_FOUND';

constructor() {
super(
i18n.translate('embeddableApi.errors.paneldoesNotExist', {
defaultMessage: 'Panel not found',
})
);
}
}
2 changes: 1 addition & 1 deletion src/platform/plugins/shared/embeddable/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Loading

0 comments on commit 3ae450b

Please sign in to comment.