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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. */
  14. _shouldShow: boolean,
  15. /**
  16. * Whether the toolbox is visible.
  17. */
  18. _toolboxVisible: boolean,
  19. /**
  20. * Handler to open the invite dialog.
  21. */
  22. onClick: Function,
  23. /**
  24. * Invoked to obtain translated strings.
  25. */
  26. t: Function
  27. }
  28. /**
  29. * Represents a replacement for the subject, prompting the
  30. * sole participant to invite more participants.
  31. *
  32. * @param {Object} props - The props of the component.
  33. * @returns {React$Element<any>}
  34. */
  35. function InviteMore({
  36. _shouldShow,
  37. _toolboxVisible,
  38. onClick,
  39. t
  40. }: Props) {
  41. return (
  42. _shouldShow
  43. ? <div className = { `invite-more-container${_toolboxVisible ? '' : ' elevated'}` }>
  44. <div className = 'invite-more-content'>
  45. <div className = 'invite-more-header'>
  46. {t('addPeople.inviteMoreHeader')}
  47. </div>
  48. <div
  49. className = 'invite-more-button'
  50. onClick = { onClick }>
  51. <Icon src = { IconInviteMore } />
  52. <div className = 'invite-more-button-text'>
  53. {t('addPeople.inviteMorePrompt')}
  54. </div>
  55. </div>
  56. </div>
  57. </div> : null
  58. );
  59. }
  60. /**
  61. * Maps (parts of) the Redux state to the associated
  62. * {@code Subject}'s props.
  63. *
  64. * @param {Object} state - The Redux state.
  65. * @private
  66. * @returns {Props}
  67. */
  68. function mapStateToProps(state) {
  69. const participantCount = getParticipantCount(state);
  70. const isAlone = participantCount === 1;
  71. const hide = interfaceConfig.HIDE_INVITE_MORE_HEADER;
  72. return {
  73. _shouldShow: isButtonEnabled('invite', state) && isAlone && !hide,
  74. _toolboxVisible: isToolboxVisible(state)
  75. };
  76. }
  77. /**
  78. * Maps dispatching of some action to React component props.
  79. *
  80. * @param {Function} dispatch - Redux action dispatcher.
  81. * @returns {Props}
  82. */
  83. const mapDispatchToProps = {
  84. onClick: () => beginAddPeople()
  85. };
  86. export default translate(connect(mapStateToProps, mapDispatchToProps)(InviteMore));