2017-11-17 19:06:47 +00:00
|
|
|
// @flow
|
2017-02-02 16:49:14 +00:00
|
|
|
|
2017-08-29 20:55:35 +00:00
|
|
|
import Tooltip from '@atlaskit/tooltip';
|
2017-01-31 22:38:34 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-08-07 16:20:44 +00:00
|
|
|
import { connect } from 'react-redux';
|
2017-01-31 22:38:34 +00:00
|
|
|
|
2017-08-29 20:55:35 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
|
2017-08-07 16:20:44 +00:00
|
|
|
import { openFeedbackDialog } from '../actions';
|
2017-02-02 16:49:14 +00:00
|
|
|
|
2017-11-13 15:54:04 +00:00
|
|
|
/**
|
2017-11-17 19:06:47 +00:00
|
|
|
* The type of the React {@code Component} props of {@link FeedbackButton}.
|
2017-11-13 15:54:04 +00:00
|
|
|
*/
|
2017-11-17 19:06:47 +00:00
|
|
|
type Props = {
|
2017-11-13 15:54:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The JitsiConference for which the feedback will be about.
|
|
|
|
*
|
|
|
|
* FIXME define JitsiConference type
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
_conference: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Redux store dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Dispatch<*>,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* From which side of the button the tooltip should appear from.
|
|
|
|
*/
|
2017-11-17 19:06:47 +00:00
|
|
|
tooltipPosition: string
|
2017-11-13 15:54:04 +00:00
|
|
|
}
|
|
|
|
|
2017-01-31 22:38:34 +00:00
|
|
|
/**
|
2017-02-02 16:49:14 +00:00
|
|
|
* Implements a Web/React Component which renders a feedback button.
|
2017-01-31 22:38:34 +00:00
|
|
|
*/
|
2017-11-17 19:06:47 +00:00
|
|
|
class FeedbackButton extends Component<Props> {
|
2017-08-07 16:20:44 +00:00
|
|
|
_onClick: Function;
|
|
|
|
|
2017-02-02 16:49:14 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new FeedbackButton instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Object) {
|
|
|
|
super(props);
|
|
|
|
|
2017-08-07 16:20:44 +00:00
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
this._onClick = this._onClick.bind(this);
|
2017-02-02 16:49:14 +00:00
|
|
|
}
|
2017-01-31 22:38:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
2017-08-29 20:55:35 +00:00
|
|
|
<div id = 'feedbackButton'>
|
|
|
|
<Tooltip
|
|
|
|
description = { this.props.t('welcomepage.sendFeedback') }
|
|
|
|
position = { this.props.tooltipPosition } >
|
|
|
|
<a
|
|
|
|
className = 'button icon-feedback'
|
|
|
|
onClick = { this._onClick } />
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
2017-01-31 22:38:34 +00:00
|
|
|
);
|
|
|
|
}
|
2017-08-07 16:20:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatches an action to open a dialog requesting call feedback.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { _conference, dispatch } = this.props;
|
|
|
|
|
|
|
|
dispatch(openFeedbackDialog(_conference));
|
|
|
|
}
|
2017-01-31 22:38:34 +00:00
|
|
|
}
|
2017-08-07 16:20:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated Conference's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _toolboxVisible: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* The JitsiConference for which the feedback will be about.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
_conference: state['features/base/conference'].conference
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-08-29 20:55:35 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(FeedbackButton));
|