mirror of https://github.com/vector-im/riot-web
Add referral section to user settings (#661)
This allows those who have registered to referrer other students to Riot and have their referral counted for the campaign competition. Also allows the base referral URL to be configurable (i.e. for Electron app, etc.) and be default this is `window.location.origin`.pull/21833/head
commit
be869a8ac6
|
@ -171,6 +171,7 @@ export default React.createClass({
|
||||||
brand={this.props.config.brand}
|
brand={this.props.config.brand}
|
||||||
collapsedRhs={this.props.collapse_rhs}
|
collapsedRhs={this.props.collapse_rhs}
|
||||||
enableLabs={this.props.config.enableLabs}
|
enableLabs={this.props.config.enableLabs}
|
||||||
|
referralBaseUrl={this.props.config.referralBaseUrl}
|
||||||
/>;
|
/>;
|
||||||
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>;
|
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -92,6 +92,9 @@ module.exports = React.createClass({
|
||||||
// True to show the 'labs' section of experimental features
|
// True to show the 'labs' section of experimental features
|
||||||
enableLabs: React.PropTypes.bool,
|
enableLabs: React.PropTypes.bool,
|
||||||
|
|
||||||
|
// The base URL to use in the referral link. Defaults to window.location.origin.
|
||||||
|
referralBaseUrl: React.PropTypes.string,
|
||||||
|
|
||||||
// true if RightPanel is collapsed
|
// true if RightPanel is collapsed
|
||||||
collapsedRhs: React.PropTypes.bool,
|
collapsedRhs: React.PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
@ -444,6 +447,27 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_renderReferral: function() {
|
||||||
|
const teamToken = window.localStorage.getItem('mx_team_token');
|
||||||
|
if (!teamToken) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (typeof teamToken !== 'string') {
|
||||||
|
console.warn('Team token not a string');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const href = (this.props.referralBaseUrl || window.location.origin) +
|
||||||
|
`/#/register?referrer=${this._me}&team_token=${teamToken}`;
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h3>Referral</h3>
|
||||||
|
<div className="mx_UserSettings_section">
|
||||||
|
Refer a friend to Riot: <a href={href}>{href}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
_renderUserInterfaceSettings: function() {
|
_renderUserInterfaceSettings: function() {
|
||||||
var client = MatrixClientPeg.get();
|
var client = MatrixClientPeg.get();
|
||||||
|
|
||||||
|
@ -819,6 +843,8 @@ module.exports = React.createClass({
|
||||||
{accountJsx}
|
{accountJsx}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{this._renderReferral()}
|
||||||
|
|
||||||
{notification_area}
|
{notification_area}
|
||||||
|
|
||||||
{this._renderUserInterfaceSettings()}
|
{this._renderUserInterfaceSettings()}
|
||||||
|
|
|
@ -57,7 +57,7 @@ module.exports = React.createClass({
|
||||||
// URL of the riot-team-server to get team configurations and track referrals
|
// URL of the riot-team-server to get team configurations and track referrals
|
||||||
teamServerURL: React.PropTypes.string.isRequired,
|
teamServerURL: React.PropTypes.string.isRequired,
|
||||||
}),
|
}),
|
||||||
teamSelected: null,
|
teamSelected: React.PropTypes.object,
|
||||||
|
|
||||||
defaultDeviceDisplayName: React.PropTypes.string,
|
defaultDeviceDisplayName: React.PropTypes.string,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue