diff --git a/packages/component-faraday-ui/src/AppBar.js b/packages/component-faraday-ui/src/AppBar.js index 80dc030cc5b325b62bc929a143d3500009f3a948..44c5885b02c463566d262142bc61fe3614fef867 100644 --- a/packages/component-faraday-ui/src/AppBar.js +++ b/packages/component-faraday-ui/src/AppBar.js @@ -1,5 +1,6 @@ import React, { Fragment } from 'react' import { get, once } from 'lodash' +import PropTypes from 'prop-types' import styled from 'styled-components' import { H2, Button } from '@pubsweet/ui' import { th } from '@pubsweet/ui-toolkit' @@ -7,13 +8,13 @@ import { compose, setDisplayName, withProps } from 'recompose' import { Item, Row, Text } from 'pubsweet-component-faraday-ui' const AppBar = ({ + fixed, + isSubmit, logo: Logo, menu: Menu, createDraft, - canCreateDraft = true, - currentUser = {}, - fixed = true, - isSubmit, + canCreateDraft, + currentUser, autosave: Autosave, journal: { metadata: { backgroundImage } }, }) => ( @@ -46,7 +47,7 @@ const AppBar = ({ </RightContainer> </Root> {!canCreateDraft && ( - <RibbonRow bgColor={th('colorInfo')} fixed={fixed}> + <RibbonRow fixed={fixed}> <Text pb={1 / 2} pt={1}> Your account is not confirmed. Please check your email. </Text> @@ -55,10 +56,28 @@ const AppBar = ({ </Fragment> ) +AppBar.propTypes = { + fixed: PropTypes.bool, + logo: PropTypes.func, + currentUser: PropTypes.shape({ + user: PropTypes.object, + isAuthenticated: PropTypes.bool, + }), + /** If false will appear an error message. */ + canCreateDraft: PropTypes.bool, + /** Pass the menu component. */ + menu: PropTypes.func, + /** Appear an animation until it's save. */ + autosave: PropTypes.func, +} + AppBar.defaultProps = { - autosave: () => <div />, + fixed: true, + currentUser: {}, + canCreateDraft: true, logo: () => <div />, menu: () => <div />, + autosave: () => <div />, } export default compose( @@ -117,7 +136,6 @@ const JournalBackground = styled.div` rgba(0, 0, 0, 0.05) ); ` - const Root = styled.div` align-items: center; background-color: ${th('appBar.colorBackground')}; @@ -140,6 +158,7 @@ const Root = styled.div` ` const RibbonRow = styled(Row)` + background-color: ${th('colorInfo')}; position: ${props => (props.fixed ? 'fixed' : 'relative')}; top: ${props => (props.fixed ? th('appBar.height') : '0')}; ` diff --git a/packages/component-faraday-ui/src/AuthorTag.js b/packages/component-faraday-ui/src/AuthorTag.js index 00168896ff392ebf7cffefea85486b7f3a34eecd..4ec4cf6a3b28b21216fef66e39d21175835b5a48 100644 --- a/packages/component-faraday-ui/src/AuthorTag.js +++ b/packages/component-faraday-ui/src/AuthorTag.js @@ -26,9 +26,9 @@ const AuthorTag = ({ AuthorTag.propTypes = { /** The author you want to be on the card. */ author: PropTypes.shape({ - id: PropTypes.number, - firstName: PropTypes.number, - lastName: PropTypes.number, + id: PropTypes.string, + firstName: PropTypes.string, + lastName: PropTypes.string, isCorresponding: PropTypes.bool, isSubmitting: PropTypes.bool, affiliationNumber: PropTypes.number, diff --git a/packages/component-faraday-ui/src/AutosaveIndicator.js b/packages/component-faraday-ui/src/AutosaveIndicator.js index 2fa2048bdb53caf97aa349a14dee5a2c09a0e495..1a3b309ff177e412df6fb305d087acd8b9b62a43 100644 --- a/packages/component-faraday-ui/src/AutosaveIndicator.js +++ b/packages/component-faraday-ui/src/AutosaveIndicator.js @@ -102,13 +102,11 @@ export default compose( AutosaveIndicator.propTypes = { /** Make appear loader until save. */ - autosave: PropTypes.objectOf( - PropTypes.oneOfType([PropTypes.bool, PropTypes.date, PropTypes.string]), - ), + autosave: PropTypes.object, // eslint-disable-line } AutosaveIndicator.defaultProps = { - autosave: undefined, + autosave: {}, } // #region styles const Root = styled.div` diff --git a/packages/component-faraday-ui/src/ContextualBox.js b/packages/component-faraday-ui/src/ContextualBox.js index 40e3e6f5f8b7b71933eafc303222f179a3f70b5b..f2c0d0d9b751ac5c0380d0efbab892830bae54da 100644 --- a/packages/component-faraday-ui/src/ContextualBox.js +++ b/packages/component-faraday-ui/src/ContextualBox.js @@ -1,6 +1,6 @@ import React from 'react' import PropTypes from 'prop-types' -import { has } from 'lodash' +import { isUndefined } from 'lodash' import styled from 'styled-components' import { Icon, H3 } from '@pubsweet/ui' import { override, th } from '@pubsweet/ui-toolkit' @@ -35,7 +35,7 @@ const CustomHeader = ({ ) const ContextualBox = ({ label, children, rightChildren, ...props }) => - has(props, 'expanded') ? ( + !isUndefined(props.expanded) ? ( <ControlledAccordion header={CustomHeader} label={label} @@ -61,7 +61,7 @@ ContextualBox.propTypes = { /** Label of the contextual box. */ label: PropTypes.string, /** Component or html to be rendered on the right side. */ - rightChildren: PropTypes.oneOfType([PropTypes.element, PropTypes.func]), + rightChildren: PropTypes.any, // eslint-disable-line /** The state of the contextual box. If passed from a parent then the component * is controlled and can be expanded/collapsed remotely. */ @@ -69,13 +69,12 @@ ContextualBox.propTypes = { /** Callback function used to control the state of the component. * To be used together with the `expanded` prop. */ - toggle: PropTypes.func, + toggle: PropTypes.func, // eslint-disable-line } ContextualBox.defaultProps = { label: '', - rightChildren: undefined, - toggle: null, + // rightChildren: undefined, } // #region styles diff --git a/packages/component-faraday-ui/src/Logo.js b/packages/component-faraday-ui/src/Logo.js index 338312793bdfef4b08c3b3cdbe138e5591248392..ddc7b7b7a6ecefb1e4aa2f566d78e44efec512c5 100644 --- a/packages/component-faraday-ui/src/Logo.js +++ b/packages/component-faraday-ui/src/Logo.js @@ -2,8 +2,9 @@ import React from 'react' import { get } from 'lodash' +import PropTypes from 'prop-types' -const Logo = ({ src, onClick, title, height = 36, ...rest }) => ( +const Logo = ({ src, onClick, title, height, ...rest }) => ( <img alt={title} data-test-id={get(rest, 'data-test-id', 'journal-logo')} @@ -14,4 +15,12 @@ const Logo = ({ src, onClick, title, height = 36, ...rest }) => ( /> ) +Logo.propTypes = { + /** Height of the logo. */ + height: PropTypes.number, +} + +Logo.defaultProps = { + height: 36, +} export default Logo diff --git a/packages/component-faraday-ui/src/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index 17e9e176354403406b6066cf5b09f589a9a93cfa..8b86a6910c0b68cc5e1e5def1636f40a0691b4e1 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -5,6 +5,7 @@ import { th } from '@pubsweet/ui-toolkit' import { withJournal } from 'xpub-journal' import { H3, H4, DateParser } from '@pubsweet/ui' import { compose, withHandlers, setDisplayName, withProps } from 'recompose' +import PropTypes from 'prop-types' import { Tag, @@ -27,8 +28,8 @@ const ManuscriptCard = ({ isFetching, onCardClick, canViewReports, - fragment = {}, - manuscriptType = {}, + fragment, + manuscriptType, collection: { visibleStatus = 'Draft', handlingEditor, customId, id: collId }, }) => { const { @@ -137,6 +138,11 @@ export default compose( setDisplayName('ManuscriptCard'), )(ManuscriptCard) +ManuscriptCard.propTypes = { + fragment: PropTypes.object.isRequired, // eslint-disable-line + collection: PropTypes.object.isRequired, // eslint-disable-line +} + // #region styles const MainContainer = styled.div` justify-content: flex-start; diff --git a/packages/component-faraday-ui/src/ManuscriptCard.md b/packages/component-faraday-ui/src/ManuscriptCard.md index aea9f0e6cf26bc6bab8d474c0ae54b8ce88828ed..e8d9bccea15dc25845a5784894302f5b8613cbed 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.md +++ b/packages/component-faraday-ui/src/ManuscriptCard.md @@ -40,46 +40,6 @@ const authors = [ firstName: 'Barrack 4', lastName: 'Obama', }, - { - email: 'barrack.obama@gmail5.com', - firstName: 'Barrack 5', - lastName: 'Obama', - }, - { - email: 'barrack.obama@gmail6.com', - firstName: 'Barrack 6', - lastName: 'Obama', - }, - { - email: 'barrack.obama@gmail7.com', - firstName: 'Barrack 7', - lastName: 'Obama', - }, - { - email: 'barrack.obama@gmail8.com', - firstName: 'Barrack 8', - lastName: 'Obama', - }, - { - email: 'barrack.obama@gmail9.com', - firstName: 'Barrack 9', - lastName: 'Obama', - }, - { - email: 'barrack.obama@gmail10.com', - firstName: 'Barrack 10', - lastName: 'Obama', - }, - { - email: 'barrack.obama@gmail11.com', - firstName: 'Barrack 11', - lastName: 'Obama', - }, - { - email: 'barrack.obama@gmail12.com', - firstName: 'Barrack 12', - lastName: 'Obama', - }, ] const collection = { diff --git a/packages/component-faraday-ui/src/Pagination.js b/packages/component-faraday-ui/src/Pagination.js index 2078907f8e0187f8b20c8c9849460b204a2ce58b..c0f38b45a64d972d6c1118165ec1dce6098fa434 100644 --- a/packages/component-faraday-ui/src/Pagination.js +++ b/packages/component-faraday-ui/src/Pagination.js @@ -51,10 +51,10 @@ const PaginationComponent = ({ </Root> ) -export const Pagination = ({ paginatedItems, children, ...props }) => ( +export const Pagination = ({ Items, children, ...props }) => ( <Fragment> <PaginationComponent {...props} /> - {typeof children === 'function' && children(paginatedItems, props)} + {typeof children === 'function' && children(Items, props)} </Fragment> ) diff --git a/packages/component-faraday-ui/src/PersonInfo.js b/packages/component-faraday-ui/src/PersonInfo.js index 7d9ce203b0be1271292ab8bbdff4f35d4fbd3e7e..bca7e16d14205d77df66a82a8d41ed490821f4a1 100644 --- a/packages/component-faraday-ui/src/PersonInfo.js +++ b/packages/component-faraday-ui/src/PersonInfo.js @@ -1,19 +1,10 @@ import React from 'react' -import PropTypes from 'prop-types' import { withCountries } from 'pubsweet-component-faraday-ui' - +import PropTypes from 'prop-types' import { Text, Row, Label, Item } from './' -const defaultPerson = { - email: '', - firstName: '', - lastName: '', - affiliation: '', - country: '', -} - const PersonInfo = ({ - person: { email, firstName, lastName, affiliation, country } = defaultPerson, + person: { email, firstName, lastName, affiliation, country }, countryLabel, }) => ( <Row> @@ -39,8 +30,8 @@ const PersonInfo = ({ </Item> </Row> ) - -PersonInfo.proTypes = { +PersonInfo.propTypes = { + /** Person with information */ person: PropTypes.shape({ email: PropTypes.string, firstName: PropTypes.string, @@ -50,4 +41,14 @@ PersonInfo.proTypes = { }), } +PersonInfo.defaultProps = { + person: { + email: '', + firstName: '', + lastName: '', + affiliation: '', + country: '', + }, +} + export default withCountries(PersonInfo) diff --git a/packages/component-faraday-ui/src/ReviewerBreakdown.js b/packages/component-faraday-ui/src/ReviewerBreakdown.js index 7d257102a24dc7f39217f22b6c0529d800026247..8e51446107a345ca5776fe3558849127755ad2b9 100644 --- a/packages/component-faraday-ui/src/ReviewerBreakdown.js +++ b/packages/component-faraday-ui/src/ReviewerBreakdown.js @@ -1,11 +1,8 @@ import React from 'react' -import { get } from 'lodash' -import { compose, withHandlers, withProps } from 'recompose' +import PropTypes from 'prop-types' import { Text, Row } from './' -const ReviewerBreakdown = ({ getReportBreakdown }) => getReportBreakdown() - const roleFilter = role => i => i.role === role const submittedFilter = r => r.review && r.review.submittedOn const acceptedFilter = i => i.hasAnswer && i.isAccepted @@ -17,48 +14,58 @@ const reviewerReduce = (acc, r) => ({ submitted: submittedFilter(r) ? acc.submitted + 1 : acc.submitted, }) -export default compose( - withProps(({ fragment }) => ({ - invitations: get(fragment, 'invitations', []), - recommendations: get(fragment, 'recommendations', []), - })), - withHandlers({ - getReportBreakdown: ({ invitations, recommendations, ...rest }) => () => { - const reviewerInvitations = invitations.filter(roleFilter('reviewer')) - const invitationsWithRecommendations = reviewerInvitations.map(r => ({ - ...r, - review: recommendations.find(rec => rec.userId === r.userId), - })) - const report = invitationsWithRecommendations.reduce(reviewerReduce, { - accepted: 0, - declined: 0, - submitted: 0, - }) - return reviewerInvitations.length ? ( - <Row fitContent justify="flex-end" {...rest}> - <Text customId mr={1 / 2}> - {reviewerInvitations.length} - </Text> - <Text mr={1 / 2}> invited,</Text> +const ReviewerBreakdown = ({ + fragment: { invitations = [], recommendations = [] }, + ...rest +}) => { + const reviewerInvitations = invitations.filter(roleFilter('reviewer')) + const invitationsWithRecommendations = reviewerInvitations.map(r => ({ + ...r, + review: recommendations.find(rec => rec.userId === r.userId), + })) + const report = invitationsWithRecommendations.reduce(reviewerReduce, { + accepted: 0, + declined: 0, + submitted: 0, + }) + return reviewerInvitations.length ? ( + <Row fitContent justify="flex-end" {...rest}> + <Text customId mr={1 / 2}> + {reviewerInvitations.length} + </Text> + <Text mr={1 / 2}> invited,</Text> + + <Text customId mr={1 / 2}> + {report.accepted} + </Text> + <Text mr={1 / 2}> agreed,</Text> - <Text customId mr={1 / 2}> - {report.accepted} - </Text> - <Text mr={1 / 2}> agreed,</Text> + <Text customId mr={1 / 2}> + {report.declined} + </Text> + <Text mr={1 / 2}> declined,</Text> - <Text customId mr={1 / 2}> - {report.declined} - </Text> - <Text mr={1 / 2}> declined,</Text> + <Text customId mr={1 / 2}> + {report.submitted} + </Text> + <Text mr={1 / 2}> submitted</Text> + </Row> + ) : ( + <Text mr={1}>{`${reviewerInvitations.length} invited`}</Text> + ) +} - <Text customId mr={1 / 2}> - {report.submitted} - </Text> - <Text mr={1 / 2}> submitted</Text> - </Row> - ) : ( - <Text mr={1}>{`${reviewerInvitations.length} invited`}</Text> - ) - }, +ReviewerBreakdown.propTypes = { + fragment: PropTypes.shape({ + invitations: PropTypes.arrayOf(PropTypes.object), + recommendations: PropTypes.arrayOf(PropTypes.object), }), -)(ReviewerBreakdown) +} +ReviewerBreakdown.defaultProps = { + fragment: { + invitations: [], + recommendations: [], + }, +} + +export default ReviewerBreakdown diff --git a/packages/component-faraday-ui/src/ReviewerReport.js b/packages/component-faraday-ui/src/ReviewerReport.js index 12391694d8b8032f53d43932629ba1f4d20a12aa..5d728ccdecab34b117fc9f4bf39050484e18a86a 100644 --- a/packages/component-faraday-ui/src/ReviewerReport.js +++ b/packages/component-faraday-ui/src/ReviewerReport.js @@ -1,13 +1,16 @@ import React, { Fragment } from 'react' import { get } from 'lodash' +import PropTypes from 'prop-types' import { withProps } from 'recompose' import styled from 'styled-components' -import { th } from '@pubsweet/ui-toolkit' import { DateParser } from '@pubsweet/ui' +import { th } from '@pubsweet/ui-toolkit' import { Label, Item, FileItem, Row, Text } from './' const ReviewerReport = ({ + journal, + showOwner, onPreview, onDownload, reportFile, @@ -16,7 +19,6 @@ const ReviewerReport = ({ reviewerName, reviewerIndex, recommendation, - showOwner = false, report: { submittedOn }, }) => ( <Root> @@ -76,7 +78,7 @@ const ReviewerReport = ({ </Root> ) -export default withProps(({ report, journal: { recommendations = [] } }) => ({ +export default withProps(({ report, journal: { recommendations } }) => ({ recommendation: get( recommendations.find(r => r.value === report.recommendation), 'label', @@ -91,6 +93,31 @@ export default withProps(({ report, journal: { recommendations = [] } }) => ({ )}`, }))(ReviewerReport) +ReviewerReport.propTypes = { + /** It's true when you want to appear the reviewer name */ + showOwner: PropTypes.bool, + /** Reviewers reports */ + report: PropTypes.shape({ + id: PropTypes.string, + userId: PropTypes.string, + comments: PropTypes.arrayOf(PropTypes.object), + createdOn: PropTypes.number, + updatedOn: PropTypes.number, + submittedOn: PropTypes.number, + recommendation: PropTypes.string, + recommendationType: PropTypes.string, + }), + /** The reviewers recommendations */ + journal: PropTypes.shape({ + recommendations: PropTypes.arrayOf(PropTypes.object), + }), +} + +ReviewerReport.defaultProps = { + showOwner: false, + report: undefined, + journal: { recommendation: [] }, +} // #region styles const Root = styled.div` background-color: ${th('colorBackgroundHue')}; diff --git a/packages/component-faraday-ui/src/ReviewerReportAuthor.js b/packages/component-faraday-ui/src/ReviewerReportAuthor.js index 4df5745b8ce86a109bad547466f3fe5ff57f94de..b10503a41a43f9181e84906122e181b54af8738b 100644 --- a/packages/component-faraday-ui/src/ReviewerReportAuthor.js +++ b/packages/component-faraday-ui/src/ReviewerReportAuthor.js @@ -1,21 +1,24 @@ import React, { Fragment } from 'react' import { get } from 'lodash' -import { withProps, compose } from 'recompose' +import PropTypes from 'prop-types' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { DateParser } from '@pubsweet/ui' +import { withProps, compose } from 'recompose' import { - Label, - Item, - FileItem, Row, Text, + Item, + Label, + FileItem, withFilePreview, withFileDownload, } from './' const ReviewerReportAuthor = ({ + journal, + showOwner, reviewFile, previewFile, downloadFile, @@ -23,7 +26,6 @@ const ReviewerReportAuthor = ({ reviewerName, reviewerIndex, recommendation, - showOwner = false, report: { submittedOn }, }) => ( <Root> @@ -82,6 +84,32 @@ export default compose( })), )(ReviewerReportAuthor) +ReviewerReportAuthor.propTypes = { + /** It's true when you want to appear the reviewer name */ + showOwner: PropTypes.bool, + /** Reviewers reports */ + report: PropTypes.shape({ + id: PropTypes.string, + userId: PropTypes.string, + comments: PropTypes.arrayOf(PropTypes.object), + createdOn: PropTypes.number, + updatedOn: PropTypes.number, + submittedOn: PropTypes.number, + recommendation: PropTypes.string, + recommendationType: PropTypes.string, + }), + /** The reviewers recommendations */ + journal: PropTypes.shape({ + recommendations: PropTypes.arrayOf(PropTypes.object), + }), +} + +ReviewerReportAuthor.defaultProps = { + showOwner: false, + report: undefined, + journal: { recommendation: [] }, +} + // #region styles const Root = styled.div` background-color: ${th('colorBackgroundHue')}; diff --git a/packages/component-faraday-ui/src/ReviewersTable.js b/packages/component-faraday-ui/src/ReviewersTable.js index 9f9e2aaa75309afd25084e94a65cbcf65e2c646b..102e6e4032f4b9a144a5dd971403c4d88ed8fdc7 100644 --- a/packages/component-faraday-ui/src/ReviewersTable.js +++ b/packages/component-faraday-ui/src/ReviewersTable.js @@ -1,3 +1,4 @@ +import PropTypes from 'prop-types' import React, { Fragment } from 'react' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' @@ -5,10 +6,10 @@ import { DateParser } from '@pubsweet/ui' import { get, isEqual, orderBy } from 'lodash' import { compose, shouldUpdate, withHandlers, withProps } from 'recompose' -import { Label, PersonInvitation, Text } from '../' +import { Label, PersonInvitation, Text } from './' const ReviewersTable = ({ - invitations, + invitations = [], getInvitationStatus, renderAcceptedLabel, onResendReviewerInvite, @@ -94,6 +95,34 @@ const orderInvitations = i => { return 1 } +ReviewersTable.propTypes = { + /** Passes properties for invited reviewwers. */ + invitations: PropTypes.arrayOf( + PropTypes.shape({ + /** Reviewers unique id. */ + id: PropTypes.string, + /** Reviewers role. */ + role: PropTypes.string, + /** Type of invitation. */ + type: PropTypes.string, + /** Users unique id. */ + userId: PropTypes.string, + /** Reviewer has responded. */ + hasAnswer: PropTypes.bool, + /** Date of invite. */ + invitedOn: PropTypes.number, + /** Reviewer has accepted. */ + isAccepted: PropTypes.bool, + /** Date of the response. */ + respondedOn: PropTypes.number, + }), + ), +} + +ReviewersTable.defaultProps = { + invitations: [], +} + export default compose( shouldUpdate( ({ invitations }, { invitations: nextInvitations }) => diff --git a/packages/component-faraday-ui/src/Tabs.js b/packages/component-faraday-ui/src/Tabs.js index a7d90025dcd5eb9ce1d48215b0da37319fe9dffa..003b084c5418f0d9c45558147e2c5a6151d9610a 100644 --- a/packages/component-faraday-ui/src/Tabs.js +++ b/packages/component-faraday-ui/src/Tabs.js @@ -1,8 +1,21 @@ +import PropTypes from 'prop-types' import { compose, withStateHandlers } from 'recompose' const Tabs = ({ items, selectedTab, changeTab, children }) => children({ selectedTab, changeTab }) +Tabs.proptypes = { + /** The selected tab. */ + selectedTab: PropTypes.number, + /** Handler to change the tab. */ + changeTab: PropTypes.func, +} + +Tabs.defaultProp = { + selectedTab: 0, + changeTab: () => {}, +} + export default compose( withStateHandlers(({ selectedTab = 0 }) => ({ selectedTab }), { changeTab: () => selectedTab => ({ diff --git a/packages/component-faraday-ui/src/Tag.js b/packages/component-faraday-ui/src/Tag.js index fd6ce0316577b29f1ca95619cdd180a860209c54..3c6997d15e07f9420cfd88520f5c5e69a60de095 100644 --- a/packages/component-faraday-ui/src/Tag.js +++ b/packages/component-faraday-ui/src/Tag.js @@ -1,11 +1,12 @@ -import { has } from 'lodash' +import { get } from 'lodash' +import PropTypes from 'prop-types' import { th } from '@pubsweet/ui-toolkit' import styled, { css } from 'styled-components' import { marginHelper } from './styledHelpers' const tagCSS = props => { - if (has(props, 'oldStatus')) { + if (get(props, 'oldStatus')) { return css` background-color: ${th('colorFurnitureHue')}; height: calc(${th('gridUnit')} * 3) @@ -15,7 +16,7 @@ const tagCSS = props => { ` } - if (has(props, `status`)) { + if (get(props, `status`)) { return css` background-color: ${th('tag.statusBackgroundColor')}; padding: calc(${th('gridUnit')} / 4) ${th('gridUnit')}; @@ -35,7 +36,7 @@ const tagCSS = props => { } /** @component */ -export default styled.div` +const Tag = styled.div` border-radius: ${th('tag.borderRadius') ? th('tag.borderRadius') : th('borderRadius')}; @@ -52,3 +53,17 @@ export default styled.div` ${tagCSS}; ${marginHelper}; ` + +Tag.propTypes = { + /** if true then object gets properties. */ + oldStatus: PropTypes.bool, + /** if true then object gets properties. */ + status: PropTypes.boo, +} + +Tag.defaultProps = { + oldStatus: false, + status: false, +} + +export default Tag diff --git a/packages/component-faraday-ui/src/Text.js b/packages/component-faraday-ui/src/Text.js index 0368f97a32f5e757721c9e39f73ec03f8dfef790..06d321cd457795456583e71f4d179e750427f202 100644 --- a/packages/component-faraday-ui/src/Text.js +++ b/packages/component-faraday-ui/src/Text.js @@ -100,23 +100,23 @@ const Text = ({ bullet, children, ...rest }) => ) Text.propTypes = { - /** if true */ + /** if true then object gets properties. */ secondary: PropTypes.bool, - /** if true then object gets properties */ + /** if true then object gets properties. */ error: PropTypes.bool, - /** if true then object gets properties */ + /** if true then object gets properties. */ customId: PropTypes.bool, - /** if true then object gets properties */ + /** if true then object gets properties. */ labelLine: PropTypes.bool, - /** if true then object gets properties */ + /** if true then object gets properties. */ journal: PropTypes.bool, - /** if true thenobject gets properties */ + /** if true thenobject gets properties. */ small: PropTypes.bool, - /** defines how items will be displayed */ + /** defines how items will be displayed. */ display: PropTypes.string, - /** defines how items will be aligned */ + /** defines how items will be aligned. */ align: PropTypes.string, - /** defines if there will be a white space */ + /** defines if there will be a white space. */ whiteSpace: PropTypes.string, } diff --git a/packages/component-faraday-ui/src/UserProfile.js b/packages/component-faraday-ui/src/UserProfile.js index 292c04822b7ee0bdbcfb2662a12a91bb961cc8ca..a5f0555c1cc902a233e97989fb0c4a290bfae559 100644 --- a/packages/component-faraday-ui/src/UserProfile.js +++ b/packages/component-faraday-ui/src/UserProfile.js @@ -1,13 +1,14 @@ /* eslint-disable handle-callback-err */ -import React, { Fragment } from 'react' import { get } from 'lodash' +import PropTypes from 'prop-types' import styled from 'styled-components' import { reduxForm } from 'redux-form' +import React, { Fragment } from 'react' import { th } from '@pubsweet/ui-toolkit' +import { withCountries } from 'pubsweet-component-faraday-ui' import { required as requiredValidator } from 'xpub-validators' import { compose, withStateHandlers, withProps } from 'recompose' import { H3, Spinner, ValidatedField, TextField, Menu } from '@pubsweet/ui' -import { withCountries } from 'pubsweet-component-faraday-ui' import { Row, @@ -236,6 +237,72 @@ const UserProfile = ({ /> ) +UserProfile.propTypes = { + /** Passes journals label and value which will appear in the signature. */ + journal: PropTypes.shape({ + title: PropTypes.arrayOf( + PropTypes.shape({ + label: PropTypes.string, + value: PropTypes.string, + }), + ), + }), + /** Passes properties for the users profile */ + user: PropTypes.shape({ + /** Users unique id. */ + id: PropTypes.string, + /** Type of created account. */ + type: PropTypes.string, + /** Determine if account is admin ot not. */ + admin: PropTypes.bool, + /** Email used for user authentification. */ + email: PropTypes.string, + /** */ + teams: PropTypes.array, + /** Title of account userd. */ + title: PropTypes.string, + /** */ + agreeTC: PropTypes.bool, + /** Country of account user. */ + contry: PropTypes.string, + /** Status of account. */ + isActive: PropTypes.bool, + /** Last Name of accounts user. */ + lastName: PropTypes.string, + /** First name of accounts user. */ + username: PropTypes.string, + /** Account user first name. */ + firstName: PropTypes.string, + /** */ + fragments: PropTypes.array, + /** Accounts user affiliation. */ + affiliation: PropTypes.string, + /** */ + collection: PropTypes.array, + /** Determine if account is confirmed or not. */ + isConfirmed: PropTypes.bool, + /** Determine if account is editor in chief or not. */ + editorInChief: PropTypes.bool, + /** */ + notifications: PropTypes.shape({ + email: PropTypes.shape({ + user: PropTypes.bool, + system: PropTypes.bool, + }), + }), + + /** Determine if account is hendling editor or not. */ + handlingEditor: PropTypes.bool, + /** Users unique token */ + token: PropTypes.array, + }), +} + +UserProfile.defaultProps = { + journal: {}, + user: {}, +} + export default compose( withCountries, withStateHandlers( diff --git a/packages/component-faraday-ui/src/WizardFiles.js b/packages/component-faraday-ui/src/WizardFiles.js index 9bd0591a7ff21c8ca020583682a8130d7b9da290..99e09b45189540f5e3be6202f51eea9849286f9d 100644 --- a/packages/component-faraday-ui/src/WizardFiles.js +++ b/packages/component-faraday-ui/src/WizardFiles.js @@ -1,4 +1,5 @@ import React, { Fragment } from 'react' +import PropTypes from 'prop-types' import { get } from 'lodash' import { compose, withState, withHandlers } from 'recompose' @@ -18,6 +19,9 @@ const WizardFiles = ({ changeList, previewFile, downloadFile, + manuscripts, + coverLetter, + supplementary, }) => ( <Fragment> <FileSection @@ -75,6 +79,47 @@ const initialFiles = { supplementary: [], } +WizardFiles.propTypes = { + /** Passes properties for the manuscript file. */ + manuscripts: PropTypes.arrayOf( + PropTypes.shape({ + /** Id of added manuscript file. */ + id: PropTypes.string, + /** Name of added manuscript file. */ + name: PropTypes.string, + /** Size of added manusript file. */ + size: PropTypes.number, + }), + ), + /** Passes properties for the cover letter file. */ + coverLetter: PropTypes.arrayOf( + PropTypes.shape({ + /** Id of added cover letter file. */ + id: PropTypes.string, + /** Name of added cover letter file. */ + name: PropTypes.string, + /** Size of added cover letter file. */ + size: PropTypes.number, + }), + ), + /** Passes properties for supplementary file. */ + supplementary: PropTypes.arrayOf( + PropTypes.shape({ + /** Id of added cover letter file. */ + id: PropTypes.string, + /** Name of added cover letter file. */ + name: PropTypes.string, + /** Size of added cover letter file. */ + size: PropTypes.number, + }), + ), +} +WizardFiles.defaultProps = { + manuscripts: [], + coverLetter: [], + supplementary: [], +} + export default compose( withFilePreview, withFileDownload, diff --git a/packages/component-faraday-ui/src/helpers/README.md b/packages/component-faraday-ui/src/helpers/README.md index 15a652d3ec699c2b98c3f903793c34804a2272ae..588a016a342b676e6bb207f4a2f87fe92da8e694 100644 --- a/packages/component-faraday-ui/src/helpers/README.md +++ b/packages/component-faraday-ui/src/helpers/README.md @@ -27,8 +27,10 @@ Injects `countries` and `countryLabel` as props. ### withCountries props -* `countries: [{value: string, label: string}]`: the list of countries -* `countryLabel: (code: string) => string`: get the name of the country with the specified code +| Name | Type | Description | +| :----------- | :--------------------------------- | :-------------------------------------------------- | +| countries | `[{value: string, label: string}]` | the list of countries | +| countryLabel | `(code: string) => string` | get the name of the country with the specified code | ```js import { Menu } from '@pubsweet/ui' @@ -51,12 +53,14 @@ Injects `isFetching`, `fetchingError`, `setFetching`, `toggleFetching`, `setErro ### withFetching props -* `isFetching: bool`: value representing a pending async operation -* `fetchingError: string`: value representing the error -* `setFetching: (value: bool) => any`: function for setting the `isFetching` value -* `toggleFetching: () => any`: function that toggle the current value of `isFetching` -* `setError: (error: string) => any`: function that sets `fetchingError` -* `clearError: () => any`: function that resets `fetchingError` to it's original value +| Name | Type | Description | +| :------------- | :----------------------- | :---------------------------------------------------------- | +| isFetching | `bool` | Pending async operation sattus | +| fetchingError | `fetchingError` | Value representing the error | +| setFetching | `(value: bool) => any` | Function for setting the `isFetching` value | +| toggleFetching | `(value: bool) => any` | Function that toggles the current value of `isFetching` | +| setError | `(error: string) => any` | Function that sets `fetchingError` | +| clearError | `() => any` | Function that resets `fetchingError` to it's original value | ```js import { withFetching } from 'pubsweet-component-faraday-ui' @@ -80,7 +84,9 @@ Injects `downloadFile` as a prop. ### withFileDownload props -* `downloadFile: (file: {id: string, name: string}) => any`: downloads the file specified as a parameter. The wrapped component should have the authentication token in a prop called `token` in order for this to work. +| Name | Type | Description | +| :----------- | :------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | +| downloadFile | `(file: {id: string, name: string}) => any` | Downloads the file specified as a parameter. The wrapped component should have the authentication token in a prop called `token` in order for this to work. | ```js import { FileItem, withFileDownload } from 'pubsweet-component-faraday-ui' @@ -106,11 +112,15 @@ Generate a securized file URL and preview it in a new tab. Injects `previewFile` This HOC assumes the following props are present on the wrapped component: -* `getSignedURL: (id: string) => Promise({signedURL: string})`: an async call that returns the securized S3 file url +| Name | Type | Description | +| :----------- | :--------------------------------------------- | :------------------------------------------------ | +| getSignedURL | `(id: string) => Promise({signedURL: string})` | Async call that returns the securized S3 file url | ### withFilePreviewProps -* `previewFile: (file: {id: string, ...}) => any`: opens the file preview in a new tab (only possible for PDF files and images) +| Name | Type | Description | +| :---------- | :--------------------------------- | :--------------------------------------------------------------------------- | +| previewFile | `(file: {id: string, ...}) => any` | Opens the file preview in a new tab (only possible for PDF files and images) | ```javascript import { withProps } from 'recompose' @@ -137,16 +147,19 @@ Injects `page`, `itemsPerPage`, `toFirst`, `nextPage`, `toLast`, `prevPage`, `ch ### withPagination props -* `page: number`: the current page -* `itemsPerPage: number`: number of items to be shown per page -* `maxItems: number`: the total number of items -* `hasMore: bool`: if we're not at the last page yet -* `paginatedItems: [any]`: slice of the original items -* `toFirst: () => { page: number }`: go to the first page -* `toLast: () => {page: number}`: go to the last page -* `nextPage: () => {page: number}`: move to the next page -* `prevPage: () => {page: number}`: move to the previous page -* `changeItemsPerPage: e: HTMLInputEvent => {page: number, itemsPerPage: number}`: change the number of items per page +| Name | Type | Description | +| :----------------- | :---------------------------------------------------------- | :------------------------------------ | +| page | `number` | Current page. | +| itemsPerPage | `number` | Number of items to be shown per page. | +| maxItems | `number` | Total number of items. | +| maxItems | `number` | Total number of items. | +| hasMore | `bool` | If we're not at the last page yet. | +| paginatedItems | `[any]` | Slice of the original items. | +| toFirst | `() => { page: number }` | Go to the first page. | +| toLast | `() => { page: number }` | Go to the last page. | +| nextPage | `() => { page: number }` | Move to the next page. | +| prevPage | `() => { page: number }` | Move to the previous page. | +| changeItemsPerPage | `e: HTMLInputEvent => {page: number, itemsPerPage: number}` | Change the number of items per page. | ```js import { withPagination } from 'pubsweet-component-faraday-ui' @@ -174,7 +187,9 @@ Injects the `roles` array as a prop. The roles are parsed from the journal confi ### withRoles props -* `roles: [{value: string, label: string}]`: an array of user roles +| Name | Type | Description | +| :---- | :--------------------------------- | :---------------------- | +| roles | `[{value: string, label: string}]` | An array of user roles. | ```js import { Menu } from '@pubsweet/ui' @@ -191,15 +206,19 @@ Downloads all the files of a fragment as a zip archive. Injects the `downloadFil This HOCs assumes the following props are present on the wrapped component: -* `token: string`: authentication token (used to authorize this request) -* `isReview: bool`: if the user is reviewer -* `fragmentId: string`: id of the fragment whose files we want to download -* `setFetching: (value: bool) => any`: a callback to set a fetching status -* `archiveName: string`: the name of the outputted archive file +| Name | Type | Description | +| :---------- | :--------------------- | :----------------------------------------------------- | +| token | `string` | Authentication token (used to authorize this request). | +| isReviewer | `bool` | If the user is reviewer. | +| fragmentId | `string` | Id of the fragment whose files we want to download. | +| setFetching | `(value: bool) => any` | Callback to set a fetching status. | +| archiveName | `string` | Name of the outputted archive file. | ### withZipDownload props -* `downloadFiles: () => any`: download all the fragment's file as a zip +| Name | Type | Description | +| :------------ | :---------------- | :----------------------------------------- | +| downloadFiles | `strin() => anyg` | Download all the fragment's file as a zip. | # Files drag and drop @@ -209,12 +228,14 @@ HOC used to provide drop functionality to the `FileSection` component. It's main This HOC assumes the wrapped component has the following props: -* `files: [{id: string, ...}]`: the list of files passed to the wrapped component -* `setError: (error: string) => any`: error setting callback -* `listId: string`: the current list id -* `allowedFileExtensions: [string]`: the allowed files -* `maxFiles: number`: the maximum number of files allowed -* `changeList: (fromListId: string, toListId: string: fileId: string)`: callback called if all the conditions are met (allowed files, number of files, etc) +| Name | Type | Description | +| :-------------------- | :-------------------------------------------------------------- | :------------------------------------------------- | +| files | `[{id: string, ...}]` | List of files passed to the wrapped component. | +| setError | `(error: string) => any` | Error setting callback. | +| listId | `string` | Current list id. | +| allowedFileExtensions | `[string]` | Allowed file types. | +| maxFiles | `number` | Maximum number of files allowed. | +| changeList | `(fromListId: string, toListId: string: fileId: string) => any` | Callback fired when moving the file to a new list. | ```js import { compose, withHandler, withProps } from 'recompose' @@ -244,11 +265,13 @@ HOC used to provide native file drop functionality to the `FileSection` componen This HOC assumes the wrapped component has the following props: -* `files: [{id: string, ...}]`: the list of files passed to the wrapped component -* `setError: (error: string) => any`: error setting callback -* `allowedFileExtensions: [string]`: the allowed files -* `maxFiles: number`: the maximum number of files allowed -* `onFileDrop: (file: File)`: callback called when a valid file is dropped +| Name | Type | Description | +| :-------------------- | :----------------------- | :--------------------------------------------- | +| files | `[{id: string, ...}]` | List of files passed to the wrapped component. | +| setError | `(error: string) => any` | Error setting callback. | +| allowedFileExtensions | `[string]` | Allowed file types. | +| maxFiles | `number` | Maximum number of files allowed. | +| onFileDrop | `(file: File) => any` | Callback fired when a valid file is dropped. | ```js import { compose, withHandler, withProps } from 'recompose' diff --git a/packages/component-manuscript/src/handleRecommendation/README.md b/packages/component-manuscript/src/handleRecommendation/README.md index 783844056d7c3ee2de1a003f86ceba5c3f74a315..81084d76afa0df06f8e584c720ec638558a4b753 100644 --- a/packages/component-manuscript/src/handleRecommendation/README.md +++ b/packages/component-manuscript/src/handleRecommendation/README.md @@ -5,12 +5,13 @@ Injects `createRecommendation` and `onEditorialRecommendation` handlers as props ### withHandleRecommendation props `recommendationHandler` namespace contains the following fields: -Name|Type|Description ----|---|--- -createRecommendation |`(reduxFormValues, modalProps) => any`|creates a recommendation for the manuscript -onEditorialRecommendation |`(reduxFormValues, modalProps) => any`|handles the recommendation for the manuscript -_Note: The functions must be used withing a modal_ +| Name | Type | Description | +| :------------------------ | :------------------------------------- | :-------------------------------------------- | +| createRecommendation | `(reduxFormValues, modalProps) => any` | creates a recommendation for the manuscript | +| onEditorialRecommendation | `(reduxFormValues, modalProps) => any` | handles the recommendation for the manuscript | + +_Note: The functions must be used withing a modal._ ```javascript const HERecommendationPanel = ({ createRecommendation }) => ( @@ -22,7 +23,11 @@ const HERecommendationPanel = ({ createRecommendation }) => ( <option>Minor revision</option> <option>Major revision</option> </select> - <button onClick={() => createRecommendation(reduxFormValues, { ...modalProps, setFetching })}> + <button + onClick={() => + createRecommendation(reduxFormValues, { ...modalProps, setFetching }) + } + > Submit </button> </Modal> @@ -37,7 +42,14 @@ const EICDecisionPanel = ({ onEditorialRecommendation }) => ( <option>Minor revision</option> <option>Major revision</option> </select> - <button onClick={() => onEditorialRecommendation(reduxFormValues, { ...modalProps, setFetching })}> + <button + onClick={() => + onEditorialRecommendation(reduxFormValues, { + ...modalProps, + setFetching, + }) + } + > Submit </button> </Modal> diff --git a/packages/component-manuscript/src/inviteHandlingEditor/README.md b/packages/component-manuscript/src/inviteHandlingEditor/README.md index 665c53eb15c3d8223e903d5249dfc10aaf688fe7..9badc8fff6048f76569b7df6f30afaf868e7b119 100644 --- a/packages/component-manuscript/src/inviteHandlingEditor/README.md +++ b/packages/component-manuscript/src/inviteHandlingEditor/README.md @@ -5,13 +5,14 @@ Injects `assignHE`, `revokeHE` and `onHEResponse` handlers as props. ### withInviteHandlingEditor props `inviteHandlingEditor` namespace contains the following fields: -Name|Type|Description ----|---|--- -assignHE |`(email, modalProps) => any`|sends an invitation to the handling editor -revokeHE |`(invitationId, modalProps) => any`|revokes a sent invitation to the handling editor -onHEResponse |`(reduxFormValues, modalProps) => any`|handles the handling editor's response -_Note: The functions must be used withing a modal_ +| Name | Type | Description | +| :----------- | :------------------------------------- | :----------------------------------------------- | +| assignHE | `(email, modalProps) => any` | sends an invitation to the handling editor | +| revokeHE | `(invitationId, modalProps) => any` | revokes a sent invitation to the handling editor | +| onHEResponse | `(reduxFormValues, modalProps) => any` | handles the handling editor's response | + +_Note: The functions must be used withing a modal._ ```javascript const EditorInChiefPanel = ({ assignHE, revokeHE }) => ( @@ -32,12 +33,16 @@ const HandlingEditorPanel = ({ onHeResponse }) => ( <Modal> <span>Accept invitation?</span> <button - onClick={() => onHeResponse(reduxFormValues, { ...modalProps, setFetching })} + onClick={() => + onHeResponse(reduxFormValues, { ...modalProps, setFetching }) + } > Yes </button> <button - onClick={() => onHeResponse(reduxFormValues, { ...modalProps, setFetching })} + onClick={() => + onHeResponse(reduxFormValues, { ...modalProps, setFetching }) + } > No </button> diff --git a/packages/component-manuscript/src/inviteReviewer/README.md b/packages/component-manuscript/src/inviteReviewer/README.md index f8bae378764fa146d8a8b37169595783e080131a..74f050b225d985e666212a0909088bcb0c223c25 100644 --- a/packages/component-manuscript/src/inviteReviewer/README.md +++ b/packages/component-manuscript/src/inviteReviewer/README.md @@ -5,13 +5,14 @@ Injects `onInviteReviewer`, `onInvitePublonReviewer`, `onResendInviteReviewer`, ### withInviteReviewer props `inviteReviewer` namespace contains the following fields: -Name|Type|Description ----|---|--- -onInviteReviewer|`(reduxFormValues, modalProps) => any`|sends an invitation to the reviewer -onInvitePublonReviewer|`(reduxFormValues, modalProps) => any`|sends an invitation to a Publon reviewer -onResendInviteReviewer|`(email, modalProps) => any`|resends an invitation to an already invited reviewer -onRevokeInviteReviewer|`(invitationId, modalProps) => any`|cancels an invitation to an invited reviewer -onReviewerResponse|`(reduxFormValues, modalProps) => any`|handles the reviewer response to the invitation + +| Name | Type | Description | +| :--------------------- | :------------------------------------- | :--------------------------------------------------- | +| onInviteReviewer | `(reduxFormValues, modalProps) => any` | sends an invitation to the reviewer | +| onInvitePublonReviewer | `(reduxFormValues, modalProps) => any` | sends an invitation to a Publon reviewer | +| onResendInviteReviewer | `(email, modalProps) => any` | resends an invitation to an already invited reviewer | +| onRevokeInviteReviewer | `(invitationId, modalProps) => any` | cancels an invitation to an invited reviewer | +| onReviewerResponse | `(reduxFormValues, modalProps) => any` | handles the reviewer response to the invitation | _Note: The functions must be used withing a modal_