From 9c977f1acd58c2799d4b32c9e85469192cc29c5f Mon Sep 17 00:00:00 2001 From: Alex Wild Date: Sun, 7 Jun 2020 15:13:33 +0100 Subject: [PATCH] Hide components in full screen when embedded --- .../application/dashboard_app_controller.tsx | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/plugins/dashboard/public/application/dashboard_app_controller.tsx b/src/plugins/dashboard/public/application/dashboard_app_controller.tsx index 0e77a0c597878c9..cd2e97b2938e3a5 100644 --- a/src/plugins/dashboard/public/application/dashboard_app_controller.tsx +++ b/src/plugins/dashboard/public/application/dashboard_app_controller.tsx @@ -154,11 +154,6 @@ export class DashboardAppController { const queryFilter = filterManager; const timefilter = queryService.timefilter.timefilter; const isEmbeddedExternally = Boolean($routeParams.embed); - let showTopNavMenu = true; - let showSearchBar = true; - let showQueryBar = true; - let showQueryInput = true; - let showDatePicker = true; // url param rules should only apply when embedded (e.g. url?embed=true) const shouldForceDisplay = (param: string): boolean => @@ -284,10 +279,6 @@ export class DashboardAppController { } }; - const showFilterBar = () => - !forceHideFilterBar && - ($scope.model.filters.length > 0 || !dashboardStateManager.getFullScreenMode()); - const getEmptyScreenProps = ( shouldShowEditHelp: boolean, isEmptyInReadOnlyMode: boolean @@ -625,9 +616,23 @@ export class DashboardAppController { dashboardStateManager.setSavedQueryId(savedQueryId); }; + const shouldShowFilterBar = () => + !forceHideFilterBar && + ($scope.model.filters.length > 0 || !dashboardStateManager.getFullScreenMode()); + + const shouldShowNavBarComponent = (forceShow: boolean) => + (forceShow || $scope.isVisible) && !dashboardStateManager.getFullScreenMode(); + const getNavBarProps = () => { const isFullScreenMode = dashboardStateManager.getFullScreenMode(); const screenTitle = dashboardStateManager.getTitle(); + const showTopNavMenu = shouldShowNavBarComponent(forceShowTopNavMenu); + const showQueryInput = shouldShowNavBarComponent(forceShowQueryInput); + const showDatePicker = shouldShowNavBarComponent(forceShowDatePicker); + const showQueryBar = showQueryInput || showDatePicker; + const showFilterBar = shouldShowFilterBar(); + const showSearchBar = showQueryBar || showFilterBar; + return { appName: 'dashboard', config: showTopNavMenu ? $scope.topNavMenu : undefined, @@ -638,7 +643,7 @@ export class DashboardAppController { showQueryBar, showQueryInput, showDatePicker, - showFilterBar: showFilterBar(), + showFilterBar, indexPatterns: $scope.indexPatterns, showSaveQuery: $scope.showSaveQuery, query: $scope.model.query, @@ -1071,16 +1076,7 @@ export class DashboardAppController { const visibleSubscription = chrome.getIsVisible$().subscribe((isVisible) => { $scope.$evalAsync(() => { - const shouldShow = (forceShow: boolean) => - (forceShow || isVisible) && !dashboardStateManager.getFullScreenMode(); - $scope.isVisible = isVisible; - showTopNavMenu = shouldShow(forceShowTopNavMenu); - showQueryInput = shouldShow(forceShowQueryInput); - showDatePicker = shouldShow(forceShowDatePicker); - showQueryBar = showQueryInput || showDatePicker; - showSearchBar = showQueryBar || showFilterBar(); - updateNavBar(); }); });