From 0b4a66e6ddedc4896293c2048fcf673550a3cf94 Mon Sep 17 00:00:00 2001 From: Maja Grubic Date: Fri, 6 Dec 2019 11:42:14 +0000 Subject: [PATCH] Re-adding emptyState, reintroducing functional test --- .../dashboard/dashboard_app_controller.tsx | 3 +++ .../viewport/dashboard_viewport.test.tsx | 3 ++- .../viewport/dashboard_viewport.tsx | 21 ++++++++++++++++--- .../apps/dashboard/full_screen_mode.js | 6 ++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx index 13b10a9b4327b..b6d445c9ae560 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx @@ -202,6 +202,8 @@ export class DashboardAppController { if (dashboardContainer && !isErrorEmbeddable(dashboardContainer)) { expandedPanelId = dashboardContainer.getInput().expandedPanelId; } + const shouldShowEditHelp = $scope.getShouldShowEditHelp(); + const shouldShowViewHelp = $scope.getShouldShowViewHelp(); return { id: dashboardStateManager.savedDashboard.id || '', filters: queryFilter.getFilters(), @@ -214,6 +216,7 @@ export class DashboardAppController { viewMode: dashboardStateManager.getViewMode(), panels: embeddablesMap, isFullScreenMode: dashboardStateManager.getFullScreenMode(), + isEmptyState: shouldShowEditHelp || shouldShowViewHelp, useMargins: dashboardStateManager.getUseMargins(), lastReloadRequestTime, title: dashboardStateManager.getTitle(), diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx index 85222cde274d7..e3d9b8552f060 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.test.tsx @@ -124,6 +124,7 @@ test('renders DashboardViewport with no visualizations', () => { test('renders DashboardEmptyScreen', () => { const renderEmptyScreen = jest.fn(); const { props, options } = getProps({ renderEmpty: renderEmptyScreen }); + props.container.updateInput({ isEmptyState: true }); const component = mount( @@ -174,7 +175,7 @@ test('renders exit full screen button when in full screen mode and empty screen' const renderEmptyScreen = jest.fn(); renderEmptyScreen.mockReturnValue(React.createElement('div')); const { props, options } = getProps({ renderEmpty: renderEmptyScreen }); - props.container.updateInput({ isFullScreenMode: true }); + props.container.updateInput({ isEmptyState: true, isFullScreenMode: true }); const component = mount( diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.tsx index 24f7123d527f5..e7fd379898dd1 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/viewport/dashboard_viewport.tsx @@ -35,6 +35,7 @@ interface State { title: string; description?: string; panels: { [key: string]: PanelState }; + isEmptyState?: boolean; } export class DashboardViewport extends React.Component { @@ -45,26 +46,40 @@ export class DashboardViewport extends React.Component { - const { isFullScreenMode, useMargins, title, description } = this.props.container.getInput(); + const { + isFullScreenMode, + useMargins, + title, + description, + isEmptyState, + } = this.props.container.getInput(); if (this.mounted) { this.setState({ isFullScreenMode, description, useMargins, title, + isEmptyState, }); } }); @@ -122,7 +137,7 @@ export class DashboardViewport extends React.Component - {this.props.renderEmpty ? this.renderEmptyScreen() : null} + {this.state.isEmptyState ? this.renderEmptyScreen() : null} {this.renderContainerScreen()} ); diff --git a/test/functional/apps/dashboard/full_screen_mode.js b/test/functional/apps/dashboard/full_screen_mode.js index 1f75fda48af2b..33ce628a02cc0 100644 --- a/test/functional/apps/dashboard/full_screen_mode.js +++ b/test/functional/apps/dashboard/full_screen_mode.js @@ -74,10 +74,12 @@ export default function ({ getService, getPageObjects }) { expect(exists).to.be(true); }); - it.skip('exits when the logo button is clicked on', async () => { + it('exits when the text button is clicked on', async () => { await PageObjects.dashboard.clickFullScreenMode(); await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.dashboard.clickExitFullScreenLogoButton(); + const logoButton = await PageObjects.dashboard.getExitFullScreenLogoButton(); + await logoButton.moveMouseTo(); + await PageObjects.dashboard.clickExitFullScreenTextButton(); await retry.try(async () => { const isChromeVisible = await PageObjects.common.isChromeVisible(); expect(isChromeVisible).to.be(true);