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.

FeedbackButton.web.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* @flow */
  2. import Tooltip from '@atlaskit/tooltip';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { translate } from '../../base/i18n';
  6. import { openFeedbackDialog } from '../actions';
  7. /**
  8. * Defines property types for the FeedbackButton component.
  9. */
  10. type FeedbackButtonPropTypes = {
  11. /**
  12. * The JitsiConference for which the feedback will be about.
  13. *
  14. * FIXME define JitsiConference type
  15. * @type {JitsiConference}
  16. */
  17. _conference: Object,
  18. /**
  19. * Redux store dispatch function.
  20. */
  21. dispatch: Dispatch<*>,
  22. /**
  23. * Invoked to obtain translated strings.
  24. */
  25. t: Function,
  26. /**
  27. * From which side of the button the tooltip should appear from.
  28. */
  29. tooltipPosition: String
  30. }
  31. /**
  32. * Implements a Web/React Component which renders a feedback button.
  33. */
  34. class FeedbackButton extends Component<FeedbackButtonPropTypes> {
  35. _onClick: Function;
  36. /**
  37. * Initializes a new FeedbackButton instance.
  38. *
  39. * @param {Object} props - The read-only properties with which the new
  40. * instance is to be initialized.
  41. */
  42. constructor(props: Object) {
  43. super(props);
  44. // Bind event handlers so they are only bound once for every instance.
  45. this._onClick = this._onClick.bind(this);
  46. }
  47. /**
  48. * Implements React's {@link Component#render()}.
  49. *
  50. * @inheritdoc
  51. * @returns {ReactElement}
  52. */
  53. render() {
  54. return (
  55. <div id = 'feedbackButton'>
  56. <Tooltip
  57. description = { this.props.t('welcomepage.sendFeedback') }
  58. position = { this.props.tooltipPosition } >
  59. <a
  60. className = 'button icon-feedback'
  61. onClick = { this._onClick } />
  62. </Tooltip>
  63. </div>
  64. );
  65. }
  66. /**
  67. * Dispatches an action to open a dialog requesting call feedback.
  68. *
  69. * @private
  70. * @returns {void}
  71. */
  72. _onClick() {
  73. const { _conference, dispatch } = this.props;
  74. dispatch(openFeedbackDialog(_conference));
  75. }
  76. }
  77. /**
  78. * Maps (parts of) the Redux state to the associated Conference's props.
  79. *
  80. * @param {Object} state - The Redux state.
  81. * @private
  82. * @returns {{
  83. * _toolboxVisible: boolean
  84. * }}
  85. */
  86. function _mapStateToProps(state) {
  87. return {
  88. /**
  89. * The JitsiConference for which the feedback will be about.
  90. *
  91. * @private
  92. * @type {JitsiConference}
  93. */
  94. _conference: state['features/base/conference'].conference
  95. };
  96. }
  97. export default translate(connect(_mapStateToProps)(FeedbackButton));