mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-18 06:35:35 +08:00
PR feedback
This commit is contained in:
parent
893e338917
commit
438558da55
@ -1003,8 +1003,8 @@ module.exports = React.createClass({
|
|||||||
guestAccessToken={this.state.guestAccessToken}
|
guestAccessToken={this.state.guestAccessToken}
|
||||||
defaultHsUrl={this.props.config.default_hs_url}
|
defaultHsUrl={this.props.config.default_hs_url}
|
||||||
defaultIsUrl={this.props.config.default_is_url}
|
defaultIsUrl={this.props.config.default_is_url}
|
||||||
initialHsUrl={this.getCurrentHsUrl()}
|
customHsUrl={this.getCurrentHsUrl()}
|
||||||
initialIsUrl={this.getCurrentIsUrl()}
|
customIsUrl={this.getCurrentIsUrl()}
|
||||||
registrationUrl={this.props.registrationUrl}
|
registrationUrl={this.props.registrationUrl}
|
||||||
onLoggedIn={this.onRegistered}
|
onLoggedIn={this.onRegistered}
|
||||||
onLoginClick={this.onLoginClick}
|
onLoginClick={this.onLoginClick}
|
||||||
@ -1015,8 +1015,8 @@ module.exports = React.createClass({
|
|||||||
<ForgotPassword
|
<ForgotPassword
|
||||||
defaultHsUrl={this.props.config.default_hs_url}
|
defaultHsUrl={this.props.config.default_hs_url}
|
||||||
defaultIsUrl={this.props.config.default_is_url}
|
defaultIsUrl={this.props.config.default_is_url}
|
||||||
initialHsUrl={this.getCurrentHsUrl()}
|
customHsUrl={this.getCurrentHsUrl()}
|
||||||
initialIsUrl={this.getCurrentIsUrl()}
|
customIsUrl={this.getCurrentIsUrl()}
|
||||||
onComplete={this.onLoginClick}
|
onComplete={this.onLoginClick}
|
||||||
onLoginClick={this.onLoginClick} />
|
onLoginClick={this.onLoginClick} />
|
||||||
);
|
);
|
||||||
@ -1027,8 +1027,8 @@ module.exports = React.createClass({
|
|||||||
onRegisterClick={this.onRegisterClick}
|
onRegisterClick={this.onRegisterClick}
|
||||||
defaultHsUrl={this.props.config.default_hs_url}
|
defaultHsUrl={this.props.config.default_hs_url}
|
||||||
defaultIsUrl={this.props.config.default_is_url}
|
defaultIsUrl={this.props.config.default_is_url}
|
||||||
initialHsUrl={this.getCurrentHsUrl()}
|
customHsUrl={this.getCurrentHsUrl()}
|
||||||
initialIsUrl={this.getCurrentIsUrl()}
|
customIsUrl={this.getCurrentIsUrl()}
|
||||||
onForgotPasswordClick={this.onForgotPasswordClick}
|
onForgotPasswordClick={this.onForgotPasswordClick}
|
||||||
onLoginAsGuestClick={this.props.enableGuest && this.props.config && this.props.config.default_hs_url ? this._registerAsGuest: undefined}
|
onLoginAsGuestClick={this.props.enableGuest && this.props.config && this.props.config.default_hs_url ? this._registerAsGuest: undefined}
|
||||||
/>
|
/>
|
||||||
|
@ -29,8 +29,8 @@ module.exports = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
defaultHsUrl: React.PropTypes.string,
|
defaultHsUrl: React.PropTypes.string,
|
||||||
defaultIsUrl: React.PropTypes.string,
|
defaultIsUrl: React.PropTypes.string,
|
||||||
initialHsUrl: React.PropTypes.string,
|
customHsUrl: React.PropTypes.string,
|
||||||
initialIsUrl: React.PropTypes.string,
|
customIsUrl: React.PropTypes.string,
|
||||||
onLoginClick: React.PropTypes.func,
|
onLoginClick: React.PropTypes.func,
|
||||||
onRegisterClick: React.PropTypes.func,
|
onRegisterClick: React.PropTypes.func,
|
||||||
onComplete: React.PropTypes.func.isRequired
|
onComplete: React.PropTypes.func.isRequired
|
||||||
@ -182,8 +182,8 @@ module.exports = React.createClass({
|
|||||||
withToggleButton={true}
|
withToggleButton={true}
|
||||||
defaultHsUrl={this.props.defaultHsUrl}
|
defaultHsUrl={this.props.defaultHsUrl}
|
||||||
defaultIsUrl={this.props.defaultIsUrl}
|
defaultIsUrl={this.props.defaultIsUrl}
|
||||||
initialHsUrl={this.props.initialHsUrl}
|
customHsUrl={this.props.customHsUrl}
|
||||||
initialIsUrl={this.props.initialIsUrl}
|
customIsUrl={this.props.customIsUrl}
|
||||||
onHsUrlChanged={this.onHsUrlChanged}
|
onHsUrlChanged={this.onHsUrlChanged}
|
||||||
onIsUrlChanged={this.onIsUrlChanged}
|
onIsUrlChanged={this.onIsUrlChanged}
|
||||||
delayTimeMs={0}/>
|
delayTimeMs={0}/>
|
||||||
|
@ -31,8 +31,8 @@ module.exports = React.createClass({displayName: 'Login',
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
onLoggedIn: React.PropTypes.func.isRequired,
|
onLoggedIn: React.PropTypes.func.isRequired,
|
||||||
|
|
||||||
initialHsUrl: React.PropTypes.string,
|
customHsUrl: React.PropTypes.string,
|
||||||
initialIsUrl: React.PropTypes.string,
|
customIsUrl: React.PropTypes.string,
|
||||||
defaultHsUrl: React.PropTypes.string,
|
defaultHsUrl: React.PropTypes.string,
|
||||||
defaultIsUrl: React.PropTypes.string,
|
defaultIsUrl: React.PropTypes.string,
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ module.exports = React.createClass({displayName: 'Login',
|
|||||||
return {
|
return {
|
||||||
busy: false,
|
busy: false,
|
||||||
errorText: null,
|
errorText: null,
|
||||||
enteredHomeserverUrl: this.props.initialHsUrl || this.props.defaultHsUrl,
|
enteredHomeserverUrl: this.props.customHsUrl || this.props.defaultHsUrl,
|
||||||
enteredIdentityServerUrl: this.props.initialIsUrl || this.props.defaultIsUrl,
|
enteredIdentityServerUrl: this.props.customIsUrl || this.props.defaultIsUrl,
|
||||||
|
|
||||||
// used for preserving username when changing homeserver
|
// used for preserving username when changing homeserver
|
||||||
username: "",
|
username: "",
|
||||||
@ -220,8 +220,8 @@ module.exports = React.createClass({displayName: 'Login',
|
|||||||
{ this.componentForStep(this._getCurrentFlowStep()) }
|
{ this.componentForStep(this._getCurrentFlowStep()) }
|
||||||
<ServerConfig ref="serverConfig"
|
<ServerConfig ref="serverConfig"
|
||||||
withToggleButton={true}
|
withToggleButton={true}
|
||||||
initialHsUrl={this.props.initialHsUrl}
|
customHsUrl={this.props.customHsUrl}
|
||||||
initialIsUrl={this.props.initialIsUrl}
|
customIsUrl={this.props.customIsUrl}
|
||||||
defaultHsUrl={this.props.defaultHsUrl}
|
defaultHsUrl={this.props.defaultHsUrl}
|
||||||
defaultIsUrl={this.props.defaultIsUrl}
|
defaultIsUrl={this.props.defaultIsUrl}
|
||||||
onHsUrlChanged={this.onHsUrlChanged}
|
onHsUrlChanged={this.onHsUrlChanged}
|
||||||
|
@ -36,8 +36,8 @@ module.exports = React.createClass({
|
|||||||
sessionId: React.PropTypes.string,
|
sessionId: React.PropTypes.string,
|
||||||
registrationUrl: React.PropTypes.string,
|
registrationUrl: React.PropTypes.string,
|
||||||
idSid: React.PropTypes.string,
|
idSid: React.PropTypes.string,
|
||||||
initialHsUrl: React.PropTypes.string,
|
customHsUrl: React.PropTypes.string,
|
||||||
initialIsUrl: React.PropTypes.string,
|
customIsUrl: React.PropTypes.string,
|
||||||
defaultHsUrl: React.PropTypes.string,
|
defaultHsUrl: React.PropTypes.string,
|
||||||
defaultIsUrl: React.PropTypes.string,
|
defaultIsUrl: React.PropTypes.string,
|
||||||
email: React.PropTypes.string,
|
email: React.PropTypes.string,
|
||||||
@ -59,7 +59,7 @@ module.exports = React.createClass({
|
|||||||
this.dispatcherRef = dis.register(this.onAction);
|
this.dispatcherRef = dis.register(this.onAction);
|
||||||
// attach this to the instance rather than this.state since it isn't UI
|
// attach this to the instance rather than this.state since it isn't UI
|
||||||
this.registerLogic = new Signup.Register(
|
this.registerLogic = new Signup.Register(
|
||||||
this.props.initialHsUrl, this.props.initialIsUrl
|
this.props.customHsUrl, this.props.customIsUrl
|
||||||
);
|
);
|
||||||
this.registerLogic.setClientSecret(this.props.clientSecret);
|
this.registerLogic.setClientSecret(this.props.clientSecret);
|
||||||
this.registerLogic.setSessionId(this.props.sessionId);
|
this.registerLogic.setSessionId(this.props.sessionId);
|
||||||
@ -242,8 +242,8 @@ module.exports = React.createClass({
|
|||||||
{busySpinner}
|
{busySpinner}
|
||||||
<ServerConfig ref="serverConfig"
|
<ServerConfig ref="serverConfig"
|
||||||
withToggleButton={true}
|
withToggleButton={true}
|
||||||
initialHsUrl={this.props.initialHsUrl}
|
customHsUrl={this.props.customHsUrl}
|
||||||
initialIsUrl={this.props.initialIsUrl}
|
customIsUrl={this.props.customIsUrl}
|
||||||
defaultHsUrl={this.props.defaultHsUrl}
|
defaultHsUrl={this.props.defaultHsUrl}
|
||||||
defaultIsUrl={this.props.defaultIsUrl}
|
defaultIsUrl={this.props.defaultIsUrl}
|
||||||
onHsUrlChanged={this.onHsUrlChanged}
|
onHsUrlChanged={this.onHsUrlChanged}
|
||||||
|
@ -29,10 +29,21 @@ module.exports = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
onHsUrlChanged: React.PropTypes.func,
|
onHsUrlChanged: React.PropTypes.func,
|
||||||
onIsUrlChanged: React.PropTypes.func,
|
onIsUrlChanged: React.PropTypes.func,
|
||||||
initialHsUrl: React.PropTypes.string, // whatever the current value is when we create the component
|
|
||||||
initialIsUrl: React.PropTypes.string, // whatever the current value is when we create the component
|
// default URLs are defined in config.json (or the hardcoded defaults)
|
||||||
|
// they are used if the user has not overridden them with a custom URL.
|
||||||
|
// In other words, if the custom URL is blank, the default is used.
|
||||||
defaultHsUrl: React.PropTypes.string, // e.g. https://matrix.org
|
defaultHsUrl: React.PropTypes.string, // e.g. https://matrix.org
|
||||||
defaultIsUrl: React.PropTypes.string, // e.g. https://vector.im
|
defaultIsUrl: React.PropTypes.string, // e.g. https://vector.im
|
||||||
|
|
||||||
|
// custom URLs are explicitly provided by the user and override the
|
||||||
|
// default URLs. The user enters them via the component's input fields,
|
||||||
|
// which is reflected on these properties whenever on..UrlChanged fires.
|
||||||
|
// They are persisted in localStorage by MatrixClientPeg, and so can
|
||||||
|
// override the default URLs when the component initially loads.
|
||||||
|
customHsUrl: React.PropTypes.string,
|
||||||
|
customIsUrl: React.PropTypes.string,
|
||||||
|
|
||||||
withToggleButton: React.PropTypes.bool,
|
withToggleButton: React.PropTypes.bool,
|
||||||
delayTimeMs: React.PropTypes.number // time to wait before invoking onChanged
|
delayTimeMs: React.PropTypes.number // time to wait before invoking onChanged
|
||||||
},
|
},
|
||||||
@ -48,12 +59,12 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
hs_url: this.props.initialHsUrl,
|
hs_url: this.props.customHsUrl,
|
||||||
is_url: this.props.initialIsUrl,
|
is_url: this.props.customIsUrl,
|
||||||
// if withToggleButton is false, then show the config all the time given we have no way otherwise of making it visible
|
// if withToggleButton is false, then show the config all the time given we have no way otherwise of making it visible
|
||||||
configVisible: !this.props.withToggleButton ||
|
configVisible: !this.props.withToggleButton ||
|
||||||
(this.props.initialHsUrl !== this.props.defaultHsUrl) ||
|
(this.props.customHsUrl !== this.props.defaultHsUrl) ||
|
||||||
(this.props.initialIsUrl !== this.props.defaultIsUrl)
|
(this.props.customIsUrl !== this.props.defaultIsUrl)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -84,11 +95,11 @@ module.exports = React.createClass({
|
|||||||
return setTimeout(fn.bind(this), this.props.delayTimeMs);
|
return setTimeout(fn.bind(this), this.props.delayTimeMs);
|
||||||
},
|
},
|
||||||
|
|
||||||
onServerConfigVisibleChange: function(ev) {
|
onServerConfigVisibleChange: function(visible, ev) {
|
||||||
this.setState({
|
this.setState({
|
||||||
configVisible: ev.target.checked
|
configVisible: visible
|
||||||
});
|
});
|
||||||
if (!ev.target.checked) {
|
if (!visible) {
|
||||||
this.props.onHsUrlChanged(this.props.defaultHsUrl);
|
this.props.onHsUrlChanged(this.props.defaultHsUrl);
|
||||||
this.props.onIsUrlChanged(this.props.defaultIsUrl);
|
this.props.onIsUrlChanged(this.props.defaultIsUrl);
|
||||||
}
|
}
|
||||||
@ -110,12 +121,19 @@ module.exports = React.createClass({
|
|||||||
var toggleButton;
|
var toggleButton;
|
||||||
if (this.props.withToggleButton) {
|
if (this.props.withToggleButton) {
|
||||||
toggleButton = (
|
toggleButton = (
|
||||||
<div>
|
<div style={{ textAlign: 'center' }}>
|
||||||
<input className="mx_Login_checkbox" id="advanced" type="checkbox"
|
<input className="mx_Login_radio" id="basic" name="configVisible" type="radio"
|
||||||
|
checked={!this.state.configVisible}
|
||||||
|
onChange={this.onServerConfigVisibleChange.bind(this, false)} />
|
||||||
|
<label className="mx_Login_label" htmlFor="basic">
|
||||||
|
Default server
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input className="mx_Login_radio" id="advanced" name="configVisible" type="radio"
|
||||||
checked={this.state.configVisible}
|
checked={this.state.configVisible}
|
||||||
onChange={this.onServerConfigVisibleChange} />
|
onChange={this.onServerConfigVisibleChange.bind(this, true)} />
|
||||||
<label className="mx_Login_label" htmlFor="advanced">
|
<label className="mx_Login_label" htmlFor="advanced">
|
||||||
Use custom server options (advanced)
|
Custom server
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user