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.

InviteButton.native.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { launchNativeInvite } from '../../mobile/invite-search';
  5. import { ToolbarButton } from '../../toolbox';
  6. /**
  7. * The type of {@link EnterPictureInPictureToobarButton}'s React
  8. * {@code Component} props.
  9. */
  10. type Props = {
  11. /**
  12. * Indicates if the "Add to call" feature is available.
  13. */
  14. enableAddPeople: boolean,
  15. /**
  16. * Indicates if the "Dial out" feature is available.
  17. */
  18. enableDialOut: boolean,
  19. /**
  20. * Launches native invite dialog.
  21. *
  22. * @protected
  23. */
  24. onLaunchNativeInvite: Function,
  25. };
  26. /**
  27. * Implements a {@link ToolbarButton} to enter Picture-in-Picture.
  28. */
  29. class InviteButton extends Component<Props> {
  30. /**
  31. * Implements React's {@link Component#render()}.
  32. *
  33. * @inheritdoc
  34. * @returns {ReactElement}
  35. */
  36. render() {
  37. const {
  38. enableAddPeople,
  39. enableDialOut,
  40. onLaunchNativeInvite,
  41. ...props
  42. } = this.props;
  43. if (!enableAddPeople && !enableDialOut) {
  44. return null;
  45. }
  46. return (
  47. <ToolbarButton
  48. iconName = { 'add' }
  49. onClick = { onLaunchNativeInvite }
  50. { ...props } />
  51. );
  52. }
  53. }
  54. /**
  55. * Maps redux actions to {@link InviteButton}'s React
  56. * {@code Component} props.
  57. *
  58. * @param {Function} dispatch - The redux action {@code dispatch} function.
  59. * @returns {{
  60. * onLaunchNativeInvite
  61. * }}
  62. * @private
  63. */
  64. function _mapDispatchToProps(dispatch) {
  65. return {
  66. /**
  67. * Launches native invite dialog.
  68. *
  69. * @private
  70. * @returns {void}
  71. * @type {Function}
  72. */
  73. onLaunchNativeInvite() {
  74. dispatch(launchNativeInvite());
  75. }
  76. };
  77. }
  78. export default connect(undefined, _mapDispatchToProps)(InviteButton);