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. import { shouldDisplayTileView } from '../../../video-layout/functions';
  10. declare var interfaceConfig: Object;
  11. type Props = {
  12. /**
  13. * Whether tile view is enabled.
  14. */
  15. _tileViewEnabled: Boolean,
  16. /**
  17. * Whether to show the option to invite more people
  18. * instead of the subject.
  19. */
  20. _visible: boolean,
  21. /**
  22. * Handler to open the invite dialog.
  23. */
  24. onClick: Function,
  25. /**
  26. * Invoked to obtain translated strings.
  27. */
  28. t: Function
  29. }
  30. /**
  31. * Represents a replacement for the subject, prompting the
  32. * sole participant to invite more participants.
  33. *
  34. * @param {Object} props - The props of the component.
  35. * @returns {React$Element<any>}
  36. */
  37. function InviteMore({
  38. _tileViewEnabled,
  39. _visible,
  40. onClick,
  41. t
  42. }: Props) {
  43. return (
  44. _visible
  45. ? <div className = { `invite-more-container${_tileViewEnabled ? ' elevated' : ''}` }>
  46. <div className = 'invite-more-header'>
  47. {t('addPeople.inviteMoreHeader')}
  48. </div>
  49. <div
  50. className = 'invite-more-button'
  51. onClick = { onClick }>
  52. <Icon src = { IconInviteMore } />
  53. <div className = 'invite-more-button-text'>
  54. {t('addPeople.inviteMorePrompt')}
  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. _tileViewEnabled: shouldDisplayTileView(state),
  74. _visible: isToolboxVisible(state) && isButtonEnabled('invite') && isAlone && !hide
  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));