Skip to content

Commit

Permalink
refact(discovery): clear dataset selection
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rocheleau committed Sep 12, 2024
1 parent 4a8ea8e commit 86789b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/js/components/Scope/DatasetScopePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { List, Avatar, Space, Typography } from 'antd';
import { useTranslationCustom, useTranslationDefault } from '@/hooks';
import { useAppSelector, useTranslationCustom, useTranslationDefault } from '@/hooks';
import { Link, useLocation } from 'react-router-dom';
import { FaDatabase } from 'react-icons/fa';
import { getCurrentPage } from '@/utils/router';
Expand All @@ -16,27 +16,31 @@ const DatasetScopePicker = ({ parentProject, isSingleProject }: DatasetScopePick
const location = useLocation();
const baseURL = '/' + location.pathname.split('/')[1];
const page = getCurrentPage();

const selectedScope = useAppSelector((state) => state.metadata.selectedScope);
return (
<Space direction="vertical" style={{ display: 'flex' }}>
<Space align="baseline" size="large">
<Typography.Title level={4} className="no-margin-top">
{td('Project')}: {t(parentProject.title)}
</Typography.Title>
{isSingleProject ? (
// give clear scope option in single project mode
<Link to={baseURL}>
<Typography.Link>{td('Clear')}</Typography.Link>
</Link>
) : (
{!isSingleProject && (
<Link to={`${baseURL}/p/${parentProject.identifier}/${page}`} key="3">
<Typography.Link>{td('Select')}</Typography.Link>
</Link>
)}
</Space>
<Typography.Text>{t(parentProject.description)}</Typography.Text>
<Typography.Title level={5} className="no-margin-top">
{td('Datasets')}
</Typography.Title>
<Space align="baseline" size="large">
<Typography.Title level={5} className="no-margin-top">
{td('Datasets')}
</Typography.Title>
{selectedScope?.dataset && (
<Link to={`${baseURL}/p/${parentProject.identifier}/${page}`} >
<Typography.Link>{td('Clear selection')}</Typography.Link>
</Link>
)}
</Space>
<List
dataSource={parentProject.datasets}
bordered
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/SiteHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { scopeToUrl } from '@/utils/router';
import { DEFAULT_TRANSLATION, LNG_CHANGE, LNGS_FULL_NAMES } from '@/constants/configConstants';
import { CLIENT_NAME, PORTAL_URL, TRANSLATED } from '@/config';

import { ScopePickerModal } from './Scope/ScopePickerModal';
import ScopePickerModal from './Scope/ScopePickerModal';

const { Header } = Layout;

Expand Down

0 comments on commit 86789b2

Please sign in to comment.