Fix raise hand toggled state

This commit is contained in:
yanas
2017-05-26 16:28:16 -05:00
parent ec2e6525ac
commit d1737745c2
7 changed files with 155 additions and 275 deletions

View File

@@ -13,6 +13,21 @@ export { abstractMapStateToProps } from './functions.native';
/* eslint-disable flowtype/space-before-type-colon */
/**
* Returns the button object corresponding to the given buttonName.
*
* @param {string} buttonName - The name of the button.
* @param {Object} state - The current state.
* @returns {Object} - The button object.
*/
export function getButton(buttonName: string, state: Object) {
const { primaryToolbarButtons, secondaryToolbarButtons }
= state['features/toolbox'];
return primaryToolbarButtons.get(buttonName)
|| secondaryToolbarButtons.get(buttonName);
}
/**
* Takes toolbar button props and maps them to HTML attributes to set.
*
@@ -52,9 +67,11 @@ export function getButtonAttributesByProps(props: Object = {})
* Returns an object which contains the default buttons for the primary and
* secondary toolbars.
*
* @param {Object} buttonHandlers - Contains additional toolbox button
* handlers.
* @returns {Object}
*/
export function getDefaultToolboxButtons(): Object {
export function getDefaultToolboxButtons(buttonHandlers: Object): Object {
let toolbarButtons = {
primaryToolbarButtons: new Map(),
secondaryToolbarButtons: new Map()
@@ -67,13 +84,21 @@ export function getDefaultToolboxButtons(): Object {
toolbarButtons
= interfaceConfig.TOOLBAR_BUTTONS.reduce(
(acc, buttonName) => {
const button = defaultToolbarButtons[buttonName];
let button = defaultToolbarButtons[buttonName];
const currentButtonHandlers = buttonHandlers[buttonName];
if (button) {
const place = _getToolbarButtonPlace(buttonName);
button.buttonName = buttonName;
if (currentButtonHandlers) {
button = {
...button,
...currentButtonHandlers
};
}
// In filmstrip-only mode we only add a button if it's
// filmstrip-only enabled.
if (!filmStripOnly || button.filmstripOnlyEnabled) {
@@ -89,21 +114,6 @@ export function getDefaultToolboxButtons(): Object {
return toolbarButtons;
}
/**
* Get place for toolbar button. Now it can be in the primary Toolbar or in the
* secondary Toolbar.
*
* @param {string} btn - Button name.
* @private
* @returns {string}
*/
function _getToolbarButtonPlace(btn) {
return (
interfaceConfig.MAIN_TOOLBAR_BUTTONS.includes(btn)
? 'primaryToolbarButtons'
: 'secondaryToolbarButtons');
}
/**
* Returns toolbar class names to add while rendering.
*
@@ -171,3 +181,18 @@ export function showCustomToolbarPopup(
AJS.$(popupSelectorID).tooltip('hide');
}
}
/**
* Get place for toolbar button. Now it can be in the primary Toolbar or in the
* secondary Toolbar.
*
* @param {string} btn - Button name.
* @private
* @returns {string}
*/
function _getToolbarButtonPlace(btn) {
return (
interfaceConfig.MAIN_TOOLBAR_BUTTONS.includes(btn)
? 'primaryToolbarButtons'
: 'secondaryToolbarButtons');
}