2023-03-21 09:47:52 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
2023-03-30 11:27:53 +03:00
|
|
|
import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
|
|
|
|
|
import { sendAnalytics } from '../../../analytics/functions';
|
|
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
|
import { IconGear } from '../../../base/icons/svg';
|
|
|
|
|
import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
|
2018-06-20 15:19:53 -05:00
|
|
|
import { openSettingsDialog } from '../../actions';
|
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}.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
interface IProps extends AbstractButtonProps {
|
2018-04-18 12:12:42 +02:00
|
|
|
|
2018-08-27 19:56:17 -05:00
|
|
|
/**
|
|
|
|
|
* The default tab at which the settings dialog will be opened.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
defaultTab: string;
|
2022-05-24 14:04:21 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether the device selection dialog is displayed on the
|
|
|
|
|
* welcome page or not.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
isDisplayedOnWelcomePage: boolean;
|
|
|
|
|
}
|
2018-04-18 12:12:42 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An abstract implementation of a button for accessing settings.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
class SettingsButton extends AbstractButton<IProps> {
|
2025-03-12 10:19:11 -05:00
|
|
|
override accessibilityLabel = 'toolbar.accessibilityLabel.Settings';
|
|
|
|
|
override icon = IconGear;
|
|
|
|
|
override label = 'toolbar.Settings';
|
|
|
|
|
override tooltip = 'toolbar.Settings';
|
2018-04-18 12:12:42 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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}
|
|
|
|
|
*/
|
2025-03-12 10:19:11 -05:00
|
|
|
override _handleClick() {
|
2023-06-12 13:55:32 +03:00
|
|
|
const { dispatch, isDisplayedOnWelcomePage = false } = this.props;
|
2018-04-18 12:12:42 +02:00
|
|
|
|
|
|
|
|
sendAnalytics(createToolbarEvent('settings'));
|
2023-06-12 13:55:32 +03:00
|
|
|
dispatch(openSettingsDialog(undefined, isDisplayedOnWelcomePage));
|
2018-04-18 12:12:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-10 16:21:07 -06:00
|
|
|
export default translate(connect()(SettingsButton));
|