Hide invite button in participant panel if disabled in config (#9287)

* Hide invite button in participant panel if disabled in config

* match code style, fix lint errors
This commit is contained in:
Shawn Chin 2021-06-02 17:49:44 +01:00 committed by GitHub
parent e5a3f8505e
commit 0d7ec9552b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { getParticipants } from '../../base/participants';
import { findStyledAncestor } from '../functions';
import { findStyledAncestor, shouldRenderInviteButton } from '../functions';
import { InviteButton } from './InviteButton';
import { MeetingParticipantContextMenu } from './MeetingParticipantContextMenu';
@ -36,6 +36,7 @@ const initialState = Object.freeze(Object.create(null));
export const MeetingParticipantList = () => {
const isMouseOverMenu = useRef(false);
const participants = useSelector(getParticipants, _.isEqual);
const showInviteButton = useSelector(shouldRenderInviteButton);
const [ raiseContext, setRaiseContext ] = useState<RaiseContext>(initialState);
const { t } = useTranslation();
@ -86,7 +87,7 @@ export const MeetingParticipantList = () => {
return (
<>
<Heading>{t('participantsPane.headings.participantsList', { count: participants.length })}</Heading>
<InviteButton />
{showInviteButton && <InviteButton />}
<div>
{participants.map(p => (
<MeetingParticipantItem

View File

@ -1,3 +1,7 @@
import { getFeatureFlag, INVITE_ENABLED } from '../base/flags';
import { toState } from '../base/redux';
import { REDUCER_KEY } from './constants';
/**
@ -64,3 +68,15 @@ const getState = state => state[REDUCER_KEY];
*/
export const getParticipantsPaneOpen = state => Boolean(getState(state)?.isOpen);
/**
* Returns true if the invite button should be rendered.
*
* @param {Object} state - Global state.
* @returns {boolean}
*/
export const shouldRenderInviteButton = state => {
const { disableInviteFunctions } = toState(state)['features/base/config'];
const flagEnabled = getFeatureFlag(state, INVITE_ENABLED, true);
return flagEnabled && !disableInviteFunctions;
};