Skip to content

Commit

Permalink
feat(prejoin) Add possibility to hide extra join options buttons (#10434
Browse files Browse the repository at this point in the history
)
  • Loading branch information
horymury authored Dec 8, 2021
1 parent 81e9d01 commit 10e5b2f
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 23 deletions.
10 changes: 8 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,14 @@ var config = {
// and microsoftApiApplicationClientID
// enableCalendarIntegration: false,

// When 'true', it shows an intermediate page before joining, where the user can configure their devices.
// prejoinPageEnabled: false,
// Configs for prejoin page.
// prejoinConfig: {
// // When 'true', it shows an intermediate page before joining, where the user can configure their devices.
// // This replaces `prejoinPageEnabled`.
// enabled: true,
// // List of buttons to hide from the extra join options dropdown.
// hideExtraJoinButtons: ['no-audio', 'by-phone']
// },

// When 'true', the user cannot edit the display name.
// (Mainly useful when used in conjuction with the JWT so the JWT name becomes read only.)
Expand Down
1 change: 1 addition & 0 deletions react/features/base/config/configWhitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export default [
'pcStatsInterval',
'preferH264',
'preferredCodec',
'prejoinConfig',
'prejoinPageEnabled',
'requireDisplayName',
'remoteVideoMenu',
Expand Down
7 changes: 7 additions & 0 deletions react/features/base/config/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ function _translateLegacyConfig(oldValue: Object) {
};
}

newValue.prejoinConfig = oldValue.prejoinConfig || {};
if (oldValue.hasOwnProperty('prejoinPageEnabled')
&& !newValue.prejoinConfig.hasOwnProperty('enabled')
) {
newValue.prejoinConfig.enabled = oldValue.prejoinPageEnabled;
}

newValue.disabledSounds = newValue.disabledSounds || [];

if (oldValue.disableJoinLeaveSounds) {
Expand Down
2 changes: 1 addition & 1 deletion react/features/prejoin/components/DropdownButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const styles = theme => {
display: 'flex',
height: 40,
fontSize: 15,
lineHeight: 24,
lineHeight: '24px',
padding: '0 16px',
backgroundColor: theme.palette.field02,

Expand Down
78 changes: 61 additions & 17 deletions react/features/prejoin/components/Prejoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ type Props = {
*/
updateSettings: Function,

/**
* The prejoin config.
*/
prejoinConfig?: Object,

/**
* Whether the name input should be read only or not.
*/
Expand Down Expand Up @@ -139,6 +144,7 @@ class Prejoin extends Component<Props, State> {
this._onJoinConferenceWithoutAudioKeyPress = this._onJoinConferenceWithoutAudioKeyPress.bind(this);
this._showDialogKeyPress = this._showDialogKeyPress.bind(this);
this._onJoinKeyPress = this._onJoinKeyPress.bind(this);
this._getExtraJoinButtons = this._getExtraJoinButtons.bind(this);
}
_onJoinButtonClick: () => void;

Expand Down Expand Up @@ -277,6 +283,40 @@ class Prejoin extends Component<Props, State> {
}
}

_getExtraJoinButtons: () => Object;

/**
* Gets the list of extra join buttons.
*
* @returns {Object} - The list of extra buttons.
*/
_getExtraJoinButtons() {
const { joinConferenceWithoutAudio, t } = this.props;

const noAudio = {
key: 'no-audio',
dataTestId: 'prejoin.joinWithoutAudio',
icon: IconVolumeOff,
label: t('prejoin.joinWithoutAudio'),
onButtonClick: joinConferenceWithoutAudio,
onKeyPressed: this._onJoinConferenceWithoutAudioKeyPress
};

const byPhone = {
key: 'by-phone',
dataTestId: 'prejoin.joinByPhone',
icon: IconPhone,
label: t('prejoin.joinAudioByPhone'),
onButtonClick: this._showDialog,
onKeyPressed: this._showDialogKeyPress
};

return {
noAudio,
byPhone
};
}

/**
* Implements React's {@link Component#render()}.
*
Expand All @@ -290,15 +330,25 @@ class Prejoin extends Component<Props, State> {
joinConference,
joinConferenceWithoutAudio,
name,
prejoinConfig,
readOnlyName,
showCameraPreview,
showDialog,
t,
videoTrack
} = this.props;
const { _closeDialog, _onDropdownClose, _onJoinButtonClick, _onJoinKeyPress,
_onOptionsClick, _setName } = this;

const extraJoinButtons = this._getExtraJoinButtons();
let extraButtonsToRender = Object.values(extraJoinButtons).filter((val: Object) =>
!(prejoinConfig?.hideExtraJoinButtons || []).includes(val.key)
);

const { _closeDialog, _onDropdownClose, _onJoinButtonClick, _onJoinKeyPress, _showDialogKeyPress,
_onJoinConferenceWithoutAudioKeyPress, _onOptionsClick, _setName, _showDialog } = this;
if (!hasJoinByPhoneButton) {
extraButtonsToRender = extraButtonsToRender.filter((btn: Object) => btn.key !== 'by-phone');
}
const hasExtraJoinButtons = Boolean(extraButtonsToRender.length);
const { showJoinByPhoneButtons, showError } = this.state;

return (
Expand Down Expand Up @@ -327,19 +377,12 @@ class Prejoin extends Component<Props, State> {

<div className = 'prejoin-preview-dropdown-container'>
<InlineDialog
content = { <div className = 'prejoin-preview-dropdown-btns'>
<DropdownButton
dataTestId = 'prejoin.joinWithoutAudio'
icon = { IconVolumeOff }
label = { t('prejoin.joinWithoutAudio') }
onButtonClick = { joinConferenceWithoutAudio }
onKeyPressed = { _onJoinConferenceWithoutAudioKeyPress } />
{hasJoinByPhoneButton && <DropdownButton
dataTestId = 'prejoin.joinByPhone'
icon = { IconPhone }
label = { t('prejoin.joinAudioByPhone') }
onButtonClick = { _showDialog }
onKeyPressed = { _showDialogKeyPress } />}
content = { hasExtraJoinButtons && <div className = 'prejoin-preview-dropdown-btns'>
{extraButtonsToRender.map(({ key, ...rest }: Object) => (
<DropdownButton
key = { key }
{ ...rest } />
))}
</div> }
isOpen = { showJoinByPhoneButtons }
onClose = { _onDropdownClose }>
Expand All @@ -348,7 +391,7 @@ class Prejoin extends Component<Props, State> {
ariaDropDownLabel = { t('prejoin.joinWithoutAudio') }
ariaLabel = { t('prejoin.joinMeeting') }
ariaPressed = { showJoinByPhoneButtons }
hasOptions = { true }
hasOptions = { hasExtraJoinButtons }
onClick = { _onJoinButtonClick }
onKeyPress = { _onJoinKeyPress }
onOptionsClick = { _onOptionsClick }
Expand Down Expand Up @@ -390,7 +433,8 @@ function mapStateToProps(state): Object {
hasJoinByPhoneButton: isJoinByPhoneButtonVisible(state),
readOnlyName: isNameReadOnly(state),
showCameraPreview: !isVideoMutedByUser(state),
videoTrack: getLocalJitsiVideoTrack(state)
videoTrack: getLocalJitsiVideoTrack(state),
prejoinConfig: state['features/base/config'].prejoinConfig
};
}

Expand Down
4 changes: 3 additions & 1 deletion react/features/prejoin/components/PrejoinApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export default class PrejoinApp extends BaseApp<Props> {
const { startWithAudioMuted, startWithVideoMuted } = store.getState()['features/base/settings'];

dispatch(setConfig({
prejoinPageEnabled: true,
prejoinConfig: {
enabled: true
},
startWithAudioMuted,
startWithVideoMuted
}));
Expand Down
2 changes: 1 addition & 1 deletion react/features/prejoin/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function isJoinByPhoneDialogVisible(state: Object): boolean {
*/
export function isPrejoinPageEnabled(state: Object): boolean {
return navigator.product !== 'ReactNative'
&& state['features/base/config'].prejoinPageEnabled
&& state['features/base/config'].prejoinConfig?.enabled
&& !state['features/base/settings'].userSelectedSkipPrejoin
&& !(state['features/base/config'].enableForcedReload && state['features/prejoin'].skipPrejoinOnReload);
}
Expand Down
2 changes: 1 addition & 1 deletion react/features/settings/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function getMoreTabProps(stateful: Object | Function) {
languages: LANGUAGES,
showLanguageSettings: configuredTabs.includes('language'),
showPrejoinPage: !state['features/base/settings'].userSelectedSkipPrejoin,
showPrejoinSettings: state['features/base/config'].prejoinPageEnabled
showPrejoinSettings: state['features/base/config'].prejoinConfig?.enabled
};
}

Expand Down

0 comments on commit 10e5b2f

Please sign in to comment.