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

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