From 4601d4a84c1cec805d9cf1aa0a2adf3538d2cfc4 Mon Sep 17 00:00:00 2001 From: Jure Triglav <juretriglav@gmail.com> Date: Wed, 27 Nov 2019 12:47:45 +0200 Subject: [PATCH] fix: a few small fixes --- app/components/App.js | 2 +- config/authsomeGraphql.js | 14 +++++++++----- config/components.json | 10 +++++----- config/development.js | 4 ++++ config/test-mailer.js | 13 +++++++++++++ package.json | 4 ++-- server/manuscript/src/resolvers.js | 5 ++--- 7 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 config/test-mailer.js diff --git a/app/components/App.js b/app/components/App.js index 428a183dc1..83f0310135 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 3ca349a4c7..e1ac0d4feb 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 ce881c8112..661c1de018 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 0a4a0858ab..ddc9a1a3d5 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 0000000000..64e557afa5 --- /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 d16cab11e4..65a00e2e30 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 a573e7f283..bb0d81e023 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 = { -- GitLab