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

[#1238] Create a derived atom for dataset hydration from Next.js #1266

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dzole0311
Copy link
Collaborator

@dzole0311 dzole0311 commented Nov 20, 2024

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

@dzole0311 dzole0311 marked this pull request as draft November 20, 2024 17:36
Copy link

netlify bot commented Nov 20, 2024

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit 41a3a48
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/673eeb897e78e5000817a99e
😎 Deploy Preview https://deploy-preview-1266--veda-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dzole0311 dzole0311 changed the title Create a derived atom for dataset hydration from Next.js [#1266] Create a derived atom for dataset hydration from Next.js Nov 21, 2024
@dzole0311 dzole0311 changed the title [#1266] Create a derived atom for dataset hydration from Next.js [#1238] Create a derived atom for dataset hydration from Next.js Nov 21, 2024
@@ -32,6 +33,8 @@ const tourProviderStyles = {
};

export default function ExplorationAndAnalysisContainer() {
const setExternalDatasets = useSetAtom(externalDatasetsAtom);
setExternalDatasets(allExploreDatasets);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current approach using setExternalDatasets works, but it might need to be called in multiple places where we depend on the static datasets.

I was wondering if a more scalable solution would be to use our existing EnvConfigProvider and evolve it into a more general ConfigProvider. Like this it would centralize both our env and data configuration in one place.

The provider could be used like this (note the extra datasets prop passed):

<EnvConfigProvider
      config={{
                envMapboxToken: process.env.NEXT_PUBLIC_MAPBOX_TOKEN ?? '',
                envApiStacEndpoint: process.env.NEXT_PUBLIC_API_STAC_ENDPOINT ?? '',
                envApiRasterEndpoint: process.env.NEXT_PUBLIC_API_RASTER_ENDPOINT ?? '',
                datasets: static-datasets
      }}
>
              {children}
</EnvConfigProvider>

And internally, the provider would handle dataset hydration:

const setExternalDatasets = useSetAtom(externalDatasetsAtom);
setExternalDatasets(allExploreDatasets);

Like that the setter won't have to be manually called several times if it's needed.

@dzole0311 dzole0311 marked this pull request as ready for review November 21, 2024 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant