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

FEATURE/HCMPRE-0000 : fixed import issues of new ui-components #2153

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

Swathi-eGov
Copy link
Contributor

@Swathi-eGov Swathi-eGov commented Jan 23, 2025

Choose the appropriate template for your PR:

Feature PR

Feature Request

JIRA ID

Module

Description

Related Issues


Bugfix PR

Bugfix Request

JIRA ID

Module

Description

Root Cause

Related Issues


Release PR

Summary by CodeRabbit

  • New Features

    • Updated changelog for version 1.8.19
    • Replaced various UI components with new versions from the component library
  • Bug Fixes

    • Corrected spelling errors in previous changelog versions
    • Resolved accessibility and stability issues
  • Component Updates

    • Replaced MobileSidebar with MobileSideNav
    • Replaced Sidebar with SideNav
    • Replaced ActionBar with Footer
    • Replaced Uploader with FileUpload
  • Improvements

    • Enhanced user interface components
    • Updated file upload functionality

@Swathi-eGov Swathi-eGov requested a review from a team as a code owner January 23, 2025 11:58
Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

📝 Walkthrough

Walkthrough

This pull request involves updates to multiple components across the micro-ui project, primarily focusing on component replacements and import changes. The modifications include switching from MobileSidebar to MobileSideNav in CitizenSideBar, replacing Sidebar with SideNav in EmployeeSideBar, substituting ActionBar with Footer in UserProfile, and changing Uploader to FileUpload in configuration and logo uploader components. The changelog for version 1.8.19 has also been updated to reflect these changes and fix previous spelling errors.

Changes

File Change Summary
core/CHANGELOG.md Added version 1.8.19 entry, corrected spelling of "Fixed" in previous versions
core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js Replaced MobileSidebar with MobileSideNav
core/src/components/TopBarSideBar/SideBar/EmployeeSideBar.js Replaced Sidebar with SideNav
core/src/pages/citizen/Home/UserProfile.js Replaced ActionBar with Footer
sandbox/src/pages/employee/tenantMgmt/ConfigUploaderComponent.js Replaced Uploader with FileUpload, changed variant from "uploadFile" to "uploadField"
sandbox/src/pages/employee/tenantMgmt/LogoUploaderComponent.js Replaced Uploader with FileUpload, changed variant from "uploadFile" to "uploadField"

Possibly related PRs

Suggested Reviewers

  • nipunarora-eGov
  • jagankumar-egov

Poem

🐰 Hop, hop, through code's green lane,
Components dance, a refactored refrain!
MobileSidebar waves goodbye,
SideNav and FileUpload now fly high
A changelog's tale of digital delight 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

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

🔭 Outside diff range comments (4)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/ConfigUploaderComponent.js (2)

Line range hint 58-67: Clean up commented code and consider component consolidation.

  1. Remove the commented code for consistency.
  2. Consider refactoring LogoUploaderComponent and ConfigUploaderComponent into a single reusable component as they share nearly identical code.

Example refactor approach:

// FileUploaderComponent.js
const FileUploaderComponent = ({ 
  onSelect, 
  componentName, 
  uploadLabel, 
  errorLabel, 
  ...props 
}) => {
  // ... shared state and functions ...
  
  return (
    <>
      <LabelFieldPair className={"uploader-label-field"}>
        <CardLabel>{t(uploadLabel)}</CardLabel>
        <FileUpload
          uploadedFiles={[]}
          variant="uploadField"
          onUpload={(files) => selectFile(files)}
          iserror={uploadErrorMessage}
          accept=".jpg, .png, .jpeg"
        />
      </LabelFieldPair>
      {/* ... Toast component ... */}
    </>
  );
};

// Usage:
<FileUploaderComponent
  componentName="LogoUploaderComponent"
  uploadLabel="LOGO_UPLOAD_LABEL"
  errorLabel="LOGO_UPLOAD_FAILED"
  onSelect={onSelect}
  {...props}
/>

Line range hint 1-82: Consider implementing proper TypeScript types.

Both components would benefit from TypeScript types for better maintainability and type safety, especially given their identical structure and prop usage.

Example type definitions:

interface FileUploaderProps {
  onSelect: (
    componentName: string, 
    data: { fileStoreId: string; type: string }
  ) => void;
  config?: {
    customProps?: {
      type: string;
    };
  };
}
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/EmployeeSideBar.js (1)

Line range hint 136-149: Consider optimizing the sort function.

The sortDataByOrderNumber function recursively sorts data but could be optimized:

  1. It mutates the input array directly
  2. The Infinity fallback might cause unexpected ordering

Consider this immutable approach:

