mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 15:47:47 +00:00
Converting the invite modal includes the following: - Creating new react components to display InviteDialog. The main parent components are ShareLink and PasswordOverview, the later handles displaying lock state and password editing. These components do not make use of atlaskit as the component for input does not yet support readonly, so for consistency within the modal content no atlaskit was used. - Using redux for keeping and accessing lock state instead of RoomLocker. - Publicly exposing the redux action lockStateChanged for direct calling on lock events experienced on the web client. - Removing Invite, InviteDialogView, and RoomLocker and references to them. - Handling errors that occur when setting a password to preserve existing web funtionality.
148 lines
3.9 KiB
JavaScript
148 lines
3.9 KiB
JavaScript
import React, { Component } from 'react';
|
|
|
|
import { translate } from '../../base/i18n';
|
|
import { LOCKED_LOCALLY } from '../../room-lock';
|
|
|
|
import AddPasswordForm from './AddPasswordForm';
|
|
import LockStatePanel from './LockStatePanel';
|
|
import RemovePasswordForm from './RemovePasswordForm';
|
|
|
|
/**
|
|
* React component for displaying the current room lock state as well as
|
|
* exposing features to modify the room lock.
|
|
*/
|
|
class PasswordContainer extends Component {
|
|
/**
|
|
* PasswordContainer component's property types.
|
|
*
|
|
* @static
|
|
*/
|
|
static propTypes = {
|
|
/**
|
|
* The JitsiConference for which to display a lock state and change the
|
|
* password.
|
|
*
|
|
* @type {JitsiConference}
|
|
*/
|
|
conference: React.PropTypes.object,
|
|
|
|
/**
|
|
* The value for how the conference is locked (or undefined if not
|
|
* locked) as defined by room-lock constants.
|
|
*/
|
|
locked: React.PropTypes.string,
|
|
|
|
/**
|
|
* The current known password for the JitsiConference.
|
|
*/
|
|
password: React.PropTypes.string,
|
|
|
|
/**
|
|
* Whether or not the password editing components should be displayed.
|
|
*/
|
|
showPasswordEdit: React.PropTypes.bool,
|
|
|
|
/**
|
|
* Invoked to obtain translated strings.
|
|
*/
|
|
t: React.PropTypes.func
|
|
}
|
|
|
|
/**
|
|
* Initializes a new PasswordContainer instance.
|
|
*
|
|
* @param {Object} props - The read-only properties with which the new
|
|
* instance is to be initialized.
|
|
*/
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
isEditingPassword: false
|
|
};
|
|
|
|
this._onTogglePasswordEdit = this._onTogglePasswordEdit.bind(this);
|
|
}
|
|
|
|
/**
|
|
* Implements React's {@link Component#render()}.
|
|
*
|
|
* @inheritdoc
|
|
* @returns {ReactElement}
|
|
*/
|
|
render() {
|
|
return (
|
|
<div className = 'password-overview'>
|
|
<div className = 'password-overview-status'>
|
|
<LockStatePanel locked = { Boolean(this.props.locked) } />
|
|
{ this._renderShowPasswordLink() }
|
|
</div>
|
|
{ this._renderPasswordEdit() }
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Toggles the display of the ReactElements used to edit the password.
|
|
*
|
|
* @private
|
|
* @returns {void}
|
|
*/
|
|
_onTogglePasswordEdit() {
|
|
this.setState({
|
|
isEditingPassword: !this.state.isEditingPassword
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Creates a ReactElement used for setting or removing a password.
|
|
*
|
|
* @private
|
|
* @returns {ReactElement|null}
|
|
*/
|
|
_renderPasswordEdit() {
|
|
if (!this.state.isEditingPassword) {
|
|
return null;
|
|
}
|
|
|
|
return this.props.locked
|
|
? <RemovePasswordForm
|
|
conference = { this.props.conference }
|
|
lockedLocally = { this.props.locked === LOCKED_LOCALLY }
|
|
password = { this.props.password } />
|
|
: <AddPasswordForm conference = { this.props.conference } />;
|
|
}
|
|
|
|
/**
|
|
* Creates a ReactElement that toggles displaying password edit components.
|
|
*
|
|
* @private
|
|
* @returns {ReactElement|null}
|
|
*/
|
|
_renderShowPasswordLink() {
|
|
if (!this.props.showPasswordEdit) {
|
|
return null;
|
|
}
|
|
|
|
let toggleStatusKey;
|
|
|
|
if (this.state.isEditingPassword) {
|
|
toggleStatusKey = 'invite.hidePassword';
|
|
} else if (this.props.locked) {
|
|
toggleStatusKey = 'invite.showPassword';
|
|
} else {
|
|
toggleStatusKey = 'invite.addPassword';
|
|
}
|
|
|
|
return (
|
|
<a
|
|
className = 'password-overview-toggle-edit'
|
|
onClick = { this._onTogglePasswordEdit }>
|
|
{ this.props.t(toggleStatusKey) }
|
|
</a>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default translate(PasswordContainer);
|