mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Use ChangeDisplayNname / ChangeAvatar widgets to prompt for display name & avatar at signup.
Fixes #7.
This commit is contained in:
parent
ccc5f30c9b
commit
c68ef38399
58
src/controllers/templates/Register.js
Normal file
58
src/controllers/templates/Register.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 OpenMarket Ltd
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var extend = require('matrix-react-sdk/lib/extend');
|
||||||
|
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||||
|
var BaseRegisterController = require('matrix-react-sdk/lib/controllers/templates/Register.js');
|
||||||
|
|
||||||
|
var RegisterController = {};
|
||||||
|
extend(RegisterController, BaseRegisterController);
|
||||||
|
|
||||||
|
RegisterController.onRegistered = function(user_id, access_token) {
|
||||||
|
MatrixClientPeg.replaceUsingAccessToken(
|
||||||
|
this.state.hs_url, this.state.is_url, user_id, access_token
|
||||||
|
);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
step: 'profile',
|
||||||
|
busy: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var cli = MatrixClientPeg.get();
|
||||||
|
cli.getProfileInfo(cli.credentials.userId).done(function(result) {
|
||||||
|
self.setState({
|
||||||
|
avatarUrl: result.avatar_url,
|
||||||
|
busy: false
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function(err) {
|
||||||
|
console.err(err);
|
||||||
|
self.setState({
|
||||||
|
busy: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
RegisterController.onAccountReady = function() {
|
||||||
|
if (this.props.onLoggedIn) {
|
||||||
|
this.props.onLoggedIn();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = RegisterController;
|
@ -51,9 +51,6 @@ module.exports = React.createClass({
|
|||||||
<input type="file" onChange={this.onFileSelected}/>
|
<input type="file" onChange={this.onFileSelected}/>
|
||||||
{this.state.errorText}
|
{this.state.errorText}
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_Dialog_buttons">
|
|
||||||
<button onClick={this.props.onFinished}>Cancel</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case this.Phases.Uploading:
|
case this.Phases.Uploading:
|
||||||
|
@ -30,7 +30,15 @@ module.exports = React.createClass({
|
|||||||
editAvatar: function() {
|
editAvatar: function() {
|
||||||
var url = MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl);
|
var url = MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl);
|
||||||
var ChangeAvatar = sdk.getComponent('molecules.ChangeAvatar');
|
var ChangeAvatar = sdk.getComponent('molecules.ChangeAvatar');
|
||||||
Modal.createDialog(ChangeAvatar, {initialAvatarUrl: url});
|
var avatarDialog = (
|
||||||
|
<div>
|
||||||
|
<ChangeAvatar initialAvatarUrl={url} />
|
||||||
|
<div className="mx_Dialog_buttons">
|
||||||
|
<button onClick={this.onAvatarDialogCancel}>Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
this.avatarDialog = Modal.createDialogWithElement(avatarDialog);
|
||||||
},
|
},
|
||||||
|
|
||||||
addEmail: function() {
|
addEmail: function() {
|
||||||
@ -55,6 +63,10 @@ module.exports = React.createClass({
|
|||||||
this.logoutModal.closeDialog();
|
this.logoutModal.closeDialog();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onAvatarDialogCancel: function() {
|
||||||
|
this.avatarDialog.close();
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
switch (this.state.phase) {
|
switch (this.state.phase) {
|
||||||
case this.Phases.Loading:
|
case this.Phases.Loading:
|
||||||
@ -80,7 +92,7 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
<div className="mx_UserSettings_3pids">
|
<div className="mx_UserSettings_3pids">
|
||||||
{this.state.threepids.map(function(val) {
|
{this.state.threepids.map(function(val) {
|
||||||
return <div>{val.address}</div>;
|
return <div key={val.address}>{val.address}</div>;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -19,10 +19,11 @@ limitations under the License.
|
|||||||
var React = require('react');
|
var React = require('react');
|
||||||
|
|
||||||
var sdk = require('matrix-react-sdk')
|
var sdk = require('matrix-react-sdk')
|
||||||
|
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg')
|
||||||
|
|
||||||
var Loader = require("react-loader");
|
var Loader = require("react-loader");
|
||||||
|
|
||||||
var RegisterController = require('matrix-react-sdk/lib/controllers/templates/Register')
|
var RegisterController = require('../../../../controllers/templates/Register')
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
DEFAULT_HS_URL: 'https://matrix.org',
|
DEFAULT_HS_URL: 'https://matrix.org',
|
||||||
@ -79,6 +80,10 @@ module.exports = React.createClass({
|
|||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onProfileContinueClicked: function() {
|
||||||
|
this.onAccountReady();
|
||||||
|
},
|
||||||
|
|
||||||
componentForStep: function(step) {
|
componentForStep: function(step) {
|
||||||
switch (step) {
|
switch (step) {
|
||||||
case 'initial':
|
case 'initial':
|
||||||
@ -127,6 +132,18 @@ module.exports = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<Loader />
|
<Loader />
|
||||||
);
|
);
|
||||||
|
} else if (this.state.step == 'profile') {
|
||||||
|
var ChangeDisplayName = sdk.getComponent('molecules.ChangeDisplayName');
|
||||||
|
var ChangeAvatar = sdk.getComponent('molecules.ChangeAvatar');
|
||||||
|
return (
|
||||||
|
<div className="mx_Login_profile">
|
||||||
|
Set a display name:
|
||||||
|
<ChangeDisplayName />
|
||||||
|
Upload an avatar:
|
||||||
|
<ChangeAvatar initialAvatarUrl={MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl)} />
|
||||||
|
<button onClick={this.onProfileContinueClicked}>Continue</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user