jiti-meet/react/features/room-lock/components/RoomLockButton.js

92 lines
1.9 KiB
JavaScript
Raw Normal View History

// @flow
import { connect } from 'react-redux';
import { translate } from '../../base/i18n';
import { AbstractButton } from '../../base/toolbox';
import type { AbstractButtonProps } from '../../base/toolbox';
import { beginRoomLockRequest } from '../actions';
type Props = AbstractButtonProps & {
/**
* The current conference.
*/
_conference: Object,
/**
* Whether the current conference is locked or not.
*/
_locked: boolean,
/**
* The redux {@code dispatch} function.
*/
dispatch: Function
};
/**
* An implementation of a button for locking / unlocking a room.
*/
class RoomLockButton extends AbstractButton<Props, *> {
accessibilityLabel = 'Room lock';
iconName = 'security';
label = 'toolbar.lock';
toggledIconName = 'security-locked';
/**
* Handles clicking / pressing the button.
*
2018-05-11 02:10:26 +00:00
* @override
* @protected
* @returns {void}
*/
_handleClick() {
this.props.dispatch(beginRoomLockRequest());
}
/**
* Indicates whether this button is disabled or not.
*
* @override
2018-05-11 02:10:26 +00:00
* @protected
* @returns {boolean}
*/
_isDisabled() {
return !this.props._conference;
}
/**
* Indicates whether this button is in toggled state or not.
*
* @override
2018-05-11 02:10:26 +00:00
* @protected
* @returns {boolean}
*/
_isToggled() {
return this.props._locked;
}
}
/**
* Maps (parts of) the redux state to the associated props for the
* {@code RoomLockButton} component.
*
* @param {Object} state - The Redux state.
* @private
* @returns {{
* _audioOnly: boolean
* }}
*/
function _mapStateToProps(state): Object {
const { conference, locked } = state['features/base/conference'];
return {
_conference: conference,
_locked: Boolean(conference && locked)
};
}
export default translate(connect(_mapStateToProps)(RoomLockButton));