您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SharedDocumentButton.web.ts 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { connect } from 'react-redux';
  2. import { createToolbarEvent } from '../../analytics/AnalyticsEvents';
  3. import { sendAnalytics } from '../../analytics/functions';
  4. import { IReduxState } from '../../app/types';
  5. import { translate } from '../../base/i18n/functions';
  6. import { IconShareDoc } from '../../base/icons/svg';
  7. import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
  8. import { setOverflowMenuVisible } from '../../toolbox/actions.web';
  9. import { toggleDocument } from '../actions';
  10. interface IProps extends AbstractButtonProps {
  11. /**
  12. * Whether the shared document is being edited or not.
  13. */
  14. _editing: boolean;
  15. }
  16. /**
  17. * Implements an {@link AbstractButton} to open the chat screen on mobile.
  18. */
  19. class SharedDocumentButton extends AbstractButton<IProps> {
  20. accessibilityLabel = 'toolbar.accessibilityLabel.documentOpen';
  21. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.documentClose';
  22. icon = IconShareDoc;
  23. label = 'toolbar.documentOpen';
  24. toggledLabel = 'toolbar.documentClose';
  25. tooltip = 'toolbar.documentOpen';
  26. toggledTooltip = 'toolbar.documentClose';
  27. /**
  28. * Handles clicking / pressing the button, and opens / closes the appropriate dialog.
  29. *
  30. * @private
  31. * @returns {void}
  32. */
  33. _handleClick() {
  34. const { _editing, dispatch } = this.props;
  35. sendAnalytics(createToolbarEvent(
  36. 'toggle.etherpad',
  37. {
  38. enable: !_editing
  39. }));
  40. dispatch(toggleDocument());
  41. dispatch(setOverflowMenuVisible(false));
  42. }
  43. /**
  44. * Indicates whether this button is in toggled state or not.
  45. *
  46. * @override
  47. * @protected
  48. * @returns {boolean}
  49. */
  50. _isToggled() {
  51. return this.props._editing;
  52. }
  53. }
  54. /**
  55. * Maps part of the redux state to the component's props.
  56. *
  57. * @param {Object} state - The redux store/state.
  58. * @param {Object} ownProps - The properties explicitly passed to the component
  59. * instance.
  60. * @returns {Object}
  61. */
  62. function _mapStateToProps(state: IReduxState, ownProps: any) {
  63. const { documentUrl, editing } = state['features/etherpad'];
  64. const { visible = Boolean(documentUrl) } = ownProps;
  65. return {
  66. _editing: editing,
  67. visible
  68. };
  69. }
  70. export default translate(connect(_mapStateToProps)(SharedDocumentButton));