2022-09-01 11:00:49 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
|
|
|
import { set } from '../base/redux/functions';
|
2017-02-16 23:02:40 +00:00
|
|
|
|
|
|
|
import {
|
2017-04-01 05:52:40 +00:00
|
|
|
CLEAR_TOOLBOX_TIMEOUT,
|
2018-03-07 00:28:19 +00:00
|
|
|
FULL_SCREEN_CHANGED,
|
2022-08-26 18:25:04 +00:00
|
|
|
SET_HANGUP_MENU_VISIBLE,
|
2021-01-04 13:30:23 +00:00
|
|
|
SET_OVERFLOW_DRAWER,
|
2018-04-20 11:24:14 +00:00
|
|
|
SET_OVERFLOW_MENU_VISIBLE,
|
2017-02-16 23:02:40 +00:00
|
|
|
SET_TOOLBAR_HOVERED,
|
2017-04-12 19:06:56 +00:00
|
|
|
SET_TOOLBOX_ENABLED,
|
2017-04-01 05:52:40 +00:00
|
|
|
SET_TOOLBOX_TIMEOUT,
|
2019-06-19 12:44:39 +00:00
|
|
|
SET_TOOLBOX_VISIBLE,
|
|
|
|
TOGGLE_TOOLBOX_VISIBLE
|
2017-02-16 23:02:40 +00:00
|
|
|
} from './actionTypes';
|
|
|
|
|
|
|
|
/**
|
2021-09-23 14:39:05 +00:00
|
|
|
* Initial state of toolbox's part of Redux store.
|
2017-02-16 23:02:40 +00:00
|
|
|
*/
|
2021-09-23 14:39:05 +00:00
|
|
|
const INITIAL_STATE = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the Toolbox is enabled.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
enabled: true,
|
|
|
|
|
2022-08-26 18:25:04 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether the hangup menu is visible.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
hangupMenuVisible: false,
|
|
|
|
|
2021-09-23 14:39:05 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether a Toolbar in the Toolbox is
|
|
|
|
* hovered.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
hovered: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the overflow menu(s) are to be displayed as drawers.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
overflowDrawer: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the OverflowMenu is visible.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
overflowMenuVisible: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A number, non-zero value which identifies the timer created by a call
|
|
|
|
* to setTimeout().
|
|
|
|
*
|
|
|
|
* @type {number|null}
|
|
|
|
*/
|
|
|
|
timeoutID: null,
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator that determines whether the Toolbox is visible.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
visible: false
|
|
|
|
};
|
2017-02-16 23:02:40 +00:00
|
|
|
|
2022-09-01 11:00:49 +00:00
|
|
|
export interface IToolboxState {
|
|
|
|
enabled: boolean;
|
|
|
|
fullScreen?: boolean;
|
|
|
|
hangupMenuVisible: boolean;
|
|
|
|
hovered: boolean;
|
|
|
|
overflowDrawer: boolean;
|
|
|
|
overflowMenuVisible: boolean;
|
|
|
|
timeoutID?: number|null;
|
|
|
|
visible: boolean;
|
|
|
|
}
|
|
|
|
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IToolboxState>(
|
2017-04-01 05:52:40 +00:00
|
|
|
'features/toolbox',
|
2022-09-05 09:05:07 +00:00
|
|
|
(state = INITIAL_STATE, action): IToolboxState => {
|
2017-02-16 23:02:40 +00:00
|
|
|
switch (action.type) {
|
2017-04-01 05:52:40 +00:00
|
|
|
case CLEAR_TOOLBOX_TIMEOUT:
|
2017-02-16 23:02:40 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-04-01 05:52:40 +00:00
|
|
|
timeoutID: undefined
|
2017-02-16 23:02:40 +00:00
|
|
|
};
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
case FULL_SCREEN_CHANGED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
fullScreen: action.fullScreen
|
|
|
|
};
|
|
|
|
|
2022-08-26 18:25:04 +00:00
|
|
|
case SET_HANGUP_MENU_VISIBLE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
hangupMenuVisible: action.visible
|
|
|
|
};
|
|
|
|
|
2021-01-04 13:30:23 +00:00
|
|
|
case SET_OVERFLOW_DRAWER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
overflowDrawer: action.displayAsDrawer
|
|
|
|
};
|
|
|
|
|
2018-04-20 11:24:14 +00:00
|
|
|
case SET_OVERFLOW_MENU_VISIBLE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
overflowMenuVisible: action.visible
|
|
|
|
};
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
case SET_TOOLBAR_HOVERED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
hovered: action.hovered
|
|
|
|
};
|
|
|
|
|
2017-04-12 19:06:56 +00:00
|
|
|
case SET_TOOLBOX_ENABLED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
enabled: action.enabled
|
|
|
|
};
|
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
case SET_TOOLBOX_TIMEOUT:
|
2017-02-16 23:02:40 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2021-09-23 14:39:05 +00:00
|
|
|
timeoutID: action.timeoutID
|
2017-02-16 23:02:40 +00:00
|
|
|
};
|
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
case SET_TOOLBOX_VISIBLE:
|
2021-09-23 14:39:05 +00:00
|
|
|
return set(state, 'visible', action.visible);
|
2019-06-19 12:44:39 +00:00
|
|
|
|
|
|
|
case TOGGLE_TOOLBOX_VISIBLE:
|
2021-09-23 14:39:05 +00:00
|
|
|
return set(state, 'visible', !state.visible);
|
2017-02-16 23:02:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|