mirror of https://github.com/vector-im/riot-web
Remove ServerConfig; Add Signup logic class
- ServerConfig seems too specific to Vector, but we can always add it back later. - Signup.js contains all the logic for determining what to show which was previously in UI components.pull/21833/head
parent
a082a24f9a
commit
f4dd88ed64
|
@ -0,0 +1,49 @@
|
|||
"use strict";
|
||||
var MatrixClientPeg = require("./MatrixClientPeg");
|
||||
var dis = require("./dispatcher");
|
||||
|
||||
class Register {
|
||||
|
||||
}
|
||||
|
||||
class Login {
|
||||
constructor(hsUrl, isUrl) {
|
||||
this._hsUrl = hsUrl;
|
||||
this._isUrl = isUrl;
|
||||
this._currentFlowIndex = 0;
|
||||
this._flows = [];
|
||||
}
|
||||
|
||||
getFlows() {
|
||||
var self = this;
|
||||
// feels a bit wrong to be clobbering the global client for something we
|
||||
// don't even know if it'll work, but we'll leave this here for now to
|
||||
// not complicate matters further. It would be nicer to isolate this
|
||||
// logic entirely from the rest of the app though.
|
||||
MatrixClientPeg.replaceUsingUrls(
|
||||
this._hsUrl,
|
||||
this._isUrl
|
||||
);
|
||||
return MatrixClientPeg.get().loginFlows().then(function(result) {
|
||||
self._flows = result.flows;
|
||||
self._currentFlowIndex = 0;
|
||||
// technically the UI should display options for all flows for the
|
||||
// user to then choose one, so return all the flows here.
|
||||
return self._flows;
|
||||
});
|
||||
}
|
||||
|
||||
chooseFlow(flowIndex) {
|
||||
this._currentFlowIndex = flowIndex;
|
||||
}
|
||||
|
||||
getCurrentFlowStep() {
|
||||
// technically the flow can have multiple steps, but no one does this
|
||||
// for login so we can ignore it.
|
||||
var flowStep = this._flows[this._currentFlowIndex];
|
||||
return flowStep ? flowStep.type : null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.Register = Register;
|
||||
module.exports.Login = Login;
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
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 React = require("react");
|
||||
|
||||
module.exports = {
|
||||
propTypes: {
|
||||
onHsUrlChanged: React.PropTypes.func,
|
||||
onIsUrlChanged: React.PropTypes.func,
|
||||
defaultHsUrl: React.PropTypes.string,
|
||||
defaultIsUrl: React.PropTypes.string
|
||||
},
|
||||
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
onHsUrlChanged: function() {},
|
||||
onIsUrlChanged: function() {},
|
||||
defaultHsUrl: 'https://matrix.org/',
|
||||
defaultIsUrl: 'https://matrix.org/'
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
hs_url: this.props.defaultHsUrl,
|
||||
is_url: this.props.defaultIsUrl,
|
||||
original_hs_url: this.props.defaultHsUrl,
|
||||
original_is_url: this.props.defaultIsUrl,
|
||||
}
|
||||
},
|
||||
|
||||
hsChanged: function(ev) {
|
||||
this.setState({hs_url: ev.target.value}, function() {
|
||||
this.props.onHsUrlChanged(this.state.hs_url);
|
||||
});
|
||||
},
|
||||
|
||||
// XXX: horrible naming due to potential confusion between the word 'is' and the acronym 'IS'
|
||||
isChanged: function(ev) {
|
||||
this.setState({is_url: ev.target.value}, function() {
|
||||
this.props.onIsUrlChanged(this.state.is_url);
|
||||
});
|
||||
},
|
||||
|
||||
getHsUrl: function() {
|
||||
return this.state.hs_url;
|
||||
},
|
||||
|
||||
getIsUrl: function() {
|
||||
return this.state.is_url;
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue