2021-09-23 09:20:11 +00:00
|
|
|
// @flow
|
2017-02-16 23:02:40 +00:00
|
|
|
|
2021-09-23 14:39:05 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2021-09-23 09:20:11 +00:00
|
|
|
import { TOGGLE_TOOLBOX_VISIBLE } from './actionTypes';
|
2017-02-16 23:02:40 +00:00
|
|
|
|
2021-09-23 09:20:11 +00:00
|
|
|
export * from './actions.any';
|
2019-06-19 12:44:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Action to toggle the toolbox visibility.
|
|
|
|
*
|
2021-09-23 14:39:05 +00:00
|
|
|
* @returns {Function}
|
2019-06-19 12:44:39 +00:00
|
|
|
*/
|
|
|
|
export function toggleToolboxVisible() {
|
2021-09-23 14:39:05 +00:00
|
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
|
|
|
const state = getState();
|
|
|
|
const { toolbarConfig: { alwaysVisible } } = state['features/base/config'];
|
|
|
|
const { visible } = state['features/toolbox'];
|
|
|
|
|
|
|
|
if (visible && alwaysVisible) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: TOGGLE_TOOLBOX_VISIBLE
|
|
|
|
});
|
2019-06-19 12:44:39 +00:00
|
|
|
};
|
|
|
|
}
|