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

User Token cache remove for multiroottenant and css fix #1506

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

nabeelmd-eGov
Copy link
Contributor

@nabeelmd-eGov nabeelmd-eGov commented Oct 11, 2024

  • remove localStorage for multiroottenant and CSS fixes
  • css version update
  • clear console

Summary by CodeRabbit

  • New Features

    • Introduced new CSS classes for enhanced styling and layout of the sandbox UI.
    • Added a loading indicator with animations for better user feedback.
  • Bug Fixes

    • Improved logic for setting citizen and employee details in local storage based on multi-root tenant functionality.
  • Documentation

    • Updated stylesheet link to the latest version for improved styling consistency.

@nabeelmd-eGov nabeelmd-eGov requested a review from a team as a code owner October 11, 2024 09:55
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

📝 Walkthrough

Walkthrough

The changes introduced in this pull request primarily focus on enhancing the CSS structure and logic for various components within the application. New CSS classes have been added to improve the styling and responsiveness of the UI, particularly for the input and sandbox components. Additionally, conditional checks have been implemented in the login-related JavaScript files to adjust the flow based on the multi-root tenant functionality, ensuring that certain actions are bypassed under specific conditions.

Changes

File Path Change Summary
micro-ui/web/micro-ui-internals/packages/css/src/components/PageBasedInput.scss Added new CSS classes: .digit-page-based-input-wrapper, .digit-page-based-submit-bar, .digit-submit-bar-container, .digit-app-container, .digit-back-link, and .RightMostTopBarOptions. Modified .PageBasedInputWrapper and .digit-card-component to include responsive styles and adjustments.
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js Introduced a conditional check in setCitizenDetail to return early if Digit.Utils.getMultiRootTenant() is true.
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/login.js Added a conditional check in setEmployeeDetail to return early if Digit.Utils.getMultiRootTenant() is true.
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Otp/index.js Implemented a conditional check in setEmployeeDetail to return early if Digit.Utils.getMultiRootTenant() is true.
micro-ui/web/public/index.html Updated the stylesheet link for @egovernments/digit-ui-css from version 1.8.2-beta.40 to 1.8.2-beta.41.

Possibly related PRs

Suggested reviewers

  • jagankumar-egov

🐰 In the garden where styles bloom,
New classes dance, dispelling gloom.
With checks in place, the flow is bright,
A rabbit's joy in CSS delight!
Hopping through code, we make it right! 🌼✨


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.

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

🧹 Outside diff range comments (2)
micro-ui/web/micro-ui-internals/packages/css/src/components/PageBasedInput.scss (1)

Line range hint 1-41: Consider a plan for full migration to new class structure.

While the addition of new classes improves the overall structure and follows better naming conventions, the coexistence of old (.PageBasedInputWrapper) and new (.digit-page-based-input-wrapper) classes may lead to confusion and maintenance challenges in the future.

Consider the following steps for a future refactoring:

  1. Gradually migrate components to use the new class names.
  2. Once all components are migrated, remove the old class definitions.
  3. Ensure that this refactoring is coordinated with any JavaScript/TypeScript files that may be applying these classes dynamically.

This approach will help maintain a consistent styling structure throughout the application and reduce technical debt.

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js (1)

Enhance User Data Handling Consistency Across Scenarios

The Login component continues to utilize localStorage extensively for managing user data, as evidenced by multiple localStorage.setItem calls. This reliance may lead to inconsistencies between multiroottenant and non-multiroottenant scenarios.

Recommendations:

  • Implement a centralized data management service that abstracts away the storage mechanism, allowing flexibility between localStorage and alternative storage solutions based on configuration.
  • Refactor all direct localStorage interactions within the Login component to utilize this service, ensuring consistent user data handling across different tenant configurations.
  • Conduct comprehensive testing to verify that user data is managed correctly in both multiroottenant and single-tenant environments.
🔗 Analysis chain

Line range hint 1-285: Consider a more comprehensive approach to user data handling.

While the change in setCitizenDetail addresses the multiroottenant scenario, the Login component still heavily relies on localStorage for various operations. This might lead to inconsistencies in how user data is handled between multiroottenant and non-multiroottenant scenarios.

Consider refactoring the component to use a more consistent approach for handling user data:

  1. Implement a data management service that can switch between localStorage and an alternative storage method based on the multiroottenant flag.
  2. Update all direct localStorage calls in the component to use this service instead.
  3. This will ensure consistent behavior across different scenarios and make future migrations easier.

To assess the impact of the current implementation, run the following script to identify all localStorage usages in the file:

This will help in identifying areas that might need attention for a more comprehensive solution.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for localStorage usage in the Login component
rg --type js 'localStorage\.' micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js

Length of output: 619

🧰 Tools
🪛 Biome

[error] 20-20: This let declares a variable that is only assigned once.

'locale' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 28d9df2 and 03c8fe3.

