diff --git a/app/components/component-xpub-dashboard/package.json b/app/components/component-dashboard/package.json similarity index 100% rename from app/components/component-xpub-dashboard/package.json rename to app/components/component-dashboard/package.json diff --git a/app/components/component-dashboard/src/components/Dashboard.js b/app/components/component-dashboard/src/components/Dashboard.js new file mode 100644 index 0000000000000000000000000000000000000000..f997ea1e818b5a5794bc2c9e33cc9c568b4c9ac6 --- /dev/null +++ b/app/components/component-dashboard/src/components/Dashboard.js @@ -0,0 +1,125 @@ +import React from 'react' +import { useQuery, useMutation } from '@apollo/react-hooks' +import { Action, Button } from '@pubsweet/ui' +// import Authorize from 'pubsweet-client/src/helpers/Authorize' + +import queries from '../graphql/queries/' +import mutations from '../graphql/mutations/' +import { Container, Section, Heading, Content } from '../style' +import EditorItem from './sections/EditorItem' +import OwnerItem from './sections/OwnerItem' +import ReviewerItem from './sections/ReviewerItem' +import { Spinner } from '../../../shared' + +const updateReviewer = (proxy, { data: { reviewerResponse } }) => { + const id = reviewerResponse.object.objectId + const data = proxy.readQuery({ + query: queries.dashboard, + variables: { + id, + }, + }) + + const manuscriptIndex = data.manuscripts.findIndex(manu => manu.id === id) + const teamIndex = data.manuscripts[manuscriptIndex].teams.findIndex( + team => team.id === reviewerResponse.id, + ) + + data.manuscripts[manuscriptIndex].teams[teamIndex] = reviewerResponse + proxy.writeQuery({ query: queries.dashboard, data }) +} + +const Dashboard = ({ history, ...props }) => { + // const uploadManuscript = upload() + // const [conversion] = useContext(XpubContext) + + const { loading, data } = useQuery(queries.dashboard) + const [reviewerRespond] = useMutation(mutations.reviewerResponseMutation, { + // variables: { currentUserId, action, teamId }, + update: updateReviewer, + }) + const [deleteManuscript] = useMutation(mutations.deleteManuscriptMutation, { + // variables: { id: manuscript.id }, + update: (proxy, { data: { deleteManuscript } }) => { + const data = proxy.readQuery({ query: queries.dashboard }) + const manuscriptIndex = data.manuscripts.findIndex( + manuscript => manuscript.id === deleteManuscript, + ) + if (manuscriptIndex > -1) { + data.manuscripts.splice(manuscriptIndex, 1) + proxy.writeQuery({ query: queries.dashboard, data }) + } + }, + }) + + if (loading) return <Spinner /> + + const dashboard = (data && data.manuscripts) || [] + const currentUser = data && data.currentUser + + return ( + <Container> + <Button onClick={() => history.push('/journal/newSubmission')} primary> + New submission + </Button> + + {!dashboard.length && <Section>Nothing to do at the moment.</Section>} + {/* <Authorize object={dashboard} operation="can view my submission section"> */} + {dashboard.length > 0 ? ( + <Content> + <Section> + <Heading>My Submissions</Heading> + + {dashboard.map(submission => ( + <OwnerItem + deleteManuscript={() => + // eslint-disable-next-line no-alert + window.confirm( + 'Are you sure you want to delete this submission?', + ) && deleteManuscript({ variables: { id: submission.id } }) + } + key={`submission-${submission.id}`} + version={submission} + /> + ))} + </Section> + </Content> + ) : null} + {/* </Authorize> + <Authorize object={dashboard} operation="can view review section"> */} + {dashboard.length > 0 ? ( + <Content> + <Section> + <Heading>To review</Heading> + {dashboard.map(review => ( + <ReviewerItem + currentUser={currentUser} + key={review.id} + reviewerRespond={reviewerRespond} + version={review} + /> + ))} + </Section> + </Content> + ) : null} + {/* </Authorize> */} + + {/* <Authorize object={dashboard} operation="can view my manuscripts section"> */} + {dashboard.length > 0 ? ( + <Content> + <Section> + <Heading>My Manuscripts</Heading> + {dashboard.map(manuscript => ( + <EditorItem + key={`manuscript-${manuscript.id}`} + version={manuscript} + /> + ))} + </Section> + </Content> + ) : null} + {/* </Authorize> */} + </Container> + ) +} +export default Dashboard diff --git a/app/components/component-xpub-dashboard/src/components/JournalLink.js b/app/components/component-dashboard/src/components/JournalLink.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/JournalLink.js rename to app/components/component-dashboard/src/components/JournalLink.js diff --git a/app/components/component-xpub-dashboard/src/components/Reviews.js b/app/components/component-dashboard/src/components/Reviews.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/Reviews.js rename to app/components/component-dashboard/src/components/Reviews.js diff --git a/app/components/component-xpub-dashboard/src/components/Status.js b/app/components/component-dashboard/src/components/Status.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/Status.js rename to app/components/component-dashboard/src/components/Status.js diff --git a/app/components/component-xpub-dashboard/src/components/index.js b/app/components/component-dashboard/src/components/index.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/index.js rename to app/components/component-dashboard/src/components/index.js diff --git a/app/components/component-xpub-dashboard/src/components/metadata/Meta.js b/app/components/component-dashboard/src/components/metadata/Meta.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/metadata/Meta.js rename to app/components/component-dashboard/src/components/metadata/Meta.js diff --git a/app/components/component-xpub-dashboard/src/components/metadata/MetadataAuthors.js b/app/components/component-dashboard/src/components/metadata/MetadataAuthors.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/metadata/MetadataAuthors.js rename to app/components/component-dashboard/src/components/metadata/MetadataAuthors.js diff --git a/app/components/component-xpub-dashboard/src/components/metadata/MetadataReviewType.js b/app/components/component-dashboard/src/components/metadata/MetadataReviewType.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/metadata/MetadataReviewType.js rename to app/components/component-dashboard/src/components/metadata/MetadataReviewType.js diff --git a/app/components/component-xpub-dashboard/src/components/metadata/MetadataSections.js b/app/components/component-dashboard/src/components/metadata/MetadataSections.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/metadata/MetadataSections.js rename to app/components/component-dashboard/src/components/metadata/MetadataSections.js diff --git a/app/components/component-xpub-dashboard/src/components/metadata/MetadataStreamLined.js b/app/components/component-dashboard/src/components/metadata/MetadataStreamLined.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/metadata/MetadataStreamLined.js rename to app/components/component-dashboard/src/components/metadata/MetadataStreamLined.js diff --git a/app/components/component-xpub-dashboard/src/components/metadata/MetadataSubmittedDate.js b/app/components/component-dashboard/src/components/metadata/MetadataSubmittedDate.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/metadata/MetadataSubmittedDate.js rename to app/components/component-dashboard/src/components/metadata/MetadataSubmittedDate.js diff --git a/app/components/component-xpub-dashboard/src/components/metadata/MetadataType.js b/app/components/component-dashboard/src/components/metadata/MetadataType.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/metadata/MetadataType.js rename to app/components/component-dashboard/src/components/metadata/MetadataType.js diff --git a/app/components/component-xpub-dashboard/src/components/sections/EditorItem.js b/app/components/component-dashboard/src/components/sections/EditorItem.js similarity index 98% rename from app/components/component-xpub-dashboard/src/components/sections/EditorItem.js rename to app/components/component-dashboard/src/components/sections/EditorItem.js index 59c2afab71c8c690ccdc19c785d84992ac0832c5..04f0c0ebc05af456b6aa20acaf5a7eae4a074313 100644 --- a/app/components/component-xpub-dashboard/src/components/sections/EditorItem.js +++ b/app/components/component-dashboard/src/components/sections/EditorItem.js @@ -3,7 +3,7 @@ import React from 'react' import styled from 'styled-components' // import Authorize from 'pubsweet-client/src/helpers/Authorize' import { Action, ActionGroup } from '@pubsweet/ui' -import { Item, Header, Body } from '../molecules/Item' +import { Item, Header, Body } from '../../style' import Status from '../Status' import Meta from '../metadata/Meta' import MetadataSections from '../metadata/MetadataSections' diff --git a/app/components/component-xpub-dashboard/src/components/sections/OwnerItem.js b/app/components/component-dashboard/src/components/sections/OwnerItem.js similarity index 96% rename from app/components/component-xpub-dashboard/src/components/sections/OwnerItem.js rename to app/components/component-dashboard/src/components/sections/OwnerItem.js index 0c193d2604b293b781e1e4332c88acac9d5ca503..34b903ff9538a47987c3d93727b3cdbf7e976755 100644 --- a/app/components/component-xpub-dashboard/src/components/sections/OwnerItem.js +++ b/app/components/component-dashboard/src/components/sections/OwnerItem.js @@ -4,7 +4,7 @@ import { pickBy } from 'lodash' import { Action, ActionGroup } from '@pubsweet/ui' // import Authorize from 'pubsweet-client/src/helpers/Authorize' -import { Item, Header, Body } from '../molecules/Item' +import { Item, Header, Body } from '../../style' import Status from '../Status' import VersionTitle from './VersionTitle' diff --git a/app/components/component-xpub-dashboard/src/components/sections/ReviewerItem.js b/app/components/component-dashboard/src/components/sections/ReviewerItem.js similarity index 94% rename from app/components/component-xpub-dashboard/src/components/sections/ReviewerItem.js rename to app/components/component-dashboard/src/components/sections/ReviewerItem.js index 380435bc2d81fae41e966e7760e7f1e10e34521a..e3be97f2967bee8245c3601dcae329324365e18e 100644 --- a/app/components/component-xpub-dashboard/src/components/sections/ReviewerItem.js +++ b/app/components/component-dashboard/src/components/sections/ReviewerItem.js @@ -1,9 +1,15 @@ import React from 'react' import { Button } from '@pubsweet/ui' // import Authorize from 'pubsweet-client/src/helpers/Authorize' -import { Item, Body, Divider } from '../molecules/Item' -import { Links, LinkContainer } from '../molecules/Links' -import { Actions, ActionContainer } from '../molecules/Actions' +import { + Item, + Body, + Divider, + Links, + LinkContainer, + Actions, + ActionContainer, +} from '../../style' import JournalLink from '../JournalLink' import VersionTitle from './VersionTitle' diff --git a/app/components/component-xpub-dashboard/src/components/sections/VersionTitle.js b/app/components/component-dashboard/src/components/sections/VersionTitle.js similarity index 100% rename from app/components/component-xpub-dashboard/src/components/sections/VersionTitle.js rename to app/components/component-dashboard/src/components/sections/VersionTitle.js diff --git a/app/components/component-xpub-dashboard/src/graphql/mutations/index.js b/app/components/component-dashboard/src/graphql/mutations/index.js similarity index 100% rename from app/components/component-xpub-dashboard/src/graphql/mutations/index.js rename to app/components/component-dashboard/src/graphql/mutations/index.js diff --git a/app/components/component-xpub-dashboard/src/graphql/queries/index.js b/app/components/component-dashboard/src/graphql/queries/index.js similarity index 98% rename from app/components/component-xpub-dashboard/src/graphql/queries/index.js rename to app/components/component-dashboard/src/graphql/queries/index.js index a03ede98186dd75d7767168ecb0a6d03100732d1..86cf636dfb4e1f90a57a84030dffee966be88164 100644 --- a/app/components/component-xpub-dashboard/src/graphql/queries/index.js +++ b/app/components/component-dashboard/src/graphql/queries/index.js @@ -27,7 +27,6 @@ export default { teams { id role - type name object { objectId diff --git a/app/components/component-xpub-dashboard/src/index.js b/app/components/component-dashboard/src/index.js similarity index 100% rename from app/components/component-xpub-dashboard/src/index.js rename to app/components/component-dashboard/src/index.js diff --git a/app/components/component-dashboard/src/style.js b/app/components/component-dashboard/src/style.js new file mode 100644 index 0000000000000000000000000000000000000000..8ff8cd0af437bcecd7949378eccbd78417f98673 --- /dev/null +++ b/app/components/component-dashboard/src/style.js @@ -0,0 +1,71 @@ +import styled from 'styled-components' +import { th, grid } from '@pubsweet/ui-toolkit' + +// TODO -- why two divs? + +export { Container, Section, Content } from '../../shared' +const Actions = styled.div`` + +const ActionContainer = styled.div` + display: inline-block; +` + +export { Actions, ActionContainer } + +const Item = styled.div` + margin-bottom: calc(${th('gridUnit') * 4}); +` + +const Header = styled.div` + align-items: baseline; + display: flex; + justify-content: space-between; + text-transform: uppercase; +` + +const Body = styled.div` + align-items: space-between; + display: flex; + justify-content: space-between; + margin-bottom: calc(${th('gridUnit')} * 4); + padding-left: 1.5em; + & > div:last-child { + flex-shrink: 0; + } +` + +const Divider = styled.span.attrs(props => ({ + children: ` ${props.separator} `, +}))` + color: ${th('colorFurniture')}; + white-space: pre; +` + +export { Item, Header, Body, Divider } + +const Links = styled.div` + align-items: flex-end; + display: flex; + justify-content: bottom; +` + +const LinkContainer = styled.div` + font-size: ${th('fontSizeBaseSmall')}; + line-height: ${th('lineHeightBaseSmall')}; +` + +export { Links, LinkContainer } + +const Page = styled.div` + padding: ${grid(2)}; +` + +const Heading = styled.div` + color: ${th('colorPrimary')}; + font-family: ${th('fontReading')}; + font-size: ${th('fontSizeHeading3')}; + line-height: ${th('lineHeightHeading3')}; + margin: 0 0 ${grid(3)} 0; +` + +export { Page, Heading } diff --git a/app/components/component-xpub-dashboard/CHANGELOG.md b/app/components/component-xpub-dashboard/CHANGELOG.md deleted file mode 100644 index 4e5da5db3d462328d7a536584b8ffc25ce401a85..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/CHANGELOG.md +++ /dev/null @@ -1,710 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [5.1.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.21...pubsweet-component-xpub-dashboard@5.1.0) (2019-11-11) - - -### Features - -* **xpub:** bring back xpub components ([fb69994](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/fb69994098b4e2dbcca75b4786ebb1335af730b9)) - - - - - -## [5.0.21](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.20...pubsweet-component-xpub-dashboard@5.0.21) (2019-09-11) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.20](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.19...pubsweet-component-xpub-dashboard@5.0.20) (2019-09-04) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.19](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.18...pubsweet-component-xpub-dashboard@5.0.19) (2019-08-30) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.18](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.17...pubsweet-component-xpub-dashboard@5.0.18) (2019-08-08) - - -### Bug Fixes - -* **styleguide:** fix status of teams to reviewerItem ([dd6722e](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/dd6722e)) - - - - - -## [5.0.17](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.16...pubsweet-component-xpub-dashboard@5.0.17) (2019-08-05) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.16](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.15...pubsweet-component-xpub-dashboard@5.0.16) (2019-07-12) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.15](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.14...pubsweet-component-xpub-dashboard@5.0.15) (2019-07-09) - - -### Bug Fixes - -* **ui:** remove attrs as objects deprecation warning ([19b20bc](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/19b20bc)) - - - - - -## [5.0.14](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.13...pubsweet-component-xpub-dashboard@5.0.14) (2019-07-03) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.13](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.12...pubsweet-component-xpub-dashboard@5.0.13) (2019-06-28) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.12](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.11...pubsweet-component-xpub-dashboard@5.0.12) (2019-06-24) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.11](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.10...pubsweet-component-xpub-dashboard@5.0.11) (2019-06-21) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.10](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.9...pubsweet-component-xpub-dashboard@5.0.10) (2019-06-13) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.9](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.8...pubsweet-component-xpub-dashboard@5.0.9) (2019-06-12) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.8](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.7...pubsweet-component-xpub-dashboard@5.0.8) (2019-05-27) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.6...pubsweet-component-xpub-dashboard@5.0.7) (2019-04-25) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.5...pubsweet-component-xpub-dashboard@5.0.6) (2019-04-18) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.4...pubsweet-component-xpub-dashboard@5.0.5) (2019-04-09) - - -### Bug Fixes - -* **xpub:** fix components in styleguide ([2db87cd](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/2db87cd)) - - - - - -## [5.0.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.3...pubsweet-component-xpub-dashboard@5.0.4) (2019-03-06) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.2...pubsweet-component-xpub-dashboard@5.0.3) (2019-03-05) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.1...pubsweet-component-xpub-dashboard@5.0.2) (2019-02-19) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [5.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@5.0.0...pubsweet-component-xpub-dashboard@5.0.1) (2019-02-19) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -# [5.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@4.0.7...pubsweet-component-xpub-dashboard@5.0.0) (2019-02-01) - - -### Bug Fixes - -* **styleguide:** temporarily disable styleguide ([e519ed1](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/e519ed1)) - - -### Code Refactoring - -* temporarily remove unmigrated components ([32db6ad](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/32db6ad)) - - -### BREAKING CHANGES - -* A lot of unmigrated (not yet moved from REST/Redux to GraphQL/Apollo system) bits -have changed. There might be some breaking changes as a result. This is a big migration involving -big changes - if you encounter anything weird, please contact us on GitLab or on Mattermost. - - - - - -## [4.0.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@4.0.6...pubsweet-component-xpub-dashboard@4.0.7) (2019-01-16) - - -### Bug Fixes - -* **components:** change back teams model to previous model ([a5eeae0](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/a5eeae0)) -* **components:** fixing components after new manuscript version ([89537ff](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/89537ff)) -* **components:** generals fixes on the components ([4a78cfe](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/4a78cfe)) -* **components:** graphql data model changes ([4b61093](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/4b61093)) -* **formik:** improve formik usage ([24b42ff](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/24b42ff)) -* **graphql:** review components fixes ([8094d9e](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/8094d9e)) -* **manuscript:** wax did not show ([80ae8c6](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/80ae8c6)) -* **test:** login tests ([438ab2e](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/438ab2e)) -* **xpub-review:** changes tp reviews ([5ae4240](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/5ae4240)) - - - - - -## [4.0.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@4.0.5...pubsweet-component-xpub-dashboard@4.0.6) (2019-01-14) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [4.0.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@4.0.4...pubsweet-component-xpub-dashboard@4.0.5) (2019-01-13) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [4.0.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@4.0.3...pubsweet-component-xpub-dashboard@4.0.4) (2019-01-09) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [4.0.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@4.0.2...pubsweet-component-xpub-dashboard@4.0.3) (2018-12-12) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [4.0.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@4.0.1...pubsweet-component-xpub-dashboard@4.0.2) (2018-12-04) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -## [4.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@4.0.0...pubsweet-component-xpub-dashboard@4.0.1) (2018-11-30) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - - - - - -# [4.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.1.0...pubsweet-component-xpub-dashboard@4.0.0) (2018-11-29) - - -### Features - -* **various:** update styled-components ([5c51466](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/5c51466)) -* **various:** upgrade styled-components ([9b886f6](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/9b886f6)) - - -### BREAKING CHANGES - -* **various:** Replace all styled-components .extend with styled() -* **various:** Replace styled-components injectGlobal with new createGlobalStyle - - - - - -<a name="3.1.0"></a> -# [3.1.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.15...pubsweet-component-xpub-dashboard@3.1.0) (2018-11-05) - - -### Features - -* GraphQL Login component ([70df3de](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/70df3de)) -* GraphQL Xpub review component ([66b3e73](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/66b3e73)) -* GraphQL Xpub submit component ([ba07060](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/ba07060)) - - - - -<a name="3.0.15"></a> -## [3.0.15](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.14...pubsweet-component-xpub-dashboard@3.0.15) (2018-10-08) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.14"></a> -## [3.0.14](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.13...pubsweet-component-xpub-dashboard@3.0.14) (2018-09-27) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.13"></a> -## [3.0.13](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.12...pubsweet-component-xpub-dashboard@3.0.13) (2018-09-25) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.12"></a> -## [3.0.12](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.11...pubsweet-component-xpub-dashboard@3.0.12) (2018-09-19) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.11"></a> -## [3.0.11](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.10...pubsweet-component-xpub-dashboard@3.0.11) (2018-09-06) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.10"></a> -## [3.0.10](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.9...pubsweet-component-xpub-dashboard@3.0.10) (2018-09-04) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.9"></a> -## [3.0.9](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.8...pubsweet-component-xpub-dashboard@3.0.9) (2018-08-20) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.8"></a> -## [3.0.8](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.7...pubsweet-component-xpub-dashboard@3.0.8) (2018-08-17) - - -### Bug Fixes - -* **actions:** pubsweet ui responsive ([b1cab9a](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/b1cab9a)) -* **actions:** validationStatus fix ([762432f](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/762432f)) -* **css:** fix responsiveness of actions ([9bff385](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/9bff385)) -* **revert:** valildateStatus ([5d6f53e](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/5d6f53e)) -* **style:** remove enter line ([e2de927](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/e2de927)) -* **style:** responsive line tool ([c3219ec](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/c3219ec)) -* **warnings:** don't pass every prop to Dom Element ([d8f5e93](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/d8f5e93)) -* **warnings:** key actions ([2f176f0](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/2f176f0)) -* **warnings:** naming changes ([e4727ad](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/e4727ad)) -* **warnings:** remove key from unneeded component ([2dda7a5](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/2dda7a5)) - - - - -<a name="3.0.7"></a> -## [3.0.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.6...pubsweet-component-xpub-dashboard@3.0.7) (2018-08-02) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.6"></a> -## [3.0.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.5...pubsweet-component-xpub-dashboard@3.0.6) (2018-07-27) - - -### Bug Fixes - -* **dashboard:** delete associated fragments ([f95c292](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/f95c292)) - - - - -<a name="3.0.5"></a> -## [3.0.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.4...pubsweet-component-xpub-dashboard@3.0.5) (2018-07-23) - - -### Bug Fixes - -* **dashboard:** add keys to dashboard ([38f73f7](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/38f73f7)) -* **dashobard:** add key to compoent ([bc76925](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/bc76925)) - - - - -<a name="3.0.4"></a> -## [3.0.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.3...pubsweet-component-xpub-dashboard@3.0.4) (2018-07-19) - - -### Bug Fixes - -* **dashboard:** fixing typo message upload ([3fec4ef](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/3fec4ef)) - - - - -<a name="3.0.3"></a> -## [3.0.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.2...pubsweet-component-xpub-dashboard@3.0.3) (2018-07-12) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.2"></a> -## [3.0.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.1...pubsweet-component-xpub-dashboard@3.0.2) (2018-07-09) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.1"></a> -## [3.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@3.0.0...pubsweet-component-xpub-dashboard@3.0.1) (2018-07-03) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="3.0.0"></a> -# [3.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@2.0.1...pubsweet-component-xpub-dashboard@3.0.0) (2018-07-02) - - -### Features - -* **ui:** introduce more line height variables ([85c24e2](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/85c24e2)) - - -### BREAKING CHANGES - -* **ui:** the existing fontLineHeight variable is gone and replaced by multiple new variables - - - - -<a name="2.0.1"></a> -## [2.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@2.0.0...pubsweet-component-xpub-dashboard@2.0.1) (2018-06-28) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="2.0.0"></a> -# [2.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@1.0.1...pubsweet-component-xpub-dashboard@2.0.0) (2018-06-28) - - -### Bug Fixes - -* **authorize:** add authorize to hide delete ([125a872](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/125a872)) -* **authsome:** update stucture of currentUpdate ([909b80f](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/909b80f)) -* **components:** prevent Delete when paper is submitted status ([b556e25](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/b556e25)) -* **dashboard:** make use of authorize ([ccc993c](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/ccc993c)) -* **dashboard:** mock authorize component ([198f95a](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/198f95a)) -* **styleguide:** correct require path ([79a2b07](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/79a2b07)) - - -### Code Refactoring - -* **ui:** replace current gridunit variables with one small value ([cf48f29](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/cf48f29)) - - -### BREAKING CHANGES - -* **ui:** Your ui components will now be multiplying a much smaller value so they need to be -adjusted - - - - -<a name="1.0.1"></a> -## [1.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@1.0.0...pubsweet-component-xpub-dashboard@1.0.1) (2018-06-19) - - -### Bug Fixes - -* **dashboard:** add actions to dashboard editorItem ([58733b6](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/58733b6)) -* **dashboard:** empty declaration object ([919bde4](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/919bde4)) -* **metadata:** empty values ([e6f55ea](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/e6f55ea)) -* **pubsweet-ui:** tests are failing ([0e57798](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/0e57798)) - - - - -<a name="1.0.0"></a> -# [1.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.3.2...pubsweet-component-xpub-dashboard@1.0.0) (2018-06-01) - - -### Bug Fixes - -* **components:** dasboard fixing multiple submissions ([01fa2f9](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/01fa2f9)) -* **dashboard:** empty dashboard collections ([3f4db98](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/3f4db98)) -* **dashboard:** remove regenerate import and add it to styleguide ([96731cf](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/96731cf)) -* **dashboard:** section hide on empty ([7a139ec](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/7a139ec)) -* **dashboard:** test change object dashboard ([906ccfd](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/906ccfd)) -* **styleguide:** compile authsome ([8e9407f](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/8e9407f)) -* **test:** dashboard - reviewer test ([30f41b3](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/30f41b3)) - - -### Features - -* **components:** add authsome to dashboard ([833a9de](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/833a9de)) -* **ui:** start ui-toolkit module ([2083b9c](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/2083b9c)) - - -### BREAKING CHANGES - -* **ui:** th now comes from the toolkit, so all th imports from ui are now broken - - - - -<a name="0.3.2"></a> -## [0.3.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.3.1...pubsweet-component-xpub-dashboard@0.3.2) (2018-05-21) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="0.3.1"></a> -## [0.3.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.3.0...pubsweet-component-xpub-dashboard@0.3.1) (2018-05-18) - - -### Bug Fixes - -* **components:** upload diasble during converting ([227b136](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/227b136)) - - - - -<a name="0.3.0"></a> -# [0.3.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.2.4...pubsweet-component-xpub-dashboard@0.3.0) (2018-05-10) - - -### Bug Fixes - -* **components:** dashboard if statment reject ([999587a](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/999587a)) -* **components:** linter ([9aac3fa](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/9aac3fa)) -* **components:** redirect submission add selectors ([53db5a7](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/53db5a7)) - - -### Features - -* **components:** create accordion component ([54f5b7d](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/54f5b7d)) - - - - -<a name="0.2.4"></a> -## [0.2.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.2.3...pubsweet-component-xpub-dashboard@0.2.4) (2018-05-09) - - -### Bug Fixes - -* **xpub-dash:** fix reviewer item crash when status is revision ([fc79496](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/fc79496)) - - - - -<a name="0.2.3"></a> -## [0.2.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.2.2...pubsweet-component-xpub-dashboard@0.2.3) (2018-05-03) - - -### Bug Fixes - -* **xpub-dashboard:** correct styles for author manuscripts ([1d8761e](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/1d8761e)) - - - - -<a name="0.2.2"></a> -## [0.2.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.2.1...pubsweet-component-xpub-dashboard@0.2.2) (2018-05-03) - - -### Bug Fixes - -* **components:** load all users to control panel ([90c88e6](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/90c88e6)) -* **components:** remove from Dashboard assign editor ([751a63e](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/751a63e)) - - - - -<a name="0.2.1"></a> -## [0.2.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.2.0...pubsweet-component-xpub-dashboard@0.2.1) (2018-04-24) - - -### Bug Fixes - -* **components:** add file streamlined data ([9dd6797](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/9dd6797)) -* **components:** add metadata StreamLined ([29a1fcd](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/29a1fcd)) -* **components:** add subinfo to upload ([446fc16](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/446fc16)) -* **components:** change order ([2020d49](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/2020d49)) -* **components:** change text to create submission button ([d3b6385](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/d3b6385)) -* **components:** statuses changed for revision ([3bc09dc](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/3bc09dc)) -* **dashboard:** change stremlined metadata label ([992cc4f](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/992cc4f)) - - - - -<a name="0.2.0"></a> -# [0.2.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.1.3...pubsweet-component-xpub-dashboard@0.2.0) (2018-04-11) - - -### Bug Fixes - -* **components:** change title styling ([3c154ba](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/3c154ba)) - - -### Features - -* **components:** add Link to control panel ([85458b9](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/85458b9)) -* **components:** fix import add link ([dfe4818](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/dfe4818)) - - - - -<a name="0.1.3"></a> -## [0.1.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.1.2...pubsweet-component-xpub-dashboard@0.1.3) (2018-04-03) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="0.1.2"></a> -## [0.1.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.1.1...pubsweet-component-xpub-dashboard@0.1.2) (2018-03-30) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="0.1.1"></a> -## [0.1.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.1.0...pubsweet-component-xpub-dashboard@0.1.1) (2018-03-28) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="0.1.0"></a> -# [0.1.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.0.5...pubsweet-component-xpub-dashboard@0.1.0) (2018-03-27) - - -### Features - -* **styleguide:** page per section ([0bf0836](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/0bf0836)) - - - - -<a name="0.0.5"></a> -## [0.0.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.0.4...pubsweet-component-xpub-dashboard@0.0.5) (2018-03-19) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="0.0.4"></a> -## [0.0.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-xpub-dashboard@0.0.3...pubsweet-component-xpub-dashboard@0.0.4) (2018-03-15) - - - - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard - -<a name="0.0.3"></a> - -## 0.0.3 (2018-03-09) - -**Note:** Version bump only for package pubsweet-component-xpub-dashboard diff --git a/app/components/component-xpub-dashboard/README.md b/app/components/component-xpub-dashboard/README.md deleted file mode 100644 index 39792fbc4378f69d84f69d6ff0ea1d3be35e516a..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## pubsweet-component-xpub-dashboard - -A PubSweet component that provides the xpub dashboard, listing submissions that are available for the current user to take action on. diff --git a/app/components/component-xpub-dashboard/src/components/Dashboard.integration.test.js b/app/components/component-xpub-dashboard/src/components/Dashboard.integration.test.js deleted file mode 100644 index a8ccfc0f7af44cb85bb66569c7228a2cfbada9dc..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/Dashboard.integration.test.js +++ /dev/null @@ -1,219 +0,0 @@ -// This test is very incomplete and doesn't actually test all that much. -// Consider throwing it out, and replacing it with actual end to end integration tests. - -import React from 'react' -import Enzyme, { mount } from 'enzyme' -import Adapter from 'enzyme-adapter-react-16' -import { MemoryRouter } from 'react-router-dom' -import { MockedProvider } from '@apollo/react-testing' -import { ThemeProvider } from 'styled-components' -import { JournalProvider } from 'xpub-journal' -import Dashboard from './Dashboard' -import queries from '../graphql/queries' -import { UploadContainer } from './molecules/Page' -import OwnerItem from './sections/OwnerItem' -import ReviewerItem from './sections/ReviewerItem' -import EditorItem from './sections/EditorItem' - -function waitABit() { - return new Promise(resolve => setTimeout(resolve, 500)) -} - -// this should be elsewhere -Enzyme.configure({ adapter: new Adapter() }) - -jest.mock('config', () => ({ - 'pubsweet-client': {}, - authsome: { - mode: 'authsome', - }, - 'pubsweet-component-xpub-dashboard': { - acceptUploadFiles: [ - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'application/x-latex', - 'text/vnd.latex-z', - 'text/x-tex', - 'application/pdf', - 'application/epub+zip', - 'application/zip', - ], - }, -})) - -jest.mock('pubsweet-client/src/helpers/Authorize', () => 'div') - -global.window.localStorage = { - getItem: jest.fn(() => 'tok123'), -} - -const journal = { - reviewStatus: ['invited', 'accepted', 'rejected', 'completed'], - articleTypes: [ - { - label: 'Original Research Report', - value: 'original-research', - }, - ], - articleSections: [ - { - label: 'Cognitive Psychology', - value: 'cognitive-psychology', - }, - ], -} - -const mockData = { - currentUser: { - id: '1', - username: 'test', - admin: true, - }, - journals: { - id: '2', - title: 'Test Journal', - manuscripts: [ - { - id: '3', - manuscriptVersions: [], - reviews: [ - { - open: null, - recommendation: 'accepted', - created: '2019-10-24T23:49:13.694Z', - isDecision: false, - user: { - id: '1', - username: 'test', - }, - }, - ], - teams: [ - { - id: '4', - role: 'author', - type: 'team', - name: 'Author', - object: { - objectId: '3', - objectType: 'Manuscript', - }, - members: [ - { - id: '5', - user: { - id: '1', - username: 'test', - }, - status: null, - }, - ], - }, - { - id: '6', - role: 'reviewerEditor', - type: 'team', - name: 'Reviewer Editor', - object: { - objectId: '3', - objectType: 'Manuscript', - }, - members: [ - { - id: '7', - user: { - id: '1', - username: 'test', - }, - status: 'completed', - }, - ], - }, - ], - status: 'submitted', - meta: { - title: 'Case report', - declarations: { - openData: 'No/Not Applicable', - openPeerReview: null, - preregistered: 'no', - previouslySubmitted: 'no', - researchNexus: null, - streamlinedReview: 'no', - }, - articleSections: null, - articleType: 'opinion', - history: null, - }, - }, - ], - }, -} - -const getProjects = item => item.map(c => c.props().version) - -describe('Dashboard', () => { - const makeWrapper = async (opts = {}) => { - const mocks = [ - { - request: { - query: queries.dashboard, - }, - result: { - data: JSON.parse(JSON.stringify(mockData)), - }, - }, - ] - - mocks[0].result.data.journals.manuscripts = opts.empty - ? [] - : mocks[0].result.data.journals.manuscripts - - const wrapper = mount( - <MemoryRouter> - <JournalProvider journal={journal}> - <ThemeProvider theme={{ colorPrimary: 'blue' }}> - <MockedProvider addTypename={false} mocks={mocks}> - <Dashboard conversion={{ converting: false }} /> - </MockedProvider> - </ThemeProvider> - </JournalProvider> - </MemoryRouter>, - ) - await waitABit() - wrapper.update() - return wrapper - } - - it('shows a message when there are no projects', async () => { - const dashboard = await makeWrapper({ empty: true }) - expect(dashboard.find(UploadContainer)).toHaveLength(2) - expect(dashboard.find(OwnerItem)).toHaveLength(0) - expect(dashboard.find(ReviewerItem)).toHaveLength(0) - }) - - it('shows a list of manuscripts submitted by the current user', async () => { - const dashboard = await makeWrapper({ empty: false }) - expect(dashboard.find('.empty')).toHaveLength(0) - const section = dashboard.find(OwnerItem) - expect(section).toHaveLength(1) - expect(getProjects(section)).toEqual([mockData.journals.manuscripts[0]]) - }) - - it('shows a list of manuscripts to be reviewed', async () => { - const dashboard = await makeWrapper({ empty: false }) - - expect(dashboard.find(UploadContainer)).toHaveLength(1) - const section = dashboard.find(ReviewerItem) - expect(section).toHaveLength(1) - expect(getProjects(section)).toEqual([mockData.journals.manuscripts[0]]) - }) - - it('shows a list of projects where the current user is the editor', async () => { - const dashboard = await makeWrapper({ empty: false }) - - expect(dashboard.find(UploadContainer)).toHaveLength(1) - const section = dashboard.find(EditorItem) - expect(section).toHaveLength(1) - expect(getProjects(section)).toEqual([mockData.journals.manuscripts[0]]) - }) -}) diff --git a/app/components/component-xpub-dashboard/src/components/Dashboard.js b/app/components/component-xpub-dashboard/src/components/Dashboard.js deleted file mode 100644 index 5129c5b105e356357801dd42af0f04030393fc6e..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/Dashboard.js +++ /dev/null @@ -1,162 +0,0 @@ -import React from 'react' -import { useQuery, useMutation, ApolloConsumer } from '@apollo/react-hooks' -import Authorize from 'pubsweet-client/src/helpers/Authorize' - -import config from 'config' -import queries from '../graphql/queries/' -import mutations from '../graphql/mutations/' -import { Page, Section, Heading, UploadContainer } from './molecules/Page' -import UploadManuscript from './UploadManuscript' -import EditorItem from './sections/EditorItem' -import OwnerItem from './sections/OwnerItem' -import ReviewerItem from './sections/ReviewerItem' - -const { acceptUploadFiles } = config['pubsweet-component-xpub-dashboard'] || {} - -const acceptFiles = - acceptUploadFiles.length > 0 - ? acceptUploadFiles.join() - : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' - -const updateReviewer = (proxy, { data: { reviewerResponse } }) => { - const id = reviewerResponse.object.objectId - const data = proxy.readQuery({ - query: queries.dashboard, - variables: { - id, - }, - }) - - const manuscriptIndex = data.manuscripts.findIndex(manu => manu.id === id) - const teamIndex = data.manuscripts[manuscriptIndex].teams.findIndex( - team => team.id === reviewerResponse.id, - ) - - data.manuscripts[manuscriptIndex].teams[teamIndex] = reviewerResponse - proxy.writeQuery({ query: queries.dashboard, data }) -} - -// export default compose( -// withProps(({ journals, currentUser }) => ({ -// dashboard: (journals || {}).manuscripts || [], -// journals, -// currentUser, -// acceptFiles, -// })), -// upload, -// )(Dashboard) - -const Dashboard = ({ - // acceptFiles, - // currentUser, // graphql - // dashboard, // graphql - // journals, // graphql - // deleteManuscript, // graphql - // reviewerResponse, // graphql - // uploadManuscript, // from compose - ...props -}) => { - // const uploadManuscript = upload() - - // const [conversion] = useContext(XpubContext) - - const { loading, data } = useQuery(queries.dashboard) - const dashboard = ((data && data.journals) || {}).manuscripts || [] - const journals = data && data.journals - const currentUser = data && data.currentUser - - const [reviewerRespond] = useMutation(mutations.reviewerResponseMutation, { - // variables: { currentUserId, action, teamId }, - update: updateReviewer, - }) - - const [deleteManuscript] = useMutation(mutations.deleteManuscriptMutation, { - // variables: { id: manuscript.id }, - update: (proxy, { data: { deleteManuscript } }) => { - const data = proxy.readQuery({ query: queries.dashboard }) - const manuscriptIndex = data.manuscripts.findIndex( - manuscript => manuscript.id === deleteManuscript, - ) - if (manuscriptIndex > -1) { - data.manuscripts.splice(manuscriptIndex, 1) - proxy.writeQuery({ query: queries.dashboard, data }) - } - }, - }) - - if (loading) return <div>Loading...</div> - - return ( - <Page> - <UploadContainer> - <ApolloConsumer> - {client => ( - <UploadManuscript - acceptFiles={acceptFiles} - client={client} - currentUser={currentUser} - history={props.history} - journals={journals} - /> - )} - </ApolloConsumer> - </UploadContainer> - - {!dashboard.length && ( - <UploadContainer>Nothing to do at the moment.</UploadContainer> - )} - {/* <Authorize object={dashboard} operation="can view my submission section"> */} - {dashboard.length > 0 ? ( - <Section> - <Heading>My Submissions</Heading> - {dashboard.map(submission => ( - <OwnerItem - deleteManuscript={() => - // eslint-disable-next-line no-alert - window.confirm( - 'Are you sure you want to delete this submission?', - ) && deleteManuscript({ variables: { id: submission.id } }) - } - journals={journals} - key={`submission-${submission.id}`} - version={submission} - /> - ))} - </Section> - ) : null} - {/* </Authorize> - <Authorize object={dashboard} operation="can view review section"> */} - {dashboard.length > 0 ? ( - <Section> - <Heading>To review</Heading> - {dashboard.map(review => ( - <ReviewerItem - currentUser={currentUser} - journals={journals} - key={review.id} - reviewerRespond={reviewerRespond} - version={review} - /> - ))} - </Section> - ) : null} - {/* </Authorize> */} - - {/* <Authorize object={dashboard} operation="can view my manuscripts section"> */} - {dashboard.length > 0 ? ( - <Section> - <Heading>My Manuscripts</Heading> - {dashboard.map(manuscript => ( - <EditorItem - journals={journals} - key={`manuscript-${manuscript.id}`} - version={manuscript} - /> - ))} - </Section> - ) : null} - {/* </Authorize> */} - </Page> - ) -} -export default Dashboard diff --git a/app/components/component-xpub-dashboard/src/components/JournalLink.md b/app/components/component-xpub-dashboard/src/components/JournalLink.md deleted file mode 100644 index d64f052eb75525831fee7c20577848bd38091f26..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/JournalLink.md +++ /dev/null @@ -1,31 +0,0 @@ -A link to a project, version, or page. - -```js -<JournalLink journal="foo">journal</JournalLink> -``` - -```js -<JournalLink journal="foo" version="bar"> - version -</JournalLink> -``` - -```js -<JournalLink journal="foo" version="bar" page="baz"> - page -</JournalLink> -``` - -```js -<JournalLink journal="foo" version="bar" page="baz" id={1}> - id -</JournalLink> -``` - -The project and/or version can be an object with an id. - -```js -<JournalLink journal={{ id: 'foo' }} version={{ id: 'bar' }}> - id -</JournalLink> -``` diff --git a/app/components/component-xpub-dashboard/src/components/UploadManuscript.js b/app/components/component-xpub-dashboard/src/components/UploadManuscript.js deleted file mode 100644 index ba74163ab32ffbf9bae4d5aaf7a9961e2c1a418d..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/UploadManuscript.js +++ /dev/null @@ -1,315 +0,0 @@ -import React, { useContext } from 'react' -import styled, { keyframes, withTheme } from 'styled-components' -import { XpubContext } from '../../../xpub-with-context' -import Dropzone from 'react-dropzone' -import { Icon } from '@pubsweet/ui' -import { th } from '@pubsweet/ui-toolkit' -import upload from '../upload' - -const StyledDropzone = styled(({ disableUpload, ...props }) => ( - <Dropzone {...props} /> -))` - border: none; - cursor: pointer; - display: inline-block; - ${({ disableUpload }) => disableUpload && 'pointer-events: none;'}; -` - -const StatusIcon = withTheme(({ children, theme }) => ( - <Icon color={theme.colorPrimary}>{children}</Icon> -)) - -const Status = styled.div` - align-items: center; - color: ${th('colorPrimary')}; - display: inline-flex; -` - -const StatusIdle = styled(Status).attrs(props => ({ - children: <StatusIcon>plus_circle</StatusIcon>, -}))`` - -const spin = keyframes` - 0% { - transform: rotate(0deg); - transform-origin: 50% 50%; - } - - 100% { - transform: rotate(360deg); - transform-origin: 50% 50%; - } -` - -const StatusConverting = styled(Status).attrs(props => ({ - children: <StatusIcon>plus_circle</StatusIcon>, -}))` - &:hover { - cursor: wait; - } - - line { - stroke-linejoin: round; - } - - circle { - animation: ${spin} 2s infinite linear; - stroke-dasharray: 16; - stroke-dashoffset: 0; - stroke-linejoin: round; - } -` - -const StatusError = styled(Status).attrs(props => ({ - children: <StatusIcon>plus_circle</StatusIcon>, -}))` - color: ${th('colorDanger')}; - font-size: 1.5em; - font-style: italic; - font-weight: 400; - - .icon circle { - display: none; - } - - .icon line { - stroke: ${th('colorDanger')}; - transform: rotate(45deg) scale(2.8); - transform-origin: 50% 50%; - } -` - -const dash = keyframes` - from { - stroke-dashoffset: -100; - } - - to { - stroke-dashoffset: 0; - } -` - -const StatusCompleted = styled(Status).attrs(props => ({ - children: <StatusIcon>check_circle</StatusIcon>, -}))` - polyline { - animation: ${dash} 1.35s linear; - stroke-dasharray: 100; - stroke-dashoffset: 0; - } - - path { - animation: ${dash} 0.75s linear; - stroke-dasharray: 100; - stroke-dashoffset: 0; - } -` - -const Root = styled.div` - display: flex; - flex-direction: column; - font-weight: 200; - padding-bottom: 10px; - padding-top: 10px; - - &:hover ${StatusIdle} { - circle { - fill: ${th('colorPrimary')}; - stroke: ${th('colorPrimary')}; - } - - line { - stroke: white; - } - } -` - -const Main = styled.div` - display: flex; - justify-content: center; - margin-left: 10px; -` - -const Error = styled.div` - color: ${th('colorDanger')}; - font-size: 1.5em; - font-style: italic; - font-weight: 400; -` - -const Info = styled.div` - color: ${th('colorPrimary')}; - font-size: 2em; - font-weight: 400; - text-transform: uppercase; -` - -const SubInfo = styled.div` - display: flex; - justify-content: center; - color: #333; - line-height: 32px; -` - -const UploadManuscript = ({ acceptFiles, ...props }) => { - // const [error, setError] = useState(false) - // const [completed, setCompleted] = useState(false) - const [conversion, setConversion] = useContext(XpubContext) - const { error, completed, converting } = conversion - - // const error = conversion.error - // const - // setConversion({ error: 'yes' }) - - const uploadManuscript = upload({ - client: props.client, - history: props.history, - journals: props.journals, - currentUser: props.currentUser, - setConversion, - }) - - // const status = completed - // ? 'completed' - // : error - // ? 'error' - // : conversion.converting - // ? 'converting' - // : 'idle' - - // if (!completed && !conversion.converting) { - // setCompleted(true) - // setError(false) - // } - - // Show and then hide the error/success state - if (error || completed) { - setTimeout(() => { - setConversion({}) - }, 3000) - } - - return ( - <StyledDropzone - accept={acceptFiles} - data-testid="dropzone" - disableUpload={converting ? 'disableUpload' : null} - onDrop={uploadManuscript} - > - {({ getRootProps, getInputProps }) => ( - <Root {...getRootProps()}> - <Main> - <input {...getInputProps()} /> - {completed && <StatusCompleted />} - {error && <StatusError />} - {converting && <StatusConverting />} - {!converting && !error && !completed && <StatusIdle />} - {error ? ( - <Error>{error.message}</Error> - ) : ( - <Info> - {completed ? 'Submission created' : 'Submit Manuscript'} - </Info> - )} - </Main> - <SubInfo> - {converting && - 'Your manuscript is being converted into a directly editable version. This might take a few seconds.'} - {!converting && 'Accepted file types: pdf, epub, zip, docx, latex'} - </SubInfo> - </Root> - )} - </StyledDropzone> - ) -} - -export default UploadManuscript - -// class UploadManuscript extends Component { - -// constructor(props) { -// super(props) -// this.state = { -// completed: false, -// error: false, -// } -// this.showErrorAndHide = this.showErrorAndHide.bind(this) -// } - -// getDerivedPropsFromState(props, state) { -// if (!state.completed && !props.conversion.converting) { -// this.setState({ -// completed: true, -// error: false, -// }) -// } - -// if (props.conversion.error) { -// this.showErrorAndHide() -// } -// } - -// showErrorAndHide() { -// this.setState({ -// error: true, -// completed: false, -// }) -// setTimeout(() => { -// this.setState({ -// error: false, -// completed: false, -// }) -// }, 3000) -// } - -// get status() { -// if (this.state.completed) { -// return 'completed' -// } -// if (this.state.error) { -// return 'error' -// } -// if (this.props.conversion.converting) { -// return 'converting' -// } -// return 'idle' -// } - -// render() { -// const { acceptFiles, uploadManuscript, conversion } = this.props - -// return ( -// <StyledDropzone -// accept={acceptFiles} -// disableUpload={this.status === 'converting' ? 'disableUpload' : null} -// onDrop={uploadManuscript} -// > -// <Root> -// <Main> -// {this.status === 'completed' && <StatusCompleted />} -// {this.status === 'error' && <StatusError />} -// {this.status === 'converting' && <StatusConverting />} -// {this.status === 'idle' && <StatusIdle />} -// {this.state.error ? ( -// <Error>{conversion.error.message}</Error> -// ) : ( -// <Info> -// {this.state.completed -// ? 'Submission created' -// : 'Submit Manuscript'} -// </Info> -// )} -// </Main> -// <SubInfo> -// {this.status === 'converting' && -// 'Your manuscript is being converted into a directly editable version. This might take a while.'} -// {this.status !== 'converting' && -// 'Accepted file types: pdf, epub, zip, docx, latex'} -// </SubInfo> -// </Root> -// </StyledDropzone> -// ) -// } -// } - -// export default UploadManuscript diff --git a/app/components/component-xpub-dashboard/src/components/UploadManuscript.md b/app/components/component-xpub-dashboard/src/components/UploadManuscript.md deleted file mode 100644 index bd968c7e0441d2b00d837a9010d8c1aacaf98231..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/UploadManuscript.md +++ /dev/null @@ -1,38 +0,0 @@ -A button for uploading a manuscript (DOCX) file to start a submission. - -```js -const conversion = { - converting: false, -} -;<UploadManuscript conversion={conversion} /> -``` - -While the manuscript is converting, a spinner is displayed. - -```js -const conversion = { - converting: true, -} -;<UploadManuscript conversion={conversion} /> -``` - -When the manuscript is complete, the icon changes and a message can be displayed. - -```js -const conversion = { - complete: true, - message: 'Submission created', -} -;<UploadManuscript conversion={conversion} /> -``` - -If there is a conversion error, a error message is displayed. - -```js -const conversion = { - error: { - message: 'There was an error', - }, -} -;<UploadManuscript conversion={conversion} /> -``` diff --git a/app/components/component-xpub-dashboard/src/components/molecules/Actions.js b/app/components/component-xpub-dashboard/src/components/molecules/Actions.js deleted file mode 100644 index 86cddd311d29363aa9c931c8ab58e82ff3b433fc..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/molecules/Actions.js +++ /dev/null @@ -1,11 +0,0 @@ -import styled from 'styled-components' - -// TODO -- why two divs? - -const Actions = styled.div`` - -const ActionContainer = styled.div` - display: inline-block; -` - -export { Actions, ActionContainer } diff --git a/app/components/component-xpub-dashboard/src/components/molecules/Item.js b/app/components/component-xpub-dashboard/src/components/molecules/Item.js deleted file mode 100644 index c8dc3de553558ac3ac1476678bba195cc459433a..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/molecules/Item.js +++ /dev/null @@ -1,33 +0,0 @@ -import styled from 'styled-components' -import { th } from '@pubsweet/ui-toolkit' - -const Item = styled.div` - margin-bottom: calc(${th('gridUnit') * 4}); -` - -const Header = styled.div` - align-items: baseline; - display: flex; - justify-content: space-between; - text-transform: uppercase; -` - -const Body = styled.div` - align-items: space-between; - display: flex; - justify-content: space-between; - margin-bottom: calc(${th('gridUnit')} * 4); - padding-left: 1.5em; - & > div:last-child { - flex-shrink: 0; - } -` - -const Divider = styled.span.attrs(props => ({ - children: ` ${props.separator} `, -}))` - color: ${th('colorFurniture')}; - white-space: pre; -` - -export { Item, Header, Body, Divider } diff --git a/app/components/component-xpub-dashboard/src/components/molecules/Links.js b/app/components/component-xpub-dashboard/src/components/molecules/Links.js deleted file mode 100644 index 20508f6a5d53e3b67004e0c6aba65fecc74eb40d..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/molecules/Links.js +++ /dev/null @@ -1,15 +0,0 @@ -import styled from 'styled-components' -import { th } from '@pubsweet/ui-toolkit' - -const Links = styled.div` - align-items: flex-end; - display: flex; - justify-content: bottom; -` - -const LinkContainer = styled.div` - font-size: ${th('fontSizeBaseSmall')}; - line-height: ${th('lineHeightBaseSmall')}; -` - -export { Links, LinkContainer } diff --git a/app/components/component-xpub-dashboard/src/components/molecules/Page.js b/app/components/component-xpub-dashboard/src/components/molecules/Page.js deleted file mode 100644 index a6152a0b94a2a112e1c1dac9531dad3abeb81e71..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/molecules/Page.js +++ /dev/null @@ -1,30 +0,0 @@ -import styled from 'styled-components' -import { th, grid } from '@pubsweet/ui-toolkit' - -const Page = styled.div` - padding: ${grid(2)}; -` - -const Section = styled.div` - margin: ${grid(3)} 0; - - &:not(:last-of-type) { - margin-bottom: ${grid(6)}; - } -` - -const Heading = styled.div` - color: ${th('colorPrimary')}; - font-family: ${th('fontReading')}; - font-size: ${th('fontSizeHeading3')}; - line-height: ${th('lineHeightHeading3')}; - margin: ${grid(3)} 0; - text-transform: uppercase; -` - -const UploadContainer = styled.div` - display: flex; - justify-content: center; -` - -export { Page, Section, Heading, UploadContainer } diff --git a/app/components/component-xpub-dashboard/src/components/sections/EditorItem.md b/app/components/component-xpub-dashboard/src/components/sections/EditorItem.md deleted file mode 100644 index de3cc04f49041a4151e7815e3e28354f4eaa0e93..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/sections/EditorItem.md +++ /dev/null @@ -1,59 +0,0 @@ -A dashboard item showing a project that the current user is handling as editor. - -```js -const { JournalProvider } = require('xpub-journal') -const { MockedProvider } = require('@apollo/react-testing') -const journal = require('@pubsweet/styleguide/config/journal') -const queries = require('../../graphql/queries') -const gql = require('graphql-tag') - -const mocks = [ - { - request: { - query: gql` - query CurrentUser { - currentUser { - admin - id - username - } - } - `, - }, - result: { - data: { - currentUser: { id: faker.random.uuid(), username: 'test', admin: true }, - }, - }, - }, -] - -const journals = { - id: faker.random.uuid(), - title: faker.lorem.sentence(15), - fragments: [faker.random.uuid()], -} - -const version = { - id: faker.random.uuid(), - status: 'submitted', - meta: { - title: faker.lorem.sentence(10), - articleType: 'original-research', - articleSection: ['cognitive-psychology'], - declarations: { - streamlinedReview: 'yes', - openPeerReview: 'yes', - }, - }, - reviews: [ - { - id: faker.random.uuid(), - user: {}, - }, - ], -} -;<JournalProvider journal={journal}> - <EditorItem journals={journals} version={version} /> -</JournalProvider> -``` diff --git a/app/components/component-xpub-dashboard/src/components/sections/EditorItem.test.js b/app/components/component-xpub-dashboard/src/components/sections/EditorItem.test.js deleted file mode 100644 index c7b6080cc6aea3792d975d6ec968f904060cca27..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/sections/EditorItem.test.js +++ /dev/null @@ -1,169 +0,0 @@ -import React from 'react' -import Enzyme, { mount } from 'enzyme' -import { MemoryRouter } from 'react-router-dom' -import Adapter from 'enzyme-adapter-react-16' -import faker from 'faker' -import { JournalProvider } from 'xpub-journal' -import { ThemeProvider } from 'styled-components' -import EditorItem from './EditorItem' - -import MetadataAuthors from '../metadata/MetadataAuthors' -import MetadataStreamLined from '../metadata/MetadataStreamLined' -import MetadataSubmittedDate from '../metadata/MetadataSubmittedDate' -import MetadataType from '../metadata/MetadataType' -import MetadataSections from '../metadata/MetadataSections' -import MetadataReviewType from '../metadata/MetadataReviewType' - -// this should be elsewhere -Enzyme.configure({ adapter: new Adapter() }) - -jest.mock('config', () => ({ - 'pubsweet-client': {}, - authsome: { - mode: 'authsome', - }, -})) - -jest.mock('pubsweet-client/src/helpers/Authorize', () => 'div') - -const journal = { - reviewStatus: ['invited', 'accepted', 'rejected', 'completed'], - articleTypes: [ - { - label: 'Original Research Report', - value: 'original-research', - }, - ], - articleSections: [ - { - label: 'Cognitive Psychology', - value: 'cognitive-psychology', - }, - ], -} - -describe('EditorItem', () => { - const makeWrapper = (props = {}) => { - props = Object.assign( - { - version: { - id: faker.random.uuid(), - created: '2018-06-07', - teams: [], - reviews: [], - status: props.status, - meta: { - history: [ - { - type: 'submitted', - date: '2018-06-07', - }, - ], - }, - }, - journals: { - id: faker.random.uuid(), - title: faker.lorem.sentence(15), - }, - }, - props, - ) - return mount( - <MemoryRouter> - <ThemeProvider theme={{}}> - <JournalProvider journal={journal}> - <EditorItem {...props} /> - </JournalProvider> - </ThemeProvider> - </MemoryRouter>, - ) - } - - it('shows empty metadata', () => { - const EditorItem = makeWrapper() - expect(EditorItem.find(MetadataStreamLined).children()).toHaveLength(0) - expect(EditorItem.find(MetadataAuthors).children()).toHaveLength(0) - expect(EditorItem.find(MetadataSections).children()).toHaveLength(0) - expect( - EditorItem.find(MetadataSubmittedDate) - .children() - .text(), - ).toEqual('2018-06-07') - expect( - EditorItem.find(MetadataType) - .children() - .text(), - ).toEqual('None') - expect( - EditorItem.find(MetadataReviewType) - .children() - .text(), - ).toEqual('Closed review') - }) - - it('shows all metadata', () => { - const username = faker.name.findName() - const EditorItem = makeWrapper({ - version: { - teams: [ - { - created: '2018-06-07', - members: [ - { - user: { - id: faker.random.uuid(), - created: '2018-06-07', - username, - admin: true, - }, - }, - ], - teamType: 'author', - }, - ], - meta: { - articleType: 'original-research', - articleSections: ['cognitive-psychology'], - declarations: { - openPeerReview: 'yes', - streamlinedReview: 'yes', - }, - history: [ - { - type: 'submitted', - date: '2018-06-07', - }, - ], - }, - }, - }) - - expect(EditorItem.find(MetadataStreamLined).text()).toEqual('Streamlined') - expect( - EditorItem.find(MetadataAuthors) - .children() - .text(), - ).toEqual(username) - - expect( - EditorItem.find(MetadataSections) - .children() - .text(), - ).toEqual(journal.articleSections[0].label) - expect( - EditorItem.find(MetadataSubmittedDate) - .children() - .text(), - ).toEqual('2018-06-07') - expect( - EditorItem.find(MetadataType) - .children() - .text(), - ).toEqual(journal.articleTypes[0].label) - expect( - EditorItem.find(MetadataReviewType) - .children() - .text(), - ).toEqual('Open review') - }) -}) diff --git a/app/components/component-xpub-dashboard/src/components/sections/OwnerItem.md b/app/components/component-xpub-dashboard/src/components/sections/OwnerItem.md deleted file mode 100644 index 5476e35f7e9af50e51839ec53dced18fb41d5b69..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/sections/OwnerItem.md +++ /dev/null @@ -1,23 +0,0 @@ -A dashboard item showing a project that the current user is an owner of. - -```js -const journal = require('@pubsweet/styleguide/config/journal') - -const journals = { - id: faker.random.uuid(), - title: faker.lorem.sentence(15), - manuscripts: [faker.random.uuid()], -} - -const version = { - id: faker.random.uuid(), - meta: { - title: faker.lorem.sentence(10), - }, -} -;<OwnerItem - journals={journals} - version={version} - deleteManuscript={props => console.log(props)} -/> -``` diff --git a/app/components/component-xpub-dashboard/src/components/sections/ReviewerItem.md b/app/components/component-xpub-dashboard/src/components/sections/ReviewerItem.md deleted file mode 100644 index d0f88812dcec54c474bea516b705130738c823d6..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/components/sections/ReviewerItem.md +++ /dev/null @@ -1,128 +0,0 @@ -A dashboard item showing a project that the current user is a reviewer of. - -```js -const currentUserId = 1 - -const currentUser = { - id: currentUserId, - username: faker.lorem.word(), -} - -const version = { - meta: { - title: faker.lorem.sentence(10), - }, - id: faker.random.uuid(), - reviews: [ - { - id: faker.random.uuid(), - recommedation: 'review', - }, - ], - teams: [ - { - created: new Date().toDateString(), - updated: new Date().toDateString(), - status: [ - { - user: currentUser.id, - status: 'invited', - }, - ], - members: [ - { - user: currentUser, - }, - ], - teamType: 'reviewerEditor', - }, - ], -} -;<ReviewerItem version={version} currentUser={currentUser} /> -``` - -When the reviewer has accepted the invitation to review, a link to perform their review is displayed. - -```js -const currentUserId = 1 - -const currentUser = { - id: currentUserId, -} - -const version = { - id: faker.random.uuid(), - meta: { - title: faker.lorem.sentence(10), - }, - reviews: [ - { - id: faker.random.uuid(), - recommedation: 'review', - }, - ], - teams: [ - { - created: new Date().toDateString(), - updated: new Date().toDateString(), - status: [ - { - user: currentUser.id, - status: 'accepted', - }, - ], - members: [ - { - user: currentUser, - status: 'accepted', - }, - ], - teamType: 'reviewerEditor', - }, - ], -} -;<ReviewerItem version={version} currentUser={currentUser} /> -``` - -When the reviewer has declined the invitation to review, they can't perform any further actions. - -```js -const currentUserId = 1 - -const currentUser = { - id: currentUserId, -} - -const version = { - meta: { - title: faker.lorem.sentence(10), - }, - id: faker.random.uuid(), - reviews: [ - { - id: faker.random.uuid(), - recommedation: 'review', - }, - ], - teams: [ - { - created: new Date().toDateString(), - updated: new Date().toDateString(), - status: [ - { - user: currentUser.id, - status: 'rejected', - }, - ], - members: [ - { - user: currentUser, - status: 'rejected', - }, - ], - teamType: 'reviewerEditor', - }, - ], -} -;<ReviewerItem version={version} currentUser={currentUser} /> -``` diff --git a/app/components/component-xpub-dashboard/src/title.js b/app/components/component-xpub-dashboard/src/title.js deleted file mode 100644 index 7aae47d80f251b4a25f856dc77739ca626d280a9..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/title.js +++ /dev/null @@ -1,12 +0,0 @@ -export const generateTitle = name => - name - .replace(/[_-]+/g, ' ') // convert hyphens/underscores to space - .replace(/\.[^.]+$/, '') // remove file extension - -// TODO: preserve italics (use parse5?) -export const extractTitle = source => { - const doc = new DOMParser().parseFromString(source, 'text/html') - const heading = doc.querySelector('h1') - - return heading ? heading.textContent : null -} diff --git a/app/components/component-xpub-dashboard/src/upload.js b/app/components/component-xpub-dashboard/src/upload.js deleted file mode 100644 index e616c85a0fc14dfe8e9e5d7b4b16f196e136cdfe..0000000000000000000000000000000000000000 --- a/app/components/component-xpub-dashboard/src/upload.js +++ /dev/null @@ -1,126 +0,0 @@ -// import { compose, withProps } from 'recompose' -// import { withRouter } from 'react-router-dom' -// import { withApollo } from '@apollo/react-hoc' -import config from 'config' -import request from 'pubsweet-client/src/helpers/api' -import queries from './graphql/queries' -import mutations from './graphql/mutations' -import { extractTitle, generateTitle } from './title' -// import { XpubContext } from 'xpub-with-context' -// import { useContext } from 'react' - -const uploadPromise = (files, client) => () => { - const [file] = files - if (files.length > 1) { - throw new Error('Only one manuscript file can be uploaded') - } - - return client.mutate({ - mutation: mutations.uploadManuscriptMutation, - variables: { file }, - }) -} - -const DocxToHTMLPromise = file => ({ data }) => { - const body = new FormData() - body.append('docx', file) - - const url = `${config['pubsweet-client'].baseUrl}/convertDocxToHTML` - - return request(url, { method: 'POST', body }).then(response => - Promise.resolve({ - fileURL: data.upload.url, - response, - }), - ) -} - -const createManuscriptPromise = (file, client, currentUser) => ({ - fileURL, - response, -}) => { - // In the case of a Docx file, response is the HTML - // In the case of another type of file, response is true/false - if (!response) { - throw new Error('The file was not converted') - } - - const source = typeof response === 'string' ? response : undefined - const title = extractTitle(response) || generateTitle(file.name) - - const manuscript = { - files: [ - { - filename: file.name, - url: fileURL, - mimeType: file.type, - size: file.size, - }, - ], - meta: { - title, - source, - }, - } - - return client.mutate({ - mutation: mutations.createManuscriptMutation, - variables: { input: manuscript }, - update: (proxy, { data: { createManuscript } }) => { - let data = proxy.readQuery({ query: queries.dashboard }) - data.manuscripts.push(createManuscript) - proxy.writeQuery({ query: queries.dashboard, data }) - - data = proxy.readQuery({ - query: queries.getUser, - variables: { id: currentUser.id }, - }) - data.user.teams.push(createManuscript.teams[0]) - proxy.writeQuery({ query: queries.getUser, data }) - }, - }) -} - -const redirectPromise = (setConversionState, journals, history) => ({ - data, -}) => { - setConversionState(() => ({ converting: false, completed: true })) - const route = `/journal/versions/${data.createManuscript.id}/submit` - // redirect after a short delay - window.setTimeout(() => { - history.push(route) - }, 2000) -} - -const skipXSweet = file => - !( - file.type === - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' - ) - -export default ({ - client, - history, - journals, - currentUser, - setConversion, -}) => files => { - const [file] = files - setConversion({ converting: true }) - return Promise.resolve() - .then(uploadPromise(files, client)) - .then( - skipXSweet(file) - ? ({ data }) => - Promise.resolve({ - fileURL: data.upload.url, - response: true, - }) - : DocxToHTMLPromise(file), - ) - .then(createManuscriptPromise(file, client, currentUser)) - .then(redirectPromise(setConversion, journals, history)) - .catch(error => { - setConversion({ error }) - }) -} diff --git a/app/components/shared/General.js b/app/components/shared/General.js new file mode 100644 index 0000000000000000000000000000000000000000..b7526acb101433e5bb84f8ee6e2bb9174ceda54c --- /dev/null +++ b/app/components/shared/General.js @@ -0,0 +1,10 @@ +import styled from 'styled-components' +import { grid } from '@pubsweet/ui-toolkit' + +export const Section = styled.div` + padding: ${grid(2)} ${grid(3)}; + margin-top: ${grid(3)}; + &:not(:last-of-type) { + margin-bottom: ${grid(6)}; + } +`