diff --git a/src/core_plugins/kibana/public/dashboard/actions/view.js b/src/core_plugins/kibana/public/dashboard/actions/view.js index 552a7d76c0813..79aa1ca3de96f 100644 --- a/src/core_plugins/kibana/public/dashboard/actions/view.js +++ b/src/core_plugins/kibana/public/dashboard/actions/view.js @@ -5,3 +5,4 @@ export const maximizePanel = createAction('MAXIMIZE_PANEl'); export const minimizePanel = createAction('MINIMIZE_PANEL'); export const updateIsFullScreenMode = createAction('UPDATE_IS_FULL_SCREEN_MODE'); export const updateUseMargins = createAction('UPDATE_USE_MARGINS'); +export const updateHidePanelTitles = createAction('HIDE_PANEL_TITLES'); diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_app.js b/src/core_plugins/kibana/public/dashboard/dashboard_app.js index a8c4ceffc8f20..e0d3195fa9f8d 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_app.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard_app.js @@ -91,6 +91,7 @@ app.directive('dashboardApp', function ($injector) { $scope.model = { query: dashboardStateManager.getQuery(), useMargins: dashboardStateManager.getUseMargins(), + hidePanelTitles: dashboardStateManager.getHidePanelTitles(), darkTheme: dashboardStateManager.getDarkTheme(), timeRestore: dashboardStateManager.getTimeRestore(), title: dashboardStateManager.getTitle(), @@ -181,6 +182,9 @@ app.directive('dashboardApp', function ($injector) { dashboardStateManager.addNewPanel(hit.id, 'search'); notify.info(`Search successfully added to your dashboard`); }; + $scope.$watch('model.hidePanelTitles', () => { + dashboardStateManager.setHidePanelTitles($scope.model.hidePanelTitles); + }); $scope.$watch('model.useMargins', () => { dashboardStateManager.setUseMargins($scope.model.useMargins); }); diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_container_api.js b/src/core_plugins/kibana/public/dashboard/dashboard_container_api.js index 98a6c7967c3d8..5b5fb276569f4 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_container_api.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard_container_api.js @@ -24,4 +24,7 @@ export class DashboardContainerAPI extends ContainerAPI { this.dashboardState.saveState(); } + getHidePanelTitles() { + return this.dashboardState.getHidePanelTitles(); + } } diff --git a/src/core_plugins/kibana/public/dashboard/dashboard_state_manager.js b/src/core_plugins/kibana/public/dashboard/dashboard_state_manager.js index 669007e3615c2..b906aebd54eb5 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard_state_manager.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard_state_manager.js @@ -13,6 +13,7 @@ import { minimizePanel, updateTitle, updateDescription, + updateHidePanelTitles, } from './actions'; import { stateMonitorFactory } from 'ui/state_management/state_monitor_factory'; import { createPanelState, getPersistedStateId } from './panel'; @@ -25,6 +26,7 @@ import { getTitle, getDescription, getUseMargins, + getHidePanelTitles, } from '../selectors'; /** @@ -85,6 +87,7 @@ export class DashboardStateManager { store.dispatch(setPanels(this.getPanels())); store.dispatch(updateViewMode(this.getViewMode())); store.dispatch(updateUseMargins(this.getUseMargins())); + store.dispatch(updateHidePanelTitles(this.getHidePanelTitles())); store.dispatch(updateIsFullScreenMode(this.getFullScreenMode())); store.dispatch(updateTitle(this.getTitle())); store.dispatch(updateDescription(this.getDescription())); @@ -138,6 +141,10 @@ export class DashboardStateManager { store.dispatch(updateUseMargins(this.getUseMargins())); } + if (getHidePanelTitles(state) !== this.getHidePanelTitles()) { + store.dispatch(updateHidePanelTitles(this.getHidePanelTitles())); + } + if (getFullScreenMode(state) !== this.getFullScreenMode()) { store.dispatch(updateIsFullScreenMode(this.getFullScreenMode())); } @@ -270,6 +277,15 @@ export class DashboardStateManager { this.saveState(); } + getHidePanelTitles() { + return this.appState.options.hidePanelTitles; + } + + setHidePanelTitles(hidePanelTitles) { + this.appState.options.hidePanelTitles = hidePanelTitles; + this.saveState(); + } + getDarkTheme() { return this.appState.options.darkTheme; } diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header.js b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header.js index 2d15633c69e9a..b61f3b4a77688 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header.js +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header.js @@ -1,8 +1,8 @@ import React from 'react'; import PropTypes from 'prop-types'; -export function PanelHeader({ title, actions, isViewOnlyMode }) { - if (isViewOnlyMode && !title) { +export function PanelHeader({ title, actions, isViewOnlyMode, hidePanelTitles }) { + if (isViewOnlyMode && (!title || hidePanelTitles)) { return (