2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-03-28 12:36:29 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-06-09 20:26:33 +09:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2016-06-06 10:06:53 +09:00
|
|
|
import { ListContainer } from "meteor/utilities:react-list-container";
|
2016-06-23 11:40:35 +09:00
|
|
|
import Posts from "meteor/nova:posts";
|
2016-06-23 15:00:58 +09:00
|
|
|
import Users from 'meteor/nova:users';
|
2016-06-30 12:05:59 +09:00
|
|
|
import { Link } from 'react-router';
|
2016-03-28 12:36:29 +09:00
|
|
|
|
2016-10-26 18:03:26 +09:00
|
|
|
import { graphql } from 'react-apollo';
|
|
|
|
import gql from 'graphql-tag';
|
|
|
|
|
|
|
|
const UsersProfilePostsList = (props, context) => {
|
|
|
|
|
|
|
|
const {loading, posts, refetch} = props.data;
|
|
|
|
return loading ?
|
|
|
|
<Telescope.components.Loading/> :
|
|
|
|
<Telescope.components.PostsList
|
|
|
|
results={posts}
|
|
|
|
hasMore={true}
|
|
|
|
ready={true}
|
|
|
|
count={10}
|
|
|
|
totalCount={20}
|
|
|
|
loadMore={()=>{console.log("load more")}}
|
|
|
|
refetchQuery={refetch}
|
|
|
|
/>;
|
|
|
|
};
|
|
|
|
|
|
|
|
UsersProfilePostsList.propTypes = {
|
|
|
|
data: React.PropTypes.shape({
|
|
|
|
loading: React.PropTypes.bool,
|
|
|
|
posts: React.PropTypes.array,
|
|
|
|
}).isRequired,
|
|
|
|
params: React.PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
UsersProfilePostsList.contextTypes = {
|
|
|
|
currentUser: React.PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
UsersProfilePostsList.displayName = "UsersProfilePostsList";
|
|
|
|
|
|
|
|
const UsersProfilePostsListWithData = graphql(gql`
|
|
|
|
query getPosts($terms: Terms, $offset: Int, $limit: Int) {
|
|
|
|
posts(terms: $terms, offset: $offset, limit: $limit) {
|
|
|
|
_id
|
|
|
|
title
|
|
|
|
url
|
|
|
|
slug
|
|
|
|
htmlBody
|
|
|
|
thumbnailUrl
|
|
|
|
baseScore
|
|
|
|
postedAt
|
|
|
|
sticky
|
|
|
|
categories {
|
|
|
|
_id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
commentCount
|
|
|
|
upvoters {
|
|
|
|
_id
|
|
|
|
}
|
|
|
|
downvoters {
|
|
|
|
_id
|
|
|
|
}
|
|
|
|
upvotes # should be asked only for admins?
|
|
|
|
score # should be asked only for admins?
|
|
|
|
viewCount # should be asked only for admins?
|
|
|
|
clickCount # should be asked only for admins?
|
|
|
|
user {
|
|
|
|
_id
|
|
|
|
telescope {
|
|
|
|
displayName
|
|
|
|
slug
|
|
|
|
emailHash
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
`, {
|
|
|
|
options(ownProps) {
|
|
|
|
return {
|
|
|
|
variables: {
|
|
|
|
// get the view from the query params or ask for the 'top' one as a default
|
|
|
|
terms: ownProps.terms,
|
|
|
|
offset: 0,
|
|
|
|
limit: 10
|
|
|
|
},
|
|
|
|
pollInterval: 20000,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
})(UsersProfilePostsList);
|
|
|
|
|
2016-08-06 19:47:04 +02:00
|
|
|
const UsersProfile = ({user}, {currentUser}) => {
|
2016-04-06 16:56:05 +02:00
|
|
|
|
2016-05-09 13:32:13 +09:00
|
|
|
const twitterName = Users.getTwitterName(user);
|
|
|
|
|
2016-10-26 18:03:26 +09:00
|
|
|
const terms = {view: "userPosts", userId: user._id};
|
2016-05-13 16:25:04 +09:00
|
|
|
const {selector, options} = Posts.parameters.get(terms);
|
|
|
|
|
2016-03-28 12:36:29 +09:00
|
|
|
return (
|
2016-04-19 15:45:36 +09:00
|
|
|
<div className="page users-profile">
|
2016-05-22 16:42:24 +09:00
|
|
|
<Telescope.components.HeadTags url={Users.getProfileUrl(user, true)} title={Users.getDisplayName(user)} description={user.telescope.bio} />
|
2016-05-22 21:56:17 +09:00
|
|
|
<h2 className="page-title">{Users.getDisplayName(user)}</h2>
|
2016-03-28 12:36:29 +09:00
|
|
|
<p>{user.telescope.bio}</p>
|
|
|
|
<ul>
|
2016-05-09 13:32:13 +09:00
|
|
|
{twitterName ? <li><a href={"http://twitter.com/" + twitterName}>@{twitterName}</a></li> : null }
|
2016-03-28 12:36:29 +09:00
|
|
|
{user.telescope.website ? <li><a href={user.telescope.website}>{user.telescope.website}</a></li> : null }
|
2016-08-06 19:47:04 +02:00
|
|
|
<Telescope.components.CanDo document={user} action="users.edit">
|
|
|
|
<li><Link to={Users.getEditUrl(user)}><FormattedMessage id="users.edit_account"/></Link></li>
|
|
|
|
</Telescope.components.CanDo>
|
2016-03-28 12:36:29 +09:00
|
|
|
</ul>
|
2016-06-09 20:26:33 +09:00
|
|
|
<h3><FormattedMessage id="users.posts"/></h3>
|
2016-10-26 18:03:26 +09:00
|
|
|
<UsersProfilePostsListWithData terms={terms} />
|
2016-03-28 12:36:29 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-04-19 15:54:53 +09:00
|
|
|
UsersProfile.propTypes = {
|
2016-03-28 12:36:29 +09:00
|
|
|
user: React.PropTypes.object.isRequired,
|
2016-08-06 19:47:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UsersProfile.contextTypes = {
|
2016-03-28 12:36:29 +09:00
|
|
|
currentUser: React.PropTypes.object
|
|
|
|
}
|
|
|
|
|
2016-05-22 16:42:24 +09:00
|
|
|
UsersProfile.displayName = "UsersProfile";
|
|
|
|
|
2016-10-26 18:03:26 +09:00
|
|
|
module.exports = UsersProfile;
|
|
|
|
|
|
|
|
// <ListContainer
|
|
|
|
// collection={Posts}
|
|
|
|
// publication="posts.list"
|
|
|
|
// terms={terms}
|
|
|
|
// selector={selector}
|
|
|
|
// options={options}
|
|
|
|
// joins={Posts.getJoins()}
|
|
|
|
// cacheSubscription={false}
|
|
|
|
// component={Telescope.components.PostsList}
|
|
|
|
// componentProps={{showHeader: false}}
|
|
|
|
// listId="posts.list.user"
|
|
|
|
// />
|