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

Use different query parameter managements between data-catalog page and new E&A page #1021

Merged
merged 17 commits into from
Jun 28, 2024

Conversation

hanbyul-here
Copy link
Collaborator

@hanbyul-here hanbyul-here commented Jun 26, 2024

Related Ticket: #1016

Description of Changes

This PR makes Catalog View on the data-catalog page use QS-state for query parameters, while Catalog View on the new E&A page uses Jotai. The current Atoms related to URL management is not designed for cross-page navigation. I drew a diagram to describe the navigation problem between catalog page and overview page.

Screenshot 2024-06-26 at 1 19 05 PM

More context:
We moved our query parameter management to use Jotai because of the concerns about the mix-use of QS-State and Jotai for query parameters on the same page. (Specifically - for the new E&A page, other parameters are managed by Jotai). More details on this PR that initially introduced data-catalog view to new E&A page: #989 (comment) In the end, we ditched the Query parameter manipulation thinking that we don't need. (Details are in this comment: #989 (comment)) But the bug reported #1016 made me realize that was a wrong call.

Notes & Questions About Changes

  • We need a better solution for long-term url management.

Validation / Testing

Navigate back and forth from data catalog to overview, from overview to data catalog (especially through taxonomy pills on the overview page)
Navigate to the new E&A page through the 'Explore Data' button on the overview page.

I opened a pr on ghg for testing: US-GHG-Center/veda-config-ghg#421

Copy link

netlify bot commented Jun 26, 2024

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit 7a08578
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/667f1dda90536500083b144e
😎 Deploy Preview https://deploy-preview-1021--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.

sandrahoang686 and others added 4 commits June 26, 2024 15:21
@hanbyul-here it might be cleaner to just still use the `useCatalogView`
hook. Just moved the qs-state logic over here instead and exposed it
from this hook since Actions are the exact same, it can reference the
same action logic `onCatalogAction`.

We can actually start deprecating and removing all `useBrowserControl`
logic, right now `stories/hub` is still using it but we can probably
port it over. This way we have one hook managing separate states and
exposing them which I think is better than having duplicated logic. We
could create a separate hook though to make it more explicit but both
can use the same actions logic `onCatalogAction`.

I know we probably dont want to use qs-state-hook. We can probably work
on updating that logic later or in this PR whichever you see fit.

Feel free to fix naming.. naming isn't great here, was just trying to
combine and see if this is better
@hanbyul-here hanbyul-here marked this pull request as ready for review June 27, 2024 18:04
@hanbyul-here
Copy link
Collaborator Author

hanbyul-here commented Jun 27, 2024

This PR is ready for the review @sandrahoang686 I ended up with a few more changes to fix the bug that @aboydnw reported in #1022

I deprecated useBrowseControls, now StoriesHub also uses useCatalogAction (I am not sure if this hook needs to be renamed? but maybe not since everything is a catalog? 🙃 ). So I would appreciate it if extra attention could be paid to stories + URL query parameters on top of the original issue 🙇

@hanbyul-here hanbyul-here requested a review from aboydnw June 27, 2024 18:47
@aboydnw
Copy link
Contributor

aboydnw commented Jun 27, 2024

I tried to break the Dataset overview -> exploration link, adding/editing layers, and the stories catalog. The only thing that I noticed is the following:

  1. Open the add layer modal (either manually or by clicking explore data from the dataset overview page)
  2. Make sure there is a a search term or filter selected
  3. Select a layer to view
  4. Click add to map
  5. Click Add Layer to reopen the select layer modal
  6. Notice that the filters persist

This is different from how it behaves in prod. I could see arguments for both experiences, but I wanted to call it out in case we intentionally wiped filters in the old layer selection modal. cc @faustoperez

@hanbyul-here
Copy link
Collaborator Author

