Skip to content

Commit

Permalink
Reflect review
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Jun 28, 2024
1 parent b3f0b59 commit 2785f5b
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/scripts/components/common/browse-controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
2 changes: 1 addition & 1 deletion app/scripts/components/common/card-sources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function CardSourcesList(props: SourcesListProps) {
e.preventDefault();
onSourceClick(source.id);
}}
><span>a</span>
>
{source.name}
</Link>
</li>
Expand Down
10 changes: 2 additions & 8 deletions app/scripts/components/common/catalog/catalog-content.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -53,8 +53,6 @@ function CatalogContent({
const [exclusiveSourceSelected, setExclusiveSourceSelected] = useState<string | null>(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() : [];

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions app/scripts/components/common/catalog/prepare-datasets.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
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<string, string | string[]> | null;
sortField?: string | null;
sortDir?: string | null;
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];
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/common/catalog/utils.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand All @@ -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]);

Expand Down

0 comments on commit 2785f5b

Please sign in to comment.