Skip to content

Commit

Permalink
Redirect to overview when explore is not allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
nerik committed Sep 21, 2023
1 parent 6e6f341 commit 94202b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/scripts/components/datasets/s-overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function DatasetsOverview() {
<PageActions>
{dataset?.data.disableExplore !== true && (
<Button
forwardedAs={Link}
forwardedAs={Link as any}
to={getDatasetExplorePath(dataset.data)}
size='large'
variation='achromic-outline'
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
8 changes: 8 additions & 0 deletions app/scripts/redirects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import React from 'react';
import { Navigate, Route, useParams } from 'react-router';

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

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

export function DatasetExploreRedirect() {
const dataset = useDataset();
return dataset?.data.disableExplore ? <DatasetsOverview /> : <DatasetsExplore />;
}

0 comments on commit 94202b2

Please sign in to comment.