Update page to properly display error message
This commit is contained in:
@@ -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>
|
||||||
)
|
)
|
||||||
@@ -85,10 +87,18 @@ export default function Home({ dataset, specs }) {
|
|||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
{
|
||||||
|
dataset.readmeHtml != "" ? (
|
||||||
<section className="m-8" name="sample-table">
|
<section className="m-8" name="sample-table">
|
||||||
|
|
||||||
<h1 className="text-2xl font-bold mb-4">README</h1>
|
<h1 className="text-2xl font-bold mb-4">README</h1>
|
||||||
<ReadMe readme={dataset.readmeHtml} />
|
<ReadMe readme={dataset.readmeHtml} />
|
||||||
</section>
|
</section>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -96,12 +106,17 @@ export default function Home({ dataset, specs }) {
|
|||||||
|
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
if (!datasetsDirectory) {
|
|
||||||
return { props: {} }
|
|
||||||
}
|
|
||||||
|
|
||||||
const dataset = await getDataset(datasetsDirectory)
|
const dataset = await getDataset(datasetsDirectory)
|
||||||
|
|
||||||
|
if (dataset.hasError == true) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
dataset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
const datasetWithViews = addView(dataset)
|
const datasetWithViews = addView(dataset)
|
||||||
return datasetWithViews
|
return datasetWithViews
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user