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.

RoomLockButton.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import { translate } from '../../base/i18n';
  4. import { AbstractButton } from '../../base/toolbox';
  5. import type { AbstractButtonProps } from '../../base/toolbox';
  6. import { beginRoomLockRequest } from '../actions';
  7. type Props = AbstractButtonProps & {
  8. /**
  9. * The current conference.
  10. */
  11. _conference: Object,
  12. /**
  13. * Whether the current conference is locked or not.
  14. */
  15. _locked: boolean,
  16. /**
  17. * The redux {@code dispatch} function.
  18. */
  19. dispatch: Function
  20. };
  21. /**
  22. * An implementation of a button for locking / unlocking a room.
  23. */
  24. class RoomLockButton extends AbstractButton<Props, *> {
  25. accessibilityLabel = 'Room lock';
  26. iconName = 'security';
  27. label = 'toolbar.lock';
  28. toggledIconName = 'security-locked';
  29. /**
  30. * Handles clicking / pressing the button.
  31. *
  32. * @override
  33. * @protected
  34. * @returns {void}
  35. */
  36. _handleClick() {
  37. this.props.dispatch(beginRoomLockRequest());
  38. }
  39. /**
  40. * Indicates whether this button is disabled or not.
  41. *
  42. * @override
  43. * @protected
  44. * @returns {boolean}
  45. */
  46. _isDisabled() {
  47. return !this.props._conference;
  48. }
  49. /**
  50. * Indicates whether this button is in toggled state or not.
  51. *
  52. * @override
  53. * @protected
  54. * @returns {boolean}
  55. */
  56. _isToggled() {
  57. return this.props._locked;
  58. }
  59. }
  60. /**
  61. * Maps (parts of) the redux state to the associated props for the
  62. * {@code RoomLockButton} component.
  63. *
  64. * @param {Object} state - The Redux state.
  65. * @private
  66. * @returns {{
  67. * _audioOnly: boolean
  68. * }}
  69. */
  70. function _mapStateToProps(state): Object {
  71. const { conference, locked } = state['features/base/conference'];
  72. return {
  73. _conference: conference,
  74. _locked: Boolean(conference && locked)
  75. };
  76. }
  77. export default translate(connect(_mapStateToProps)(RoomLockButton));