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

revamp side-menu #956

Merged
merged 2 commits into from
Oct 15, 2024
Merged

revamp side-menu #956

merged 2 commits into from
Oct 15, 2024

Conversation

Abhi-m-anue
Copy link
Contributor

BlueWave.Uptime.-.Personal.-.Microsoft.Edge.2024-10-14.12-16-25.mp4

Copy link

coderabbitai bot commented Oct 14, 2024

Walkthrough

The pull request introduces modifications to the Sidebar component in Client/src/Components/Sidebar/index.jsx. A new Folder icon is imported, and a new section called "Other" is added to the sidebar, which nests existing items: "Settings," "Support," "Docs," and "Changelog." The state management for the sidebar's open/close functionality is updated to include the "Other" section. Additionally, the navigation logic is refined to check for URLs in the URL_MAP, enhancing the overall structure and usability of the sidebar.

Changes

File Change Summary
Client/src/Components/Sidebar/index.jsx - Added Folder icon import.
- Updated menu structure to include "Other" section with nested items.
- Modified state management to include "Other" key.
- Altered navigation logic to check for URLs in URL_MAP.
- Removed separate list for "Other" items and cleaned up JSX.

Possibly related PRs

  • Added docs and changelog to main menu #947: This PR modifies the same Sidebar component and updates the navigation logic to utilize a URL_MAP, which is also a key change in the main PR. Both PRs involve restructuring the sidebar's menu items and enhancing navigation functionality.

Suggested reviewers

  • jennifer-gan
  • ajhollid

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 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

@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

🧹 Outside diff range and nitpick comments (3)
Client/src/Components/Sidebar/index.jsx (3)

72-81: Yo, we're cookin' up a storm with this new "Other" section!

This new menu item's got me weak in the knees, it's so organized! But yo, we might wanna consider sortin' these nested items alphabetically. It's like arrangin' mom's spaghetti on the plate, you feel me?

How 'bout we sort these items like this:

 {
   name: "Other",
   icon: <Folder />,
   nested: [
-    { name: "Settings", path: "settings", icon: <Settings /> },
-    { name: "Support", path: "support", icon: <Support /> },
-    { name: "Docs", path: "docs", icon: <Docs /> },
-    { name: "Changelog", path: "changelog", icon: <ChangeLog /> },
+    { name: "Changelog", path: "changelog", icon: <ChangeLog /> },
+    { name: "Docs", path: "docs", icon: <Docs /> },
+    { name: "Settings", path: "settings", icon: <Settings /> },
+    { name: "Support", path: "support", icon: <Support /> },
   ],
 },

144-145: Yo, this useEffect hook's got more flavor than mom's secret sauce!

Addin' that condition for the "Other" section, it's like you're stirrin' the pot just right. But hey, why stop at "/settings"? We could make this even tastier!

How 'bout we spice it up like this:

 useEffect(() => {
   if (
     location.pathname.includes("monitors") ||
     location.pathname.includes("pagespeed")
   )
     setOpen((prev) => ({ ...prev, Dashboard: true }));
   else if (location.pathname.includes("/account"))
     setOpen((prev) => ({ ...prev, Account: true }));
-  else if (location.pathname.includes("/settings"))
+  else if (location.pathname.includes("/settings") || location.pathname.includes("/support") || location.pathname.includes("/docs") || location.pathname.includes("/changelog"))
     setOpen((prev) => ({ ...prev, Other: true }));
 }, []);

This way, we're catchin' all the flavors in our "Other" section, you feel me?


365-370: Yo, this navigation logic's got more twists than a plate of spaghetti!

You're servin' up some gourmet code here with this URL_MAP business. It's like you're givin' us a choice between eatin' in or takin' out, you know what I'm sayin'?

But yo, we might wanna add some extra seasoning to this dish.

How 'bout we wrap this logic in a helper function? Something like:

const handleNavigation = (path) => {
  const url = URL_MAP[path];
  if (url) {
    window.open(url, "_blank", "noreferrer");
  } else {
    navigate(`/${path}`);
  }
};

Then we can just call handleNavigation(child.path) in both places. It's like havin' a secret recipe that we can use whenever we need, you feel me?

Also applies to: 439-446

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e3c0d23 and 7e14184.

