diff --git a/app/components/MainPage.js b/app/components/MainPage.js index abb49df47782a41520477db80dcec9b3b5a8b436..e10a5d5fa3d9ccb2ff69ffed922e9f38daa8f1ee 100644 --- a/app/components/MainPage.js +++ b/app/components/MainPage.js @@ -59,7 +59,7 @@ const App = ({ authorized, children, history, match }) => { const currentUser = data && data.currentUser const { pathname } = history.location - const showLinks = pathname.match(/submit|manuscript/g) + const showLinks = pathname.match(/^\/(submit|manuscript)/g) let links = [] const formBuilderLink = `/admin/form-builder` const profileLink = `/profile` @@ -86,6 +86,7 @@ const App = ({ authorized, children, history, match }) => { links.push(NavLink({ link: '/teams', name: 'Teams' })) links.push(NavLink({ link: formBuilderLink, name: 'Forms' })) links.push(NavLink({ link: '/admin/users', name: 'Users' })) + links.push(NavLink({ link: '/admin/manuscripts', name: 'Manuscripts' })) } return ( diff --git a/app/components/component-manuscripts/CHANGELOG.md b/app/components/component-manuscripts/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..8918f355c608a16d8bdcc90333d7c08db3f840b1 --- /dev/null +++ b/app/components/component-manuscripts/CHANGELOG.md @@ -0,0 +1,373 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [3.1.10](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.9...pubsweet-component-users-manager@3.1.10) (2020-05-13) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.9](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.8...pubsweet-component-users-manager@3.1.9) (2020-04-24) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.8](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.7...pubsweet-component-users-manager@3.1.8) (2020-04-06) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.6...pubsweet-component-users-manager@3.1.7) (2020-03-16) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.5...pubsweet-component-users-manager@3.1.6) (2020-03-04) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.4...pubsweet-component-users-manager@3.1.5) (2020-02-28) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.3...pubsweet-component-users-manager@3.1.4) (2020-02-26) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.2...pubsweet-component-users-manager@3.1.3) (2020-01-29) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.1...pubsweet-component-users-manager@3.1.2) (2020-01-23) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.1.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.1.0...pubsweet-component-users-manager@3.1.1) (2019-12-11) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +# [3.1.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.21...pubsweet-component-users-manager@3.1.0) (2019-11-11) + + +### Features + +* **xpub:** bring back xpub components ([fb69994](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/fb69994098b4e2dbcca75b4786ebb1335af730b9)) + + + + + +## [3.0.21](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.20...pubsweet-component-users-manager@3.0.21) (2019-09-11) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.20](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.19...pubsweet-component-users-manager@3.0.20) (2019-09-04) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.19](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.18...pubsweet-component-users-manager@3.0.19) (2019-08-30) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.18](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.17...pubsweet-component-users-manager@3.0.18) (2019-08-08) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.17](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.16...pubsweet-component-users-manager@3.0.17) (2019-08-05) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.16](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.15...pubsweet-component-users-manager@3.0.16) (2019-07-12) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.15](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.14...pubsweet-component-users-manager@3.0.15) (2019-07-09) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.14](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.13...pubsweet-component-users-manager@3.0.14) (2019-07-03) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.13](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.12...pubsweet-component-users-manager@3.0.13) (2019-06-28) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.12](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.11...pubsweet-component-users-manager@3.0.12) (2019-06-24) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.11](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.10...pubsweet-component-users-manager@3.0.11) (2019-06-21) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.10](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.9...pubsweet-component-users-manager@3.0.10) (2019-06-13) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.9](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.8...pubsweet-component-users-manager@3.0.9) (2019-06-12) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.8](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.7...pubsweet-component-users-manager@3.0.8) (2019-05-27) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.6...pubsweet-component-users-manager@3.0.7) (2019-04-25) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.5...pubsweet-component-users-manager@3.0.6) (2019-04-18) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.4...pubsweet-component-users-manager@3.0.5) (2019-04-09) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.3...pubsweet-component-users-manager@3.0.4) (2019-03-06) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.2...pubsweet-component-users-manager@3.0.3) (2019-03-05) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.1...pubsweet-component-users-manager@3.0.2) (2019-02-19) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [3.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@3.0.0...pubsweet-component-users-manager@3.0.1) (2019-02-19) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +# [3.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@2.0.6...pubsweet-component-users-manager@3.0.0) (2019-02-01) + + +### Code Refactoring + +* temporarily remove unmigrated components ([32db6ad](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/32db6ad)) + + +### Features + +* **users-manager:** migrate to GraphQL ([fa54414](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/fa54414)) +* very basic backend/working users manager ([b3c06b6](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/b3c06b6)) + + +### 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. +* **users-manager:** No longer uses the REST endpoints or the Redux functinality on the client-side, +it's purely GraphQL-based. + + + + + +## [2.0.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@2.0.5...pubsweet-component-users-manager@2.0.6) (2019-01-16) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [2.0.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@2.0.4...pubsweet-component-users-manager@2.0.5) (2019-01-14) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [2.0.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@2.0.3...pubsweet-component-users-manager@2.0.4) (2019-01-13) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [2.0.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@2.0.2...pubsweet-component-users-manager@2.0.3) (2019-01-09) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +## [2.0.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@2.0.1...pubsweet-component-users-manager@2.0.2) (2018-12-12) + +**Note:** Version bump only for package pubsweet-component-users-manager + + + + + +<a name="2.0.1"></a> +## [2.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@2.0.0...pubsweet-component-users-manager@2.0.1) (2018-04-03) + + + + +**Note:** Version bump only for package pubsweet-component-users-manager + +<a name="2.0.0"></a> +# [2.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@1.0.1...pubsweet-component-users-manager@2.0.0) (2018-03-30) + + +### Features + +* **components:** remove react-bootstrap ([e66c933](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/e66c933)) +* **users-manager:** add support for removing members ([bb06148](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/bb06148)) +* **users-manager:** add way to add global teams ([9bbccab](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/9bbccab)) + + +### BREAKING CHANGES + +* **users-manager:** Depends on a validation change for teamType -> string, and additionally, a validation change where team's objects are no longer required. + + + + +<a name="1.0.1"></a> + +## [1.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@1.0.0...pubsweet-component-users-manager@1.0.1) (2018-02-16) + +**Note:** Version bump only for package pubsweet-component-users-manager + +<a name="1.0.0"></a> + +# [1.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-users-manager@0.2.3...pubsweet-component-users-manager@1.0.0) (2018-02-02) + +### Features + +* **client:** upgrade React to version 16 ([626cf59](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/626cf59)), closes [#65](https://gitlab.coko.foundation/pubsweet/pubsweet/issues/65) + +### BREAKING CHANGES + +* **client:** Upgrade React to version 16 diff --git a/app/components/component-manuscripts/LICENSE b/app/components/component-manuscripts/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..ddc2703187220d48da45bd4e40313e9f8de2b728 --- /dev/null +++ b/app/components/component-manuscripts/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2018 Adam Hyde + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/app/components/component-manuscripts/package.json b/app/components/component-manuscripts/package.json new file mode 100644 index 0000000000000000000000000000000000000000..52a4ce39991a9f954c7d10007284dde1c346452a --- /dev/null +++ b/app/components/component-manuscripts/package.json @@ -0,0 +1,26 @@ +{ + "name": "pubsweet-component-users-manager", + "version": "3.1.10", + "description": "Basic navigation bar component for PubSweet", + "main": "src/Manuscripts.jsx", + "author": "Collaborative Knowledge Foundation", + "license": "MIT", + "dependencies": { + "@pubsweet/ui": "^12.5.0", + "prop-types": "^15.5.10", + "recompose": "^0.30.0" + }, + "peerDependencies": { + "@apollo/react-components": "^3.0.1", + "@apollo/react-hoc": "^3.0.1", + "config": "^3.0.1", + "graphql-tag": ">=2.10.0", + "pubsweet-client": ">=1.0.0", + "react": ">=16.9" + }, + "repository": { + "type": "git", + "url": "https://gitlab.coko.foundation/pubsweet/pubsweet" + }, + "gitHead": "7de26ece1265898482ecd7f0e33961a55e8fccba" +} diff --git a/app/components/component-manuscripts/src/Manuscript.jsx b/app/components/component-manuscripts/src/Manuscript.jsx new file mode 100644 index 0000000000000000000000000000000000000000..ca00bf445ae732ef7fb457eb0e9442fe01db232a --- /dev/null +++ b/app/components/component-manuscripts/src/Manuscript.jsx @@ -0,0 +1,64 @@ +import React from 'react' +import gql from 'graphql-tag' +import { useMutation } from '@apollo/react-hooks' +import { Action } from '@pubsweet/ui' +import { UserAvatar } from '../../component-avatar/src' +import { + Row, + Cell, + LastCell, + UserCombo, + Primary, + Secondary, + UserInfo, + SuccessStatus, + ErrorStatus, + NormalStatus +} from './style' +import { convertTimestampToDate } from '../../../shared/time-formatting' + +const DELETE_MANUSCRIPT = gql` + mutation($id: ID) { + deleteManuscript(id: $id) { + id + } + } +` + + +const Status = ({status}) => { + if (status === 'accepted') { + return <SuccessStatus>{status}</SuccessStatus> + } else if (status === 'rejected') { + return <ErrorStatus>{status}</ErrorStatus> + } + return <NormalStatus>{status}</NormalStatus> +} + +const User = ({ manuscript }) => { + const [deleteManuscript] = useMutation(DELETE_MANUSCRIPT) + + return ( + <Row> + <Cell> + { manuscript.meta && manuscript.meta.title } + {/* <UserCombo> + <UserAvatar manuscript={manuscript} /> + <UserInfo> + <Primary>{manuscript.username}</Primary> + <Secondary>{manuscript.email || '(via ORCID)'}</Secondary> + </UserInfo> + </UserCombo> */} + </Cell> + <Cell>{convertTimestampToDate(manuscript.created)}</Cell> + <Cell><Status status={manuscript.status}/></Cell> + <LastCell> + <Action onClick={() => deleteManuscript({ variables: { id: manuscript.id } })}> + Delete + </Action> + </LastCell> + </Row> + ) +} + +export default User diff --git a/app/components/component-manuscripts/src/Manuscripts.jsx b/app/components/component-manuscripts/src/Manuscripts.jsx new file mode 100644 index 0000000000000000000000000000000000000000..8bb982aa4fdabf7fad784f8aa7ceff04f96ec965 --- /dev/null +++ b/app/components/component-manuscripts/src/Manuscripts.jsx @@ -0,0 +1,146 @@ +import React, { useState } from 'react' +import gql from 'graphql-tag' +import { useQuery } from '@apollo/react-hooks' +import { Heading } from '@pubsweet/ui' + +import Manuscript from './Manuscript' +import { Container, Table, Header, Caret, Carets } from './style' +import Spinner from '../../shared/Spinner' +import Pagination from '../../shared/Pagination' + +const GET_MANUSCRIPTS = gql` + query Manuscripts( + $sort: String + $filter: ManuscriptsFilter + $offset: Int + $limit: Int + ) { + paginatedManuscripts(sort: $sort, filter: $filter, offset: $offset, limit: $limit) { + totalCount + manuscripts { + id + meta { + title + } + created + updated + status + } + } + } +` + +const CaretUp = ({ active }) => ( + <Caret + aria-hidden="true" + className="" + data-icon="caret-up" + fill="currentColor" + focusable="false" + height="1em" + viewBox="0 0 100 100" + width="1em" + active={active} + > + <path d="M50 17L100.229 67.25H-0.229473L50 17Z" /> + </Caret> +) + + +const CaretDown = ({ active }) => ( + <Caret + active={active} + aria-hidden="true" + className="" + data-icon="caret-down" + fill="currentColor" + focusable="false" + height="1em" + viewBox="0 0 100 100" + width="1em" + > + <path d="M50 84L-0.229473 33.75L100.229 33.75L50 84Z" /> + </Caret> +) + +const Manuscripts = () => { + const SortHeader = ({ thisSortName, children }) => { + const changeSort = () => { + if (sortName !== thisSortName) { + setSortName(thisSortName) + setSortDirection('ASC') + } else if (sortDirection === 'ASC') { + setSortDirection('DESC') + } else if (sortDirection === 'DESC') { + setSortName() + setSortDirection() + } + } + + const UpDown = () => { + if (thisSortName === sortName) { + return ( + <Carets> + <CaretUp active={sortDirection === 'ASC'} /> + <CaretDown active={sortDirection === 'DESC'} /> + </Carets> + ) + // return sortDirection + } + } + + return ( + <th onClick={changeSort}> + {children} {UpDown()} + </th> + ) + } + + const [sortName, setSortName] = useState('created') + const [sortDirection, setSortDirection] = useState('DESC') + const [page, setPage] = useState(1) + const limit = 10 + const sort = sortName && sortDirection && `${sortName}_${sortDirection}` + + const { loading, error, data } = useQuery(GET_MANUSCRIPTS, { + variables: { + sort, + offset: (page - 1) * limit, + limit, + }, + }) + + if (loading) return <Spinner /> + if (error) return `Error! ${error.message}` + + const { manuscripts, totalCount } = data.paginatedManuscripts + + return ( + <Container> + <Heading level={1}>Manuscripts</Heading> + <Table> + <Header> + <tr> + <SortHeader thisSortName="title">Title</SortHeader> + <SortHeader thisSortName="created">Created</SortHeader> + <SortHeader thisSortName="status">Status</SortHeader> + <th /> + </tr> + </Header> + <tbody> + {manuscripts.map((manuscript, key) => ( + <Manuscript key={manuscript.id} number={key + 1} manuscript={manuscript} /> + ))} + </tbody> + </Table> + <Pagination + limit={limit} + page={page} + setPage={setPage} + totalCount={totalCount} + /> + </Container> + ) +} + +export default Manuscripts \ No newline at end of file diff --git a/app/components/component-manuscripts/src/style.js b/app/components/component-manuscripts/src/style.js new file mode 100644 index 0000000000000000000000000000000000000000..6e2ee3eceef24155aa1b60750511fa8199d2ae6c --- /dev/null +++ b/app/components/component-manuscripts/src/style.js @@ -0,0 +1,116 @@ +import styled, { css } from 'styled-components' +import { Action } from '@pubsweet/ui' +import { th, grid } from '@pubsweet/ui-toolkit' + +export const Table = styled.table` + width: 100%; + border-radius: ${th('borderRadius')}; + border-collapse: collapse; + font-size: ${th('fontSizeBaseSmall')}; + + td { + width: 33%; + } +` +export const Header = styled.thead` + text-align: left; + font-variant: all-small-caps; + border-bottom: 1px solid ${th('colorFurniture')}; + + background-color: ${th('colorBackgroundHue')}; + + th { + padding: ${grid(1)} ${grid(3)}; + } +` + +export const Container = styled.div` + padding: ${grid(2)}; +` + +export const Row = styled.tr` + max-height: ${grid(8)}; + border-bottom: 1px solid ${th('colorFurniture')}; + + &:hover { + background-color: ${th('colorBackgroundHue')}; + } +` + +export const Cell = styled.td` + padding-bottom: ${grid(2)}; + padding-top: calc(${grid(2)} - 1px); + padding-left: ${grid(3)}; + padding-right: ${grid(3)}; + button { + font-size: ${th('fontSizeBaseSmall')}; + } +` + +export const UserCombo = styled.div` + display: flex; + line-height: ${grid(2.5)}; + align-items: center; +` + +export const LastCell = styled(Cell)` + text-align: right; +` + +export const Primary = styled.div` + font-weight: 500; +` + +export const Secondary = styled.div` + color: ${th('colorTextPlaceholder')}; +` + +export const UserInfo = styled.div` + margin-left: ${grid(1)}; +` + +export const Caret = styled.svg` + ${props => + props.active + ? css` + color: ${th('colorPrimary')}; + ` + : css` + color: ${th('colorSecondary')}; + `} +` + +export const Carets = styled.span` + display: inline-flex; + flex-direction: column; + align-items: center; + vertical-align: middle; + margin-left: ${grid(0.5)}; + svg { + height: ${grid(1.5)}; + } + svg:nth-of-type(2) { + margin-top: ${grid(-0.5)}; + } +` + +// TODO: Extract common above +// Specific + +const Status = styled.span` + border-radius: 8px; + font-variant: all-small-caps; + padding: ${grid(0.5)} ${grid(1)}; +` +export const SuccessStatus = styled(Status)` + background-color: ${th('colorSuccess')}; +` + +export const ErrorStatus = styled(Status)` + background-color: ${th('colorError')}; +` + +export const NormalStatus = styled(Status)` + background-color: ${th('colorWarning')}; + // color: ${th('colorTextReverse')}; +` diff --git a/app/components/component-users-manager/src/UsersManager.jsx b/app/components/component-users-manager/src/UsersManager.jsx index 763daf696e0e6ac8b25aea70664caa9c8b0e6c85..07baede85822971ceb3f17e200d961368f0ea1c1 100644 --- a/app/components/component-users-manager/src/UsersManager.jsx +++ b/app/components/component-users-manager/src/UsersManager.jsx @@ -6,7 +6,7 @@ import { Heading } from '@pubsweet/ui' import User from './User' import { Container, Table, Header, Caret, Carets } from './style' import Spinner from '../../shared/Spinner' -import Pagination from './Pagination' +import Pagination from '../../shared/Pagination' const GET_USERS = gql` query Users( diff --git a/app/components/component-users-manager/src/Pagination.jsx b/app/components/shared/Pagination.jsx similarity index 96% rename from app/components/component-users-manager/src/Pagination.jsx rename to app/components/shared/Pagination.jsx index 10f86269edd7227c56085bee5727e9f797ec6ed7..fff156627111344b98e6a1d02181ff489cb19aca 100644 --- a/app/components/component-users-manager/src/Pagination.jsx +++ b/app/components/shared/Pagination.jsx @@ -2,9 +2,9 @@ import React from 'react' import { Action } from '@pubsweet/ui' import styled, { css } from 'styled-components' import { th, grid } from '@pubsweet/ui-toolkit' -import Icon from '../../shared/Icon' -import { zIndex } from '../../../globals' +import Icon from './Icon' +import { zIndex } from '../../globals' const Page = styled.div` line-height: ${grid(5)}; @@ -44,7 +44,6 @@ const Page = styled.div` } } - // border-color: ${th('colorPrimary')}; `} ` diff --git a/app/routes.js b/app/routes.js index 50536dd407af954f40d7692bd5a3c50c33ecbc8d..c75a66035477f34de778aa203c767e92e5672ac4 100644 --- a/app/routes.js +++ b/app/routes.js @@ -1,11 +1,9 @@ import React from 'react' import { Route, Switch, Redirect } from 'react-router-dom' -// Common PubSweet components import Login from './components/component-login' import UsersManager from './components/component-users-manager' - -// SimpleJ-specific components +import Manuscripts from './components/component-manuscripts' import Dashboard from './components/component-xpub-dashboard/src/components/Dashboard' import SubmitPage from './components/component-xpub-submit/src/components/SubmitPage' import ManuscriptPage from './components/component-xpub-manuscript/src/components/ManuscriptPage' @@ -53,7 +51,6 @@ export default ( exact path="/admin/form-builder" /> - <PrivateRoute component={UsersManager} exact path="/admin/users" /> <PrivateRoute component={ManuscriptPage} exact @@ -92,7 +89,8 @@ export default ( /> */} <Route component={Login} path="/login" /> - <PrivateRoute component={UsersManager} path="/users" /> + <PrivateRoute component={UsersManager} path="/admin/users" /> + <PrivateRoute component={Manuscripts} path="/admin/manuscripts" /> {/* <PrivateRoute component={Dashboard} path="*" /> */} </Switch> diff --git a/server/model-manuscript/src/graphql.js b/server/model-manuscript/src/graphql.js index 70f97c24ecc3244ada6108b50c283576f97adf51..4685d5731b17c1fc0f07f0c17dfacdc9622d18c9 100644 --- a/server/model-manuscript/src/graphql.js +++ b/server/model-manuscript/src/graphql.js @@ -185,6 +185,36 @@ const resolvers = { async manuscripts(_, { where }, ctx) { return ctx.connectors.Manuscript.fetchAll(where, ctx) }, + async paginatedManuscripts(_, { sort, offset, limit, filter }, ctx) { + const query = ctx.connectors.Manuscript.model.query() + + if (filter && filter.status) { + query.where({ status: filter.status }) + } + + const totalCount = await query.resultSize() + + if (sort) { + // e.g. 'created_DESC' into 'created' and 'DESC' arguments + query.orderBy(...sort.split('_')) + } + + if (limit) { + query.limit(limit) + } + + if (offset) { + query.offset(offset) + } + + const manuscripts = await query + return { + totalCount, + manuscripts, + } + + // return ctx.connectors.User.fetchAll(where, ctx, { eager }) + }, async getFile() { return form }, @@ -204,8 +234,26 @@ const typeDefs = ` globalTeams: [Team] manuscript(id: ID!): Manuscript! manuscripts: [Manuscript]! + paginatedManuscripts(sort: String, offset: Int, limit: Int, filter: ManuscriptsFilter): PaginatedManuscripts + } + + input ManuscriptsFilter { + status: String + } + + type PaginatedManuscripts { + totalCount: Int + manuscripts: [Manuscript] } + # enum ManuscriptsSort { + # meta->>'title'_DESC + # created_ASC + # created_DESC + # updated_ASC + # updated_DESC + # } + extend type Mutation { createManuscript(input: ManuscriptInput): Manuscript! updateManuscript(id: ID!, input: String): Manuscript!