Skip to content

feature: add view query param to visit satellite view#1631

Closed
sunilsabatp wants to merge 2 commits into
developfrom
Feature/view_queryParam
Closed

feature: add view query param to visit satellite view#1631
sunilsabatp wants to merge 2 commits into
developfrom
Feature/view_queryParam

Conversation

@sunilsabatp
Copy link
Copy Markdown
Contributor

@sunilsabatp sunilsabatp commented Dec 5, 2022

feature -> view query param to visit time-travel or site-data view
visit to get result -> yucatan?site=site_1P7gSIcbHILfsi3&view=time-travel
two possible value forviewquery param (i.e time-travel, site-data, vegetation)
site-data is the default view

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
planet-webapp ✅ Ready (Inspect) Visit Preview Jan 5, 2023 at 9:43AM (UTC)

@mohitb35 mohitb35 requested a review from prachigarg19 December 7, 2022 08:54
@mariahosfeld
Copy link
Copy Markdown
Contributor

@sunilsabatp, we have a third option "Vegetation Change". Check the project with the slug treeplanting to see it. This should also be included.

@sunilsabatp
Copy link
Copy Markdown
Contributor Author

@sunilsabatp, we have a third option "Vegetation Change". Check the project with the slug treeplanting to see it. This should also be included.

I'll look into it

@sagararyal
Copy link
Copy Markdown
Member

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2025

Walkthrough

This update modifies the routing and tab selection logic for a project details interface. The main changes involve synchronizing the selected view mode with the URL's view query parameter and updating the URL when tabs are clicked. The router redirection now includes a view=site-data parameter when no view is specified, and the tab component reads and sets the selected mode based on the URL. No public API or exported entity signatures were changed.

Changes

File(s) Change Summary
pages/[p].tsx Updated router redirection to include view=site-data in the query parameters and used optional chaining for project slug.
src/features/projects/components/maps/ProjectTabs.tsx Enhanced tab logic: reads view from URL to set mode, updates URL with view param on tab click, and syncs state with URL.
src/features/projects/screens/SingleProjectDetails.tsx Removed unused selectedMode from context destructuring.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ProjectTabs
    participant Router

    User->>ProjectTabs: Clicks a tab
    ProjectTabs->>Router: push(new URL with updated site and view params)
    Router-->>ProjectTabs: Updates query params
    ProjectTabs->>ProjectTabs: useEffect detects query.view change
    ProjectTabs->>ProjectTabs: Sets selectedMode based on query.view
Loading

Suggested reviewers

  • sunilsabatp

Poem

In the warren of code, a path was made clear,
Tabs now guide with URLs, so users won't fear.
When a bunny clicks "view," the route hops along,
Keeping state in the query, where it rightly belongs.
With a whisker-twitch redirect and a shallow leap,
The project’s new logic is tidy and neat!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/features/projects/components/maps/ProjectTabs.tsx (1)

27-39: Consider standardizing URL parameter values and internal mode names

There's a discrepancy between URL parameter values and internal mode names:

  • field-data maps to location
  • time-travel maps to imagery
  • vegetation maps to vegetation
  • site-data in the redirect URL (in [p].tsx) isn't explicitly handled

Consider standardizing these naming conventions in a future refactoring for better code clarity.

Also applies to: 52-56, 73-77, 98-102

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76bc0d2 and dd7cd51.

📒 Files selected for processing (3)
  • pages/[p].tsx (1 hunks)
  • src/features/projects/components/maps/ProjectTabs.tsx (4 hunks)
  • src/features/projects/screens/SingleProjectDetails.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • src/features/projects/screens/SingleProjectDetails.tsx
🧰 Additional context used
🧠 Learnings (1)
src/features/projects/components/maps/ProjectTabs.tsx (1)
Learnt from: mohitb35
PR: Plant-for-the-Planet-org/planet-webapp#2329
File: src/features/projectsV2/ProjectsMap/ProjectMapTabs/index.tsx:29-37
Timestamp: 2025-01-23T04:33:49.974Z
Learning: The commented-out code in `src/features/projectsV2/ProjectsMap/ProjectMapTabs/index.tsx` is for a delayed satellite tab feature, including `allTabsList` array and `setSeparatorVisibility` function.
🧬 Code Graph Analysis (1)
src/features/projects/components/maps/ProjectTabs.tsx (1)
src/features/common/Layout/ProjectPropsContext.tsx (1)
  • ProjectPropsContext (6-84)
🔇 Additional comments (7)
pages/[p].tsx (1)

118-126: URL parameter enhancement adds better navigation support

The addition of view=site-data parameter to the redirection URL implements the new feature for visiting different satellite views via URL parameters. The optional chaining for project?.slug is also a good defensive programming practice to prevent potential null reference errors.

src/features/projects/components/maps/ProjectTabs.tsx (6)

15-15: Properly expanded router object destructuring

Good addition of query and push from the router object to support the new URL parameter functionality.


17-25: Appropriately expanded context consumption

The additional context values (selectedSite, project, geoJson, and plantLocations) are necessary to implement the URL parameter-based navigation system.


27-39: Well-implemented URL parameter to mode mapping

This useEffect hook correctly synchronizes the UI state with URL parameters, mapping the view query parameter to the appropriate internal mode. The conditional check for plantLocations ensures the component doesn't attempt to set the mode before data is available.


52-56: Field Data tab now updates URL

The onClick handler now properly updates the URL with the view=field-data parameter when the tab is clicked.


73-77: Time Travel tab now updates URL

The onClick handler now properly updates the URL with the view=time-travel parameter when the tab is clicked.


98-102: Vegetation Change tab now updates URL

The onClick handler now properly updates the URL with the view=vegetation parameter when the tab is clicked, which fulfills the requirement mentioned by mariahosfeld in the PR comments.

@mohitb35
Copy link
Copy Markdown
Member

mohitb35 commented Apr 23, 2025

Closing this as outdated.

@mariahosfeld in case this is a desired feature, could you update the backlog?

@mohitb35 mohitb35 closed this Apr 23, 2025
@mohitb35 mohitb35 deleted the Feature/view_queryParam branch April 23, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants