Skip to content

Commit

Permalink
Create catalog-view dir and move catalog logic over
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrahoang686 committed May 13, 2024
1 parent 216650f commit 7e099b4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const optionAll = {
name: 'All'
};

export const minSearchLength = 3;

export function useBrowserControls({ sortOptions }: BrowseControlsHookParams) {
// Setup Qs State to store data in the url's query string
// react-router function to get the navigation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import styled from 'styled-components';
import { DatasetData } from 'veda';
import { useNavigate } from 'react-router-dom';
import { themeVal } from '@devseed-ui/theme-provider';
import prepareDatasets from '../../data-catalog/prepare-datasets';
import FiltersControl from './filters-control';
import FilterTag from './filter-tag';
import prepareDatasets from './prepare-datasets';
import {
Actions,
minSearchLength,
useBrowserControls
} from '$components/common/browse-controls/use-browse-controls';
import {
Expand Down Expand Up @@ -39,7 +40,7 @@ import { getAllDatasetsWithEnhancedLayers } from '$components/exploration/data-u
* Allows you to browse through datasets using the filters sidebar control
*/

const DataCatalogWrapper = styled.div`
const CatalogWrapper = styled.div`
width: 100%;
max-width: ${themeVal('layout.max')};
margin: 0 auto;
Expand All @@ -59,7 +60,7 @@ const Content = styled.div`
position: relative;
`;

const CatalogWrapper = styled.div`
const Catalog = styled.div`
width: 100%;
`;

Expand Down Expand Up @@ -92,18 +93,18 @@ const EmptyState = styled(EmptyHub)`

export const sortOptions = [{ id: 'name', name: 'Name' }];

export interface DataCatalogProps {
export interface CatalogViewProps {
datasets: DatasetData[];
cardComponentOverride?: { // Allow user to override with a different cardType with optional props
CardComponent: ComponentType<CardComponentProps>;
props: Partial<CardComponentProps>;
}
}

function DataCatalog({
function CatalogView({
datasets,
cardComponentOverride,
}: DataCatalogProps) {
}: CatalogViewProps) {
const controlVars = useBrowserControls({
sortOptions
});
Expand Down Expand Up @@ -211,15 +212,15 @@ function DataCatalog({
title={
<TextHighlight
value={search}
disabled={search.length < 3}
disabled={search.length < minSearchLength}
>
{dataset.name}
</TextHighlight>
}
description={
<TextHighlight
value={search}
disabled={search.length < 3}
disabled={search.length < minSearchLength}
>
{dataset.description}
</TextHighlight>
Expand All @@ -231,7 +232,7 @@ function DataCatalog({
};

return (
<DataCatalogWrapper>
<CatalogWrapper>
<CatalogFoldHeader
style={{
scrollMarginTop: `${headerHeight + 16}px`
Expand All @@ -250,7 +251,7 @@ function DataCatalog({
setClearedTagItem={setClearedTagItem}
allSelected={allSelectedFilters}
/>
<CatalogWrapper>
<Catalog>
{renderTags}
{datasetsToDisplay.length ? (
<Cards>
Expand All @@ -269,10 +270,10 @@ function DataCatalog({
There are no datasets to show with the selected filters.
</EmptyState>
)}
</CatalogWrapper>
</Catalog>
</Content>
</DataCatalogWrapper>
</CatalogWrapper>
);
}

export default DataCatalog;
export default CatalogView;
4 changes: 2 additions & 2 deletions app/scripts/components/data-catalog/container.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { getString } from 'veda';
import { allDatasets } from '$components/exploration/data-utils';
import DataCatalog from '$components/data-catalog';
import CatalogView from '$components/content-views/catalog-view';
import { PageMainContent } from '$styles/page';
import { LayoutProps } from '$components/common/layout-root';
import PageHero from '$components/common/page-hero';
Expand All @@ -20,7 +20,7 @@ export default function DataCatalogContainer() {
<LayoutProps title='Data Catalog' description={getString('dataCatalogBanner').other} />
<PageHero title='Data Catalog' description={getString('dataCatalogBanner').other} />
<FeaturedDatasets />
<DataCatalog datasets={allDatasets} />
<CatalogView datasets={allDatasets} />
</PageMainContent>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
allExploreDatasetsWithEnhancedLayers as allDatasets
} from '$components/exploration/data-utils';
import { generateTaxonomies } from '$utils/veda-data';
import { sortOptions } from '$components/data-catalog';
import { sortOptions } from '$components/content-views/catalog-view';

const StyledModalHeadline = styled(ModalHeadline)`
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
TaxonomyFilterOption,
useBrowserControls
} from '$components/common/browse-controls/use-browse-controls';
import { sortOptions } from '$components/data-catalog';
import { sortOptions } from '$components/content-views/catalog-view';
import prepareDatasets from '$components/data-catalog/prepare-datasets';
import { TAXONOMY_SOURCE, getTaxonomy } from '$utils/veda-data';
import { usePreviousValue } from '$utils/use-effect-previous';
Expand Down

0 comments on commit 7e099b4

Please sign in to comment.