Update page to properly display error message

This commit is contained in:
Rising Odegua
2022-01-31 13:12:14 +01:00
parent ba6f616dd6
commit 3ac0ee4653

View File

@@ -14,7 +14,7 @@ const datasetsDirectory = process.env.PORTAL_DATASET_PATH || path.join(process.c
export default function Home({ dataset, specs }) { export default function Home({ dataset, specs }) {
if (!dataset) { if (!dataset || dataset.hasError) {
return ( return (
<div className="container"> <div className="container">
<Head> <Head>
@@ -23,8 +23,10 @@ export default function Home({ dataset, specs }) {
<link rel="preconnect" href="https://fonts.gstatic.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet" />
</Head> </Head>
<h1 data-testid="datasetTitle" className="text-3xl font-bold mb-8"> <h1
No dataset found in path data-testid="datasetTitle"
className="m-10 text-center"
dangerouslySetInnerHTML={{ __html: dataset.errorMsg }}>
</h1> </h1>
</div> </div>
) )
@@ -48,11 +50,11 @@ export default function Home({ dataset, specs }) {
</Head> </Head>
<section name="key-info"> <section name="key-info">
<KeyInfo descriptor={descriptor} resources={resources} /> <KeyInfo descriptor={descriptor} resources={resources} />
</section> </section>
<section name="file-list"> <section name="file-list">
<ResourceInfo resources={resources} /> <ResourceInfo resources={resources} />
</section> </section>
@@ -85,10 +87,18 @@ export default function Home({ dataset, specs }) {
)} )}
</section> </section>
<section className="m-8" name="sample-table"> {
<h1 className="text-2xl font-bold mb-4">README</h1> dataset.readmeHtml != "" ? (
<ReadMe readme={dataset.readmeHtml} /> <section className="m-8" name="sample-table">
</section>
<h1 className="text-2xl font-bold mb-4">README</h1>
<ReadMe readme={dataset.readmeHtml} />
</section>
) : (
""
)
}
</div> </div>
) )
@@ -96,12 +106,17 @@ export default function Home({ dataset, specs }) {
export async function getStaticProps() { export async function getStaticProps() {
if (!datasetsDirectory) { const dataset = await getDataset(datasetsDirectory)
return { props: {} }
if (dataset.hasError == true) {
return {
props: {
dataset
}
}
} else {
const datasetWithViews = addView(dataset)
return datasetWithViews
} }
const dataset = await getDataset(datasetsDirectory)
const datasetWithViews = addView(dataset)
return datasetWithViews
} }