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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 { isToolboxVisible } from '../../../toolbox';
  9. declare var interfaceConfig: Object;
  10. type Props = {
  11. /**
  12. * Whether tile view is enabled.
  13. */
  14. _tileViewEnabled: Boolean,
  15. /**
  16. * Whether to show the option to invite more people
  17. * instead of the subject.
  18. */
  19. _visible: boolean,
  20. /**
  21. * Handler to open the invite dialog.
  22. */
  23. onClick: Function,
  24. /**
  25. * Invoked to obtain translated strings.
  26. */
  27. t: Function
  28. }
  29. /**
  30. * Represents a replacement for the subject, prompting the
  31. * sole participant to invite more participants.
  32. *
  33. * @param {Object} props - The props of the component.
  34. * @returns {React$Element<any>}
  35. */
  36. function InviteMore({
  37. _tileViewEnabled,
  38. _visible,
  39. onClick,
  40. t
  41. }: Props) {
  42. return (
  43. _visible
  44. ? <div className = { `invite-more-container${_tileViewEnabled ? ' elevated' : ''}` }>
  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> : null
  57. );
  58. }
  59. /**
  60. * Maps (parts of) the Redux state to the associated
  61. * {@code Subject}'s props.
  62. *
  63. * @param {Object} state - The Redux state.
  64. * @private
  65. * @returns {Props}
  66. */
  67. function mapStateToProps(state) {
  68. const participantCount = getParticipantCount(state);
  69. const isAlone = participantCount === 1;
  70. const hide = interfaceConfig.HIDE_INVITE_MORE_HEADER;
  71. return {
  72. _tileViewEnabled: state['features/video-layout'].tileViewEnabled,
  73. _visible: isToolboxVisible(state) && isAlone && !hide
  74. };
  75. }
  76. /**
  77. * Maps dispatching of some action to React component props.
  78. *
  79. * @param {Function} dispatch - Redux action dispatcher.
  80. * @returns {Props}
  81. */
  82. const mapDispatchToProps = {
  83. onClick: () => beginAddPeople()
  84. };
  85. export default translate(connect(mapStateToProps, mapDispatchToProps)(InviteMore));