From 433d27d9806ce29acdfefb05d0b33b0a1b11265e Mon Sep 17 00:00:00 2001
From: Anca Ursachi <anca.ursachi@thinslices.com>
Date: Thu, 6 Dec 2018 10:31:09 +0200
Subject: [PATCH] fix(ReviewerReportForm): ReviewerReportForm

While a reviewer write a recommendation he will see a loader instead of a button until the
recommendation update.
---
 packages/component-faraday-selectors/src/index.js              | 3 +++
 .../src/contextualBoxes/ReviewerReportForm.js                  | 3 ++-
 .../component-manuscript/src/components/ManuscriptLayout.js    | 2 ++
 packages/component-manuscript/src/components/ManuscriptPage.js | 2 ++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js
index 709e7506f..3c48b4f1a 100644
--- a/packages/component-faraday-selectors/src/index.js
+++ b/packages/component-faraday-selectors/src/index.js
@@ -557,3 +557,6 @@ export const canReview = (state, collection = {}, fragment = {}) => {
     !get(ownRecommendation[0], 'submittedOn', false)
   )
 }
+
+export const isFetchingFromAutosave = state =>
+  get(state.autosave, 'isFetching', false)
diff --git a/packages/component-faraday-ui/src/contextualBoxes/ReviewerReportForm.js b/packages/component-faraday-ui/src/contextualBoxes/ReviewerReportForm.js
index 27a9917dc..8d66da2f9 100644
--- a/packages/component-faraday-ui/src/contextualBoxes/ReviewerReportForm.js
+++ b/packages/component-faraday-ui/src/contextualBoxes/ReviewerReportForm.js
@@ -35,6 +35,7 @@ const ReviewerReportForm = ({
   review = {},
   formValues = {},
   journal: { recommendations },
+  isFetchingFromAutosave,
 }) => (
   <ContextualBox
     expanded={expanded}
@@ -148,7 +149,7 @@ const ReviewerReportForm = ({
         </Row>
       )}
       <Row justify="flex-end" mt={1}>
-        {isFetching ? (
+        {isFetching || isFetchingFromAutosave ? (
           <Spinner />
         ) : (
           <Button
diff --git a/packages/component-manuscript/src/components/ManuscriptLayout.js b/packages/component-manuscript/src/components/ManuscriptLayout.js
index 868b40830..589bf7608 100644
--- a/packages/component-manuscript/src/components/ManuscriptLayout.js
+++ b/packages/component-manuscript/src/components/ManuscriptLayout.js
@@ -58,6 +58,7 @@ const ManuscriptLayout = ({
   heResponseExpanded,
   inviteHandlingEditor,
   toggleReviewerDetails,
+  isFetchingFromAutosave,
   recommendationHandler,
   toggleReviewerResponse,
   reviewerDetailsExpanded,
@@ -163,6 +164,7 @@ const ManuscriptLayout = ({
               changeForm={changeForm}
               expanded={reviewerRecommendationExpanded}
               formValues={get(formValues, 'reviewerReport', {})}
+              isFetchingFromAutosave={isFetchingFromAutosave}
               modalKey="reviewer-report"
               project={collection}
               review={pendingOwnRecommendation}
diff --git a/packages/component-manuscript/src/components/ManuscriptPage.js b/packages/component-manuscript/src/components/ManuscriptPage.js
index 9ecbb8297..928d9077c 100644
--- a/packages/component-manuscript/src/components/ManuscriptPage.js
+++ b/packages/component-manuscript/src/components/ManuscriptPage.js
@@ -46,6 +46,7 @@ import {
   pendingHEInvitation,
   currentUserIsReviewer,
   parseCollectionDetails,
+  isFetchingFromAutosave,
   canMakeHERecommendation,
   canViewReviewersDetails,
   canViewEditorialComments,
@@ -227,6 +228,7 @@ export default compose(
         editorsFetching: selectFetching(state),
         publonsFetching: isFetching,
       },
+      isFetchingFromAutosave: isFetchingFromAutosave(state),
       formValues: {
         revision: getFormValues('revision')(state),
         eicDecision: getFormValues('eic-decision')(state),
-- 
GitLab