mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
working on UsersProfile container
This commit is contained in:
parent
3af91b00ee
commit
879a9e4c55
2 changed files with 106 additions and 17 deletions
|
@ -37,8 +37,8 @@ PostsHome.contextTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const PostsHomeWithData = graphql(gql`
|
const PostsHomeWithData = graphql(gql`
|
||||||
query getPosts($view: String, $offset: Int, $limit: Int) {
|
query getPosts($terms: Terms, $offset: Int, $limit: Int) {
|
||||||
posts(view: $view, offset: $offset, limit: $limit) {
|
posts(terms: $terms, offset: $offset, limit: $limit) {
|
||||||
_id
|
_id
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
|
@ -77,10 +77,11 @@ const PostsHomeWithData = graphql(gql`
|
||||||
|
|
||||||
`, {
|
`, {
|
||||||
options(ownProps) {
|
options(ownProps) {
|
||||||
|
const view = ownProps.location && ownProps.location.query && ownProps.location.query.view || 'top';
|
||||||
return {
|
return {
|
||||||
variables: {
|
variables: {
|
||||||
// get the view from the query params or ask for the 'top' one as a default
|
// get the view from the query params or ask for the 'top' one as a default
|
||||||
view: ownProps.location && ownProps.location.query && ownProps.location.query.view || 'top',
|
terms: { view },
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 10
|
limit: 10
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,11 +6,97 @@ import Posts from "meteor/nova:posts";
|
||||||
import Users from 'meteor/nova:users';
|
import Users from 'meteor/nova:users';
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
const UsersProfile = ({user}, {currentUser}) => {
|
const UsersProfile = ({user}, {currentUser}) => {
|
||||||
|
|
||||||
const twitterName = Users.getTwitterName(user);
|
const twitterName = Users.getTwitterName(user);
|
||||||
|
|
||||||
const terms = {view:"userPosts", userId: user._id};
|
const terms = {view: "userPosts", userId: user._id};
|
||||||
const {selector, options} = Posts.parameters.get(terms);
|
const {selector, options} = Posts.parameters.get(terms);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -26,18 +112,7 @@ const UsersProfile = ({user}, {currentUser}) => {
|
||||||
</Telescope.components.CanDo>
|
</Telescope.components.CanDo>
|
||||||
</ul>
|
</ul>
|
||||||
<h3><FormattedMessage id="users.posts"/></h3>
|
<h3><FormattedMessage id="users.posts"/></h3>
|
||||||
<ListContainer
|
<UsersProfilePostsListWithData terms={terms} />
|
||||||
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"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -52,4 +127,17 @@ UsersProfile.contextTypes = {
|
||||||
|
|
||||||
UsersProfile.displayName = "UsersProfile";
|
UsersProfile.displayName = "UsersProfile";
|
||||||
|
|
||||||
module.exports = UsersProfile;
|
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"
|
||||||
|
// />
|
Loading…
Add table
Reference in a new issue