2019-10-04 15:10:19 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
import { IconShareDoc } from '../../base/icons';
|
|
|
|
import { connect } from '../../base/redux';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
2021-10-20 19:29:21 +00:00
|
|
|
import { navigate } from '../../conference/components/native/ConferenceNavigationContainerRef';
|
|
|
|
import { screen } from '../../conference/components/native/routes';
|
2019-10-04 15:10:19 +00:00
|
|
|
|
|
|
|
|
2021-12-01 13:29:55 +00:00
|
|
|
type Props = AbstractButtonProps;
|
2019-10-04 15:10:19 +00: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 13:29:55 +00:00
|
|
|
tooltip = 'toolbar.documentOpen';
|
2021-07-08 13:42:07 +00:00
|
|
|
|
2019-10-04 15:10:19 +00:00
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and opens / closes the appropriate dialog.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2021-12-01 13:29:55 +00:00
|
|
|
const { handleClick } = this.props;
|
2021-09-14 07:07:20 +00:00
|
|
|
|
|
|
|
if (handleClick) {
|
|
|
|
handleClick();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-04 15:10:19 +00:00
|
|
|
sendAnalytics(createToolbarEvent(
|
|
|
|
'toggle.etherpad',
|
|
|
|
{
|
2021-12-01 13:29:55 +00:00
|
|
|
enable: true
|
2019-10-04 15:10:19 +00:00
|
|
|
}));
|
2021-10-20 19:29:21 +00:00
|
|
|
|
|
|
|
navigate(screen.conference.sharedDocument);
|
2019-10-04 15:10:19 +00: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 13:29:55 +00:00
|
|
|
const { documentUrl } = state['features/etherpad'];
|
2019-10-04 15:10:19 +00:00
|
|
|
const { visible = Boolean(documentUrl) } = ownProps;
|
|
|
|
|
|
|
|
return {
|
|
|
|
visible
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(SharedDocumentButton));
|