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

mobile sidebar redirection and cleanup of the sidebar redundant elements #1502

Merged
merged 6 commits into from
Oct 21, 2024

Conversation

mithunhegde-egov
Copy link

@mithunhegde-egov mithunhegde-egov commented Oct 11, 2024

redirection changes of sidebar and has been tested from
1- mobile sidebar employee
2- mobile sidebar citizen
3-sidebar employee
4- sidebar citizen.

all redirections are working as expected

Summary by CodeRabbit

  • New Features

    • Introduced a new login button in the sidebar with a logout icon.
    • Enhanced navigation options including home, city, language, and edit profile.
  • Improvements

    • Streamlined sidebar structure for better user experience, especially on mobile devices.
    • Refined user profile picture handling and city selection data management.
    • Improved URL handling for multi-root tenant navigation.
  • Bug Fixes

    • Updated logic to ensure correct redirection to the language selection page based on user type.

@mithunhegde-egov mithunhegde-egov requested a review from a team as a code owner October 11, 2024 04:27
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

📝 Walkthrough

Walkthrough

The changes involve significant modifications to the CitizenSideBar component within the CitizenSideBar.js file. These include new icon imports, updates to navigation logic for multi-root tenants, and alterations to the redirection process. The sidebar menu has been restructured to include a login button, and the rendering logic for user profiles has been refined. Additionally, state management improvements and adjustments to useEffect hooks have been made to enhance user experience, particularly for mobile views.

Changes

File Change Summary
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js - Added imports for LogoutIcon.
- Updated handleModuleClick for multi-root tenant logic.
- Modified redirectToLoginPage for language selection.
- Restructured sidebar menu to include a login button.
- Adjusted profile rendering logic to filter login button for authenticated users.
- Enhanced state management and useEffect hooks for user profile and city selection.

Possibly related PRs

  • side bar mobileview and sidebar link order fixes #1481: This PR focuses on mobile view fixes for the CitizenSideBar, which is directly related to the changes made in the main PR that also modifies the CitizenSideBar component.
  • fixed redirection issue #1527: This PR addresses redirection issues in the EmployeeSideBar, which is relevant as the main PR also involves URL handling and redirection logic in the CitizenSideBar.
  • Sidebar localization #1494: This PR enhances localization for sidebar item labels in the EmployeeSideBar, which connects to the main PR's updates in the CitizenSideBar that also involve user interface improvements and localization aspects.

Suggested reviewers

  • nabeelmd-eGov
  • jagankumar-egov

🐰 In the sidebar where options bloom,
New icons dance, dispelling gloom.
With each click, a path unfolds,
Language and city, stories told.
A login button, bright and clear,
Hop on in, the change is here! 🌟


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:

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

@mithunhegde-egov mithunhegde-egov changed the title mobile sidebar redirection working mobile sidebar redirection and cleanup of the sidebar redundant elements Oct 11, 2024
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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 0209ae1 and 396468b.

📒 Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js (1)

Pattern **/*.js: check

🪛 Biome
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js

[error] 169-169: Reassigning a function parameter is confusing.

The parameter is declared here:

Use a local variable instead.

(lint/style/noParameterAssign)

🔇 Additional comments (2)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js (2)

10-11: Imports are correctly added.

The new icons are successfully imported from the appropriate package.


185-186: Redirection to language selection page is correctly implemented.

The redirectToLoginPage function now appropriately redirects to the language selection page.

Comment on lines 175 to +177
history.push(`/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}${url}`) :
history.push(`/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}/${url}`);
toggleSidebar();
toggleSidebar();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix syntax error in navigation logic.

The current use of the ternary operator leads to a syntax error because it's not correctly structured within an expression.

Modify the code to use the ternary operator within the history.push function:

-          url[0]==="/" ? 
-          history.push(`/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}${url}`) :
-          history.push(`/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}/${url}`);
+          history.push(
+            url[0] === "/"
+              ? `/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}${url}`
+              : `/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}/${url}`
+          );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
history.push(`/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}${url}`) :
history.push(`/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}/${url}`);
toggleSidebar();
toggleSidebar();
history.push(
url[0] === "/"
? `/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}${url}`
: `/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}/${url}`
);
toggleSidebar();

Comment on lines 169 to 171
url=isEmployee?url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`): url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`)
history.push(url);
toggleSidebar();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid reassigning the function parameter url.

Reassigning function parameters can lead to unexpected behavior and reduces code clarity. It's better to use a local variable to store the modified URL.

Consider using a local variable:

-          url = isEmployee ? url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`) : url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`);
-          history.push(url);
+          const newUrl = isEmployee ? url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`) : url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`);
+          history.push(newUrl);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
url=isEmployee?url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`): url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`)
history.push(url);
toggleSidebar();
const newUrl = isEmployee ? url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`) : url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`);
history.push(newUrl);
toggleSidebar();
🧰 Tools
🪛 Biome

[error] 169-169: Reassigning a function parameter is confusing.

The parameter is declared here:

Use a local variable instead.

(lint/style/noParameterAssign)

Comment on lines +198 to +199
icon: <LogoutIcon className="icon" />,
populators: {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider using a more appropriate icon for the login button.

The LogoutIcon is used for the login button, which might confuse users. It's better to use an icon that represents the login action.

If available, use a LoginIcon or a suitable icon:

-          icon: <LogoutIcon className="icon" />,
+          icon: <LoginIcon className="icon" />,

Committable suggestion was skipped due to low confidence.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 396468b and 582b0f9.

📒 Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js (1)

Pattern **/*.js: check

Comment on lines +170 to +171
updatedUrl=isEmployee?url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`): url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`);
history.push(updatedUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use window.contextPath instead of hardcoding /sandbox-ui

To improve maintainability and ensure consistency with the application's context path, consider using window.contextPath instead of hardcoding /sandbox-ui when constructing URLs. This will make your code more adaptable to changes in the context path.

Apply this diff to update the URL construction:

-      updatedUrl=isEmployee?url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`): url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`);
+      updatedUrl = isEmployee
+        ? url.replace(`/${window.contextPath}/employee`, `/${window.contextPath}/${tenantId}/employee`)
+        : url.replace(`/${window.contextPath}/citizen`, `/${window.contextPath}/${tenantId}/citizen`);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
updatedUrl=isEmployee?url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`): url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`);
history.push(updatedUrl);
updatedUrl = isEmployee
? url.replace(`/${window.contextPath}/employee`, `/${window.contextPath}/${tenantId}/employee`)
: url.replace(`/${window.contextPath}/citizen`, `/${window.contextPath}/${tenantId}/citizen`);
history.push(updatedUrl);

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.

3 participants