forked from jitsi/jitsi-meet
/
AbstractGrantModeratorButton.js
75 lines (63 loc) · 1.9 KB
/
AbstractGrantModeratorButton.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// @flow
import { openDialog } from '../../base/dialog';
import { IconCrown } from '../../base/icons';
import {
getLocalParticipant,
getParticipantById,
isParticipantModerator,
PARTICIPANT_ROLE
} from '../../base/participants';
import { AbstractButton } from '../../base/toolbox';
import type { AbstractButtonProps } from '../../base/toolbox';
import { GrantModeratorDialog } from '.';
export type Props = AbstractButtonProps & {
/**
* The redux {@code dispatch} function.
*/
dispatch: Function,
/**
* The ID of the participant for whom to grant moderator status.
*/
participantID: string,
/**
* The function to be used to translate i18n labels.
*/
t: Function
};
/**
* An abstract remote video menu button which kicks the remote participant.
*/
export default class AbstractGrantModeratorButton extends AbstractButton<Props, *> {
accessibilityLabel = 'toolbar.accessibilityLabel.grantModerator';
icon = IconCrown;
label = 'videothumbnail.grantModerator';
/**
* Handles clicking / pressing the button, and kicks the participant.
*
* @private
* @returns {void}
*/
_handleClick() {
const { dispatch, participantID } = this.props;
dispatch(openDialog(GrantModeratorDialog, { participantID }));
}
}
/**
* Function that maps parts of Redux state tree into component props.
*
* @param {Object} state - Redux state.
* @param {Object} ownProps - Properties of component.
* @private
* @returns {{
* visible: boolean
* }}
*/
export function _mapStateToProps(state: Object, ownProps: Props) {
const { participantID } = ownProps;
const localParticipant = getLocalParticipant(state);
const targetParticipant = getParticipantById(state, participantID);
return {
visible: Boolean(localParticipant?.role === PARTICIPANT_ROLE.MODERATOR)
&& !isParticipantModerator(targetParticipant)
};
}