-const sortDataByOrderNumber = (data) => {
-  data.sort((a, b) => {
-    const aOrder = a.orderNumber !== undefined ? a.orderNumber : Infinity;
-    const bOrder = b.orderNumber !== undefined ? b.orderNumber : Infinity;
-    return aOrder - bOrder;
-  });
-  data.forEach((item) => {
-    if (item.children && item.children.length > 0) {
-      sortDataByOrderNumber(item.children);
-    }
-  });
-  return data;
+const sortDataByOrderNumber = (data) => {
+  return [...data].sort((a, b) => {
+    const aOrder = a.orderNumber ?? Number.MAX_SAFE_INTEGER;
+    const bOrder = b.orderNumber ?? Number.MAX_SAFE_INTEGER;
+    return aOrder - bOrder;
+  }).map(item => ({
+    ...item,
+    children: item.children?.length > 0 
+      ? sortDataByOrderNumber(item.children)
+      : item.children
+  }));
};
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js (1)

Line range hint 31-39: Consider extracting validation configuration.

The default validation configuration could be moved to a separate configuration file for better maintainability.

+// validationConfig.js
+export const defaultValidationConfig = {
+  tenantId: `${Digit.ULBService.getStateId()}`,
+  UserProfileValidationConfig: [{
+    name: "/^[a-zA-Z ]+$/i",
+    mobileNumber: "/^[6-9]{1}[0-9]{9}$/",
+    password: "/^([a-zA-Z0-9@#$%]{8,15})$/i",
+  }],
+};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 835c717 and 3e530d4.

⛔ Files ignored due to path filters (5)
  • micro-ui/web/micro-ui-internals/example/package.json is excluded by !**/*.json
  • micro-ui/web/micro-ui-internals/packages/modules/core/package.json is excluded by !**/*.json
  • micro-ui/web/package.json is excluded by !**/*.json
  • micro-ui/web/sandbox/package.json is excluded by !**/*.json
  • micro-ui/web/workbench/package.json is excluded by !**/*.json
📒 Files selected for processing (6)
  • micro-ui/web/micro-ui-internals/packages/modules/core/CHANGELOG.md (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/EmployeeSideBar.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/ConfigUploaderComponent.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/LogoUploaderComponent.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/EmployeeSideBar.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/CitizenSideBar.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/LogoUploaderComponent.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/ConfigUploaderComponent.js (1)

Pattern **/*.js: check

🪛 Markdownlint (0.37.0)
micro-ui/web/micro-ui-internals/packages/modules/core/CHANGELOG.md

3-3: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


4-4: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

🪛 Biome (1.9.4)
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js

[error] 895-895: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (8)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/LogoUploaderComponent.js (2)

2-2: LGTM: Import change aligns with UI component updates.

The change from Uploader to FileUpload aligns with the component replacement initiative.


Line range hint 55-64: Clean up commented code and verify component behavior.

A few suggestions:

  1. Remove the commented code as it's no longer needed and might cause confusion.
  2. Verify that setting uploadedFiles to an empty array doesn't affect the display of previously uploaded files.
✅ Verification successful

Remove commented code as it's redundant with the useEffect implementation

The commented code can be safely removed because:

  • The same file upload handling is already implemented in the useEffect hook
  • The pattern of using empty array for uploadedFiles is consistent with other similar components in the codebase
  • Previously uploaded files are managed separately through the component's state management
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of FileUpload to verify consistent usage
rg -U "FileUpload.*uploadedFiles" --type js

Length of output: 45


Script:

#!/bin/bash
# Search for FileUpload component usage with broader pattern
echo "=== FileUpload Component Usage ==="
rg -U "FileUpload" --type js -A 5

# Search for file upload related patterns
echo -e "\n=== File Upload Patterns ==="
rg -U "onUpload|handleUpload|uploadFile" --type js -A 3

# Search for FileUpload component definition
echo -e "\n=== FileUpload Component Definition ==="
fd -e js -e jsx FileUpload

Length of output: 47266

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/ConfigUploaderComponent.js (1)

2-2: LGTM: Import change consistent with LogoUploaderComponent.

The change from Uploader to FileUpload maintains consistency across components.

micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/EmployeeSideBar.js (2)

2-2: Component import updated correctly.

The SideNav component has been imported from the correct package to replace the old Sidebar component.


Line range hint 167-179: Verify the SideNav component props.

The component migration from Sidebar to SideNav looks good, but some props have empty string values which might affect the component's behavior:

  • transitionDuration=""
  • expandedWidth=""
  • collapsedWidth=""
✅ Verification successful

Empty string props in SideNav component are acceptable

The transitionDuration, expandedWidth, and collapsedWidth props are optional styling parameters. Empty string values will fall back to the component's internal defaults, which is acceptable behavior especially within a responsive layout.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for SideNav component usage to verify prop values
ast-grep --pattern 'SideNav transitionDuration={$_}'

Length of output: 54


Script:

#!/bin/bash
# Search for SideNav component definition and usage
echo "=== Looking for SideNav component definition ==="
ast-grep --pattern 'export $_ function SideNav'
ast-grep --pattern 'export $_ class SideNav'

echo -e "\n=== Looking for SideNav imports ==="
rg "import.*SideNav" -A 2

echo -e "\n=== Looking for SideNav usage patterns ==="
rg "<SideNav" -A 5 -B 1

Length of output: 2496

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

9-9: Component import updated correctly.

The MobileSideNav component has been imported from the correct package.


Line range hint 408-420: Verify mobile navigation behavior.

The mobile navigation implementation looks good, but ensure that the profile image handling is consistent with the new component's requirements.

✅ Verification successful

Profile image handling is implemented correctly

The profile image implementation in MobileSideNav follows best practices for optional prop handling, using a safe conditional pattern that passes undefined when no profile image is available.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for MobileSideNav usage patterns
ast-grep --pattern 'MobileSideNav profile={$_}'

Length of output: 49


Script:

#!/bin/bash
# Search for MobileSideNav component definition and usage
ast-grep --pattern 'const MobileSideNav = $_'

# Backup search using ripgrep
echo "=== Searching for MobileSideNav usage ==="
rg "MobileSideNav" -A 5 -B 5

# Search for the component file
echo "=== Looking for MobileSideNav file ==="
fd "MobileSideNav" --type f

Length of output: 3504

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

12-12: Component import updated correctly.

The Footer component has been imported from the correct package.

@jagankumar-egov jagankumar-egov merged commit 5194677 into develop Jan 23, 2025
5 checks passed
@jagankumar-egov jagankumar-egov deleted the FEATURE/HCMPRE-0000 branch January 23, 2025 12:06
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