diff --git a/app/components/hint.tsx b/app/components/hint.tsx index 7004bf24a..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 = () => ( ( ); -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-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 ( 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..16696caef 100644 --- a/app/configurator/components/select-dataset-step.tsx +++ b/app/configurator/components/select-dataset-step.tsx @@ -4,7 +4,6 @@ import { Router, useRouter } from "next/router"; import React, { useMemo } from "react"; import { Box, Button, Text } from "theme-ui"; import { useDebounce } from "use-debounce"; -import { DataSetHint } from "../../components/hint"; import { useDataCubesQuery } from "../../graphql/query-hooks"; import { useConfiguratorState, useLocale } from "../../src"; import { @@ -157,15 +156,11 @@ export const SelectDatasetStepContent = () => { )} - {dataset || !data ? ( + {dataset ? ( <> - {dataset ? ( - - - - ) : ( - - )} + + + ) : (