fix(toolbox): move default toolbox buttons logic to web only

toolbox/functions has functions that are specific only to web,
specifically defaultToolbarButtons. This has caused the native
build to attempt to bring in a web dependency which leads to a
build error. The fix for now is splitting web functions from
native functions to resolve the build error.
This commit is contained in:
Leonard Kim 2017-05-01 16:04:12 -07:00 committed by Lyubo Marinov
parent 1ffa7be4e1
commit 48626ee71b
4 changed files with 124 additions and 123 deletions

View File

@ -4,7 +4,6 @@ import type { Dispatch } from 'redux-thunk';
import {
CLEAR_TOOLBOX_TIMEOUT,
SET_DEFAULT_TOOLBOX_BUTTONS,
SET_SUBJECT,
SET_SUBJECT_SLIDE_IN,
SET_TOOLBAR_BUTTON,
@ -15,7 +14,6 @@ import {
SET_TOOLBOX_TIMEOUT_MS,
SET_TOOLBOX_VISIBLE
} from './actionTypes';
import { getDefaultToolboxButtons } from './functions';
/**
* Event handler for local raise hand changed event.
@ -70,22 +68,6 @@ export function setAudioIconEnabled(enabled: boolean = false): Function {
};
}
/**
* Sets the default toolbar buttons of the Toolbox.
*
* @returns {{
* type: SET_DEFAULT_TOOLBOX_BUTTONS,
* primaryToolbarButtons: Map,
* secondaryToolbarButtons: Map
* }}
*/
export function setDefaultToolboxButtons(): Object {
return {
type: SET_DEFAULT_TOOLBOX_BUTTONS,
...getDefaultToolboxButtons()
};
}
/**
* Signals that value of conference subject should be changed.
*

View File

@ -3,8 +3,8 @@
import Recording from '../../../modules/UI/recording/Recording';
import SideContainerToggler
from '../../../modules/UI/side_pannels/SideContainerToggler';
import UIUtil from '../../../modules/UI/util/UIUtil';
import UIEvents from '../../../service/UI/UIEvents';
import UIUtil from '../../../modules/UI/util/UIUtil';
import {
clearToolboxTimeout,
@ -15,14 +15,16 @@ import {
setToolboxVisible,
toggleToolbarButton
} from './actions.native';
export * from './actions.native';
import { SET_DEFAULT_TOOLBOX_BUTTONS } from './actionTypes';
import { getDefaultToolboxButtons } from './functions';
declare var $: Function;
declare var APP: Object;
declare var config: Object;
declare var interfaceConfig: Object;
export * from './actions.native';
/**
* Checks whether desktop sharing is enabled and whether
* we have params to start automatically sharing.
@ -109,6 +111,22 @@ export function hideToolbox(force: boolean = false): Function {
};
}
/**
* Sets the default toolbar buttons of the Toolbox.
*
* @returns {{
* type: SET_DEFAULT_TOOLBOX_BUTTONS,
* primaryToolbarButtons: Map,
* secondaryToolbarButtons: Map
* }}
*/
export function setDefaultToolboxButtons(): Object {
return {
type: SET_DEFAULT_TOOLBOX_BUTTONS,
...getDefaultToolboxButtons()
};
}
/**
* Signals that unclickable property of profile button should change its value.
*

View File

@ -0,0 +1,102 @@
/* @flow */
import type { Dispatch } from 'redux';
import { appNavigate } from '../app';
import { toggleAudioMuted, toggleVideoMuted } from '../base/media';
/**
* Maps (redux) actions to React component props.
*
* @param {Function} dispatch - Redux action dispatcher.
* @returns {{
* _onHangup: Function,
* _onToggleAudio: Function,
* _onToggleVideo: Function
* }}
* @private
*/
export function abstractMapDispatchToProps(dispatch: Dispatch<*>): Object {
return {
/**
* Dispatches action to leave the current conference.
*
* @private
* @returns {void}
* @type {Function}
*/
_onHangup() {
// XXX We don't know here which value is effectively/internally
// used when there's no valid room name to join. It isn't our
// business to know that anyway. The undefined value is our
// expression of (1) the lack of knowledge & (2) the desire to no
// longer have a valid room name to join.
return dispatch(appNavigate(undefined));
},
/**
* Dispatches an action to toggle the mute state of the
* audio/microphone.
*
* @private
* @returns {Object} - Dispatched action.
* @type {Function}
*/
_onToggleAudio() {
return dispatch(toggleAudioMuted());
},
/**
* Dispatches an action to toggle the mute state of the video/camera.
*
* @private
* @returns {Object} - Dispatched action.
* @type {Function}
*/
_onToggleVideo() {
return dispatch(toggleVideoMuted());
}
};
}
/**
* Maps parts of media state to component props.
*
* @param {Object} state - Redux state.
* @protected
* @returns {{
* _audioMuted: boolean,
* _videoMuted: boolean,
* _visible: boolean
* }}
*/
export function abstractMapStateToProps(state: Object): Object {
const media = state['features/base/media'];
const { visible } = state['features/toolbox'];
return {
/**
* Flag showing that audio is muted.
*
* @protected
* @type {boolean}
*/
_audioMuted: media.audio.muted,
/**
* Flag showing whether video is muted.
*
* @protected
* @type {boolean}
*/
_videoMuted: media.video.muted,
/**
* Flag showing whether toolbox is visible.
*
* @protected
* @type {boolean}
*/
_visible: visible
};
}

View File

@ -1,116 +1,15 @@
/* @flow */
import SideContainerToggler
from '../../../modules/UI/side_pannels/SideContainerToggler';
import { appNavigate } from '../app';
import { toggleAudioMuted, toggleVideoMuted } from '../base/media';
import defaultToolbarButtons from './defaultToolbarButtons';
import type { Dispatch } from 'redux-thunk';
type MapOfAttributes = { [key: string]: * };
declare var $: Function;
declare var AJS: Object;
declare var interfaceConfig: Object;
/**
* Maps (redux) actions to React component props.
*
* @param {Function} dispatch - Redux action dispatcher.
* @returns {{
* _onHangup: Function,
* _onToggleAudio: Function,
* _onToggleVideo: Function
* }}
* @private
*/
export function abstractMapDispatchToProps(dispatch: Dispatch<*>): Object {
return {
/**
* Dispatches action to leave the current conference.
*
* @private
* @returns {void}
* @type {Function}
*/
_onHangup() {
// XXX We don't know here which value is effectively/internally
// used when there's no valid room name to join. It isn't our
// business to know that anyway. The undefined value is our
// expression of (1) the lack of knowledge & (2) the desire to no
// longer have a valid room name to join.
return dispatch(appNavigate(undefined));
},
/**
* Dispatches an action to toggle the mute state of the
* audio/microphone.
*
* @private
* @returns {Object} - Dispatched action.
* @type {Function}
*/
_onToggleAudio() {
return dispatch(toggleAudioMuted());
},
/**
* Dispatches an action to toggle the mute state of the video/camera.
*
* @private
* @returns {Object} - Dispatched action.
* @type {Function}
*/
_onToggleVideo() {
return dispatch(toggleVideoMuted());
}
};
}
/**
* Maps parts of media state to component props.
*
* @param {Object} state - Redux state.
* @protected
* @returns {{
* _audioMuted: boolean,
* _videoMuted: boolean,
* _visible: boolean
* }}
*/
export function abstractMapStateToProps(state: Object): Object {
const media = state['features/base/media'];
const { visible } = state['features/toolbox'];
return {
/**
* Flag showing that audio is muted.
*
* @protected
* @type {boolean}
*/
_audioMuted: media.audio.muted,
/**
* Flag showing whether video is muted.
*
* @protected
* @type {boolean}
*/
_videoMuted: media.video.muted,
/**
* Flag showing whether toolbox is visible.
*
* @protected
* @type {boolean}
*/
_visible: visible
};
}
export { abstractMapStateToProps } from './functions.native';
/* eslint-disable flowtype/space-before-type-colon */