Skip to content

Commit

Permalink
DCAT-9: As a user, I want to be able to filter all Near Real-Time dat…
Browse files Browse the repository at this point in the history
…asets with a Near Real-Time filter (#3)

* DCAT-9: Add latency to interface
  • Loading branch information
eudoroolivares2016 authored Jan 17, 2025
1 parent 5bfb389 commit 48688d8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ts/component/AppliedFilters/AppliedFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface AppliedFiltersProps {
page_num?: number
page_size?: number
processing_level_id_h?: string[]
latency?: string[]
science_keywords_h?: string[]
sort_key?: string
temporal?: string[] | string
Expand Down Expand Up @@ -133,6 +134,7 @@ export const AppliedFilters: React.FC<AppliedFiltersProps> = ({
'platforms_h',
'horizontal_data_resolution_range',
'granule_data_format_h',
'latency',
'processing_level_id_h',
'page_num'
]))
Expand Down
16 changes: 15 additions & 1 deletion src/ts/component/SearchFilters/SearchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const namesToParams: { [key: string]: string } = {
Platforms: 'platforms_h',
'Horizontal Data Resolution': 'horizontal_data_resolution_range',
'Data Format': 'granule_data_format_h',
'Processing Levels': 'processing_level_id'
'Processing Levels': 'processing_level_id',
Latency: 'latency'
}

const SearchFilters: React.FC<SearchFiltersProps> = ({
Expand Down Expand Up @@ -99,6 +100,7 @@ const SearchFilters: React.FC<SearchFiltersProps> = ({
</SearchFilterSection>
)
}

<SearchFilterSection title="Temporal" eventKey="4" setSidebarOpened={setSidebarOpened}>
<Accordion alwaysOpen className="hzn-filters__accordion_sub" defaultActiveKey={['4.0', '4.1']}>
<Accordion.Item eventKey="4.0">
Expand Down Expand Up @@ -197,6 +199,18 @@ const SearchFilters: React.FC<SearchFiltersProps> = ({
</SearchFilterSection>
)
}
{
getFacets('Latency').length > 0 && (
<SearchFilterSection title="Latency" eventKey="8" setSidebarOpened={setSidebarOpened}>
<FacetChecklist
name="Latency"
facets={getFacets('Latency')}
param={namesToParams.Latency}
onChange={onChange}
/>
</SearchFilterSection>
)
}
{ /* Accordion.Item "Center" (No equivalent CMR field/facet. Requested CMR-9874) */ }
{ /* Accordion.Item "Date" (No equivalent. Probably won't do.) */ }
</SearchFilterSectionList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ describe('DataCatalog SearchFilters component and facets', () => {

expect(screen.getByText('Data Processing Level')).toBeInTheDocument()
expect(screen.getByLabelText('Proc0 (10)')).toBeInTheDocument()

expect(screen.getByText('Latency')).toBeInTheDocument()
expect(screen.getByLabelText('Late0 (10)')).toBeInTheDocument()
})

test('populates filters with applied values', () => {
Expand Down Expand Up @@ -131,6 +134,7 @@ describe('DataCatalog SearchFilters component and facets', () => {
expect(screen.queryByText('Observation Method')).not.toBeInTheDocument()
expect(screen.queryByText('Data Format')).not.toBeInTheDocument()
expect(screen.queryByText('Data Processing Level')).not.toBeInTheDocument()
expect(screen.queryByText('Latency')).not.toBeInTheDocument()

// Check that the Temporal and Spatial sections are still rendered
// as they don't depend on facets
Expand Down
4 changes: 4 additions & 0 deletions src/ts/pages/DataCatalog/__tests__/DataCatalog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ const setup = ({ params }: { params?: string } = {}) => {
describe('DataCatalog', () => {
beforeEach(() => nock.cleanAll())

afterEach(() => {
vi.clearAllMocks()
})

test('request new collections upon form submission', async () => {
const { user } = setup({})

Expand Down
1 change: 1 addition & 0 deletions src/ts/utils/queryFacetedCollections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const validParameters = [
'page_num',
'page_size',
'platforms_h',
'latency',
'processing_level_id_h',
'science_keywords_h',
'sort_key',
Expand Down
1 change: 1 addition & 0 deletions src/ts/utils/stringifyCollectionsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import facetDefaultParams from '../constants/facetDefaultParams'
interface Params {
bounding_box?: string
processing_level_id_h?: string[]
latency?: string[]
science_keywords_h?: string[]
temporal?: string[] | string
keyword?: string
Expand Down

0 comments on commit 48688d8

Please sign in to comment.