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

feat(website): store previewed sequence ID in URL #3762

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

Conversation

theosanderson
Copy link
Member

@theosanderson theosanderson commented Feb 26, 2025

resolves #2025

preview URL: http://previewurl.loculus.org

Summary

Stores the ID of the sequence currently previewed in a modal on the search page in the URL

  1. Modified both the previewedSeqId and previewHalfScreen state
    to initialize from URL parameters
  2. Created callback functions to update both local state and
    URL state
  3. Added a useEffect hook to keep the local state in sync with
    URL parameters when they change
  4. Used the same pattern as the page parameter:
    - For selected sequence: selectedSeq=ABC123 in URL
    - For half screen mode: halfScreen=true in URL
    - Parameters are completely removed from URL when not active

Now when users:

  1. Select a sequence for preview, it will be stored in the URL
  2. Change to half-screen view, that preference will be stored
    in the URL
  3. Reload the page or share the URL, both the selected sequence
    and view mode will be preserved

Tests aren't working atm though the function does

@theosanderson theosanderson added the preview Triggers a deployment to argocd label Feb 26, 2025
@theosanderson theosanderson marked this pull request as draft February 26, 2025 22:02
@theosanderson theosanderson removed the preview Triggers a deployment to argocd label Feb 26, 2025
@theosanderson theosanderson requested a review from Copilot March 6, 2025 00:40

Choose a reason for hiding this comment

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

PR Overview

This PR updates the search page functionality to store the previewed sequence ID and half-screen preference in the URL, enabling state persistence on reload or when sharing the URL.

  • Initializes state from URL parameters for sequence and view mode
  • Introduces callbacks to update both local state and URL query parameters
  • Adds tests to verify the URL parameter integration for sequence selection and half-screen view

Reviewed Changes

File Description
website/src/components/SearchPage/SearchFullUI.tsx Refactored state initialization and updated functions to synchronize URL parameters
website/tests/pages/search/index.spec.ts Added integration tests for updating and restoring URL parameters

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

website/src/components/SearchPage/SearchFullUI.tsx:121

  • [nitpick] The callback function 'setPreviewedSeqId' shares a similar naming to the inner state setter 'setPreviewedSeqIdInner', which could be confusing. Consider renaming the callback to 'updatePreviewedSeqId' for improved clarity.
const setPreviewedSeqId = useCallback(
@theosanderson theosanderson added the preview Triggers a deployment to argocd label Mar 13, 2025
@theosanderson theosanderson mentioned this pull request Mar 13, 2025
2 tasks
@theosanderson theosanderson marked this pull request as ready for review March 14, 2025 15:03
@theosanderson theosanderson requested a review from fhennig March 14, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Triggers a deployment to argocd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Persist sequence opened in modal in URL
1 participant