2020-07-15 10:13:28 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { openDialog } from '../../base/dialog';
|
|
|
|
import { IconCrown } from '../../base/icons';
|
|
|
|
import {
|
2022-09-27 07:10:28 +00:00
|
|
|
PARTICIPANT_ROLE,
|
2020-07-21 08:26:26 +00:00
|
|
|
getLocalParticipant,
|
2020-07-15 10:13:28 +00:00
|
|
|
getParticipantById,
|
2022-09-27 07:10:28 +00:00
|
|
|
isParticipantModerator
|
2020-07-15 10:13:28 +00:00
|
|
|
} from '../../base/participants';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
2020-07-15 10:13:28 +00:00
|
|
|
|
2022-01-20 10:59:50 +00:00
|
|
|
import { GrantModeratorDialog } from './';
|
2020-07-15 10:13:28 +00:00
|
|
|
|
|
|
|
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, *> {
|
2021-11-04 21:10:43 +00:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.grantModerator';
|
|
|
|
icon = IconCrown;
|
|
|
|
label = 'videothumbnail.grantModerator';
|
2020-07-15 10:13:28 +00:00
|
|
|
|
2021-11-04 21:10:43 +00:00
|
|
|
/**
|
2020-07-15 10:13:28 +00:00
|
|
|
* Handles clicking / pressing the button, and kicks the participant.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-11-04 21:10:43 +00:00
|
|
|
_handleClick() {
|
|
|
|
const { dispatch, participantID } = this.props;
|
2020-07-15 10:13:28 +00:00
|
|
|
|
2021-11-04 21:10:43 +00:00
|
|
|
dispatch(openDialog(GrantModeratorDialog, { participantID }));
|
|
|
|
}
|
2020-07-15 10:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2020-07-21 08:26:26 +00:00
|
|
|
const localParticipant = getLocalParticipant(state);
|
|
|
|
const targetParticipant = getParticipantById(state, participantID);
|
|
|
|
|
2020-07-15 10:13:28 +00:00
|
|
|
return {
|
2020-07-21 08:26:26 +00:00
|
|
|
visible: Boolean(localParticipant?.role === PARTICIPANT_ROLE.MODERATOR)
|
|
|
|
&& !isParticipantModerator(targetParticipant)
|
2020-07-15 10:13:28 +00:00
|
|
|
};
|
|
|
|
}
|