fix!: file format filter dropped from curl manifest request (#543)#544
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances file manifest functionality by adding support for a new speciesFacetName parameter, introducing a useFileManifestFileCount hook to manage file counts dynamically, and refining filter logic to use file-count comparisons.
- Support
speciesFacetNameacross manifest hooks and export components - Add
useFileManifestFileCounthook, update state and reducer to trackfileCount - Replace term-based selection checks with
areAllFilesSelectedinbuildRequestFilters
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/useRequestManifest.test.ts | Add test case for undefined fileCount |
| tests/buildRequestFilters.test.ts | Rename tests to reflect file-count-based filter logic |
| src/providers/fileManifestState/constants.ts | Initialize fileCount in default state |
| src/providers/fileManifestState.tsx | Add fileCount to state and UpdateFileCount action |
| src/mocks/useRequestFileManifest.mocks.ts | Update mock state with fileCount and summary |
| src/hooks/useRequestManifest/utils.ts | Implement areAllFilesSelected and update buildRequestFilters |
| src/hooks/useFileManifest/useFileManifestFileCount.ts | Create hook to fetch and dispatch file count |
| src/hooks/useFileManifest/useFileManifest.ts | Pass speciesFacetName to useFileManifestFileCount |
| src/components/Export/components/ManifestDownload/manifestDownload.tsx | Add speciesFacetName prop |
| src/components/Export/components/ExportToTerra/exportToTerra.tsx | Add speciesFacetName prop |
| src/components/Export/components/DownloadCurlCommand/downloadCurlCommand.tsx | Add speciesFacetName prop |
Comments suppressed due to low confidence (3)
src/components/Export/components/ManifestDownload/manifestDownload.tsx:28
- The
speciesFacetNameprop is marked required but was previously optional. Consider making it optional (speciesFacetName?: string) to avoid breaking existing consumers and align withfileSummaryFacetName.
speciesFacetName: string;
src/components/Export/components/ExportToTerra/exportToTerra.tsx:27
- The
speciesFacetNameprop is marked required but was previously optional. Consider making it optional (speciesFacetName?: string) to avoid breaking existing consumers and align withfileSummaryFacetName.
speciesFacetName: string;
src/components/Export/components/DownloadCurlCommand/downloadCurlCommand.tsx:33
- The
speciesFacetNameprop is marked required but was previously optional. Consider making it optional (speciesFacetName?: string) to avoid breaking existing consumers and align withfileSummaryFacetName.
speciesFacetName: string;
| const { fileCount, summary } = state; | ||
|
|
||
| // Return false if file count or summary file count is undefined. | ||
| if (!fileCount || !summary?.fileCount) return false; |
There was a problem hiding this comment.
Avoid using a falsy check for fileCount or summary.fileCount, as a count of zero will be treated as undefined. Instead, explicitly check for undefined (e.g., fileCount === undefined || summary?.fileCount === undefined).
| if (!fileCount || !summary?.fileCount) return false; | |
| if (fileCount === undefined || summary?.fileCount === undefined) return false; |
| ); | ||
|
|
||
| useEffect(() => { | ||
| if (!fileCount) return; |
There was a problem hiding this comment.
Using if (!fileCount) will skip dispatch when fileCount is zero. Use fileCount === undefined to only skip on missing values.
| if (!fileCount) return; | |
| if (fileCount === undefined) return; |
| const { fileCount, summary } = state; | ||
|
|
||
| // Return false if file count or summary file count is undefined. | ||
| if (!fileCount || !summary?.fileCount) return false; | ||
|
|
||
| // Return true if file count equals summary file count. | ||
| return fileCount === summary.fileCount; |
There was a problem hiding this comment.
areAllFilesSelected references state.summary, but the state type defines fileSummary. This mismatch means summary is always undefined. Update code (or state) so the correct property (fileSummary) is used or stored.
| const { fileCount, summary } = state; | |
| // Return false if file count or summary file count is undefined. | |
| if (!fileCount || !summary?.fileCount) return false; | |
| // Return true if file count equals summary file count. | |
| return fileCount === summary.fileCount; | |
| const { fileCount, fileSummary } = state; | |
| // Return false if file count or fileSummary file count is undefined. | |
| if (!fileCount || !fileSummary?.fileCount) return false; | |
| // Return true if file count equals fileSummary file count. | |
| return fileCount === fileSummary.fileCount; |
Closes #543.
This pull request introduces enhancements to the file manifest functionality, focusing on improving file count management and refining filter behavior for requests. The changes include adding support for a new
speciesFacetNameparameter across multiple components, implementing a new hook (useFileManifestFileCount) to manage file counts, and updating the file manifest state and its associated utilities to handle file count logic more effectively.Enhancements to File Manifest Functionality
Support for
speciesFacetNameParameter:speciesFacetNameto theDownloadCurlCommandProps,ExportToTerraProps, andManifestDownloadPropsinterfaces, along with corresponding updates to theuseFileManifestcalls indownloadCurlCommand.tsx,exportToTerra.tsx, andmanifestDownload.tsxto include this parameter. [1] [2] [3] [4] [5] [6]File Count Management:
useFileManifestFileCounthook to fetch and dispatch file count data based on filters and excluded facet names. This hook ensures that file count is updated dynamically and is integrated into theuseFileManifesthook. [1] [2]FileManifestStatetype to include afileCountproperty and added a new action (UpdateFileCount) in the file manifest reducer to handle file count updates. [1] [2] [3] [4] [5] [6] [7] [8]Refinements to Filter Behavior:
areAllFormFilterTermsSelectedutility withareAllFilesSelected, which compares the file count to the summary file count to determine whether all files are selected. Updated thebuildRequestFiltersfunction to use this logic for generating request filters. [1] [2]These changes collectively improve the handling of file manifest data, particularly in scenarios involving large datasets and complex filtering requirements.