Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

InviteMore.js 2.6KB

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