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

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