Dashboard container (#49600) (#49897)

* feat: 🎸 create dasboard embeddable NP plugin, move panel action

* refactor: 💡 pass in getFactories() fn to "replace" action

* refactor: 💡 move dashboard container actions to NP

* refactor: 💡 remove action files from dashboard container in LP

* refactor: 💡 move dashboard grid to NP plugin

* refactor: 💡 move Embeddable SASS to the NP

* refactor: 💡 move dashboard container panel to NP

* refactor: 💡 move dashboard container viewport to NP

* refactor: 💡 move dashboard constant to constants file

* refactor: 💡 move dashboard_continaer file to NP

* refactor: 💡 move dashboard_container_factory.tsx to NP

* chore: 🤖 disable injected React components

* feat: 🎸 fill in NP plugin

* feat: 🎸 move expand panel action to NP

* feat: 🎸 move replace action panel to NP

* feat: 🎸 move dashboard_contaienr to NP

* chore: 🤖 delete LP dasboard container plugin shim

* chore: 🤖 delete LP dashboard_embeddable_container plugin

* chore: 🤖 point translations to the NP plugin

* test: 💍 re-enable dashboard container tests

* chore: 🤖 fix TypeScript type errors

* chore: 🤖 fix more TypeScript tyeps

* test: 💍 fix import in .js test

* feat: 🎸 use <SavedObjectFinder> in dashboard container

* feat: 🎸 add full screen button to dashboard container

* fix: 🐛 execute Chrome hiding only once

* chore: 🤖 put back temporary type substitutions

While moving this plugin file-by-file those types were not available

* chore: 🤖 revert back kibana_react imports

* fix: 🐛 address review comments
This commit is contained in:
Vadim Dalecky 2019-10-31 20:52:20 +01:00 committed by GitHub
parent 82359197c0
commit a18a0293ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 264 additions and 201 deletions

View file

@ -1,40 +1,39 @@
{
"paths": {
"common.ui": "src/legacy/ui",
"data": ["src/legacy/core_plugins/data", "src/plugins/data"],
"expressions": "src/legacy/core_plugins/expressions",
"expressions_np": "src/plugins/expressions",
"kibana_react": "src/legacy/core_plugins/kibana_react",
"navigation": "src/legacy/core_plugins/navigation",
"server": "src/legacy/server",
"console": "src/legacy/core_plugins/console",
"core": "src/core",
"dashboardEmbeddableContainer": "src/plugins/dashboard_embeddable_container",
"data": ["src/legacy/core_plugins/data", "src/plugins/data"],
"embeddableApi": "src/plugins/embeddable",
"esUi": "src/plugins/es_ui_shared",
"expressions_np": "src/plugins/expressions",
"expressions": "src/legacy/core_plugins/expressions",
"inputControl": "src/legacy/core_plugins/input_control_vis",
"inspectorViews": "src/legacy/core_plugins/inspector_views",
"inspector": "src/plugins/inspector",
"inspectorViews": "src/legacy/core_plugins/inspector_views",
"interpreter": "src/legacy/core_plugins/interpreter",
"dashboardEmbeddableContainer": "src/legacy/core_plugins/dashboard_embeddable_container",
"kbn": "src/legacy/core_plugins/kibana",
"kbnDocViews": "src/legacy/core_plugins/kbn_doc_views",
"embeddableApi": "src/plugins/embeddable",
"kbnESQuery": "packages/kbn-es-query",
"kbnVislibVisTypes": "src/legacy/core_plugins/kbn_vislib_vis_types",
"visTypeMarkdown": "src/legacy/core_plugins/vis_type_markdown",
"visTypeMetric": "src/legacy/core_plugins/vis_type_metric",
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
"visTypeTable": "src/legacy/core_plugins/vis_type_table",
"kibana_react": "src/legacy/core_plugins/kibana_react",
"kibana-react": "src/plugins/kibana_react",
"navigation": "src/legacy/core_plugins/navigation",
"regionMap": "src/legacy/core_plugins/region_map",
"server": "src/legacy/server",
"statusPage": "src/legacy/core_plugins/status_page",
"telemetry": "src/legacy/core_plugins/telemetry",
"tileMap": "src/legacy/core_plugins/tile_map",
"timelion": "src/legacy/core_plugins/timelion",
"uiActions": "src/plugins/ui_actions",
"visTypeMarkdown": "src/legacy/core_plugins/vis_type_markdown",
"visTypeMetric": "src/legacy/core_plugins/vis_type_metric",
"visTypeTable": "src/legacy/core_plugins/vis_type_table",
"visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud",
"visTypeTimeseries": "src/legacy/core_plugins/vis_type_timeseries",
"kbnESQuery": "packages/kbn-es-query",
"inspector": "src/plugins/inspector",
"kibana-react": "src/plugins/kibana_react",
"visualizations": "src/plugins/visualizations",
"telemetry": "src/legacy/core_plugins/telemetry",
"esUi": "src/plugins/es_ui_shared",
"uiActions": "src/plugins/ui_actions"
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
"visualizations": "src/plugins/visualizations"
},
"exclude": ["src/legacy/ui/ui_render/ui_render_mixin.js"],
"translations": []

View file

@ -23,7 +23,6 @@ import { resolve } from 'path';
export default function(kibana: any) {
return new kibana.Plugin({
uiExports: {
hacks: ['plugins/dashboard_embeddable_container/initialize'],
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
},
});

View file

@ -1,6 +1,3 @@
@import 'src/legacy/ui/public/styles/styling_constants';
@import 'src/legacy/core_plugins/embeddable_api/public/variables';
@import './np_ready/public/lib/embeddable/grid/index';
@import './np_ready/public/lib/embeddable/panel/index';
@import './np_ready/public/lib/embeddable/viewport/index';
@import '../../../../plugins/dashboard_embeddable_container/public/index';

View file

@ -16,5 +16,3 @@
* specific language governing permissions and limitations
* under the License.
*/
import './np_ready/public/legacy';

View file

@ -17,13 +17,4 @@
* under the License.
*/
import { PluginInitializerContext } from '../../../../../../core/public';
import { DashboardEmbeddableContainerPublicPlugin } from './plugin';
export * from './lib';
export function plugin(initializerContext: PluginInitializerContext) {
return new DashboardEmbeddableContainerPublicPlugin(initializerContext);
}
export { DashboardEmbeddableContainerPublicPlugin as Plugin };
export * from '../../../../../../plugins/dashboard_embeddable_container/public';

View file

@ -16,32 +16,3 @@
* specific language governing permissions and limitations
* under the License.
*/
/* eslint-disable @kbn/eslint/no-restricted-paths */
import { npSetup, npStart } from 'ui/new_platform';
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
import { ExitFullScreenButton } from 'ui/exit_full_screen';
/* eslint-enable @kbn/eslint/no-restricted-paths */
import { plugin } from '.';
import {
setup as embeddableSetup,
start as embeddableStart,
} from '../../../../embeddable_api/public/np_ready/public/legacy';
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, {
embeddable: embeddableStart,
inspector: npStart.plugins.inspector,
__LEGACY: {
SavedObjectFinder,
ExitFullScreenButton,
},
uiActions: npStart.plugins.uiActions,
});

View file

@ -1,5 +1,3 @@
@import 'src/legacy/ui/public/styles/styling_constants';
@import './variables';
@import '../../../../plugins/embeddable/public/lib/panel/index';
@import '../../../../plugins/embeddable/public/lib/panel/panel_header/index';
@import '../../../../plugins/embeddable/public/index';

View file

@ -4,7 +4,7 @@
"requiredPlugins": [
"embeddable",
"inspector",
"ui_actions"
"uiActions"
],
"server": false,
"ui": true

View file

@ -0,0 +1,5 @@
@import '../../embeddable/public/variables';
@import './embeddable/grid/index';
@import './embeddable/panel/index';
@import './embeddable/viewport/index';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { isErrorEmbeddable, EmbeddableFactory } from '../embeddable_api';
import { isErrorEmbeddable, EmbeddableFactory } from '../embeddable_plugin';
import { ExpandPanelAction } from './expand_panel_action';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
@ -27,7 +27,7 @@ import {
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
} from '../embeddable_plugin_test_samples';
import { DashboardOptions } from '../embeddable/dashboard_container_factory';
const embeddableFactories = new Map<string, EmbeddableFactory>();

View file

@ -18,12 +18,9 @@
*/
import { i18n } from '@kbn/i18n';
import { IEmbeddable } from '../../../../../../embeddable_api/public/np_ready/public';
import { IEmbeddable } from '../embeddable_plugin';
import { IAction, IncompatibleActionError } from '../ui_actions_plugin';
import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../embeddable';
import {
IAction,
IncompatibleActionError,
} from '../../../../../../../../../src/plugins/ui_actions/public';
export const EXPAND_PANEL_ACTION = 'togglePanel';

View file

@ -17,26 +17,32 @@
* under the License.
*/
import React from 'react';
import { CoreStart } from 'src/core/public';
import { CoreStart } from '../../../../core/public';
import { ReplacePanelFlyout } from './replace_panel_flyout';
import {
IEmbeddable,
EmbeddableInput,
EmbeddableOutput,
} from '../../../../../../embeddable_api/public/np_ready/public';
import { IContainer } from '../../../../../../embeddable_api/public/np_ready/public';
import { NotificationsStart } from '../../../../../../../../core/public';
Start as EmbeddableStart,
IContainer,
} from '../embeddable_plugin';
export async function openReplacePanelFlyout(options: {
embeddable: IContainer;
core: CoreStart;
savedObjectFinder: React.ComponentType<any>;
notifications: NotificationsStart;
notifications: CoreStart['notifications'];
panelToRemove: IEmbeddable<EmbeddableInput, EmbeddableOutput>;
getEmbeddableFactories: EmbeddableStart['getEmbeddableFactories'];
}) {
const { embeddable, core, panelToRemove, savedObjectFinder, notifications } = options;
const {
embeddable,
core,
panelToRemove,
savedObjectFinder,
notifications,
getEmbeddableFactories,
} = options;
const flyoutSession = core.overlays.openFlyout(
<ReplacePanelFlyout
container={embeddable}
@ -48,6 +54,7 @@ export async function openReplacePanelFlyout(options: {
panelToRemove={panelToRemove}
savedObjectsFinder={savedObjectFinder}
notifications={notifications}
getEmbeddableFactories={getEmbeddableFactories}
/>,
{
'data-test-subj': 'replacePanelFlyout',

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { isErrorEmbeddable, EmbeddableFactory } from '../embeddable_api';
import { isErrorEmbeddable, EmbeddableFactory } from '../embeddable_plugin';
import { ReplacePanelAction } from './replace_panel_action';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
@ -27,7 +27,7 @@ import {
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
} from '../embeddable_plugin_test_samples';
import { DashboardOptions } from '../embeddable/dashboard_container_factory';
const embeddableFactories = new Map<string, EmbeddableFactory>();
@ -35,6 +35,7 @@ embeddableFactories.set(
CONTACT_CARD_EMBEDDABLE,
new ContactCardEmbeddableFactory({} as any, (() => null) as any, {} as any)
);
const getEmbeddableFactories = () => embeddableFactories.values();
let container: DashboardContainer;
let embeddable: ContactCardEmbeddable;
@ -82,7 +83,12 @@ test('Executes the replace panel action', async () => {
let core: any;
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(core, SavedObjectFinder, notifications);
const action = new ReplacePanelAction(
core,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
action.execute({ embeddable });
});
@ -90,7 +96,12 @@ test('Is not compatible when embeddable is not in a dashboard container', async
let core: any;
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(core, SavedObjectFinder, notifications);
const action = new ReplacePanelAction(
core,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
expect(
await action.isCompatible({
embeddable: new ContactCardEmbeddable(
@ -105,7 +116,12 @@ test('Execute throws an error when called with an embeddable not in a parent', a
let core: any;
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(core, SavedObjectFinder, notifications);
const action = new ReplacePanelAction(
core,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
async function check() {
await action.execute({ embeddable: container });
}
@ -116,7 +132,12 @@ test('Returns title', async () => {
let core: any;
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(core, SavedObjectFinder, notifications);
const action = new ReplacePanelAction(
core,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
expect(action.getDisplayName({ embeddable })).toBeDefined();
});
@ -124,6 +145,11 @@ test('Returns an icon', async () => {
let core: any;
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(core, SavedObjectFinder, notifications);
const action = new ReplacePanelAction(
core,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
expect(action.getIconType({ embeddable })).toBeDefined();
});

View file

@ -18,15 +18,10 @@
*/
import { i18n } from '@kbn/i18n';
import { CoreStart } from 'src/core/public';
import { IEmbeddable, ViewMode } from '../../../../../../embeddable_api/public/np_ready/public';
import { CoreStart } from '../../../../core/public';
import { IEmbeddable, ViewMode, Start as EmbeddableStart } from '../embeddable_plugin';
import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../embeddable';
import {
IAction,
IncompatibleActionError,
} from '../../../../../../../../plugins/ui_actions/public';
import { NotificationsStart } from '../../../../../../../../core/public';
import { IAction, IncompatibleActionError } from '../ui_actions_plugin';
import { openReplacePanelFlyout } from './open_replace_panel_flyout';
export const REPLACE_PANEL_ACTION = 'replacePanel';
@ -47,7 +42,8 @@ export class ReplacePanelAction implements IAction<ActionContext> {
constructor(
private core: CoreStart,
private savedobjectfinder: React.ComponentType<any>,
private notifications: NotificationsStart
private notifications: CoreStart['notifications'],
private getEmbeddableFactories: EmbeddableStart['getEmbeddableFactories']
) {}
public getDisplayName({ embeddable }: ActionContext) {
@ -89,6 +85,7 @@ export class ReplacePanelAction implements IAction<ActionContext> {
savedObjectFinder: this.savedobjectfinder,
notifications: this.notifications,
panelToRemove: view,
getEmbeddableFactories: this.getEmbeddableFactories,
});
}
}

View file

@ -19,10 +19,6 @@
import { i18n } from '@kbn/i18n';
import React from 'react';
import { NotificationsStart } from 'src/core/public';
import { DashboardPanelState } from 'src/legacy/core_plugins/dashboard_embeddable_container/public/np_ready/public';
import {
EuiFlyout,
EuiFlyoutBody,
@ -30,15 +26,15 @@ import {
EuiTitle,
EuiGlobalToastListToast as Toast,
} from '@elastic/eui';
import { IContainer } from '../../../../../../embeddable_api/public/np_ready/public';
import { DashboardPanelState } from '../embeddable';
import { NotificationsStart } from '../../../../core/public';
import {
IContainer,
IEmbeddable,
EmbeddableInput,
EmbeddableOutput,
} from '../../../../../../embeddable_api/public/np_ready/public';
import { start } from '../../../../../../embeddable_api/public/np_ready/public/legacy';
Start as EmbeddableStart,
} from '../embeddable_plugin';
interface Props {
container: IContainer;
@ -46,6 +42,7 @@ interface Props {
onClose: () => void;
notifications: NotificationsStart;
panelToRemove: IEmbeddable<EmbeddableInput, EmbeddableOutput>;
getEmbeddableFactories: EmbeddableStart['getEmbeddableFactories'];
}
export class ReplacePanelFlyout extends React.Component<Props> {
@ -117,7 +114,7 @@ export class ReplacePanelFlyout extends React.Component<Props> {
defaultMessage: 'No matching objects found.',
}
)}
savedObjectMetaData={[...start.getEmbeddableFactories()]
savedObjectMetaData={[...this.props.getEmbeddableFactories()]
.filter(
embeddableFactory =>
Boolean(embeddableFactory.savedObjectMetaData) && !embeddableFactory.isContainerType

View file

@ -21,3 +21,4 @@ export const DASHBOARD_GRID_COLUMN_COUNT = 48;
export const DASHBOARD_GRID_HEIGHT = 20;
export const DEFAULT_PANEL_WIDTH = DASHBOARD_GRID_COLUMN_COUNT / 2;
export const DEFAULT_PANEL_HEIGHT = 15;
export const DASHBOARD_CONTAINER_TYPE = 'dashboard';

View file

@ -20,7 +20,7 @@
// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';
import { nextTick } from 'test_utils/enzyme_helpers';
import { isErrorEmbeddable, ViewMode, EmbeddableFactory } from '../embeddable_api';
import { isErrorEmbeddable, ViewMode, EmbeddableFactory } from '../embeddable_plugin';
import { DashboardContainer, DashboardContainerOptions } from './dashboard_container';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
import {
@ -29,7 +29,7 @@ import {
ContactCardEmbeddableInput,
ContactCardEmbeddable,
ContactCardEmbeddableOutput,
} from '../../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
} from '../embeddable_plugin_test_samples';
const options: DashboardContainerOptions = {
application: {} as any,

View file

@ -21,8 +21,9 @@ import React from 'react';
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 { RefreshInterval, TimeRange, Query } from '../../../data/public';
import { CoreStart } from '../../../../core/public';
import { IUiActionsStart } from '../ui_actions_plugin';
import {
Container,
ContainerInput,
@ -30,20 +31,18 @@ import {
ViewMode,
EmbeddableFactory,
IEmbeddable,
} from '../../../../../../embeddable_api/public/np_ready/public';
import { DASHBOARD_CONTAINER_TYPE } from './dashboard_container_factory';
Start as EmbeddableStartContract,
} from '../embeddable_plugin';
import { DASHBOARD_CONTAINER_TYPE } from './dashboard_constants';
import { createPanelState } from './panel';
import { DashboardPanelState } from './types';
import { DashboardViewport } from './viewport/dashboard_viewport';
import { Query } from '../../../../../../data/public';
import { CoreStart } from '../../../../../../../../core/public';
import { Start as InspectorStartContract } from '../../../../../../../../plugins/inspector/public';
import { Start as EmbeddableStartContract } from '../../../../../../embeddable_api/public/np_ready/public';
import { Start as InspectorStartContract } from '../../../inspector/public';
import {
KibanaContextProvider,
KibanaReactContext,
KibanaReactContextValue,
KibanaContextProvider,
} from '../../../../../../../../plugins/kibana_react/public';
} from '../../../kibana_react/public';
export interface DashboardContainerInput extends ContainerInput {
viewMode: ViewMode;

View file

@ -18,17 +18,21 @@
*/
import { i18n } from '@kbn/i18n';
import { SavedObjectAttributes } from '../../../../../../../../core/server';
import { SavedObjectAttributes } from '../../../../core/public';
import { SavedObjectMetaData } from '../types';
import { ContainerOutput, EmbeddableFactory, ErrorEmbeddable, Container } from '../embeddable_api';
import {
ContainerOutput,
EmbeddableFactory,
ErrorEmbeddable,
Container,
} from '../embeddable_plugin';
import {
DashboardContainer,
DashboardContainerInput,
DashboardContainerOptions,
} from './dashboard_container';
import { DashboardCapabilities } from '../types';
export const DASHBOARD_CONTAINER_TYPE = 'dashboard';
import { DASHBOARD_CONTAINER_TYPE } from './dashboard_constants';
export interface DashboardOptions extends DashboardContainerOptions {
savedObjectMetaData?: SavedObjectMetaData<SavedObjectAttributes>;

View file

@ -23,15 +23,15 @@ import sizeMe from 'react-sizeme';
import React from 'react';
import { nextTick, mountWithIntl } from 'test_utils/enzyme_helpers';
import { skip } from 'rxjs/operators';
import { EmbeddableFactory, GetEmbeddableFactory } from '../../embeddable_api';
import { EmbeddableFactory, GetEmbeddableFactory } from '../../embeddable_plugin';
import { DashboardGrid, DashboardGridProps } from './dashboard_grid';
import { DashboardContainer, DashboardContainerOptions } from '../dashboard_container';
import { getSampleDashboardInput } from '../../test_helpers';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
} from '../../../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
import { KibanaContextProvider } from '../../../../../../../../../plugins/kibana_react/public';
} from '../../embeddable_plugin_test_samples';
import { KibanaContextProvider } from '../../../../kibana_react/public';
let dashboardContainer: DashboardContainer | undefined;

View file

@ -20,19 +20,21 @@
import 'react-grid-layout/css/styles.css';
import 'react-resizable/css/styles.css';
// @ts-ignore
import sizeMe from 'react-sizeme';
import { injectI18n } from '@kbn/i18n/react';
import classNames from 'classnames';
import _ from 'lodash';
import React from 'react';
import { Subscription } from 'rxjs';
import ReactGridLayout, { Layout } from 'react-grid-layout';
// @ts-ignore
import sizeMe from 'react-sizeme';
import { ViewMode, EmbeddableChildPanel } from '../../embeddable_api';
import { ViewMode, EmbeddableChildPanel } from '../../embeddable_plugin';
import { DASHBOARD_GRID_COLUMN_COUNT, DASHBOARD_GRID_HEIGHT } from '../dashboard_constants';
import { DashboardContainer, DashboardReactContextValue } from '../dashboard_container';
import { DashboardPanelState, GridData } from '../types';
import { withKibana } from '../../../../../../../../../plugins/kibana_react/public';
import { withKibana } from '../../../../kibana_react/public';
import { DashboardContainerInput } from '../dashboard_container';
import { DashboardContainer, DashboardReactContextValue } from '../dashboard_container';
let lastValidGridSize = 0;
@ -174,16 +176,18 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> {
isLayoutInvalid,
});
this.subscription = this.props.container.getInput$().subscribe(input => {
if (this.mounted) {
this.setState({
panels: input.panels,
viewMode: input.viewMode,
useMargins: input.useMargins,
expandedPanelId: input.expandedPanelId,
});
}
});
this.subscription = this.props.container
.getInput$()
.subscribe((input: DashboardContainerInput) => {
if (this.mounted) {
this.setState({
panels: input.panels,
viewMode: input.viewMode,
useMargins: input.useMargins,
expandedPanelId: input.expandedPanelId,
});
}
});
}
public componentWillUnmount() {

View file

@ -17,7 +17,7 @@
* under the License.
*/
export { DASHBOARD_CONTAINER_TYPE, DashboardContainerFactory } from './dashboard_container_factory';
export { DashboardContainerFactory } from './dashboard_container_factory';
export { DashboardContainer, DashboardContainerInput } from './dashboard_container';
export { createPanelState } from './panel';
@ -27,4 +27,5 @@ export {
DASHBOARD_GRID_COLUMN_COUNT,
DEFAULT_PANEL_HEIGHT,
DEFAULT_PANEL_WIDTH,
DASHBOARD_CONTAINER_TYPE,
} from './dashboard_constants';

View file

@ -20,9 +20,8 @@
import { DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_WIDTH } from '../dashboard_constants';
import { DashboardPanelState } from '../types';
import { createPanelState } from './create_panel_state';
import { EmbeddableInput } from '../../embeddable_api';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { CONTACT_CARD_EMBEDDABLE } from '../../../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
import { EmbeddableInput } from '../../embeddable_plugin';
import { CONTACT_CARD_EMBEDDABLE } from '../../embeddable_plugin_test_samples';
interface TestInput extends EmbeddableInput {
test: string;

View file

@ -18,7 +18,7 @@
*/
import _ from 'lodash';
import { PanelState, EmbeddableInput } from '../../embeddable_api';
import { PanelState, EmbeddableInput } from '../../embeddable_plugin';
import {
DASHBOARD_GRID_COLUMN_COUNT,
DEFAULT_PANEL_HEIGHT,

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { PanelState, EmbeddableInput } from '../embeddable_api';
import { PanelState, EmbeddableInput } from '../embeddable_plugin';
export type PanelId = string;
export type SavedObjectId = string;

View file

@ -24,15 +24,15 @@ import { skip } from 'rxjs/operators';
import { mount } from 'enzyme';
import { I18nProvider } from '@kbn/i18n/react';
import { nextTick } from 'test_utils/enzyme_helpers';
import { EmbeddableFactory } from '../../embeddable_api';
import { EmbeddableFactory } from '../../embeddable_plugin';
import { DashboardViewport, DashboardViewportProps } from './dashboard_viewport';
import { DashboardContainer, DashboardContainerOptions } from '../dashboard_container';
import { getSampleDashboardInput } from '../../test_helpers';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
} from '../../../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
import { KibanaContextProvider } from '../../../../../../../../../plugins/kibana_react/public';
} from '../../embeddable_plugin_test_samples';
import { KibanaContextProvider } from '../../../../../plugins/kibana_react/public';
let dashboardContainer: DashboardContainer | undefined;

View file

@ -19,10 +19,10 @@
import React from 'react';
import { Subscription } from 'rxjs';
import { PanelState } from '../../embeddable_api';
import { PanelState } from '../../embeddable_plugin';
import { DashboardContainer, DashboardReactContextValue } from '../dashboard_container';
import { DashboardGrid } from '../grid';
import { context } from '../../../../../../../../../plugins/kibana_react/public';
import { context } from '../../../../kibana_react/public';
export interface DashboardViewportProps {
container: DashboardContainer;

View file

@ -17,4 +17,4 @@
* under the License.
*/
export * from '../../../../../embeddable_api/public/np_ready/public';
export * from '../../../plugins/embeddable/public';

View file

@ -0,0 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// eslint-disable-next-line
export * from '../../../plugins/embeddable/public/lib/test_samples';

View file

@ -0,0 +1,31 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { PluginInitializerContext } from '../../../core/public';
import { DashboardEmbeddableContainerPublicPlugin } from './plugin';
export * from './types';
export * from './actions';
export * from './embeddable';
export function plugin(initializerContext: PluginInitializerContext) {
return new DashboardEmbeddableContainerPublicPlugin(initializerContext);
}
export { DashboardEmbeddableContainerPublicPlugin as Plugin };

View file

@ -17,11 +17,21 @@
* under the License.
*/
/* eslint-disable max-classes-per-file */
import * as React from 'react';
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, ReplacePanelAction, DashboardContainerFactory } from './lib';
import { Start as InspectorStartContract } from '../../../../../../plugins/inspector/public';
import { IUiActionsSetup, IUiActionsStart } from '../../../plugins/ui_actions/public';
import { CONTEXT_MENU_TRIGGER, Plugin as EmbeddablePlugin } from './embeddable_plugin';
import { ExpandPanelAction, ReplacePanelAction } from '.';
import { DashboardContainerFactory } from './embeddable/dashboard_container_factory';
import { Start as InspectorStartContract } from '../../../plugins/inspector/public';
import {
SavedObjectFinder as SavedObjectFinderUi,
SavedObjectFinderProps,
ExitFullScreenButton as ExitFullScreenButtonUi,
ExitFullScreenButtonProps,
} from '../../../plugins/kibana_react/public';
interface SetupDependencies {
embeddable: ReturnType<EmbeddablePlugin['setup']>;
@ -32,10 +42,6 @@ interface StartDependencies {
embeddable: ReturnType<EmbeddablePlugin['start']>;
inspector: InspectorStartContract;
uiActions: IUiActionsStart;
__LEGACY: {
SavedObjectFinder: React.ComponentType<any>;
ExitFullScreenButton: React.ComponentType<any>;
};
}
export type Setup = void;
@ -53,12 +59,35 @@ export class DashboardEmbeddableContainerPublicPlugin
public start(core: CoreStart, plugins: StartDependencies): Start {
const { application, notifications, overlays } = core;
const { embeddable, inspector, __LEGACY, uiActions } = plugins;
const { embeddable, inspector, uiActions } = plugins;
const SavedObjectFinder: React.FC<
Exclude<SavedObjectFinderProps, 'savedObjects' | 'uiSettings'>
> = props => (
<SavedObjectFinderUi
{...props}
savedObjects={core.savedObjects}
uiSettings={core.uiSettings}
/>
);
const useHideChrome = () => {
React.useEffect(() => {
core.chrome.setIsVisible(false);
return () => core.chrome.setIsVisible(true);
}, []);
};
const ExitFullScreenButton: React.FC<ExitFullScreenButtonProps> = props => {
useHideChrome();
return <ExitFullScreenButtonUi {...props} />;
};
const changeViewAction = new ReplacePanelAction(
core,
__LEGACY.SavedObjectFinder,
notifications
SavedObjectFinder,
notifications,
plugins.embeddable.getEmbeddableFactories
);
uiActions.registerAction(changeViewAction);
uiActions.attachAction(CONTEXT_MENU_TRIGGER, changeViewAction.id);
@ -69,8 +98,8 @@ export class DashboardEmbeddableContainerPublicPlugin
overlays,
embeddable,
inspector,
SavedObjectFinder: __LEGACY.SavedObjectFinder,
ExitFullScreenButton: __LEGACY.ExitFullScreenButton,
SavedObjectFinder,
ExitFullScreenButton,
uiActions,
});

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { ViewMode, EmbeddableInput } from '../embeddable_api';
import { ViewMode, EmbeddableInput } from '../embeddable_plugin';
import { DashboardContainerInput, DashboardPanelState } from '../embeddable';
export function getSampleDashboardInput(

View file

@ -23,28 +23,24 @@ import React from 'react';
import { mount } from 'enzyme';
import { nextTick } from 'test_utils/enzyme_helpers';
import { I18nProvider } from '@kbn/i18n/react';
import { ViewMode, CONTEXT_MENU_TRIGGER, EmbeddablePanel } from '../lib/embeddable_api';
import {
DashboardContainer,
DashboardContainerOptions,
} from '../lib/embeddable/dashboard_container';
import { getSampleDashboardInput } from '../lib/test_helpers';
import { ViewMode, CONTEXT_MENU_TRIGGER, EmbeddablePanel } from '../embeddable_plugin';
import { DashboardContainer, DashboardContainerOptions } from '../embeddable/dashboard_container';
import { getSampleDashboardInput } from '../test_helpers';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
} from '../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
import {
ContactCardEmbeddableInput,
ContactCardEmbeddable,
ContactCardEmbeddableOutput,
} from '../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
import { embeddablePluginMock } from '../../../../../embeddable_api/public/np_ready/public/mocks';
import { createEditModeAction } from '../../../../../embeddable_api/public/np_ready/public/lib/test_samples';
createEditModeAction,
} from '../embeddable_plugin_test_samples';
// eslint-disable-next-line
import { inspectorPluginMock } from '../../../../../../../plugins/inspector/public/mocks';
import { KibanaContextProvider } from '../../../../../../../plugins/kibana_react/public';
import { embeddablePluginMock } from '../../../embeddable/public/mocks';
// eslint-disable-next-line
import { uiActionsPluginMock } from 'src/plugins/ui_actions/public/mocks';
import { inspectorPluginMock } from '../../../inspector/public/mocks';
import { KibanaContextProvider } from '../../../kibana_react/public';
// eslint-disable-next-line
import { uiActionsPluginMock } from '../../../ui_actions/public/mocks';
test('DashboardContainer in edit mode shows edit mode actions', async () => {
const inspector = inspectorPluginMock.createStartContract();

View file

@ -18,10 +18,7 @@
*/
import { IconType } from '@elastic/eui';
import {
SavedObject as SavedObjectType,
SavedObjectAttributes,
} from '../../../../../../../core/server';
import { SavedObject as SavedObjectType, SavedObjectAttributes } from '../../../core/public';
export interface DashboardCapabilities {
showWriteControls: boolean;

View file

@ -17,6 +17,4 @@
* under the License.
*/
export * from './types';
export * from './actions';
export * from './embeddable';
export * from '../../../plugins/ui_actions/public';

View file

@ -0,0 +1,3 @@
@import './variables';
@import './lib/panel/index';
@import './lib/panel/panel_header/index';

View file

@ -21,7 +21,7 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { context, createKibanaReactContext, useKibana, KibanaContextProvider } from './context';
import { coreMock, overlayServiceMock } from '../../../../core/public/mocks';
import { CoreStart } from './types';
import { CoreStart } from '../../../../core/public';
let container: HTMLDivElement | null;

View file

@ -22,8 +22,6 @@ import { CoreStart } from '../../../../core/public';
import { KibanaReactOverlays } from '../overlays';
import { KibanaReactNotifications } from '../notifications';
export { CoreStart };
export type KibanaServices = Partial<CoreStart>;
export interface KibanaReactContextValue<Services extends KibanaServices> {

View file

@ -24,11 +24,11 @@ import { EuiScreenReaderOnly, keyCodes } from '@elastic/eui';
// @ts-ignore
import { KuiButton } from '@kbn/ui-framework/components';
interface Props {
export interface ExitFullScreenButtonProps {
onExitFullScreenMode: () => void;
}
class ExitFullScreenButtonUi extends PureComponent<Props> {
class ExitFullScreenButtonUi extends PureComponent<ExitFullScreenButtonProps> {
public onKeyDown = (e: KeyboardEvent) => {
if (e.keyCode === keyCodes.ESCAPE) {
this.props.onExitFullScreenMode();

View file

@ -17,4 +17,4 @@
* under the License.
*/
export { ExitFullScreenButton } from './exit_full_screen_button';
export { ExitFullScreenButton, ExitFullScreenButtonProps } from './exit_full_screen_button';

View file

@ -18,7 +18,7 @@
*/
import * as React from 'react';
import { CoreStart } from '../context/types';
import { CoreStart } from '../../../../core/public';
export interface KibanaReactOverlays {
openFlyout: (

View file

@ -104,7 +104,7 @@ interface SavedObjectFinderInitialPageSize extends BaseSavedObjectFinder {
initialPageSize?: 5 | 10 | 15 | 25;
fixedPageSize?: undefined;
}
type SavedObjectFinderProps = {
export type SavedObjectFinderProps = {
savedObjects: CoreStart['savedObjects'];
uiSettings: CoreStart['uiSettings'];
} & (SavedObjectFinderFixedPage | SavedObjectFinderInitialPageSize);

View file

@ -24,7 +24,7 @@ import { PIE_CHART_VIS_NAME, AREA_CHART_VIS_NAME } from '../../page_objects/dash
// eslint-disable-next-line
import {
DEFAULT_PANEL_WIDTH
} from '../../../../src/legacy/core_plugins/dashboard_embeddable_container/public/np_ready/public/lib/embeddable/dashboard_constants';
} from '../../../../src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_constants';
export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['dashboard', 'visualize', 'header', 'discover']);