From 6bd36ac79bf08692b528f994a04dae326b93788f Mon Sep 17 00:00:00 2001 From: Hanbyul Jo Date: Tue, 25 Jun 2024 17:20:35 -0400 Subject: [PATCH 1/2] Put the hot fix for URL search paramter *WIP* --- .../components/common/catalog/catalog-content.tsx | 10 ++++++++-- app/scripts/components/common/catalog/utils.ts | 10 ++++++++++ .../components/dataset-selector-modal/index.tsx | 9 +++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/scripts/components/common/catalog/catalog-content.tsx b/app/scripts/components/common/catalog/catalog-content.tsx index 93cff42d6..3b90c692f 100644 --- a/app/scripts/components/common/catalog/catalog-content.tsx +++ b/app/scripts/components/common/catalog/catalog-content.tsx @@ -108,8 +108,7 @@ function CatalogContent({ useEffect(() => { if (!selectedFilters.length) { - onAction(CatalogActions.CLEAR); - + onAction(CatalogActions.CLEAR_TAXONOMY); if (!isSelectable) { navigate(DATASETS_PATH); } @@ -119,6 +118,13 @@ function CatalogContent({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedFilters]); + // Trigger URL parameter set up first initialized without any search paramter + useEffect(() => { + if (!search) { + onAction(CatalogActions.CLEAR_SEARCH); + } + }, [search, onAction]); + const getSelectedIdsWithParentData = (selectedIds) => { return selectedIds.map((selectedId: string) => { const parentData = findParentDataset(selectedId); diff --git a/app/scripts/components/common/catalog/utils.ts b/app/scripts/components/common/catalog/utils.ts index 15ed625bb..78c5e188c 100644 --- a/app/scripts/components/common/catalog/utils.ts +++ b/app/scripts/components/common/catalog/utils.ts @@ -2,6 +2,8 @@ import { omit, set } from 'lodash'; export enum CatalogActions { CLEAR = 'clear', + CLEAR_TAXONOMY = 'clear_taxonomy', + CLEAR_SEARCH = 'clear_search', SEARCH = 'search', TAXONOMY_MULTISELECT = 'taxonomy_multiselect' } @@ -16,6 +18,14 @@ export function onCatalogAction( setTaxonomies: (value: any) => void ) { switch (action) { + case CatalogActions.CLEAR_TAXONOMY: { + setTaxonomies({}); + break; + } + case CatalogActions.CLEAR_SEARCH: { + setSearch(''); + break; + } case CatalogActions.CLEAR: { setSearch(''); setTaxonomies({}); 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 1d4651073..0b95455ea 100644 --- a/app/scripts/components/exploration/components/dataset-selector-modal/index.tsx +++ b/app/scripts/components/exploration/components/dataset-selector-modal/index.tsx @@ -1,4 +1,6 @@ import React, { useCallback, useEffect, useState } from 'react'; +import { useSearchParams } from 'react-router-dom'; + import styled from 'styled-components'; import { useAtom } from 'jotai'; @@ -77,8 +79,11 @@ export function DatasetSelectorModal(props: DatasetSelectorModalProps) { const { revealed, close } = props; const [timelineDatasets, setTimelineDatasets] = useAtom(timelineDatasetsAtom); - - const [searchTerm, setSearchTerm] = useState(''); + // Use the search url paramter for the initial value + const [searchParams] = useSearchParams(); + const search = searchParams.get('search'); + + const [searchTerm, setSearchTerm] = useState(search?? ''); const [taxonomies, setTaxonomies] = useState({}); // Store a list of selected datasets and only confirm on save. const [selectedIds, setSelectedIds] = useState( From 47e77de04704ed6fe8e4d3edfc14a151fee4210b Mon Sep 17 00:00:00 2001 From: Hanbyul Jo Date: Tue, 25 Jun 2024 17:39:20 -0400 Subject: [PATCH 2/2] Turn on new E&A for debugging --- .env | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.env b/.env index 9b9f3f8a0..31d08b58e 100644 --- a/.env +++ b/.env @@ -11,3 +11,5 @@ API_STAC_ENDPOINT='https://staging-stac.delta-backend.com' # Google form for feedback GOOGLE_FORM = 'https://docs.google.com/forms/d/e/1FAIpQLSfGcd3FDsM3kQIOVKjzdPn4f88hX8RZ4Qef7qBsTtDqxjTSkg/viewform?embedded=true' + +FEATURE_NEW_EXPLORATION = 'TRUE'