jiti-meet/react/features/toolbox/components/ProfileButton.web.js

148 lines
3.5 KiB
JavaScript
Raw Normal View History

2017-09-22 22:02:34 +00:00
/* @flow */
import PropTypes from 'prop-types';
2017-09-22 22:02:34 +00:00
import React, { Component } from 'react';
import { connect } from 'react-redux';
Restructures the analytics events (#2333) * ref: Restructures the pinned/unpinned events. * ref: Refactors the "audio only disabled" event. * ref: Refactors the "stream switch delay" event. * ref: Refactors the "select participant failed" event. * ref: Refactors the "initially muted" events. * ref: Refactors the screen sharing started/stopped events. * ref: Restructures the "device list changed" events. * ref: Restructures the "shared video" events. * ref: Restructures the "start muted" events. * ref: Restructures the "start audio only" event. * ref: Restructures the "sync track state" event. * ref: Restructures the "callkit" events. * ref: Restructures the "replace track". * ref: Restructures keyboard shortcuts events. * ref: Restructures most of the toolbar events. * ref: Refactors the API events. * ref: Restructures the video quality, profile button and invite dialog events. * ref: Refactors the "device changed" events. * ref: Refactors the page reload event. * ref: Removes an unused function. * ref: Removes a method which is needlessly exposed under a different name. * ref: Refactors the events from the remote video menu. * ref: Refactors the events from the profile pane. * ref: Restructures the recording-related events. Removes events fired when recording with something other than jibri (which isn't currently supported anyway). * ref: Cleans up AnalyticsEvents.js. * ref: Removes an unused function and adds documentation. * feat: Adds events for all API calls. * fix: Addresses feedback. * fix: Brings back mistakenly removed code. * fix: Simplifies code and fixes a bug in toggleFilmstrip when the 'visible' parameter is defined. * feat: Removes the resolution change application log. * ref: Uses consistent naming for events' attributes. Uses "_" as a separator instead of camel case or ".". * ref: Don't add the user agent and conference name as permanent properties. The library does this on its own now. * ref: Adapts the GA handler to changes in lib-jitsi-meet. * ref: Removes unused fields from the analytics handler initializaiton. * ref: Renames the google analytics file and add docs. * fix: Fixes the push-to-talk events and logs. * npm: Updates lib-jitsi-meet to 515374c8d383cb17df8ed76427e6f0fb5ea6ff1e. * fix: Fixes a recently introduced bug in the google analytics handler. * ref: Uses "value" instead of "delay" since this is friendlier to GA.
2018-01-03 21:24:07 +00:00
import {
createToolbarEvent,
sendAnalytics
} from '../../analytics';
import {
getAvatarURL,
getLocalParticipant
} from '../../base/participants';
2017-09-22 22:02:34 +00:00
import UIEvents from '../../../../service/UI/UIEvents';
import ToolbarButton from './ToolbarButton';
declare var APP: Object;
/**
* The default configuration for the button.
*
* @type {Object}
*/
const DEFAULT_BUTTON_CONFIGURATION = {
buttonName: 'profile',
classNames: [ 'button' ],
enabled: true,
id: 'toolbar_button_profile',
tooltipKey: 'profile.setDisplayNameLabel'
};
/**
* React {@code Component} for the profile button.
*
* @extends Component
*/
class ProfileButton extends Component<*> {
2017-09-22 22:02:34 +00:00
_onClick: Function;
/**
* {@code ProfileButton}'s property types.
*
* @static
*/
static propTypes = {
/**
* The redux representation of the local participant.
*/
_localParticipant: PropTypes.object,
2017-09-22 22:02:34 +00:00
/**
* Whether the button support clicking or not.
*/
_unclickable: PropTypes.bool,
2017-09-22 22:02:34 +00:00
/**
* Whether the side panel is opened or not.
*/
toggled: PropTypes.bool,
2017-09-22 22:02:34 +00:00
/**
* From which side tooltips should display. Will be re-used for
* displaying the inline dialog for video quality adjustment.
*/
tooltipPosition: PropTypes.string
2017-09-22 22:02:34 +00:00
};
/**
* Initializes a new {@code ProfileButton} instance.
*
* @param {Object} props - The read-only properties with which the new
* instance is to be initialized.
*/
constructor(props) {
super(props);
// Bind event handlers so they are only bound once for every instance.
this._onClick = this._onClick.bind(this);
}
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
const {
_localParticipant,
_unclickable,
tooltipPosition,
toggled
} = this.props;
2017-09-22 22:02:34 +00:00
const buttonConfiguration = {
...DEFAULT_BUTTON_CONFIGURATION,
unclickable: _unclickable,
toggled
};
return (
<ToolbarButton
button = { buttonConfiguration }
onClick = { this._onClick }
tooltipPosition = { tooltipPosition }>
<img
id = 'avatar'
src = { getAvatarURL(_localParticipant) } />
2017-09-22 22:02:34 +00:00
</ToolbarButton>
);
}
/**
* Click handler for the button.
*
* @returns {void}
*/
_onClick() {
if (!this.props._unclickable) {
Restructures the analytics events (#2333) * ref: Restructures the pinned/unpinned events. * ref: Refactors the "audio only disabled" event. * ref: Refactors the "stream switch delay" event. * ref: Refactors the "select participant failed" event. * ref: Refactors the "initially muted" events. * ref: Refactors the screen sharing started/stopped events. * ref: Restructures the "device list changed" events. * ref: Restructures the "shared video" events. * ref: Restructures the "start muted" events. * ref: Restructures the "start audio only" event. * ref: Restructures the "sync track state" event. * ref: Restructures the "callkit" events. * ref: Restructures the "replace track". * ref: Restructures keyboard shortcuts events. * ref: Restructures most of the toolbar events. * ref: Refactors the API events. * ref: Restructures the video quality, profile button and invite dialog events. * ref: Refactors the "device changed" events. * ref: Refactors the page reload event. * ref: Removes an unused function. * ref: Removes a method which is needlessly exposed under a different name. * ref: Refactors the events from the remote video menu. * ref: Refactors the events from the profile pane. * ref: Restructures the recording-related events. Removes events fired when recording with something other than jibri (which isn't currently supported anyway). * ref: Cleans up AnalyticsEvents.js. * ref: Removes an unused function and adds documentation. * feat: Adds events for all API calls. * fix: Addresses feedback. * fix: Brings back mistakenly removed code. * fix: Simplifies code and fixes a bug in toggleFilmstrip when the 'visible' parameter is defined. * feat: Removes the resolution change application log. * ref: Uses consistent naming for events' attributes. Uses "_" as a separator instead of camel case or ".". * ref: Don't add the user agent and conference name as permanent properties. The library does this on its own now. * ref: Adapts the GA handler to changes in lib-jitsi-meet. * ref: Removes unused fields from the analytics handler initializaiton. * ref: Renames the google analytics file and add docs. * fix: Fixes the push-to-talk events and logs. * npm: Updates lib-jitsi-meet to 515374c8d383cb17df8ed76427e6f0fb5ea6ff1e. * fix: Fixes a recently introduced bug in the google analytics handler. * ref: Uses "value" instead of "delay" since this is friendlier to GA.
2018-01-03 21:24:07 +00:00
// TODO: Include an 'enable' attribute, which specifies whether
// the profile panel was opened or closed.
sendAnalytics(createToolbarEvent('profile'));
2017-09-22 22:02:34 +00:00
APP.UI.emitEvent(UIEvents.TOGGLE_PROFILE);
}
}
}
/**
* Maps (parts of) the Redux state to the associated {@code ProfileButton}
* component's props.
*
* @param {Object} state - The Redux state.
* @private
* @returns {{
* _localParticipant: Object,
2017-09-22 22:02:34 +00:00
* _unclickable: boolean
* }}
*/
function _mapStateToProps(state) {
return {
_localParticipant: getLocalParticipant(state),
2017-10-05 22:54:13 +00:00
_unclickable: !state['features/base/jwt'].isGuest
2017-09-22 22:02:34 +00:00
};
}
export default connect(_mapStateToProps)(ProfileButton);