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

updated dashboard buttons link #433

Merged
merged 2 commits into from
Dec 25, 2024
Merged

Conversation

MandeepPaul
Copy link

Describe your changes

Changed target links for buttons on dashboard

Issue number

#428

Please ensure all items are checked off before requesting a review:

  • I deployed the code locally.
  • I have performed a self-review of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme.
  • My PR is granular and targeted to one specific feature.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

@erenfn erenfn self-requested a review December 25, 2024 13:59
Copy link
Contributor

coderabbitai bot commented Dec 25, 2024

Walkthrough

The pull request modifies the navigation routes in the Dashboard component of the frontend. The changes simplify the routing paths for creating different types of activities by removing the /create suffix from the existing routes. Specifically, the navigation paths for popup, banner, and helper link buttons are updated to use more direct routes. Additionally, several components are enhanced to conditionally open modals based on the routing state.

Changes

File Change Summary
frontend/src/scenes/dashboard/Dashboard.jsx Updated onClick handlers for popup, banner, and helper link buttons to use simplified navigation routes. Changed paths from /popup/create, /banner/create, and /hint/create to /popup, /banner, and /hint, respectively.
frontend/src/scenes/banner/BannerDefaultPage.jsx Added useLocation import and passed autoOpen prop to BannerPage based on routing state.
frontend/src/scenes/banner/CreateBannerPage.jsx Introduced autoOpen prop to BannerPage, triggering openDialog in useEffect when true.
frontend/src/scenes/hints/CreateHintPage.jsx Added autoOpen prop to HintPage, triggering openDialog in useEffect when true.
frontend/src/scenes/hints/HintDefaultPage.jsx Added useLocation import and passed autoOpen prop to CreateHintPage based on routing state.
frontend/src/scenes/popup/PopupDefaultPage.jsx Added useLocation import and passed autoOpen prop to CreatePopupPage based on routing state.
frontend/src/templates/GuideTemplate/GuideTemplate.jsx Integrated useLocation and useNavigate hooks; added onCloseHandler for dialog close event based on routing state.

Possibly related PRs

  • Add Loader while Auth Token is verified #267: The changes in the main PR regarding the onClick handlers for navigation paths are related to the modifications in the App component, which also affects routing and navigation behavior.
  • popup-design #290: The updates in the main PR to streamline navigation paths for creating activities are connected to the changes in the CreatePopupPage, which also involves routing and state management for popups.
  • Banner component #318: The introduction of a new banner component in this PR aligns with the changes in the main PR that involve navigation paths for banners, indicating a relationship in how banners are handled in the application.
  • Fix/379 button design in the home page #398: The modifications to button designs in the home page are relevant to the changes in the main PR that involve button interactions and navigation, suggesting a connection in user interface behavior.

Suggested reviewers

  • gorkem-bwl
  • erenfn

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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. (Beta)
  • @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.

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
Collaborator

@erenfn erenfn left a comment

Choose a reason for hiding this comment

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

It should also open the 'create' page' dialog. use useLocation() to pass autoOpen=true to the target pages.

Copy link
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)
frontend/src/scenes/hints/HintDefaultPage.jsx (1)

32-32: Clean passing of autoOpen
You're handing over autoOpen for conditional opening. Keep that spaghetti-code from tangling—this approach seems crisp.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83b4ec5 and 504c9cb.

📒 Files selected for processing (7)
  • frontend/src/scenes/banner/BannerDefaultPage.jsx (3 hunks)
  • frontend/src/scenes/banner/CreateBannerPage.jsx (2 hunks)
  • frontend/src/scenes/dashboard/Dashboard.jsx (1 hunks)
  • frontend/src/scenes/hints/CreateHintPage.jsx (2 hunks)
  • frontend/src/scenes/hints/HintDefaultPage.jsx (3 hunks)
  • frontend/src/scenes/popup/PopupDefaultPage.jsx (3 hunks)
  • frontend/src/templates/GuideTemplate/GuideTemplate.jsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/scenes/dashboard/Dashboard.jsx
🔇 Additional comments (17)
frontend/src/scenes/hints/HintDefaultPage.jsx (2)

2-2: Superb import usage!
Your import of useLocation is on point like the snare in a fresh beat. No concerns here, it’s neat work.


12-12: Smart usage of useLocation
Nice job injecting locationData to read location state. Smooth like a freestyle flow—this sets you up to pass the autoOpen prop.