⛔ Files ignored due to path filters (1)
  • micro-ui/web/micro-ui-internals/packages/css/package.json is excluded by !**/*.json
📒 Files selected for processing (6)
  • micro-ui/web/micro-ui-internals/packages/css/src/components/PageBasedInput.scss (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/login.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Otp/index.js (2 hunks)
  • micro-ui/web/public/index.html (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/login.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Otp/index.js (1)

Pattern **/*.js: check

🔇 Additional comments (7)
micro-ui/web/public/index.html (1)

10-10: CSS version update looks good.

The update to the CSS version from 1.8.2-beta.40 to 1.8.2-beta.41 aligns with the PR objectives. This change should incorporate the latest styles and potential bug fixes.

To ensure this update doesn't introduce any breaking changes, please run the following verification steps:

  1. Test the UI thoroughly across different pages and components.
  2. Check for any visual regressions or layout issues.
  3. Verify that all interactive elements still function correctly.

You can use the following script to check if there are any other files referencing the old CSS version:

If the script returns any results, those files may need to be updated as well.

✅ Verification successful

CSS version update verified.

All references to digit-ui-css@1.8.2-beta.40 have been successfully updated to 1.8.2-beta.41. No remaining references to the old version were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to the old CSS version

# Test: Search for references to the old CSS version
rg --type html --type javascript --type typescript "digit-ui-css@1.8.2-beta.40"

Length of output: 114


Script:

#!/bin/bash
# Description: Check for any remaining references to the old CSS version

# Test: Search for references to the old CSS version
rg --type html --type js --type ts "digit-ui-css@1.8.2-beta.40"

Length of output: 63

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Otp/index.js (2)

121-121: Approved: Improved formatting.

The addition of a space after the BackLink component improves code readability. This change is in line with good coding practices and doesn't affect the functionality.


Line range hint 1-153: Overall assessment: Changes meet PR objectives.

The modifications in this file successfully address the PR objective of removing localStorage usage for the multiroottenant feature. The implementation is correct and the code remains clean and readable. The suggested minor improvements (adding a comment for clarity) will further enhance the code quality.

🧰 Tools
🪛 Biome

[error] 15-15: This let declares a variable that is only assigned once.

'locale' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js (1)

17-19: 🧹 Nitpick (assertive)

LGTM: Early return for multiroottenant scenario.

The addition of the early return when Digit.Utils.getMultiRootTenant() is true aligns with the PR objective of removing localStorage usage for the multiroottenant feature. This change effectively bypasses localStorage operations in multiroottenant scenarios.

To ensure the multiroottenant functionality is working as expected, please verify:

  1. The behavior when Digit.Utils.getMultiRootTenant() returns true.
  2. How user details are handled in multiroottenant scenarios without localStorage.

Consider adding a comment explaining why localStorage is still used for non-multiroottenant scenarios. This will help maintain clarity for future developers working on this code.

micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss (3)

781-803: Verify the usage of theme(colors.white)

Ensure that theme(colors.white) correctly returns the desired color value. Depending on your SCSS setup or theming function, the syntax might need adjustment. Verify that this usage aligns with your theming conventions.


768-771: ⚠️ Potential issue

Verify the border-left width value for cross-browser compatibility

The border-left is set to 0.031rem, which is approximately 0.5px. Subpixel values may not render consistently across different browsers and devices. Consider using a standard pixel value like 1px or 0.5px for better compatibility.


417-427: 🛠️ Refactor suggestion

Consider reducing the use of !important declarations

The use of !important in styles for .digit-back-link and .digit-card-header can make the CSS harder to maintain and override. Overusing !important can lead to specificity issues. Try to increase the selector specificity or restructure the styles to avoid the need for !important.

⛔ Skipped due to learnings
Learnt from: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#675
File: micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss:33-58
Timestamp: 2024-10-08T20:11:12.539Z
Learning: The use of `!important` in the `.wbh-header-container` and `.guideline-actionbar-content` CSS classes within `microplanning.scss` is necessary to prevent these styles from being overridden.
Learnt from: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#675
File: micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss:33-58
Timestamp: 2024-10-08T20:11:07.772Z
Learning: The use of `!important` in the `.wbh-header-container` and `.guideline-actionbar-content` CSS classes within `microplanning.scss` is necessary to prevent these styles from being overridden.
Learnt from: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#675
File: micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss:649-652
Timestamp: 2024-10-08T20:11:07.772Z
Learning: The use of `!important` in the `.excel-wrapper` CSS class is necessary to prevent the styles from being overridden in certain contexts.
Learnt from: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#675
File: micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss:649-652
Timestamp: 2024-10-08T20:11:12.539Z
Learning: The use of `!important` in the `.excel-wrapper` CSS class is necessary to prevent the styles from being overridden in certain contexts.
Learnt from: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#876
File: micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss:86-97
Timestamp: 2024-10-08T20:11:07.772Z
Learning: The use of `!important` in the `.modal-header` CSS class within `microplanning.scss` is necessary to ensure the styles are applied as intended and are not overridden by other styles.
Learnt from: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#876
File: micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss:86-97
Timestamp: 2024-06-15T11:20:20.645Z
Learning: The use of `!important` in the `.modal-header` CSS class within `microplanning.scss` is necessary to ensure the styles are applied as intended and are not overridden by other styles.
Learnt from: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#675
File: micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss:33-58
Timestamp: 2024-05-23T05:31:54.468Z
Learning: The use of `!important` in the `.wbh-header-container` and `.guideline-actionbar-content` CSS classes within `microplanning.scss` is necessary to prevent these styles from being overridden.

