Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[embeddable] folder cleanup #205219

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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
Original file line number Diff line number Diff line change
@@ -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
};
Loading