Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit aeef80f

Browse files
authored
Merge pull request #2268 from jryans/guest-warning
Add visible guest warning to encourage login
2 parents 57ee816 + 975392c commit aeef80f

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

res/css/structures/_HomePage.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ limitations under the License.
3333
.mx_HomePage_body {
3434
// margin-left: 63px;
3535
}
36+
37+
.mx_HomePage_guest_warning {
38+
display: flex;
39+
background-color: $secondary-accent-color;
40+
border: 1px solid $accent-color;
41+
margin: 20px;
42+
padding: 20px 40px;
43+
border-radius: 5px;
44+
}
45+
46+
.mx_HomePage_guest_warning img {
47+
padding-right: 10px;
48+
}

src/components/structures/HomePage.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import request from 'browser-request';
2323
import { _t } from '../../languageHandler';
2424
import sanitizeHtml from 'sanitize-html';
2525
import sdk from '../../index';
26+
import { MatrixClient } from 'matrix-js-sdk';
27+
import dis from '../../dispatcher';
2628

2729
class HomePage extends React.Component {
2830
static displayName = 'HomePage';
@@ -37,6 +39,10 @@ class HomePage extends React.Component {
3739
homePageUrl: PropTypes.string,
3840
};
3941

42+
static contextTypes = {
43+
matrixClient: PropTypes.instanceOf(MatrixClient),
44+
};
45+
4046
state = {
4147
iframeSrc: '',
4248
page: '',
@@ -85,17 +91,55 @@ class HomePage extends React.Component {
8591
this._unmounted = true;
8692
}
8793

94+
onLoginClick() {
95+
dis.dispatch({ action: 'start_login' });
96+
}
97+
98+
onRegisterClick() {
99+
dis.dispatch({ action: 'start_registration' });
100+
}
101+
88102
render() {
103+
let guestWarning = "";
104+
if (this.context.matrixClient.isGuest()) {
105+
guestWarning = (
106+
<div className="mx_HomePage_guest_warning">
107+
<img src="img/warning.svg" width="24" height="23" />
108+
<div>
109+
<div>
110+
{ _t("You are currently using Riot anonymously as a guest.") }
111+
</div>
112+
<div>
113+
{ _t(
114+
'If you would like to create a Matrix account you can <a>register</a> now.',
115+
{},
116+
{ 'a': (sub) => <a href="#" onClick={this.onRegisterClick}>{ sub }</a> },
117+
) }
118+
</div>
119+
<div>
120+
{ _t(
121+
'If you already have a Matrix account you can <a>log in</a> instead.',
122+
{},
123+
{ 'a': (sub) => <a href="#" onClick={this.onLoginClick}>{ sub }</a> },
124+
) }
125+
</div>
126+
</div>
127+
</div>
128+
);
129+
}
130+
89131
if (this.state.iframeSrc) {
90132
return (
91133
<div className="mx_HomePage">
134+
{ guestWarning }
92135
<iframe src={ this.state.iframeSrc } />
93136
</div>
94137
);
95138
} else {
96139
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
97140
return (
98141
<GeminiScrollbarWrapper autoshow={true} className="mx_HomePage">
142+
{ guestWarning }
99143
<div className="mx_HomePage_body" dangerouslySetInnerHTML={{ __html: this.state.page }}>
100144
</div>
101145
</GeminiScrollbarWrapper>

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,9 @@
927927
"Username available": "Username available",
928928
"To get started, please pick a username!": "To get started, please pick a username!",
929929
"This will be your account name on the <span></span> homeserver, or you can pick a <a>different server</a>.": "This will be your account name on the <span></span> homeserver, or you can pick a <a>different server</a>.",
930+
"If you would like to create a Matrix account you can <a>register</a> now.": "If you would like to create a Matrix account you can <a>register</a> now.",
930931
"If you already have a Matrix account you can <a>log in</a> instead.": "If you already have a Matrix account you can <a>log in</a> instead.",
932+
"You are currently using Riot anonymously as a guest.": "You are currently using Riot anonymously as a guest.",
931933
"You have successfully set a password!": "You have successfully set a password!",
932934
"You have successfully set a password and an email address!": "You have successfully set a password and an email address!",
933935
"You can now return to your account after signing out, and sign in on other devices.": "You can now return to your account after signing out, and sign in on other devices.",

src/i18n/strings/en_US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,9 @@
644644
"Username not available": "Username not available",
645645
"Something went wrong!": "Something went wrong!",
646646
"This will be your account name on the <span></span> homeserver, or you can pick a <a>different server</a>.": "This will be your account name on the <span></span> homeserver, or you can pick a <a>different server</a>.",
647+
"If you would like to create a Matrix account you can <a>register</a> now.": "If you would like to create a Matrix account you can <a>register</a> now.",
647648
"If you already have a Matrix account you can <a>log in</a> instead.": "If you already have a Matrix account you can <a>log in</a> instead.",
649+
"You are currently using Riot anonymously as a guest.": "You are currently using Riot anonymously as a guest.",
648650
"Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions",
649651
"Not a valid Riot keyfile": "Not a valid Riot keyfile",
650652
"Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?",

0 commit comments

Comments
 (0)