2019-10-04 17:10:19 +02:00
|
|
|
// @flow
|
|
|
|
|
|
2023-03-21 09:47:52 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
2019-10-04 17:10:19 +02:00
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
|
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
|
import { IconShareDoc } from '../../base/icons';
|
2020-07-24 14:14:33 +02:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
2022-01-25 14:55:57 +02:00
|
|
|
import { navigate } from '../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
|
|
|
|
|
import { screen } from '../../mobile/navigation/routes';
|
2019-10-04 17:10:19 +02:00
|
|
|
|
|
|
|
|
|
2021-12-01 14:29:55 +01:00
|
|
|
type Props = AbstractButtonProps;
|
2019-10-04 17:10:19 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements an {@link AbstractButton} to open the chat screen on mobile.
|
|
|
|
|
*/
|
|
|
|
|
class SharedDocumentButton extends AbstractButton<Props, *> {
|
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.document';
|
|
|
|
|
icon = IconShareDoc;
|
|
|
|
|
label = 'toolbar.documentOpen';
|
2021-12-01 14:29:55 +01:00
|
|
|
tooltip = 'toolbar.documentOpen';
|
2021-07-08 16:42:07 +03:00
|
|
|
|
2019-10-04 17:10:19 +02:00
|
|
|
/**
|
|
|
|
|
* Handles clicking / pressing the button, and opens / closes the appropriate dialog.
|
|
|
|
|
*
|
|
|
|
|
* @private
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
_handleClick() {
|
2021-12-01 14:29:55 +01:00
|
|
|
const { handleClick } = this.props;
|
2021-09-14 10:07:20 +03:00
|
|
|
|
|
|
|
|
if (handleClick) {
|
|
|
|
|
handleClick();
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-04 17:10:19 +02:00
|
|
|
sendAnalytics(createToolbarEvent(
|
|
|
|
|
'toggle.etherpad',
|
|
|
|
|
{
|
2021-12-01 14:29:55 +01:00
|
|
|
enable: true
|
2019-10-04 17:10:19 +02:00
|
|
|
}));
|
2021-10-20 22:29:21 +03:00
|
|
|
|
|
|
|
|
navigate(screen.conference.sharedDocument);
|
2019-10-04 17:10:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Maps part of the redux state to the component's props.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The redux store/state.
|
|
|
|
|
* @param {Object} ownProps - The properties explicitly passed to the component
|
|
|
|
|
* instance.
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
*/
|
|
|
|
|
function _mapStateToProps(state: Object, ownProps: Object) {
|
2021-12-01 14:29:55 +01:00
|
|
|
const { documentUrl } = state['features/etherpad'];
|
2019-10-04 17:10:19 +02:00
|
|
|
const { visible = Boolean(documentUrl) } = ownProps;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
visible
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(SharedDocumentButton));
|