-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
**Related Ticket:** #1238 **Related Next.js PR:** developmentseed/next-veda-ui#17 ### Description of Changes - Removed dependency on static datasets (veda_faux_module_datasets) when reconciling datasets from URL params in E&A - Created `externalDatasetsAtom` to store datasets from host applications (eg Next.js) - Modified `datasetLayersAtom` to use external datasets instead of the bundled static datasets from VEDA UI ### Notes & Questions About Changes _{Add additonal notes and outstanding questions here related to changes in this pull request}_ ### Validation / Testing VEDA UI 1. Open E&A and select a few datasets 2. Once they are loaded, refresh the page 3. Verify that the datasets still load without issues, no errors are thrown Next.js 1. Same as for the VEDA UI above
- Loading branch information
Showing
6 changed files
with
58 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { atom } from 'jotai'; | ||
import { DatasetLayer } from '$types/veda'; | ||
|
||
/** | ||
* This is the primary storage atom for external datasets (e.g. passed from Next.js). | ||
*/ | ||
export const externalDatasetsAtom = atom<any[]>([]); | ||
|
||
/** | ||
* Derived atom that transforms the provided datasets into layers. | ||
* It is used by the timelineDatasetsAtom to rebuild state from URL parameters | ||
* while it preserves the parent dataset metadata for each layer that comes | ||
* from the MDX configuration. | ||
*/ | ||
export const datasetLayersAtom = atom<DatasetLayer[]>((get) => { | ||
const datasets = get(externalDatasetsAtom); | ||
|
||
return datasets.flatMap((dataset) => { | ||
return (dataset.layers || []).map((l: any) => ({ | ||
...l, | ||
parentDataset: { | ||
id: dataset.id, | ||
name: dataset.name | ||
} | ||
})); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters