You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InviteMore.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // @flow
  2. import React from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { Icon, IconInviteMore } from '../../../base/icons';
  5. import { getParticipantCount } from '../../../base/participants';
  6. import { connect } from '../../../base/redux';
  7. import { beginAddPeople } from '../../../invite';
  8. import { isButtonEnabled, isToolboxVisible } from '../../../toolbox/functions.web';
  9. declare var interfaceConfig: Object;
  10. type Props = {
  11. /**
  12. * Whether to show the option to invite more people
  13. * instead of the subject.
  14. */
  15. _visible: boolean,
  16. /**
  17. * Handler to open the invite dialog.
  18. */
  19. onClick: Function,
  20. /**
  21. * Invoked to obtain translated strings.
  22. */
  23. t: Function
  24. }
  25. /**
  26. * Represents a replacement for the subject, prompting the
  27. * sole participant to invite more participants.
  28. *
  29. * @param {Object} props - The props of the component.
  30. * @returns {React$Element<any>}
  31. */
  32. function InviteMore({
  33. _visible,
  34. onClick,
  35. t
  36. }: Props) {
  37. return (
  38. _visible
  39. ? <div className = 'invite-more-container'>
  40. <div className = 'invite-more-header'>
  41. {t('addPeople.inviteMoreHeader')}
  42. </div>
  43. <div
  44. className = 'invite-more-button'
  45. onClick = { onClick }>
  46. <Icon src = { IconInviteMore } />
  47. <div className = 'invite-more-button-text'>
  48. {t('addPeople.inviteMorePrompt')}
  49. </div>
  50. </div>
  51. </div> : null
  52. );
  53. }
  54. /**
  55. * Maps (parts of) the Redux state to the associated
  56. * {@code Subject}'s props.
  57. *
  58. * @param {Object} state - The Redux state.
  59. * @private
  60. * @returns {Props}
  61. */
  62. function mapStateToProps(state) {
  63. const participantCount = getParticipantCount(state);
  64. const isAlone = participantCount === 1;
  65. const hide = interfaceConfig.HIDE_INVITE_MORE_HEADER;
  66. return {
  67. _visible: isToolboxVisible(state) && isButtonEnabled('invite') && isAlone && !hide
  68. };
  69. }
  70. /**
  71. * Maps dispatching of some action to React component props.
  72. *
  73. * @param {Function} dispatch - Redux action dispatcher.
  74. * @returns {Props}
  75. */
  76. const mapDispatchToProps = {
  77. onClick: () => beginAddPeople()
  78. };
  79. export default translate(connect(mapStateToProps, mapDispatchToProps)(InviteMore));