diff --git a/packages/component-faraday-ui/src/AuthorReply.js b/packages/component-faraday-ui/src/AuthorReply.js new file mode 100644 index 0000000000000000000000000000000000000000..c9f8c6ca8b17ff2442df8b365eb70448eb48593a --- /dev/null +++ b/packages/component-faraday-ui/src/AuthorReply.js @@ -0,0 +1,56 @@ +import React from 'react' +import { get } from 'lodash' +import { withProps } from 'recompose' +import styled from 'styled-components' +import { th } from '@pubsweet/ui-toolkit' +import { DateParser } from '@pubsweet/ui' + +import { Label, Item, Row, Text } from './' + +const submittingAuthor = authors => { + const thisAuthor = authors.filter(e => e.isSubmitting) + return thisAuthor[0] +} + +const AuthorReply = ({ reply, authorName, submittedOn }) => ( + <Root> + <Row justify="space-between" mb={2}> + <Item justify="flex-end"> + <Row mb={1}> + <Item vertical> + <Label mb={1 / 2}>Author Reply</Label> + <Text>{reply}</Text> + </Item> + </Row> + <Text ml={1} mr={1} whiteSpace="nowrap"> + {authorName} + </Text> + <DateParser timestamp={submittedOn}> + {date => <Text>{date}</Text>} + </DateParser> + </Item> + </Row> + </Root> +) + +export default withProps( + ({ fragment: { authors, submitted, responseToReviewers } }) => ({ + reply: responseToReviewers.content, + submittedOn: submitted, + authorName: `${get(submittingAuthor(authors), 'firstName', '')} ${get( + submittingAuthor(authors), + 'lastName', + '', + )}`, + }), +)(AuthorReply) + +// #region styles +const Root = styled.div` + background-color: ${th('colorBackgroundHue')}; + border: ${th('borderWidth')} ${th('borderStyle')} ${th('colorBackgroundHue3')}; + border-radius: ${th('borderRadius')}; + padding: calc(${th('gridUnit')} * 2); + margin: ${th('gridUnit')}; +` +// #endregion diff --git a/packages/component-faraday-ui/src/AuthorReply.md b/packages/component-faraday-ui/src/AuthorReply.md new file mode 100644 index 0000000000000000000000000000000000000000..0548cdd8dc8e29ab92e88edc197301ea6b7b3eb5 --- /dev/null +++ b/packages/component-faraday-ui/src/AuthorReply.md @@ -0,0 +1,77 @@ +Reviewer report. + +```js +const fragment = { + "id": "1378b0e4-5c29-46a6-8afe-2f5ec1b13899", + "type": "fragment", + "files": { + "manuscripts": [ + { + "id": "e891d6dd-fe46-472d-87db-5c80fdd48ac2/9e103d6a-dd0e-4d1e-b6ff-9b8383579649", + "name": "Evolutionary Programming.pdf", + "size": 81618, + "originalName": "Evolutionary Programming.pdf" + } + ], + "supplementary": [] + }, + "owners": [ + { + "id": "f3a16660-ae1e-4ab2-9ae4-220a0c7ac575", + "username": "tania.fecheta+a@thinslices.com" + } + ], + "authors": [ + { + "id": "f3a16660-ae1e-4ab2-9ae4-220a0c7ac575", + "title": "mrs", + "country": "AL", + "lastName": "Tania", + "firstName": "Author", + "affiliation": "Ts", + "isSubmitting": true, + "isCorresponding": true + } + ], + "created": "2018-10-30T07:33:26.128Z", + "version": 2, + "metadata": { + "type": "research", + "title": "Major revision and new version sunmited", + "journal": "Bioinorganic Chemistry and Applications", + "abstract": "something something" + }, + "conflicts": { + "hasFunding": "", + "hasConflicts": "no", + "hasDataAvailability": "" + }, + "submitted": 1540884806175, + "invitations": [ + { + "id": "7b50667d-883c-43d4-aea5-71455e251801", + "role": "reviewer", + "type": "invitation", + "userId": "b7554926-89dc-4b8b-b4d7-cd1bcc51f2de", + "hasAnswer": true, + "invitedOn": 1540884401711, + "isAccepted": true, + "respondedOn": 1540884410543 + } + ], + "collectionId": "383a5314-788c-49e5-aa00-617426b5c7c7", + "declarations": { + "agree": true + }, + "fragmentType": "version", + "responseToReviewers": { + "file": null, + "content": "i changed that thing" + }, + "recommendations": [] +}; + +<AuthorReply + fragment={fragment} +/> +``` diff --git a/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.js b/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.js new file mode 100644 index 0000000000000000000000000000000000000000..3f6bbd424511aecaecc918240471772bef9057da --- /dev/null +++ b/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.js @@ -0,0 +1,11 @@ +import React from 'react' + +import { ContextualBox, AuthorReply } from '../' + +const ResponseToRevisionRequest = ({ fragment }) => ( + <ContextualBox label="Response to Revision Request" mb={2}> + <AuthorReply fragment={fragment} /> + </ContextualBox> +) + +export default ResponseToRevisionRequest diff --git a/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.md b/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.md new file mode 100644 index 0000000000000000000000000000000000000000..eae07412e44fa24ea983e46dffd6ca01bef3713b --- /dev/null +++ b/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.md @@ -0,0 +1,75 @@ +ResponseToRevisionRequest. + +```js +const fragment = { + "id": "1378b0e4-5c29-46a6-8afe-2f5ec1b13899", + "type": "fragment", + "files": { + "manuscripts": [ + { + "id": "e891d6dd-fe46-472d-87db-5c80fdd48ac2/9e103d6a-dd0e-4d1e-b6ff-9b8383579649", + "name": "Evolutionary Programming.pdf", + "size": 81618, + "originalName": "Evolutionary Programming.pdf" + } + ], + "supplementary": [] + }, + "owners": [ + { + "id": "f3a16660-ae1e-4ab2-9ae4-220a0c7ac575", + "username": "tania.fecheta+a@thinslices.com" + } + ], + "authors": [ + { + "id": "f3a16660-ae1e-4ab2-9ae4-220a0c7ac575", + "title": "mrs", + "country": "AL", + "lastName": "Tania", + "firstName": "Author", + "affiliation": "Ts", + "isSubmitting": true, + "isCorresponding": true + } + ], + "created": "2018-10-30T07:33:26.128Z", + "version": 2, + "metadata": { + "type": "research", + "title": "Major revision and new version sunmited", + "journal": "Bioinorganic Chemistry and Applications", + "abstract": "something something" + }, + "conflicts": { + "hasFunding": "", + "hasConflicts": "no", + "hasDataAvailability": "" + }, + "submitted": 1540884806175, + "invitations": [ + { + "id": "7b50667d-883c-43d4-aea5-71455e251801", + "role": "reviewer", + "type": "invitation", + "userId": "b7554926-89dc-4b8b-b4d7-cd1bcc51f2de", + "hasAnswer": true, + "invitedOn": 1540884401711, + "isAccepted": true, + "respondedOn": 1540884410543 + } + ], + "collectionId": "383a5314-788c-49e5-aa00-617426b5c7c7", + "declarations": { + "agree": true + }, + "fragmentType": "version", + "responseToReviewers": { + "file": null, + "content": "i changed that thing" + }, + "recommendations": [] +}; + +<ResponseToRevisionRequest fragment={fragment} /> +``` diff --git a/packages/component-faraday-ui/src/contextualBoxes/index.js b/packages/component-faraday-ui/src/contextualBoxes/index.js index d3ad70c5ba82387ff832effb11447534d18e4b15..97a41d51e4791b8f11f3d53cbd355de93d516cd8 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/index.js +++ b/packages/component-faraday-ui/src/contextualBoxes/index.js @@ -3,3 +3,6 @@ export { default as ReviewerDetails } from './ReviewerDetails' export { default as HERecommendation } from './HERecommendation' export { default as ReviewerReportForm } from './ReviewerReportForm' export { default as AuthorReviews } from './AuthorReviews' +export { + default as ResponseToRevisionRequest, +} from './ResponseToRevisionRequest' diff --git a/packages/component-faraday-ui/src/index.js b/packages/component-faraday-ui/src/index.js index 4bfa4af165b2ecd8865299970a1ebe90428a1cfb..a99b60e4c1b2e18f15810beb84255aecd4ad4260 100644 --- a/packages/component-faraday-ui/src/index.js +++ b/packages/component-faraday-ui/src/index.js @@ -6,6 +6,7 @@ export * from './gridItems' export { default as ActionLink } from './ActionLink' export { default as AuthorWithTooltip } from './AuthorWithTooltip' +export { default as AuthorReply } from './AuthorReply' export { default as Logo } from './Logo' export { default as AppBar } from './AppBar' export { default as AppBarMenu } from './AppBarMenu' diff --git a/packages/component-manuscript/src/components/ManuscriptLayout.js b/packages/component-manuscript/src/components/ManuscriptLayout.js index ab97d296049c9240213c740f6987eb0cabd8f8ad..13865d92ca0c2efea90bcd523d10c04b2f36148c 100644 --- a/packages/component-manuscript/src/components/ManuscriptLayout.js +++ b/packages/component-manuscript/src/components/ManuscriptLayout.js @@ -195,7 +195,7 @@ const ManuscriptLayout = ({ {...inviteReviewer} /> )} - + {console.log('fragment', fragment)} {get(currentUser, 'permissions.canSubmitRevision', false) && ( <SubmitRevision {...submitRevision} /> )} diff --git a/packages/xpub-faraday/config/validations.js b/packages/xpub-faraday/config/validations.js index cc116eecca70a91cb64c085c77fc0c6b6da39cfd..60cd146dec55f085d5535fc0eb934edfcfebc7da 100644 --- a/packages/xpub-faraday/config/validations.js +++ b/packages/xpub-faraday/config/validations.js @@ -98,6 +98,7 @@ module.exports = { size: Joi.number(), url: Joi.string(), signedUrl: Joi.string(), + submittedOn: Joi.date(), }), ), }),