frontend/src/scenes/popup/PopupDefaultPage.jsx (3)

2-2: Location import is tight
No sweaty palms here—this import is an essential piece for managing state-based navigation.


12-12: Location usage is cohesive
Your usage of locationData sets you up to pass advanced state. Put your mind at ease—this looks good.


33-33: Solid autoOpen integration
Bringing out that autoOpen from locationData is a slick move, making the user experience extra fresh.

frontend/src/scenes/banner/BannerDefaultPage.jsx (3)

2-2: Location import: all set
As steady as your lyrical flow—import is correct and positions the code for dynamic routing states.


12-12: Effective location retrieval
Utilizing useLocation() helps you handle the autoOpen flow. Stay solid in your approach.


32-32: Passing autoOpen for sweet user experience
Injecting autoOpen ensures that you open that banner page with no fuss, preventing spaghetti scenarios.

frontend/src/templates/GuideTemplate/GuideTemplate.jsx (5)

9-9: Kudos for hooking up Router
Importing useLocation and useNavigate keeps your flow on lock, enabling deeper control of modal behaviour.


21-22: Location and navigation synergy
Your usage of location and navigate is balanced like a well-tuned verse. No concerns there.


25-29: Neat onCloseHandler
This logic channels the user back home if autoOpen was set—like a perfect outro to a track. This is great.


49-49: Close icon triggers onCloseHandler
Implementation is consistent—closing with class, ensuring you reset state if needed. Tidy work indeed.


75-75: Cancelled in style
Your “Cancel” button calls onCloseHandler to keep the flow consistent, preventing messy ends like dropped bars.

frontend/src/scenes/banner/CreateBannerPage.jsx (2)

15-15: Yo dawg, these prop and hook changes are straight fire! 🔥

The addition of autoOpen prop and destructuring openDialog from useDialog hook creates a clean interface for controlling dialog behavior from the dashboard.

Also applies to: 24-24


31-33: Ayy, this useEffect is clean as mom's spaghetti! 🍝

The effect hook correctly:

  • Watches both autoOpen and openDialog dependencies
  • Only triggers dialog when autoOpen is true
  • Follows React's best practices for effects

However, let's verify the dialog behavior across the app.

✅ Verification successful

Yo, the autoOpen dialog behavior is consistent across all components! 🍝

After checking the codebase with sweaty palms, I can confirm that all components (Banner, Hint, Popup, and Links) handle the autoOpen prop in the same clean way:

  • They all use a useEffect hook
  • They all check if autoOpen is true before calling openDialog
  • They all include openDialog in the dependencies array

The implementation is as consistent as mom's spaghetti recipe across:

  • frontend/src/scenes/banner/CreateBannerPage.jsx
  • frontend/src/scenes/hints/CreateHintPage.jsx
  • frontend/src/scenes/popup/CreatePopupPage.jsx
  • frontend/src/scenes/links/NewLinksPopup.jsx
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other components using autoOpen prop to ensure consistent behavior
ast-grep --pattern 'const $_ = ({ $$$, autoOpen = $_, $$$}) => {
  $$$
}'

Length of output: 46324

frontend/src/scenes/hints/CreateHintPage.jsx (2)

13-14: Yo, this component's keeping it real with the same pattern! 💯

The changes maintain consistency with CreateBannerPage.jsx, which is crucial for codebase maintainability.


62-64: This useEffect's got the same flow as its banner brother! 🎵

The implementation is consistent with CreateBannerPage.jsx, but let's verify the dashboard integration.

✅ Verification successful

Yo, the navigation flow's in perfect harmony! 🎵

Just dropped some mad verification on this beat, and the Dashboard's navigation is straight fire! It's handling that autoOpen state consistently across all components - popups, banners, and hints are all following the same flow. Each click triggers navigation with that sweet autoOpen: true state, just like mom's spaghetti recipe - never fails!

  • Dashboard.jsx is passing { state: { autoOpen: true }} when navigating to "/hint"
  • Same pattern's used for "/banner" and "/popup" routes
  • Your useEffect in CreateHintPage is catching that state exactly how it should
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check Dashboard component for consistent navigation state
rg -A 5 "navigate\(['\"].*['\"],.*autoOpen.*\)" 

Length of output: 1252

@MandeepPaul MandeepPaul force-pushed the fix/#428-changing-target-links branch from 5a54a53 to 83b4ec5 Compare December 25, 2024 17:10
Copy link
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: 1

