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.

LocalRecordingButton.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { translate } from '../../base/i18n';
  4. import { IconRec } from '../../base/icons';
  5. import { ToolbarButton } from '../../toolbox';
  6. /**
  7. * The type of the React {@code Component} state of
  8. * {@link LocalRecordingButton}.
  9. */
  10. type Props = {
  11. /**
  12. * Whether or not {@link LocalRecordingInfoDialog} should be displayed.
  13. */
  14. isDialogShown: boolean,
  15. /**
  16. * Callback function called when {@link LocalRecordingButton} is clicked.
  17. */
  18. onClick: Function,
  19. /**
  20. * Invoked to obtain translated strings.
  21. */
  22. t: Function
  23. }
  24. /**
  25. * A React {@code Component} for opening or closing the
  26. * {@code LocalRecordingInfoDialog}.
  27. *
  28. * @extends Component
  29. */
  30. class LocalRecordingButton extends Component<Props> {
  31. /**
  32. * Initializes a new {@code LocalRecordingButton} instance.
  33. *
  34. * @param {Object} props - The read-only properties with which the new
  35. * instance is to be initialized.
  36. */
  37. constructor(props: Props) {
  38. super(props);
  39. // Bind event handlers so they are only bound once per instance.
  40. this._onClick = this._onClick.bind(this);
  41. }
  42. /**
  43. * Implements React's {@link Component#render()}.
  44. *
  45. * @inheritdoc
  46. * @returns {ReactElement}
  47. */
  48. render() {
  49. const { isDialogShown, t } = this.props;
  50. return (
  51. <ToolbarButton
  52. accessibilityLabel
  53. = { t('toolbar.accessibilityLabel.localRecording') }
  54. icon = { IconRec }
  55. onClick = { this._onClick }
  56. toggled = { isDialogShown }
  57. tooltip = { t('localRecording.dialogTitle') } />
  58. );
  59. }
  60. _onClick: () => void;
  61. /**
  62. * Callback invoked when the Toolbar button is clicked.
  63. *
  64. * @private
  65. * @returns {void}
  66. */
  67. _onClick() {
  68. this.props.onClick();
  69. }
  70. }
  71. export default translate(LocalRecordingButton);