⛔ Files ignored due to path filters (1)
  • Client/src/assets/icons/folder.svg is excluded by !**/*.svg
📒 Files selected for processing (1)
  • Client/src/Components/Sidebar/index.jsx (8 hunks)
🧰 Additional context used
🪛 Biome
Client/src/Components/Sidebar/index.jsx

[error] 398-398: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

🔇 Additional comments (4)
Client/src/Components/Sidebar/index.jsx (4)

46-46: Yo, this Folder icon import's lookin' fresh!

Bringin' in that new Folder icon, it's like addin' some extra sauce to our spaghetti code. It's all good in the hood!


104-104: Yo, this state management's got more layers than lasagna!

Adding that "Other" to the open state, it's like you're givin' our sidebar some extra cheese. It's all comin' together like a well-plated dish, you know what I'm sayin'?


396-403: Yo, this spread syntax's got the static analysis tool sweatin', but don't lose your lunch over it!

The tool's yellin' about using spread in an accumulator, sayin' it might make our code run slower than cold spaghetti. But chill, it's not as bad as it sounds!

In this case, we're only spreadin' a small object with boolean values. It's like addin' a pinch of salt to the pasta water - it ain't gonna slow down the boil, you feel me?

The way it's written now is easier to read than mom's handwritten recipe. Sometimes, a little performance trade-off for cleaner code is worth it, especially when the impact's smaller than the crumbs in your lap after eatin' garlic bread.

If you're still worried about it keepin' you up at night, we could refactor it like this:

setOpen((prev) => {
  const newState = Object.keys(prev).reduce((acc, key) => {
    acc[key] = false;
    return acc;
  }, {});
  newState[item.name] = !prev[item.name];
  return newState;
});

But honestly? I'd stick with what we've got. It's cleaner than a fresh plate, ready for some sauce!

🧰 Tools
🪛 Biome

[error] 398-398: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)


Line range hint 1-653: Yo, this sidebar revamp's got more flavor than a gourmet Italian joint!

Let's break it down like we're platin' up a five-course meal:

  1. We've got that fresh Folder icon import, addin' some visual zest.
  2. The new "Other" section's organizin' our menu items like a pro chef arranges the plate.
  3. Our state management's got more layers than a lasagna, keepin' everything in check.
  4. That useEffect hook's stirrin' the pot just right, makin' sure everything opens up smooth.
  5. And that navigation logic? It's like havin' a secret menu - we can eat in or take out!

Overall, this code's cookin' up a storm! It's gonna make our users' experience smoother than a creamy carbonara. Just a few small suggestions to take it from great to chef's kiss, but it's already lookin' mighty tasty!

Copy link
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

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

Nice work! Couple readability/maintainability changes that I think could improve things, other than that looks great.

Thanks again for your contribution!

Client/src/Components/Sidebar/index.jsx Show resolved Hide resolved
Client/src/Components/Sidebar/index.jsx Show resolved Hide resolved
Copy link

@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

🧹 Outside diff range and nitpick comments (3)
Client/src/Components/Sidebar/index.jsx (3)

72-81: Yo, this "Other" section's droppin' like it's hot!

Mad props for groupin' these items, homie. It's cleanin' up the sidebar like mom's spaghetti off a sweater. But check it, we could make it even tighter by sortin' these items alphabetically. Wanna give it a shot?

 {
   name: "Other",
   icon: <Folder />,
   nested: [
-    { name: "Settings", path: "settings", icon: <Settings /> },
-    { name: "Support", path: "support", icon: <Support /> },
-    { name: "Docs", path: "docs", icon: <Docs /> },
-    { name: "Changelog", path: "changelog", icon: <ChangeLog /> },
+    { name: "Changelog", path: "changelog", icon: <ChangeLog /> },
+    { name: "Docs", path: "docs", icon: <Docs /> },
+    { name: "Settings", path: "settings", icon: <Settings /> },
+    { name: "Support", path: "support", icon: <Support /> },
   ],
 },

This'll make it easier to spot items than spottin' vomit on your sweater, ya feel me?


90-95: Yo, this PATH_MAP's straight fire!

This PATH_MAP's gonna make our code flow smoother than Eminem's rhymes, no cap. But peep this, we could make it even more lit by usin' object property shorthand. Check it:

 const PATH_MAP = {
-  monitors: "Dashboard",
-  pagespeed: "Dashboard",
+  monitors: "Dashboard",
+  pagespeed: "Dashboard",
   account: "Account",
   settings: "Other",
 };

Now it's cleaner than your sweater after mom's done with it, you feel me?


144-150: Yo, this useEffect hook's got me shook!

This update's smoother than Slim Shady's flow, no doubt. You took that feedback from the last PR and ran with it like you're runnin' from mom's spaghetti. Mad respect for implementin' that PATH_MAP, it's gonna make our code more flexible than a rapper's vocabulary.

Just one thing though, we might wanna add a comment explainin' what this effect does, you feel me? Sometimes future us might forget and get lost in the sauce.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7e14184 and cefe93b.

⛔ Files ignored due to path filters (1)
  • Client/src/assets/icons/folder.svg is excluded by !**/*.svg
📒 Files selected for processing (1)
  • Client/src/Components/Sidebar/index.jsx (9 hunks)
🧰 Additional context used
🔇 Additional comments (4)
Client/src/Components/Sidebar/index.jsx (4)

46-46: Yo, this Folder icon import's lookin' fresh!

Addin' this Folder icon's a solid move, dawg. It's gonna make that new "Other" section pop like mom's spaghetti on a sweater.


111-111: Yo, this state init's got me weak!

You're killin' it with this update, G. Addin' that "Other" section to the initial state's gonna keep our sidebar game strong, like mom's spaghetti recipe. It's all about that consistency, you know what I'm sayin'?


372-377: Yo, this navigation logic's got more layers than Eminem's lyrics!

You're switchin' up the game with this update, homie. Checkin' that URL_MAP before we bounce is smart like mom checkin' the pasta before servin' it up. Now we can handle both internal and external links like a pro, openin' new tabs when we need to. That's some next-level thinkin' right there!


403-404: Yo, this setOpen call's cleaner than mom's kitchen after spaghetti night!

Mad props for takin' that feedback and runnin' with it like you're Eminem in 8 Mile. You've turned this setOpen call into a lyrical masterpiece with Object.fromEntries and map. It's so clean now, it's like the vomit never even touched the sweater. You're killin' it, G!

Copy link
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

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

Nice work, thanks for incorporating those changes 👍

@ajhollid ajhollid merged commit c2e0037 into bluewave-labs:develop Oct 15, 2024
1 check passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 15, 2024
3 tasks
@coderabbitai coderabbitai bot mentioned this pull request Oct 24, 2024
4 tasks
@coderabbitai coderabbitai bot mentioned this pull request Nov 13, 2024
10 tasks
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