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] 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