Skip to content
Snippets Groups Projects
Commit 0c56c38c authored by Tania Fecheta's avatar Tania Fecheta
Browse files

Merge branch 'develop' of gitlab.coko.foundation:xpub/xpub-faraday into HIN-1102

parents 209cabfb d211a9cd
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!150Develop,!140Hin 1102
...@@ -205,6 +205,15 @@ const collections = { ...@@ -205,6 +205,15 @@ const collections = {
status: 'revisionRequested', status: 'revisionRequested',
customId: chance.natural({ min: 999999, max: 9999999 }), customId: chance.natural({ min: 999999, max: 9999999 }),
}, },
noFragmentsCollection: {
id: chance.guid(),
title: chance.sentence(),
type: 'collection',
fragments: [],
owners: [user.id],
save: jest.fn(() => collections.collection),
customId: chance.natural({ min: 999999, max: 9999999 }),
},
} }
module.exports = collections module.exports = collections
...@@ -112,6 +112,8 @@ describe('Get collections route handler', () => { ...@@ -112,6 +112,8 @@ describe('Get collections route handler', () => {
expect(res.statusCode).toBe(200) expect(res.statusCode).toBe(200)
const data = JSON.parse(res._getData()) const data = JSON.parse(res._getData())
delete testFixtures.collections.noFragmentsCollection
expect(data).toHaveLength(size(testFixtures.collections)) expect(data).toHaveLength(size(testFixtures.collections))
expect(data[0].type).toEqual('collection') expect(data[0].type).toEqual('collection')
expect(data[0]).toHaveProperty('visibleStatus') expect(data[0]).toHaveProperty('visibleStatus')
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"country-list": "^1.1.0", "country-list": "^1.1.0",
"moment": "^2.22.1", "moment": "^2.22.1",
"prop-types": "^15.5.10", "prop-types": "^15.5.10",
"pubsweet-component-login": "^1.1.11", "pubsweet-component-login": "^1.2.0",
"react": "^16.4.2", "react": "^16.4.2",
"react-dnd": "^2.5.4", "react-dnd": "^2.5.4",
"react-dnd-html5-backend": "^2.5.4", "react-dnd-html5-backend": "^2.5.4",
......
const config = require('config') const config = require('config')
const logger = require('@pubsweet/logger')
const { get, pickBy, last, has, pick } = require('lodash') const { get, pickBy, last, has, pick } = require('lodash')
const statuses = config.get('statuses') const statuses = config.get('statuses')
...@@ -294,8 +295,13 @@ async function applyEditorInChiefPolicy(user, operation, object, context) { ...@@ -294,8 +295,13 @@ async function applyEditorInChiefPolicy(user, operation, object, context) {
if (get(object, 'path') === '/api/collections') { if (get(object, 'path') === '/api/collections') {
const collections = await context.models.Collection.all() const collections = await context.models.Collection.all()
return Promise.all( const modifiedCollections = await Promise.all(
collections.map(async coll => { collections.map(async coll => {
if (coll.fragments.length === 0) {
logger.error(`Collection ${coll.id} does not have any fragments!`)
return null
}
const latestFragmentId = coll.fragments[coll.fragments.length - 1] const latestFragmentId = coll.fragments[coll.fragments.length - 1]
coll.currentVersion = await context.models.Fragment.find( coll.currentVersion = await context.models.Fragment.find(
latestFragmentId, latestFragmentId,
...@@ -306,6 +312,8 @@ async function applyEditorInChiefPolicy(user, operation, object, context) { ...@@ -306,6 +312,8 @@ async function applyEditorInChiefPolicy(user, operation, object, context) {
return coll return coll
}), }),
) )
return modifiedCollections.filter(Boolean)
} }
} }
return true return true
......
[ [
"pubsweet-component-login",
"pubsweet-component-signup", "pubsweet-component-signup",
"pubsweet-component-login",
"pubsweet-component-wizard", "pubsweet-component-wizard",
"pubsweet-component-modal", "pubsweet-component-modal",
"pubsweet-components-faraday", "pubsweet-components-faraday",
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
"prop-types": "^15.5.10", "prop-types": "^15.5.10",
"pubsweet": "3.0.6", "pubsweet": "3.0.6",
"pubsweet-client": "^4.0.4", "pubsweet-client": "^4.0.4",
"pubsweet-component-login": "^1.1.0", "pubsweet-component-login": "^1.2.0",
"pubsweet-component-signup": "^1.0.0", "pubsweet-component-signup": "^1.0.0",
"pubsweet-server": "10.0.1", "pubsweet-server": "10.0.1",
"react": "^16.4.2", "react": "^16.4.2",
......
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment