From 9d1b6637c8484b6f6b295e3c21d1a6293f6bfcc8 Mon Sep 17 00:00:00 2001 From: ekachxaidze98 Date: Mon, 9 Sep 2024 17:29:35 +0400 Subject: [PATCH] CORE-4990: add error view --- .../[data-provider-id]/deduplication.jsx | 1 + .../[data-provider-id]/indexing.jsx | 1 + store/issues.js | 16 +++++-- .../deduplication/cards/deduplicationInfo.jsx | 22 +++++++--- templates/deduplication/index.jsx | 7 ++- templates/deduplication/styles.module.css | 14 ++++++ .../harvesting/cards/harvesting-progress.jsx | 44 ++++++++++++++----- .../cards/harvesting-status-card.jsx | 15 ++++++- templates/harvesting/index.jsx | 3 ++ templates/harvesting/styles.module.css | 15 +++++++ 10 files changed, 115 insertions(+), 23 deletions(-) diff --git a/pages/data-providers/[data-provider-id]/deduplication.jsx b/pages/data-providers/[data-provider-id]/deduplication.jsx index d7fc9606..fd23fa40 100644 --- a/pages/data-providers/[data-provider-id]/deduplication.jsx +++ b/pages/data-providers/[data-provider-id]/deduplication.jsx @@ -9,6 +9,7 @@ const DeduplicationPage = ({ store, ...props }) => ( getDeduplicationData={store.dataProvider?.getDeduplicationData} duplicateDataLoading={store.dataProvider?.duplicateDataLoading} harvestingStatus={store.dataProvider?.issues?.harvestingStatus} + harvestingError={store.dataProvider?.issues?.harvestingError} duplicateList={store.dataProvider?.duplicateList} getDeduplicationInfo={store.dataProvider?.getDeduplicationInfo} duplicateListDetails={store.dataProvider?.duplicateListDetails} diff --git a/pages/data-providers/[data-provider-id]/indexing.jsx b/pages/data-providers/[data-provider-id]/indexing.jsx index 89d04396..c58e1ed7 100644 --- a/pages/data-providers/[data-provider-id]/indexing.jsx +++ b/pages/data-providers/[data-provider-id]/indexing.jsx @@ -6,6 +6,7 @@ import { withGlobalStore } from 'store' const HarvestingPage = ({ store, store: { dataProvider }, ...props }) => ( ( +const DeduplicationInfoCard = ({ harvestingStatus, harvestingError }) => ( (
- - {valueOrDefault( - formatDate(harvestingStatus?.lastHarvestingDate), - 'Loading...' - )} - + {harvestingError ? ( +
+ riox +

This data is not available now.

+
+ ) : ( + + {valueOrDefault( + formatDate(harvestingStatus?.lastHarvestingDate), + 'Loading...' + )} + + )}
{texts.info.description} diff --git a/templates/deduplication/index.jsx b/templates/deduplication/index.jsx index f3ec6759..5518aa45 100644 --- a/templates/deduplication/index.jsx +++ b/templates/deduplication/index.jsx @@ -1,3 +1,4 @@ +// templates/deduplication/index.jsx import React, { useEffect, useState } from 'react' import { classNames } from '@oacore/design/lib/utils' import { useRouter } from 'next/router' @@ -20,6 +21,7 @@ const DeduplicationPageTemplate = observer( getDeduplicationInfo, duplicateListDetails, harvestingStatus, + harvestingError, getOutputsData, outputData, getWorksData, @@ -85,7 +87,10 @@ const DeduplicationPageTemplate = observer( } />
- + { + ({ harvestingStatus, sendHarvestingRequest, harvestingError }) => { const { ...globalStore } = useContext(GlobalContext) const [loading, setLoading] = useState(false) const [success, setSuccess] = useState(false) const [modalOpen, setModalOpen] = useState(false) const [errorMessage, setErrorMessage] = useState(null) + const [renderedContent, setRenderedContent] = useState(null) + const dayInterval = (lastHarvestingDateString) => { const lastHarvestingDate = new Date(lastHarvestingDateString) const currentDate = new Date() @@ -105,6 +108,32 @@ const HarvestingProgressCard = observer( } } + const getContent = () => { + if (harvestingError) { + return ( +
+ riox +

+ Request reindexing is not available at the moment. +

+
+ ) + } + if (!harvestingStatus) { + return ( +
+ +

Loading...

+
+ ) + } + return
{renderView()}
+ } + + useEffect(() => { + setRenderedContent(getContent()) + }, [harvestingError, harvestingStatus]) + return (
{modalOpen && harvestingStatus?.scheduledState === 'IN_DOWNLOAD_METADATA_QUEUE' && - !result( + !result && ( {texts.progress.description}
- {!harvestingStatus ? ( -
- -

Loading

-
- ) : ( -
{renderView()}
- )} + {renderedContent}
) } diff --git a/templates/harvesting/cards/harvesting-status-card.jsx b/templates/harvesting/cards/harvesting-status-card.jsx index 84f9ebd7..859a096f 100644 --- a/templates/harvesting/cards/harvesting-status-card.jsx +++ b/templates/harvesting/cards/harvesting-status-card.jsx @@ -1,6 +1,7 @@ import React from 'react' import styles from '../styles.module.css' +import info from '../../../components/upload/assets/info.svg' import { Card } from 'design' import { valueOrDefault, formatDate, patchValueFull } from 'utils/helpers' @@ -15,13 +16,25 @@ const HarvestingStatusCard = ({ lastHarvestingDate, metadataCount, total, + harvestingError, }) => ( {texts.genInfo.title}
+ riox +

+ This data is not available now.{' '} +

+
+ ) : ( + valueOrDefault(formatDate(lastHarvestingDate), 'Loading...') + ) + } title="Last successful updating" tag="div" bold diff --git a/templates/harvesting/index.jsx b/templates/harvesting/index.jsx index 9099d739..b3912298 100644 --- a/templates/harvesting/index.jsx +++ b/templates/harvesting/index.jsx @@ -32,6 +32,7 @@ const HarvestingPageTemplate = observer( issues, typesCount, responseData, + harvestingError, ...restProps }) => { const { ...globalStore } = useContext(GlobalContext) @@ -60,6 +61,7 @@ const HarvestingPageTemplate = observer( )}
diff --git a/templates/harvesting/styles.module.css b/templates/harvesting/styles.module.css index 26ce5404..dbe5b330 100644 --- a/templates/harvesting/styles.module.css +++ b/templates/harvesting/styles.module.css @@ -24,6 +24,21 @@ width: 50%; } +.errors-wrapper { + background: #f5f5f5; + display: flex; + height: 48px; + padding: 12px 16px; + align-items: center; + gap: 10px; + width: 100%; + font-size: 14px; +} + +.error-text { + margin-top: unset; +} + .chart { max-width: 12.5rem; background-color: var(--white);