Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put a hot fix for URL search paramter *WIP* #1020

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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'
10 changes: 8 additions & 2 deletions app/scripts/components/common/catalog/catalog-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ function CatalogContent({

useEffect(() => {
if (!selectedFilters.length) {
onAction(CatalogActions.CLEAR);

onAction(CatalogActions.CLEAR_TAXONOMY);
if (!isSelectable) {
navigate(DATASETS_PATH);
}
Expand All @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions app/scripts/components/common/catalog/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand All @@ -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({});
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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<string[]>(
Expand Down