Merge pull request #2268 from jryans/guest-warning
Add visible guest warning to encourage login
This commit is contained in:
commit
aeef80fb1c
4 changed files with 61 additions and 0 deletions
|
@ -33,3 +33,16 @@ limitations under the License.
|
||||||
.mx_HomePage_body {
|
.mx_HomePage_body {
|
||||||
// margin-left: 63px;
|
// margin-left: 63px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_HomePage_guest_warning {
|
||||||
|
display: flex;
|
||||||
|
background-color: $secondary-accent-color;
|
||||||
|
border: 1px solid $accent-color;
|
||||||
|
margin: 20px;
|
||||||
|
padding: 20px 40px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_HomePage_guest_warning img {
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import request from 'browser-request';
|
||||||
import { _t } from '../../languageHandler';
|
import { _t } from '../../languageHandler';
|
||||||
import sanitizeHtml from 'sanitize-html';
|
import sanitizeHtml from 'sanitize-html';
|
||||||
import sdk from '../../index';
|
import sdk from '../../index';
|
||||||
|
import { MatrixClient } from 'matrix-js-sdk';
|
||||||
|
import dis from '../../dispatcher';
|
||||||
|
|
||||||
class HomePage extends React.Component {
|
class HomePage extends React.Component {
|
||||||
static displayName = 'HomePage';
|
static displayName = 'HomePage';
|
||||||
|
@ -37,6 +39,10 @@ class HomePage extends React.Component {
|
||||||
homePageUrl: PropTypes.string,
|
homePageUrl: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
matrixClient: PropTypes.instanceOf(MatrixClient),
|
||||||
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
iframeSrc: '',
|
iframeSrc: '',
|
||||||
page: '',
|
page: '',
|
||||||
|
@ -85,10 +91,47 @@ class HomePage extends React.Component {
|
||||||
this._unmounted = true;
|
this._unmounted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLoginClick() {
|
||||||
|
dis.dispatch({ action: 'start_login' });
|
||||||
|
}
|
||||||
|
|
||||||
|
onRegisterClick() {
|
||||||
|
dis.dispatch({ action: 'start_registration' });
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let guestWarning = "";
|
||||||
|
if (this.context.matrixClient.isGuest()) {
|
||||||
|
guestWarning = (
|
||||||
|
<div className="mx_HomePage_guest_warning">
|
||||||
|
<img src="img/warning.svg" width="24" height="23" />
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
{ _t("You are currently using Riot anonymously as a guest.") }
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{ _t(
|
||||||
|
'If you would like to create a Matrix account you can <a>register</a> now.',
|
||||||
|
{},
|
||||||
|
{ 'a': (sub) => <a href="#" onClick={this.onRegisterClick}>{ sub }</a> },
|
||||||
|
) }
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{ _t(
|
||||||
|
'If you already have a Matrix account you can <a>log in</a> instead.',
|
||||||
|
{},
|
||||||
|
{ 'a': (sub) => <a href="#" onClick={this.onLoginClick}>{ sub }</a> },
|
||||||
|
) }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.state.iframeSrc) {
|
if (this.state.iframeSrc) {
|
||||||
return (
|
return (
|
||||||
<div className="mx_HomePage">
|
<div className="mx_HomePage">
|
||||||
|
{ guestWarning }
|
||||||
<iframe src={ this.state.iframeSrc } />
|
<iframe src={ this.state.iframeSrc } />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -96,6 +139,7 @@ class HomePage extends React.Component {
|
||||||
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
|
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
|
||||||
return (
|
return (
|
||||||
<GeminiScrollbarWrapper autoshow={true} className="mx_HomePage">
|
<GeminiScrollbarWrapper autoshow={true} className="mx_HomePage">
|
||||||
|
{ guestWarning }
|
||||||
<div className="mx_HomePage_body" dangerouslySetInnerHTML={{ __html: this.state.page }}>
|
<div className="mx_HomePage_body" dangerouslySetInnerHTML={{ __html: this.state.page }}>
|
||||||
</div>
|
</div>
|
||||||
</GeminiScrollbarWrapper>
|
</GeminiScrollbarWrapper>
|
||||||
|
|
|
@ -927,7 +927,9 @@
|
||||||
"Username available": "Username available",
|
"Username available": "Username available",
|
||||||
"To get started, please pick a username!": "To get started, please pick a username!",
|
"To get started, please pick a username!": "To get started, please pick a username!",
|
||||||
"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>.",
|
"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>.",
|
||||||
|
"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.",
|
||||||
"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.",
|
"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.",
|
||||||
|
"You are currently using Riot anonymously as a guest.": "You are currently using Riot anonymously as a guest.",
|
||||||
"You have successfully set a password!": "You have successfully set a password!",
|
"You have successfully set a password!": "You have successfully set a password!",
|
||||||
"You have successfully set a password and an email address!": "You have successfully set a password and an email address!",
|
"You have successfully set a password and an email address!": "You have successfully set a password and an email address!",
|
||||||
"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.",
|
"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.",
|
||||||
|
|
|
@ -644,7 +644,9 @@
|
||||||
"Username not available": "Username not available",
|
"Username not available": "Username not available",
|
||||||
"Something went wrong!": "Something went wrong!",
|
"Something went wrong!": "Something went wrong!",
|
||||||
"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>.",
|
"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>.",
|
||||||
|
"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.",
|
||||||
"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.",
|
"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.",
|
||||||
|
"You are currently using Riot anonymously as a guest.": "You are currently using Riot anonymously as a guest.",
|
||||||
"Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions",
|
"Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions",
|
||||||
"Not a valid Riot keyfile": "Not a valid Riot keyfile",
|
"Not a valid Riot keyfile": "Not a valid Riot keyfile",
|
||||||
"Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?",
|
"Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?",
|
||||||
|
|
Loading…
Reference in a new issue