mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 18:27:59 -04:00
* Hide all panel titles option at the dashboard level * Hide panel titles in edit mode too
This commit is contained in:
parent
a492c01fcd
commit
a9ce9eee36
14 changed files with 69 additions and 7 deletions
|
@ -5,3 +5,4 @@ export const maximizePanel = createAction('MAXIMIZE_PANEl');
|
||||||
export const minimizePanel = createAction('MINIMIZE_PANEL');
|
export const minimizePanel = createAction('MINIMIZE_PANEL');
|
||||||
export const updateIsFullScreenMode = createAction('UPDATE_IS_FULL_SCREEN_MODE');
|
export const updateIsFullScreenMode = createAction('UPDATE_IS_FULL_SCREEN_MODE');
|
||||||
export const updateUseMargins = createAction('UPDATE_USE_MARGINS');
|
export const updateUseMargins = createAction('UPDATE_USE_MARGINS');
|
||||||
|
export const updateHidePanelTitles = createAction('HIDE_PANEL_TITLES');
|
||||||
|
|
|
@ -91,6 +91,7 @@ app.directive('dashboardApp', function ($injector) {
|
||||||
$scope.model = {
|
$scope.model = {
|
||||||
query: dashboardStateManager.getQuery(),
|
query: dashboardStateManager.getQuery(),
|
||||||
useMargins: dashboardStateManager.getUseMargins(),
|
useMargins: dashboardStateManager.getUseMargins(),
|
||||||
|
hidePanelTitles: dashboardStateManager.getHidePanelTitles(),
|
||||||
darkTheme: dashboardStateManager.getDarkTheme(),
|
darkTheme: dashboardStateManager.getDarkTheme(),
|
||||||
timeRestore: dashboardStateManager.getTimeRestore(),
|
timeRestore: dashboardStateManager.getTimeRestore(),
|
||||||
title: dashboardStateManager.getTitle(),
|
title: dashboardStateManager.getTitle(),
|
||||||
|
@ -181,6 +182,9 @@ app.directive('dashboardApp', function ($injector) {
|
||||||
dashboardStateManager.addNewPanel(hit.id, 'search');
|
dashboardStateManager.addNewPanel(hit.id, 'search');
|
||||||
notify.info(`Search successfully added to your dashboard`);
|
notify.info(`Search successfully added to your dashboard`);
|
||||||
};
|
};
|
||||||
|
$scope.$watch('model.hidePanelTitles', () => {
|
||||||
|
dashboardStateManager.setHidePanelTitles($scope.model.hidePanelTitles);
|
||||||
|
});
|
||||||
$scope.$watch('model.useMargins', () => {
|
$scope.$watch('model.useMargins', () => {
|
||||||
dashboardStateManager.setUseMargins($scope.model.useMargins);
|
dashboardStateManager.setUseMargins($scope.model.useMargins);
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,4 +24,7 @@ export class DashboardContainerAPI extends ContainerAPI {
|
||||||
this.dashboardState.saveState();
|
this.dashboardState.saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHidePanelTitles() {
|
||||||
|
return this.dashboardState.getHidePanelTitles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
minimizePanel,
|
minimizePanel,
|
||||||
updateTitle,
|
updateTitle,
|
||||||
updateDescription,
|
updateDescription,
|
||||||
|
updateHidePanelTitles,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
|
import { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
|
||||||
import { createPanelState, getPersistedStateId } from './panel';
|
import { createPanelState, getPersistedStateId } from './panel';
|
||||||
|
@ -25,6 +26,7 @@ import {
|
||||||
getTitle,
|
getTitle,
|
||||||
getDescription,
|
getDescription,
|
||||||
getUseMargins,
|
getUseMargins,
|
||||||
|
getHidePanelTitles,
|
||||||
} from '../selectors';
|
} from '../selectors';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,6 +87,7 @@ export class DashboardStateManager {
|
||||||
store.dispatch(setPanels(this.getPanels()));
|
store.dispatch(setPanels(this.getPanels()));
|
||||||
store.dispatch(updateViewMode(this.getViewMode()));
|
store.dispatch(updateViewMode(this.getViewMode()));
|
||||||
store.dispatch(updateUseMargins(this.getUseMargins()));
|
store.dispatch(updateUseMargins(this.getUseMargins()));
|
||||||
|
store.dispatch(updateHidePanelTitles(this.getHidePanelTitles()));
|
||||||
store.dispatch(updateIsFullScreenMode(this.getFullScreenMode()));
|
store.dispatch(updateIsFullScreenMode(this.getFullScreenMode()));
|
||||||
store.dispatch(updateTitle(this.getTitle()));
|
store.dispatch(updateTitle(this.getTitle()));
|
||||||
store.dispatch(updateDescription(this.getDescription()));
|
store.dispatch(updateDescription(this.getDescription()));
|
||||||
|
@ -138,6 +141,10 @@ export class DashboardStateManager {
|
||||||
store.dispatch(updateUseMargins(this.getUseMargins()));
|
store.dispatch(updateUseMargins(this.getUseMargins()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getHidePanelTitles(state) !== this.getHidePanelTitles()) {
|
||||||
|
store.dispatch(updateHidePanelTitles(this.getHidePanelTitles()));
|
||||||
|
}
|
||||||
|
|
||||||
if (getFullScreenMode(state) !== this.getFullScreenMode()) {
|
if (getFullScreenMode(state) !== this.getFullScreenMode()) {
|
||||||
store.dispatch(updateIsFullScreenMode(this.getFullScreenMode()));
|
store.dispatch(updateIsFullScreenMode(this.getFullScreenMode()));
|
||||||
}
|
}
|
||||||
|
@ -270,6 +277,15 @@ export class DashboardStateManager {
|
||||||
this.saveState();
|
this.saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHidePanelTitles() {
|
||||||
|
return this.appState.options.hidePanelTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
setHidePanelTitles(hidePanelTitles) {
|
||||||
|
this.appState.options.hidePanelTitles = hidePanelTitles;
|
||||||
|
this.saveState();
|
||||||
|
}
|
||||||
|
|
||||||
getDarkTheme() {
|
getDarkTheme() {
|
||||||
return this.appState.options.darkTheme;
|
return this.appState.options.darkTheme;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
export function PanelHeader({ title, actions, isViewOnlyMode }) {
|
export function PanelHeader({ title, actions, isViewOnlyMode, hidePanelTitles }) {
|
||||||
if (isViewOnlyMode && !title) {
|
if (isViewOnlyMode && (!title || hidePanelTitles)) {
|
||||||
return (
|
return (
|
||||||
<div className="panel-heading-floater">
|
<div className="panel-heading-floater">
|
||||||
<div className="kuiMicroButtonGroup">
|
<div className="kuiMicroButtonGroup">
|
||||||
|
@ -20,7 +20,7 @@ export function PanelHeader({ title, actions, isViewOnlyMode }) {
|
||||||
title={title}
|
title={title}
|
||||||
aria-label={`Dashboard panel: ${title}`}
|
aria-label={`Dashboard panel: ${title}`}
|
||||||
>
|
>
|
||||||
{title}
|
{hidePanelTitles ? '' : title}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div className="kuiMicroButtonGroup">
|
<div className="kuiMicroButtonGroup">
|
||||||
|
@ -34,4 +34,5 @@ PanelHeader.propTypes = {
|
||||||
isViewOnlyMode: PropTypes.bool,
|
isViewOnlyMode: PropTypes.bool,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
actions: PropTypes.node,
|
actions: PropTypes.node,
|
||||||
|
hidePanelTitles: PropTypes.bool.isRequired,
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,8 @@ import {
|
||||||
getPanel,
|
getPanel,
|
||||||
getMaximizedPanelId,
|
getMaximizedPanelId,
|
||||||
getFullScreenMode,
|
getFullScreenMode,
|
||||||
getViewMode
|
getViewMode,
|
||||||
|
getHidePanelTitles,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
|
|
||||||
const mapStateToProps = ({ dashboard }, { panelId }) => {
|
const mapStateToProps = ({ dashboard }, { panelId }) => {
|
||||||
|
@ -29,6 +30,7 @@ const mapStateToProps = ({ dashboard }, { panelId }) => {
|
||||||
title: panel.title === undefined ? embeddableTitle : panel.title,
|
title: panel.title === undefined ? embeddableTitle : panel.title,
|
||||||
isExpanded: getMaximizedPanelId(dashboard) === panelId,
|
isExpanded: getMaximizedPanelId(dashboard) === panelId,
|
||||||
isViewOnlyMode: getFullScreenMode(dashboard) || getViewMode(dashboard) === DashboardViewMode.VIEW,
|
isViewOnlyMode: getFullScreenMode(dashboard) || getViewMode(dashboard) === DashboardViewMode.VIEW,
|
||||||
|
hidePanelTitles: getHidePanelTitles(dashboard),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ const mapDispatchToProps = (dispatch, { panelId }) => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
||||||
const { isExpanded, isViewOnlyMode, title } = stateProps;
|
const { isExpanded, isViewOnlyMode, title, hidePanelTitles } = stateProps;
|
||||||
const { onMaximizePanel, onMinimizePanel } = dispatchProps;
|
const { onMaximizePanel, onMinimizePanel } = dispatchProps;
|
||||||
const { panelId, embeddableFactory } = ownProps;
|
const { panelId, embeddableFactory } = ownProps;
|
||||||
let actions;
|
let actions;
|
||||||
|
@ -60,6 +62,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
||||||
title,
|
title,
|
||||||
actions,
|
actions,
|
||||||
isViewOnlyMode,
|
isViewOnlyMode,
|
||||||
|
hidePanelTitles,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
maximizePanel,
|
maximizePanel,
|
||||||
minimizePanel,
|
minimizePanel,
|
||||||
updateUseMargins,
|
updateUseMargins,
|
||||||
|
updateHidePanelTitles,
|
||||||
updateIsFullScreenMode,
|
updateIsFullScreenMode,
|
||||||
} from '../actions';
|
} from '../actions';
|
||||||
|
|
||||||
|
@ -20,6 +21,11 @@ export const view = handleActions({
|
||||||
useMargins: payload
|
useMargins: payload
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
[updateHidePanelTitles]: (state, { payload }) => ({
|
||||||
|
...state,
|
||||||
|
hidePanelTitles: payload
|
||||||
|
}),
|
||||||
|
|
||||||
[combineActions(maximizePanel, minimizePanel)]: (state, { payload }) => ({
|
[combineActions(maximizePanel, minimizePanel)]: (state, { payload }) => ({
|
||||||
...state,
|
...state,
|
||||||
maximizedPanelId: payload
|
maximizedPanelId: payload
|
||||||
|
@ -34,4 +40,5 @@ export const view = handleActions({
|
||||||
viewMode: DashboardViewMode.VIEW,
|
viewMode: DashboardViewMode.VIEW,
|
||||||
maximizedPanelId: undefined,
|
maximizedPanelId: undefined,
|
||||||
useMargins: true,
|
useMargins: true,
|
||||||
|
hidePanelTitles: false,
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,6 +28,7 @@ module.factory('SavedDashboard', function (courier, config) {
|
||||||
darkTheme: config.get('dashboard:defaultDarkTheme'),
|
darkTheme: config.get('dashboard:defaultDarkTheme'),
|
||||||
// for BWC reasons we can't default dashboards that already exist without this setting to true.
|
// for BWC reasons we can't default dashboards that already exist without this setting to true.
|
||||||
useMargins: id ? false : true,
|
useMargins: id ? false : true,
|
||||||
|
hidePanelTitles: false,
|
||||||
}),
|
}),
|
||||||
uiStateJSON: '{}',
|
uiStateJSON: '{}',
|
||||||
version: 1,
|
version: 1,
|
||||||
|
|
|
@ -79,6 +79,11 @@ export const getViewMode = dashboard => dashboard.view.viewMode;
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
export const getFullScreenMode = dashboard => dashboard.view.isFullScreenMode;
|
export const getFullScreenMode = dashboard => dashboard.view.isFullScreenMode;
|
||||||
|
/**
|
||||||
|
* @param dashboard {DashboardState}
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
export const getHidePanelTitles = dashboard => dashboard.view.hidePanelTitles;
|
||||||
/**
|
/**
|
||||||
* @param dashboard {DashboardState}
|
* @param dashboard {DashboardState}
|
||||||
* @return {string|undefined}
|
* @return {string|undefined}
|
||||||
|
|
|
@ -29,5 +29,17 @@
|
||||||
Use margins between panels
|
Use margins between panels
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="kuiCheckBoxLabel">
|
||||||
|
<input
|
||||||
|
class="kuiCheckBox"
|
||||||
|
type="checkbox"
|
||||||
|
ng-model="model.hidePanelTitles"
|
||||||
|
ng-checked="model.hidePanelTitles"
|
||||||
|
data-test-subj="dashboardPanelTitlesCheckbox"
|
||||||
|
>
|
||||||
|
<span class="kuiCheckBoxLabel__text">
|
||||||
|
Hide all panel titles
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -31,7 +31,9 @@ export class SearchEmbeddableFactory extends EmbeddableFactory {
|
||||||
searchScope.editPath = this.getEditPath(panel.id);
|
searchScope.editPath = this.getEditPath(panel.id);
|
||||||
return this.searchLoader.get(panel.id)
|
return this.searchLoader.get(panel.id)
|
||||||
.then(savedObject => {
|
.then(savedObject => {
|
||||||
searchScope.sharedItemTitle = panel.title !== undefined ? panel.title : savedObject.title;
|
if (!container.getHidePanelTitles()) {
|
||||||
|
searchScope.sharedItemTitle = panel.title !== undefined ? panel.title : savedObject.title;
|
||||||
|
}
|
||||||
searchScope.savedObj = savedObject;
|
searchScope.savedObj = savedObject;
|
||||||
searchScope.panel = panel;
|
searchScope.panel = panel;
|
||||||
container.registerPanelIndexPattern(panel.panelIndex, savedObject.searchSource.get('index'));
|
container.registerPanelIndexPattern(panel.panelIndex, savedObject.searchSource.get('index'));
|
||||||
|
|
|
@ -24,6 +24,7 @@ export const getViewMode = state => DashboardSelectors.getViewMode(getDashboard(
|
||||||
export const getFullScreenMode = state => DashboardSelectors.getFullScreenMode(getDashboard(state));
|
export const getFullScreenMode = state => DashboardSelectors.getFullScreenMode(getDashboard(state));
|
||||||
export const getMaximizedPanelId = state => DashboardSelectors.getMaximizedPanelId(getDashboard(state));
|
export const getMaximizedPanelId = state => DashboardSelectors.getMaximizedPanelId(getDashboard(state));
|
||||||
export const getUseMargins = state => DashboardSelectors.getUseMargins(getDashboard(state));
|
export const getUseMargins = state => DashboardSelectors.getUseMargins(getDashboard(state));
|
||||||
|
export const getHidePanelTitles = state => DashboardSelectors.getHidePanelTitles(getDashboard(state));
|
||||||
|
|
||||||
export const getTitle = state => DashboardSelectors.getTitle(getDashboard(state));
|
export const getTitle = state => DashboardSelectors.getTitle(getDashboard(state));
|
||||||
export const getDescription = state => DashboardSelectors.getDescription(getDashboard(state));
|
export const getDescription = state => DashboardSelectors.getDescription(getDashboard(state));
|
||||||
|
|
|
@ -30,7 +30,9 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory {
|
||||||
visualizeScope.editUrl = this.getEditPath(panel.id);
|
visualizeScope.editUrl = this.getEditPath(panel.id);
|
||||||
return this.visualizeLoader.get(panel.id)
|
return this.visualizeLoader.get(panel.id)
|
||||||
.then(savedObject => {
|
.then(savedObject => {
|
||||||
visualizeScope.sharedItemTitle = panel.title !== undefined ? panel.title : savedObject.title;
|
if (!container.getHidePanelTitles()) {
|
||||||
|
visualizeScope.sharedItemTitle = panel.title !== undefined ? panel.title : savedObject.title;
|
||||||
|
}
|
||||||
visualizeScope.savedObj = savedObject;
|
visualizeScope.savedObj = savedObject;
|
||||||
visualizeScope.panel = panel;
|
visualizeScope.panel = panel;
|
||||||
|
|
||||||
|
|
|
@ -48,4 +48,8 @@ export class ContainerAPI {
|
||||||
updatePanel(/*paneIndex, panelAttributes */) {
|
updatePanel(/*paneIndex, panelAttributes */) {
|
||||||
throw new Error('Must implement updatePanel.');
|
throw new Error('Must implement updatePanel.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHidePanelTitles() {
|
||||||
|
return this.dashboardState.getHidePanelTitles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue