您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RoomLockButton.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import { translate } from '../../../../base/i18n';
  4. import { beginRoomLockRequest } from '../../../../room-lock';
  5. import AbstractButton from '../AbstractButton';
  6. import type { Props as AbstractButtonProps } from '../AbstractButton';
  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. * @private
  33. * @returns {void}
  34. */
  35. _handleClick() {
  36. this.props.dispatch(beginRoomLockRequest());
  37. }
  38. /**
  39. * Indicates whether this button is disabled or not.
  40. *
  41. * @override
  42. * @private
  43. * @returns {boolean}
  44. */
  45. _isDisabled() {
  46. return !this.props._conference;
  47. }
  48. /**
  49. * Indicates whether this button is in toggled state or not.
  50. *
  51. * @override
  52. * @private
  53. * @returns {boolean}
  54. */
  55. _isToggled() {
  56. return this.props._locked;
  57. }
  58. }
  59. /**
  60. * Maps (parts of) the redux state to the associated props for the
  61. * {@code RoomLockButton} component.
  62. *
  63. * @param {Object} state - The Redux state.
  64. * @private
  65. * @returns {{
  66. * _audioOnly: boolean
  67. * }}
  68. */
  69. function _mapStateToProps(state): Object {
  70. const { conference, locked } = state['features/base/conference'];
  71. return {
  72. _conference: conference,
  73. _locked: Boolean(conference && locked)
  74. };
  75. }
  76. export default translate(connect(_mapStateToProps)(RoomLockButton));