From 29b5a5798a89009527fdc19f4f860117f4b0bffe Mon Sep 17 00:00:00 2001 From: Louise Wang Date: Tue, 29 Mar 2022 11:28:28 +0200 Subject: [PATCH] fix: add refresh button --- .../item/sharing/ItemPublishConfiguration.js | 26 +++++++++++++------ src/config/constants.js | 6 +++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/components/item/sharing/ItemPublishConfiguration.js b/src/components/item/sharing/ItemPublishConfiguration.js index 54244752d..7c6528e56 100644 --- a/src/components/item/sharing/ItemPublishConfiguration.js +++ b/src/components/item/sharing/ItemPublishConfiguration.js @@ -12,12 +12,13 @@ import CheckCircleIcon from '@material-ui/icons/CheckCircle'; import CancelIcon from '@material-ui/icons/Cancel'; import UpdateIcon from '@material-ui/icons/Update'; import { MUTATION_KEYS } from '@graasp/query-client'; -import { useMutation, hooks } from '../../../config/queryClient'; +import { useMutation, hooks, queryClient } from '../../../config/queryClient'; import CategorySelection from './CategorySelection'; import CustomizedTagsEdit from './CustomizedTagsEdit'; import CCLicenseSelection from './CCLicenseSelection'; import { ADMIN_CONTACT, + buildItemValidationAndReviewsKey, ITEM_VALIDATION_REVIEW_STATUSES, ITEM_VALIDATION_STATUSES, SETTINGS, @@ -57,6 +58,7 @@ const useStyles = makeStyles((theme) => ({ marginTop: theme.spacing(1), width: 'auto', minWidth: SUBMIT_BUTTON_WIDTH, + marginRight: theme.spacing(2), }, })); @@ -159,13 +161,10 @@ const ItemPublishConfiguration = ({ itemValidationStatus === ITEM_VALIDATION_STATUSES.FAILURE ) validateItem({ itemId }); + }; - // force to reload the page - // TODO: any better method to reload this component only? - setTimeout(() => { - // eslint-disable-next-line no-restricted-globals - location.reload(); - }, 3000); + const handleRefresh = () => { + queryClient.invalidateQueries(buildItemValidationAndReviewsKey(itemId)); }; const publishItem = () => { @@ -252,7 +251,9 @@ const ItemPublishConfiguration = ({ {t('Validation')} - {t('You need to validate your item before publish it.')} + {t( + 'You need to validate your item before publish it. Please allow some time for the validation to finish.', + )} + {displayItemValidationMessage()} diff --git a/src/config/constants.js b/src/config/constants.js index f43baeed0..b1e15b41c 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -210,3 +210,9 @@ export const ITEM_VALIDATION_REVIEW_STATUSES = { }; export const ADMIN_CONTACT = 'admin@graasp.org'; + +export const buildItemValidationAndReviewsKey = (id) => [ + 'items', + id, + 'itemValidationAndReviews', +];