Thank you @aboydnw , that is a sharp catch! That behavior you described, is precisely why we ditched 'keeping the current state of filtering as URL parameters' at first (Details are: #989 (comment)). However, we learned we needed it to manipulate the current filter state through query parameters. (So the modal can show the filtered layers on landing when a user comes from the Data Overview page.)

But I agree that it is a weird behavior that the search state persists after the purpose of filtering is fulfilled - so I added 'reset' of search terms and taxonomies whenever the layer selections are confirmed, or the layer selection modal is closed (hidden).

Copy link
Collaborator

@sandrahoang686 sandrahoang686 left a comment

Choose a reason for hiding this comment

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

🙇🏼‍♀️Nice and fast work on this! Left some comments but none if it huge, logic makes sense, comments are minor

app/scripts/components/common/browse-controls/constant.js Outdated Show resolved Hide resolved
app/scripts/components/common/card-sources.tsx Outdated Show resolved Hide resolved
app/scripts/components/common/catalog/catalog-content.tsx Outdated Show resolved Hide resolved
app/scripts/components/common/catalog/catalog-content.tsx Outdated Show resolved Hide resolved
commit: navigate
});

const [search, setSearch] = useQsState.memo(
Copy link
Collaborator

Choose a reason for hiding this comment

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

💭 : Can we make a tech-debt note or todo where we comment on how we hope to consolidate how we manage taxonomies states and url. But here's a thought, I think it actually makes sense to keep this separate? right now the atomWithUrlStability manages taxonomies state but url routing which does it make sense to break up? So it manages just that state but does nothing with the url, we can create a hook or have a useEffect wherever applicate to worry about the naviagation based on whatever state change? Does that make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, That sounds like how the current main branch is using the filters with the states in the data selection modal, but in a separate hook. Am I getting it right?

Aside from how we will handle the query parameter in the future... I wonder if there is a better place than the code base where this kind of discussion should go so it can get deserving attention. I changed @NOTE prefix to @TECH-DEBTto signal that actions need to be taken.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure how its managed in the modal but yep talking about not combining taxonomies state and url changes likes whats happening in the atomWithUrlStability and to have them separate

}
// @NOTE: A hook using qs-state for query parameter management for cross-page navigation
// Details: https://github.com/NASA-IMPACT/veda-ui/pull/1021
export function useCatalogViewQS(): UseCatalogViewResult {
Copy link
Collaborator

Choose a reason for hiding this comment

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

⛏️ : What do you think about changing the name to useFiltersUrlManagement because this is mostly tied to the filters instead of the greater catalog view. We can probably change the interface to be UseFiltersUrlManagementResults... its long though..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted to get around without renaming the hook, but you are right that this hook is not capturing what it is doing now 💦 I renamed it as useFilterswithURLAtom and useFiltersWithQS, hoping that the name of the hook signals enough what it does!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(This also required renaming of related variables to prefix by Filter, instead of Catalog !)

app/scripts/components/common/catalog/prepare-datasets.ts Outdated Show resolved Hide resolved
@sandrahoang686
Copy link
Collaborator

sandrahoang686 commented Jun 28, 2024

QA Findings

Test Result
Selecting different filters across groups and clearing tags
Selecting filters and clicking into dataset and then pill tag takes you to correct filter view
Search persist
Selecting filters and Search work correctly in modal
Clicking on "Explore data" navigates to the modal with search correct
Closing out of the modal into E&A, url params empty search query param still persists (ex. https://deploy-preview-1021--veda-ui.netlify.app/exploration?search=&datasets=%5B%7B%22id%22%3A%22combined_CMIP6_daily_GISS-E2-1-.... but doesn't cause any issues)

@hanbyul-here hanbyul-here merged commit 9b97013 into main Jun 28, 2024
8 checks passed
@hanbyul-here hanbyul-here deleted the 1016-search-qp branch June 28, 2024 20:36
@hanbyul-here hanbyul-here mentioned this pull request Jul 1, 2024
sandrahoang686 added a commit that referenced this pull request Jul 1, 2024
## What's Changed

Note: This could be a patch version number. But the fix for the query
parameter on the data catalog page, new E&A page, and stories hub
brought a substantial change and improvement, in my opinion. And there
are some other improvements we made. So I am cutting a minor version
release.

## 🎉 Features
🦗 
## 🚀 Improvements
* Create bug.md in #1015
* Use VizDataset data type for block map, set a default value for
interactive in #1006
## 🐛 Fixes
* Fix scrollytelling projection problem in
#1011
* Use different query parameter managements between data-catalog page
and new E&A page in #1021


**Full Changelog**:
v5.1.2...v5.2.0
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.

4 participants