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';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconGear } from '../../../base/icons';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2018-06-20 20:19:53 +00:00
|
|
|
import { openSettingsDialog } from '../../actions';
|
|
|
|
import { SETTINGS_TABS } from '../../constants';
|
2018-04-18 10:12:42 +00:00
|
|
|
|
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 & {
|
|
|
|
|
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.
|
|
|
|
*/
|
2022-05-24 19:04:21 +00:00
|
|
|
dispatch: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the device selection dialog is displayed on the
|
|
|
|
* welcome page or not.
|
|
|
|
*/
|
|
|
|
isDisplayedOnWelcomePage: boolean
|
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';
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = IconGear;
|
2018-04-18 10:12:42 +00:00
|
|
|
label = 'toolbar.Settings';
|
2021-07-08 13:42:07 +00:00
|
|
|
tooltip = 'toolbar.Settings';
|
2018-04-18 10:12:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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() {
|
2022-05-24 19:04:21 +00:00
|
|
|
const { defaultTab = SETTINGS_TABS.DEVICES, dispatch, isDisplayedOnWelcomePage = false } = this.props;
|
2018-04-18 10:12:42 +00:00
|
|
|
|
|
|
|
sendAnalytics(createToolbarEvent('settings'));
|
2022-05-24 19:04:21 +00:00
|
|
|
dispatch(openSettingsDialog(defaultTab, isDisplayedOnWelcomePage));
|
2018-04-18 10:12:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-10 22:21:07 +00:00
|
|
|
export default translate(connect()(SettingsButton));
|