Moved most of the sidebar into a CommonLinks panel
This commit is contained in:
+3
-1
@@ -10,7 +10,9 @@ let excluded = [ //messages that should not be logged
|
|||||||
'Not enough soldiers',
|
'Not enough soldiers',
|
||||||
'Not enough spies',
|
'Not enough spies',
|
||||||
'Not enough scientists',
|
'Not enough scientists',
|
||||||
'Not enough time has passed'
|
'Not enough time has passed',
|
||||||
|
|
||||||
|
'Profile sent'
|
||||||
];
|
];
|
||||||
|
|
||||||
const log = (msg, ...args) => {
|
const log = (msg, ...args) => {
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ function profileRequestInner(connection, req, res, fields) {
|
|||||||
scientists: results[0].scientists
|
scientists: results[0].scientists
|
||||||
});
|
});
|
||||||
res.end();
|
res.end();
|
||||||
// log('Profile sent', fields.username, fields.id, fields.token);
|
log('Profile sent', fields.username, fields.id, fields.token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ import { withRouter, Link } from 'react-router-dom';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
//panels
|
//panels
|
||||||
|
import CommonLinks from '../panels/common_links.jsx';
|
||||||
|
|
||||||
import Signup from '../panels/signup.jsx';
|
import Signup from '../panels/signup.jsx';
|
||||||
import Login from '../panels/login.jsx';
|
import Login from '../panels/login.jsx';
|
||||||
import Logout from '../panels/logout.jsx';
|
|
||||||
import PasswordChange from '../panels/password_change.jsx';
|
|
||||||
import PasswordRecover from '../panels/password_recover.jsx';
|
import PasswordRecover from '../panels/password_recover.jsx';
|
||||||
|
|
||||||
import NewsPanel from '../panels/news_panel.jsx';
|
import NewsPanel from '../panels/news_panel.jsx';
|
||||||
|
|
||||||
class Home extends React.Component {
|
class Home extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
changedPassword: false,
|
|
||||||
signupSent: false,
|
signupSent: false,
|
||||||
signupMsg: '',
|
signupMsg: '',
|
||||||
recoverSent: false,
|
recoverSent: false,
|
||||||
@@ -34,14 +34,14 @@ class Home extends React.Component {
|
|||||||
SidePanel = this.LoggedOutSidePanel.bind(this);
|
SidePanel = this.LoggedOutSidePanel.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: news column
|
|
||||||
|
|
||||||
//return the home page
|
//return the home page
|
||||||
return (
|
return (
|
||||||
<div className='page'>
|
<div className='page'>
|
||||||
<h1 style={{textAlign: 'center', fontSize: '50px', margin: '30px'}}>KINGDOM BATTLES!</h1>
|
<h1 style={{textAlign: 'center', fontSize: '50px', margin: '30px'}}>KINGDOM BATTLES!</h1>
|
||||||
|
|
||||||
<div className='sidePanelPage'>
|
<div className='sidePanelPage'>
|
||||||
<SidePanel />
|
<SidePanel />
|
||||||
|
|
||||||
<div className='mainPanel'>
|
<div className='mainPanel'>
|
||||||
<h1 className='centered'>News</h1>
|
<h1 className='centered'>News</h1>
|
||||||
<NewsPanel />
|
<NewsPanel />
|
||||||
@@ -62,35 +62,15 @@ class Home extends React.Component {
|
|||||||
this.setState({ recoverSent: false });
|
this.setState({ recoverSent: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
//build the password change panel
|
|
||||||
let PasswordChangePanel;
|
|
||||||
|
|
||||||
if (!this.state.changedPassword) {
|
|
||||||
PasswordChangePanel = () => {
|
|
||||||
return (<PasswordChange onPasswordChange={() => { this.setState({changedPassword: true}) }} />);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PasswordChangePanel = () => {
|
|
||||||
return (<p>Password changed!</p>);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//finally return the side panel
|
//finally return the side panel
|
||||||
return (
|
return (
|
||||||
<div className='sidePanel'>
|
<div className='sidePanel'>
|
||||||
<p>Go to <Link to='/profile'>your profile</Link></p>
|
<CommonLinks />
|
||||||
<PasswordChangePanel />
|
|
||||||
<Logout />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoggedOutSidePanel() {
|
LoggedOutSidePanel() {
|
||||||
//reset the other mode
|
|
||||||
if (this.state.changedPassword) {
|
|
||||||
this.setState({ changedPassword: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
//build the signup panel
|
//build the signup panel
|
||||||
let SignupPanel;
|
let SignupPanel;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
|
|||||||
import queryString from 'query-string';
|
import queryString from 'query-string';
|
||||||
|
|
||||||
//panels
|
//panels
|
||||||
import Logout from '../panels/logout.jsx';
|
import CommonLinks from '../panels/common_links.jsx';
|
||||||
import PasswordChange from '../panels/password_change.jsx';
|
import PasswordChange from '../panels/password_change.jsx';
|
||||||
|
|
||||||
class Profile extends React.Component {
|
class Profile extends React.Component {
|
||||||
@@ -21,9 +21,7 @@ class Profile extends React.Component {
|
|||||||
scientists: 0,
|
scientists: 0,
|
||||||
warning: ''
|
warning: ''
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
componentWillMount() {
|
|
||||||
this.sendRequest('/profilerequest', this.state.params.username ? this.state.params.username : this.props.username);
|
this.sendRequest('/profilerequest', this.state.params.username ? this.state.params.username : this.props.username);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +63,7 @@ class Profile extends React.Component {
|
|||||||
|
|
||||||
<div className='sidePanelPage'>
|
<div className='sidePanelPage'>
|
||||||
<SidePanel />
|
<SidePanel />
|
||||||
|
|
||||||
<div className='mainPanel'>
|
<div className='mainPanel'>
|
||||||
<div className='warning' style={warningStyle}>
|
<div className='warning' style={warningStyle}>
|
||||||
<p>{this.state.warning}</p>
|
<p>{this.state.warning}</p>
|
||||||
@@ -143,9 +142,7 @@ class Profile extends React.Component {
|
|||||||
//finally return the side panel
|
//finally return the side panel
|
||||||
return (
|
return (
|
||||||
<div className='sidePanel'>
|
<div className='sidePanel'>
|
||||||
<p>Return <Link to='/'>home</Link></p>
|
<CommonLinks extra={() => <PasswordChangePanel />} />
|
||||||
<PasswordChangePanel />
|
|
||||||
<Logout onClick={(e) => this.props.history.push('/')} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -200,9 +197,7 @@ class Profile extends React.Component {
|
|||||||
//finally return the side panel
|
//finally return the side panel
|
||||||
return (
|
return (
|
||||||
<div className='sidePanel'>
|
<div className='sidePanel'>
|
||||||
<p>Return <Link to='/'>home</Link></p>
|
<CommonLinks onClickProfile={() => {e.preventDefault(); this.sendRequest('/profilerequest', this.props.username); this.setWarning(''); this.props.history.push('/profile');}} />
|
||||||
<p>Go to <Link to='/profile' onClick={(e) => { e.preventDefault(); this.sendRequest('/profilerequest', this.props.username); this.setWarning(''); this.props.history.push('/profile'); }}>your profile</Link></p>
|
|
||||||
<Logout onClick={(e) => this.props.history.push('/')} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -258,7 +253,7 @@ class Profile extends React.Component {
|
|||||||
LoggedOutSidePanel() {
|
LoggedOutSidePanel() {
|
||||||
return (
|
return (
|
||||||
<div className='sidePanel'>
|
<div className='sidePanel'>
|
||||||
<p>Return <Link to='/'>home</Link></p>
|
<CommonLinks />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { withRouter, Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
import Logout from './logout.jsx';
|
||||||
|
|
||||||
|
class CommonLinks extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
let Extra;
|
||||||
|
|
||||||
|
if (this.props.extra) {
|
||||||
|
Extra = this.props.extra;
|
||||||
|
} else {
|
||||||
|
Extra = () => null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='panel'>
|
||||||
|
<p>Return <Link to='/' onClick={this.props.onClickHome}>home</Link></p>
|
||||||
|
<p>Go to <Link to='/profile' onClick={this.props.onClickProfile}>your profile</Link></p>
|
||||||
|
<p>Go to <Link to='/ladder' onClick={this.props.onClickLadder}>the game ladder</Link></p>
|
||||||
|
|
||||||
|
<Extra />
|
||||||
|
|
||||||
|
<Logout onClick={() => this.props.history.push('/')} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withRouter(CommonLinks);
|
||||||
Reference in New Issue
Block a user