Merge branch 'master' into subscribe-mod-actions

Conflicts:
	client/coral-admin/src/routes/Moderation/components/Moderation.js
	client/coral-admin/src/routes/Moderation/components/styles.css
	client/coral-admin/src/routes/Moderation/containers/Moderation.js
This commit is contained in:
Chi Vinh Le
2017-06-19 23:52:10 +07:00
24 changed files with 522 additions and 86 deletions
+11
View File
@@ -19,6 +19,16 @@ const genAssetsByID = (context, ids) => AssetModel.find({
}
}).then(util.singleJoinBy(ids, 'id'));
/**
* [getAssetsByQuery description]
* @param {Object} context the context of the request
* @param {Object} query the query
* @return {Promise} resolves the assets
*/
const getAssetsByQuery = (context, query) => {
return AssetsService.search(query);
};
/**
* This endpoint find or creates an asset at the given url when it is loaded.
* @param {Object} context the context of the request
@@ -65,6 +75,7 @@ module.exports = (context) => ({
// this operation create a new asset if one isn't found.
getByURL: (url) => findOrCreateAssetByURL(context, url),
search: (query) => getAssetsByQuery(context, query),
getByID: new DataLoader((ids) => genAssetsByID(context, ids)),
getForMetrics: () => getAssetsForMetrics(context),
getAll: new util.SingletonResolver(() => AssetModel.find({}))
+2 -2
View File
@@ -6,12 +6,12 @@ const {
} = require('../../perms/constants');
const RootQuery = {
assets(_, args, {loaders: {Assets}, user}) {
assets(_, {query}, {loaders: {Assets}, user}) {
if (user == null || !user.can(SEARCH_ASSETS)) {
return null;
}
return Assets.getAll.load();
return Assets.search(query);
},
asset(_, query, {loaders: {Assets}}) {
if (query.id) {
+9 -1
View File
@@ -104,7 +104,15 @@ input UsersQuery {
sort: SORT_ORDER = REVERSE_CHRONOLOGICAL
}
# AssetsQuery allows teh ability to query assets by specific fields
input AssetsQuery {
# a search string to match against titles, authors, urls, etc.
value: String = ""
# Limit the number of results to be returned
limit: Int = 10
}
################################################################################
## Tags
################################################################################
@@ -635,7 +643,7 @@ type RootQuery {
comment(id: ID!): Comment
# All assets. Requires the `ADMIN` role.
assets: [Asset]
assets(query: AssetsQuery): [Asset]
# Find or create an asset by url, or just find with the ID.
asset(id: ID, url: String): Asset