2018-04-18 12:12:42 +02:00
|
|
|
// @flow
|
|
|
|
|
|
2018-05-10 18:01:55 -05:00
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../../analytics';
|
|
|
|
|
import { translate } from '../../../base/i18n';
|
2019-08-30 18:39:06 +02:00
|
|
|
import { IconSettings } from '../../../base/icons';
|
2019-03-21 17:38:29 +01:00
|
|
|
import { connect } from '../../../base/redux';
|
2020-07-24 14:14:33 +02:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2018-06-20 15:19:53 -05:00
|
|
|
import { openSettingsDialog } from '../../actions';
|
|
|
|
|
import { SETTINGS_TABS } from '../../constants';
|
2018-04-18 12:12:42 +02:00
|
|
|
|
2018-05-10 21:10:26 -05:00
|
|
|
/**
|
|
|
|
|
* The type of the React {@code Component} props of {@link SettingsButton}.
|
|
|
|
|
*/
|
2018-04-18 12:12:42 +02:00
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
2018-08-27 19:56:17 -05:00
|
|
|
/**
|
|
|
|
|
* The default tab at which the settings dialog will be opened.
|
|
|
|
|
*/
|
|
|
|
|
defaultTab: string,
|
|
|
|
|
|
2018-04-18 12:12:42 +02:00
|
|
|
/**
|
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
|
*/
|
|
|
|
|
dispatch: Function
|
2018-05-10 18:01:55 -05:00
|
|
|
};
|
2018-04-18 12:12:42 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An abstract implementation of a button for accessing settings.
|
|
|
|
|
*/
|
|
|
|
|
class SettingsButton extends AbstractButton<Props, *> {
|
2018-06-07 22:32:18 +02:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.Settings';
|
2019-08-30 18:39:06 +02:00
|
|
|
icon = IconSettings;
|
2018-04-18 12:12:42 +02:00
|
|
|
label = 'toolbar.Settings';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles clicking / pressing the button, and opens the appropriate dialog.
|
|
|
|
|
*
|
2018-05-10 21:10:26 -05:00
|
|
|
* @protected
|
2018-04-18 12:12:42 +02:00
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
_handleClick() {
|
2018-08-27 19:56:17 -05:00
|
|
|
const {
|
|
|
|
|
defaultTab = SETTINGS_TABS.DEVICES,
|
|
|
|
|
dispatch } = this.props;
|
2018-04-18 12:12:42 +02:00
|
|
|
|
|
|
|
|
sendAnalytics(createToolbarEvent('settings'));
|
2020-11-10 16:21:07 -06:00
|
|
|
dispatch(openSettingsDialog(defaultTab));
|
2018-04-18 12:12:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-10 16:21:07 -06:00
|
|
|
export default translate(connect()(SettingsButton));
|