For the most part the changes are taking the "static propTypes" declaration off of components and declaring them as Flow types. Sometimes to support flow some method signatures had to be added. There are some exceptions in which more had to be done to tame the beast: - AbstractVideoTrack: put in additional truthy checks for videoTrack. - Video: add truthy checks for the _videoElement ref. - shouldRenderVideoTrack function: Some component could pass null for the videoTrack argument and Flow wanted that called out explicitly. - DisplayName: Add a truthy check for the input ref before acting on it. - NumbersList: Move array checks inline for Flow to comprehend array methods could be called. Add type checks in the Object.entries loop as the value is assumed to be a mixed type by Flow. - AbstractToolbarButton: add additional truthy check for passed in type.
106 lines
2.7 KiB
JavaScript
106 lines
2.7 KiB
JavaScript
// @flow
|
|
|
|
import React, { Component } from 'react';
|
|
import { connect } from 'react-redux';
|
|
|
|
import { Dialog } from '../../base/dialog';
|
|
|
|
import { endRoomLockRequest } from '../actions';
|
|
|
|
/**
|
|
* The style of the {@link TextInput} rendered by {@code RoomLockPrompt}. As it
|
|
* requests the entry of a password, {@code TextInput} automatically correcting
|
|
* the entry of the password is a pain to deal with as a user.
|
|
*/
|
|
const _TEXT_INPUT_PROPS = {
|
|
autoCapitalize: 'none',
|
|
autoCorrect: false
|
|
};
|
|
|
|
/**
|
|
* The type of the React {@code Component} props of {@link RoomLockPrompt}.
|
|
*/
|
|
type Props = {
|
|
|
|
/**
|
|
* The JitsiConference which requires a password.
|
|
*/
|
|
conference: Object,
|
|
|
|
/**
|
|
* Redux store dispatch function.
|
|
*/
|
|
dispatch: Dispatch<*>,
|
|
};
|
|
|
|
/**
|
|
* Implements a React Component which prompts the user for a password to lock a
|
|
* conference/room.
|
|
*/
|
|
class RoomLockPrompt extends Component<Props> {
|
|
/**
|
|
* Initializes a new RoomLockPrompt instance.
|
|
*
|
|
* @param {Props} props - The read-only properties with which the new
|
|
* instance is to be initialized.
|
|
*/
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
// Bind event handlers so they are only bound once per instance.
|
|
this._onCancel = this._onCancel.bind(this);
|
|
this._onSubmit = this._onSubmit.bind(this);
|
|
}
|
|
|
|
/**
|
|
* Implements React's {@link Component#render()}.
|
|
*
|
|
* @inheritdoc
|
|
* @returns {ReactElement}
|
|
*/
|
|
render() {
|
|
return (
|
|
<Dialog
|
|
bodyKey = 'dialog.passwordLabel'
|
|
onCancel = { this._onCancel }
|
|
onSubmit = { this._onSubmit }
|
|
textInputProps = { _TEXT_INPUT_PROPS }
|
|
titleKey = 'dialog.lockRoom' />
|
|
);
|
|
}
|
|
|
|
_onCancel: () => boolean;
|
|
|
|
/**
|
|
* Notifies this prompt that it has been dismissed by cancel.
|
|
*
|
|
* @private
|
|
* @returns {boolean} True to hide this dialog/prompt; otherwise, false.
|
|
*/
|
|
_onCancel() {
|
|
// An undefined password is understood to cancel the request to lock the
|
|
// conference/room.
|
|
return this._onSubmit(undefined);
|
|
}
|
|
|
|
_onSubmit: (?string) => boolean;
|
|
|
|
/**
|
|
* Notifies this prompt that it has been dismissed by submitting a specific
|
|
* value.
|
|
*
|
|
* @param {string|undefined} value - The submitted value.
|
|
* @private
|
|
* @returns {boolean} False because we do not want to hide this
|
|
* dialog/prompt as the hiding will be handled inside endRoomLockRequest
|
|
* after setting the password is resolved.
|
|
*/
|
|
_onSubmit(value: ?string) {
|
|
this.props.dispatch(endRoomLockRequest(this.props.conference, value));
|
|
|
|
return false; // Do not hide.
|
|
}
|
|
}
|
|
|
|
export default connect()(RoomLockPrompt);
|