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 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* @flow */
  2. import InlineDialog from '@atlaskit/inline-dialog';
  3. import React, { Component } from 'react';
  4. import { translate } from '../../base/i18n';
  5. import { ToolbarButton } from '../../toolbox';
  6. import LocalRecordingInfoDialog from './LocalRecordingInfoDialog';
  7. /**
  8. * The type of the React {@code Component} state of
  9. * {@link LocalRecordingButton}.
  10. */
  11. type Props = {
  12. /**
  13. * Whether or not {@link LocalRecordingInfoDialog} should be displayed.
  14. */
  15. isDialogShown: boolean,
  16. /**
  17. * Callback function called when {@link LocalRecordingButton} is clicked.
  18. */
  19. onClick: Function,
  20. /**
  21. * Invoked to obtain translated strings.
  22. */
  23. t: Function
  24. }
  25. /**
  26. * A React {@code Component} for opening or closing the
  27. * {@code LocalRecordingInfoDialog}.
  28. *
  29. * @extends Component
  30. */
  31. class LocalRecordingButton extends Component<Props> {
  32. /**
  33. * Initializes a new {@code LocalRecordingButton} instance.
  34. *
  35. * @param {Object} props - The read-only properties with which the new
  36. * instance is to be initialized.
  37. */
  38. constructor(props: Props) {
  39. super(props);
  40. // Bind event handlers so they are only bound once per instance.
  41. this._onClick = this._onClick.bind(this);
  42. }
  43. /**
  44. * Implements React's {@link Component#render()}.
  45. *
  46. * @inheritdoc
  47. * @returns {ReactElement}
  48. */
  49. render() {
  50. const { isDialogShown, t } = this.props;
  51. const iconClasses
  52. = `icon-thumb-menu ${isDialogShown
  53. ? 'icon-rec toggled' : 'icon-rec'}`;
  54. return (
  55. <div className = 'toolbox-button-wth-dialog'>
  56. <InlineDialog
  57. content = {
  58. <LocalRecordingInfoDialog />
  59. }
  60. isOpen = { isDialogShown }
  61. onClose = { this._onCloseDialog }
  62. position = { 'top right' }>
  63. <ToolbarButton
  64. iconName = { iconClasses }
  65. onClick = { this._onClick }
  66. tooltip = { t('localRecording.dialogTitle') } />
  67. </InlineDialog>
  68. </div>
  69. );
  70. }
  71. _onClick: () => void;
  72. /**
  73. * Callback invoked when the Toolbar button is clicked.
  74. *
  75. * @private
  76. * @returns {void}
  77. */
  78. _onClick() {
  79. this.props.onClick();
  80. }
  81. _onCloseDialog: () => void;
  82. /**
  83. * Callback invoked when {@code InlineDialog} signals that it should be
  84. * close.
  85. *
  86. * @returns {void}
  87. */
  88. _onCloseDialog() {
  89. // Do nothing for now, because we want the dialog to stay open
  90. // after certain time, otherwise the moderator might need to repeatly
  91. // open the dialog to see the stats.
  92. }
  93. }
  94. export default translate(LocalRecordingButton);