Generalize HomePage into EmbeddedPage
This commit is contained in:
parent
2fde67787c
commit
73de56d72d
3 changed files with 16 additions and 19 deletions
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2016 OpenMarket Ltd
|
Copyright 2016 OpenMarket Ltd
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
Copyright 2019 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -22,10 +23,3 @@ limitations under the License.
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_HomePage iframe {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
border: 0px;
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,10 +27,12 @@ import sdk from '../../index';
|
||||||
import { MatrixClient } from 'matrix-js-sdk';
|
import { MatrixClient } from 'matrix-js-sdk';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
export default class HomePage extends React.PureComponent {
|
export default class EmbeddedPage extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
// URL to use as the iFrame src. Defaults to /home.html.
|
// URL to request embedded page content from
|
||||||
homePageUrl: PropTypes.string,
|
url: PropTypes.string,
|
||||||
|
// Class name prefix to apply for a given instance
|
||||||
|
className: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
|
@ -57,10 +59,8 @@ export default class HomePage extends React.PureComponent {
|
||||||
// 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.
|
||||||
|
|
||||||
const src = this.props.homePageUrl || 'home.html';
|
|
||||||
|
|
||||||
request(
|
request(
|
||||||
{ method: "GET", url: src },
|
{ method: "GET", url: this.props.url },
|
||||||
(err, response, body) => {
|
(err, response, body) => {
|
||||||
if (this._unmounted) {
|
if (this._unmounted) {
|
||||||
return;
|
return;
|
||||||
|
@ -84,14 +84,17 @@ export default class HomePage extends React.PureComponent {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const isGuest = this.context.matrixClient.isGuest();
|
const isGuest = this.context.matrixClient.isGuest();
|
||||||
|
const className = this.props.className;
|
||||||
const classes = classnames({
|
const classes = classnames({
|
||||||
mx_HomePage: true,
|
[className]: true,
|
||||||
mx_HomePage_guest: isGuest,
|
[`${className}_guest`]: isGuest,
|
||||||
});
|
});
|
||||||
|
|
||||||
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
|
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
|
||||||
return <GeminiScrollbarWrapper autoshow={true} className={classes}>
|
return <GeminiScrollbarWrapper autoshow={true} className={classes}>
|
||||||
<div className="mx_HomePage_body" dangerouslySetInnerHTML={{ __html: this.state.page }}>
|
<div className={`${className}_body`}
|
||||||
|
dangerouslySetInnerHTML={{ __html: this.state.page }}
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</GeminiScrollbarWrapper>;
|
</GeminiScrollbarWrapper>;
|
||||||
}
|
}
|
|
@ -420,7 +420,7 @@ const LoggedInView = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
const LeftPanel = sdk.getComponent('structures.LeftPanel');
|
const LeftPanel = sdk.getComponent('structures.LeftPanel');
|
||||||
const RoomView = sdk.getComponent('structures.RoomView');
|
const RoomView = sdk.getComponent('structures.RoomView');
|
||||||
const HomePage = sdk.getComponent('structures.HomePage');
|
const EmbeddedPage = sdk.getComponent('structures.EmbeddedPage');
|
||||||
const GroupView = sdk.getComponent('structures.GroupView');
|
const GroupView = sdk.getComponent('structures.GroupView');
|
||||||
const MyGroups = sdk.getComponent('structures.MyGroups');
|
const MyGroups = sdk.getComponent('structures.MyGroups');
|
||||||
const MatrixToolbar = sdk.getComponent('globals.MatrixToolbar');
|
const MatrixToolbar = sdk.getComponent('globals.MatrixToolbar');
|
||||||
|
@ -459,8 +459,8 @@ const LoggedInView = React.createClass({
|
||||||
|
|
||||||
case PageTypes.HomePage:
|
case PageTypes.HomePage:
|
||||||
{
|
{
|
||||||
pageElement = <HomePage
|
pageElement = <EmbeddedPage className="mx_HomePage"
|
||||||
homePageUrl={this.props.config.welcomePageUrl}
|
url={this.props.config.welcomePageUrl || 'home.html'}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue