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

Enhanced the Asset Page header layout #9472

Closed

Conversation

manmeetnagii
Copy link
Contributor

@manmeetnagii manmeetnagii commented Dec 17, 2024

Proposed Changes

image

Screenshot 2024-12-17 151847

@ohcnetwork/care-fe-code-reviewers

Summary by CodeRabbit

  • New Features

    • Introduced a new search interface allowing users to filter assets by name, serial number, and QR code ID.
    • Enhanced filtering capabilities for a more comprehensive search experience.
  • Bug Fixes

    • Resolved issues with state management related to search functionality.
  • UI Improvements

    • Updated layout and rendering logic for better user interface and experience.
    • Removed the previous search input component to streamline the search process.

@manmeetnagii manmeetnagii requested a review from a team as a code owner December 17, 2024 09:49
Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Walkthrough

The pull request modifies the AssetsList component in src/components/Assets/AssetsList.tsx, focusing on enhancing the search and filtering capabilities. The changes introduce a new SearchByMultipleFields component, update the useFilters hook configuration, and modify the search functionality to allow filtering by name, serial number, and QR code ID. The component's layout and rendering logic are adjusted to accommodate these new search parameters while maintaining the existing asset management features.

Changes

File Change Summary
src/components/Assets/AssetsList.tsx - Added import for SearchByMultipleFields
- Updated useFilters hook with new search parameters
- Modified params object to handle new query parameters
- Replaced SearchInput with SearchByMultipleFields
- Adjusted component layout and search interface

Assessment against linked issues

