diff --git a/app/brand-instances-configs/elife.json b/app/brand-instances-configs/elife.json index 79ff52d8793009334e20f13e64180224363d34f8..59269e6810ca4713b3af2e1f96e812b5261d1a0b 100644 --- a/app/brand-instances-configs/elife.json +++ b/app/brand-instances-configs/elife.json @@ -2,5 +2,5 @@ "logoPath": "/public/logo-elife.svg", "primaryColor": "#0A9DD9", "secondaryColor": "#0A9DD9", - "brandName": "Elife" + "brandName": "eLife" } diff --git a/app/components/component-manuscripts/src/Manuscript.js b/app/components/component-manuscripts/src/Manuscript.js index dffb694d9db14ac0153cded0d76dc870616dfa12..618d468ed66444a325f476381f5d76ecd4ded103 100644 --- a/app/components/component-manuscripts/src/Manuscript.js +++ b/app/components/component-manuscripts/src/Manuscript.js @@ -21,6 +21,7 @@ import { import { convertTimestampToDate } from '../../../shared/time-formatting' import { articleStatuses } from '../../../globals' +import { publishManuscriptMutation } from '../../component-review/src/components/queries' const DELETE_MANUSCRIPT = gql` mutation($id: ID!) { @@ -32,6 +33,7 @@ const urlFrag = config.journal.metadata.toplevel_urlfragment // manuscriptId is always the parent manuscript's id const User = ({ manuscriptId, manuscript, submitter }) => { + const [publishManuscript] = useMutation(publishManuscriptMutation) const [deleteManuscript] = useMutation(DELETE_MANUSCRIPT, { update(cache, { data: { deleteManuscriptId } }) { const id = cache.identify({ @@ -43,6 +45,20 @@ const User = ({ manuscriptId, manuscript, submitter }) => { }, }) + const publishManuscriptHandler = () => { + publishManuscript({ + variables: { id: manuscript.id }, + update: (cache, { data }) => { + cache.modify({ + id: cache.identify(manuscript), + fields: { + status: data.publishManuscript.status + }, + }) + } + }) + } + return ( <Row> <Cell>{manuscript.meta && manuscript.meta.title}</Cell> @@ -83,6 +99,13 @@ const User = ({ manuscriptId, manuscript, submitter }) => { > Delete </Action> + {process.env.INSTANCE_NAME === 'elife' && + <Action + onClick={publishManuscriptHandler} + > + Publish + </Action> + } </LastCell> </Row> ) diff --git a/app/components/component-review/src/components/queries.js b/app/components/component-review/src/components/queries.js index 737e7d97e5a36a240a1d4c24785343be2525de19..afc88635675fb8d6bec0eb25b7349102085dd020 100644 --- a/app/components/component-review/src/components/queries.js +++ b/app/components/component-review/src/components/queries.js @@ -162,6 +162,7 @@ export const publishManuscriptMutation = gql` publishManuscript(id: $id) { id published + status } } ` diff --git a/app/components/shared/Badge.js b/app/components/shared/Badge.js index eff96a77087c6226141576774a36a2a03e1e10e5..86fa7c39756e17da387a29c1acdd43c16cf90280 100644 --- a/app/components/shared/Badge.js +++ b/app/components/shared/Badge.js @@ -64,6 +64,7 @@ const label = (status, published) => { invited: 'Invited', // reviewer status completed: 'Completed', // reviewer status evaluated: 'evaluated', + published: 'published', } if (isPublished) { diff --git a/package.json b/package.json index de5ed4f466995909e0d224f1b5bb767ffb3bd239..dd8e297bb0eba9c9235d6f4f18cdd70992f2d502 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "apollo-link-context": "1.0.20", "apollo-link-schema": "1.2.5", "apollo-upload-client": "14.1.2", + "axios": "^0.21.1", "bcrypt": "3.0.8", "body-parser": "^1.19.0", "compression": "^1.7.4", diff --git a/server/model-manuscript/src/graphql.js b/server/model-manuscript/src/graphql.js index 6e746824bf97b9992145aec57b644763fb5dac96..bf1f6c122834c16cc0f722405404812b4ca726f7 100644 --- a/server/model-manuscript/src/graphql.js +++ b/server/model-manuscript/src/graphql.js @@ -1,5 +1,6 @@ const merge = require('lodash/merge') const { ref, raw } = require('objection') +const axios = require('axios') const ManuscriptResolvers = ({ isVersion }) => { const resolvers = { @@ -262,7 +263,33 @@ const resolvers = { async publishManuscript(_, { id }, ctx) { let manuscript = await ctx.models.Manuscript.query().findById(id) - if (!manuscript.published) { + if (process.env.INSTANCE_NAME === 'elife') { + const requestBody = { + uri: manuscript.submission.articleURL, + text: manuscript.submission.evaluationContent, + tags: [ + manuscript.submission.evalType + ], + // group: "q5X6RWJ6", + } + + try { + const response = await axios.post('https://api.hypothes.is/api/annotations', requestBody, { + headers: { + 'Authorization': 'Bearer 6879-C9eSHATI6gsjTD0GmZ9NIojOPDnntsdt76iE1AKlyzA' + } + }) + const updatedManuscript = await ctx.models.Manuscript.query().updateAndFetchById(id, { + published: new Date(), + status: 'published', + }) + return updatedManuscript + } catch { + return + } + } + + if (!manuscript.published && process.env.INSTANCE_NAME === 'coko') { manuscript = ctx.models.Manuscript.query().updateAndFetchById(id, { published: new Date(), }) diff --git a/yarn.lock b/yarn.lock index 6fd96954d889859dd005f2e41cc0372946f283d0..13e900e13ea1f31298c1979925a3d5cc0e2fa7b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4797,6 +4797,13 @@ axios@^0.19.2: dependencies: follow-redirects "1.5.10" +axios@^0.21.1: + version "0.21.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" + integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== + dependencies: + follow-redirects "^1.10.0" + axobject-query@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be" @@ -9539,7 +9546,7 @@ follow-redirects@1.5.10: dependencies: debug "=3.1.0" -follow-redirects@^1.0.0: +follow-redirects@^1.0.0, follow-redirects@^1.10.0: version "1.13.3" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.3.tgz#e5598ad50174c1bc4e872301e82ac2cd97f90267" integrity sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==