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

UX Enhancement for Middleware Override Workflow #9358

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

saikiranpatil
Copy link

@saikiranpatil saikiranpatil commented Dec 10, 2024

Proposed Changes

  • Closes UX Enhancement for Middleware Override Workflow. #8335

  • Changes
    image

    • When the asset configuration is pre-filled from the location management or facility page, instead of making the user hover over the exclamation mark, add fine text below the input box, along with the pre-filled middleware placeholder, to provide details about the middleware's source.

    image

    • In the location creation form, under the middleware field, add fine text indicating that if left blank, the facility middleware will be applied to assets.

    image

    • In the location management card, display the facility configuration middleware with a "Pre-filled Facility Middleware" badge if no middleware is set for the location.

    image

    • Under the facility configuration middleware field, add fine text stating that the facility middleware will be applied to all assets when asset and location middleware are Unspecified.

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Introduced a new message display feature in form fields to enhance user feedback.
    • Added guidance messages for middleware address fields in various components.
  • Bug Fixes

    • Retained error handling for invalid IP addresses in relevant components.
  • Refactor

    • Streamlined UI by replacing tooltips with message properties in form fields for better clarity.
  • Chores

    • Updated component interfaces to support new messaging capabilities.

prefilled middleware displayed as message in asset congiguration, added new attributes `message` and `messageClass` to `FormFeild` component`
add fine default behaviour text in facility configuration page
@saikiranpatil saikiranpatil requested a review from a team as a code owner December 10, 2024 18:56
Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Warning

Rate limit exceeded

@saikiranpatil has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e5d881e and d7e4a45.

📒 Files selected for processing (1)
  • src/components/Form/FormFields/FormField.tsx (5 hunks)

Walkthrough

The changes in this pull request involve modifications across several components to enhance the user interface by replacing tooltips with direct message displays in form fields. Specifically, the TextFormField component in HL7Monitor.tsx, ConfigureCamera.tsx, and other components has been updated to show contextual messages instead of tooltips. Additionally, new properties have been added to support these changes, and a new component for displaying messages has been introduced. The overall functionality and control flow of the components remain unchanged.

Changes

File Path Change Summary
src/components/Assets/AssetType/HL7Monitor.tsx Replaced tooltip with a message in TextFormField for middleware hostname; retained error handling for IP address input.
src/components/CameraFeed/ConfigureCamera.tsx Replaced tooltip with a message in TextFormField for middleware hostname; overall structure and error handling remain unchanged.
src/components/Facility/AddLocationForm.tsx Added a message to TextFormField for middleware address input to provide guidance on leaving it blank.
src/components/Facility/FacilityConfigure.tsx Added a message to TextFormField for middleware address input to clarify its application to all assets.
src/components/Facility/LocationManagement.tsx Added facilityMiddleware property to LocationProps; updated state management and rendering logic to display middleware addresses.
src/components/Form/FormFields/FormField.tsx Introduced FieldMessageText component for displaying messages; updated FormField to include this new component.
src/components/Form/FormFields/Utils.ts Added message and messageClassName properties to FormFieldBaseProps type to support new messaging capabilities.

Assessment against linked issues

Objective Addressed Explanation
Add fine text below the input box for pre-filled middleware (related to #8335)
In the location creation form, add fine text indicating that leaving blank applies facility middleware (related to #8335)
Under the facility configuration middleware field, add fine text regarding application to all assets (related to #8335)

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • Jacobjeevan
  • rithviknishad

🐇 In the fields where we play,
Messages guide us on our way.
Tooltips gone, clarity's here,
In every form, we cheer and cheer!
With each change, our paths align,
A smoother journey, oh how fine! 🌼


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. (Experiment)
  • @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 10, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit d7e4a45
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/675a914b2afa6f00082a6d50
😎 Deploy Preview https://deploy-preview-9358--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: 1

🧹 Outside diff range and nitpick comments (1)
src/components/Assets/AssetType/HL7Monitor.tsx (1)

105-109: Consider enhancing message clarity and maintainability

While the implementation works, consider these improvements:

  1. Use an enum or constant for the "asset" source type
  2. Structure the message text for better maintainability
+ const MIDDLEWARE_SOURCE = {
+   ASSET: "asset"
+ } as const;
+
+ const getMiddlewareMessage = (source?: string) => {
+   return source && source !== MIDDLEWARE_SOURCE.ASSET
+     ? `Middleware hostname sourced from ${source}`
+     : undefined;
+ };

  <TextFormField
    message={
-     resolvedMiddleware?.source != "asset"
-       ? `Middleware hostname sourced from asset ${resolvedMiddleware?.source}`
-       : undefined
+     getMiddlewareMessage(resolvedMiddleware?.source)
    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b25ecd0 and 937e6fd.

📒 Files selected for processing (7)
  • src/components/Assets/AssetType/HL7Monitor.tsx (1 hunks)
  • src/components/CameraFeed/ConfigureCamera.tsx (1 hunks)
  • src/components/Facility/AddLocationForm.tsx (1 hunks)
  • src/components/Facility/FacilityConfigure.tsx (1 hunks)
  • src/components/Facility/LocationManagement.tsx (5 hunks)
  • src/components/Form/FormFields/FormField.tsx (2 hunks)
  • src/components/Form/FormFields/Utils.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/components/Facility/AddLocationForm.tsx
  • src/components/Facility/FacilityConfigure.tsx
🔇 Additional comments (8)
src/components/Form/FormFields/Utils.ts (1)

23-23: LGTM: Type definitions for new message properties

The addition of message and messageClassName optional properties to FormFieldBaseProps provides a clean way to support the new messaging functionality while maintaining backward compatibility.

Also applies to: 27-27

src/components/Form/FormFields/FormField.tsx (2)

51-68: LGTM: Well-structured message component implementation

The FieldMessageText component follows established patterns and includes proper transition effects. The use of primary-400 color effectively distinguishes informative messages from error text.


95-98: LGTM: Clean integration of message component

The message component is properly integrated into the FormField component, maintaining consistency with the existing error text display pattern.

src/components/Assets/AssetType/HL7Monitor.tsx (1)

105-109: Verify consistent middleware source handling

Let's ensure the middleware source message implementation is consistent across all relevant components.

✅ Verification successful

Middleware source handling is consistent across components

The implementation is consistent with other components in the codebase:

  • Both ConfigureCamera.tsx and HL7Monitor.tsx use the same pattern to display middleware source messages
  • Both check resolvedMiddleware?.source != "asset" condition
  • Both provide informative messages about the source of middleware hostname
  • Other middleware-related messages in FacilityConfigure.tsx and AddLocationForm.tsx serve different purposes and don't need this specific source handling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other components that might need similar middleware source handling
rg -l "middleware.*source|resolvedMiddleware" --type ts --type tsx

# Look for existing message implementations in form fields
rg "message[=:].*middleware" --type ts --type tsx

Length of output: 176


Script:

#!/bin/bash
# Search for other components that might need similar middleware source handling
rg -t typescript -t javascriptreact -t typescriptreact -l "middleware.*source|resolvedMiddleware"

# Look for existing message implementations in form fields
rg -t typescript -t javascriptreact -t typescriptreact "message[=:].*middleware"

Length of output: 252


Script:

#!/bin/bash
# First, let's find all TypeScript and React files that might contain middleware source handling
fd -e ts -e tsx | xargs rg -l "middleware.*source|resolvedMiddleware"

# Then search for message implementations related to middleware
fd -e ts -e tsx | xargs rg "message[=:].*middleware"

Length of output: 510


Script:

#!/bin/bash
# Let's examine the middleware source handling in ConfigureCamera.tsx
rg -A 5 -B 5 "middleware.*source|resolvedMiddleware" src/components/CameraFeed/ConfigureCamera.tsx

# And check the specific implementation in HL7Monitor.tsx for comparison
rg -A 5 -B 5 "middleware.*source|resolvedMiddleware" src/components/Assets/AssetType/HL7Monitor.tsx

Length of output: 2218

src/components/Facility/LocationManagement.tsx (3)

30-30: LGTM: Clean implementation of facility middleware state management

The implementation properly handles facility middleware through well-typed props and efficient state management using React hooks.

Also applies to: 46-57


286-293: LGTM: Clear and informative middleware source display

The implementation effectively communicates the middleware source to users, aligning with the PR's UX enhancement goals.


298-298: LGTM: Well-structured middleware fallback logic

The implementation properly handles the middleware address display hierarchy, falling back to facility middleware when appropriate.

src/components/CameraFeed/ConfigureCamera.tsx (1)

154-161: LGTM: Improved middleware source visibility

The implementation effectively replaces tooltips with direct messages, improving user experience by making middleware source information immediately visible.

src/components/Facility/LocationManagement.tsx Outdated Show resolved Hide resolved
@saikiranpatil
Copy link
Author

@ohcnetwork/care-fe-code-reviewers @nihal467 please review this PR

@Jacobjeevan
Copy link
Contributor

I don't think the color scheme fits with rest of the UI 🤔 Plus, we should probably add the note as a badge on Location management page. I'll ping the design team in Slack for feedback.

@rithviknishad
Copy link
Member

Let's also switch to using shadcn's input fields from the ui directory!

@saikiranpatil
Copy link
Author

I don't think the color scheme fits with rest of the UI 🤔 Plus, we should probably add the note as a badge on Location management page. I'll ping the design team in Slack for feedback.

agreed,
i changed text to badge in location management as below
image

@github-actions github-actions bot added needs-triage question Further information is requested labels Dec 12, 2024
@saikiranpatil
Copy link
Author

i also tried to change the color to gray (color used in few elements) as below, let me know if looks better
image

@saikiranpatil
Copy link
Author

Let's also switch to using shadcn's input fields from the ui directory!

@rithviknishad were the recent changes made as expected?

</p>
</span>
{!middleware_address && facilityMiddleware && (
<span className="ml-2 mt-2 text-xs h-fit rounded-full border-2 border-primary-500 bg-primary-100 px-3 py-[3px]">
Copy link
Contributor

@Jacobjeevan Jacobjeevan Dec 12, 2024

Choose a reason for hiding this comment

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

Make use of the badge component (src/components/ui) here instead of custom logic.

As for the UI feedback, I'd wait for design team to respond.

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.

UX Enhancement for Middleware Override Workflow.
3 participants