feat(participants): add isLocalParticipantModerator utility method
This commit is contained in:
parent
494e8eb8d9
commit
b57dad576a
|
@ -5,7 +5,8 @@ import { toState } from '../redux';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_AVATAR_RELATIVE_PATH,
|
DEFAULT_AVATAR_RELATIVE_PATH,
|
||||||
LOCAL_PARTICIPANT_DEFAULT_ID
|
LOCAL_PARTICIPANT_DEFAULT_ID,
|
||||||
|
PARTICIPANT_ROLE
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
declare var config: Object;
|
declare var config: Object;
|
||||||
|
@ -224,3 +225,28 @@ function _getAllParticipants(stateful) {
|
||||||
? stateful
|
? stateful
|
||||||
: toState(stateful)['features/base/participants'] || []);
|
: toState(stateful)['features/base/participants'] || []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the current local participant is a moderator in the
|
||||||
|
* conference.
|
||||||
|
*
|
||||||
|
* @param {Object|Function} stateful - Object or function that can be resolved
|
||||||
|
* to the Redux state.
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function isLocalParticipantModerator(stateful: Object | Function) {
|
||||||
|
const state = toState(stateful);
|
||||||
|
const localParticipant = getLocalParticipant(state);
|
||||||
|
|
||||||
|
if (!localParticipant) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isModerator = localParticipant.role === PARTICIPANT_ROLE.MODERATOR;
|
||||||
|
|
||||||
|
if (state['features/base/config'].enableUserRolesBasedOnToken) {
|
||||||
|
return isModerator && !state['features/base/jwt'].isGuest;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isModerator;
|
||||||
|
}
|
||||||
|
|
|
@ -5,10 +5,7 @@ import { connect } from 'react-redux';
|
||||||
import { setPassword } from '../../../base/conference';
|
import { setPassword } from '../../../base/conference';
|
||||||
import { getInviteURL } from '../../../base/connection';
|
import { getInviteURL } from '../../../base/connection';
|
||||||
import { translate } from '../../../base/i18n';
|
import { translate } from '../../../base/i18n';
|
||||||
import {
|
import { isLocalParticipantModerator } from '../../../base/participants';
|
||||||
PARTICIPANT_ROLE,
|
|
||||||
getLocalParticipant
|
|
||||||
} from '../../../base/participants';
|
|
||||||
|
|
||||||
import DialInNumber from './DialInNumber';
|
import DialInNumber from './DialInNumber';
|
||||||
import PasswordForm from './PasswordForm';
|
import PasswordForm from './PasswordForm';
|
||||||
|
@ -553,18 +550,9 @@ function _mapStateToProps(state) {
|
||||||
password,
|
password,
|
||||||
room
|
room
|
||||||
} = state['features/base/conference'];
|
} = state['features/base/conference'];
|
||||||
const isModerator
|
|
||||||
= getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR;
|
|
||||||
let canEditPassword;
|
|
||||||
|
|
||||||
if (state['features/base/config'].enableUserRolesBasedOnToken) {
|
|
||||||
canEditPassword = isModerator && !state['features/base/jwt'].isGuest;
|
|
||||||
} else {
|
|
||||||
canEditPassword = isModerator;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_canEditPassword: canEditPassword,
|
_canEditPassword: isLocalParticipantModerator(state),
|
||||||
_conference: conference,
|
_conference: conference,
|
||||||
_conferenceName: room,
|
_conferenceName: room,
|
||||||
_inviteURL: getInviteURL(state),
|
_inviteURL: getInviteURL(state),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import { getAppProp } from '../app';
|
import { getAppProp } from '../app';
|
||||||
import { getLocalParticipant, PARTICIPANT_ROLE } from '../base/participants';
|
import { isLocalParticipantModerator } from '../base/participants';
|
||||||
import { doGetJSON } from '../base/util';
|
import { doGetJSON } from '../base/util';
|
||||||
|
|
||||||
declare var $: Function;
|
declare var $: Function;
|
||||||
|
@ -300,14 +300,10 @@ export function isAddPeopleEnabled(state: Object): boolean {
|
||||||
* @returns {boolean} Indication of whether dial out is currently enabled.
|
* @returns {boolean} Indication of whether dial out is currently enabled.
|
||||||
*/
|
*/
|
||||||
export function isDialOutEnabled(state: Object): boolean {
|
export function isDialOutEnabled(state: Object): boolean {
|
||||||
const participant = getLocalParticipant(state);
|
|
||||||
const { conference } = state['features/base/conference'];
|
const { conference } = state['features/base/conference'];
|
||||||
const { isGuest } = state['features/base/jwt'];
|
let dialOutEnabled = isLocalParticipantModerator(state)
|
||||||
const { enableUserRolesBasedOnToken } = state['features/base/config'];
|
&& conference
|
||||||
let dialOutEnabled
|
&& conference.isSIPCallingSupported();
|
||||||
= participant && participant.role === PARTICIPANT_ROLE.MODERATOR
|
|
||||||
&& conference && conference.isSIPCallingSupported()
|
|
||||||
&& (!enableUserRolesBasedOnToken || !isGuest);
|
|
||||||
|
|
||||||
if (dialOutEnabled) {
|
if (dialOutEnabled) {
|
||||||
// XXX The mobile/react-native app is capable of disabling of dial-out.
|
// XXX The mobile/react-native app is capable of disabling of dial-out.
|
||||||
|
|
Loading…
Reference in New Issue