Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds option to hide dataset explore button #665

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions app/scripts/components/datasets/s-overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ function DatasetsOverview() {
parentTo: DATASETS_PATH,
items: allDatasetsProps,
currentId: dataset.data.id,
localMenuCmp: <DatasetsLocalMenu dataset={dataset} />
localMenuCmp:
dataset?.data.disableExplore !== true ? (
<DatasetsLocalMenu dataset={dataset} />
) : null
}}
/>

Expand All @@ -53,23 +56,25 @@ function DatasetsOverview() {
title={`${dataset.data.name} Overview`}
description={dataset.data.description}
renderBetaBlock={() => (
<PageActions>
<PageActions>
{dataset?.data.disableExplore !== true && (
<Button
forwardedAs={Link}
forwardedAs={Link as any}
to={getDatasetExplorePath(dataset.data)}
size='large'
variation='achromic-outline'
>
<CollecticonCompass />
Explore data
</Button>
<NotebookConnectButton
dataset={dataset.data}
size='large'
compact={false}
variation='achromic-outline'
/>
</PageActions>
)}
<NotebookConnectButton
dataset={dataset.data}
size='large'
compact={false}
variation='achromic-outline'
/>
</PageActions>
)}
renderDetailsBlock={() => (
<>
Expand Down
5 changes: 2 additions & 3 deletions app/scripts/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BrowserRouter, Route, Routes, useLocation } from 'react-router-dom';
import { DevseedUiThemeProvider as DsTp } from '@devseed-ui/theme-provider';
import { userPages } from 'veda';

import { discoveryRoutes, thematicRoutes } from './redirects';
import { DatasetExploreRedirect, discoveryRoutes, thematicRoutes } from './redirects';

import theme, { GlobalStyles } from '$styles/theme';
import { getAppURL } from '$utils/history';
Expand All @@ -28,7 +28,6 @@ const StoriesHub = lazy(() => import('$components/stories/hub'));
const StoriesSingle = lazy(() => import('$components/stories/single'));

const DataCatalog = lazy(() => import('$components/data-catalog'));
const DatasetsExplore = lazy(() => import('$components/datasets/s-explore'));
const DatasetsOverview = lazy(() => import('$components/datasets/s-overview'));

const Analysis = lazy(() => import('$components/analysis/define'));
Expand Down Expand Up @@ -95,7 +94,7 @@ function Root() {
/>
<Route
path={`${DATASETS_PATH}/:datasetId/explore`}
element={<DatasetsExplore />}
element={<DatasetExploreRedirect />}
/>
<Route path={STORIES_PATH} element={<StoriesHub />} />
<Route
Expand Down
14 changes: 13 additions & 1 deletion app/scripts/redirects.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import { Navigate, Route, useParams } from 'react-router';

import { STORIES_PATH } from '$utils/routes';
import { DATASETS_PATH, STORIES_PATH } from '$utils/routes';
import { useDataset } from '$utils/veda-data';
import DatasetsExplore from '$components/datasets/s-explore';

function DiscoveryRedirect() {
const { discoveryId } = useParams();
Expand Down Expand Up @@ -52,3 +54,13 @@ export const discoveryRoutes = (
<Route path='discoveries/:discoveryId' element={<DiscoveryRedirect />} />
</Route>
);

export function DatasetExploreRedirect() {
const dataset = useDataset();
const url = `${DATASETS_PATH}/${dataset?.data.id}`;
return dataset?.data.disableExplore ? (
<Navigate replace to={url} />
) : (
<DatasetsExplore />
);
}
6 changes: 6 additions & 0 deletions docs/content/CONTENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ media: Media
thematics: string[]
sources: string[]
featured: boolean
disableExplore: boolean

layers: Layer[]
related: Related[]
Expand Down Expand Up @@ -109,6 +110,11 @@ taxonomy:
Whether this dataset is featured
![](./media/fm-featured-dataset.png)

**disableExplore**
`boolean`
When set to true, the 'explore data' section won't be available for this dataset.


**layers**
`Layer[]`
List of layers for this dataset. See [layer.md](./frontmatter/layer.md).
Expand Down
1 change: 1 addition & 0 deletions parcel-resolver-veda/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ declare module 'veda' {
media?: Media;
layers: DatasetLayer[];
related?: RelatedContentData[];
disableExplore?: boolean;
}

// ///////////////////////////////////////////////////////////////////////////
Expand Down
Loading