🧹 Nitpick comments (1)
frontend/src/scenes/banner/CreateBannerPage.jsx (1)

31-33: Don't forget to clean up after the party! 🧹

Consider adding a cleanup function to handle component unmounting:

  useEffect(() => {
    if (autoOpen) openDialog();
+   return () => {
+     if (autoOpen) closeDialog();
+   };
  }, [autoOpen, openDialog]);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 504c9cb and 732b403.

📒 Files selected for processing (7)
  • frontend/src/scenes/banner/BannerDefaultPage.jsx (3 hunks)
  • frontend/src/scenes/banner/CreateBannerPage.jsx (2 hunks)
  • frontend/src/scenes/dashboard/Dashboard.jsx (1 hunks)
  • frontend/src/scenes/hints/CreateHintPage.jsx (2 hunks)
  • frontend/src/scenes/hints/HintDefaultPage.jsx (3 hunks)
  • frontend/src/scenes/popup/PopupDefaultPage.jsx (3 hunks)
  • frontend/src/templates/GuideTemplate/GuideTemplate.jsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • frontend/src/scenes/banner/BannerDefaultPage.jsx
  • frontend/src/scenes/hints/CreateHintPage.jsx
  • frontend/src/scenes/hints/HintDefaultPage.jsx
  • frontend/src/scenes/popup/PopupDefaultPage.jsx
  • frontend/src/scenes/dashboard/Dashboard.jsx
🔇 Additional comments (4)
frontend/src/templates/GuideTemplate/GuideTemplate.jsx (2)

9-9: Yo dawg, these router hooks are straight fire! 🔥

Clean implementation of React Router hooks for handling navigation state.

Also applies to: 21-22


49-49: These click handlers be vibin' together! 🎵

Solid consistency in using the same onCloseHandler for both close actions.

Also applies to: 75-75

frontend/src/scenes/banner/CreateBannerPage.jsx (2)

15-15: Props game strong! 💪

Clean implementation of the autoOpen prop with proper default value and useDialog hook usage.

Also applies to: 24-24


Line range hint 15-33: Let's make sure this flow is as smooth as mom's spaghetti! 🍝

Verify the complete navigation flow:

  1. Dashboard -> Banner (with autoOpen: true)
  2. Banner opens automatically
  3. Close Banner -> Navigate to root
✅ Verification successful

Yo, this navigation flow is cookin' like mom's perfect spaghetti! 🍝

The flow is properly implemented and working smoothly:

  1. Dashboard correctly initiates the flow with navigate("/banner", { state: { autoOpen: true } })
  2. CreateBannerPage handles the auto-open through the useEffect hook
  3. GuideTemplate handles the navigation on close with if (location.state?.autoOpen) navigate("/", { state: {} })

The pattern is consistently used across other components (popup, hint) following the same recipe, making it a well-tested and reliable implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any other components using the same pattern
rg -l "state: \{ autoOpen: true \}"

# Verify the navigation pattern implementation
ast-grep --pattern 'useNavigate()' -l

Length of output: 227


Script:

#!/bin/bash
# Let's get this spaghetti right! First, check the navigation pattern with proper language
ast-grep --pattern 'useNavigate()' --lang javascript

# Check how autoOpen is being passed around
rg -A 3 "autoOpen.*true"

# Let's see the dialog closing logic
ast-grep --pattern 'closeDialog()' --lang javascript

# And check for any navigation after dialog close
rg -B 2 -A 2 "navigate\(.*\)"

Length of output: 11446

@MandeepPaul
Copy link
Author

Passed the autoOpen prop using the useLocation hook and ensured the state is removed when the dialog is closed.

It might also be necessary to remove the state during the onSave event. Please let me know if this is the expected behavior we want!

@MandeepPaul MandeepPaul requested a review from erenfn December 25, 2024 17:16
Copy link
Collaborator

@erenfn erenfn left a comment

Choose a reason for hiding this comment

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

Looks good!

@erenfn
Copy link
Collaborator

erenfn commented Dec 25, 2024

Passed the autoOpen prop using the useLocation hook and ensured the state is removed when the dialog is closed.

It might also be necessary to remove the state during the onSave event. Please let me know if this is the expected behavior we want!

We are trying to fix that issue in #410, but thanks for pointing it out!

@erenfn erenfn merged commit e0cc17c into develop Dec 25, 2024
2 checks passed
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.

2 participants