Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"kbnESQuery": "packages/kbn-es-query",
"inspector": "src/plugins/inspector",
"kibana-react": "src/plugins/kibana_react",
"esUi": "src/plugins/es_ui_shared"
"esUi": "src/plugins/es_ui_shared",
"uiActions": "src/plugins/ui_actions"
},
"exclude": ["src/legacy/ui/ui_render/ui_render_mixin.js"],
"translations": []
Expand Down
1 change: 1 addition & 0 deletions src/dev/jest/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default {
'!src/legacy/ui/public/{agg_types,vis}/**/*.d.ts',
],
moduleNameMapper: {
'^src/plugins/(.*)': '<rootDir>/src/plugins/$1',
'^plugins/([^\/.]*)(.*)': '<rootDir>/src/legacy/core_plugins/$1/public$2',
'^ui/(.*)': '<rootDir>/src/legacy/ui/public/$1',
'^uiExports/(.*)': '<rootDir>/src/dev/jest/mocks/file_mock.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "kibana",
"requiredPlugins": [
"embeddable",
"inspector"
"inspector",
"ui_actions"
],
"server": false,
"ui": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const pluginInstance = plugin({} as any);

export const setup = pluginInstance.setup(npSetup.core, {
embeddable: embeddableSetup,
uiActions: npSetup.plugins.uiActions,
});

export const start = pluginInstance.start(npStart.core, {
Expand All @@ -42,4 +43,5 @@ export const start = pluginInstance.start(npStart.core, {
SavedObjectFinder,
ExitFullScreenButton,
},
uiActions: npStart.plugins.uiActions,
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ beforeEach(async () => {
notifications: {} as any,
overlays: {} as any,
savedObjectMetaData: {} as any,
uiActions: {} as any,
};
const input = getSampleDashboardInput({
panels: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

import { i18n } from '@kbn/i18n';
import { IEmbeddable } from '../../../../../../embeddable_api/public/np_ready/public';
import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../embeddable';
import {
Action,
IEmbeddable,
IAction,
IncompatibleActionError,
} from '../../../../../../embeddable_api/public/np_ready/public';
import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../embeddable';
} from '../../../../../../../../../src/plugins/ui_actions/public';

export const EXPAND_PANEL_ACTION = 'togglePanel';

Expand All @@ -43,13 +43,12 @@ interface ActionContext {
embeddable: IEmbeddable;
}

export class ExpandPanelAction extends Action<ActionContext> {
export class ExpandPanelAction implements IAction<ActionContext> {
public readonly type = EXPAND_PANEL_ACTION;
public readonly id = EXPAND_PANEL_ACTION;
public order = 7;

constructor() {
super(EXPAND_PANEL_ACTION);
this.order = 7;
}
constructor() {}

public getDisplayName({ embeddable }: ActionContext) {
if (!embeddable.parent || !isDashboard(embeddable.parent)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const options: DashboardContainerOptions = {
inspector: {} as any,
SavedObjectFinder: () => null,
ExitFullScreenButton: () => null,
uiActions: {} as any,
};

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ReactDOM from 'react-dom';
import { I18nProvider } from '@kbn/i18n/react';
import { Filter } from '@kbn/es-query';
import { RefreshInterval, TimeRange } from 'src/plugins/data/public';
import { IUiActionsStart } from '../../../../../../../../plugins/ui_actions/public';
import {
Container,
ContainerInput,
Expand Down Expand Up @@ -82,6 +83,7 @@ export interface DashboardContainerOptions {
inspector: InspectorStartContract;
SavedObjectFinder: React.ComponentType<any>;
ExitFullScreenButton: React.ComponentType<any>;
uiActions: IUiActionsStart;
}

export type DashboardReactContextValue = KibanaReactContextValue<DashboardContainerOptions>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function prepare(props?: Partial<DashboardGridProps>) {
inspector: {} as any,
SavedObjectFinder: () => null,
ExitFullScreenButton: () => null,
uiActions: {} as any,
};
dashboardContainer = new DashboardContainer(initialInput, options);
const defaultTestProps: DashboardGridProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> {
<EmbeddableChildPanel
embeddableId={panel.explicitInput.id}
container={this.props.container}
getActions={this.props.kibana.services.embeddable.getTriggerCompatibleActions}
getActions={this.props.kibana.services.uiActions.getTriggerCompatibleActions}
getEmbeddableFactory={this.props.kibana.services.embeddable.getEmbeddableFactory}
getAllEmbeddableFactories={this.props.kibana.services.embeddable.getEmbeddableFactories}
overlays={this.props.kibana.services.overlays}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function getProps(
inspector: {} as any,
SavedObjectFinder: () => null,
ExitFullScreenButton,
uiActions: {} as any,
};

const input = getSampleDashboardInput({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@
*/

import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
import { IUiActionsSetup, IUiActionsStart } from '../../../../../../plugins/ui_actions/public';
import { CONTEXT_MENU_TRIGGER, Plugin as EmbeddablePlugin } from './lib/embeddable_api';
import { ExpandPanelAction, DashboardContainerFactory } from './lib';
import { Start as InspectorStartContract } from '../../../../../../plugins/inspector/public';

interface SetupDependencies {
embeddable: ReturnType<EmbeddablePlugin['setup']>;
uiActions: IUiActionsSetup;
}

interface StartDependencies {
embeddable: ReturnType<EmbeddablePlugin['start']>;
inspector: InspectorStartContract;
uiActions: IUiActionsStart;
__LEGACY: {
SavedObjectFinder: React.ComponentType<any>;
ExitFullScreenButton: React.ComponentType<any>;
Expand All @@ -42,15 +45,15 @@ export class DashboardEmbeddableContainerPublicPlugin
implements Plugin<Setup, Start, SetupDependencies, StartDependencies> {
constructor(initializerContext: PluginInitializerContext) {}

public setup(core: CoreSetup, { embeddable }: SetupDependencies): Setup {
public setup(core: CoreSetup, { embeddable, uiActions }: SetupDependencies): Setup {
const expandPanelAction = new ExpandPanelAction();
embeddable.registerAction(expandPanelAction);
embeddable.attachAction(CONTEXT_MENU_TRIGGER, expandPanelAction.id);
uiActions.registerAction(expandPanelAction);
uiActions.attachAction(CONTEXT_MENU_TRIGGER, expandPanelAction.id);
}

public start(core: CoreStart, plugins: StartDependencies): Start {
const { application, notifications, overlays } = core;
const { embeddable, inspector, __LEGACY } = plugins;
const { embeddable, inspector, __LEGACY, uiActions } = plugins;

const factory = new DashboardContainerFactory({
application,
Expand All @@ -60,6 +63,7 @@ export class DashboardEmbeddableContainerPublicPlugin
inspector,
SavedObjectFinder: __LEGACY.SavedObjectFinder,
ExitFullScreenButton: __LEGACY.ExitFullScreenButton,
uiActions,
});

embeddable.registerEmbeddableFactory(factory.type, factory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ import {
ContactCardEmbeddableOutput,
} from '../../../../../embeddable_api/public/np_ready/public/lib/test_samples/embeddables/contact_card/contact_card_embeddable';
import { embeddablePluginMock } from '../../../../../embeddable_api/public/np_ready/public/mocks';
import { EditModeAction } from '../../../../../embeddable_api/public/np_ready/public/lib/test_samples/actions/edit_mode_action';
import { createEditModeAction } from '../../../../../embeddable_api/public/np_ready/public/lib/test_samples/actions/edit_mode_action';
// eslint-disable-next-line
import { inspectorPluginMock } from '../../../../../../../plugins/inspector/public/mocks';
import { KibanaContextProvider } from '../../../../../../../plugins/kibana_react/public';
// eslint-disable-next-line
import { uiActionsPluginMock } from 'src/plugins/ui_actions/public/mocks';

test('DashboardContainer in edit mode shows edit mode actions', async () => {
const inspector = inspectorPluginMock.createStartContract();
const { setup, doStart } = embeddablePluginMock.createInstance();
const uiActionsSetup = uiActionsPluginMock.createSetupContract();

const editModeAction = new EditModeAction();
setup.registerAction(editModeAction);
setup.attachAction(CONTEXT_MENU_TRIGGER, editModeAction.id);
const editModeAction = createEditModeAction();
uiActionsSetup.registerAction(editModeAction);
uiActionsSetup.attachAction(CONTEXT_MENU_TRIGGER, editModeAction.id);
setup.registerEmbeddableFactory(
CONTACT_CARD_EMBEDDABLE,
new ContactCardEmbeddableFactory({} as any, (() => null) as any, {} as any)
Expand All @@ -67,6 +70,7 @@ test('DashboardContainer in edit mode shows edit mode actions', async () => {
inspector: {} as any,
SavedObjectFinder: () => null,
ExitFullScreenButton: () => null,
uiActions: {} as any,
};
const container = new DashboardContainer(initialInput, options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"id": "embeddable",
"version": "kibana",
"server": false,
"ui": true
"ui": true,
"requiredPlugins": [
"embeddable",
"inspector"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,16 @@ import {
EmbeddableApi,
EmbeddableDependenciesInternal,
} from './types';
import { attachAction } from './attach_action';
import { detachAction } from './detach_action';
import { executeTriggerActions } from './execute_trigger_actions';
import { getEmbeddableFactories } from './get_embeddable_factories';
import { getEmbeddableFactory } from './get_embeddable_factory';
import { getTrigger } from './get_trigger';
import { getTriggerActions } from './get_trigger_actions';
import { getTriggerCompatibleActions } from './get_trigger_compatible_actions';
import { registerAction } from './register_action';
import { registerEmbeddableFactory } from './register_embeddable_factory';
import { registerTrigger } from './register_trigger';

export * from './types';

export const pureApi: EmbeddableApiPure = {
attachAction,
detachAction,
executeTriggerActions,
getEmbeddableFactories,
getEmbeddableFactory,
getTrigger,
getTriggerActions,
getTriggerCompatibleActions,
registerAction,
registerEmbeddableFactory,
registerTrigger,
};

export const createApi = (deps: EmbeddableDependencies) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { EmbeddableDependencies } from '../types';

export const createDeps = (): EmbeddableDependencies => {
const deps: EmbeddableDependencies = {
triggers: new Map<any, any>(),
actions: new Map<any, any>(),
embeddableFactories: new Map<any, any>(),
};
return deps;
Expand Down
Loading