diff --git a/app/scripts/components/common/browse-controls/constant.js b/app/scripts/components/common/browse-controls/constants.js similarity index 100% rename from app/scripts/components/common/browse-controls/constant.js rename to app/scripts/components/common/browse-controls/constants.js diff --git a/app/scripts/components/common/browse-controls/index.tsx b/app/scripts/components/common/browse-controls/index.tsx index 1f0a8a3e7..41987f01e 100644 --- a/app/scripts/components/common/browse-controls/index.tsx +++ b/app/scripts/components/common/browse-controls/index.tsx @@ -11,7 +11,7 @@ import { glsp, truncated } from '@devseed-ui/theme-provider'; import { DropMenu, DropTitle } from '@devseed-ui/dropdown'; import { useCatalogViewQS } from '../catalog/controls/hooks/use-catalog-view'; -import { optionAll } from './constant'; +import { optionAll } from './constants'; import { CatalogActions } from '$components/common/catalog/utils'; import DropdownScrollable from '$components/common/dropdown-scrollable'; diff --git a/app/scripts/components/common/browse-controls/use-browse-controls.ts b/app/scripts/components/common/browse-controls/use-browse-controls.ts index bafe00fd7..9b264f0b2 100644 --- a/app/scripts/components/common/browse-controls/use-browse-controls.ts +++ b/app/scripts/components/common/browse-controls/use-browse-controls.ts @@ -3,8 +3,5 @@ export enum Actions { CLEAR = 'clear', SEARCH = 'search', - TAXONOMY = 'taxonomy', - TAXONOMY_MULTISELECT = 'taxonomy_multiselect', - CLEAR_TAXONOMY = 'clear_taxonomy', - CLEAR_SEARCH = 'clear_search', + TAXONOMY = 'taxonomy' } diff --git a/app/scripts/components/common/card-sources.tsx b/app/scripts/components/common/card-sources.tsx index b5c68ca85..caa05489e 100644 --- a/app/scripts/components/common/card-sources.tsx +++ b/app/scripts/components/common/card-sources.tsx @@ -60,7 +60,7 @@ export function CardSourcesList(props: SourcesListProps) { e.preventDefault(); onSourceClick(source.id); }} - >a + > {source.name} diff --git a/app/scripts/components/common/catalog/catalog-content.tsx b/app/scripts/components/common/catalog/catalog-content.tsx index fae0a7883..51cadb176 100644 --- a/app/scripts/components/common/catalog/catalog-content.tsx +++ b/app/scripts/components/common/catalog/catalog-content.tsx @@ -1,7 +1,7 @@ import React, { useState, useMemo, useEffect, useCallback } from 'react'; import styled from 'styled-components'; import { DatasetData } from 'veda'; -// import { useNavigate } from 'react-router-dom'; + import { glsp, themeVal } from '@devseed-ui/theme-provider'; import TextHighlight from '../text-highlight'; import { CollecticonDatasetLayers } from '../icons/dataset-layers'; @@ -13,7 +13,7 @@ import CatalogTagsContainer from './catalog-tags'; import { CatalogActions } from './utils'; import { CardList } from '$components/common/card/styles'; import EmptyHub from '$components/common/empty-hub'; -// import { DATASETS_PATH } from '$utils/routes'; + import { getTaxonomyByIds, generateTaxonomies, @@ -53,8 +53,6 @@ function CatalogContent({ const [exclusiveSourceSelected, setExclusiveSourceSelected] = useState(null); const isSelectable = selectedIds !== undefined; - // const navigate = useNavigate(); - const datasetTaxonomies = generateTaxonomies(datasets); const urlTaxonomyItems = taxonomies ? Object.entries(taxonomies).map(([key, val]) => getTaxonomyByIds(key, val, datasetTaxonomies)).flat() : []; @@ -109,10 +107,6 @@ function CatalogContent({ useEffect(() => { if (!selectedFilters.length) { onAction(CatalogActions.CLEAR_TAXONOMY); - // @NOTE: When is this used? Is this safe to remove? - // if (!isSelectable) { - // navigate(DATASETS_PATH); - // } } setExclusiveSourceSelected(null); diff --git a/app/scripts/components/common/catalog/prepare-datasets.ts b/app/scripts/components/common/catalog/prepare-datasets.ts index a221f0894..835fc48cf 100644 --- a/app/scripts/components/common/catalog/prepare-datasets.ts +++ b/app/scripts/components/common/catalog/prepare-datasets.ts @@ -1,12 +1,12 @@ import { DatasetData, StoryData } from 'veda'; -import { optionAll } from '$components/common/browse-controls/constant'; +import { optionAll } from '$components/common/browse-controls/constants'; import { TAXONOMY_TOPICS } from '$utils/veda-data'; const isDatasetData = (data: DatasetData | StoryData): data is DatasetData => { return 'layers' in data; }; -interface OptionsType { +interface FilterOptionsType { search: string | null; taxonomies: Record | null; sortField?: string | null; @@ -14,11 +14,11 @@ interface OptionsType { filterLayers?: boolean | null; } -export function prepareDatasets(data: DatasetData[], options: OptionsType): DatasetData[]; -export function prepareDatasets(data: StoryData[], options: OptionsType): StoryData[]; +export function prepareDatasets(data: DatasetData[], options: FilterOptionsType): DatasetData[]; +export function prepareDatasets(data: StoryData[], options: FilterOptionsType): StoryData[]; export function prepareDatasets ( data: DatasetData[] | StoryData[], - options: OptionsType + options: FilterOptionsType ) { const { sortField, sortDir, search, taxonomies, filterLayers } = options; let filtered = [...data]; diff --git a/app/scripts/components/common/catalog/utils.ts b/app/scripts/components/common/catalog/utils.ts index 3a446431b..652c4a560 100644 --- a/app/scripts/components/common/catalog/utils.ts +++ b/app/scripts/components/common/catalog/utils.ts @@ -1,5 +1,5 @@ import { omit, set } from 'lodash'; -import { optionAll } from '$components/common/browse-controls/constant'; +import { optionAll } from '$components/common/browse-controls/constants'; export enum CatalogActions { TAXONOMY_MULTISELECT = 'taxonomy_multiselect', diff --git a/app/scripts/components/exploration/components/dataset-selector-modal/index.tsx b/app/scripts/components/exploration/components/dataset-selector-modal/index.tsx index 82c9b24ce..0263e0dd8 100644 --- a/app/scripts/components/exploration/components/dataset-selector-modal/index.tsx +++ b/app/scripts/components/exploration/components/dataset-selector-modal/index.tsx @@ -86,9 +86,9 @@ export function DatasetSelectorModal(props: DatasetSelectorModalProps) { const {search: searchTerm, taxonomies, onAction } = useCatalogView(); useEffect(() => { + // Reset filter when modal is hidden if(!revealed) { - onAction(CatalogActions.CLEAR_SEARCH); - onAction(CatalogActions.CLEAR_TAXONOMY); + onAction(CatalogActions.CLEAR); } },[revealed, onAction]); @@ -100,8 +100,7 @@ export function DatasetSelectorModal(props: DatasetSelectorModalProps) { setTimelineDatasets( reconcileDatasets(selectedIds, datasetLayers, timelineDatasets) ); - onAction(CatalogActions.CLEAR_SEARCH); - onAction(CatalogActions.CLEAR_TAXONOMY); + onAction(CatalogActions.CLEAR); close(); }, [close, selectedIds, timelineDatasets, setTimelineDatasets, onAction]);