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.

ShareScreenWarningDialog.tsx 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import React, { Component } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { IStore } from '../../app/types';
  4. import { translate } from '../../base/i18n/functions';
  5. import { connect } from '../../base/redux/functions';
  6. // eslint-disable-next-line lines-around-comment
  7. // @ts-ignore
  8. import { toggleScreensharing } from '../../base/tracks/actions';
  9. import Dialog from '../../base/ui/components/web/Dialog';
  10. export interface Props extends WithTranslation {
  11. /**
  12. * Whether or not the dialog was opened for the audio screen sharing flow or the normal one.
  13. */
  14. _isAudioScreenShareWarning: Boolean;
  15. /**
  16. * The redux {@code dispatch} function.
  17. */
  18. dispatch: IStore['dispatch'];
  19. }
  20. /**
  21. * Component that displays the share audio helper dialog.
  22. */
  23. class ShareScreenWarningDialog extends Component<Props> {
  24. /**
  25. * Instantiates a new component.
  26. *
  27. * @inheritdoc
  28. */
  29. constructor(props: Props) {
  30. super(props);
  31. this._onStopSharing = this._onStopSharing.bind(this);
  32. }
  33. /**
  34. * Stop current screen sharing session.
  35. *
  36. * @returns {boolean}
  37. */
  38. _onStopSharing() {
  39. // Depending on the context from which this dialog is opened we'll either be toggling off an audio only
  40. // share session or a normal screen sharing one, this is indicated by the _isAudioScreenShareWarning prop.
  41. this.props.dispatch(toggleScreensharing(undefined,
  42. !this.props._isAudioScreenShareWarning));
  43. return true;
  44. }
  45. /**
  46. * Implements {@Component#render}.
  47. *§.
  48. *
  49. * @inheritdoc
  50. */
  51. render() {
  52. const { t } = this.props;
  53. let description1, description2, header1, header2, stopSharing, title;
  54. if (this.props._isAudioScreenShareWarning) {
  55. header1 = 'dialog.shareAudioWarningH1';
  56. header2 = 'dialog.shareMediaWarningGenericH2';
  57. description1 = 'dialog.shareAudioWarningD1';
  58. description2 = 'dialog.shareAudioWarningD2';
  59. title = 'dialog.shareAudioWarningTitle';
  60. stopSharing = 'toolbar.stopScreenSharing';
  61. } else {
  62. header1 = 'dialog.shareScreenWarningTitle';
  63. header2 = 'dialog.shareMediaWarningGenericH2';
  64. description1 = 'dialog.shareScreenWarningD1';
  65. description2 = 'dialog.shareScreenWarningD2';
  66. title = 'dialog.shareScreenWarningTitle';
  67. stopSharing = 'toolbar.stopAudioSharing';
  68. }
  69. return (<Dialog
  70. ok = {{ translationKey: stopSharing }}
  71. onSubmit = { this._onStopSharing }
  72. titleKey = { t(title) }>
  73. <div className = 'share-screen-warn-dialog'>
  74. <p className = 'header'> { t(header1) } </p>
  75. <p className = 'description' > { t(description1) } </p>
  76. <div className = 'separator-line' />
  77. <p className = 'header' > { t(header2) } </p>
  78. <p className = 'description' > { t(description2) } </p>
  79. </div>
  80. </Dialog>);
  81. }
  82. }
  83. export default translate(connect()(ShareScreenWarningDialog));