Objective Addressed Explanation
Update button layout in Assets Page [#9349] The changes do not address the button layout as specified in the issue.

Suggested reviewers

  • rithviknishad

Poem

🐰 Hop, hop, through assets we go,
Searching wide with filters in tow
Serial numbers, names so bright
QR codes dancing in our sight
A rabbit's search, now swift and clear! 🔍


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

netlify bot commented Dec 17, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 6e57357
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67614e71bcfb510007768c1d
😎 Deploy Preview https://deploy-preview-9472--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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)
src/components/Assets/AssetsList.tsx (1)

Line range hint 351-464: Consider optimizing the nested layout structure

While the layout improvements align with the PR objectives, consider simplifying the nested div structure for better maintainability.

Consider this simplified structure:

-<div className="flex w-full flex-col gap-2 items-center justify-between lg:flex-row">
-  <div className="flex flex-col w-full lg:w-auto md:flex-row">
+<div className="grid grid-cols-1 lg:grid-cols-2 gap-2 w-full items-center">
+  <div className="flex flex-col md:flex-row w-full lg:w-auto">
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 10bfd6c and 4d9be38.

📒 Files selected for processing (1)
  • src/components/Assets/AssetsList.tsx (6 hunks)
🔇 Additional comments (4)
src/components/Assets/AssetsList.tsx (4)

18-18: LGTM: Search-related configuration changes are well-structured

The addition of SearchByMultipleFields and the corresponding hook configuration with proper cache management for search fields is implemented correctly.

Also applies to: 40-40, 44-44


59-62: LGTM: Search parameters are properly configured

The new search parameters are well-structured with appropriate default values, ensuring clean query parameter handling.


318-343: LGTM: Search options are well-configured with accessibility features

The search configuration includes clear labels, placeholders, and keyboard shortcuts, enhancing user experience and accessibility.


481-481: LGTM: Filter badge integration is consistent

The new name filter badge is properly integrated with the existing filter system.

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

🧹 Nitpick comments (1)
src/components/Assets/AssetsList.tsx (1)

467-473: Consider adding tests for the new search functionality

The new search implementation would benefit from automated tests to verify:

  • Multiple field search behavior
  • Keyboard shortcut functionality
  • Search parameter handling

Would you like me to help create test cases for the new search functionality?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4d9be38 and 6e57357.

📒 Files selected for processing (1)
  • src/components/Assets/AssetsList.tsx (6 hunks)
🔇 Additional comments (3)
src/components/Assets/AssetsList.tsx (3)

11-12: LGTM: Import and hook configuration changes are appropriate

The new imports and hook configuration support the enhanced search functionality. The cacheBlacklist configuration correctly prevents caching of search parameters.

Also applies to: 19-19, 46-46


467-473: LGTM: Search implementation with keyboard shortcuts

The SearchByMultipleFields implementation provides a good user experience with:

  • Multiple search fields for different asset properties
  • Keyboard shortcuts for quick access
  • Clear placeholders for better usability

Line range hint 357-453: LGTM: Improved header layout with responsive design

The new layout structure provides:

  • Better organization of buttons and controls
  • Responsive design that adapts to different screen sizes
  • Consistent spacing and alignment
  • Clear visual hierarchy

<SearchByMultipleFields
id="asset-search"
options={searchOptions}
onSearch={(key, value) => updateQuery({ search: value })}
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

Consider updating search callback to utilize multiple fields

The current onSearch implementation updates a single 'search' query parameter, which doesn't fully utilize the multiple field search capability. Consider updating the search fields individually.

Consider this approach:

-          onSearch={(key, value) => updateQuery({ search: value })}
+          onSearch={(key, value) => updateQuery({ [key]: value })}
📝 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
onSearch={(key, value) => updateQuery({ search: value })}
onSearch={(key, value) => updateQuery({ [key]: value })}

Comment on lines +323 to +348
const searchOptions = [
{
key: "name",
label: "Name",
type: "text" as const,
placeholder: "Search by Name",
value: qParams.name || "",
shortcutKey: "n",
},
{
key: "serial_number",
label: "Serial No.",
type: "text" as const,
placeholder: "Search by Serial No.",
value: qParams.serial_number || "",
shortcutKey: "u",
},
{
key: "asset_qr_id",
label: "QR Code ID",
type: "text" as const,
placeholder: "Search by QR Code ID",
value: qParams.qr_code_id || "",
shortcutKey: "p",
},
];
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 inconsistency in search option key naming

The asset_qr_id key in searchOptions doesn't match the parameter name qr_code_id used in the params object (line 64). This mismatch could cause search functionality to break.

Apply this fix:

-      key: "asset_qr_id",
+      key: "qr_code_id",
📝 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
const searchOptions = [
{
key: "name",
label: "Name",
type: "text" as const,
placeholder: "Search by Name",
value: qParams.name || "",
shortcutKey: "n",
},
{
key: "serial_number",
label: "Serial No.",
type: "text" as const,
placeholder: "Search by Serial No.",
value: qParams.serial_number || "",
shortcutKey: "u",
},
{
key: "asset_qr_id",
label: "QR Code ID",
type: "text" as const,
placeholder: "Search by QR Code ID",
value: qParams.qr_code_id || "",
shortcutKey: "p",
},
];
const searchOptions = [
{
key: "name",
label: "Name",
type: "text" as const,
placeholder: "Search by Name",
value: qParams.name || "",
shortcutKey: "n",
},
{
key: "serial_number",
label: "Serial No.",
type: "text" as const,
placeholder: "Search by Serial No.",
value: qParams.serial_number || "",
shortcutKey: "u",
},
{
key: "qr_code_id",
label: "QR Code ID",
type: "text" as const,
placeholder: "Search by QR Code ID",
value: qParams.qr_code_id || "",
shortcutKey: "p",
},
];

@manmeetnagii
Copy link
Contributor Author

manmeetnagii commented Dec 17, 2024

@nithish1018 previous pulled request was closed by me mistakenly which leads to unassign the issue, can you assign the #9349 again as I am still working on that issue, migrating the dropdown to shadcn dropdown in Export.tsx component as asked

@github-actions github-actions bot added needs-triage question Further information is requested labels Dec 17, 2024
@nithish1018
Copy link
Contributor

Hey @manmeetnagii I can't assign issues.
cc: @rithviknishad @Jacobjeevan can anyone look into this?

@rithviknishad
Copy link
Member

Duplicate of #9466

@rithviknishad rithviknishad marked this as a duplicate of #9466 Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Update the button layout in Assets Page
3 participants