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

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