From 1fc0c2d7fcbaf374462dced0cc4b001df9be9133 Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Mon, 5 Nov 2018 10:41:20 +0200 Subject: [PATCH 01/49] docs(faraday-ui): add documentation for some components and remove unused stuff --- .../component-faraday-ui/src/ActionLink.js | 28 +- .../component-faraday-ui/src/ActionLink.md | 6 +- .../component-faraday-ui/src/AuthorCard.js | 52 +++- .../component-faraday-ui/src/AuthorCard.md | 6 +- .../component-faraday-ui/src/ContextualBox.js | 22 ++ .../component-faraday-ui/src/ContextualBox.md | 6 +- .../src/DownloadZipFiles.js | 12 + packages/component-faraday-ui/src/File.js | 12 +- .../src/InviteReviewers.js | 13 + .../src/components/ManuscriptVersion.js | 29 -- .../src/components/SubmitRevision.js | 293 ------------------ .../src/components/index.js | 2 - 12 files changed, 143 insertions(+), 338 deletions(-) delete mode 100644 packages/component-manuscript/src/components/ManuscriptVersion.js delete mode 100644 packages/component-manuscript/src/components/SubmitRevision.js diff --git a/packages/component-faraday-ui/src/ActionLink.js b/packages/component-faraday-ui/src/ActionLink.js index 05ad25cd2..46eaff19e 100644 --- a/packages/component-faraday-ui/src/ActionLink.js +++ b/packages/component-faraday-ui/src/ActionLink.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import styled from 'styled-components' import { Link } from 'react-router-dom' import { withHandlers } from 'recompose' @@ -12,10 +13,10 @@ const ActionLink = ({ icon, size, onClick, + iconSize, disabled, children, renderLink, - iconSize = 2, iconPosition = 'left', ...rest }) => ( @@ -36,6 +37,31 @@ const ActionLink = ({ </Root> ) +ActionLink.propTypes = { + /** Link/URL specifying where to navigate, outside or inside the app. + * If present the component will behave like a navigation link. */ + to: PropTypes.string, + /** What icon to be used. */ + icon: PropTypes.string, + /** Size of the icon. */ + iconSize: PropTypes.number, + /** Position of the icon. */ + iconPosition: PropTypes.oneOf(['left', 'right']), + /** Callback function fired when the component is clicked. */ + onClick: PropTypes.func, + /** If true the component will be disabled (can't be interacted with). */ + disabled: PropTypes.bool, +} + +ActionLink.defaultProps = { + iconSize: 2, + to: undefined, + disabled: true, + icon: undefined, + onClick: undefined, + iconPosition: 'left', +} + export default withHandlers({ renderLink: ({ to, internal, disabled, onClick, size, children }) => () => { if (to && !internal) { diff --git a/packages/component-faraday-ui/src/ActionLink.md b/packages/component-faraday-ui/src/ActionLink.md index 0cd8d6bd0..833522ce6 100644 --- a/packages/component-faraday-ui/src/ActionLink.md +++ b/packages/component-faraday-ui/src/ActionLink.md @@ -1,7 +1,9 @@ A clickable text button. ```js -<ActionLink onClick={() => console.log('I am clicked.')}>Default action</ActionLink> +<ActionLink onClick={() => console.log('I am clicked.')}> + Default action +</ActionLink> ``` A disabled text buton. @@ -24,7 +26,7 @@ A text button with an icon on the right. </ActionLink> ``` -A text link. +A navigation link. ```js <ActionLink icon="eye" iconPosition="right" to="https://www.google.com"> diff --git a/packages/component-faraday-ui/src/AuthorCard.js b/packages/component-faraday-ui/src/AuthorCard.js index 2ace7fa98..16c11e1d7 100644 --- a/packages/component-faraday-ui/src/AuthorCard.js +++ b/packages/component-faraday-ui/src/AuthorCard.js @@ -1,16 +1,17 @@ import React, { Fragment } from 'react' +import PropTypes from 'prop-types' import { isNumber, get } from 'lodash' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { required } from 'xpub-validators' import { reduxForm, Field } from 'redux-form' import { - Menu, H3, - ValidatedField, - TextField, - Checkbox, + Menu, Spinner, + Checkbox, + TextField, + ValidatedField, } from '@pubsweet/ui' import { compose, @@ -19,10 +20,10 @@ import { withHandlers, setDisplayName, } from 'recompose' - import { withCountries } from 'pubsweet-component-faraday-ui' -import { Tag, Label, Row, Item, PersonInfo, IconButton, OpenModal } from './' + import { validators } from './helpers' +import { Tag, Label, Row, Item, PersonInfo, IconButton, OpenModal } from './' const Empty = () => <div /> @@ -287,6 +288,45 @@ const AuthorCard = ({ </Root> ) +AuthorCard.propTypes = { + /** The author details. */ + item: PropTypes.shape({ + email: PropTypes.string, + firstName: PropTypes.string, + lastName: PropTypes.string, + affiliation: PropTypes.string, + country: PropTypes.string, + }).isRequired, + /** Callback function fired when deleting an author after confirmation. + * @param {Author} author + * @returns A function that receives the modal properties as an argument. + * */ + deleteAuthor: PropTypes.func, + /** Whether the author is currently being edited. */ + isAuthorEdit: PropTypes.bool, + /** Callback function fired when editing an author. + * Called with the author's index or null when closing edit mode. + * @param {number} authorIndex + * */ + onEdit: PropTypes.func, // eslint-disable-line + /** Callback function fired when saving a new author. + * The added author is passed as a parameter. */ + saveNewAuthor: PropTypes.func, + /** Callback function fired when editing an author. + * @param {object} values + * @param {function} dispatch + * @param {object} props */ + authorEditorSubmit: PropTypes.func, +} + +AuthorCard.defaultProps = { + onEdit: null, + deleteAuthor: null, + isAuthorEdit: false, + saveNewAuthor: null, + authorEditorSubmit: null, +} + export default compose( withState('editMode', 'setEditMode', ({ item }) => item.id === 'newAuthor'), withHandlers({ diff --git a/packages/component-faraday-ui/src/AuthorCard.md b/packages/component-faraday-ui/src/AuthorCard.md index d71f220ff..6496d159d 100644 --- a/packages/component-faraday-ui/src/AuthorCard.md +++ b/packages/component-faraday-ui/src/AuthorCard.md @@ -1,3 +1,5 @@ +A component that shows details about an author. It has two modes: a presentation mode and an edit mode. This component can be a part of a submission wizard as well as in a sortable list. + An author card. ```js @@ -11,12 +13,14 @@ const author = { } ;<div> <AuthorCard - onEdit={() => console.log('s-a dat click pe edit')} + onEdit={e => console.log('s-a dat click pe edit', e)} index={0} item={author} deleteAuthor={item => () => { console.log('delete author', item) }} + saveNewAuthor={(...args) => console.log('save new authot', args)} + authorEditorSubmit={(...args) => console.log('edit the author', args)} /> <AuthorCard onEdit={() => console.log('s-a dat click pe edit')} diff --git a/packages/component-faraday-ui/src/ContextualBox.js b/packages/component-faraday-ui/src/ContextualBox.js index 32ff2966e..40e3e6f5f 100644 --- a/packages/component-faraday-ui/src/ContextualBox.js +++ b/packages/component-faraday-ui/src/ContextualBox.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { has } from 'lodash' import styled from 'styled-components' import { Icon, H3 } from '@pubsweet/ui' @@ -56,6 +57,27 @@ const ContextualBox = ({ label, children, rightChildren, ...props }) => export default ContextualBox +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]), + /** The state of the contextual box. If passed from a parent then the component + * is controlled and can be expanded/collapsed remotely. + */ + expanded: PropTypes.bool, // eslint-disable-line + /** Callback function used to control the state of the component. + * To be used together with the `expanded` prop. + */ + toggle: PropTypes.func, +} + +ContextualBox.defaultProps = { + label: '', + rightChildren: undefined, + toggle: null, +} + // #region styles const Header = styled.div.attrs({ 'data-test-id': props => props['data-test-id'] || 'accordion-header', diff --git a/packages/component-faraday-ui/src/ContextualBox.md b/packages/component-faraday-ui/src/ContextualBox.md index a9c7114bd..9e48b6c95 100644 --- a/packages/component-faraday-ui/src/ContextualBox.md +++ b/packages/component-faraday-ui/src/ContextualBox.md @@ -1,3 +1,7 @@ +*Component to show or hide it's children. Can be controlled from a parent component by passing the expanded state and toggle callback.* + +--- + A collapseable contextual box. ```js @@ -113,7 +117,7 @@ const MyRightComponent = ({ headLabel }) => ( </ContextualBox> ``` -A controlled ContextualBox. +A controlled ContextualBox. This is usually used together with the RemoteOpener component. ```js const MyRightComponent = () => <div>works like a charm!</div> diff --git a/packages/component-faraday-ui/src/DownloadZipFiles.js b/packages/component-faraday-ui/src/DownloadZipFiles.js index 8e5d34d7c..e2d9c95dc 100644 --- a/packages/component-faraday-ui/src/DownloadZipFiles.js +++ b/packages/component-faraday-ui/src/DownloadZipFiles.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { Spinner } from '@pubsweet/ui' import { compose, withState } from 'recompose' import { Item } from 'pubsweet-component-faraday-ui' @@ -16,6 +17,17 @@ const DownloadZipFiles = ({ disabled, fetching, children, downloadFiles }) => ( </Item> ) +DownloadZipFiles.propTypes = { + /** Name for the downloaded archive file. */ + archiveName: PropTypes.string.isRequired, // eslint-disable-line + /** If the user is a reviewer. */ + isReviewer: PropTypes.bool, // eslint-disable-line +} + +DownloadZipFiles.defaultProps = { + isReviewer: false, +} + export default compose( withState('fetching', 'setFetching', false), withZipDownload, diff --git a/packages/component-faraday-ui/src/File.js b/packages/component-faraday-ui/src/File.js index 4c6014d3e..96b484d0c 100644 --- a/packages/component-faraday-ui/src/File.js +++ b/packages/component-faraday-ui/src/File.js @@ -91,11 +91,17 @@ FileItem.propTypes = { }).isRequired, /** Used when part of a sortable list. */ dragHandle: PropTypes.oneOfType([PropTypes.element, PropTypes.func]), - /** Handler for the preview button. */ + /** Callback function fired when clicking the preview icon. + * @param {File} file + */ onPreview: PropTypes.func, - /** Handler for the download button. */ + /** Callback function fired when clicking the download icon. + * @param {File} file + */ onDownload: PropTypes.func, - /** Handler for the delete button. */ + /** Callback function fired when clicking the delete icon. + * @param {File} file + */ onDelete: PropTypes.func, } diff --git a/packages/component-faraday-ui/src/InviteReviewers.js b/packages/component-faraday-ui/src/InviteReviewers.js index 7c93ebb31..ca30641a3 100644 --- a/packages/component-faraday-ui/src/InviteReviewers.js +++ b/packages/component-faraday-ui/src/InviteReviewers.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { compose } from 'recompose' import styled from 'styled-components' import { reduxForm } from 'redux-form' @@ -91,6 +92,18 @@ const InviteReviewers = ({ countries, handleSubmit, reset }) => ( </Root> ) +InviteReviewers.propTypes = { + /** Callback function fired after confirming a reviewer invitation. + * @param {Reviewer} reviewer + * @param {object} props + */ + onInvite: PropTypes.func, +} + +InviteReviewers.defaultProps = { + onInvite: null, +} + export default compose( withFetching, withCountries, diff --git a/packages/component-manuscript/src/components/ManuscriptVersion.js b/packages/component-manuscript/src/components/ManuscriptVersion.js deleted file mode 100644 index b198686d0..000000000 --- a/packages/component-manuscript/src/components/ManuscriptVersion.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react' -import { get } from 'lodash' -import { Menu } from '@pubsweet/ui' -import { withRouter } from 'react-router-dom' - -import { parseVersionOptions } from './utils' - -const ManuscriptVersion = ({ - history, - version = {}, - project = { fragments: [] }, -}) => { - const fragments = get(project, 'fragments') - return ( - !!fragments.length && ( - <Menu - inline - onChange={v => - history.push(`/projects/${project.id}/versions/${v}/details`) - } - options={parseVersionOptions(fragments)} - placeholder="Please select" - value={get(version, 'id')} - /> - ) - ) -} - -export default withRouter(ManuscriptVersion) diff --git a/packages/component-manuscript/src/components/SubmitRevision.js b/packages/component-manuscript/src/components/SubmitRevision.js deleted file mode 100644 index 0fa813808..000000000 --- a/packages/component-manuscript/src/components/SubmitRevision.js +++ /dev/null @@ -1,293 +0,0 @@ -// #region imports -import React from 'react' -import PropTypes from 'prop-types' -import { get, isEmpty } from 'lodash' -import { connect } from 'react-redux' -import { th } from '@pubsweet/ui-toolkit' -import { required } from 'xpub-validators' -import { DragDropContext } from 'react-dnd' -import { withRouter } from 'react-router-dom' -import styled, { css } from 'styled-components' -import HTML5Backend from 'react-dnd-html5-backend' -import { ValidatedField, Button } from '@pubsweet/ui' -import { AbstractEditor, TitleEditor } from 'xpub-edit' -import { - reduxForm, - getFormSyncErrors, - getFormValues, - change as changeForm, -} from 'redux-form' -import { - withModal, - ConfirmationModal, -} from 'pubsweet-component-modal/src/components' -import { AuthorList, Files } from 'pubsweet-components-faraday/src/components' -import { submitRevision } from 'pubsweet-component-wizard/src/redux/conversion' -import { selectReviewRecommendations } from 'pubsweet-components-faraday/src/redux/recommendations' -import { - toClass, - compose, - withProps, - withContext, - withHandlers, -} from 'recompose' -import { - uploadFile, - deleteFile, - getRequestStatus, -} from 'pubsweet-components-faraday/src/redux/files' -import { - requiredHTML, - requiredFiles, - onRevisionSubmit, - onRevisionChange, -} from './utils' - -import { Expandable } from '../molecules/' -// #endregion - -const TextAreaField = input => <Textarea {...input} height={70} rows={6} /> -const SubmitRevision = ({ - addFile, - project, - version, - formError, - formValues, - removeFile, - handleSubmit, - responseFiles, - reviews = [], - submitFailed, -}) => ( - <Root> - <Expandable label="Submit Revision" startExpanded> - <Expandable label="DETAILS & AUTHORS" startExpanded> - <Title>MANUSCRIPT TITLE*</Title> - <ValidatedField - component={input => <TitleEditor {...input} />} - name="metadata.title" - validate={[requiredHTML]} - /> - <Title>ABSTRACT*</Title> - <ValidatedField - component={input => <AbstractEditor {...input} />} - name="metadata.abstract" - validate={[requiredHTML]} - /> - <Title>AUTHORS DETAILS*</Title> - <CustomValidatedField> - <ValidatedField - component={() => ( - <AuthorList - authorPath="revision.authors" - parentForm="revision" - project={project} - /> - )} - name="authors" - validate={[required]} - /> - </CustomValidatedField> - </Expandable> - <Expandable label="FILES" startExpanded> - <CustomValidatedField> - <ValidatedField - component={() => ( - <Files - filePath="revision.files" - parentForm="revision" - project={project} - version={version} - /> - )} - name="files" - validate={[requiredFiles]} - /> - </CustomValidatedField> - </Expandable> - {!isEmpty(reviews) && ( - <Expandable label="RESPONSE TO REVIEWER COMMENTS" startExpanded> - <Title>Reply text*</Title> - <Row> - <FullWidth className="full-width"> - <ValidatedField - component={TextAreaField} - name="commentsToReviewers" - validate={ - isEmpty(get(formValues, 'files.responseToReviewers')) - ? [required] - : [] - } - /> - </FullWidth> - </Row> - </Expandable> - )} - <SubmitContainer> - {submitFailed && - formError && <Error>There are some errors above.</Error>} - <Button onClick={handleSubmit} primary> - SUBMIT REVISION - </Button> - </SubmitContainer> - </Expandable> - </Root> -) - -export default compose( - withContext( - { - version: PropTypes.object, - project: PropTypes.object, - }, - ({ project, version }) => ({ - project, - version, - }), - ), - withRouter, - withModal(props => ({ - modalComponent: ConfirmationModal, - })), - connect( - (state, { version }) => ({ - fileFetching: getRequestStatus(state), - reviews: selectReviewRecommendations(state, version.id), - formValues: getFormValues('revision')(state), - formError: getFormSyncErrors('revision')(state), - }), - { - changeForm, - uploadFile, - deleteFile, - submitRevision, - }, - ), - withHandlers({ - addFile: ({ formValues = {}, uploadFile, changeForm, version }) => file => { - uploadFile(file, 'responseToReviewers', version) - .then(file => { - const { files } = formValues - const newFiles = files.responseToReviewers - ? [...files.responseToReviewers, file] - : [file] - changeForm('revision', 'files', { - ...files, - responseToReviewers: newFiles, - }) - }) - .catch(e => console.error(`Couldn't upload file.`, e)) - }, - removeFile: ({ - formValues: { files }, - changeForm, - deleteFile, - }) => id => e => { - deleteFile(id) - .then(r => { - const newFiles = files.responseToReviewers.filter(f => f.id !== id) - changeForm('revision', 'files', { - ...files, - responseToReviewers: newFiles, - }) - }) - .catch(e => console.error(`Couldn't delete the file.`, e)) - }, - }), - withProps(({ version, formValues }) => ({ - initialValues: { - metadata: { - title: get(version, 'revision.metadata.title', ''), - abstract: get(version, 'revision.metadata.abstract', ''), - }, - authors: get(version, 'revision.authors'), - files: get(version, 'revision.files', []), - commentsToReviewers: get(version, 'revision.commentsToReviewers'), - }, - responseFiles: get(formValues, 'files.responseToReviewers', []), - })), - reduxForm({ - form: 'revision', - onChange: onRevisionChange, - onSubmit: onRevisionSubmit, - }), - DragDropContext(HTML5Backend), - toClass, -)(SubmitRevision) - -// #region styled-components -const defaultText = css` - color: ${th('colorPrimary')}; - font-family: ${th('fontReading')}; - font-size: ${th('fontSizeBaseSmall')}; -` - -const Error = styled.span` - color: ${th('colorError')}; - font-size: ${th('fontSizeBaseSmall')}; - margin-right: ${th('subGridUnit')}; -` - -const CustomValidatedField = styled.div` - div { - div:last-child { - margin-top: 0; - } - } -` - -const Textarea = styled.textarea` - border-color: ${({ hasError }) => - hasError ? th('colorError') : th('colorPrimary')}; - font-size: ${th('fontSizeBaseSmall')}; - font-family: ${th('fontWriting')}; - padding: calc(${th('subGridUnit')} * 2); - transition: all 300ms linear; - width: 100%; - - &:read-only { - background-color: ${th('colorBackgroundHue')}; - } -` - -const FullWidth = styled.div` - flex: 1; - > div { - flex: 1; - } -` - -const Row = styled.div` - ${defaultText}; - align-items: center; - box-sizing: border-box; - display: flex; - flex-direction: row; - flex: 1; - flex-wrap: wrap; - justify-content: ${({ left }) => (left ? 'left' : 'space-between')}; - - div[role='alert'] { - margin-top: 0; - } -` - -const Root = styled.div` - background-color: ${th('colorBackground')}; -` - -const Title = styled.span` - align-self: center; - font-family: ${th('fontHeading')}; - font-size: ${th('fontSizeBaseSmall')}; - text-transform: uppercase; -` - -const SubmitContainer = styled.div` - align-items: center; - display: flex; - flex-direction: row; - justify-content: space-between; - margin-top: calc(${th('subGridUnit')} * 2); -` -// #endregion diff --git a/packages/component-manuscript/src/components/index.js b/packages/component-manuscript/src/components/index.js index 66110b8f2..411c86ca2 100644 --- a/packages/component-manuscript/src/components/index.js +++ b/packages/component-manuscript/src/components/index.js @@ -2,11 +2,9 @@ export { default as Authors } from './Authors' export { default as ShowMore } from './ShowMore' export { default as SideBarRoles } from './SideBarRoles' export { default as ManuscriptPage } from './ManuscriptPage' -export { default as SubmitRevision } from './SubmitRevision' export { default as EditorialComment } from './EditorialComment' export { default as ReviewReportCard } from './ReviewReportCard' export { default as ManuscriptLayout } from './ManuscriptLayout' -export { default as ManuscriptVersion } from './ManuscriptVersion' export { default as ReviewsAndReports } from './ReviewsAndReports' export { default as EditorialComments } from './EditorialComments' export { default as ReviewReportsList } from './ReviewReportsList' -- GitLab From 38c4a0c480348c153f2004e0f0bd24daefd5c024 Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Mon, 5 Nov 2018 14:42:37 +0200 Subject: [PATCH 02/49] docs(faraday-ui): doument faraday utility HOCs --- packages/component-faraday-ui/package.json | 3 +- packages/component-faraday-ui/src/AppBar.md | 2 +- .../src/gridItems/Item.js | 4 +- .../src/helpers/helpers.md | 168 ++++++++++++++++++ 4 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 packages/component-faraday-ui/src/helpers/helpers.md diff --git a/packages/component-faraday-ui/package.json b/packages/component-faraday-ui/package.json index 020fd030a..a21a5636e 100644 --- a/packages/component-faraday-ui/package.json +++ b/packages/component-faraday-ui/package.json @@ -12,5 +12,6 @@ "querystring": "^0.2.0", "react": "^16.4.2", "styled-components": "^3.4.2" - } + }, + "devDependencies": {} } diff --git a/packages/component-faraday-ui/src/AppBar.md b/packages/component-faraday-ui/src/AppBar.md index 49d8caf19..107dbbe75 100644 --- a/packages/component-faraday-ui/src/AppBar.md +++ b/packages/component-faraday-ui/src/AppBar.md @@ -18,7 +18,7 @@ const autosave = { const HindawiLogo = () => ( <Logo onClick={() => console.log('Hindawi best publish!')} - title="Hindawi" + title="Anca" src="https://upload.wikimedia.org/wikipedia/en/thumb/c/ca/Hindawi.svg/1200px-Hindawi.svg.png" /> ) diff --git a/packages/component-faraday-ui/src/gridItems/Item.js b/packages/component-faraday-ui/src/gridItems/Item.js index 32b29bc61..e8a868634 100644 --- a/packages/component-faraday-ui/src/gridItems/Item.js +++ b/packages/component-faraday-ui/src/gridItems/Item.js @@ -4,7 +4,7 @@ import styled from 'styled-components' import { marginHelper, paddingHelper } from 'pubsweet-component-faraday-ui' /** @component */ -export default styled.div.attrs({ +const Item = styled.div.attrs({ 'data-test-id': props => props['data-test-id'] || 'item', })` align-items: ${({ alignItems }) => alignItems || 'initial'}; @@ -17,3 +17,5 @@ export default styled.div.attrs({ ${marginHelper}; ${paddingHelper}; ` + +export default Item diff --git a/packages/component-faraday-ui/src/helpers/helpers.md b/packages/component-faraday-ui/src/helpers/helpers.md new file mode 100644 index 000000000..2bb8ec45c --- /dev/null +++ b/packages/component-faraday-ui/src/helpers/helpers.md @@ -0,0 +1,168 @@ +## Hindawi utility HOCs. + +* [withCountries](#withCountries) +* [withFetching](#withFetching) +* [withFileDownload](#withFileDownload) +* [withFilePreview](#withFilePreview) +* [withPagination](#withPagination) +* [withRoles](#withRoles) +* [withZipDownload](#withZipDownload) + +## withCountries + +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 + +```js +import { Menu } from '@pubsweet/ui' +import { withCountries } from 'pubsweet-component-faraday-ui' + +const Wrapped = ({ countries, countryLabel }) => ( + <div> + <Menu options={countries} placeholder="Select a country" /> + + <span>Selected country: {countryLabel('RO')}</span> + </div> +) +``` + +## withFetching + +Injects `isFetching`, `fetchingError`, `setFetching`, `toggleFetching`, `setError` and `clearError` as props. + +### 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 + +```js +import { withFetching } from 'pubsweet-component-faraday-ui' + +const Wrapped = ({ isFetching, fetchingError, setFetching, toggleFetching }) => ( + <div> + {isFetching && <span>I am fetching</span>} + <span>{`The error: ${fetchingError}`</span> + <button onClick={() => setFetching(true)}>Set fetching true</button> + <button onClick={() => setFetching(false)}>Set fetching false</button> + <button onClick={toggleFetching}>Toggle fetching</button> + </div> +) + +export default withFetching(Wrapped) +``` + +## withFileDownload + +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. + +```js +import { FileItem, withFileDownload } from 'pubsweet-component-faraday-ui' + +const file = { + id: 'myfile', + name: 'myfile.pdf', + size: 100231, +} + +const Wrapped = ({ downloadFile }) => ( + <div> + <FileItem item={file} onDownload={downloadfile} /> + </div> +) + +export default Wrapped +``` + +## withFilePreview + +Generate a securized file URL and preview it in a new tab. Injects `previewFile` as a prop. + +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 + +### withFilePreviewProps + +* `previewFile: (file: {id: string, ...}) => any`: opens the file preview in a new tab (only possible for PDF files and images) + +## withPagination + +Injects `page`, `itemsPerPage`, `toFirst`, `nextPage`, `toLast`, `prevPage`, `changeItemsPerPage`, `hasMore`, `maxItems` and `paginatedItems` as props. + +### 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 + +```js +import { withPagination } from 'pubsweet-component-faraday-ui' + +const Wrapped = ({ page, nextPage, prevPage, paginatedItems, changeItemsPerPage }) => ( + <div> + <span>Page {page}</span> + <button onClick={prevPage}>Prev page</button> + <button onClick={nextPage}>Next page</button> + <input type="text" onChange={changeItemsPerPage} /> + <div> + { + paginatedItems.map(p => <span>{p}<span>) + } + </div> + </div> +) + +export default withPagination(Wrapped) +``` + +## withRoles + +Injects the `roles` array as a prop. The roles are parsed from the journal config files. + +### withRoles props + +* `roles: [{value: string, label: string}]`: an array of user roles + +```js +import { Menu } from '@pubsweet/ui' +import { withRoles } from 'pubsweet-component-faraday-ui' + +const Wrapped = ({ roles }) => <Menu options={roles} /> + +export default withRoles(Wrapped) +``` + +## withZipDownload + +Downloads all the files of a fragment as a zip archive. Injects the `downloadFiles` function as a prop. + +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 + +### withZipDownload props + +* `downloadFiles: () => any`: download all the fragment's file as a zip -- GitLab From edae851d3f1f8b4b535db580f973bcd176f7f030 Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Mon, 5 Nov 2018 16:15:13 +0200 Subject: [PATCH 03/49] docs(faraday-ui): add documentation for faraday helpers --- .../src/helpers/helpers.md | 112 +++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/packages/component-faraday-ui/src/helpers/helpers.md b/packages/component-faraday-ui/src/helpers/helpers.md index 2bb8ec45c..f8b826816 100644 --- a/packages/component-faraday-ui/src/helpers/helpers.md +++ b/packages/component-faraday-ui/src/helpers/helpers.md @@ -1,4 +1,6 @@ -## Hindawi utility HOCs. +## Hindawi Helpers + +_Utility HOCs_ * [withCountries](#withCountries) * [withFetching](#withFetching) @@ -8,6 +10,17 @@ * [withRoles](#withRoles) * [withZipDownload](#withZipDownload) +_HOCs used for files drag and drop_ + +* [withFileSectionDrop](#withFileSectionDrop) +* [withNativeFileDrop](#withNativeFileDrop) + +_Utility functions_ + +* [handleError](#handleError) + +# Utility HOCs + ## withCountries Injects `countries` and `countryLabel` as props. @@ -28,6 +41,8 @@ const Wrapped = ({ countries, countryLabel }) => ( <span>Selected country: {countryLabel('RO')}</span> </div> ) + +export default withCountries(Wrapped) ``` ## withFetching @@ -166,3 +181,98 @@ This HOCs assumes the following props are present on the wrapped component: ### withZipDownload props * `downloadFiles: () => any`: download all the fragment's file as a zip + +# Files drag and drop + +## withFileSectionDrop + +HOC used to provide drop functionality to the `FileSection` component. It's main purpose is to change a file from one list to another. This is usually done in a callback called `changeList` that should be provided to the wrapped component. + +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) + +```js +import { compose, withHandler, withProps } from 'recompose' +import { FileSection, withFileSectionDrop } from 'pubsweet-component-faraday-ui' + +const Wrapped = compose( + withProps({ + files: [...], + listId: 'CoverLetter', + maxFiles: 3, + allowedFileExtensions: ['pdf'], + }), + withHandlers({ + changeList: () => (fromListId, toListId, fileId) => { + // do the actual change here + } + }), + withFileSectionDrop, +)(FileSection) + +export default Wrapped +``` + +## withNativeFileDrop + +HOC used to provide native file drop functionality to the `FileSection` component. It's purpose is to do something when dragging files from the computer's hard drive into the app. _This HOC allows only single items! Dragging multiple items into the wrapped component will only handle the first item!_ + +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 + +```js +import { compose, withHandler, withProps } from 'recompose' +import { FileSection, withNativeFileDrop } from 'pubsweet-component-faraday-ui' + +const Wrapped = compose( + withProps({ + files: [...], + listId: 'CoverLetter', + maxFiles: 3, + allowedFileExtensions: ['pdf'], + }), + withHandlers({ + onFileDrop: () => file => { + // do something with the dropped file + } + }), + withNativeFileDrop, +)(FileSection) + +export default Wrapped +``` + +# Utility functions + +## handleError + +Function that parses the server error. Calls the passed function with the parsed error. + +Has the following signature: +`(callbackFn: (parsedError) => any) => (e: Error) => any` + +```js +const customErrorLogger = parsedError => + console.error(`This is very handled: ${parsedError}`) + +// point free notation +anAsyncOperation().catch(handleError(customErrorLogger)) + +// can be used besides other function calls + +anAsyncOperation().catch(err => { + setFetching(false) + handleError(customErrorLogger)(err) +}) +``` -- GitLab From 2feafa1465fb43abb531eedf30c14ab871f86fe8 Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Mon, 5 Nov 2018 17:11:38 +0200 Subject: [PATCH 04/49] docs(faraday-ui): fix markdown links --- .../src/helpers/helpers.md | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/packages/component-faraday-ui/src/helpers/helpers.md b/packages/component-faraday-ui/src/helpers/helpers.md index f8b826816..15a652d3e 100644 --- a/packages/component-faraday-ui/src/helpers/helpers.md +++ b/packages/component-faraday-ui/src/helpers/helpers.md @@ -2,22 +2,22 @@ _Utility HOCs_ -* [withCountries](#withCountries) -* [withFetching](#withFetching) -* [withFileDownload](#withFileDownload) -* [withFilePreview](#withFilePreview) -* [withPagination](#withPagination) -* [withRoles](#withRoles) -* [withZipDownload](#withZipDownload) +* [withCountries](#withcountries) +* [withFetching](#withfetching) +* [withFileDownload](#withfiledownload) +* [withFilePreview](#withfilepreview) +* [withPagination](#withpagination) +* [withRoles](#withroles) +* [withZipDownload](#withzipdownload) _HOCs used for files drag and drop_ -* [withFileSectionDrop](#withFileSectionDrop) -* [withNativeFileDrop](#withNativeFileDrop) +* [withFileSectionDrop](#withfilesectiondrop) +* [withNativeFileDrop](#withnativefiledrop) _Utility functions_ -* [handleError](#handleError) +* [handleError](#handleerror) # Utility HOCs @@ -97,7 +97,7 @@ const Wrapped = ({ downloadFile }) => ( </div> ) -export default Wrapped +export default withFileDownload(Wrapped) ``` ## withFilePreview @@ -112,6 +112,25 @@ This HOC assumes the following props are present on the wrapped component: * `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' +import { FileItem, withFilePreview Wrapped} from 'pubsweet-component-faraday-ui' + +const file = { + id: 'myfile', + name: 'myfile.pdf', + size: 100231, +} + +const Wrapped = ({ previewFile }) => ( + <div> + <FileItem item={file} onPreview={previewFile} /> + </div> +) + +export default withFilePreview(Wrapped) +``` + ## withPagination Injects `page`, `itemsPerPage`, `toFirst`, `nextPage`, `toLast`, `prevPage`, `changeItemsPerPage`, `hasMore`, `maxItems` and `paginatedItems` as props. -- GitLab From 7219a3ac01556cbd6be894edb19176258ad456f6 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Mon, 5 Nov 2018 17:26:23 +0200 Subject: [PATCH 05/49] docs(Component-faraday-ui): --- packages/component-faraday-ui/src/Text.js | 50 +++++++++++++--- .../src/gridItems/Item.js | 26 ++++++++- .../src/gridItems/Item.md | 38 +++++++++++++ .../component-faraday-ui/src/gridItems/Row.js | 26 ++++++++- .../component-faraday-ui/src/gridItems/Row.md | 57 +++++++++++++++++-- 5 files changed, 184 insertions(+), 13 deletions(-) diff --git a/packages/component-faraday-ui/src/Text.js b/packages/component-faraday-ui/src/Text.js index d8092434a..0368f97a3 100644 --- a/packages/component-faraday-ui/src/Text.js +++ b/packages/component-faraday-ui/src/Text.js @@ -1,30 +1,31 @@ import React from 'react' -import { has, get } from 'lodash' +import { get } from 'lodash' +import PropTypes from 'prop-types' import { th } from '@pubsweet/ui-toolkit' import styled, { css } from 'styled-components' import { paddingHelper, marginHelper } from './styledHelpers' const textHelper = props => { - if (has(props, 'secondary')) { + if (get(props, 'secondary')) { return css` color: ${th('colorSecondary')}; font-family: ${th('fontReading')}; ` } - if (has(props, 'error')) { + if (get(props, 'error')) { return css` color: ${th('colorError')}; font-family: ${th('fontReading')}; ` } - if (has(props, 'customId')) { + if (get(props, 'customId')) { return css` color: ${th('colorPrimary')}; font-family: ${th('fontInterface')}; ` } - if (has(props, 'labelLine')) { + if (get(props, 'labelLine')) { return css` color: ${th('colorFurnitureHue')}; font-family: ${th('fontInterface')}; @@ -38,7 +39,7 @@ const textHelper = props => { } ` } - if (has(props, 'journal')) { + if (get(props, 'journal')) { return css` color: ${th('colorSecondary')}; font-family: ${th('fontReading')}; @@ -88,7 +89,7 @@ const Root = styled.div` display: flex; ` -export default ({ bullet, children, ...rest }) => +const Text = ({ bullet, children, ...rest }) => bullet ? ( <Root> <Bullet>{'\u2022'}</Bullet> @@ -97,3 +98,38 @@ export default ({ bullet, children, ...rest }) => ) : ( <StyledText {...rest}>{children}</StyledText> ) + +Text.propTypes = { + /** if true */ + secondary: PropTypes.bool, + /** if true then object gets properties */ + error: PropTypes.bool, + /** if true then object gets properties */ + customId: PropTypes.bool, + /** if true then object gets properties */ + labelLine: PropTypes.bool, + /** if true then object gets properties */ + journal: PropTypes.bool, + /** if true thenobject gets properties */ + small: PropTypes.bool, + /** defines how items will be displayed */ + display: PropTypes.string, + /** defines how items will be aligned */ + align: PropTypes.string, + /** defines if there will be a white space */ + whiteSpace: PropTypes.string, +} + +Text.defaultProps = { + secondary: false, + error: false, + customId: false, + labelLine: false, + journal: false, + small: false, + display: 'inline-block', + align: 'start', + whiteSpace: 'initial', +} + +export default Text diff --git a/packages/component-faraday-ui/src/gridItems/Item.js b/packages/component-faraday-ui/src/gridItems/Item.js index 32b29bc61..6680ce0f5 100644 --- a/packages/component-faraday-ui/src/gridItems/Item.js +++ b/packages/component-faraday-ui/src/gridItems/Item.js @@ -1,10 +1,11 @@ import { isNumber } from 'lodash' +import PropTypes from 'prop-types' import styled from 'styled-components' import { marginHelper, paddingHelper } from 'pubsweet-component-faraday-ui' /** @component */ -export default styled.div.attrs({ +const Item = styled.div.attrs({ 'data-test-id': props => props['data-test-id'] || 'item', })` align-items: ${({ alignItems }) => alignItems || 'initial'}; @@ -17,3 +18,26 @@ export default styled.div.attrs({ ${marginHelper}; ${paddingHelper}; ` + +Item.propTypes = { + /** defines how flex items are laid out along the axis */ + alignItems: PropTypes.string, + /** is a sub-property for flexbox that sets flexible length on flexible items */ + flex: PropTypes.number, + /** specifies how flex items are placed in the flex container */ + vertical: PropTypes.bool, + /** sets whether flex items are forced onto one line or can wrap ont multiple ones */ + flexWrap: PropTypes.string, + /** specifies how the browser distributes space between and around items along the axis */ + justify: PropTypes.string, +} + +Item.defaultProps = { + alignItems: 'initial', + flex: 1, + vertical: false, + flexWrap: 'initial', + justify: 'initial', +} + +export default Item diff --git a/packages/component-faraday-ui/src/gridItems/Item.md b/packages/component-faraday-ui/src/gridItems/Item.md index f6f91b4d3..60aa616a3 100644 --- a/packages/component-faraday-ui/src/gridItems/Item.md +++ b/packages/component-faraday-ui/src/gridItems/Item.md @@ -7,6 +7,14 @@ An item. By default the content is displayed in a row. </Item> ``` +All items are wrapped into a flex container + +```js +<Item flex={1}> + <div>i m the only flex container</div> +</Item> +``` + Displayed in a column. ```js @@ -15,3 +23,33 @@ Displayed in a column. <span>I am at the bottom</span> </Item> ``` + +Items are aligned in their containing block + +```js +<Item alignItems="center" vertical> + <div>I m the first item</div> + <div>I m the second item</div> + <div>I m the third item</div> +</Item> +``` + +Long items wrap on the next row + +```js +<Item flexWrap="wrap"> + <div>wrap us together please, i m first, and i will be the longest to prove my point</div> + <div>wrap us together please, i m second</div> + <div>wrap us together please, i m last</div> +</Item> +``` + +Adds spaces between items + +```js +<Item justify="space-between"> + <div>group us from the left, i m first</div> + <div>group us from the left, i m second</div> + <div>group us from the left, i m last</div> +</Item> +``` diff --git a/packages/component-faraday-ui/src/gridItems/Row.js b/packages/component-faraday-ui/src/gridItems/Row.js index 794ed2b3f..4afa71d26 100644 --- a/packages/component-faraday-ui/src/gridItems/Row.js +++ b/packages/component-faraday-ui/src/gridItems/Row.js @@ -1,10 +1,11 @@ import { get } from 'lodash' +import PropTypes from 'prop-types' import styled from 'styled-components' import { heightHelper, marginHelper, paddingHelper } from '../styledHelpers' /** @component */ -export default styled.div.attrs({ +const Row = styled.div.attrs({ 'data-test-id': props => props['data-test-id'] || 'row', })` align-items: ${props => get(props, 'alignItems', 'flex-start')}; @@ -20,3 +21,26 @@ export default styled.div.attrs({ ${marginHelper}; ${paddingHelper}; ` + +Row.propTypes = { + /** defines how flex items are laid out along the axis */ + alignItems: PropTypes.string, + /** defines the background color */ + backgroundColor: PropTypes.string, + /** specifies how the browser distributes space between and around items along the axis */ + flexWrap: PropTypes.string, + /** specifies how the browser distributes space between and around items along the axis */ + justifyContent: PropTypes.string, + /** specifies the height of the item */ + height: PropTypes.string, +} + +Row.defaultProps = { + alignItems: 'flex-start', + bgColor: 'transparent', + flexWrap: 'initial', + justifyContent: 'space-evenly', + height: '100%', +} + +export default Row diff --git a/packages/component-faraday-ui/src/gridItems/Row.md b/packages/component-faraday-ui/src/gridItems/Row.md index 77bcd1717..c397c36e4 100644 --- a/packages/component-faraday-ui/src/gridItems/Row.md +++ b/packages/component-faraday-ui/src/gridItems/Row.md @@ -2,8 +2,57 @@ A row of items. ```js <Row> - <Item>Item 1</Item> - <Item>Item 2</Item> - <div>Item 3</div> + <Item>Item 1</Item> + <Item>Item 2</Item> + <Item>Item 3</Item> </Row> -``` \ No newline at end of file +``` + +Items are aligned in their containing block + +```js +<Row alignItems="flex-start" vertical> + <Item>I m the first item</Item> + <Item>I m the second item</Item> + <Item>I m the third item</Item> +</Row> +``` + +Long items wrap on the next row + +```js +<Row flexWrap="wrap"> + <Item> + wrap us together please, i m first, and i will be the longest to prove my + point + </Item> + <Item>wrap us together please, i m second</Item> + <Item>wrap us together please, i m last</Item> +</Row> +``` + +Adds spaces between items + +```js +<Row justifyContent="space-evenly"> + <Item>group us from the left, i m first</Item> + <Item>group us from the left, i m second</Item> + <Item>group us from the left, i m last</Item> +</Row> +``` + +The height of an item is specified + +```js +<Row height="100%"> + <Item>this is an item</Item> +</Row> +``` + +Adds color to the row + +```js +<Row bgColor="aqua"> + <Item>this is an item</Item> +</Row> +``` -- GitLab From 55cd4470a396f6cd380db852868dd148f7b428b3 Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Mon, 5 Nov 2018 17:40:12 +0200 Subject: [PATCH 06/49] docs(InviteHandlingEditor+InviteReviewer): Documentation for withInviteHandlingEditor and withInvite --- .../withInviteHandlingEditor.md | 28 +++++++ .../src/inviteReviewer/withInviteReviewer.md | 76 +++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md create mode 100644 packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md diff --git a/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md b/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md new file mode 100644 index 000000000..257c2b2a2 --- /dev/null +++ b/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md @@ -0,0 +1,28 @@ +## Hindawi Handling Editor Invite HOC. + +Injects `assignHE`, `revokeHE` and `onHEResponse` handlers as props. + +### withInviteHandlingEditor props + +* `inviteHandlingEditor: object`: namespace containing the following fields: + * `assignHE: function`: sends an invitation to the handling editor. + * `revokeHE: function`: revokes a sent invitation to the handling editor. + * `onHeResponse: function`: handles the handling editor's response. + +```javascript +const EditorInChiefPanel = ({ assignHE, revokeHE }) => ( + <Modal> + <span>Handlin d'Editor</span> + <button onClick={() => assignHE(email, {...modalProps, setFetching})}>Resend Invitation</button> + <button onClick={() => revokeHE(invitationId, {...modalProps, setFetching})}>Cancel Invitation</button> + </Modal> +) + +const HandlingEditorPanel = ({ onHeResponse }) => ( + <Modal> + <span>Accept invitation?</span> + <button onClick={() => onHeResponse(values, {...modalProps, setFetching})}>Yes</button> + <button onClick={() => onHeResponse(values, {...modalProps, setFetching})}>No</button> + </Modal> +) +``` diff --git a/packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md b/packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md new file mode 100644 index 000000000..e8d03b883 --- /dev/null +++ b/packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md @@ -0,0 +1,76 @@ +## Hindawi Reviewer Invite HOC. + +Injects `onInviteReviewer`, `onInvitePublonReviewer`, `onResendInviteReviewer`, `onRevokeInviteReviewer` and `onReviewerResponse` handlers as props. + +### withInviteReviewer props + +* `inviteReviewer: object`: namespace containing the following fields: + * `onInviteReviewer: function`: sends an invitation to the reviewer. + * `onInvitePublonReviewer: function`: sends an invitation to a Publon reviewer. + * `onResendInviteReviewer: function`: resends an invitation to an already invited reviewer. + * `onRevokeInviteReviewer: function`: cancels an invitation to an invited reviewer. + * `onReviewerResponse: function`: handles the reviewer response to the invitation. + +```javascript +const InviteReviewer = ({ + onInviteReviewer, + onInvitePublonReviewer, + onResendInviteReviewer, + onRevokeInviteReviewer, +}) => ( + <Modal> + <span>Reviewers list</span> + <div> + <span>Revi Ewerin</span> + <button + onClick={() => onInviteReviewer(values, { ...modalProps, setFetching })} + > + Invite + </button> + </div> + <div> + <span>Publonus re' Vyewer</span> + <button + onClick={() => + onInvitePublonReviewer(reviewerData, { ...modalProps, setFetching }) + } + > + Invite + </button> + </div> + <div> + <span>Rev d'Iewer</span> + <button + onClick={() => + onResendInviteReviewer(email, { ...modalProps, setFetching }) + } + > + Resend invitation + </button> + <button + onClick={() => + onRevokeInviteReviewer(invitationId, { ...modalProps, setFetching }) + } + > + Cancel invitation + </button> + </div> + </Modal> +) + +const Invitation = ({ onReviewerResponse }) => ( + <Modal> + <span>Accept invitation?</span> + <button + onClick={() => onReviewerResponse(values, { ...modalProps, setFetching })} + > + Yes + </button> + <button + onClick={() => onReviewerResponse(values, { ...modalProps, setFetching })} + > + No + </button> + </Modal> +) +``` -- GitLab From af72779f35a536b95e8abbeb6be9dfdf5b55fc45 Mon Sep 17 00:00:00 2001 From: Anca Ursachi <anca.ursachi@thinslices.com> Date: Mon, 5 Nov 2018 17:47:29 +0200 Subject: [PATCH 07/49] docs(component-faraday-ui): --- .../component-faraday-ui/src/AuthorTag.js | 18 +++++++++- .../component-faraday-ui/src/AuthorTagList.js | 34 +++++++++++++++---- .../src/AutosaveIndicator.js | 11 ++++++ .../src/EditorialReportCard.js | 30 ++++++++++++++++ .../component-faraday-ui/src/FileSection.js | 9 +++++ .../component-faraday-ui/src/IconButton.js | 34 ++++++++++++------- .../component-faraday-ui/src/IconTooltip.js | 18 ++++++++-- packages/component-faraday-ui/src/Label.js | 11 +++++- 8 files changed, 142 insertions(+), 23 deletions(-) diff --git a/packages/component-faraday-ui/src/AuthorTag.js b/packages/component-faraday-ui/src/AuthorTag.js index 1ac2a56a9..00168896f 100644 --- a/packages/component-faraday-ui/src/AuthorTag.js +++ b/packages/component-faraday-ui/src/AuthorTag.js @@ -1,7 +1,7 @@ import React from 'react' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' - +import PropTypes from 'prop-types' import Tag from './Tag' import Text from './Text' @@ -23,6 +23,22 @@ const AuthorTag = ({ </Root> ) +AuthorTag.propTypes = { + /** The author you want to be on the card. */ + author: PropTypes.shape({ + id: PropTypes.number, + firstName: PropTypes.number, + lastName: PropTypes.number, + isCorresponding: PropTypes.bool, + isSubmitting: PropTypes.bool, + affiliationNumber: PropTypes.number, + }), +} + +AuthorTag.defaultProps = { + author: undefined, +} + export default AuthorTag // #region styles diff --git a/packages/component-faraday-ui/src/AuthorTagList.js b/packages/component-faraday-ui/src/AuthorTagList.js index 5aea50c28..81f95ff2c 100644 --- a/packages/component-faraday-ui/src/AuthorTagList.js +++ b/packages/component-faraday-ui/src/AuthorTagList.js @@ -3,6 +3,7 @@ import { get } from 'lodash' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { compose, withProps, withStateHandlers } from 'recompose' +import PropTypes from 'prop-types' import { Row, @@ -42,13 +43,13 @@ const parseAffiliations = (authors = []) => ) const AuthorTagList = ({ - authors = [], + authors, affiliationList, - separator = `, `, - authorKey = 'id', - withTooltip = false, - withAffiliations = false, - showAffiliation = false, + separator, + authorKey, + withTooltip, + withAffiliations, + showAffiliation, toggleAffiliation, }) => ( <Root> @@ -112,6 +113,27 @@ export default compose( })), )(AuthorTagList) +AuthorTagList.propTypes = { + authorKey: PropTypes.string, + /** All authors we wanna see. */ + authors: PropTypes.arrayOf(PropTypes.object), + /** What separator to be used. */ + separator: PropTypes.string, + /** Tooltip about author details. */ + withTooltip: PropTypes.bool, + withAffiliations: PropTypes.bool, + showAffiliation: PropTypes.bool, +} + +AuthorTagList.defaultProps = { + authorKey: 'id', + authors: [], + separator: `, `, + withTooltip: false, + withAffiliations: false, + showAffiliation: false, +} + // #region styles const Root = styled.div` align-items: center; diff --git a/packages/component-faraday-ui/src/AutosaveIndicator.js b/packages/component-faraday-ui/src/AutosaveIndicator.js index 10335b7e8..2fa2048bd 100644 --- a/packages/component-faraday-ui/src/AutosaveIndicator.js +++ b/packages/component-faraday-ui/src/AutosaveIndicator.js @@ -6,6 +6,7 @@ import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { Icon, Spinner } from '@pubsweet/ui' import { compose, setDisplayName, withStateHandlers } from 'recompose' +import PropTypes from 'prop-types' import Text from './Text' @@ -99,6 +100,16 @@ export default compose( setDisplayName('AutosaveIndicator'), )(AutosaveIndicator) +AutosaveIndicator.propTypes = { + /** Make appear loader until save. */ + autosave: PropTypes.objectOf( + PropTypes.oneOfType([PropTypes.bool, PropTypes.date, PropTypes.string]), + ), +} + +AutosaveIndicator.defaultProps = { + autosave: undefined, +} // #region styles const Root = styled.div` align-items: center; diff --git a/packages/component-faraday-ui/src/EditorialReportCard.js b/packages/component-faraday-ui/src/EditorialReportCard.js index 1f394ee94..60c667b5a 100644 --- a/packages/component-faraday-ui/src/EditorialReportCard.js +++ b/packages/component-faraday-ui/src/EditorialReportCard.js @@ -4,6 +4,7 @@ import { withProps, withHandlers, compose } from 'recompose' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { DateParser } from '@pubsweet/ui' +import PropTypes from 'prop-types' import { Label, Item, Row, Text, Tag } from './' import { getReportComments } from './helpers' @@ -111,6 +112,35 @@ export default compose( ), )(EditorialReportCard) +EditorialReportCard.propTypes = { + /** Label that will be view by public persons. */ + publicLabel: PropTypes.string, + /** Label that will be view by private persons like Editorial Team. */ + privateLabel: PropTypes.string, + /** Message by editorial team and other information. */ + 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, + reviewer: PropTypes.object, + }), + /** What is the decision/recommendation by editorial team. */ + journal: PropTypes.shape({ + recommendation: PropTypes.arrayOf(PropTypes.object), + }), +} + +EditorialReportCard.defaultProps = { + publicLabel: '', + privateLabel: '', + report: undefined, + journal: undefined, +} // #region styles const Root = styled.div` box-shadow: ${th('boxShadow')}; diff --git a/packages/component-faraday-ui/src/FileSection.js b/packages/component-faraday-ui/src/FileSection.js index 596f65e84..8a252859e 100644 --- a/packages/component-faraday-ui/src/FileSection.js +++ b/packages/component-faraday-ui/src/FileSection.js @@ -3,6 +3,7 @@ import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { FilePicker, Spinner } from '@pubsweet/ui' import { compose, withState, withHandlers, withProps } from 'recompose' +import PropTypes from 'prop-types' import { radiusHelpers } from './styledHelpers' import { withNativeFileDrop, withFileSectionDrop } from './helpers' @@ -130,6 +131,14 @@ export default compose( withNativeFileDrop, )(FileSection) +FileSection.propTypes = { + /** Files that are uploaded. */ + files: PropTypes.arrayOf(PropTypes.object), +} + +FileSection.defaultProps = { + files: undefined, +} // #region styles const Root = styled.div` background: ${props => diff --git a/packages/component-faraday-ui/src/IconButton.js b/packages/component-faraday-ui/src/IconButton.js index 5e4b4acfc..58e6ce1d0 100644 --- a/packages/component-faraday-ui/src/IconButton.js +++ b/packages/component-faraday-ui/src/IconButton.js @@ -1,10 +1,19 @@ import React from 'react' import { Icon } from '@pubsweet/ui' import styled from 'styled-components' +import PropTypes from 'prop-types' import { positionHelper, marginHelper, paddingHelper } from './styledHelpers' -const IconButton = styled.div` +const IconButton = ({ icon, onClick, iconSize = 3, disabled, ...props }) => ( + <Root disabled={disabled} onClick={!disabled ? onClick : null} {...props}> + <Icon size={iconSize} {...props}> + {icon} + </Icon> + </Root> +) + +const Root = styled.div` align-items: center; cursor: pointer; display: flex; @@ -23,15 +32,16 @@ const IconButton = styled.div` ${paddingHelper}; ${positionHelper}; ` +IconButton.propTypes = { + /** Icon name */ + icon: PropTypes.string, + /** Icon size */ + iconSize: PropTypes.number, +} -export default ({ icon, onClick, iconSize = 3, disabled, ...props }) => ( - <IconButton - disabled={disabled} - onClick={!disabled ? onClick : null} - {...props} - > - <Icon size={iconSize} {...props}> - {icon} - </Icon> - </IconButton> -) +IconButton.defaultProps = { + icon: '', + iconSize: 3, +} + +export default IconButton diff --git a/packages/component-faraday-ui/src/IconTooltip.js b/packages/component-faraday-ui/src/IconTooltip.js index 75c537efa..e20e03e86 100644 --- a/packages/component-faraday-ui/src/IconTooltip.js +++ b/packages/component-faraday-ui/src/IconTooltip.js @@ -2,6 +2,7 @@ import React, { Fragment } from 'react' import 'react-tippy/dist/tippy.css' import { Tooltip } from 'react-tippy' import { ThemeProvider, withTheme } from 'styled-components' +import PropTypes from 'prop-types' import { IconButton } from './' @@ -9,8 +10,8 @@ const IconTooltip = ({ theme, primary, interactive, - icon = 'help-circle', - iconSize = 3, + icon, + iconSize, ...rest }) => ( <Tooltip @@ -31,5 +32,16 @@ const InfoTooltip = ({ theme, content }) => ( <Fragment>{typeof content === 'function' ? content() : content}</Fragment> </ThemeProvider> ) +IconTooltip.propTypes = { + /** Icon name */ + icon: PropTypes.string, + /** Icon size */ + iconSize: PropTypes.number, +} -export default withTheme(IconTooltip) +IconTooltip.defaultProps = { + icon: 'help-circle', + iconSize: 3, +} + +export default IconTooltip diff --git a/packages/component-faraday-ui/src/Label.js b/packages/component-faraday-ui/src/Label.js index 5cbdf0696..18d44f023 100644 --- a/packages/component-faraday-ui/src/Label.js +++ b/packages/component-faraday-ui/src/Label.js @@ -2,16 +2,25 @@ import React from 'react' import { H4 } from '@pubsweet/ui' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' +import PropTypes from 'prop-types' import { marginHelper } from './' -const Label = ({ children, required = false, ...rest }) => ( +const Label = ({ children, required, ...rest }) => ( <Root {...rest}> <H4>{children}</H4> {required && <Required>*</Required>} </Root> ) +Label.propTypes = { + /** Mention if the label is require or not. */ + required: PropTypes.bool, +} + +Label.defaultProps = { + required: false, +} export default Label // #region styles -- GitLab From 6cb52aadce25483c03077ad4d6708b6b3278f16b Mon Sep 17 00:00:00 2001 From: Anca Ursachi <anca.ursachi@thinslices.com> Date: Mon, 5 Nov 2018 17:59:02 +0200 Subject: [PATCH 08/49] docs(iconTooltip): Resolve pipeline problems --- packages/component-faraday-ui/src/IconTooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/component-faraday-ui/src/IconTooltip.js b/packages/component-faraday-ui/src/IconTooltip.js index e20e03e86..418cb018c 100644 --- a/packages/component-faraday-ui/src/IconTooltip.js +++ b/packages/component-faraday-ui/src/IconTooltip.js @@ -44,4 +44,4 @@ IconTooltip.defaultProps = { iconSize: 3, } -export default IconTooltip +export default withTheme(IconTooltip) -- GitLab From 79062906324f0d1cf9b06ca567675e0adb1d8771 Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Tue, 6 Nov 2018 09:46:44 +0200 Subject: [PATCH 09/49] docs(faraday-ui): update grid items docs --- packages/component-faraday-ui/src/gridItems/Item.js | 10 +++++----- packages/component-faraday-ui/src/gridItems/Row.js | 12 ++++++------ .../src/helpers/{helpers.md => README.md} | 0 3 files changed, 11 insertions(+), 11 deletions(-) rename packages/component-faraday-ui/src/helpers/{helpers.md => README.md} (100%) diff --git a/packages/component-faraday-ui/src/gridItems/Item.js b/packages/component-faraday-ui/src/gridItems/Item.js index 6680ce0f5..a784d8561 100644 --- a/packages/component-faraday-ui/src/gridItems/Item.js +++ b/packages/component-faraday-ui/src/gridItems/Item.js @@ -20,15 +20,15 @@ const Item = styled.div.attrs({ ` Item.propTypes = { - /** defines how flex items are laid out along the axis */ + /** Defines how flex items are laid out along the secondary axis. */ alignItems: PropTypes.string, - /** is a sub-property for flexbox that sets flexible length on flexible items */ + /** How much space should this item take relative to the other items. */ flex: PropTypes.number, - /** specifies how flex items are placed in the flex container */ + /** Sets the flex direction. If true items are layed out in a column. */ vertical: PropTypes.bool, - /** sets whether flex items are forced onto one line or can wrap ont multiple ones */ + /** Sets whether flex items are forced onto one line or can wrap on multiple ones. */ flexWrap: PropTypes.string, - /** specifies how the browser distributes space between and around items along the axis */ + /** Specifies alignment along the main axis. */ justify: PropTypes.string, } diff --git a/packages/component-faraday-ui/src/gridItems/Row.js b/packages/component-faraday-ui/src/gridItems/Row.js index 4afa71d26..54c7faacf 100644 --- a/packages/component-faraday-ui/src/gridItems/Row.js +++ b/packages/component-faraday-ui/src/gridItems/Row.js @@ -23,15 +23,15 @@ const Row = styled.div.attrs({ ` Row.propTypes = { - /** defines how flex items are laid out along the axis */ + /** Defines how flex items are laid out along the seconday axis. */ alignItems: PropTypes.string, - /** defines the background color */ - backgroundColor: PropTypes.string, - /** specifies how the browser distributes space between and around items along the axis */ + /** Defines the background color. */ + bgColor: PropTypes.string, + /** Sets whether flex items are forced onto one line or can wrap on multiple ones. */ flexWrap: PropTypes.string, - /** specifies how the browser distributes space between and around items along the axis */ + /** Specifies alignment along the main axis. */ justifyContent: PropTypes.string, - /** specifies the height of the item */ + /** Set the height in pixels. */ height: PropTypes.string, } diff --git a/packages/component-faraday-ui/src/helpers/helpers.md b/packages/component-faraday-ui/src/helpers/README.md similarity index 100% rename from packages/component-faraday-ui/src/helpers/helpers.md rename to packages/component-faraday-ui/src/helpers/README.md -- GitLab From 793ebead6ad57b63a163f8783ab1807e047ff4cc Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 6 Nov 2018 10:49:40 +0200 Subject: [PATCH 10/49] docs(faradai-ui): update tag items docs --- packages/component-faraday-ui/src/Tag.js | 23 +++++++++++++++++++---- packages/component-faraday-ui/src/Text.js | 18 +++++++++--------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/packages/component-faraday-ui/src/Tag.js b/packages/component-faraday-ui/src/Tag.js index fd6ce0316..3c6997d15 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 0368f97a3..06d321cd4 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, } -- GitLab From 16b386c064ff7e732923ff86fe2550b30e03945c Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Tue, 6 Nov 2018 11:28:29 +0200 Subject: [PATCH 11/49] docs(InviteHandlingEditor+InviteReviewer): Changed prop list to table and renamed files to README.md --- .../src/inviteHandlingEditor/README.md | 46 +++++++++++++++++++ .../withInviteHandlingEditor.md | 28 ----------- .../{withInviteReviewer.md => README.md} | 24 ++++++---- 3 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 packages/component-manuscript/src/inviteHandlingEditor/README.md delete mode 100644 packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md rename packages/component-manuscript/src/inviteReviewer/{withInviteReviewer.md => README.md} (62%) diff --git a/packages/component-manuscript/src/inviteHandlingEditor/README.md b/packages/component-manuscript/src/inviteHandlingEditor/README.md new file mode 100644 index 000000000..665c53eb1 --- /dev/null +++ b/packages/component-manuscript/src/inviteHandlingEditor/README.md @@ -0,0 +1,46 @@ +## Hindawi Handling Editor Invite HOC. + +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_ + +```javascript +const EditorInChiefPanel = ({ assignHE, revokeHE }) => ( + <Modal> + <span>Handlin d'Editor</span> + <button onClick={() => assignHE(email, { ...modalProps, setFetching })}> + Resend Invitation + </button> + <button + onClick={() => revokeHE(invitationId, { ...modalProps, setFetching })} + > + Cancel Invitation + </button> + </Modal> +) + +const HandlingEditorPanel = ({ onHeResponse }) => ( + <Modal> + <span>Accept invitation?</span> + <button + onClick={() => onHeResponse(reduxFormValues, { ...modalProps, setFetching })} + > + Yes + </button> + <button + onClick={() => onHeResponse(reduxFormValues, { ...modalProps, setFetching })} + > + No + </button> + </Modal> +) +``` diff --git a/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md b/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md deleted file mode 100644 index 257c2b2a2..000000000 --- a/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md +++ /dev/null @@ -1,28 +0,0 @@ -## Hindawi Handling Editor Invite HOC. - -Injects `assignHE`, `revokeHE` and `onHEResponse` handlers as props. - -### withInviteHandlingEditor props - -* `inviteHandlingEditor: object`: namespace containing the following fields: - * `assignHE: function`: sends an invitation to the handling editor. - * `revokeHE: function`: revokes a sent invitation to the handling editor. - * `onHeResponse: function`: handles the handling editor's response. - -```javascript -const EditorInChiefPanel = ({ assignHE, revokeHE }) => ( - <Modal> - <span>Handlin d'Editor</span> - <button onClick={() => assignHE(email, {...modalProps, setFetching})}>Resend Invitation</button> - <button onClick={() => revokeHE(invitationId, {...modalProps, setFetching})}>Cancel Invitation</button> - </Modal> -) - -const HandlingEditorPanel = ({ onHeResponse }) => ( - <Modal> - <span>Accept invitation?</span> - <button onClick={() => onHeResponse(values, {...modalProps, setFetching})}>Yes</button> - <button onClick={() => onHeResponse(values, {...modalProps, setFetching})}>No</button> - </Modal> -) -``` diff --git a/packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md b/packages/component-manuscript/src/inviteReviewer/README.md similarity index 62% rename from packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md rename to packages/component-manuscript/src/inviteReviewer/README.md index e8d03b883..f8bae3787 100644 --- a/packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md +++ b/packages/component-manuscript/src/inviteReviewer/README.md @@ -4,12 +4,16 @@ Injects `onInviteReviewer`, `onInvitePublonReviewer`, `onResendInviteReviewer`, ### withInviteReviewer props -* `inviteReviewer: object`: namespace containing the following fields: - * `onInviteReviewer: function`: sends an invitation to the reviewer. - * `onInvitePublonReviewer: function`: sends an invitation to a Publon reviewer. - * `onResendInviteReviewer: function`: resends an invitation to an already invited reviewer. - * `onRevokeInviteReviewer: function`: cancels an invitation to an invited reviewer. - * `onReviewerResponse: function`: handles the reviewer response to the invitation. +`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 + +_Note: The functions must be used withing a modal_ ```javascript const InviteReviewer = ({ @@ -62,12 +66,16 @@ const Invitation = ({ onReviewerResponse }) => ( <Modal> <span>Accept invitation?</span> <button - onClick={() => onReviewerResponse(values, { ...modalProps, setFetching })} + onClick={() => + onReviewerResponse(reduxFormValues, { ...modalProps, setFetching }) + } > Yes </button> <button - onClick={() => onReviewerResponse(values, { ...modalProps, setFetching })} + onClick={() => + onReviewerResponse(reduxFormValues, { ...modalProps, setFetching }) + } > No </button> -- GitLab From 8fe92f2009393945300a042cf8dc7484b3f382ef Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Tue, 6 Nov 2018 11:29:21 +0200 Subject: [PATCH 12/49] docs(faraday-ui): write props inside a table --- .../src/helpers/README.md | 101 +++++++++++------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/packages/component-faraday-ui/src/helpers/README.md b/packages/component-faraday-ui/src/helpers/README.md index 15a652d3e..588a016a3 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' -- GitLab From f2979487f00471d0368a63848fde72e44f9288df Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Tue, 6 Nov 2018 12:56:54 +0200 Subject: [PATCH 13/49] docs(HandleRecommendation): Wrote documentation for withHandleRecommendation HOC --- .../src/handleRecommendation/README.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 packages/component-manuscript/src/handleRecommendation/README.md diff --git a/packages/component-manuscript/src/handleRecommendation/README.md b/packages/component-manuscript/src/handleRecommendation/README.md new file mode 100644 index 000000000..783844056 --- /dev/null +++ b/packages/component-manuscript/src/handleRecommendation/README.md @@ -0,0 +1,45 @@ +## Hindawi Handling Recommendation HOC. + +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_ + +```javascript +const HERecommendationPanel = ({ createRecommendation }) => ( + <Modal> + <span>Recommend the manuscript for:</span> + <select> + <option>Approve</option> + <option>Reject</option> + <option>Minor revision</option> + <option>Major revision</option> + </select> + <button onClick={() => createRecommendation(reduxFormValues, { ...modalProps, setFetching })}> + Submit + </button> + </Modal> +) + +const EICDecisionPanel = ({ onEditorialRecommendation }) => ( + <Modal> + <span>Take decision to:</span> + <select> + <option>Approve</option> + <option>Reject</option> + <option>Minor revision</option> + <option>Major revision</option> + </select> + <button onClick={() => onEditorialRecommendation(reduxFormValues, { ...modalProps, setFetching })}> + Submit + </button> + </Modal> +) +``` -- GitLab From 5bc888c7ad02750375d4d28640c7ae4f72d42439 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 6 Nov 2018 15:17:32 +0200 Subject: [PATCH 14/49] docs(faraday-ui): --- packages/component-faraday-ui/src/Tabs.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/component-faraday-ui/src/Tabs.js b/packages/component-faraday-ui/src/Tabs.js index a7d90025d..57deca667 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 = { + /** property that sets any tab as curent selcted tab */ + selectedTab: PropTypes.func, + /** property that changes tab on click */ + changeTab: PropTypes.func, +} + +Tabs.defaultProp = { + selectedTab: undefined, + changeTab: undefined, +} + export default compose( withStateHandlers(({ selectedTab = 0 }) => ({ selectedTab }), { changeTab: () => selectedTab => ({ -- GitLab From 7ce27f56c56b87b12f7f913c6cb8fbae46814798 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 6 Nov 2018 15:35:24 +0200 Subject: [PATCH 15/49] docs(faraday-ui): --- .../src/ReviewersTable.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/component-faraday-ui/src/ReviewersTable.js b/packages/component-faraday-ui/src/ReviewersTable.js index 9f9e2aaa7..69253a9eb 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' @@ -94,6 +95,26 @@ const orderInvitations = i => { return 1 } +ReviewersTable.propTypes = { + /** passes */ + invitations: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string, + role: PropTypes.string, + type: PropTypes.string, + userId: PropTypes.string, + hasAnswer: PropTypes.bool, + invitedOn: PropTypes.number, + isAccepted: PropTypes.bool, + respondedOn: PropTypes.number, + }), + ), +} + +ReviewersTable.defaultProps = { + invitations: [], +} + export default compose( shouldUpdate( ({ invitations }, { invitations: nextInvitations }) => -- GitLab From f6d16a961d0d1200c8e88018df3db060da3e3626 Mon Sep 17 00:00:00 2001 From: Anca Ursachi <anca.ursachi@thinslices.com> Date: Tue, 6 Nov 2018 16:12:23 +0200 Subject: [PATCH 16/49] docs(component-faraday-ui): --- packages/component-faraday-ui/src/Logo.js | 11 ++++- .../src/ManuscriptCard.js | 15 ++++++- .../src/ManuscriptCard.md | 40 ------------------- .../component-faraday-ui/src/Pagination.js | 4 +- .../component-faraday-ui/src/PersonInfo.js | 27 +++++++------ .../src/ReviewerBreakdown.js | 26 +++++++++--- .../src/ReviewerReport.js | 32 +++++++++++++-- .../src/ReviewerReportAuthor.js | 27 +++++++++++++ 8 files changed, 115 insertions(+), 67 deletions(-) diff --git a/packages/component-faraday-ui/src/Logo.js b/packages/component-faraday-ui/src/Logo.js index 338312793..ddc7b7b7a 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 17e9e1763..f6647ffb9 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,16 @@ export default compose( setDisplayName('ManuscriptCard'), )(ManuscriptCard) +ManuscriptCard.propTypes = { + manuscriptType: PropTypes.oneOfType(PropTypes.object), + fragment: PropTypes.oneOfType(PropTypes.object).isRequired, + collection: PropTypes.oneOfType(PropTypes.object).isRequired, +} + +ManuscriptCard.defaultProps = { + manuscriptType: {}, +} + // #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 aea9f0e6c..e8d9bccea 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 2078907f8..c0f38b45a 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 7d9ce203b..bca7e16d1 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 7d257102a..66aa094b0 100644 --- a/packages/component-faraday-ui/src/ReviewerBreakdown.js +++ b/packages/component-faraday-ui/src/ReviewerBreakdown.js @@ -1,10 +1,11 @@ import React from 'react' -import { get } from 'lodash' +// import { get } from 'lodash' import { compose, withHandlers, withProps } from 'recompose' - +import PropTypes from 'prop-types' import { Text, Row } from './' -const ReviewerBreakdown = ({ getReportBreakdown }) => getReportBreakdown() +const ReviewerBreakdown = ({ getReportBreakdown, fragment }) => + getReportBreakdown() const roleFilter = role => i => i.role === role const submittedFilter = r => r.review && r.review.submittedOn @@ -18,9 +19,9 @@ const reviewerReduce = (acc, r) => ({ }) export default compose( - withProps(({ fragment }) => ({ - invitations: get(fragment, 'invitations', []), - recommendations: get(fragment, 'recommendations', []), + withProps(({ fragment: { invitations = [], recommendations = [] } }) => ({ + invitations, + recommendations, })), withHandlers({ getReportBreakdown: ({ invitations, recommendations, ...rest }) => () => { @@ -62,3 +63,16 @@ export default compose( }, }), )(ReviewerBreakdown) + +ReviewerBreakdown.propTypes = { + fragment: PropTypes.shape({ + invitations: PropTypes.arrayOf(PropTypes.object), + recommendations: PropTypes.arrayOf(PropTypes.object), + }), +} +ReviewerBreakdown.defaultProps = { + fragment: { + invitations: [], + recommendations: [], + }, +} diff --git a/packages/component-faraday-ui/src/ReviewerReport.js b/packages/component-faraday-ui/src/ReviewerReport.js index 12391694d..6eb95dc54 100644 --- a/packages/component-faraday-ui/src/ReviewerReport.js +++ b/packages/component-faraday-ui/src/ReviewerReport.js @@ -4,19 +4,20 @@ import { withProps } from 'recompose' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { DateParser } from '@pubsweet/ui' - +import PropTypes from 'prop-types' import { Label, Item, FileItem, Row, Text } from './' const ReviewerReport = ({ onPreview, onDownload, reportFile, + journal, publicReport, privateReport, reviewerName, reviewerIndex, recommendation, - showOwner = false, + showOwner, report: { submittedOn }, }) => ( <Root> @@ -76,7 +77,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 +92,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 4df5745b8..d1530006d 100644 --- a/packages/component-faraday-ui/src/ReviewerReportAuthor.js +++ b/packages/component-faraday-ui/src/ReviewerReportAuthor.js @@ -4,6 +4,7 @@ import { withProps, compose } from 'recompose' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { DateParser } from '@pubsweet/ui' +import PropTypes from 'prop-types' import { Label, @@ -16,6 +17,7 @@ import { } from './' const ReviewerReportAuthor = ({ + journal, reviewFile, previewFile, downloadFile, @@ -82,6 +84,31 @@ 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')}; -- GitLab From b91ad2d7ed0133e13656188151df675130469008 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 6 Nov 2018 16:12:33 +0200 Subject: [PATCH 17/49] docs(faraday-ui): --- packages/component-faraday-ui/src/ReviewersTable.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/component-faraday-ui/src/ReviewersTable.js b/packages/component-faraday-ui/src/ReviewersTable.js index 69253a9eb..2f4625288 100644 --- a/packages/component-faraday-ui/src/ReviewersTable.js +++ b/packages/component-faraday-ui/src/ReviewersTable.js @@ -9,7 +9,7 @@ import { compose, shouldUpdate, withHandlers, withProps } from 'recompose' import { Label, PersonInvitation, Text } from '../' const ReviewersTable = ({ - invitations, + invitations = [], getInvitationStatus, renderAcceptedLabel, onResendReviewerInvite, @@ -96,16 +96,24 @@ const orderInvitations = i => { } ReviewersTable.propTypes = { - /** passes */ + /** 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, }), ), -- GitLab From 8bc5bd345a41f92344f6e02908238c462e70d8cf Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 6 Nov 2018 16:55:35 +0200 Subject: [PATCH 18/49] docs(faraday-ui): --- .../src/ReviewersTable.js | 18 +++++----- .../component-faraday-ui/src/WizardFiles.js | 36 +++++++++++++++++++ 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/packages/component-faraday-ui/src/ReviewersTable.js b/packages/component-faraday-ui/src/ReviewersTable.js index 2f4625288..e2ed71185 100644 --- a/packages/component-faraday-ui/src/ReviewersTable.js +++ b/packages/component-faraday-ui/src/ReviewersTable.js @@ -96,24 +96,24 @@ const orderInvitations = i => { } ReviewersTable.propTypes = { - /** passes properties for invited reviewwers */ + /** Passes properties for invited reviewwers. */ invitations: PropTypes.arrayOf( PropTypes.shape({ - /** reviewers unique id */ + /** Reviewers unique id. */ id: PropTypes.string, - /** reviewers role */ + /** Reviewers role. */ role: PropTypes.string, - /** type of invitation */ + /** Type of invitation. */ type: PropTypes.string, - /** users unique id */ + /** Users unique id. */ userId: PropTypes.string, - /** reviewer has responded */ + /** Reviewer has responded. */ hasAnswer: PropTypes.bool, - /** date of invite */ + /** Date of invite. */ invitedOn: PropTypes.number, - /** reviewer has accepted */ + /** Reviewer has accepted. */ isAccepted: PropTypes.bool, - /** date of the response */ + /** Date of the response. */ respondedOn: PropTypes.number, }), ), diff --git a/packages/component-faraday-ui/src/WizardFiles.js b/packages/component-faraday-ui/src/WizardFiles.js index 9bd0591a7..2d7016178 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,38 @@ 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.oneOfType(PropTypes.array), +} +WizardFiles.defaultProps = { + manuscripts: [], + coverLetter: [], + supplementary: [], +} + export default compose( withFilePreview, withFileDownload, -- GitLab From 055ff076bb97aae2d2f85b6ef946fe33ca8e443d Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Tue, 6 Nov 2018 17:10:01 +0200 Subject: [PATCH 19/49] docs(faraday-ui): fix some props that anca wrote --- packages/component-faraday-ui/src/AuthorTag.js | 6 +++--- .../component-faraday-ui/src/AutosaveIndicator.js | 6 ++---- packages/component-faraday-ui/src/ContextualBox.js | 11 +++++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/component-faraday-ui/src/AuthorTag.js b/packages/component-faraday-ui/src/AuthorTag.js index 00168896f..4ec4cf6a3 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 2fa2048bd..1a3b309ff 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 40e3e6f5f..f2c0d0d9b 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 -- GitLab From 3f5bf7a7108f3e3368b1b663ed1bb68d4fe7a93c Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Tue, 6 Nov 2018 17:37:57 +0200 Subject: [PATCH 20/49] docs(SubmitRevision): WIP withSubmitRevision HOC documentation --- .../src/submitRevision/README.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/component-manuscript/src/submitRevision/README.md diff --git a/packages/component-manuscript/src/submitRevision/README.md b/packages/component-manuscript/src/submitRevision/README.md new file mode 100644 index 000000000..1768825b9 --- /dev/null +++ b/packages/component-manuscript/src/submitRevision/README.md @@ -0,0 +1,48 @@ +## Hindawi Submit Revision HOC. + +The `withSubmitRevision` HOC contains the logic for submitting a manuscript version. It contains the following utility HOCs: + +* `withFetching` +* `withFilePreview` +* `withFileDownload` +* `withModal` + +..as well as other `recompose` HOCs. + +### withSubmitRevision props + +`submitRevision` namespace contains the following fields: +Name|Type|Description +---|---|--- +initialValues|`{...fragment}`| Object containing the initial state of the fragment +addFile|`({ file: object, type: string, fragment: object }) => any`|Uploads the file to the server +journal|`function`|Des Cri Pti On! +history|`object`|Added by `react-router` to allow navigation +fragment|`function`|Des Cri Pti On! +canSubmit|`function`|Des Cri Pti On! +addAuthor|`function`|Des Cri Pti On! +showModal|`function`|Des Cri Pti On! +changeForm|`function`|Des Cri Pti On! +collection|`function`|Des Cri Pti On! +isFetching|`function`|Des Cri Pti On! +deleteFile|`function`|Des Cri Pti On! +currentUser|`function`|Des Cri Pti On! +setFetching|`function`|Des Cri Pti On! +previewFile|`function`|Des Cri Pti On! +downloadFile|`function`|Des Cri Pti On! +onAuthorEdit|`function`|Des Cri Pti On! +deleteAuthor|`function`|Des Cri Pti On! +getSignedUrl|`function`|Des Cri Pti On! +hasFormError|`function`|Des Cri Pti On! +formErrors|`function`|Des Cri Pti On! +fetchingError|`string`|Value representing a server request error +addResponseFile|`file => any`|Uploads the file and adds it on the form +deleteResponseFile|`file => any`|Deletes the file from the server and removes it from the form +isEditingAuthor|`bool`|Value representing if the current user is the editing author +onChange|`(reduxFormValues, dispatch, { collection, fragment }) => any`|Used to autosave new fragment when fields change +onSubmit|`(reduxFormValues, dispatch, { history, fragment, collection, showModal, setFetching, canSubmit })`|Handles the submission of a new manuscript version +validate|`({ editAuthors, files, responseToReviewers }) => errors: object`|Checks the form for required fields and returns the errors +responseFile|`file`|Value containing the revision's file for the reviewer's response + +```javascript +``` -- GitLab From 2d9baa4a954c5d8d79fe647e92ae19d947a5fb4a Mon Sep 17 00:00:00 2001 From: Anca Ursachi <anca.ursachi@thinslices.com> Date: Tue, 6 Nov 2018 17:56:23 +0200 Subject: [PATCH 21/49] docs(appBar): --- packages/component-faraday-ui/src/AppBar.js | 28 +++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/component-faraday-ui/src/AppBar.js b/packages/component-faraday-ui/src/AppBar.js index 80dc030cc..146f337e9 100644 --- a/packages/component-faraday-ui/src/AppBar.js +++ b/packages/component-faraday-ui/src/AppBar.js @@ -5,14 +5,15 @@ import { H2, Button } from '@pubsweet/ui' import { th } from '@pubsweet/ui-toolkit' import { compose, setDisplayName, withProps } from 'recompose' import { Item, Row, Text } from 'pubsweet-component-faraday-ui' +import PropTypes from 'prop-types' const AppBar = ({ logo: Logo, menu: Menu, createDraft, - canCreateDraft = true, - currentUser = {}, - fixed = true, + canCreateDraft, + currentUser, + fixed, isSubmit, autosave: Autosave, journal: { metadata: { backgroundImage } }, @@ -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')}; -- GitLab From 7b0f7ef723fba5736c1f4a3fbbd97efc483a88cf Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Tue, 6 Nov 2018 18:02:25 +0200 Subject: [PATCH 22/49] docs(faraday-ui): fix invalid prop types for some components --- packages/component-faraday-ui/src/AppBar.js | 6 +- .../src/ManuscriptCard.js | 9 +- .../src/ReviewerBreakdown.js | 87 +++++++++---------- .../src/ReviewerReport.js | 9 +- .../src/ReviewerReportAuthor.js | 13 +-- .../src/ReviewersTable.js | 2 +- packages/component-faraday-ui/src/Tabs.js | 10 +-- .../component-faraday-ui/src/WizardFiles.js | 11 ++- 8 files changed, 74 insertions(+), 73 deletions(-) diff --git a/packages/component-faraday-ui/src/AppBar.js b/packages/component-faraday-ui/src/AppBar.js index 80dc030cc..9c3384686 100644 --- a/packages/component-faraday-ui/src/AppBar.js +++ b/packages/component-faraday-ui/src/AppBar.js @@ -7,13 +7,14 @@ import { compose, setDisplayName, withProps } from 'recompose' import { Item, Row, Text } from 'pubsweet-component-faraday-ui' const AppBar = ({ + theme, + isSubmit, logo: Logo, menu: Menu, createDraft, canCreateDraft = true, currentUser = {}, fixed = true, - isSubmit, 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> @@ -140,6 +141,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/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index f6647ffb9..8b86a6910 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -139,13 +139,8 @@ export default compose( )(ManuscriptCard) ManuscriptCard.propTypes = { - manuscriptType: PropTypes.oneOfType(PropTypes.object), - fragment: PropTypes.oneOfType(PropTypes.object).isRequired, - collection: PropTypes.oneOfType(PropTypes.object).isRequired, -} - -ManuscriptCard.defaultProps = { - manuscriptType: {}, + fragment: PropTypes.object.isRequired, // eslint-disable-line + collection: PropTypes.object.isRequired, // eslint-disable-line } // #region styles diff --git a/packages/component-faraday-ui/src/ReviewerBreakdown.js b/packages/component-faraday-ui/src/ReviewerBreakdown.js index 66aa094b0..8e5144610 100644 --- a/packages/component-faraday-ui/src/ReviewerBreakdown.js +++ b/packages/component-faraday-ui/src/ReviewerBreakdown.js @@ -1,11 +1,7 @@ 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, fragment }) => - getReportBreakdown() +import { Text, Row } from './' const roleFilter = role => i => i.role === role const submittedFilter = r => r.review && r.review.submittedOn @@ -18,51 +14,46 @@ const reviewerReduce = (acc, r) => ({ submitted: submittedFilter(r) ? acc.submitted + 1 : acc.submitted, }) -export default compose( - withProps(({ fragment: { invitations = [], recommendations = [] } }) => ({ - invitations, - 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> - ) - }, - }), -)(ReviewerBreakdown) + <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({ @@ -76,3 +67,5 @@ ReviewerBreakdown.defaultProps = { recommendations: [], }, } + +export default ReviewerBreakdown diff --git a/packages/component-faraday-ui/src/ReviewerReport.js b/packages/component-faraday-ui/src/ReviewerReport.js index 6eb95dc54..5d728ccde 100644 --- a/packages/component-faraday-ui/src/ReviewerReport.js +++ b/packages/component-faraday-ui/src/ReviewerReport.js @@ -1,23 +1,24 @@ 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 PropTypes from 'prop-types' +import { th } from '@pubsweet/ui-toolkit' + import { Label, Item, FileItem, Row, Text } from './' const ReviewerReport = ({ + journal, + showOwner, onPreview, onDownload, reportFile, - journal, publicReport, privateReport, reviewerName, reviewerIndex, recommendation, - showOwner, report: { submittedOn }, }) => ( <Root> diff --git a/packages/component-faraday-ui/src/ReviewerReportAuthor.js b/packages/component-faraday-ui/src/ReviewerReportAuthor.js index d1530006d..b10503a41 100644 --- a/packages/component-faraday-ui/src/ReviewerReportAuthor.js +++ b/packages/component-faraday-ui/src/ReviewerReportAuthor.js @@ -1,23 +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 PropTypes from 'prop-types' +import { withProps, compose } from 'recompose' import { - Label, - Item, - FileItem, Row, Text, + Item, + Label, + FileItem, withFilePreview, withFileDownload, } from './' const ReviewerReportAuthor = ({ journal, + showOwner, reviewFile, previewFile, downloadFile, @@ -25,7 +26,6 @@ const ReviewerReportAuthor = ({ reviewerName, reviewerIndex, recommendation, - showOwner = false, report: { submittedOn }, }) => ( <Root> @@ -109,6 +109,7 @@ ReviewerReportAuthor.defaultProps = { 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 e2ed71185..102e6e403 100644 --- a/packages/component-faraday-ui/src/ReviewersTable.js +++ b/packages/component-faraday-ui/src/ReviewersTable.js @@ -6,7 +6,7 @@ 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 = [], diff --git a/packages/component-faraday-ui/src/Tabs.js b/packages/component-faraday-ui/src/Tabs.js index 57deca667..003b084c5 100644 --- a/packages/component-faraday-ui/src/Tabs.js +++ b/packages/component-faraday-ui/src/Tabs.js @@ -5,15 +5,15 @@ const Tabs = ({ items, selectedTab, changeTab, children }) => children({ selectedTab, changeTab }) Tabs.proptypes = { - /** property that sets any tab as curent selcted tab */ - selectedTab: PropTypes.func, - /** property that changes tab on click */ + /** The selected tab. */ + selectedTab: PropTypes.number, + /** Handler to change the tab. */ changeTab: PropTypes.func, } Tabs.defaultProp = { - selectedTab: undefined, - changeTab: undefined, + selectedTab: 0, + changeTab: () => {}, } export default compose( diff --git a/packages/component-faraday-ui/src/WizardFiles.js b/packages/component-faraday-ui/src/WizardFiles.js index 2d7016178..99e09b451 100644 --- a/packages/component-faraday-ui/src/WizardFiles.js +++ b/packages/component-faraday-ui/src/WizardFiles.js @@ -103,7 +103,16 @@ WizardFiles.propTypes = { }), ), /** Passes properties for supplementary file. */ - supplementary: PropTypes.oneOfType(PropTypes.array), + 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: [], -- GitLab From e69442abed6045fb7dbd6d36d775c3e2b64da123 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 6 Nov 2018 19:17:40 +0200 Subject: [PATCH 23/49] docs(faraday-ui): --- .../component-faraday-ui/src/UserProfile.js | 71 ++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/packages/component-faraday-ui/src/UserProfile.js b/packages/component-faraday-ui/src/UserProfile.js index 292c04822..a5f0555c1 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( -- GitLab From 24e3cca2415c4d3c99964226034fc1726223f016 Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Tue, 6 Nov 2018 21:08:29 +0200 Subject: [PATCH 24/49] docs(manuscript-details): format markdown tables --- .../src/handleRecommendation/README.md | 26 ++++++++++++++----- .../src/inviteHandlingEditor/README.md | 21 +++++++++------ .../src/inviteReviewer/README.md | 15 ++++++----- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/packages/component-manuscript/src/handleRecommendation/README.md b/packages/component-manuscript/src/handleRecommendation/README.md index 783844056..81084d76a 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 665c53eb1..9badc8fff 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 f8bae3787..74f050b22 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_ -- GitLab From fab6673f0dedb1f12793d2e81b1f515373c8e326 Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Wed, 7 Nov 2018 09:57:37 +0200 Subject: [PATCH 25/49] docs(SubmitRevision): Updated documentation for withSubmitRevision HOC --- .../src/submitRevision/README.md | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/packages/component-manuscript/src/submitRevision/README.md b/packages/component-manuscript/src/submitRevision/README.md index 1768825b9..a3b9620b9 100644 --- a/packages/component-manuscript/src/submitRevision/README.md +++ b/packages/component-manuscript/src/submitRevision/README.md @@ -14,35 +14,29 @@ The `withSubmitRevision` HOC contains the logic for submitting a manuscript vers `submitRevision` namespace contains the following fields: Name|Type|Description ---|---|--- -initialValues|`{...fragment}`| Object containing the initial state of the fragment -addFile|`({ file: object, type: string, fragment: object }) => any`|Uploads the file to the server -journal|`function`|Des Cri Pti On! -history|`object`|Added by `react-router` to allow navigation -fragment|`function`|Des Cri Pti On! -canSubmit|`function`|Des Cri Pti On! -addAuthor|`function`|Des Cri Pti On! -showModal|`function`|Des Cri Pti On! +. initialValues|`{...fragment}`| Object containing the initial state of the fragment +. addFile|`({ file: object, type: string, fragment: object }) => any`|Uploads the file to the server +journal|`???`|??? +. collection|`object`|Object containing the selected collection +. fragment|`object`|Object containing the selected fragment +. canSubmit|`bool`|Value representing if the form doesn't have errors and can be submitted +. addAuthor|`({ author, collectionId: string, fragmentId: string }) => any`|An async call to add an author to the manuscript changeForm|`function`|Des Cri Pti On! -collection|`function`|Des Cri Pti On! -isFetching|`function`|Des Cri Pti On! -deleteFile|`function`|Des Cri Pti On! -currentUser|`function`|Des Cri Pti On! -setFetching|`function`|Des Cri Pti On! -previewFile|`function`|Des Cri Pti On! -downloadFile|`function`|Des Cri Pti On! +. deleteFile|`({ fileId: string, type: string }) => any`|Removes the file from the server +. currentUser|`object`|Object containing the currently logged user onAuthorEdit|`function`|Des Cri Pti On! -deleteAuthor|`function`|Des Cri Pti On! -getSignedUrl|`function`|Des Cri Pti On! +. deleteAuthor|`({ authorId, fragmentId, collectionId }) => any`|An async call to remove an existing author from the manuscript +. getSignedUrl|`(id: string) => Promise({signedURL: string})`|An async call that returns the securized S3 file url hasFormError|`function`|Des Cri Pti On! formErrors|`function`|Des Cri Pti On! -fetchingError|`string`|Value representing a server request error addResponseFile|`file => any`|Uploads the file and adds it on the form deleteResponseFile|`file => any`|Deletes the file from the server and removes it from the form isEditingAuthor|`bool`|Value representing if the current user is the editing author -onChange|`(reduxFormValues, dispatch, { collection, fragment }) => any`|Used to autosave new fragment when fields change -onSubmit|`(reduxFormValues, dispatch, { history, fragment, collection, showModal, setFetching, canSubmit })`|Handles the submission of a new manuscript version -validate|`({ editAuthors, files, responseToReviewers }) => errors: object`|Checks the form for required fields and returns the errors -responseFile|`file`|Value containing the revision's file for the reviewer's response +. onChange|`(reduxFormValues, dispatch, { collection, fragment }) => any`|Used to autosave new fragment when fields change +. onSubmit|`(reduxFormValues, dispatch, { history, fragment, collection, showModal, setFetching, canSubmit })`|Handles the submission of a new manuscript version +. validate|`({ editAuthors: , files: array, responseToReviewers: object }) => errors: object`|Checks the form for required fields and returns the errors +. responseFile|`file`|Value containing the revision's file for the reviewer's response ```javascript + ``` -- GitLab From a9ed49621426a8619a3539ce580f1043ece7dda6 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Wed, 7 Nov 2018 10:40:23 +0200 Subject: [PATCH 26/49] docs(hindawy-ui): --- packages/component-faraday-ui/src/TextTooltip.js | 12 +++++++++++- packages/component-faraday-ui/src/WizardFiles.js | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/component-faraday-ui/src/TextTooltip.js b/packages/component-faraday-ui/src/TextTooltip.js index 8bcd4cc03..2c43317ee 100644 --- a/packages/component-faraday-ui/src/TextTooltip.js +++ b/packages/component-faraday-ui/src/TextTooltip.js @@ -1,6 +1,7 @@ -import React, { Fragment } from 'react' +import PropTypes from 'prop-types' import 'react-tippy/dist/tippy.css' import { Tooltip } from 'react-tippy' +import React, { Fragment } from 'react' import { Text, Row } from 'pubsweet-component-faraday-ui' import { ThemeProvider, withTheme } from 'styled-components' @@ -25,4 +26,13 @@ const TextTooltip = ({ theme = {}, children, ...rest }) => ( </Tooltip> ) +TextTooltip.propTypes = { + /** User can hover over an item, without clicking it, and a new window will appear with a new title */ + title: PropTypes.string, +} +TextTooltip.defaultProps = { + title: + 'β-Carboline Silver Compound Binding Studies with Human Serum Albumin: A Comprehensive Multispectroscopic Analysis and Molecular Modeling Study', +} + export default withTheme(TextTooltip) diff --git a/packages/component-faraday-ui/src/WizardFiles.js b/packages/component-faraday-ui/src/WizardFiles.js index 99e09b451..d93ddfe81 100644 --- a/packages/component-faraday-ui/src/WizardFiles.js +++ b/packages/component-faraday-ui/src/WizardFiles.js @@ -80,7 +80,7 @@ const initialFiles = { } WizardFiles.propTypes = { - /** Passes properties for the manuscript file. */ + /** Fragments manuscript file. */ manuscripts: PropTypes.arrayOf( PropTypes.shape({ /** Id of added manuscript file. */ @@ -91,7 +91,7 @@ WizardFiles.propTypes = { size: PropTypes.number, }), ), - /** Passes properties for the cover letter file. */ + /** Fragments cover letter file. */ coverLetter: PropTypes.arrayOf( PropTypes.shape({ /** Id of added cover letter file. */ @@ -102,7 +102,7 @@ WizardFiles.propTypes = { size: PropTypes.number, }), ), - /** Passes properties for supplementary file. */ + /** Fragments supplementary file. */ supplementary: PropTypes.arrayOf( PropTypes.shape({ /** Id of added cover letter file. */ -- GitLab From 649d7a740436e2eebfcd85495a5de04399cfded2 Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Wed, 7 Nov 2018 10:46:06 +0200 Subject: [PATCH 27/49] docs(SubmitRevision): Updated documentation for withSubmitRevision HOC --- .../src/submitRevision/README.md | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/packages/component-manuscript/src/submitRevision/README.md b/packages/component-manuscript/src/submitRevision/README.md index a3b9620b9..7ce0591fb 100644 --- a/packages/component-manuscript/src/submitRevision/README.md +++ b/packages/component-manuscript/src/submitRevision/README.md @@ -14,29 +14,27 @@ The `withSubmitRevision` HOC contains the logic for submitting a manuscript vers `submitRevision` namespace contains the following fields: Name|Type|Description ---|---|--- -. initialValues|`{...fragment}`| Object containing the initial state of the fragment -. addFile|`({ file: object, type: string, fragment: object }) => any`|Uploads the file to the server -journal|`???`|??? -. collection|`object`|Object containing the selected collection -. fragment|`object`|Object containing the selected fragment -. canSubmit|`bool`|Value representing if the form doesn't have errors and can be submitted -. addAuthor|`({ author, collectionId: string, fragmentId: string }) => any`|An async call to add an author to the manuscript -changeForm|`function`|Des Cri Pti On! -. deleteFile|`({ fileId: string, type: string }) => any`|Removes the file from the server -. currentUser|`object`|Object containing the currently logged user -onAuthorEdit|`function`|Des Cri Pti On! -. deleteAuthor|`({ authorId, fragmentId, collectionId }) => any`|An async call to remove an existing author from the manuscript -. getSignedUrl|`(id: string) => Promise({signedURL: string})`|An async call that returns the securized S3 file url -hasFormError|`function`|Des Cri Pti On! -formErrors|`function`|Des Cri Pti On! -addResponseFile|`file => any`|Uploads the file and adds it on the form -deleteResponseFile|`file => any`|Deletes the file from the server and removes it from the form +collection|`object`|Object containing the selected collection +fragment|`object`|Object containing the selected fragment +journal|`object`|Deprecated object containing manuscript types +currentUser|`object`|Object containing the currently logged user +initialValues|`{...fragment}`| Object containing the initial state of the fragment isEditingAuthor|`bool`|Value representing if the current user is the editing author -. onChange|`(reduxFormValues, dispatch, { collection, fragment }) => any`|Used to autosave new fragment when fields change -. onSubmit|`(reduxFormValues, dispatch, { history, fragment, collection, showModal, setFetching, canSubmit })`|Handles the submission of a new manuscript version -. validate|`({ editAuthors: , files: array, responseToReviewers: object }) => errors: object`|Checks the form for required fields and returns the errors -. responseFile|`file`|Value containing the revision's file for the reviewer's response +canSubmit|`bool`|Value representing if the form doesn't have errors and can be submitted +hasFormError|`bool`|Value representing if the form has any errors +formErrors|`bool`|Value representing if the form has any errors +responseFile|`file`|Value containing the revision's file for the reviewer's response +addAuthor|`({ author, collectionId: string, fragmentId: string }) => any`|An async call to add an author to the manuscript +deleteAuthor|`({ authorId, fragmentId, collectionId }) => any`|An async call to remove an existing author from the manuscript +onAuthorEdit|`index => authorEditIndex: number`|Chages the form to allow editing of the selected author and returns his index +addFile|`({ file: object, type: string, fragment: object }) => any`|Uploads the file to the server +deleteFile|`({ fileId: string, type: string }) => any`|Removes the file from the server +getSignedUrl|`(id: string) => Promise({signedURL: string})`|An async call that returns the securized S3 file url +addResponseFile|`file => any`|Uploads the file then updates the form +deleteResponseFile|`file => any`|Deletes the file from the server then updates the form +onChange|`(reduxFormValues, dispatch, { collection, fragment }) => any`|Used to autosave new fragment when fields change +validate|`({ editAuthors: , files: array, responseToReviewers: object }) => errors: object`|Checks the form for required fields and returns the errors +onSubmit|`(reduxFormValues, dispatch, { history, fragment, collection, showModal, setFetching, canSubmit })`|Handles the submission of a new manuscript version ```javascript - ``` -- GitLab From 53c5b257afed080748c198186f7553928b06e8fe Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Wed, 7 Nov 2018 10:53:01 +0200 Subject: [PATCH 28/49] docs(SubmitRevision): Wrote example for withSubmitRevision HOC --- .../src/submitRevision/README.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/component-manuscript/src/submitRevision/README.md b/packages/component-manuscript/src/submitRevision/README.md index 7ce0591fb..0ba42dd4b 100644 --- a/packages/component-manuscript/src/submitRevision/README.md +++ b/packages/component-manuscript/src/submitRevision/README.md @@ -37,4 +37,45 @@ validate|`({ editAuthors: , files: array, responseToReviewers: object }) => erro onSubmit|`(reduxFormValues, dispatch, { history, fragment, collection, showModal, setFetching, canSubmit })`|Handles the submission of a new manuscript version ```javascript +const ManuscriptLayout = ({submitRevision}) =>( + <SubmitRevision {...submitRevision} /> +) + +const SubmitRevision = ({...}) => ( + <Root> + <DetailsAndAuthors + addAuthor={addAuthor} + changeForm={changeForm} + collection={collection} + deleteAuthor={deleteAuthor} + formErrors={formErrors} + fragment={fragment} + isAuthorEdit={isEditingAuthor} + manuscriptTypes={journal.manuscriptTypes} + onAuthorEdit={onAuthorEdit} + /> + + <ManuscriptFiles + changeForm={changeForm} + collection={collection} + deleteFile={deleteFile} + downloadFile={downloadFile} + formErrors={formErrors} + formName="revision" + fragment={fragment} + getSignedUrl={getSignedUrl} + previewFile={previewFile} + token={currentUser.token} + uploadFile={addFile} + /> + + <ResponseToReviewer + file={responseFile} + getSignedUrl={getSignedUrl} + isFetching={isFetching} + onDelete={deleteResponseFile} + onUpload={addResponseFile} + token={currentUser.token} + /> + </Root> ``` -- GitLab From 7a20fb9f158ee36120bc097fa4bf7f4d6c962b22 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Wed, 7 Nov 2018 14:09:25 +0200 Subject: [PATCH 29/49] docs: --- packages/component-faraday-ui/src/Tag.js | 6 +++--- packages/component-faraday-ui/src/Textarea.js | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/component-faraday-ui/src/Tag.js b/packages/component-faraday-ui/src/Tag.js index 3c6997d15..a37711bc7 100644 --- a/packages/component-faraday-ui/src/Tag.js +++ b/packages/component-faraday-ui/src/Tag.js @@ -55,10 +55,10 @@ const Tag = styled.div` ` Tag.propTypes = { - /** if true then object gets properties. */ + /** Old status of the corresponding user. */ oldStatus: PropTypes.bool, - /** if true then object gets properties. */ - status: PropTypes.boo, + /** New status of the corresponding user. */ + status: PropTypes.bool, } Tag.defaultProps = { diff --git a/packages/component-faraday-ui/src/Textarea.js b/packages/component-faraday-ui/src/Textarea.js index 8013357da..91fac36c2 100644 --- a/packages/component-faraday-ui/src/Textarea.js +++ b/packages/component-faraday-ui/src/Textarea.js @@ -1,4 +1,5 @@ import { get } from 'lodash' +import PropTypes from 'prop-types' import { th } from '@pubsweet/ui-toolkit' import styled, { css } from 'styled-components' @@ -33,6 +34,14 @@ const Textarea = styled.textarea` background-color: ${th('colorBackgroundHue')}; } ` +Textarea.propTypes = { + /** The minimum height that the text box should have */ + minHeight: PropTypes.number, +} + +Textarea.defaultProps = { + minHeight: 10, +} /** @component */ export default Textarea -- GitLab From cd8e312ee0ce63c0e8be9411c820abed8e957ca3 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Wed, 7 Nov 2018 16:04:12 +0200 Subject: [PATCH 30/49] docs(faraday-ui): --- packages/component-faraday-ui/src/ShadowedBox.js | 15 ++++++++++++++- packages/component-faraday-ui/src/Text.js | 12 ++++++------ packages/component-faraday-ui/src/Text.md | 12 ++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/packages/component-faraday-ui/src/ShadowedBox.js b/packages/component-faraday-ui/src/ShadowedBox.js index 62de72cb0..f2d1afed6 100644 --- a/packages/component-faraday-ui/src/ShadowedBox.js +++ b/packages/component-faraday-ui/src/ShadowedBox.js @@ -1,5 +1,6 @@ import { get } from 'lodash' import { H2 } from '@pubsweet/ui' +import PropTypes from 'prop-types' import styled, { css } from 'styled-components' import { th } from '@pubsweet/ui-toolkit' @@ -9,7 +10,7 @@ const width = props => css` width: calc(${th('gridUnit')} * ${get(props, 'width', 50)}); ` -export default styled.div` +const ShadowedBox = styled.div` background-color: ${th('colorBackgroundHue')}; border-radius: ${th('borderRadius')}; box-shadow: ${th('boxShadow')}; @@ -26,3 +27,15 @@ export default styled.div` text-align: center; } ` +ShadowedBox.propTypes = { + /** Width of shadowed box */ + width: PropTypes.number, + /** Position of shadowed box */ + position: PropTypes.string, +} +ShadowedBox.defaultProps = { + width: 50, + position: 'initial', +} + +export default ShadowedBox diff --git a/packages/component-faraday-ui/src/Text.js b/packages/component-faraday-ui/src/Text.js index 06d321cd4..aed324d77 100644 --- a/packages/component-faraday-ui/src/Text.js +++ b/packages/component-faraday-ui/src/Text.js @@ -100,17 +100,17 @@ const Text = ({ bullet, children, ...rest }) => ) Text.propTypes = { - /** if true then object gets properties. */ + /** Defines what style the secondary text will have. */ secondary: PropTypes.bool, - /** if true then object gets properties. */ + /** Defines what style the error text will have. */ error: PropTypes.bool, - /** if true then object gets properties. */ + /** Defines what style the customId text will have. */ customId: PropTypes.bool, - /** if true then object gets properties. */ + /** Defines what style the labelLine text will have. */ labelLine: PropTypes.bool, - /** if true then object gets properties. */ + /** Defines what style the journal text will have. */ journal: PropTypes.bool, - /** if true thenobject gets properties. */ + /** Defines what style the small text will have. */ small: PropTypes.bool, /** defines how items will be displayed. */ display: PropTypes.string, diff --git a/packages/component-faraday-ui/src/Text.md b/packages/component-faraday-ui/src/Text.md index a99cff36c..18d570216 100644 --- a/packages/component-faraday-ui/src/Text.md +++ b/packages/component-faraday-ui/src/Text.md @@ -19,12 +19,24 @@ A secondary text. (Body 2) <Text secondary>my boy is amazing</Text> ``` +Error text. + +```js +<Text error>why error?</Text> +``` + A text used for manuscript custom IDs. ```js <Text customId>ID 444222</Text> ``` +A text used for journal. + +```js +<Text journal>text for journal</Text> +``` + A small text. ```js -- GitLab From 01a5be0a9414beef3ee9f74c07e7085f756900a8 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Wed, 7 Nov 2018 16:06:54 +0200 Subject: [PATCH 31/49] docs(faraday-ui): --- packages/component-faraday-ui/src/UserProfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/component-faraday-ui/src/UserProfile.js b/packages/component-faraday-ui/src/UserProfile.js index a5f0555c1..586d5f430 100644 --- a/packages/component-faraday-ui/src/UserProfile.js +++ b/packages/component-faraday-ui/src/UserProfile.js @@ -294,7 +294,7 @@ UserProfile.propTypes = { /** Determine if account is hendling editor or not. */ handlingEditor: PropTypes.bool, /** Users unique token */ - token: PropTypes.array, + token: PropTypes.string, }), } -- GitLab From e7ed4206fd4a2d6ac23ca7a254d0bfd049746351 Mon Sep 17 00:00:00 2001 From: Anca Ursachi <anca.ursachi@thinslices.com> Date: Wed, 7 Nov 2018 18:10:59 +0200 Subject: [PATCH 32/49] docs(component-faraday-ui): --- .../component-faraday-ui/src/AuthorTag.js | 11 ++++- .../component-faraday-ui/src/AuthorTagList.js | 8 ++-- .../component-faraday-ui/src/AuthorTagList.md | 3 ++ .../src/AutosaveIndicator.js | 2 +- .../component-faraday-ui/src/IconButton.js | 9 ++-- .../component-faraday-ui/src/IconTooltip.js | 10 +++- packages/component-faraday-ui/src/Label.js | 2 +- .../src/ManuscriptCard.js | 33 +++++++------ .../src/ManuscriptCard.md | 7 +++ .../component-faraday-ui/src/PublonsTable.js | 10 +++- .../component-faraday-ui/src/PublonsTable.md | 47 +++++++------------ .../src/ReviewerReport.js | 14 ++++-- .../src/ReviewerReport.md | 1 + .../src/ReviewerReportAuthor.js | 14 ++++-- .../component-faraday-ui/src/UserProfile.js | 2 +- 15 files changed, 109 insertions(+), 64 deletions(-) diff --git a/packages/component-faraday-ui/src/AuthorTag.js b/packages/component-faraday-ui/src/AuthorTag.js index 4ec4cf6a3..a0177b561 100644 --- a/packages/component-faraday-ui/src/AuthorTag.js +++ b/packages/component-faraday-ui/src/AuthorTag.js @@ -26,7 +26,7 @@ const AuthorTag = ({ AuthorTag.propTypes = { /** The author you want to be on the card. */ author: PropTypes.shape({ - id: PropTypes.string, + id: PropTypes.number, firstName: PropTypes.string, lastName: PropTypes.string, isCorresponding: PropTypes.bool, @@ -36,7 +36,14 @@ AuthorTag.propTypes = { } AuthorTag.defaultProps = { - author: undefined, + author: { + id: undefined, + firstName: undefined, + lastName: undefined, + isCorresponding: undefined, + isSubmitting: undefined, + affiliationNumber: undefined, + }, } export default AuthorTag diff --git a/packages/component-faraday-ui/src/AuthorTagList.js b/packages/component-faraday-ui/src/AuthorTagList.js index 81f95ff2c..f168d53c6 100644 --- a/packages/component-faraday-ui/src/AuthorTagList.js +++ b/packages/component-faraday-ui/src/AuthorTagList.js @@ -114,15 +114,16 @@ export default compose( )(AuthorTagList) AuthorTagList.propTypes = { + /** What label we want to be seen on the card. */ authorKey: PropTypes.string, - /** All authors we wanna see. */ + /** All authors we want to be seen on the card. */ authors: PropTypes.arrayOf(PropTypes.object), - /** What separator to be used. */ + /** Separator between authors. */ separator: PropTypes.string, /** Tooltip about author details. */ withTooltip: PropTypes.bool, + /** Show authors affifiations. */ withAffiliations: PropTypes.bool, - showAffiliation: PropTypes.bool, } AuthorTagList.defaultProps = { @@ -131,7 +132,6 @@ AuthorTagList.defaultProps = { separator: `, `, withTooltip: false, withAffiliations: false, - showAffiliation: false, } // #region styles diff --git a/packages/component-faraday-ui/src/AuthorTagList.md b/packages/component-faraday-ui/src/AuthorTagList.md index 12ff3c606..d66972f14 100644 --- a/packages/component-faraday-ui/src/AuthorTagList.md +++ b/packages/component-faraday-ui/src/AuthorTagList.md @@ -107,12 +107,14 @@ Use a different separator and key for mapping the authors. ```js const authors = [ { + id: 1, email: 'john.doe@gmail.com', firstName: 'John', lastName: 'Doe', isSubmitting: true, }, { + id: 2, email: 'michael.felps@gmail.com', firstName: 'Michael', lastName: 'Felps', @@ -120,6 +122,7 @@ const authors = [ isCorresponding: true, }, { + id: 3, email: 'barrack.obama@gmail.com', firstName: 'Barrack', lastName: 'Obama', diff --git a/packages/component-faraday-ui/src/AutosaveIndicator.js b/packages/component-faraday-ui/src/AutosaveIndicator.js index 1a3b309ff..c219d5816 100644 --- a/packages/component-faraday-ui/src/AutosaveIndicator.js +++ b/packages/component-faraday-ui/src/AutosaveIndicator.js @@ -101,7 +101,7 @@ export default compose( )(AutosaveIndicator) AutosaveIndicator.propTypes = { - /** Make appear loader until save. */ + /** Saving loader. */ autosave: PropTypes.object, // eslint-disable-line } diff --git a/packages/component-faraday-ui/src/IconButton.js b/packages/component-faraday-ui/src/IconButton.js index 58e6ce1d0..4dadbbf47 100644 --- a/packages/component-faraday-ui/src/IconButton.js +++ b/packages/component-faraday-ui/src/IconButton.js @@ -33,15 +33,18 @@ const Root = styled.div` ${positionHelper}; ` IconButton.propTypes = { - /** Icon name */ + /** What icon to be used. */ icon: PropTypes.string, - /** Icon size */ + /** Size of the icon. */ iconSize: PropTypes.number, + /** Callback function fired when the component is clicked. */ + onClick: PropTypes.func, } IconButton.defaultProps = { - icon: '', + icon: undefined, iconSize: 3, + onClick: undefined, } export default IconButton diff --git a/packages/component-faraday-ui/src/IconTooltip.js b/packages/component-faraday-ui/src/IconTooltip.js index 418cb018c..487c2b7b5 100644 --- a/packages/component-faraday-ui/src/IconTooltip.js +++ b/packages/component-faraday-ui/src/IconTooltip.js @@ -33,15 +33,21 @@ const InfoTooltip = ({ theme, content }) => ( </ThemeProvider> ) IconTooltip.propTypes = { - /** Icon name */ + /** What icon to be used. */ icon: PropTypes.string, - /** Icon size */ + /** Size of the icon. */ iconSize: PropTypes.number, + /** What content to be used in tooltip. */ + content: PropTypes.func, + /** If true the content can be clicked (can be interacted with). */ + interactive: PropTypes.bool, } IconTooltip.defaultProps = { icon: 'help-circle', iconSize: 3, + content: undefined, + interactive: undefined, } export default withTheme(IconTooltip) diff --git a/packages/component-faraday-ui/src/Label.js b/packages/component-faraday-ui/src/Label.js index 18d44f023..635efd36c 100644 --- a/packages/component-faraday-ui/src/Label.js +++ b/packages/component-faraday-ui/src/Label.js @@ -14,7 +14,7 @@ const Label = ({ children, required, ...rest }) => ( ) Label.propTypes = { - /** Mention if the label is require or not. */ + /** If true the label is required. */ required: PropTypes.bool, } diff --git a/packages/component-faraday-ui/src/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index 8b86a6910..a356b14ee 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -4,9 +4,8 @@ import styled from 'styled-components' 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 { compose, withHandlers, setDisplayName, withProps } from 'recompose' import { Tag, Text, @@ -19,7 +18,6 @@ import { AuthorTagList, ReviewerBreakdown, } from './' - import { OpenModal } from './modals' const ManuscriptCard = ({ @@ -29,7 +27,7 @@ const ManuscriptCard = ({ onCardClick, canViewReports, fragment, - manuscriptType, + manuscriptType = {}, collection: { visibleStatus = 'Draft', handlingEditor, customId, id: collId }, }) => { const { @@ -115,7 +113,6 @@ const ManuscriptCard = ({ </Root> ) } - export default compose( withJournal, withHandlers({ @@ -137,13 +134,27 @@ export default compose( ), setDisplayName('ManuscriptCard'), )(ManuscriptCard) +// #region styles ManuscriptCard.propTypes = { - fragment: PropTypes.object.isRequired, // eslint-disable-line - collection: PropTypes.object.isRequired, // eslint-disable-line + fragment: PropTypes.shape({ + authors: PropTypes.arrayOf(PropTypes.object), + created: PropTypes.number, + submitted: PropTypes.number, + metadata: PropTypes.object, + }), // eslint-disable-line + collection: PropTypes.shape({ + customId: PropTypes.string, + visibleStatus: PropTypes.string, + handlingEditor: PropTypes.object, + }), // eslint-disable-line +} + +ManuscriptCard.defaultProps = { + fragment: {}, + collection: undefined, } -// #region styles const MainContainer = styled.div` justify-content: flex-start; display: flex; @@ -153,7 +164,6 @@ const MainContainer = styled.div` padding-bottom: ${th('gridUnit')}; width: calc(100% - (${th('gridUnit')} * 5 / 2)); overflow: hidden; - ${Row} { [data-tooltipped] { overflow: hidden; @@ -171,7 +181,6 @@ const MainContainer = styled.div` } } ` - const SideNavigation = styled.div` align-items: center; background-color: ${th('colorBackgroundHue2') @@ -182,7 +191,6 @@ const SideNavigation = styled.div` display: flex; width: calc(${th('gridUnit')} * 5 / 2); ` - const Root = styled.div` background-color: #fff; border-radius: ${th('borderRadius')}; @@ -191,14 +199,11 @@ const Root = styled.div` display: flex; margin: calc(${th('gridUnit')} / 4) calc(${th('gridUnit')} / 4) ${th('gridUnit')} calc(${th('gridUnit')} / 4); - &:hover { box-shadow: ${th('dashboardCard.hoverShadow')}; } - ${H3} { margin: 0; margin-bottom: ${th('gridUnit')}; } ` -// #endregion diff --git a/packages/component-faraday-ui/src/ManuscriptCard.md b/packages/component-faraday-ui/src/ManuscriptCard.md index e8d9bccea..ad9fc06f5 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.md +++ b/packages/component-faraday-ui/src/ManuscriptCard.md @@ -3,12 +3,14 @@ A manuscript card. ```js const authors = [ { + id:1, email: 'john.doe@gmail.com', firstName: 'John', lastName: 'Doe', isSubmitting: true, }, { + id:2, email: 'michael.felps@gmail.com', firstName: 'Michael', lastName: 'Felps', @@ -16,26 +18,31 @@ const authors = [ isCorresponding: true, }, { + id:3, email: 'barrack.obama@gmail.com', firstName: 'Barrack', lastName: 'Obama', }, { + id:5, email: 'barrack.obama@gmail1.com', firstName: 'Barrack 1', lastName: 'Obama', }, { + id:6, email: 'barrack.obama@gmail2.com', firstName: 'Barrack 2', lastName: 'Obama', }, { + id:7, email: 'barrack.obama@gmail3.com', firstName: 'Barrack 3', lastName: 'Obama', }, { + id:8, email: 'barrack.obama@gmail4.com', firstName: 'Barrack 4', lastName: 'Obama', diff --git a/packages/component-faraday-ui/src/PublonsTable.js b/packages/component-faraday-ui/src/PublonsTable.js index ce9f54947..cc4712d4b 100644 --- a/packages/component-faraday-ui/src/PublonsTable.js +++ b/packages/component-faraday-ui/src/PublonsTable.js @@ -4,7 +4,7 @@ import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { Button, Spinner } from '@pubsweet/ui' import { compose, withHandlers, withProps } from 'recompose' - +import PropTypes from 'prop-types' import { Label, OpenModal, Text, withFetching, ActionLink } from '../' const TableView = ({ @@ -100,6 +100,14 @@ export default compose( }), )(PublonsTable) +TableView.propTypes = { + reviewers: PropTypes.arrayOf(PropTypes.object), +} + +TableView.defaultProps = { + reviewers: undefined, +} + // #region styles const Table = styled.table` border-collapse: collapse; diff --git a/packages/component-faraday-ui/src/PublonsTable.md b/packages/component-faraday-ui/src/PublonsTable.md index f692c2e47..bf7301a2e 100644 --- a/packages/component-faraday-ui/src/PublonsTable.md +++ b/packages/component-faraday-ui/src/PublonsTable.md @@ -3,37 +3,26 @@ A list of publon reviewers. ```js const reviewers = [ { - id: 0, - email: 'email1@email.com', - publishingName: 'Name1', - recentOrganizations: { - name: 'Org1' - }, - numVerifiedReviews: '100' + name: 'Ursachi Anca', + email: 'anca@thinslices.com', + profileUrl: '', + affiliation: 'ts', + reviews: 10, }, { - id: 1, - email: 'email2@email.com', - publishingName: 'Name2', - recentOrganizations: { - name: 'Org2' - }, - numVerifiedReviews: '200' + name: 'Josh', + email: 'josh@thinslices.com', + profileUrl: '', + affiliation: 'ts', + reviews: 8, }, - { - id: 2, - email: 'email3@email.com', - publishingName: 'Name3', - recentOrganizations: { - name: 'Org3' - }, - numVerifiedReviews: '300' - }, -]; +] +;<PublonsTable + reviewers={reviewers} + onInviteReviwer={(reviewer, modalProps) => { + console.log('the reviewer', reviewer) -<PublonsTable reviewers={reviewers} onInviteReviwer={(reviewer, modalProps) => { - console.log('the reviewer', reviewer) - - modalProps.setModalError('avem eroare boss') -}}/> + modalProps.setModalError('avem eroare boss') + }} +/> ``` diff --git a/packages/component-faraday-ui/src/ReviewerReport.js b/packages/component-faraday-ui/src/ReviewerReport.js index 5d728ccde..4eeada6bc 100644 --- a/packages/component-faraday-ui/src/ReviewerReport.js +++ b/packages/component-faraday-ui/src/ReviewerReport.js @@ -94,20 +94,28 @@ export default withProps(({ report, journal: { recommendations } }) => ({ }))(ReviewerReport) ReviewerReport.propTypes = { - /** It's true when you want to appear the reviewer name */ + /** True when you want to show reviewer name. */ showOwner: PropTypes.bool, - /** Reviewers reports */ + /** Pass object with informations about the report. */ report: PropTypes.shape({ + /** Unique id for report. */ id: PropTypes.string, + /** Unique id for user. */ userId: PropTypes.string, + /** Comments by reviewers. */ comments: PropTypes.arrayOf(PropTypes.object), + /** When the comment was created. */ createdOn: PropTypes.number, + /** When the comment was updated. */ updatedOn: PropTypes.number, + /** When the comment was submited. */ submittedOn: PropTypes.number, + /** The recommendation given by reviewer. */ recommendation: PropTypes.string, + /** Type of recommendation. */ recommendationType: PropTypes.string, }), - /** The reviewers recommendations */ + /** Pass object with informations about recommendation. */ journal: PropTypes.shape({ recommendations: PropTypes.arrayOf(PropTypes.object), }), diff --git a/packages/component-faraday-ui/src/ReviewerReport.md b/packages/component-faraday-ui/src/ReviewerReport.md index 440b6a882..515b6e465 100644 --- a/packages/component-faraday-ui/src/ReviewerReport.md +++ b/packages/component-faraday-ui/src/ReviewerReport.md @@ -29,6 +29,7 @@ const report = { submittedOn: 1538053600624, recommendation: 'publish', recommendationType: 'review', + reviewerIndex: 1 } const journal = { diff --git a/packages/component-faraday-ui/src/ReviewerReportAuthor.js b/packages/component-faraday-ui/src/ReviewerReportAuthor.js index b10503a41..9547f8d96 100644 --- a/packages/component-faraday-ui/src/ReviewerReportAuthor.js +++ b/packages/component-faraday-ui/src/ReviewerReportAuthor.js @@ -85,20 +85,28 @@ export default compose( )(ReviewerReportAuthor) ReviewerReportAuthor.propTypes = { - /** It's true when you want to appear the reviewer name */ + /** True when you want to show reviewer name. */ showOwner: PropTypes.bool, - /** Reviewers reports */ + /** Pass object with informations about the report. */ report: PropTypes.shape({ + /** Unique id for report. */ id: PropTypes.string, + /** Unique id for user. */ userId: PropTypes.string, + /** Comments by reviewers. */ comments: PropTypes.arrayOf(PropTypes.object), + /** When the comment was created. */ createdOn: PropTypes.number, + /** When the comment was updated. */ updatedOn: PropTypes.number, + /** When the comment was submited. */ submittedOn: PropTypes.number, + /** The recommendation given by reviewer. */ recommendation: PropTypes.string, + /** Type of recommendation. */ recommendationType: PropTypes.string, }), - /** The reviewers recommendations */ + /** Pass object with informations about recommendation. */ journal: PropTypes.shape({ recommendations: PropTypes.arrayOf(PropTypes.object), }), diff --git a/packages/component-faraday-ui/src/UserProfile.js b/packages/component-faraday-ui/src/UserProfile.js index a5f0555c1..586d5f430 100644 --- a/packages/component-faraday-ui/src/UserProfile.js +++ b/packages/component-faraday-ui/src/UserProfile.js @@ -294,7 +294,7 @@ UserProfile.propTypes = { /** Determine if account is hendling editor or not. */ handlingEditor: PropTypes.bool, /** Users unique token */ - token: PropTypes.array, + token: PropTypes.string, }), } -- GitLab From 8222a56a6ecccf84a8585066f3a455786a864d3d Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Thu, 8 Nov 2018 11:49:20 +0200 Subject: [PATCH 33/49] docs(faraday-ui): --- packages/component-faraday-ui/src/Tabs.js | 6 ++-- .../component-faraday-ui/src/WizardAuthors.js | 32 ++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/packages/component-faraday-ui/src/Tabs.js b/packages/component-faraday-ui/src/Tabs.js index 003b084c5..0e7ebbb33 100644 --- a/packages/component-faraday-ui/src/Tabs.js +++ b/packages/component-faraday-ui/src/Tabs.js @@ -1,17 +1,17 @@ import PropTypes from 'prop-types' import { compose, withStateHandlers } from 'recompose' -const Tabs = ({ items, selectedTab, changeTab, children }) => +const Tabs = ({ items, selectedTab = 2, changeTab, children }) => children({ selectedTab, changeTab }) -Tabs.proptypes = { +Tabs.propTypes = { /** The selected tab. */ selectedTab: PropTypes.number, /** Handler to change the tab. */ changeTab: PropTypes.func, } -Tabs.defaultProp = { +Tabs.defaultProps = { selectedTab: 0, changeTab: () => {}, } diff --git a/packages/component-faraday-ui/src/WizardAuthors.js b/packages/component-faraday-ui/src/WizardAuthors.js index b9dbdcf9a..d9a55a5da 100644 --- a/packages/component-faraday-ui/src/WizardAuthors.js +++ b/packages/component-faraday-ui/src/WizardAuthors.js @@ -1,5 +1,6 @@ -import React, { Fragment } from 'react' +import PropTypes from 'prop-types' import styled from 'styled-components' +import React, { Fragment } from 'react' import { th } from '@pubsweet/ui-toolkit' import { omit, isBoolean, get } from 'lodash' import { compose, withState, withHandlers } from 'recompose' @@ -223,6 +224,35 @@ export default compose( }), )(WizardAuthors) +WizardAuthors.propTypes = { + authors: PropTypes.arrayOf(PropTypes.object), + /** Function used for draging authors. */ + moveAuthor: PropTypes.func, + /** Funtion used for adding new authors. */ + addNewAuthor: PropTypes.func, + /** Function used for deleting authors. */ + deleteAuthor: PropTypes.func, + /** Function used for selecting authors for edit. */ + setAuthorEdit: PropTypes.func, + /** Function used for saving new authors. */ + saveNewAuthor: PropTypes.func, + /** Function used for editing authors. */ + editExistingAuthor: PropTypes.func, + /** Function used for submiting authors. */ + authorEditorSubmit: PropTypes.func, +} + +WizardAuthors.defaultProps = { + authors: [], + moveAuthor: () => {}, + addNewAuthor: () => {}, + deleteAuthor: () => {}, + setAuthorEdit: () => {}, + saveNewAuthor: () => {}, + editExistingAuthor: () => {}, + authorEditorSubmit: () => {}, +} + // #region styles const SortableContainer = styled.div` background-color: ${th('colorBackground')}; -- GitLab From 65b4fb7f5aaaf896eada8ee8510e79f4dd07a6c8 Mon Sep 17 00:00:00 2001 From: Anca Ursachi <anca.ursachi@thinslices.com> Date: Thu, 8 Nov 2018 15:34:14 +0200 Subject: [PATCH 34/49] docs(modals(component-faraday-ui)): --- .../src/modals/MultiAction.js | 41 +++++++++++++-- .../src/modals/OpenModal.js | 50 +++++++++++++++++-- .../src/modals/OpenModal.md | 7 ++- .../src/modals/SingleActionModal.js | 25 +++++++++- 4 files changed, 112 insertions(+), 11 deletions(-) diff --git a/packages/component-faraday-ui/src/modals/MultiAction.js b/packages/component-faraday-ui/src/modals/MultiAction.js index 3a9acf7d3..aee2cbce2 100644 --- a/packages/component-faraday-ui/src/modals/MultiAction.js +++ b/packages/component-faraday-ui/src/modals/MultiAction.js @@ -3,19 +3,22 @@ import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { H2, Button, Spinner } from '@pubsweet/ui' import { compose, setDisplayName, withHandlers } from 'recompose' +import PropTypes from 'prop-types' import { IconButton, Text, Row } from '../' const MultiAction = ({ title, + content, onClose, + onCancel, subtitle, onConfirm, modalError, isFetching, renderContent, - confirmText = 'OK', - cancelText = 'Cancel', + confirmText, + cancelText, }) => ( <Root> <IconButton icon="x" onClick={onClose} right={5} secondary top={5} /> @@ -36,7 +39,7 @@ const MultiAction = ({ <Spinner size={3} /> ) : ( <Fragment> - <Button data-test-id="modal-cancel" onClick={onClose}> + <Button data-test-id="modal-cancel" onClick={onCancel}> {cancelText} </Button> <Button data-test-id="modal-confirm" onClick={onConfirm} primary> @@ -48,6 +51,38 @@ const MultiAction = ({ </Root> ) +MultiAction.propTypes = { + /** Title that will be showed on the card. */ + title: PropTypes.string, + /** Subtitle that will be showed on the card. */ + subtitle: PropTypes.string, + /** The text you want to see on the button when someone submit the report. */ + confirmText: PropTypes.string, + /** The text you want to see on the button when someone cancel the report. */ + cancelText: PropTypes.string, + /** Callback function fired when cancel confirmation card. */ + onCancel: PropTypes.func, + /** Callback function fired when confirm confirmation card. */ + onConfirm: PropTypes.func, + /** When is true will show a spinner. */ + onClose: PropTypes.func, + /** Callback function fired when you want to close the card. */ + isFetching: PropTypes.bool, + /** The text you want to show on the card. */ + content: PropTypes.string, +} +MultiAction.defaultProps = { + title: undefined, + subtitle: undefined, + confirmText: 'OK', + cancelText: 'Cancel', + onCancel: undefined, + onConfirm: undefined, + onClose: undefined, + isFetching: undefined, + content: undefined, +} + export default compose( withHandlers({ onConfirm: ({ onConfirm, ...props }) => () => { diff --git a/packages/component-faraday-ui/src/modals/OpenModal.js b/packages/component-faraday-ui/src/modals/OpenModal.js index 16ac00971..7cc313e54 100644 --- a/packages/component-faraday-ui/src/modals/OpenModal.js +++ b/packages/component-faraday-ui/src/modals/OpenModal.js @@ -1,10 +1,22 @@ +import React from 'react' import { compose, withHandlers, withProps } from 'recompose' import { withModal } from 'pubsweet-component-modal/src/components' - +import PropTypes from 'prop-types' import { MultiAction, SingleActionModal, FormModal } from './' -const OpenModal = ({ showModal, children }) => children(showModal) - +const OpenModal = ({ + showModal, + title, + subtitle, + confirmText, + cancelText, + children, + onConfirm, + onCancel, + onClose, + content, + modalKey, +}) => <div>{children(showModal)}</div> const selectModalComponent = props => { if (props.single) { return { @@ -20,6 +32,38 @@ const selectModalComponent = props => { } } +OpenModal.propTypes = { + /** Title that will be showed on the card. */ + title: PropTypes.string, + /** Subtitle that will be showed on the card. */ + subtitle: PropTypes.string, + /** The text you want to see on the button when someone submit the report. */ + confirmText: PropTypes.string, + /** The text you want to see on the button when someone cancel the report. */ + cancelText: PropTypes.string, + /** Callback function fired when cancel confirmation card. */ + onCancel: PropTypes.func, + /** Callback function fired when confirm confirmation card. */ + onConfirm: PropTypes.func, + /** When is true will show a spinner. */ + onClose: PropTypes.func, + /** The text you want to show on the card. */ + content: PropTypes.string, + /** Unique key for modal box. */ + modalKey: PropTypes.string, +} +OpenModal.defaultProps = { + title: undefined, + subtitle: undefined, + confirmText: 'OK', + cancelText: 'Cancel', + onCancel: undefined, + onConfirm: undefined, + onClose: undefined, + content: undefined, + modalKey: undefined, +} + export default compose( withProps(selectModalComponent), withModal(({ isFetching, modalKey, modalComponent }) => ({ diff --git a/packages/component-faraday-ui/src/modals/OpenModal.md b/packages/component-faraday-ui/src/modals/OpenModal.md index 617fcdf25..ae38b6151 100644 --- a/packages/component-faraday-ui/src/modals/OpenModal.md +++ b/packages/component-faraday-ui/src/modals/OpenModal.md @@ -19,9 +19,8 @@ Open a confirmation modal by clicking on an element Pass a custon component as the modal content. ```js -const Custom = () => <div>inside the modal</div>; - -<OpenModal +const Custom = `<div>inside the modal</div>` +;<OpenModal onConfirm={props => console.log('confirm', props)} onCancel={props => console.log('cancel', props)} title="Are you sure?" @@ -37,7 +36,7 @@ Open a single action modal. ```js <OpenModal - onConfirm={console.log} + onConfirm={props => console.log('confirm', props)} title="Are you sure?" confirmText="I am pretty sure" modalKey="1234" diff --git a/packages/component-faraday-ui/src/modals/SingleActionModal.js b/packages/component-faraday-ui/src/modals/SingleActionModal.js index 44385a9e7..55366096a 100644 --- a/packages/component-faraday-ui/src/modals/SingleActionModal.js +++ b/packages/component-faraday-ui/src/modals/SingleActionModal.js @@ -3,6 +3,7 @@ import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { Button, Icon, H2 } from '@pubsweet/ui' import { compose, setDisplayName, withHandlers } from 'recompose' +import PropTypes from 'prop-types' import { IconButton, Text } from '../' @@ -12,7 +13,8 @@ const SingleActionModal = ({ content, onClick, subtitle, - confirmText = 'OK', + confirmText, + onConfirm, }) => ( <Root> <IconButton icon="x" onClick={onClick} right={5} secondary top={5} /> @@ -63,4 +65,25 @@ const Root = styled.div` margin-top: ${th('gridUnit')}; } ` + +SingleActionModal.propTypes = { + /** Title that will be showed on the card. */ + title: PropTypes.string, + /** Subtitle that will be showed on the card. */ + subtitle: PropTypes.string, + /** Callback function fired when confirm confirmation card. */ + onConfirm: PropTypes.func, + /** The text you want to see on the button when someone submit the report. */ + confirmText: PropTypes.string, + /** If true success icon is replaced with error icon. */ + error: PropTypes.bool, +} + +SingleActionModal.defaultProps = { + title: undefined, + subtitle: undefined, + onConfirm: undefined, + confirmText: 'OK', + error: undefined, +} // #endregion -- GitLab From 9867e98a33258e568938fd280d71c4d8358183ca Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Fri, 9 Nov 2018 15:12:07 +0200 Subject: [PATCH 35/49] docs(AssignHE): Wrote documentation for AssignHE Contextual Box --- .../src/contextualBoxes/AssignHE.js | 27 ++++++++++++++++--- .../src/contextualBoxes/AssignHE.md | 20 ++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js b/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js index c65487c70..20d88937f 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js +++ b/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js @@ -1,4 +1,5 @@ import React, { Fragment } from 'react' +import PropTypes from 'prop-types' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { Button, TextField } from '@pubsweet/ui' @@ -49,7 +50,7 @@ const AssignHE = ({ </TextContainer> {handlingEditors.length > 0 && ( <Fragment> - <Row alignItems="center" height={4} pl={1}> + <Row alignItems="center" height="4" pl={1}> <Item flex={1}> <Label>Name</Label> </Item> @@ -62,7 +63,7 @@ const AssignHE = ({ <CustomRow alignItems="center" data-test-id={`manuscript-assign-he-invite-${he.id}`} - height={4} + height="4" isFirst={index === 0} key={he.id} pl={1} @@ -96,6 +97,27 @@ const AssignHE = ({ </Root> ) +AssignHE.propTypes = { + /** Changes the search value to lowercase letters. */ + changeSearch: PropTypes.func, + /** The value of the search input box. */ + searchValue: PropTypes.string, + /** Clears the value of the search input box. */ + clearSearch: PropTypes.func, + /** The list of available handling editors. */ + handlingEditors: PropTypes.arrayOf(PropTypes.object), + /** Invites the selected handling editor. */ + inviteHandlingEditor: PropTypes.func, +} + +AssignHE.defaultProps = { + changeSearch: undefined, + searchValue: '', + clearSearch: undefined, + handlingEditors: [], + inviteHandlingEditor: undefined, +} + export default compose( defaultProps({ inviteHandlingEditor: he => {}, @@ -134,7 +156,6 @@ export default compose( // #region styles const Root = styled.div` background-color: ${th('colorBackgroundHue2')}; - ${paddingHelper}; ` diff --git a/packages/component-faraday-ui/src/contextualBoxes/AssignHE.md b/packages/component-faraday-ui/src/contextualBoxes/AssignHE.md index afb5179bd..7e25e7c07 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AssignHE.md +++ b/packages/component-faraday-ui/src/contextualBoxes/AssignHE.md @@ -2,12 +2,22 @@ Assign Handling Editor contextual box. ```js const handlingEditors = [ - { id: '1', name: 'Handling Edi', email: 'handling@edi.com' }, - { id: '2', name: 'Aurel Vlaicu', email: 'aurel@vlaicu.com' }, - { id: '3', name: 'Gheorghe Hagi', email: 'gica@hagi.com' }, -]; + { + id: '1', + firstName: 'Handling', + lastName: 'Edi', + email: 'handling@edi.com', + }, + { + id: '2', + firstName: 'Aurel', + lastName: 'Vlaicu', + email: 'aurel@vlaicu.com', + }, + { id: '3', firstName: 'Gheorghe', lastName: 'Hagi', email: 'gica@hagi.com' }, +] -<ContextualBox label="Assign Handling Editor"> +;<ContextualBox label="Assign Handling Editor"> <AssignHE handlingEditors={handlingEditors} inviteHandlingEditor={he => console.log('inviting: ', he)} -- GitLab From 8711b95d2696ef380b31ad36be11630574b40116 Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Fri, 9 Nov 2018 16:02:44 +0200 Subject: [PATCH 36/49] docs(AuthorReviews): Wrote documentation for AuthorReviews component --- .../src/contextualBoxes/AuthorReviews.js | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js index 5518b3ebf..8512204ea 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js +++ b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { withProps, compose } from 'recompose' import { ContextualBox, ReviewerReportAuthor, Row, Text } from '../' @@ -15,14 +16,7 @@ const SubmittedReportsNumberForAuthorReviews = ({ reports }) => ( </Row> ) -const AuthorReviews = ({ - invitations, - journal, - reports, - fragment, - token, - getSignedUrl, -}) => +const AuthorReviews = ({ journal, reports, token, getSignedUrl }) => reports.length > 0 && ( <ContextualBox label="Reviewer Reports" @@ -43,4 +37,22 @@ const AuthorReviews = ({ </ContextualBox> ) +AuthorReviews.propTypes = { + /** The list of available reports. */ + reports: PropTypes.arrayOf(PropTypes.object), + /** Returns the url of the selected file. */ + getSignedUrl: PropTypes.func, + /** Object containing the list of recommendations. */ + journal: PropTypes.object, //eslint-disable-line + /** Contains the token of the currently logged user */ + token: PropTypes.string, +} + +AuthorReviews.defaultProps = { + reports: [], + getSignedUrl: undefined, + journal: {}, + token: '', +} + export default compose(withProps())(AuthorReviews) -- GitLab From d25b340278d5a5987392b65a806b38889ac72c40 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Fri, 9 Nov 2018 17:40:51 +0200 Subject: [PATCH 37/49] docs(faraday-ui): --- .../component-faraday-ui/src/AuthorReply.js | 14 ++ .../component-faraday-ui/src/DragHandle.js | 9 ++ .../component-faraday-ui/src/FileSection.js | 44 +++++- .../component-faraday-ui/src/Pagination.js | 21 +++ .../src/PersonInvitation.js | 41 ++++- .../src/RadioWithComments.js | 27 ++++ .../component-faraday-ui/src/RemoteOpener.js | 12 ++ .../component-faraday-ui/src/WizardAuthors.js | 1 + .../submissionRevision/DetailsAndAuthors.js | 146 ++++++++++++++++++ 9 files changed, 306 insertions(+), 9 deletions(-) diff --git a/packages/component-faraday-ui/src/AuthorReply.js b/packages/component-faraday-ui/src/AuthorReply.js index 22649c963..c33f4a3aa 100644 --- a/packages/component-faraday-ui/src/AuthorReply.js +++ b/packages/component-faraday-ui/src/AuthorReply.js @@ -1,5 +1,6 @@ import React 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' @@ -32,6 +33,19 @@ const AuthorReply = ({ reply, authorName, submittedOn }) => ( </Row> </Root> ) +AuthorReply.propTypes = { + /** Reply of author. */ + reply: PropTypes.string, + /** Name of author that replied. */ + authorName: PropTypes.string, + /** Date of submitted reply. */ + submittedOn: PropTypes.number, +} +AuthorReply.defaultProps = { + reply: undefined, + authorName: undefined, + submittedOn: undefined, +} export default withProps(({ fragment: { authors, submitted } }) => ({ submittedOn: submitted, diff --git a/packages/component-faraday-ui/src/DragHandle.js b/packages/component-faraday-ui/src/DragHandle.js index 196408247..7a42e645a 100644 --- a/packages/component-faraday-ui/src/DragHandle.js +++ b/packages/component-faraday-ui/src/DragHandle.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { Icon } from '@pubsweet/ui' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' @@ -17,6 +18,14 @@ const DragHandle = props => ( DragHandle.displayName = 'DragHandle' +DragHandle.protoTypes = { + /** Designed size for icon */ + size: PropTypes.number, +} +DragHandle.defaultProps = { + size: 2, +} + export default DragHandle // #region styles diff --git a/packages/component-faraday-ui/src/FileSection.js b/packages/component-faraday-ui/src/FileSection.js index 8a252859e..ab124e3b8 100644 --- a/packages/component-faraday-ui/src/FileSection.js +++ b/packages/component-faraday-ui/src/FileSection.js @@ -110,6 +110,42 @@ const FileSection = ({ </Root> ) +FileSection.propTypes = { + /** Files that are uploaded. */ + files: PropTypes.arrayOf(PropTypes.object), + /** Error you geton uploading. */ + error: PropTypes.string, + /** Titles of manuscript, cover letter and supplimental files. */ + title: PropTypes.string, + /** Id of manuscript, cover letter and supplimental files. */ + listId: PropTypes.string, + /** Function used for draging and hovering over items. */ + moveItem: PropTypes.func, + /** Extensions allowed to be uploaded. */ + allowedFileExtensions: PropTypes.arrayOf(PropTypes.shape({})), + /** Appears when a file was picked. */ + onFilePick: PropTypes.func, + /** Appears when a file was previwed. */ + onPreview: PropTypes.func, + /** Appears when a file was downloaded. */ + onDownload: PropTypes.func, + /** Appears when a file was deleted. */ + onDelete: PropTypes.func, +} + +FileSection.defaultProps = { + files: undefined, + error: undefined, + title: undefined, + listId: undefined, + moveItem: () => {}, + allowedFileExtensions: undefined, + onFilePick: () => {}, + onPreview: () => {}, + onDownload: () => {}, + onDelete: () => {}, +} + export default compose( withState('error', 'setStateError', ''), withHandlers({ @@ -131,14 +167,6 @@ export default compose( withNativeFileDrop, )(FileSection) -FileSection.propTypes = { - /** Files that are uploaded. */ - files: PropTypes.arrayOf(PropTypes.object), -} - -FileSection.defaultProps = { - files: undefined, -} // #region styles const Root = styled.div` background: ${props => diff --git a/packages/component-faraday-ui/src/Pagination.js b/packages/component-faraday-ui/src/Pagination.js index c0f38b45a..5917f5f0f 100644 --- a/packages/component-faraday-ui/src/Pagination.js +++ b/packages/component-faraday-ui/src/Pagination.js @@ -1,4 +1,5 @@ import React, { Fragment } from 'react' +import PropTypes from 'prop-types' import styled from 'styled-components' import { TextField } from '@pubsweet/ui' import { th } from '@pubsweet/ui-toolkit' @@ -58,6 +59,26 @@ export const Pagination = ({ Items, children, ...props }) => ( </Fragment> ) +Pagination.propTypes = { + /** Page current number. */ + page: PropTypes.number, + /** Indicates if there are more pages to be displayed. */ + hasMore: PropTypes.bool, + /** Maximum items displayed. */ + maxItems: PropTypes.number, + /** Items displayed per page. */ + itemsPerPage: PropTypes.number, + /** Change how many items should be displayed per page. */ + changeItemsPerPage: PropTypes.func, +} +Pagination.defaultProps = { + page: 1, + hasMore: undefined, + maxItems: 23, + itemsPerPage: 10, + changeItemsPerPage: () => {}, +} + export default PaginationComponent // #region styles diff --git a/packages/component-faraday-ui/src/PersonInvitation.js b/packages/component-faraday-ui/src/PersonInvitation.js index 5b1da63fa..225ceba05 100644 --- a/packages/component-faraday-ui/src/PersonInvitation.js +++ b/packages/component-faraday-ui/src/PersonInvitation.js @@ -1,5 +1,6 @@ -import React, { Fragment } from 'react' +import PropTypes from 'prop-types' import styled from 'styled-components' +import React, { Fragment } from 'react' import { compose, withHandlers, defaultProps, setDisplayName } from 'recompose' import { Text, OpenModal, IconButton, marginHelper, withFetching } from './' @@ -60,6 +61,44 @@ const PersonInvitation = ({ </Root> ) +PersonInvitation.propTypes = { + /** Id of invitation. */ + id: PropTypes.string, + /** Type of invitation. */ + type: PropTypes.string, + /** Role of user. */ + role: PropTypes.string, + /** Reason written for review. */ + reason: PropTypes.string, + /** Id of user. */ + userId: PropTypes.string, + /** If user has left an answer or not. */ + hasAnswer: PropTypes.bool, + /** Date of invite. */ + invitedOn: PropTypes.number, + /** If user was accepted or not. */ + isAccepted: PropTypes.bool, + /** Date of user response. */ + respondedOn: PropTypes.number, + /** Details of person. */ + person: PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + }), +} +PersonInvitation.defaultProps = { + id: undefined, + role: undefined, + type: undefined, + reason: undefined, + userId: undefined, + hasAnswer: false, + invitedOn: undefined, + isAccepted: false, + respondedOn: undefined, + person: {}, +} + export default compose( defaultProps({ person: { diff --git a/packages/component-faraday-ui/src/RadioWithComments.js b/packages/component-faraday-ui/src/RadioWithComments.js index 785149e94..af4276dc5 100644 --- a/packages/component-faraday-ui/src/RadioWithComments.js +++ b/packages/component-faraday-ui/src/RadioWithComments.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { get } from 'lodash' import { Field } from 'redux-form' import styled from 'styled-components' @@ -75,6 +76,32 @@ const RadioWithComments = ({ </Root> ) +RadioWithComments.propTypes = { + /** Defines if a fragment si required or not. */ + required: PropTypes.bool, + /** Values taken by form. */ + formValues: PropTypes.object, //eslint-disable-line + /** Name of field selected after using radio buttons. */ + radioFieldName: PropTypes.string, + /** Name of comments field after radio buttons choice. */ + commentsFieldName: PropTypes.string, + /** Name of field that was commented on. */ + commentsOn: PropTypes.string, + /** Label name of the field that was commented on. */ + commentsLabel: PropTypes.string, + /** Name of radio label field on witch it was commented. */ + radioLabel: PropTypes.string, +} +RadioWithComments.defaultProps = { + required: false, + formValues: {}, + radioFieldName: undefined, + commentsFieldName: undefined, + commentsOn: undefined, + commentsLabel: undefined, + radioLabel: undefined, +} + export default RadioWithComments // #region styles diff --git a/packages/component-faraday-ui/src/RemoteOpener.js b/packages/component-faraday-ui/src/RemoteOpener.js index 44bcb785b..7f808aad7 100644 --- a/packages/component-faraday-ui/src/RemoteOpener.js +++ b/packages/component-faraday-ui/src/RemoteOpener.js @@ -1,3 +1,4 @@ +import PropTypes from 'prop-types' import { withStateHandlers } from 'recompose' const RemoteOpener = ({ expanded, toggle, children }) => @@ -11,3 +12,14 @@ export default withStateHandlers( }), }, )(RemoteOpener) + +RemoteOpener.propTypes = { + /** Expands a message for collapse or expand. */ + expanded: PropTypes.string, + /** Method used to toggle a message on click. */ + toggle: PropTypes.func, +} +RemoteOpener.defaultProps = { + expanded: undefined, + toggle: () => {}, +} diff --git a/packages/component-faraday-ui/src/WizardAuthors.js b/packages/component-faraday-ui/src/WizardAuthors.js index d9a55a5da..8b7601713 100644 --- a/packages/component-faraday-ui/src/WizardAuthors.js +++ b/packages/component-faraday-ui/src/WizardAuthors.js @@ -225,6 +225,7 @@ export default compose( )(WizardAuthors) WizardAuthors.propTypes = { + /** List of authors. */ authors: PropTypes.arrayOf(PropTypes.object), /** Function used for draging authors. */ moveAuthor: PropTypes.func, diff --git a/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js b/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js index 351585752..61428ba17 100644 --- a/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js +++ b/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { get, has } from 'lodash' import { Field } from 'redux-form' import styled from 'styled-components' @@ -107,4 +108,149 @@ const Root = styled.div` padding-left: calc(${th('gridUnit')} * 1); ` +DetailsAndAuthors.propTypes = { + /** Name of the manuscript. */ + journal: PropTypes.string, + /** */ + fragment: PropTypes.PropTypes.shape({ + id: PropTypes.string, + type: PropTypes.string, + files: PropTypes.shape({ + coverLetter: PropTypes.array, + manuscripts: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + size: PropTypes.number, + originalName: PropTypes.string, + }), + ), + supplementary: PropTypes.array, + }), + owners: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string, + username: PropTypes.string, + }), + ), + authors: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string, + email: PropTypes.string, + country: PropTypes.string, + lastName: PropTypes.string, + firstName: PropTypes.string, + affiliation: PropTypes.string, + isSubmitting: PropTypes.bool, + isCorresponding: PropTypes.bool, + }), + ), + created: PropTypes.string, + version: PropTypes.number, + metadata: PropTypes.shape({ + type: PropTypes.string, + title: PropTypes.string, + journal: PropTypes.string, + abstract: PropTypes.string, + }), + conflicts: PropTypes.shape({ + hasFunding: PropTypes.string, + hasConflicts: PropTypes.string, + hasDataAvailability: PropTypes.string, + }), + submitted: PropTypes.number, + collectionId: PropTypes.string, + declarations: PropTypes.shape({ + agree: PropTypes.bool, + }), + fragmentType: PropTypes.string, + recomandations: PropTypes.array, + }), + /** Information sent for the manuscript. */ + collection: PropTypes.shape({ + id: PropTypes.string, + type: PropTypes.string, + owners: PropTypes.array, + status: PropTypes.string, + created: PropTypes.number, + customId: PropTypes.string, + fragments: PropTypes.arrayOf(PropTypes.string), + technicalChecks: PropTypes.object, + CurrentVersion: PropTypes.shape({ + id: PropTypes.string, + type: PropTypes.string, + files: PropTypes.shape({ + coverLetter: PropTypes.array, + manuscripts: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + size: PropTypes.number, + originalName: PropTypes.string, + }), + ), + supplementary: PropTypes.array, + }), + owners: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string, + username: PropTypes.string, + }), + ), + authors: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string, + email: PropTypes.string, + country: PropTypes.string, + lastName: PropTypes.string, + firstName: PropTypes.string, + affiliation: PropTypes.string, + isSubmitting: PropTypes.bool, + isCorresponding: PropTypes.bool, + }), + ), + created: PropTypes.string, + version: PropTypes.number, + metadata: PropTypes.shape({ + type: PropTypes.string, + title: PropTypes.string, + journal: PropTypes.string, + abstract: PropTypes.string, + }), + conflicts: PropTypes.shape({ + hasFunding: PropTypes.string, + hasConflicts: PropTypes.string, + hasDataAvailability: PropTypes.string, + }), + submitted: PropTypes.number, + collectionId: PropTypes.string, + declarations: PropTypes.shape({ + agree: PropTypes.bool, + }), + fragmentType: PropTypes.string, + recomandations: PropTypes.array, + }), + visibleStatus: PropTypes.string, + }), + /** Here you can edit author. */ + onAuthorEdit: PropTypes.func, + /** Manuscript types that you can chose from. */ + manuscriptTypes: PropTypes.arrayOf( + PropTypes.shape({ + label: PropTypes.string, + value: PropTypes.string, + author: PropTypes.bool, + peerReview: PropTypes.bool, + abstractRequired: PropTypes.bool, + }), + ), +} +DetailsAndAuthors.defaultProps = { + journal: undefined, + fragment: {}, + collection: {}, + onAuthorEdit: () => {}, + manuscriptTypes: [], +} + export default DetailsAndAuthors -- GitLab From da566546f52735955270395885450b4d0d7ae67a Mon Sep 17 00:00:00 2001 From: Anca Ursachi <anca.ursachi@thinslices.com> Date: Fri, 9 Nov 2018 20:56:25 +0200 Subject: [PATCH 38/49] docs(manuscriptDetails): --- .../component-faraday-ui/src/gridItems/Row.js | 8 ++- .../manuscriptDetails/ManuscriptAssignHE.js | 13 +++++ .../manuscriptDetails/ManuscriptAssignHE.md | 2 +- .../manuscriptDetails/ManuscriptDetailsTop.js | 20 ++++++- .../manuscriptDetails/ManuscriptDetailsTop.md | 54 ++++++++++++++++++- .../ManuscriptEicDecision.js | 19 ++++++- .../manuscriptDetails/ManuscriptFileList.js | 23 +++++++- .../ManuscriptFileSection.js | 21 +++++++- .../manuscriptDetails/ManuscriptVersion.js | 2 +- 9 files changed, 147 insertions(+), 15 deletions(-) diff --git a/packages/component-faraday-ui/src/gridItems/Row.js b/packages/component-faraday-ui/src/gridItems/Row.js index 54c7faacf..e430fa497 100644 --- a/packages/component-faraday-ui/src/gridItems/Row.js +++ b/packages/component-faraday-ui/src/gridItems/Row.js @@ -13,8 +13,6 @@ const Row = styled.div.attrs({ display: flex; flex-wrap: ${props => get(props, 'flexWrap', 'initial')}; justify-content: ${props => get(props, 'justify', 'space-evenly')}; - height: ${props => get(props, 'height', 'auto')}; - width: ${props => (props.fitContent ? 'fit-content' : '100%')}; ${heightHelper}; @@ -31,8 +29,8 @@ Row.propTypes = { flexWrap: PropTypes.string, /** Specifies alignment along the main axis. */ justifyContent: PropTypes.string, - /** Set the height in pixels. */ - height: PropTypes.string, + /** Set the height in multiple of grid units. */ + height: PropTypes.number, } Row.defaultProps = { @@ -40,7 +38,7 @@ Row.defaultProps = { bgColor: 'transparent', flexWrap: 'initial', justifyContent: 'space-evenly', - height: '100%', + height: 2, } export default Row diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.js index ed9e04dfc..edf468460 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.js @@ -1,5 +1,6 @@ import React from 'react' import { ContextualBox, AssignHE } from 'pubsweet-component-faraday-ui' +import PropTypes from 'prop-types' const ManuscriptAssignHE = ({ toggle, @@ -8,6 +9,7 @@ const ManuscriptAssignHE = ({ isFetching, currentUser: { permissions: { canAssignHE = false } }, handlingEditors = [], + inviteHandlingEditor, }) => canAssignHE ? ( <ContextualBox @@ -25,4 +27,15 @@ const ManuscriptAssignHE = ({ </ContextualBox> ) : null +ManuscriptAssignHE.propTypes = { + /** Handling editors you want to be displayed. */ + handlingEditors: PropTypes.arrayOf(PropTypes.object), + /** Callback function fired when the handling editor is invited. */ + inviteHandlingEditor: PropTypes.func, +} + +ManuscriptAssignHE.defaultProps = { + handlingEditors: [], + inviteHandlingEditor: undefined, +} export default ManuscriptAssignHE diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.md b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.md index 7787e6279..29309b5e1 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.md +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.md @@ -32,7 +32,7 @@ const currentUser = { {(expanded, toggle) => ( <ManuscriptAssignHE toggle={toggle} - expanded={expanded} + expanded currentUser={currentUser} handlingEditors={handlingEditors} assignHE={he => console.log('assigning...', he)} diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js index 6a4c5dfb3..5a70bfee8 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js @@ -2,6 +2,7 @@ import React from 'react' import { get } from 'lodash' import { DateParser } from '@pubsweet/ui' import { compose, withHandlers } from 'recompose' +import PropTypes from 'prop-types' import { Row, @@ -20,8 +21,8 @@ const ManuscriptDetailsTop = ({ goToEdit, getSignedUrl, goToTechnicalCheck, - fragment = {}, - collection = {}, + fragment, + collection, currentUser: { isReviewer, token, @@ -111,3 +112,18 @@ export default compose( }, }), )(ManuscriptDetailsTop) + +ManuscriptDetailsTop.propTypes = { + /** Object with details about fragment. */ + fragment: PropTypes.object, //eslint-disable-line + /** Object with details about collection. */ + collection: PropTypes.object, //eslint-disable-line + /** Object with versions of manuscript. */ + versions: PropTypes.object, //eslint-disable-line +} + +ManuscriptDetailsTop.defaultProps = { + fragment: {}, + collection: {}, + versions: {}, +} diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.md b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.md index f4b7fc2d8..f08d36e62 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.md +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.md @@ -1,11 +1,61 @@ Manuscript Details top section ```js +const authors = [ + { + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + }, + { + email: 'michael.felps@gmail.com', + firstName: 'Michael', + lastName: 'Felps', + isSubmitting: true, + isCorresponding: true, + }, + { + email: 'barrack.obama@gmail.com', + firstName: 'Barrack', + lastName: 'Obama', + }, + { + email: 'barrack.obama@gmail1.com', + firstName: 'Barrack 1', + lastName: 'Obama', + }, + { + email: 'barrack.obama@gmail2.com', + firstName: 'Barrack 2', + lastName: 'Obama', + }, +] + +const collection = { + customId: '55113358', + visibleStatus: 'Pending Approval', + handlingEditor: { + id: 'he-1', + name: 'Handlington Ignashevici', + }, + invitations: [], +} + +const fragment = { + authors, + created: Date.now(), + submitted: Date.now(), + metadata: { + journal: 'Awesomeness', + title: 'A very ok title with many authors', + type: 'research', + }, +} const history = { push: () => alert('go back') }; -const fragment={}; -const collection={}; + const currentUser = { isReviewer: true, token: 'abc-123', diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js index f0e5d8a3f..f628e98ff 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js @@ -6,6 +6,7 @@ import { reduxForm } from 'redux-form' import { th } from '@pubsweet/ui-toolkit' import { required } from 'xpub-validators' import { Button, Menu, ValidatedField } from '@pubsweet/ui' +import PropTypes from 'prop-types' import { withModal } from 'pubsweet-component-modal/src/components' import { @@ -46,7 +47,8 @@ const ManuscriptEicDecision = ({ formValues, handleSubmit, messagesLabel, - collection = {}, + collection, + submitDecision, ...rest }) => ( <ContextualBox @@ -74,7 +76,6 @@ const ManuscriptEicDecision = ({ /> </ItemOverrideAlert> </Row> - {get(formValues, 'decision') !== 'publish' && ( <Row mt={2}> <Item vertical> @@ -140,6 +141,20 @@ export default compose( }), )(ManuscriptEicDecision) +ManuscriptEicDecision.propTypes = { + /** Object with details about collection. */ + collection: PropTypes.object, //eslint-disable-line + /** Label of the decision of EIC. */ + messagesLabel: PropTypes.object, //eslint-disable-line + /** Callback function fired when the handling editor submit his decision. */ + submitDecision: PropTypes.func, +} +ManuscriptEicDecision.defaultProps = { + collection: {}, + messagesLabel: undefined, + submitDecision: undefined, +} + // #region styles const Root = styled.div` display: flex; diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileList.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileList.js index 4f4c2ea78..857aeba89 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileList.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileList.js @@ -1,6 +1,6 @@ +import PropTypes from 'prop-types' import React, { Fragment } from 'react' import { ManuscriptFileSection } from 'pubsweet-component-faraday-ui' - import { withFilePreview, withFileDownload } from '../helpers' const ManuscriptFileList = ({ @@ -35,5 +35,26 @@ const ManuscriptFileList = ({ /> </Fragment> ) +ManuscriptFileList.propTypes = { + /** Files that are uploaded by author. */ + files: PropTypes.shape({ + coverLetter: PropTypes.arrayOf(PropTypes.object), + manuscripts: PropTypes.arrayOf(PropTypes.object), + supplementary: PropTypes.arrayOf(PropTypes.object), + }), + /** Callback function fired when delete icon it's pressed. */ + onDelete: PropTypes.func, + /** Callback function fired when download icon it's pressed. */ + onDownload: PropTypes.func, + /** Callback function fired when preview icon it's pressed. */ + onPreview: PropTypes.func, +} + +ManuscriptFileList.defaultProps = { + files: undefined, + onDelete: undefined, + onDownload: undefined, + onPreview: undefined, +} export default withFilePreview(withFileDownload(ManuscriptFileList)) diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js index c2a6867e2..7458b13be 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js @@ -1,7 +1,8 @@ import React, { Fragment } from 'react' import { Text, FileItem, Item, Row } from 'pubsweet-component-faraday-ui' +import PropTypes from 'prop-types' -const ManuscriptFileSection = ({ list = [], label = '', ...rest }) => ( +const ManuscriptFileSection = ({ list, label, ...rest }) => ( <Fragment> {!!list.length && ( <Fragment> @@ -28,4 +29,22 @@ const ManuscriptFileSection = ({ list = [], label = '', ...rest }) => ( </Fragment> ) +ManuscriptFileSection.propTypes = { + /** List of uploaded files */ + list: PropTypes.arrayOf(PropTypes.object), + /** Category name of uploaded files. */ + label: PropTypes.string, + /** Callback function fired when download icon it's pressed. */ + onDownload: PropTypes.func, + /** Callback function fired when preview icon it's pressed. */ + onPreview: PropTypes.func, +} + +ManuscriptFileSection.defaultProps = { + list: [], + label: '', + onDownload: undefined, + onPreview: undefined, +} + export default ManuscriptFileSection diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.js index 2f7473750..1738e297d 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.js @@ -4,7 +4,7 @@ import { Menu } from '@pubsweet/ui' const ManuscriptVersion = ({ history, - versions, + versions = {}, fragment = {}, collection = {}, }) => -- GitLab From a666e82c4fb6e61335003dd32820aedac8769af3 Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Fri, 23 Nov 2018 14:37:12 +0200 Subject: [PATCH 39/49] fix(Documentation): Fixed broken design and prop-type errors --- packages/component-faraday-ui/src/AuthorTag.js | 2 +- packages/component-faraday-ui/src/FileSection.js | 2 +- packages/component-faraday-ui/src/ManuscriptCard.js | 4 ++-- packages/component-faraday-ui/src/RemoteOpener.js | 4 ++-- packages/component-faraday-ui/src/gridItems/Row.js | 5 ++--- .../src/manuscriptDetails/ManuscriptDetailsTop.js | 4 ++-- packages/component-faraday-ui/src/modals/MultiAction.js | 4 ++-- packages/component-faraday-ui/src/modals/OpenModal.js | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/component-faraday-ui/src/AuthorTag.js b/packages/component-faraday-ui/src/AuthorTag.js index a0177b561..59760469e 100644 --- a/packages/component-faraday-ui/src/AuthorTag.js +++ b/packages/component-faraday-ui/src/AuthorTag.js @@ -26,7 +26,7 @@ const AuthorTag = ({ AuthorTag.propTypes = { /** The author you want to be on the card. */ author: PropTypes.shape({ - id: PropTypes.number, + id: PropTypes.string, firstName: PropTypes.string, lastName: PropTypes.string, isCorresponding: PropTypes.bool, diff --git a/packages/component-faraday-ui/src/FileSection.js b/packages/component-faraday-ui/src/FileSection.js index ab124e3b8..3317a88d1 100644 --- a/packages/component-faraday-ui/src/FileSection.js +++ b/packages/component-faraday-ui/src/FileSection.js @@ -122,7 +122,7 @@ FileSection.propTypes = { /** Function used for draging and hovering over items. */ moveItem: PropTypes.func, /** Extensions allowed to be uploaded. */ - allowedFileExtensions: PropTypes.arrayOf(PropTypes.shape({})), + allowedFileExtensions: PropTypes.arrayOf(PropTypes.string), /** Appears when a file was picked. */ onFilePick: PropTypes.func, /** Appears when a file was previwed. */ diff --git a/packages/component-faraday-ui/src/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index a356b14ee..0bec741bc 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -139,12 +139,12 @@ export default compose( ManuscriptCard.propTypes = { fragment: PropTypes.shape({ authors: PropTypes.arrayOf(PropTypes.object), - created: PropTypes.number, + created: PropTypes.string, submitted: PropTypes.number, metadata: PropTypes.object, }), // eslint-disable-line collection: PropTypes.shape({ - customId: PropTypes.string, + customId: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), visibleStatus: PropTypes.string, handlingEditor: PropTypes.object, }), // eslint-disable-line diff --git a/packages/component-faraday-ui/src/RemoteOpener.js b/packages/component-faraday-ui/src/RemoteOpener.js index 7f808aad7..29a777fde 100644 --- a/packages/component-faraday-ui/src/RemoteOpener.js +++ b/packages/component-faraday-ui/src/RemoteOpener.js @@ -15,11 +15,11 @@ export default withStateHandlers( RemoteOpener.propTypes = { /** Expands a message for collapse or expand. */ - expanded: PropTypes.string, + expanded: PropTypes.bool, /** Method used to toggle a message on click. */ toggle: PropTypes.func, } RemoteOpener.defaultProps = { - expanded: undefined, + expanded: false, toggle: () => {}, } diff --git a/packages/component-faraday-ui/src/gridItems/Row.js b/packages/component-faraday-ui/src/gridItems/Row.js index e430fa497..9885c26aa 100644 --- a/packages/component-faraday-ui/src/gridItems/Row.js +++ b/packages/component-faraday-ui/src/gridItems/Row.js @@ -14,6 +14,7 @@ const Row = styled.div.attrs({ flex-wrap: ${props => get(props, 'flexWrap', 'initial')}; justify-content: ${props => get(props, 'justify', 'space-evenly')}; width: ${props => (props.fitContent ? 'fit-content' : '100%')}; + height: ${props => get(props, 'height', 'autp')}; ${heightHelper}; ${marginHelper}; @@ -29,8 +30,6 @@ Row.propTypes = { flexWrap: PropTypes.string, /** Specifies alignment along the main axis. */ justifyContent: PropTypes.string, - /** Set the height in multiple of grid units. */ - height: PropTypes.number, } Row.defaultProps = { @@ -38,7 +37,7 @@ Row.defaultProps = { bgColor: 'transparent', flexWrap: 'initial', justifyContent: 'space-evenly', - height: 2, + height: '100%', } export default Row diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js index 5a70bfee8..005af4452 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js @@ -119,11 +119,11 @@ ManuscriptDetailsTop.propTypes = { /** Object with details about collection. */ collection: PropTypes.object, //eslint-disable-line /** Object with versions of manuscript. */ - versions: PropTypes.object, //eslint-disable-line + versions: PropTypes.array, //eslint-disable-line } ManuscriptDetailsTop.defaultProps = { fragment: {}, collection: {}, - versions: {}, + versions: [], } diff --git a/packages/component-faraday-ui/src/modals/MultiAction.js b/packages/component-faraday-ui/src/modals/MultiAction.js index aee2cbce2..803f2156a 100644 --- a/packages/component-faraday-ui/src/modals/MultiAction.js +++ b/packages/component-faraday-ui/src/modals/MultiAction.js @@ -68,8 +68,8 @@ MultiAction.propTypes = { onClose: PropTypes.func, /** Callback function fired when you want to close the card. */ isFetching: PropTypes.bool, - /** The text you want to show on the card. */ - content: PropTypes.string, + /** The component you want to show on the card. */ + content: PropTypes.func, } MultiAction.defaultProps = { title: undefined, diff --git a/packages/component-faraday-ui/src/modals/OpenModal.js b/packages/component-faraday-ui/src/modals/OpenModal.js index 7cc313e54..8a8e59199 100644 --- a/packages/component-faraday-ui/src/modals/OpenModal.js +++ b/packages/component-faraday-ui/src/modals/OpenModal.js @@ -48,7 +48,7 @@ OpenModal.propTypes = { /** When is true will show a spinner. */ onClose: PropTypes.func, /** The text you want to show on the card. */ - content: PropTypes.string, + content: PropTypes.func, /** Unique key for modal box. */ modalKey: PropTypes.string, } -- GitLab From 55b2e7341172847ed530c7e28ba3587bb9b88259 Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Fri, 23 Nov 2018 15:09:24 +0200 Subject: [PATCH 40/49] docs(HERecommendation): Wrote documentation for HERecommendation component --- .../src/contextualBoxes/HERecommendation.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js index 877243b16..356638fb6 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js +++ b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { get, tail } from 'lodash' import { reduxForm } from 'redux-form' import styled from 'styled-components' @@ -150,6 +151,24 @@ const HERecommendation = ({ </ContextualBox> ) +HERecommendation.prototypes = { + /* Contains the values of the form inputs */ + formValues: PropTypes.object, + /* Handles the submission of the recommendation */ + handleSubmit: PropTypes.func, + /* Specifies if the fragment has reviewer reports */ + hasReviewerReports: PropTypes.bool, + /* Specifies if the contextual box should be highlighted */ + highlight: PropTypes.bool, +} + +HERecommendation.defaultProps = { + formValues: {}, + handleSubmit: undefined, + hasReviewerReports: false, + highlight: false, +} + export default compose( withFetching, withModal(({ isFetching }) => ({ -- GitLab From d5e9ed170873bffcc8be8b7ca9bcbefeb7744dff Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Fri, 23 Nov 2018 15:22:50 +0200 Subject: [PATCH 41/49] fix(HERecommendation): Fixed typo --- .../src/contextualBoxes/HERecommendation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js index 356638fb6..2791a8813 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js +++ b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js @@ -151,9 +151,9 @@ const HERecommendation = ({ </ContextualBox> ) -HERecommendation.prototypes = { +HERecommendation.propTypes = { /* Contains the values of the form inputs */ - formValues: PropTypes.object, + formValues: PropTypes.object, //eslint-disable-line /* Handles the submission of the recommendation */ handleSubmit: PropTypes.func, /* Specifies if the fragment has reviewer reports */ -- GitLab From b5b831f47280d3cf423bf26a5ab6eead1a67de1c Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 27 Nov 2018 13:18:16 +0200 Subject: [PATCH 42/49] docs(ManuscriptFiles): Wrote documentation for ManuscriptFiles component --- .../src/contextualBoxes/AuthorReviews.js | 2 +- .../manuscriptDetails/ManuscriptDetailsTop.js | 4 +- .../src/submissionRevision/ManuscriptFiles.js | 37 +++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js index 8512204ea..f3ffc9825 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js +++ b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js @@ -44,7 +44,7 @@ AuthorReviews.propTypes = { getSignedUrl: PropTypes.func, /** Object containing the list of recommendations. */ journal: PropTypes.object, //eslint-disable-line - /** Contains the token of the currently logged user */ + /** Contains the token of the currently logged user. */ token: PropTypes.string, } diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js index 005af4452..162a6ade7 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js @@ -114,9 +114,9 @@ export default compose( )(ManuscriptDetailsTop) ManuscriptDetailsTop.propTypes = { - /** Object with details about fragment. */ + /** Object containing the selected fragment. */ fragment: PropTypes.object, //eslint-disable-line - /** Object with details about collection. */ + /** Object containing the selected collection. */ collection: PropTypes.object, //eslint-disable-line /** Object with versions of manuscript. */ versions: PropTypes.array, //eslint-disable-line diff --git a/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.js b/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.js index 81a19cecb..d0e4eb12e 100644 --- a/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.js +++ b/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.js @@ -1,6 +1,7 @@ import React from 'react' import { get, has } from 'lodash' import { Field } from 'redux-form' +import PropTypes from 'prop-types' import { Icon } from '@pubsweet/ui' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' @@ -59,6 +60,42 @@ const ManuscriptFiles = ({ </ContextualBox> ) +ManuscriptFiles.propTypes = { + /** Contains the token of the currently logged user. */ + token: PropTypes.string, + /** Object containing the selected fragment. */ + fragment: PropTypes.object, //eslint-disable-line + /** Object containing the selected collection. */ + collection: PropTypes.object, //eslint-disable-line + /** Name of added form. */ + formName: PropTypes.func, + /** Change added form. */ + changeForm: PropTypes.func, + /** Removes the file from the server. */ + deleteFile: PropTypes.func, + /** Uploads the file to the server. */ + uploadFile: PropTypes.func, + /** View content of the uploaded file. */ + previewFile: PropTypes.func, + /** An async call that returns the securized S3 file url. */ + getSignedUrl: PropTypes.func, + /** Value representing if the form has any errors. */ + formErrors: PropTypes.object, //eslint-disable-line +} + +ManuscriptFiles.defaultProps = { + token: '', + fragment: {}, + collection: {}, + formName: undefined, + changeForm: undefined, + deleteFile: undefined, + uploadFile: undefined, + previewFile: undefined, + getSignedUrl: undefined, + formErrors: {}, +} + export default ManuscriptFiles // #region styled-components -- GitLab From fa34fd793b430ee41fa1220facaa1e3790360665 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 27 Nov 2018 16:34:36 +0200 Subject: [PATCH 43/49] docs(SubmitRevision/ResponseToReviewer/ManuscriptFiles): Wrote documentation for SubmitRevision/Resp --- .../submissionRevision/DetailsAndAuthors.js | 8 +-- .../src/submissionRevision/ManuscriptFiles.js | 14 ++--- .../submissionRevision/ResponseToReviewer.js | 19 ++++++ .../src/submissionRevision/SubmitRevision.js | 63 ++++++++++++++++++- .../src/submissionRevision/SubmitRevision.md | 3 + 5 files changed, 95 insertions(+), 12 deletions(-) diff --git a/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js b/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js index 61428ba17..3109bc5ea 100644 --- a/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js +++ b/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js @@ -109,9 +109,9 @@ const Root = styled.div` ` DetailsAndAuthors.propTypes = { - /** Name of the manuscript. */ + /** Deprecated object containing manuscript types. */ journal: PropTypes.string, - /** */ + /** Object containing the selected fragment */ fragment: PropTypes.PropTypes.shape({ id: PropTypes.string, type: PropTypes.string, @@ -166,7 +166,7 @@ DetailsAndAuthors.propTypes = { fragmentType: PropTypes.string, recomandations: PropTypes.array, }), - /** Information sent for the manuscript. */ + /** Object containing the selected collection. */ collection: PropTypes.shape({ id: PropTypes.string, type: PropTypes.string, @@ -232,7 +232,7 @@ DetailsAndAuthors.propTypes = { }), visibleStatus: PropTypes.string, }), - /** Here you can edit author. */ + /** Chages the form to allow editing of the selected author and returns his index. */ onAuthorEdit: PropTypes.func, /** Manuscript types that you can chose from. */ manuscriptTypes: PropTypes.arrayOf( diff --git a/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.js b/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.js index d0e4eb12e..b8cdfff71 100644 --- a/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.js +++ b/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.js @@ -80,19 +80,19 @@ ManuscriptFiles.propTypes = { /** An async call that returns the securized S3 file url. */ getSignedUrl: PropTypes.func, /** Value representing if the form has any errors. */ - formErrors: PropTypes.object, //eslint-disable-line + formErrors: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), } ManuscriptFiles.defaultProps = { token: '', fragment: {}, collection: {}, - formName: undefined, - changeForm: undefined, - deleteFile: undefined, - uploadFile: undefined, - previewFile: undefined, - getSignedUrl: undefined, + formName: () => {}, + changeForm: () => {}, + deleteFile: () => {}, + uploadFile: () => {}, + previewFile: () => {}, + getSignedUrl: () => {}, formErrors: {}, } diff --git a/packages/component-faraday-ui/src/submissionRevision/ResponseToReviewer.js b/packages/component-faraday-ui/src/submissionRevision/ResponseToReviewer.js index 790f2143d..d1f8bfdeb 100644 --- a/packages/component-faraday-ui/src/submissionRevision/ResponseToReviewer.js +++ b/packages/component-faraday-ui/src/submissionRevision/ResponseToReviewer.js @@ -1,5 +1,6 @@ import React from 'react' import { isEmpty } from 'lodash' +import PropTypes from 'prop-types' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { FilePicker, Spinner, ValidatedField } from '@pubsweet/ui' @@ -20,6 +21,7 @@ import { const allowedFileExtensions = ['pdf', 'doc', 'docx', 'txt', 'rdf', 'odt'] const ResponseToReviewer = ({ file, + token, onDelete, onUpload, isFetching, @@ -74,6 +76,23 @@ const ResponseToReviewer = ({ </ContextualBox> ) +ResponseToReviewer.propTypes = { + /** Deletes the file from the server then updates the form. */ + onDelete: PropTypes.func, + /** Uploads the file then updates the form. */ + onUpload: PropTypes.func, + /** View content of the uploaded file. */ + previewFile: PropTypes.func, + /** Downloads the file from the server. */ + downloadFile: PropTypes.func, +} +ResponseToReviewer.defaultProps = { + onDelete: () => {}, + onUpload: () => {}, + previewFile: () => {}, + downloadFile: () => {}, +} + const Root = styled.div` border-left: ${th('borderWidth')} ${th('borderStyle')} ${th('colorBorder')}; padding-left: calc(${th('gridUnit')} * 1); diff --git a/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js b/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js index ace1a76ed..5c94d8718 100644 --- a/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js +++ b/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { Button } from '@pubsweet/ui' import styled from 'styled-components' import { reduxForm } from 'redux-form' @@ -30,6 +31,7 @@ const SubmitRevision = ({ onAuthorEdit, isEditingAuthor, formErrors, + formName, }) => ( <ContextualBox highlight label="Submit Revision" mb={2}> <Root> @@ -51,7 +53,7 @@ const SubmitRevision = ({ deleteFile={deleteFile} downloadFile={downloadFile} formErrors={formErrors} - formName="revision" + formName={formName} fragment={fragment} getSignedUrl={getSignedUrl} previewFile={previewFile} @@ -85,6 +87,65 @@ const SubmitRevision = ({ </ContextualBox> ) +SubmitRevision.propTypes = { + /** Object containing the list of recommendations. */ + journal: PropTypes.object, //eslint-disable-line + /** Uploads the file to the server. */ + addFile: PropTypes.func, + /** Object containing the selected fragment. */ + fragment: PropTypes.object, //eslint-disable-line + /** An async call to add an author to the manuscript. */ + addAuthor: PropTypes.func, + /** Removes the file from the server. */ + deleteFile: PropTypes.func, + /** Object containing the selected collection. */ + collection: PropTypes.object, //eslint-disable-line + /** Change added form. */ + changeForm: PropTypes.func, + /** Object containing token for current user. */ + currentUser: PropTypes.object, //eslint-disable-line + /** View content of the uploaded file. */ + previewFile: PropTypes.func, + /** Value representing if the form has any errors. */ + hasFormError: PropTypes.bool, + /** An async call to remove an existing author from the manuscript. */ + deleteAuthor: PropTypes.func, + /** An async call that returns the securized S3 file url. */ + getSignedUrl: PropTypes.func, + /** Value containing the revision's file for the reviewer's response. */ + responseFile: PropTypes.func, + /** Downloads the file from the server. */ + downloadFile: PropTypes.func, + /** Uploads the file then updates the form. */ + addResponseFile: PropTypes.func, + /** Deletes the file from the server then updates the form. */ + deleteResponseFile: PropTypes.func, + /** Chages the form to allow editing of the selected author and returns his index */ + onAuthorEdit: PropTypes.func, + /** Value representing if the form has any errors */ + formErrors: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), +} +SubmitRevision.defaultProps = { + journal: {}, + addFile: () => {}, + fragment: {}, + addAuthor: () => {}, + deleteFile: () => {}, + collection: {}, + changeForm: () => {}, + currentUser: {}, + previewFile: () => {}, + hasFormError: false, + deleteAuthor: () => {}, + getSignedUrl: () => {}, + responseFile: () => {}, + downloadFile: () => {}, + addResponseFile: () => {}, + deleteResponseFile: () => {}, + onAuthorEdit: () => {}, + formErrors: {}, +} + const Root = styled.div` background-color: ${th('colorBackgroundHue2')}; padding: calc(${th('gridUnit')} * 2); diff --git a/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.md b/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.md index 6c9a0bde8..a6768429d 100644 --- a/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.md +++ b/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.md @@ -1,5 +1,8 @@ ```js const props = { + currentUser: { + token: 'hashmancasalaamdanam', + }, fragment: { id: 'a9dc38fe-5524-4728-b97f-9495a2eb4bee', type: 'fragment', -- GitLab From a79b83d41246a678b80dea92208bb29daf401b24 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Wed, 28 Nov 2018 11:00:54 +0200 Subject: [PATCH 44/49] docs(ResponseToRevisionRequest/ReviewDetails): Wrote documentation for ResponseToRevisionRequest and --- .../ResponseToRevisionRequest.js | 18 +++++- .../src/contextualBoxes/ReviewerDetails.js | 62 +++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.js b/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.js index 4d3d4b181..8f2ea00ac 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.js +++ b/packages/component-faraday-ui/src/contextualBoxes/ResponseToRevisionRequest.js @@ -1,5 +1,5 @@ import React from 'react' - +import PropTypes from 'prop-types' import { ContextualBox, AuthorReply } from '../' const ResponseToRevisionRequest = ({ @@ -18,4 +18,20 @@ const ResponseToRevisionRequest = ({ </ContextualBox> ) +ResponseToRevisionRequest.propTypes = { + /** Object containing the selected fragment. */ + fragment: PropTypes.object, //eslint-disable-line + /** Callback function used to control the state of the component. + * To be used together with the `expanded` prop. + */ + toggle: PropTypes.func, + /** Prop used together with toggle. */ + expanded: PropTypes.bool, +} +ResponseToRevisionRequest.defaultProps = { + fragment: {}, + toggle: () => {}, + expanded: false, +} + export default ResponseToRevisionRequest diff --git a/packages/component-faraday-ui/src/contextualBoxes/ReviewerDetails.js b/packages/component-faraday-ui/src/contextualBoxes/ReviewerDetails.js index d8a41b821..b77e07729 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/ReviewerDetails.js +++ b/packages/component-faraday-ui/src/contextualBoxes/ReviewerDetails.js @@ -1,5 +1,6 @@ import React, { Fragment } from 'react' import { get } from 'lodash' +import PropTypes from 'prop-types' import { H4 } from '@pubsweet/ui' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' @@ -138,6 +139,67 @@ const ReviewerDetails = ({ </ContextualBox> ) +ReviewerDetails.propTypes = { + /** Object containing the list of recommendations. */ + journal: PropTypes.object, //eslint-disable-line + /** Object containing the selected fragment. */ + fragment: PropTypes.object, //eslint-disable-line + /** Specifies how many reviewers have been invited. */ + invitations: PropTypes.array, //eslint-disable-line + /** Array that contains publon reviewers. */ + publonReviewers: PropTypes.array, //eslint-disable-line + /** View content of the uploaded file. */ + previewFile: PropTypes.func, + /** Downloads the file from the server. */ + downloadFile: PropTypes.func, + /** Sends an invitation to the reviewer. */ + onInviteReviewer: PropTypes.func, + /** Reviewers reports. */ + reports: PropTypes.array, //eslint-disable-line + /** Sends an invitation to a Publon reviewer. */ + onInvitePublonReviewer: PropTypes.func, + /** Resends an invitation to an already invited. */ + onResendReviewerInvite: PropTypes.func, + /** Cancels an invitation to an invited reviewer. */ + onRevokeReviewerInvite: PropTypes.func, + /** Callback function used to control the state of the component. + * To be used together with the `expanded` prop. + */ + toggle: PropTypes.func, + /** Prop used together with toggle. */ + expanded: PropTypes.bool, + /* Specifies if the contextual box should be highlighted */ + highlight: PropTypes.bool, + /** Specifies if manuscript is at the latest version. */ + isLatestVersion: PropTypes.bool, + /** Specifies if we can invite reviewers on the current version. */ + canInviteReviewers: PropTypes.bool, + /** Specifies if we can view reviewers details on the current version. */ + canViewReviewersDetails: PropTypes.bool, + /** Specifies if the author can view reports details on the current version. */ + authorCanViewReportsDetails: PropTypes.func, +} +ReviewerDetails.defaultProps = { + journal: {}, + reports: [], + fragment: {}, + invitations: [], + publonReviewers: [], + previewFile: () => {}, + downloadFile: () => {}, + onInviteReviewer: () => {}, + onInvitePublonReviewer: () => {}, + onResendReviewerInvite: () => {}, + onRevokeReviewerInvite: () => {}, + toggle: () => {}, + expanded: false, + highlight: false, + canInviteReviewers: false, + canViewReviewersDetails: false, + authorCanViewReportsDetails: () => {}, + isLatestVersion: false, +} + export default compose( withFilePreview, withFileDownload, -- GitLab From 04bee2c1796df37425862bfcd2e3fe45f442f252 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Wed, 28 Nov 2018 13:26:49 +0200 Subject: [PATCH 45/49] docs(AuthorReply): Wrote documentation for AuthorReply --- .../component-faraday-ui/src/AuthorReply.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/component-faraday-ui/src/AuthorReply.js b/packages/component-faraday-ui/src/AuthorReply.js index 88dbb9074..ac320032e 100644 --- a/packages/component-faraday-ui/src/AuthorReply.js +++ b/packages/component-faraday-ui/src/AuthorReply.js @@ -1,10 +1,10 @@ -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 React, { Fragment } from 'react' import { DateParser } from '@pubsweet/ui' +import { th } from '@pubsweet/ui-toolkit' import { Label, Item, Row, Text, FileItem } from './' @@ -57,16 +57,25 @@ const AuthorReply = ({ ) AuthorReply.propTypes = { /** Reply of author. */ - reply: PropTypes.string, + replyContent: PropTypes.string, /** Name of author that replied. */ authorName: PropTypes.string, /** Date of submitted reply. */ submittedOn: PropTypes.number, + /** Download the file from the server then updates the form. */ + onDownload: PropTypes.func, + /** Previews the file from the server then updates the form. */ + onPreview: PropTypes.func, + /** Reply File. */ + replyFile: PropTypes.string, } AuthorReply.defaultProps = { - reply: undefined, + replyContent: undefined, + replyFile: undefined, authorName: undefined, submittedOn: undefined, + onDownload: () => {}, + onPreview: () => {}, } export default withProps( -- GitLab From 8aea2de1a85cba538c8a1a4c7ff8b5283d12c3ac Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 4 Dec 2018 11:14:31 +0200 Subject: [PATCH 46/49] docs(manuscriptDetails Folder): Wrote documentation for files inside manuscriptDetails folder --- .../component-faraday-ui/src/AuthorReply.js | 4 +-- .../component-faraday-ui/src/AuthorTag.js | 2 +- .../manuscriptDetails/ManuscriptDetailsTop.js | 14 +++++++++- .../ManuscriptEicDecision.js | 3 +++ .../manuscriptDetails/ManuscriptFileList.js | 14 +++++----- .../ManuscriptFileSection.js | 6 ++--- .../src/manuscriptDetails/ManuscriptHeader.js | 24 +++++++++++++++++ .../src/manuscriptDetails/ManuscriptHeader.md | 17 +++++++----- .../manuscriptDetails/ManuscriptMetadata.js | 22 +++++++++++++-- .../manuscriptDetails/ManuscriptVersion.js | 17 +++++++++++- .../manuscriptDetails/ResponseToInvitation.js | 27 +++++++++++++++++++ 11 files changed, 126 insertions(+), 24 deletions(-) diff --git a/packages/component-faraday-ui/src/AuthorReply.js b/packages/component-faraday-ui/src/AuthorReply.js index ac320032e..053d3003c 100644 --- a/packages/component-faraday-ui/src/AuthorReply.js +++ b/packages/component-faraday-ui/src/AuthorReply.js @@ -67,11 +67,11 @@ AuthorReply.propTypes = { /** Previews the file from the server then updates the form. */ onPreview: PropTypes.func, /** Reply File. */ - replyFile: PropTypes.string, + replyFile: PropTypes.object, //eslint-disable-line } AuthorReply.defaultProps = { replyContent: undefined, - replyFile: undefined, + replyFile: {}, authorName: undefined, submittedOn: undefined, onDownload: () => {}, diff --git a/packages/component-faraday-ui/src/AuthorTag.js b/packages/component-faraday-ui/src/AuthorTag.js index 59760469e..9f9394ff8 100644 --- a/packages/component-faraday-ui/src/AuthorTag.js +++ b/packages/component-faraday-ui/src/AuthorTag.js @@ -26,7 +26,7 @@ const AuthorTag = ({ AuthorTag.propTypes = { /** The author you want to be on the card. */ author: PropTypes.shape({ - id: PropTypes.string, + id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), firstName: PropTypes.string, lastName: PropTypes.string, isCorresponding: PropTypes.bool, diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js index 162a6ade7..7b0e01788 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptDetailsTop.js @@ -118,12 +118,24 @@ ManuscriptDetailsTop.propTypes = { fragment: PropTypes.object, //eslint-disable-line /** Object containing the selected collection. */ collection: PropTypes.object, //eslint-disable-line - /** Object with versions of manuscript. */ + /** Object with versions of manuscript. */ versions: PropTypes.array, //eslint-disable-line + /** An async call that returns the securized S3 file url. */ + getSignedUrl: PropTypes.func, + /** An async call that takes you to edit. */ + goToEdit: PropTypes.func, + /** An async call that takes you to thchnical check. */ + goToTechnicalCheck: PropTypes.func, + /** Object containing token for current user. */ + currentUser: PropTypes.object, //eslint-disable-line } ManuscriptDetailsTop.defaultProps = { fragment: {}, collection: {}, versions: [], + getSignedUrl: () => {}, + goToEdit: () => {}, + goToTechnicalCheck: () => {}, + currentUser: {}, } diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js index 8afd41c6b..65d865121 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js @@ -148,11 +148,14 @@ ManuscriptEicDecision.propTypes = { messagesLabel: PropTypes.object, //eslint-disable-line /** Callback function fired when the handling editor submit his decision. */ submitDecision: PropTypes.func, + /** Values taken by form. */ + formValues: PropTypes.object, //eslint-disable-line } ManuscriptEicDecision.defaultProps = { collection: {}, messagesLabel: undefined, submitDecision: undefined, + formValues: {}, } // #region styles diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileList.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileList.js index 857aeba89..901ebc1a2 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileList.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileList.js @@ -42,19 +42,19 @@ ManuscriptFileList.propTypes = { manuscripts: PropTypes.arrayOf(PropTypes.object), supplementary: PropTypes.arrayOf(PropTypes.object), }), - /** Callback function fired when delete icon it's pressed. */ + /** Callback function fired when delete icon is pressed. */ onDelete: PropTypes.func, - /** Callback function fired when download icon it's pressed. */ + /** Callback function fired when download icon is pressed. */ onDownload: PropTypes.func, - /** Callback function fired when preview icon it's pressed. */ + /** Callback function fired when preview icon is pressed. */ onPreview: PropTypes.func, } ManuscriptFileList.defaultProps = { - files: undefined, - onDelete: undefined, - onDownload: undefined, - onPreview: undefined, + files: {}, + onDelete: () => {}, + onDownload: () => {}, + onPreview: () => {}, } export default withFilePreview(withFileDownload(ManuscriptFileList)) diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js index 7458b13be..4e43e59df 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js @@ -34,15 +34,15 @@ ManuscriptFileSection.propTypes = { list: PropTypes.arrayOf(PropTypes.object), /** Category name of uploaded files. */ label: PropTypes.string, - /** Callback function fired when download icon it's pressed. */ + /** Callback function fired when download icon is pressed. */ onDownload: PropTypes.func, - /** Callback function fired when preview icon it's pressed. */ + /** Callback function fired when preview icon is pressed. */ onPreview: PropTypes.func, } ManuscriptFileSection.defaultProps = { list: [], - label: '', + label: undefined, onDownload: undefined, onPreview: undefined, } diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js index 296bebafc..e3925e13f 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js @@ -1,5 +1,6 @@ import React, { Fragment } from 'react' import { get, chain, isEmpty } from 'lodash' +import PropTypes from 'prop-types' import { H2, H4, DateParser, Button } from '@pubsweet/ui' import { compose, @@ -83,6 +84,29 @@ const ManuscriptHeader = ({ ) } +ManuscriptHeader.propTypes = { + /** Component that takes a func that returns a react elem and calls it instead of implementing its own rander. */ + renderHE: PropTypes.func, + /** Object containing the selected fragment. */ + fragment: PropTypes.object, //eslint-disable-line + /** Manuscript types that you can chose from. */ + manuscriptType: PropTypes.object, //eslint-disable-line + /** Status for editor in chief. */ + editorInChief: PropTypes.string, + /** Object containing the selected collection. */ + collection: PropTypes.object, //eslint-disable-line + /** Specifies if manuscript is at the latest version. */ + isLatestVersion: PropTypes.bool, +} +ManuscriptHeader.defaultProps = { + renderHE: () => {}, + fragment: {}, + manuscriptType: {}, + editorInChief: 'Unassigned', + collection: {}, + isLatestVersion: false, +} + export default compose( defaultProps({ inviteHE: () => {}, diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.md b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.md index 86ddd80a7..6c3c740eb 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.md +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.md @@ -54,7 +54,9 @@ const fragment = { } const currentUser = { - canAssignHE: true, + permissions: { + canAssignHE: true, + }, } const journal = { @@ -75,7 +77,6 @@ const journal = { }, ], } - ;<ManuscriptHeader collection={collection} fragment={fragment} @@ -143,12 +144,14 @@ const collection = { ], } -const handlingEditors=[{ +const handlingEditors = [ + { id: 'he-1', firstName: 'Handlington', lastName: 'Ignashevici', name: 'Handlington Ignashevici', -}] + }, +] const fragment = { authors, @@ -162,7 +165,9 @@ const fragment = { } const currentUser = { - canAssignHE: true, + permissions: { + canAssignHE: true, + }, } const journal = { @@ -183,7 +188,6 @@ const journal = { }, ], } - ;<ManuscriptHeader collection={collection} fragment={fragment} @@ -283,7 +287,6 @@ const journal = { }, ], } - ;<ManuscriptHeader collection={collection} fragment={fragment} diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptMetadata.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptMetadata.js index f86208b45..a3992ff16 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptMetadata.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptMetadata.js @@ -1,6 +1,7 @@ -import React, { Fragment } from 'react' -import { isEmpty, get } from 'lodash' +import PropTypes from 'prop-types' import { withProps } from 'recompose' +import { isEmpty, get } from 'lodash' +import React, { Fragment } from 'react' import { Text, @@ -57,6 +58,23 @@ const ManuscriptMetadata = ({ </Fragment> ) +ManuscriptMetadata.propTypes = { + /** Files Label of the contextual box. */ + filesLabel: PropTypes.string, + /** An async call that returns the securized S3 file url. */ + getSignedUrl: PropTypes.func, + /** Object containing token for current user. */ + currentUser: PropTypes.object, //eslint-disable-line + /** Object containing the selected fragment. */ + fragment: PropTypes.object, //eslint-disable-line +} +ManuscriptMetadata.defaultProps = { + filesLabel: '', + getSignedUrl: () => {}, + currentUser: {}, + fragment: {}, +} + export default withProps(({ fragment: { files } }) => ({ filesLabel: `Files (${get(files, 'manuscripts', []).length + get(files, 'coverLetter', []).length + diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.js index 1738e297d..423a35f02 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.js @@ -1,10 +1,11 @@ import React from 'react' import { get } from 'lodash' +import PropTypes from 'prop-types' import { Menu } from '@pubsweet/ui' const ManuscriptVersion = ({ history, - versions = {}, + versions = [], fragment = {}, collection = {}, }) => @@ -20,4 +21,18 @@ const ManuscriptVersion = ({ /> ) +ManuscriptVersion.propTypes = { + /** Object with versions of manuscript. */ + versions: PropTypes.array, //eslint-disable-line + /** Object containing the selected fragment. */ + fragment: PropTypes.object, //eslint-disable-line + /** Object containing the selected collection. */ + collection: PropTypes.object, //eslint-disable-line +} + +ManuscriptVersion.defaultProps = { + versions: [], + fragment: {}, + collection: {}, +} export default ManuscriptVersion diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.js b/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.js index a638617e4..ca4d710b8 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import { reduxForm } from 'redux-form' import { required } from 'xpub-validators' import { get, has, capitalize } from 'lodash' @@ -86,6 +87,32 @@ const ResponseToInvitation = ({ </ContextualBox> ) +ResponseToInvitation.propTypes = { + /** Label of the contextual box. */ + label: PropTypes.string, + /** Title that will be showed on the card. */ + title: PropTypes.string, + /** Expands a message for collapse or expand. */ + expanded: PropTypes.bool, + /** Method used to toggle a message on click. */ + toggle: PropTypes.func, + /* Handles the submission of the recommendation. */ + handleSubmit: PropTypes.func, + /** Specifies if it will show comments on the current version. */ + shouldShowComments: PropTypes.bool, + /** Specifies the Label name for the respond to invitation button. */ + buttonLabel: PropTypes.string, +} +ResponseToInvitation.defaultProps = { + label: undefined, + title: undefined, + toggle: () => {}, + expanded: false, + handleSubmit: () => {}, + shouldShowComments: false, + buttonLabel: 'RESPOND TO INVITATION', +} + export default compose( withFetching, withModal(({ isFetching, modalKey }) => ({ -- GitLab From 7458a7a821d5553a019852da53a6eaf4d8dba2fe Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Fri, 7 Dec 2018 16:31:26 +0200 Subject: [PATCH 47/49] docs(ContextualBoxes/ManuscriptDetails/submissionRevisionfolders): Wrote documentation for files ins --- .../component-faraday-ui/src/AuthorReply.js | 2 +- .../src/contextualBoxes/AuthorReviews.js | 1 + .../src/contextualBoxes/HERecommendation.js | 2 - .../src/contextualBoxes/HERecommendation.md | 29 ++- .../src/manuscriptDetails/ManuscriptHeader.md | 178 ++++++++++++++---- .../manuscriptDetails/ManuscriptVersion.md | 23 ++- .../manuscriptDetails/ResponseToInvitation.md | 6 +- .../src/pending/ControlledAccordion.js | 4 +- .../src/submissionRevision/ManuscriptFiles.md | 6 +- .../submissionRevision/ResponseToReviewer.md | 21 ++- .../src/submissionRevision/SubmitRevision.js | 4 +- 11 files changed, 209 insertions(+), 67 deletions(-) diff --git a/packages/component-faraday-ui/src/AuthorReply.js b/packages/component-faraday-ui/src/AuthorReply.js index 053d3003c..3d1ed3491 100644 --- a/packages/component-faraday-ui/src/AuthorReply.js +++ b/packages/component-faraday-ui/src/AuthorReply.js @@ -67,7 +67,7 @@ AuthorReply.propTypes = { /** Previews the file from the server then updates the form. */ onPreview: PropTypes.func, /** Reply File. */ - replyFile: PropTypes.object, //eslint-disable-line + replyFile: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), } AuthorReply.defaultProps = { replyContent: undefined, diff --git a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js index 580363ef7..613ab6e4f 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js +++ b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js @@ -10,6 +10,7 @@ import { Text, indexReviewers, } from '../' +import { FragmentsOnCompositeTypes } from 'graphql' const SubmittedReportsNumberForAuthorReviews = ({ reports }) => ( <Row fitContent justify="flex-end"> diff --git a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js index a1f02843e..9fd76615c 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js +++ b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js @@ -108,7 +108,6 @@ const HERecommendation = ({ /> </ItemOverrideAlert> </Row> - {get(formValues, 'recommendation') === 'minor' || get(formValues, 'recommendation') === 'major' ? ( <Row mt={2}> @@ -148,7 +147,6 @@ const HERecommendation = ({ </ResponsiveItem> </ResponsiveRow> )} - <Row justify="flex-end" mt={2}> <Button data-test-id="button-editorial-recommendation-submit" diff --git a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.md b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.md index 8d00e6a5f..45874db4a 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.md +++ b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.md @@ -2,10 +2,37 @@ HE recommendation. ```js const formValues = { - recommendation: 'minor-revision', + recommendation: 'minor', } +const options = [ + { + value: 'publish', + label: 'Publish', + message: 'Recommend Manuscript for Publishing', + button: 'Submit Recommendation', + }, + { + value: 'reject', + label: 'Reject', + message: 'Recommend Manuscript for Rejection', + button: 'Submit Recommendation', + }, + { + value: 'minor', + label: 'Request Minor Revision', + message: 'Request Minor Revision', + button: 'Request Revision', + }, + { + value: 'major', + label: 'Request Major Revision', + message: 'Request Major Revision', + button: 'Request Revision', + }, +] ;<HERecommendation formValues={formValues} + options={options} modalKey="heRecommendation" onRecommendationSubmit={(values, props) => { props.setFetching(true) diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.md b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.md index 6c3c740eb..e8d4243ea 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.md +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.md @@ -2,33 +2,65 @@ Manuscript header without a HE assigned. ```js const authors = [ - { + { + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ecbafc48fe', email: 'john.doe@gmail.com', firstName: 'John', lastName: 'Doe', isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'michael.felps@gmail.com', - firstName: 'Michael', - lastName: 'Felps', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ecsdfc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', isSubmitting: true, isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail.com', - firstName: 'Barrack', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ec56fc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail1.com', - firstName: 'Barrack 1', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-144cbafc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail2.com', - firstName: 'Barrack 2', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ec33fc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, ] @@ -93,33 +125,65 @@ Manuscript header with a pending HE invitation. ```js const authors = [ - { + { + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ecbafc48fe', email: 'john.doe@gmail.com', firstName: 'John', lastName: 'Doe', isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'michael.felps@gmail.com', - firstName: 'Michael', - lastName: 'Felps', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ecsdfc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', isSubmitting: true, isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail.com', - firstName: 'Barrack', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ec56fc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail1.com', - firstName: 'Barrack 1', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-144cbafc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail2.com', - firstName: 'Barrack 2', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ec33fc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, ] @@ -205,32 +269,64 @@ Manuscript header with a pending HE invitation. ```js const authors = [ { + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ecbafc48fe', email: 'john.doe@gmail.com', firstName: 'John', lastName: 'Doe', isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'michael.felps@gmail.com', - firstName: 'Michael', - lastName: 'Felps', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ecsdfc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', isSubmitting: true, isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail.com', - firstName: 'Barrack', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ec56fc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail1.com', - firstName: 'Barrack 1', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-144cbafc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, { - email: 'barrack.obama@gmail2.com', - firstName: 'Barrack 2', - lastName: 'Obama', + affiliation: 'TSD', + affiliationNumber: 1, + country: 'AX', + id: '5001955e-cc18-42d4-b0ca-15ec33fc48fe', + email: 'john.doe@gmail.com', + firstName: 'John', + lastName: 'Doe', + isSubmitting: true, + isCorresponding: true, + title: 'mr', }, ] @@ -267,7 +363,11 @@ const fragment = { }, } -const currentUser = {} +const currentUser = { + permissions: { + canAssignHE: false, + }, +} const journal = { manuscriptTypes: [ diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.md b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.md index 00e12ce33..cee73787f 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.md +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptVersion.md @@ -1,19 +1,22 @@ Manuscript version component ```js - const history = { - push: v => console.log('go to version -> ', v) -}; - -const fragment={}; -const collection={ - fragments: ['1','2'], -}; + push: v => console.log('go to version -> ', v), +} -<ManuscriptVersion +const fragment = {} +const collection = { + fragments: ['1', '2'], +} +const versions = [ + { label: 'Version 1', value: '10d28459-6f8e-4f6c-a57e-65979e5f8d2' }, + { label: 'Version 2', value: '10d28459-6f8e-4f6c-a57e-65979e5f854' }, +] +;<ManuscriptVersion collection={collection} history={history} fragment={fragment} - /> + versions={versions} +/> ``` diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.md b/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.md index e7f3a21c9..588a77de8 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.md +++ b/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.md @@ -5,10 +5,9 @@ const formValues = { decision: 'accept', } ;<RemoteOpener> - {({ toggle, expanded }) => ( + {({ toggle }) => ( <ResponseToInvitation commentsOn="decline" - expanded={expanded} label="Do you agree to be the handling editor for this manuscript?" formValues={formValues} onResponse={(values, { setFetching }) => { @@ -26,9 +25,8 @@ A Reviewer response to an invitation. ```js <RemoteOpener> - {({ toggle, expanded }) => ( + {({ toggle }) => ( <ResponseToInvitation - expanded={expanded} label="Do you agree to review this manuscript?" onResponse={(values, { setFetching }) => { console.log('on response: ', values) diff --git a/packages/component-faraday-ui/src/pending/ControlledAccordion.js b/packages/component-faraday-ui/src/pending/ControlledAccordion.js index 0c63d576e..8b13d4478 100644 --- a/packages/component-faraday-ui/src/pending/ControlledAccordion.js +++ b/packages/component-faraday-ui/src/pending/ControlledAccordion.js @@ -24,8 +24,8 @@ class ControlledAccordion extends React.Component { const shouldScroll = !prevProps.expanded && this.props.expanded if (this.props.scrollIntoView && shouldScroll) { - const appBarHeight = 70 // TODO -- take height from constants - const appBarMargin = 16 // TODO -- take margin from constants + const appBarHeight = 70 + const appBarMargin = 16 this.scroller.scrollTop = this._accordion.offsetTop - appBarHeight - appBarMargin } diff --git a/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.md b/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.md index 42a8e2120..5129d1d5a 100644 --- a/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.md +++ b/packages/component-faraday-ui/src/submissionRevision/ManuscriptFiles.md @@ -14,8 +14,6 @@ const Wrapper = compose( reduxForm({ form: 'styleguide', }), -)(( props ) => ( - <ManuscriptFiles {...props} /> -)) +)(props => <ManuscriptFiles {...props} />) ;<Wrapper /> -``` \ No newline at end of file +``` diff --git a/packages/component-faraday-ui/src/submissionRevision/ResponseToReviewer.md b/packages/component-faraday-ui/src/submissionRevision/ResponseToReviewer.md index e9264445b..903a52a70 100644 --- a/packages/component-faraday-ui/src/submissionRevision/ResponseToReviewer.md +++ b/packages/component-faraday-ui/src/submissionRevision/ResponseToReviewer.md @@ -1,7 +1,24 @@ ```js +const { reduxForm, getFormValues, change } = require('redux-form') +const { compose } = require('recompose') +const { connect } = require('react-redux') + const allowedFileExtensions = ['pdf', 'doc', 'docx'] -const onUpload = (f) => {console.log('Upload', f)} +const onUpload = file => console.log('Upload', file) -<ResponseToReviewer onUpload={onUpload} allowedFileExtensions={allowedFileExtensions}/> +const Wrapper = compose( + connect(state => ({ + formValues: getFormValues('Response to reviewer')(state), + })), + reduxForm({ + form: 'Response to reviewer', + }), +)(props => ( + <ResponseToReviewer + onUpload={onUpload} + allowedFileExtensions={allowedFileExtensions} + /> +)) +;<Wrapper /> ``` diff --git a/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js b/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js index 5c94d8718..aec7021b0 100644 --- a/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js +++ b/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js @@ -113,7 +113,7 @@ SubmitRevision.propTypes = { /** An async call that returns the securized S3 file url. */ getSignedUrl: PropTypes.func, /** Value containing the revision's file for the reviewer's response. */ - responseFile: PropTypes.func, + responseFile: PropTypes.object, //eslint-disable-line /** Downloads the file from the server. */ downloadFile: PropTypes.func, /** Uploads the file then updates the form. */ @@ -138,7 +138,7 @@ SubmitRevision.defaultProps = { hasFormError: false, deleteAuthor: () => {}, getSignedUrl: () => {}, - responseFile: () => {}, + responseFile: {}, downloadFile: () => {}, addResponseFile: () => {}, deleteResponseFile: () => {}, -- GitLab From a54710cdfe771e4f407c6df8a3be40850f477177 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Fri, 7 Dec 2018 16:42:07 +0200 Subject: [PATCH 48/49] docs(AuthorReviews): fixed lint errors --- .../component-faraday-ui/src/contextualBoxes/AuthorReviews.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js index 613ab6e4f..580363ef7 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js +++ b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js @@ -10,7 +10,6 @@ import { Text, indexReviewers, } from '../' -import { FragmentsOnCompositeTypes } from 'graphql' const SubmittedReportsNumberForAuthorReviews = ({ reports }) => ( <Row fitContent justify="flex-end"> -- GitLab From 363cd2f0dc97ec6272d0da979b63706fca5d4fb0 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Wed, 12 Dec 2018 14:46:10 +0200 Subject: [PATCH 49/49] docs(component-faraday-ui): completed code review changes --- packages/component-faraday-ui/src/AppBar.js | 8 +++---- .../component-faraday-ui/src/AuthorReply.js | 12 +++-------- .../component-faraday-ui/src/AuthorTagList.js | 2 +- .../src/AutosaveIndicator.js | 2 +- .../component-faraday-ui/src/ContextualBox.js | 4 +++- .../src/EditorialReportCard.js | 19 ++++++++--------- .../component-faraday-ui/src/FileSection.js | 20 +++++++++--------- .../component-faraday-ui/src/IconButton.js | 4 ++-- .../component-faraday-ui/src/IconTooltip.js | 4 ++-- .../src/InviteReviewers.js | 2 +- .../src/ManuscriptCard.js | 2 +- .../component-faraday-ui/src/Pagination.js | 2 +- .../src/PasswordValidation.js | 14 ++++++------- .../src/PersonInvitation.js | 14 ++++++------- .../component-faraday-ui/src/PublonsTable.js | 5 ++++- .../src/RadioWithComments.js | 12 +++++------ .../component-faraday-ui/src/RemoteOpener.js | 7 ++++--- .../src/ReviewerReport.js | 2 +- .../src/ReviewerReportAuthor.js | 2 +- packages/component-faraday-ui/src/Text.js | 21 ++++++------------- .../src/contextualBoxes/AssignHE.js | 6 +++--- .../src/contextualBoxes/AuthorReviews.js | 2 +- .../src/contextualBoxes/HERecommendation.js | 2 +- .../manuscriptDetails/ManuscriptAssignHE.js | 2 +- .../ManuscriptEicDecision.js | 4 ++-- .../ManuscriptFileSection.js | 6 +++--- .../manuscriptDetails/ResponseToInvitation.js | 4 ++-- .../submissionRevision/DetailsAndAuthors.js | 2 +- 28 files changed, 88 insertions(+), 98 deletions(-) diff --git a/packages/component-faraday-ui/src/AppBar.js b/packages/component-faraday-ui/src/AppBar.js index 44c5885b0..22cf49c55 100644 --- a/packages/component-faraday-ui/src/AppBar.js +++ b/packages/component-faraday-ui/src/AppBar.js @@ -9,7 +9,6 @@ import { Item, Row, Text } from 'pubsweet-component-faraday-ui' const AppBar = ({ fixed, - isSubmit, logo: Logo, menu: Menu, createDraft, @@ -29,7 +28,6 @@ const AppBar = ({ <Autosave /> </Item> {createDraft && - !isSubmit && currentUser.user && ( <Button data-test-id="new-manuscript" @@ -57,17 +55,19 @@ const AppBar = ({ ) AppBar.propTypes = { + /** If true, it will be fixed at the top of the screen. */ fixed: PropTypes.bool, + /** Logo that will be added to the fragment. */ logo: PropTypes.func, currentUser: PropTypes.shape({ user: PropTypes.object, isAuthenticated: PropTypes.bool, }), - /** If false will appear an error message. */ + /** If false an error message will appear. */ canCreateDraft: PropTypes.bool, /** Pass the menu component. */ menu: PropTypes.func, - /** Appear an animation until it's save. */ + /** Custom component that will be used as an autosave indicator. */ autosave: PropTypes.func, } diff --git a/packages/component-faraday-ui/src/AuthorReply.js b/packages/component-faraday-ui/src/AuthorReply.js index 82523a7de..e1b6cfff6 100644 --- a/packages/component-faraday-ui/src/AuthorReply.js +++ b/packages/component-faraday-ui/src/AuthorReply.js @@ -62,20 +62,14 @@ AuthorReply.propTypes = { authorName: PropTypes.string, /** Date of submitted reply. */ submittedOn: PropTypes.number, - /** Download the file from the server then updates the form. */ - onDownload: PropTypes.func, - /** Previews the file from the server then updates the form. */ - onPreview: PropTypes.func, /** Reply File. */ replyFile: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), } AuthorReply.defaultProps = { - replyContent: undefined, + replyContent: '', replyFile: {}, - authorName: undefined, - submittedOn: undefined, - onDownload: () => {}, - onPreview: () => {}, + authorName: '', + submittedOn: Date.now(), } export default withProps( diff --git a/packages/component-faraday-ui/src/AuthorTagList.js b/packages/component-faraday-ui/src/AuthorTagList.js index f168d53c6..724643ba0 100644 --- a/packages/component-faraday-ui/src/AuthorTagList.js +++ b/packages/component-faraday-ui/src/AuthorTagList.js @@ -114,7 +114,7 @@ export default compose( )(AuthorTagList) AuthorTagList.propTypes = { - /** What label we want to be seen on the card. */ + /** The identificator label that will be seen on the card. */ authorKey: PropTypes.string, /** All authors we want to be seen on the card. */ authors: PropTypes.arrayOf(PropTypes.object), diff --git a/packages/component-faraday-ui/src/AutosaveIndicator.js b/packages/component-faraday-ui/src/AutosaveIndicator.js index c219d5816..03a3041f2 100644 --- a/packages/component-faraday-ui/src/AutosaveIndicator.js +++ b/packages/component-faraday-ui/src/AutosaveIndicator.js @@ -101,7 +101,7 @@ export default compose( )(AutosaveIndicator) AutosaveIndicator.propTypes = { - /** Saving loader. */ + /** Displays the status of the form, in progress, saved or error. */ autosave: PropTypes.object, // eslint-disable-line } diff --git a/packages/component-faraday-ui/src/ContextualBox.js b/packages/component-faraday-ui/src/ContextualBox.js index cb3350d6d..188d9a4a3 100644 --- a/packages/component-faraday-ui/src/ContextualBox.js +++ b/packages/component-faraday-ui/src/ContextualBox.js @@ -74,7 +74,9 @@ ContextualBox.propTypes = { ContextualBox.defaultProps = { label: '', - // rightChildren: undefined, + rightChildren: undefined, + expanded: false, + toggle: () => {}, } // #region styles diff --git a/packages/component-faraday-ui/src/EditorialReportCard.js b/packages/component-faraday-ui/src/EditorialReportCard.js index 387c6f2ac..649beafe6 100644 --- a/packages/component-faraday-ui/src/EditorialReportCard.js +++ b/packages/component-faraday-ui/src/EditorialReportCard.js @@ -25,11 +25,10 @@ const EditorialReportCard = ({ <Root> <Row justify="space-between" mb={2}> <Item vertical> - {editorRole === 'HE' ? ( - <Label mb={1 / 2}>Recommendation</Label> - ) : ( - <Label mb={1 / 2}>Decision</Label> - )} + <Label mb={1 / 2}> + {editorRole === 'HE' ? 'Recommendation' : 'Decision'} + </Label> + ) <Text>{recommendation}</Text> </Item> @@ -113,9 +112,9 @@ export default compose( )(EditorialReportCard) EditorialReportCard.propTypes = { - /** Label that will be view by public persons. */ + /** Label that will be publicly viewed, for example, a message for the author will be seen by other roles also. */ publicLabel: PropTypes.string, - /** Label that will be view by private persons like Editorial Team. */ + /** Label that will only be viewed as private message, for example, by the Editorial Team. */ privateLabel: PropTypes.string, /** Message by editorial team and other information. */ report: PropTypes.shape({ @@ -129,7 +128,7 @@ EditorialReportCard.propTypes = { recommendationType: PropTypes.string, reviewer: PropTypes.object, }), - /** What is the decision/recommendation by editorial team. */ + /** Object containing the list of recommendations. */ journal: PropTypes.shape({ recommendation: PropTypes.arrayOf(PropTypes.object), }), @@ -138,8 +137,8 @@ EditorialReportCard.propTypes = { EditorialReportCard.defaultProps = { publicLabel: '', privateLabel: '', - report: undefined, - journal: undefined, + report: {}, + journal: {}, } // #region styles const Root = styled.div` diff --git a/packages/component-faraday-ui/src/FileSection.js b/packages/component-faraday-ui/src/FileSection.js index 0c72c9cdd..f0691d983 100644 --- a/packages/component-faraday-ui/src/FileSection.js +++ b/packages/component-faraday-ui/src/FileSection.js @@ -113,7 +113,7 @@ const FileSection = ({ FileSection.propTypes = { /** Files that are uploaded. */ files: PropTypes.arrayOf(PropTypes.object), - /** Error you geton uploading. */ + /** Error you get on uploading. */ error: PropTypes.string, /** Titles of manuscript, cover letter and supplimental files. */ title: PropTypes.string, @@ -123,23 +123,23 @@ FileSection.propTypes = { moveItem: PropTypes.func, /** Extensions allowed to be uploaded. */ allowedFileExtensions: PropTypes.arrayOf(PropTypes.string), - /** Appears when a file was picked. */ + /** Callback function fired when a file is picked. */ onFilePick: PropTypes.func, - /** Appears when a file was previwed. */ + /** Callback function fired when preview icon is pressed. */ onPreview: PropTypes.func, - /** Appears when a file was downloaded. */ + /** Callback function fired when download icon is pressed. */ onDownload: PropTypes.func, - /** Appears when a file was deleted. */ + /** Callback function fired when delete icon is pressed. */ onDelete: PropTypes.func, } FileSection.defaultProps = { - files: undefined, - error: undefined, - title: undefined, - listId: undefined, + files: {}, + error: '', + title: '', + listId: '', moveItem: () => {}, - allowedFileExtensions: undefined, + allowedFileExtensions: [], onFilePick: () => {}, onPreview: () => {}, onDownload: () => {}, diff --git a/packages/component-faraday-ui/src/IconButton.js b/packages/component-faraday-ui/src/IconButton.js index df9bb387a..d06944c05 100644 --- a/packages/component-faraday-ui/src/IconButton.js +++ b/packages/component-faraday-ui/src/IconButton.js @@ -40,9 +40,9 @@ IconButton.propTypes = { } IconButton.defaultProps = { - icon: undefined, + icon: '', iconSize: 3, - onClick: undefined, + onClick: () => {}, } export default IconButton diff --git a/packages/component-faraday-ui/src/IconTooltip.js b/packages/component-faraday-ui/src/IconTooltip.js index 487c2b7b5..def736836 100644 --- a/packages/component-faraday-ui/src/IconTooltip.js +++ b/packages/component-faraday-ui/src/IconTooltip.js @@ -46,8 +46,8 @@ IconTooltip.propTypes = { IconTooltip.defaultProps = { icon: 'help-circle', iconSize: 3, - content: undefined, - interactive: undefined, + content: () => {}, + interactive: false, } export default withTheme(IconTooltip) diff --git a/packages/component-faraday-ui/src/InviteReviewers.js b/packages/component-faraday-ui/src/InviteReviewers.js index 9d0959259..69b113655 100644 --- a/packages/component-faraday-ui/src/InviteReviewers.js +++ b/packages/component-faraday-ui/src/InviteReviewers.js @@ -104,7 +104,7 @@ InviteReviewers.propTypes = { } InviteReviewers.defaultProps = { - onInvite: null, + onInvite: () => {}, } export default compose( diff --git a/packages/component-faraday-ui/src/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index 0bec741bc..c03d86116 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -152,7 +152,7 @@ ManuscriptCard.propTypes = { ManuscriptCard.defaultProps = { fragment: {}, - collection: undefined, + collection: {}, } const MainContainer = styled.div` diff --git a/packages/component-faraday-ui/src/Pagination.js b/packages/component-faraday-ui/src/Pagination.js index 5917f5f0f..63ca0c3bd 100644 --- a/packages/component-faraday-ui/src/Pagination.js +++ b/packages/component-faraday-ui/src/Pagination.js @@ -73,7 +73,7 @@ Pagination.propTypes = { } Pagination.defaultProps = { page: 1, - hasMore: undefined, + hasMore: false, maxItems: 23, itemsPerPage: 10, changeItemsPerPage: () => {}, diff --git a/packages/component-faraday-ui/src/PasswordValidation.js b/packages/component-faraday-ui/src/PasswordValidation.js index 6dacbd634..22619b640 100644 --- a/packages/component-faraday-ui/src/PasswordValidation.js +++ b/packages/component-faraday-ui/src/PasswordValidation.js @@ -120,14 +120,14 @@ PasswordValidation.propTypes = { atLeastOnePunctuation: PropTypes.bool, } PasswordValidation.defaultProps = { - formName: undefined, - formLabel: undefined, + formName: '', + formLabel: '', submitFailed: false, - minLength: undefined, - atLeastOneDigit: undefined, - atLeastOneUppercase: undefined, - atLeastOneLowerrcase: undefined, - atLeastOnePunctuation: undefined, + minLength: false, + atLeastOneDigit: false, + atLeastOneUppercase: false, + atLeastOneLowerrcase: false, + atLeastOnePunctuation: false, } export default compose( diff --git a/packages/component-faraday-ui/src/PersonInvitation.js b/packages/component-faraday-ui/src/PersonInvitation.js index 2e00a74bb..dc2d49439 100644 --- a/packages/component-faraday-ui/src/PersonInvitation.js +++ b/packages/component-faraday-ui/src/PersonInvitation.js @@ -111,15 +111,15 @@ PersonInvitation.propTypes = { }), } PersonInvitation.defaultProps = { - id: undefined, - role: undefined, - type: undefined, - reason: undefined, - userId: undefined, + id: '', + role: '', + type: '', + reason: '', + userId: '', hasAnswer: false, - invitedOn: undefined, + invitedOn: Date.now(), isAccepted: false, - respondedOn: undefined, + respondedOn: Date.now(), person: {}, } diff --git a/packages/component-faraday-ui/src/PublonsTable.js b/packages/component-faraday-ui/src/PublonsTable.js index cc4712d4b..c77945960 100644 --- a/packages/component-faraday-ui/src/PublonsTable.js +++ b/packages/component-faraday-ui/src/PublonsTable.js @@ -102,10 +102,13 @@ export default compose( TableView.propTypes = { reviewers: PropTypes.arrayOf(PropTypes.object), + /** Sends an invitation to the reviewer. */ + onInviteReviewer: PropTypes.func, } TableView.defaultProps = { - reviewers: undefined, + reviewers: [], + onInviteReviewer: () => {}, } // #region styles diff --git a/packages/component-faraday-ui/src/RadioWithComments.js b/packages/component-faraday-ui/src/RadioWithComments.js index af4276dc5..d81a9cdc3 100644 --- a/packages/component-faraday-ui/src/RadioWithComments.js +++ b/packages/component-faraday-ui/src/RadioWithComments.js @@ -77,7 +77,7 @@ const RadioWithComments = ({ ) RadioWithComments.propTypes = { - /** Defines if a fragment si required or not. */ + /** Defines if a fragment is required or not. */ required: PropTypes.bool, /** Values taken by form. */ formValues: PropTypes.object, //eslint-disable-line @@ -95,11 +95,11 @@ RadioWithComments.propTypes = { RadioWithComments.defaultProps = { required: false, formValues: {}, - radioFieldName: undefined, - commentsFieldName: undefined, - commentsOn: undefined, - commentsLabel: undefined, - radioLabel: undefined, + radioFieldName: '', + commentsFieldName: '', + commentsOn: '', + commentsLabel: '', + radioLabel: '', } export default RadioWithComments diff --git a/packages/component-faraday-ui/src/RemoteOpener.js b/packages/component-faraday-ui/src/RemoteOpener.js index 29a777fde..6681f273f 100644 --- a/packages/component-faraday-ui/src/RemoteOpener.js +++ b/packages/component-faraday-ui/src/RemoteOpener.js @@ -14,10 +14,11 @@ export default withStateHandlers( )(RemoteOpener) RemoteOpener.propTypes = { - /** Expands a message for collapse or expand. */ + /** Prop used together with toggle. */ expanded: PropTypes.bool, - /** Method used to toggle a message on click. */ - toggle: PropTypes.func, + /** Callback function used to control the state of the component. + * To be used together with the `expanded` prop. + */ toggle: PropTypes.func, } RemoteOpener.defaultProps = { expanded: false, diff --git a/packages/component-faraday-ui/src/ReviewerReport.js b/packages/component-faraday-ui/src/ReviewerReport.js index ccf5eed4b..ab0359a20 100644 --- a/packages/component-faraday-ui/src/ReviewerReport.js +++ b/packages/component-faraday-ui/src/ReviewerReport.js @@ -124,7 +124,7 @@ ReviewerReport.propTypes = { ReviewerReport.defaultProps = { showOwner: false, - report: undefined, + report: {}, journal: { recommendation: [] }, } // #region styles diff --git a/packages/component-faraday-ui/src/ReviewerReportAuthor.js b/packages/component-faraday-ui/src/ReviewerReportAuthor.js index 29f2605fd..c29d5e60c 100644 --- a/packages/component-faraday-ui/src/ReviewerReportAuthor.js +++ b/packages/component-faraday-ui/src/ReviewerReportAuthor.js @@ -114,7 +114,7 @@ ReviewerReportAuthor.propTypes = { ReviewerReportAuthor.defaultProps = { showOwner: false, - report: undefined, + report: {}, journal: { recommendation: [] }, } diff --git a/packages/component-faraday-ui/src/Text.js b/packages/component-faraday-ui/src/Text.js index aed324d77..5a21b6b2e 100644 --- a/packages/component-faraday-ui/src/Text.js +++ b/packages/component-faraday-ui/src/Text.js @@ -100,24 +100,18 @@ const Text = ({ bullet, children, ...rest }) => ) Text.propTypes = { - /** Defines what style the secondary text will have. */ + /** Default color for non-primary actions. */ secondary: PropTypes.bool, - /** Defines what style the error text will have. */ + /** Default color for error actions. */ error: PropTypes.bool, - /** Defines what style the customId text will have. */ + /** Default style for the customId text. */ customId: PropTypes.bool, - /** Defines what style the labelLine text will have. */ + /** Default style for text used as a label Line. */ labelLine: PropTypes.bool, - /** Defines what style the journal text will have. */ + /** Default style used for journal text. */ journal: PropTypes.bool, - /** Defines what style the small text will have. */ + /** Default style used for small text. */ small: PropTypes.bool, - /** defines how items will be displayed. */ - display: PropTypes.string, - /** defines how items will be aligned. */ - align: PropTypes.string, - /** defines if there will be a white space. */ - whiteSpace: PropTypes.string, } Text.defaultProps = { @@ -127,9 +121,6 @@ Text.defaultProps = { labelLine: false, journal: false, small: false, - display: 'inline-block', - align: 'start', - whiteSpace: 'initial', } export default Text diff --git a/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js b/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js index 20d88937f..93abbfee1 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js +++ b/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js @@ -111,11 +111,11 @@ AssignHE.propTypes = { } AssignHE.defaultProps = { - changeSearch: undefined, + changeSearch: () => {}, searchValue: '', - clearSearch: undefined, + clearSearch: () => {}, handlingEditors: [], - inviteHandlingEditor: undefined, + inviteHandlingEditor: () => {}, } export default compose( diff --git a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js index 580363ef7..aed0b39d2 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js +++ b/packages/component-faraday-ui/src/contextualBoxes/AuthorReviews.js @@ -65,7 +65,7 @@ AuthorReviews.propTypes = { AuthorReviews.defaultProps = { reports: [], - getSignedUrl: undefined, + getSignedUrl: () => {}, journal: {}, token: '', } diff --git a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js index 9fd76615c..79593cc08 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js +++ b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js @@ -178,7 +178,7 @@ HERecommendation.propTypes = { HERecommendation.defaultProps = { formValues: {}, - handleSubmit: undefined, + handleSubmit: () => {}, hasReviewerReports: false, highlight: false, } diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.js index edf468460..59d3714ce 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptAssignHE.js @@ -36,6 +36,6 @@ ManuscriptAssignHE.propTypes = { ManuscriptAssignHE.defaultProps = { handlingEditors: [], - inviteHandlingEditor: undefined, + inviteHandlingEditor: () => {}, } export default ManuscriptAssignHE diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js index d4d024fb6..3224fd577 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js @@ -163,8 +163,8 @@ ManuscriptEicDecision.propTypes = { } ManuscriptEicDecision.defaultProps = { collection: {}, - messagesLabel: undefined, - submitDecision: undefined, + messagesLabel: {}, + submitDecision: () => {}, formValues: {}, } diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js index 4e43e59df..e4fef65e9 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptFileSection.js @@ -42,9 +42,9 @@ ManuscriptFileSection.propTypes = { ManuscriptFileSection.defaultProps = { list: [], - label: undefined, - onDownload: undefined, - onPreview: undefined, + label: '', + onDownload: () => {}, + onPreview: () => {}, } export default ManuscriptFileSection diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.js b/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.js index ca4d710b8..27165b3c1 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ResponseToInvitation.js @@ -104,8 +104,8 @@ ResponseToInvitation.propTypes = { buttonLabel: PropTypes.string, } ResponseToInvitation.defaultProps = { - label: undefined, - title: undefined, + label: '', + title: '', toggle: () => {}, expanded: false, handleSubmit: () => {}, diff --git a/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js b/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js index 3109bc5ea..310761201 100644 --- a/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js +++ b/packages/component-faraday-ui/src/submissionRevision/DetailsAndAuthors.js @@ -246,7 +246,7 @@ DetailsAndAuthors.propTypes = { ), } DetailsAndAuthors.defaultProps = { - journal: undefined, + journal: '', fragment: {}, collection: {}, onAuthorEdit: () => {}, -- GitLab