2021-07-08 13:42:07 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { translate } from '../../../base/i18n';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconScreenshare, IconStopScreenshare } from '../../../base/icons';
|
2021-07-08 13:42:07 +00:00
|
|
|
import JitsiMeetJS from '../../../base/lib-jitsi-meet/_';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2022-10-28 10:07:58 +00:00
|
|
|
import { isScreenVideoShared } from '../../../screen-share/functions';
|
2022-01-05 20:27:42 +00:00
|
|
|
import { isDesktopShareButtonDisabled } from '../../functions';
|
2021-07-08 13:42:07 +00:00
|
|
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
2022-08-16 12:53:53 +00:00
|
|
|
* Whether or not screensharing is initialized.
|
2021-07-08 13:42:07 +00:00
|
|
|
*/
|
2022-08-16 12:53:53 +00:00
|
|
|
_desktopSharingEnabled: boolean,
|
2021-07-08 13:42:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the local participant is screensharing.
|
|
|
|
*/
|
2022-08-16 12:53:53 +00:00
|
|
|
_screensharing: boolean,
|
2021-07-08 13:42:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
2022-08-16 12:53:53 +00:00
|
|
|
dispatch: Function,
|
2021-07-08 13:42:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of a button for sharing desktop / windows.
|
|
|
|
*/
|
|
|
|
class ShareDesktopButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.shareYourScreen';
|
|
|
|
label = 'toolbar.startScreenSharing';
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = IconScreenshare;
|
|
|
|
toggledIcon = IconStopScreenshare;
|
2021-11-04 21:10:43 +00:00
|
|
|
toggledLabel = 'toolbar.stopScreenSharing';
|
2021-07-08 13:42:07 +00:00
|
|
|
tooltip = 'toolbar.accessibilityLabel.shareYourScreen';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves tooltip dynamically.
|
|
|
|
*/
|
|
|
|
get tooltip() {
|
2022-08-16 12:53:53 +00:00
|
|
|
const { _desktopSharingEnabled, _screensharing } = this.props;
|
2021-07-08 13:42:07 +00:00
|
|
|
|
|
|
|
if (_desktopSharingEnabled) {
|
|
|
|
if (_screensharing) {
|
|
|
|
return 'toolbar.stopScreenSharing';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'toolbar.startScreenSharing';
|
|
|
|
}
|
|
|
|
|
2022-08-16 12:53:53 +00:00
|
|
|
return 'dialog.shareYourScreenDisabled';
|
2021-07-08 13:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Required by linter due to AbstractButton overwritten prop being writable.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @param {string} _value - The icon value.
|
2021-07-08 13:42:07 +00:00
|
|
|
*/
|
2021-11-04 21:10:43 +00:00
|
|
|
set tooltip(_value) {
|
|
|
|
// Unused.
|
2021-07-08 13:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._screensharing;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is in disabled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isDisabled() {
|
|
|
|
return !this.props._desktopSharingEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
const mapStateToProps = state => {
|
2022-01-05 20:27:42 +00:00
|
|
|
// Disable the screenshare button if the video sender limit is reached and there is no video or media share in
|
|
|
|
// progress.
|
2022-08-16 12:53:53 +00:00
|
|
|
const desktopSharingEnabled
|
|
|
|
= JitsiMeetJS.isDesktopSharingEnabled() && !isDesktopShareButtonDisabled(state);
|
2022-01-05 20:27:42 +00:00
|
|
|
|
2021-07-08 13:42:07 +00:00
|
|
|
return {
|
|
|
|
_desktopSharingEnabled: desktopSharingEnabled,
|
2021-08-16 09:24:01 +00:00
|
|
|
_screensharing: isScreenVideoShared(state)
|
2021-07-08 13:42:07 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default translate(connect(mapStateToProps)(ShareDesktopButton));
|