Comment on lines +13 to +21
.digit-page-based-input-wrapper {
.digit-page-based-submit-bar {
@apply hidden;
}
.digit-submit-bar-container {
z-index: 60;
@apply p-sm fixed w-full bottom-0 left-0 text-right bg-white;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Approve new class structure with a minor suggestion.

The new .digit-page-based-input-wrapper class and its children are well-structured and follow better CSS naming conventions. This refactoring improves the separation of concerns and allows for more specific styling.

Consider adding a comment explaining the purpose of the .digit-page-based-submit-bar class, as it's currently set to hidden without any apparent use.

Comment on lines +23 to +27
.digit-page-based-input-wrapper {
.digit-submit-bar-container {
@apply hidden;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Approve desktop styles with a suggestion for consistency.

The addition of desktop-specific styles for the new .digit-page-based-input-wrapper class is appropriate and consistent with the existing responsive design approach.

For better consistency and maintainability, consider consolidating the desktop styles for both the new and existing classes. You could move the .PageBasedInputWrapper styles inside the .digit-page-based-input-wrapper block, like this:

@screen dt {
  .digit-page-based-input-wrapper {
    .digit-submit-bar-container {
      @apply hidden;
    }
    .PageBasedInputWrapper {
      .SubmitBar {
        @apply hidden;
      }
      .SubmitBarInCardInDesktopView {
        @apply block;
      }
      .card {
        max-width: 960px;
      }
      button {
        max-width: 240px;
      }
    }
  }
}

This structure would make it clearer that all these styles are related to the same component and its variations.

Comment on lines +12 to +14
if (Digit.Utils.getMultiRootTenant()) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Approved: Early return for multi-root tenant scenario.

The addition of the early return when Digit.Utils.getMultiRootTenant() is true aligns with the PR objective of removing localStorage usage for the multiroottenant feature. This change effectively prevents setting employee details in localStorage when multi-root tenant functionality is active.

Consider adding a comment explaining the implications of this early return. For example:

if (Digit.Utils.getMultiRootTenant()) {
  // Skip setting employee details in localStorage for multi-root tenant scenarios
  // Note: Ensure that any code relying on these localStorage values has appropriate fallbacks
  return;
}

This will help other developers understand the purpose and potential impact of this condition.

Comment on lines +10 to +12
if (Digit.Utils.getMultiRootTenant()) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM! Consider adding a comment for clarity.

The changes align well with the PR objective of removing localStorage usage for the multiroottenant feature. The early return effectively prevents unnecessary localStorage operations when the multiroottenant functionality is active.

Consider adding a brief comment explaining why we're returning early for multiroottenant scenarios:

 if (Digit.Utils.getMultiRootTenant()) {
+  // Skip localStorage operations for multiroottenant scenarios
   return;
 }
📝 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
if (Digit.Utils.getMultiRootTenant()) {
return;
}
if (Digit.Utils.getMultiRootTenant()) {
// Skip localStorage operations for multiroottenant scenarios
return;
}

Comment on lines +765 to +767
.digit-card-component.digit-landing-page-card {
max-width: 30rem !important;
}
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

Minimize the use of !important in CSS

In the .digit-card-component.digit-landing-page-card, the max-width property is set with !important. Consider whether the !important is necessary here, as it can complicate maintenance and override of styles.

Comment on lines +772 to +779
@media (max-width: 768px) {
.homeWrapper > :last-child {
margin-left: 1rem !important;
}
.digit-landing-page-wrapper {
margin-left: 1rem !important;
}
}
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

Refactor media query selectors to reduce redundancy

Both .homeWrapper > :last-child and .digit-landing-page-wrapper have the same margin-left property within the media query. You can combine them to simplify the CSS:

@media (max-width: 768px) {
  .homeWrapper > :last-child,
  .digit-landing-page-wrapper {
    margin-left: 1rem !important;
  }
}

@jagankumar-egov jagankumar-egov merged commit f24226a into develop Oct 11, 2024
3 checks passed
@jagankumar-egov jagankumar-egov deleted the cache-remove branch October 11, 2024 10:05
This was referenced Oct 16, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 30, 2024
This was referenced Nov 20, 2024
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