101 lines
4.1 KiB
JavaScript
Raw Normal View History

2015-04-29 11:19:10 +02:00
var ReactBootstrap = require('react-bootstrap')
, Grid = ReactBootstrap.Grid
, Col = ReactBootstrap.Col
, Row = ReactBootstrap.Row
, ListGroupItem = ReactBootstrap.ListGroupItem
, ListGroup = ReactBootstrap.ListGroup
, Nav = ReactBootstrap.Nav
, NavItem = ReactBootstrap.NavItem
, Button = ReactBootstrap.Button
, ButtonGroup = ReactBootstrap.ButtonGroup
, Glyphicon = ReactBootstrap.Glyphicon
var React = require('react');
var Router = require('react-router');
2016-01-04 13:12:21 +01:00
var Route = Router.Route; var DefaultRoute = Router.DefaultRoute; var RouteHandler = Router.RouteHandler; var Link = Router.Link;
2015-04-29 11:19:10 +02:00
var SetIntervalMixin = require("../common/SetIntervalMixin.js");
var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
var ProfileMixin = require('../common/ProfileMixin.js');
2016-01-05 19:06:48 +01:00
var FollowButton = require('../common/FollowButton.js');
2016-01-06 13:12:24 +01:00
var EditProfileModalButton = require('../profile/EditProfileModalButton.js');
var EditAvatarModalButton = require('../profile/EditAvatarModalButton.js');
2016-01-05 19:06:48 +01:00
2015-04-29 11:19:10 +02:00
module.exports = Post = React.createClass({
2016-01-06 13:12:24 +01:00
mixins: [
SetIntervalMixin,
SafeStateChangeMixin,
ProfileMixin
],
2015-04-29 11:19:10 +02:00
contextTypes: {
router: React.PropTypes.func
},
getHandlerKey: function () {
var childDepth = 2; // assuming App is top-level route
2016-01-04 13:12:21 +01:00
var router = this.context.router;
2015-04-29 11:19:10 +02:00
//console.log(router.getCurrentParams())
if ( router.getCurrentRoutes()[childDepth] ) {
var key = router.getCurrentRoutes()[childDepth].name;
if (key.indexOf("active")>-1) {key+="/"+this.props.activeAccount;}
var id = JSON.stringify(router.getCurrentParams());
if (id) { key += id; }
2015-04-30 11:22:58 +02:00
//console.log(key);
2015-04-29 11:19:10 +02:00
return key;
} else {return "none"}
},
render: function() {
var routeprefix = "#/profile/"+(this.context.router.getCurrentParams().username ? this.context.router.getCurrentParams().username+"/" : "")
var subroute = this.context.router.getCurrentRoutes()[2].name
2015-04-30 11:22:58 +02:00
//console.log(this.context.router.getCurrentRoutes());
2015-04-29 11:19:10 +02:00
return (
<ListGroup fill>
<ListGroupItem>
<Row className="nomargin">
<Col xs={3} md={3} className="fullytight">
<img className="img-responsive" src={this.state.avatar}/>
2016-01-05 19:06:48 +01:00
<br/>
2016-01-06 13:12:24 +01:00
<EditAvatarModalButton
activeAccount={this.props.activeAccount}
username={this.state.username}
avatar={this.state.avatar}
/>
2016-01-05 19:06:48 +01:00
<FollowButton activeAccount={this.props.activeAccount} username={this.state.username}/>
2015-04-29 11:19:10 +02:00
</Col>
<Col xs={8} md={8}>
2016-01-06 19:09:17 +01:00
<h4 className="nomargin-top">{this.state.fullname}<small> {'@'+this.state.username}</small></h4>
2015-04-29 11:19:10 +02:00
<p className="text-center">{this.state.location}</p>
<p className="text-center">{this.state.bio}</p>
<p className="text-center"><a href={this.state.url}>{this.state.url}</a></p>
2016-01-06 13:12:24 +01:00
<EditProfileModalButton
activeAccount={this.props.activeAccount}
username={this.state.username}
fullname={this.state.fullname}
location={this.state.location}
bio={this.state.bio}
url={this.state.url}
/>
2015-04-29 11:19:10 +02:00
</Col>
<Col xs={1} md={1} className="fullytight text-align-right"></Col>
</Row>
</ListGroupItem>
<ListGroupItem className="fullytight_all">
<ButtonGroup justified>
<Button href={routeprefix+"timeline"} bsStyle={subroute.indexOf("timeline")>-1 ? "primary" : "default"}><Glyphicon glyph="list"/></Button>
<Button href={routeprefix+"followings"} bsStyle={subroute.indexOf("followings")>-1 ? "primary" : "default"}><Glyphicon glyph="eye-open"/></Button>
<Button href={routeprefix+"mentions"} bsStyle={subroute.indexOf("mentions")>-1 ? "primary" : "default"}><Glyphicon glyph="comment"/></Button>
</ButtonGroup>
</ListGroupItem>
<RouteHandler
activeAccount={this.props.activeAccount}
key={this.getHandlerKey()}
/>
</ListGroup>
);
}
});