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.

DeviceSelectionButton.web.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import Button from '@atlaskit/button';
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { translate } from '../../base/i18n';
  6. import { openDeviceSelectionDialog } from '../../device-selection';
  7. /**
  8. * Implements a React {@link Component} which displays a button for opening the
  9. * {@code DeviceSelectionDialog}.
  10. *
  11. * @extends Component
  12. */
  13. class DeviceSelectionButton extends Component {
  14. /**
  15. * {@code DeviceSelectionButton} component's property types.
  16. *
  17. * @static
  18. */
  19. static propTypes = {
  20. /**
  21. * Invoked to display the {@code DeviceSelectionDialog}.
  22. */
  23. dispatch: PropTypes.func,
  24. /**
  25. * Whether or not the button's title should be displayed.
  26. */
  27. showTitle: PropTypes.bool,
  28. /**
  29. * Invoked to obtain translated strings.
  30. */
  31. t: PropTypes.func
  32. };
  33. /**
  34. * Initializes a new {@code DeviceSelectionButton} instance.
  35. *
  36. * @param {Object} props - The read-only properties with which the new
  37. * instance is to be initialized.
  38. */
  39. constructor(props) {
  40. super(props);
  41. // Bind event handler so it is only bound once for every instance.
  42. this._onOpenDeviceSelectionDialog
  43. = this._onOpenDeviceSelectionDialog.bind(this);
  44. }
  45. /**
  46. * Implements React's {@link Component#render()}.
  47. *
  48. * @inheritdoc
  49. * @returns {ReactElement}
  50. */
  51. render() {
  52. return (
  53. <div>
  54. { this.props.showTitle
  55. ? <div className = 'subTitle'>
  56. { this.props.t('settings.audioVideo') }
  57. </div>
  58. : null }
  59. <Button
  60. appearance = 'primary'
  61. onClick = { this._onOpenDeviceSelectionDialog }
  62. shouldFitContainer = { true }>
  63. { this.props.t('deviceSelection.deviceSettings') }
  64. </Button>
  65. </div>
  66. );
  67. }
  68. /**
  69. * Opens the {@code DeviceSelectionDialog}.
  70. *
  71. * @private
  72. * @returns {void}
  73. */
  74. _onOpenDeviceSelectionDialog() {
  75. this.props.dispatch(openDeviceSelectionDialog());
  76. }
  77. }
  78. export default translate(connect()(DeviceSelectionButton));