add posts component to admin dashboard

This commit is contained in:
SachaG 2017-06-21 15:03:38 +09:00
parent 624308ab28
commit de76f6404d
8 changed files with 40 additions and 6 deletions

View file

@ -9,6 +9,9 @@ import GraphQLJSON from 'graphql-type-json';
import GraphQLDate from 'graphql-date';
import Vulcan from './config.js'; // used for global export
import { Utils } from './utils.js';
import { disableFragmentWarnings } from 'graphql-tag';
disableFragmentWarnings();
// convert a JSON schema to a GraphQL schema
const jsTypeToGraphQLType = type => {

View file

@ -0,0 +1,14 @@
import { extendFragment, addAdminColumn } from 'meteor/vulcan:core';
import AdminUsersPosts from './components/AdminUsersPosts';
extendFragment('UsersAdmin', `
posts{
...PostsPage
}
`);
addAdminColumn({
name: 'users.posts',
order: 50,
component: AdminUsersPosts
});

View file

@ -1,3 +1 @@
import Posts from './modules.js';
export default Posts;
export * from './modules.js';

View file

@ -0,0 +1,12 @@
import React from 'react';
import Posts from 'meteor/vulcan:posts';
import { Link } from 'react-router';
const AdminUsersPosts = ({ user }) =>
<ul>
{user.posts && user.posts.map(post =>
<li key={post._id}><Link to={Posts.getLink(post)}>{post.title}</Link></li>
)}
</ul>
export default AdminUsersPosts;

View file

@ -0,0 +1,5 @@
import { addStrings } from 'meteor/vulcan:core';
addStrings('en', {
'admin.users.posts': 'Posts',
});

View file

@ -12,5 +12,8 @@ import './permissions.js';
import './resolvers.js';
import './mutations.js';
import './redux.js';
import './i18n.js';
import './admin.js';
export default Posts;
export { default as AdminUsersPosts } from './components/AdminUsersPosts';
export default Posts;

View file

@ -38,7 +38,6 @@ const resolvers = {
// get selector and options from terms and perform Mongo query
let {selector, options} = Posts.getParameters(terms);
options.limit = (terms.limit < 1 || terms.limit > 100) ? 100 : terms.limit;
options.skip = terms.offset;
const posts = Posts.find(selector, options).fetch();

View file

@ -7,4 +7,4 @@ import './server/cron.js';
Posts._ensureIndex({"status": 1, "isFuture": 1});
Posts._ensureIndex({"status": 1, "isFuture": 1, "postedAt": 1});
export default Posts;
export * from './modules.js';