2018-04-18 10:12:42 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-05-10 23:01:55 +00:00
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../../analytics';
|
|
|
|
import { translate } from '../../../base/i18n';
|
2019-08-30 16:39:06 +00:00
|
|
|
import { IconSettings } from '../../../base/icons';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { AbstractButton } from '../../../base/toolbox';
|
|
|
|
import type { AbstractButtonProps } from '../../../base/toolbox';
|
2018-06-20 20:19:53 +00:00
|
|
|
import { openDeviceSelectionPopup } from '../../../device-selection';
|
|
|
|
import { openSettingsDialog } from '../../actions';
|
|
|
|
import { SETTINGS_TABS } from '../../constants';
|
2018-04-18 10:12:42 +00:00
|
|
|
|
|
|
|
declare var interfaceConfig: Object;
|
|
|
|
|
2018-05-11 02:10:26 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link SettingsButton}.
|
|
|
|
*/
|
2018-04-18 10:12:42 +00:00
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether we are in filmstrip only mode or not.
|
|
|
|
*/
|
2018-05-03 17:36:29 +00:00
|
|
|
_filmstripOnly: boolean,
|
2018-04-18 10:12:42 +00:00
|
|
|
|
2018-08-28 00:56:17 +00:00
|
|
|
/**
|
|
|
|
* The default tab at which the settings dialog will be opened.
|
|
|
|
*/
|
|
|
|
defaultTab: string,
|
|
|
|
|
2018-04-18 10:12:42 +00:00
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function
|
2018-05-10 23:01:55 +00:00
|
|
|
};
|
2018-04-18 10:12:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An abstract implementation of a button for accessing settings.
|
|
|
|
*/
|
|
|
|
class SettingsButton extends AbstractButton<Props, *> {
|
2018-06-07 20:32:18 +00:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.Settings';
|
2019-08-30 16:39:06 +00:00
|
|
|
icon = IconSettings;
|
2018-04-18 10:12:42 +00:00
|
|
|
label = 'toolbar.Settings';
|
|
|
|
tooltip = 'toolbar.Settings';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and opens the appropriate dialog.
|
|
|
|
*
|
2018-05-11 02:10:26 +00:00
|
|
|
* @protected
|
2018-04-18 10:12:42 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2018-08-28 00:56:17 +00:00
|
|
|
const {
|
|
|
|
_filmstripOnly,
|
|
|
|
defaultTab = SETTINGS_TABS.DEVICES,
|
|
|
|
dispatch } = this.props;
|
2018-04-18 10:12:42 +00:00
|
|
|
|
|
|
|
sendAnalytics(createToolbarEvent('settings'));
|
2018-06-20 20:19:53 +00:00
|
|
|
if (_filmstripOnly) {
|
|
|
|
dispatch(openDeviceSelectionPopup());
|
2018-04-18 10:12:42 +00:00
|
|
|
} else {
|
2018-08-28 00:56:17 +00:00
|
|
|
dispatch(openSettingsDialog(defaultTab));
|
2018-04-18 10:12:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for the
|
|
|
|
* {@code SettingsButton} component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2018-05-03 17:36:29 +00:00
|
|
|
* _filmstripOnly: boolean
|
2018-04-18 10:12:42 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state): Object { // eslint-disable-line no-unused-vars
|
|
|
|
// XXX: We are not currently using state here, but in the future, when
|
|
|
|
// interfaceConfig is part of redux we will.
|
|
|
|
|
|
|
|
return {
|
2018-06-20 20:19:53 +00:00
|
|
|
_filmstripOnly: Boolean(interfaceConfig.filmStripOnly)
|
2018-04-18 10:12:42 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(SettingsButton));
|