fix untested stuff with iframe homepages
This commit is contained in:
parent
4805bcf364
commit
623f995934
1 changed files with 22 additions and 23 deletions
|
@ -38,15 +38,18 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
page: ""
|
iframeSrc: '',
|
||||||
|
page: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
if (this.props.teamToken && this.props.teamServerUrl) {
|
if (this.props.teamToken && this.props.teamServerUrl) {
|
||||||
return;
|
this.setState({
|
||||||
|
iframeSrc: `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// we use request() to inline the homepage into the react component
|
// we use request() to inline the homepage into the react component
|
||||||
// so that it can inherit CSS and theming easily rather than mess around
|
// so that it can inherit CSS and theming easily rather than mess around
|
||||||
// with iframes and trying to synchronise document.stylesheets.
|
// with iframes and trying to synchronise document.stylesheets.
|
||||||
|
@ -61,21 +64,17 @@ module.exports = React.createClass({
|
||||||
this.setState({ page: "Couldn't load home page" });
|
this.setState({ page: "Couldn't load home page" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// We parse the JSON ourselves rather than use the JSON
|
|
||||||
// parameter, since this throws a parse error on empty
|
|
||||||
// which breaks if there's no config.json and we're
|
|
||||||
// loading from the filesystem (see above).
|
|
||||||
this.setState({ page: body });
|
this.setState({ page: body });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
if (this.props.teamToken && this.props.teamServerUrl) {
|
if (this.state.iframeSrc) {
|
||||||
src = `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`;
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_HomePage">
|
<div className="mx_HomePage">
|
||||||
<iframe src={ src } />
|
<iframe src={ this.state.iframeSrc } />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue