Skip to content

Commit efb6316

Browse files
author
Luke Barnard
committed
Implement default welcome page and allow custom URL /w config
counterpart to matrix-org/matrix-react-sdk#922
1 parent 299dc7f commit efb6316

6 files changed

Lines changed: 29 additions & 19 deletions

File tree

‎config.sample.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
"matrix.org"
1212
]
1313
},
14-
"welcomeUserId": "@RiotBot:matrix.org"
14+
"welcomeUserId": "@RiotBot:matrix.org",
15+
"welcomePageUrl": "https://about.riot.im"
1516
}

‎res/home.html‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Riot - Home</title>
5+
</head>
6+
<body>
7+
<div>Welcome to Riot</div>
8+
</body>
9+
</html>

‎scripts/copy-res.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// "dest/b/...".
99
const COPY_LIST = [
1010
["res/manifest.json", "webapp"],
11+
["res/home.html", "webapp"],
1112
["res/{media,vector-icons}/**", "webapp"],
1213
["res/flags/*", "webapp/flags/"],
1314
["src/skins/vector/{fonts,img}/**", "webapp"],

‎src/components/structures/BottomLeftMenu.js‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ module.exports = React.createClass({
2727

2828
propTypes: {
2929
collapsed: React.PropTypes.bool.isRequired,
30-
teamToken: React.PropTypes.string,
3130
},
3231

3332
getInitialState: function() {
@@ -114,21 +113,13 @@ module.exports = React.createClass({
114113

115114
render: function() {
116115
var TintableSvg = sdk.getComponent('elements.TintableSvg');
117-
118-
var homeButton;
119-
if (this.props.teamToken) {
120-
homeButton = (
121-
<AccessibleButton className="mx_BottomLeftMenu_homePage" onClick={ this.onHomeClick } onMouseEnter={ this.onHomeMouseEnter } onMouseLeave={ this.onHomeMouseLeave } >
122-
<TintableSvg src="img/icons-home.svg" width="25" height="25" />
123-
{ this.getLabel("Welcome page", this.state.homeHover) }
124-
</AccessibleButton>
125-
);
126-
}
127-
128116
return (
129117
<div className="mx_BottomLeftMenu">
130118
<div className="mx_BottomLeftMenu_options">
131-
{ homeButton }
119+
<AccessibleButton className="mx_BottomLeftMenu_homePage" onClick={ this.onHomeClick } onMouseEnter={ this.onHomeMouseEnter } onMouseLeave={ this.onHomeMouseLeave } >
120+
<TintableSvg src="img/icons-home.svg" width="25" height="25" />
121+
{ this.getLabel("Welcome page", this.state.homeHover) }
122+
</AccessibleButton>
132123
<AccessibleButton className="mx_BottomLeftMenu_people" onClick={ this.onPeopleClick } onMouseEnter={ this.onPeopleMouseEnter } onMouseLeave={ this.onPeopleMouseLeave } >
133124
<TintableSvg src="img/icons-people.svg" width="25" height="25" />
134125
{ this.getLabel("Start chat", this.state.peopleHover) }

‎src/components/structures/HomePage.js‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,24 @@ module.exports = React.createClass({
2525
displayName: 'HomePage',
2626

2727
propTypes: {
28+
// URL base of the team server.
2829
teamServerUrl: React.PropTypes.string.isRequired,
29-
teamToken: React.PropTypes.string.isRequired,
30-
collapsedRhs: React.PropTypes.bool,
30+
// Team token. Optional. If unset, the homePageUrl will be used
31+
teamToken: React.PropTypes.string,
32+
// URL to use as the iFrame src. Defaults to /home.html.
33+
homePageUrl: React.PropTypes.string,
3134
},
3235

3336
render: function() {
37+
let src = this.props.homePageUrl || '/home.html';
38+
39+
if (this.props.teamToken) {
40+
src = `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`;
41+
}
42+
3443
return (
3544
<div className="mx_HomePage">
36-
<iframe src={`${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`}/>
45+
<iframe src={src}/>
3746
</div>
3847
);
3948
}

‎src/components/structures/LeftPanel.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ var LeftPanel = React.createClass({
3030

3131
propTypes: {
3232
collapsed: React.PropTypes.bool.isRequired,
33-
teamToken: React.PropTypes.string,
3433
},
3534

3635
getInitialState: function() {
@@ -129,7 +128,7 @@ var LeftPanel = React.createClass({
129128
collapsed={this.props.collapsed}
130129
searchFilter={this.state.searchFilter}
131130
ConferenceHandler={VectorConferenceHandler} />
132-
<BottomLeftMenu collapsed={this.props.collapsed} teamToken={this.props.teamToken}/>
131+
<BottomLeftMenu collapsed={this.props.collapsed}/>
133132
</aside>
134133
);
135134
}

0 commit comments

Comments
 (0)