From 74c2bc6795bb3904847241cf004d26e58303d2ff Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Tue, 1 Feb 2022 16:47:02 +0100 Subject: [PATCH 1/3] feat: Do not show spinner in browsing left panel while loading dataset Already one spinner in the middle --- app/configurator/components/dataset-metadata.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/configurator/components/dataset-metadata.tsx b/app/configurator/components/dataset-metadata.tsx index 39536280b..ca871a799 100644 --- a/app/configurator/components/dataset-metadata.tsx +++ b/app/configurator/components/dataset-metadata.tsx @@ -2,7 +2,6 @@ import { Trans } from "@lingui/macro"; import NextLink from "next/link"; import React, { ReactNode } from "react"; import { Box, BoxProps, Link } from "theme-ui"; -import { Loading } from "../../components/hint"; import Stack from "../../components/Stack"; import { useFormatDate } from "../../configurator/components/ui-helpers"; import { @@ -19,12 +18,14 @@ export const DataSetMetadata = ({ }: { dataSetIri: string } & BoxProps) => { const locale = useLocale(); const formatDate = useFormatDate(); - const [{ data }] = useDataCubeMetadataQuery({ + const [{ data, fetching, error }] = useDataCubeMetadataQuery({ variables: { iri: dataSetIri, locale }, }); const cube = data?.dataCubeByIri; - if (!cube) { - return ; + if (fetching || error || !cube) { + // The error and loading are managed by the component + // displayed in the middle panel + return null; } return ( From fcbda352b8d125ba33a4e840107b8f49a0b13d1c Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Tue, 1 Feb 2022 16:47:02 +0100 Subject: [PATCH 2/3] feat: Handle dataset loading error --- app/components/hint.tsx | 19 +++++++++++++------ .../components/dataset-preview.tsx | 19 ++++++++++++++++--- .../components/select-dataset-step.tsx | 12 ++++-------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/app/components/hint.tsx b/app/components/hint.tsx index 7004bf24a..3f7dcb5f7 100644 --- a/app/components/hint.tsx +++ b/app/components/hint.tsx @@ -151,7 +151,7 @@ export const NoDataHint = () => ( ); -export const LoadingDataError = () => ( +export const LoadingDataError = ({ message }: { message?: string }) => ( ( Data loading error - - - The data could not be loaded. - - + * + *:not([data-no-margin])": { marginTop: 2 } }}> + + + The data could not be loaded. + + + {message ? ( + + {message} + + ) : null} + ); diff --git a/app/configurator/components/dataset-preview.tsx b/app/configurator/components/dataset-preview.tsx index 2c627b0ee..afa22cd85 100644 --- a/app/configurator/components/dataset-preview.tsx +++ b/app/configurator/components/dataset-preview.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { Box, Text, Flex } from "theme-ui"; -import { HintRed, Loading } from "../../components/hint"; +import { HintRed, Loading, LoadingDataError } from "../../components/hint"; import { DataSetPreviewTable } from "./datatable"; import { Trans } from "@lingui/macro"; import { useDataCubePreviewQuery } from "../../graphql/query-hooks"; @@ -15,7 +15,7 @@ export interface Preview { } export const DataSetPreview = ({ dataSetIri }: { dataSetIri: string }) => { const locale = useLocale(); - const [{ data: metaData }] = useDataCubePreviewQuery({ + const [{ data: metaData, fetching, error }] = useDataCubePreviewQuery({ variables: { iri: dataSetIri, locale }, }); @@ -108,7 +108,7 @@ export const DataSetPreview = ({ dataSetIri }: { dataSetIri: string }) => { ); - } else { + } else if (fetching) { return ( { ); + } else { + return ( + + + + ); } }; diff --git a/app/configurator/components/select-dataset-step.tsx b/app/configurator/components/select-dataset-step.tsx index 44e0855b8..e6ee6f622 100644 --- a/app/configurator/components/select-dataset-step.tsx +++ b/app/configurator/components/select-dataset-step.tsx @@ -157,15 +157,11 @@ export const SelectDatasetStepContent = () => { )} - {dataset || !data ? ( + {dataset ? ( <> - {dataset ? ( - - - - ) : ( - - )} + + + ) : ( From 1c74258322dc4025368f3b6afe4cf42ed2947a23 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Tue, 1 Feb 2022 16:58:28 +0100 Subject: [PATCH 3/3] refactor: Remove unused component --- app/components/hint.tsx | 26 ------------------- .../components/select-dataset-step.tsx | 1 - 2 files changed, 27 deletions(-) diff --git a/app/components/hint.tsx b/app/components/hint.tsx index 3f7dcb5f7..2fc17a10f 100644 --- a/app/components/hint.tsx +++ b/app/components/hint.tsx @@ -98,32 +98,6 @@ export const LoadingOverlay = () => ( ); -export const DataSetHint = () => ( - - - - Select a dataset - - - - Click on a dataset in the left column to preview its structure and - content. - - - -); export const NoDataHint = () => (