diff --git a/app/components/App.js b/app/components/App.js index 428a183dc124e7118590dc4c3dc9358473e2b8d4..83f031013597f97092fff9fd8af65993d88940f4 100644 --- a/app/components/App.js +++ b/app/components/App.js @@ -43,7 +43,7 @@ const App = ({ match, }) => { const journal = useContext(JournalContext) - const [conversion, _] = useContext(XpubContext) + const [conversion] = useContext(XpubContext) const { pathname } = history.location const showLinks = pathname.match(/submit|manuscript/g) diff --git a/config/authsomeGraphql.js b/config/authsomeGraphql.js index 3ca349a4c7e2ee3687f87d90edaede6411daafcf..e1ac0d4feb718ea48b8e6148b19f60acc8cebd9d 100644 --- a/config/authsomeGraphql.js +++ b/config/authsomeGraphql.js @@ -49,11 +49,14 @@ class XpubCollabraMode { let membershipCondition if (object) { // We're asking if a user is a member of a team for a specific object - membershipCondition = team => - team.role === role && team.object && team.object.objectId === object.id + membershipCondition = team => { + // TODO: This needs to be fixed... + const objectId = team.objectId || (team.object && team.object.objectId) + return team.role === role && objectId === object.id + } } else { // We're asking if a user is a member of a global team - membershipCondition = team => team.role === role && !team.object + membershipCondition = team => team.role === role && team.global } const memberships = await Promise.all( @@ -515,7 +518,9 @@ class XpubCollabraMode { } async isAllowedToReview(object) { - this.user = await this.context.models.User.find(this.userId) + this.user = await this.context.models.User.query() + .findById(this.userId) + .eager('teams') const permission = await this.isAssignedReviewerEditor({ id: object.manuscriptId, }) @@ -752,7 +757,6 @@ module.exports = { read: async (userId, operation, object, context) => { const mode = new XpubCollabraMode(userId, operation, object, context) - console.log(userId, operation, object, object.name, object.constructor.name) if (object === 'Manuscript' || object === 'Review') { return true } diff --git a/config/components.json b/config/components.json index ce881c811232bf270fdb2589abaabc76fc46888d..661c1de018b13613094bb692486333d8034df89a 100644 --- a/config/components.json +++ b/config/components.json @@ -8,11 +8,11 @@ "pubsweet-component-xpub-formbuilder", "@pubsweet/model-team", "@pubsweet/model-user", - "server/journal/src/", - "server/manuscript/src/", - "server/review/src/", - "server/file/src/", - "server/formbuilder/src/", + "./server/journal/src/", + "./server/manuscript/src/", + "./server/review/src/", + "./server/file/src/", + "./server/formbuilder/src/", "@pubsweet/job-xsweet", "@pubsweet/component-password-reset-server" ] diff --git a/config/development.js b/config/development.js index 0a4a0858abad2ef156f0cee84447404ccad36d38..ddc9a1a3d55c00f36054826793e77bf74416de4b 100644 --- a/config/development.js +++ b/config/development.js @@ -13,6 +13,10 @@ module.exports = { 'pubsweet-client': { baseUrl: 'http://localhost:4000/', }, + mailer: { + from: 'simplej@simplej.com', + path: `${__dirname}/test-mailer`, + }, dbManager: { username: 'admin', password: '12345678', diff --git a/config/test-mailer.js b/config/test-mailer.js new file mode 100644 index 0000000000000000000000000000000000000000..64e557afa5d4857c50ebf212843a49ea59174b96 --- /dev/null +++ b/config/test-mailer.js @@ -0,0 +1,13 @@ +// This is a test mailer setup, according to instructions on: +// https://nodemailer.com/smtp/testing/ + +module.exports = { + transport: { + host: 'smtp.ethereal.email', + port: 587, + auth: { + user: 'patrick23@ethereal.email', + pass: 'VbnXvJ9UW9BHevDnxk', + }, + }, +} diff --git a/package.json b/package.json index d16cab11e49d2c20d226482075b3b9bf31e58392..65a00e2e304dbe4ab38f1697cd96a41b34a886b6 100644 --- a/package.json +++ b/package.json @@ -56,10 +56,10 @@ "styled-components": "^4.1.1", "supertest": "^3.0.0", "winston": "^2.4.0", - "xpub-journal": "^0.0.22", + "xpub-journal": "^0.1.0", "xpub-selectors": "^0.2.0", "xpub-theme": "^0.0.23", - "xpub-with-context": "^0.1.4" + "xpub-with-context": "^0.2.0" }, "devDependencies": { "@babel/core": "^7.0.0", diff --git a/server/manuscript/src/resolvers.js b/server/manuscript/src/resolvers.js index a573e7f283336368b354f4ccf2f698aa09e56f64..bb0d81e023f9fa76eb57594926ddb8450a7be7d3 100644 --- a/server/manuscript/src/resolvers.js +++ b/server/manuscript/src/resolvers.js @@ -92,15 +92,14 @@ const resolvers = { .eager('members') team.members = team.members.map(m => { - if (m.user && m.user.id === currentUserId) { + if (m.userId === currentUserId) { m.status = action } return m }) - if (!team) throw new Error('No team was found') - await new Team(team).save() + await new Team(team).saveGraph() if (action === 'accepted') { const review = {