2021-09-23 09:20:11 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-09-23 14:39:05 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2021-09-23 09:20:11 +00:00
|
|
|
import {
|
|
|
|
SET_TOOLBOX_ENABLED,
|
|
|
|
SET_TOOLBOX_VISIBLE
|
|
|
|
} from './actionTypes';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables/disables the toolbox.
|
|
|
|
*
|
|
|
|
* @param {boolean} enabled - True to enable the toolbox or false to disable it.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_TOOLBOX_ENABLED,
|
|
|
|
* enabled: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setToolboxEnabled(enabled: boolean): Object {
|
|
|
|
return {
|
|
|
|
type: SET_TOOLBOX_ENABLED,
|
|
|
|
enabled
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows/hides the toolbox.
|
|
|
|
*
|
|
|
|
* @param {boolean} visible - True to show the toolbox or false to hide it.
|
2021-09-23 14:39:05 +00:00
|
|
|
* @returns {Function}
|
2021-09-23 09:20:11 +00:00
|
|
|
*/
|
|
|
|
export function setToolboxVisible(visible: boolean): Object {
|
2021-09-23 14:39:05 +00:00
|
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
|
|
|
const { toolbarConfig: { alwaysVisible } } = getState()['features/base/config'];
|
|
|
|
|
|
|
|
if (!visible && alwaysVisible) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SET_TOOLBOX_VISIBLE,
|
|
|
|
visible
|
|
|
|
});
|
2021-09-23 09:20:11 +00:00
|
|
|
};
|
|
|
|
}
|