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

Disable facility editing #1833

Open
wants to merge 4 commits into
base: console
Choose a base branch
from
Open

Disable facility editing #1833

wants to merge 4 commits into from

Conversation

ashish-egov
Copy link
Contributor

@ashish-egov ashish-egov commented Nov 14, 2024

Summary by CodeRabbit

  • New Features

    • Introduced editingDisabled prop in AccessibilityPopUp and SecurityPopUp components to control editability.
    • Dropdowns and radio buttons now conditionally disable based on the editingDisabled state.
  • Bug Fixes

    • Updated save button logic to consider editingDisabled along with existing conditions for enabling/disabling.
  • Documentation

    • Method signatures for AccessibilityPopUp and SecurityPopUp components have been updated to include the new editingDisabled prop.

@ashish-egov ashish-egov requested a review from a team as a code owner November 14, 2024 13:02
Copy link
Contributor

coderabbitai bot commented Nov 14, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request introduce the editingDisabled prop to the AccessibilityPopUp and SecurityPopUp components, allowing for conditional disabling of UI elements based on this prop's value. The FacilityPopup component also receives this prop, enhancing its functionality by preventing editing within the pop-ups. These modifications do not alter the existing logic or structure of the components but enhance user interaction management by controlling editability.

Changes

File Change Summary
.../FacilityPopup.js Added editingDisabled prop to AccessibilityPopUp and SecurityPopUp, set to true.
.../accessbilityPopUP.js Introduced editingDisabled prop (default false), affecting dropdowns and save button logic.
.../securityPopUp.js Added editingDisabled prop (default false), affecting radio buttons and save button logic.

Possibly related PRs

  • Facility mapper #1590: The SecurityPopUp component has been modified to include an additional prop, editingDisabled, which is relevant to the changes made in the main PR regarding the editingDisabled prop in the SecurityPopUp component.
  • Added action bar for pop inbox screen #1622: The AccessibilityPopUp component has been updated to include the editingDisabled prop, which aligns with the changes made in the main PR that introduced this prop to the AccessibilityPopUp component.
  • Changes regarding facility catchment popup #1741: The FacilityPopup component has been modified to include an additional prop, updateDetails, which relates to the changes in the main PR that also involve modifications to the FacilityPopup component.
  • Facility data fix #1829: The FacilityMappingConfig has been updated to include a new property for MICROPLAN_FACILITY_SERVINGPOPULATION, which is relevant to the changes in the main PR that involve the FacilityPopup component and its interaction with facility data.

Suggested reviewers

  • nipunarora-eGov

🐰 In the pop-up bright and clear,
Editing's gone, that much is clear.
With props that guide and dropdowns neat,
Our UI's now a treat to greet!
So hop along, let changes flow,
In our micro world, we’ll surely grow! 🌟


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

🧹 Outside diff range comments (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/accessbilityPopUP.js (1)

Line range hint 1-179: Consider adding error boundary protection

Since this component handles API mutations and state management, consider wrapping it with an error boundary to gracefully handle runtime errors, especially during API calls or state updates.

Example implementation:

class AccessibilityPopUpErrorBoundary extends React.Component {
  state = { hasError: false };
  
  static getDerivedStateFromError(error) {
    return { hasError: true };
  }
  
  render() {
    if (this.state.hasError) {
      return <div>Error loading accessibility settings</div>;
    }
    return this.props.children;
  }
}

// Usage:
<AccessibilityPopUpErrorBoundary>
  <AccessibilityPopUp {...props} />
</AccessibilityPopUpErrorBoundary>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 5b8e5e0 and 9d925f3.

📒 Files selected for processing (3)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/accessbilityPopUP.js (4 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/securityPopUp.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/accessbilityPopUP.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/securityPopUp.js (1)

Pattern **/*.js: check

🔇 Additional comments (4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/securityPopUp.js (1)

119-119: LGTM! Radio buttons disabled state implementation looks good.

The disabled state is correctly implemented using the editingDisabled prop.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/accessbilityPopUP.js (2)

7-7: LGTM: Clean prop addition with backward compatibility

The new editingDisabled prop with default false is well-implemented and maintains backward compatibility for existing usage.


118-118: LGTM: Consistent dropdown disabling implementation

The disabled prop is consistently applied to both dropdowns, providing a uniform editing restriction mechanism.

Also applies to: 130-130

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (1)

437-437: LGTM: Consistent implementation of editing restrictions

The addition of editingDisabled={true} to both AccessibilityPopUp and SecurityPopUp components aligns with the PR objective to disable facility editing. The implementation is consistent across both popups, ensuring a uniform user experience.

Let's verify that the editingDisabled prop is properly handled in the popup components:

Also applies to: 444-444

✅ Verification successful

The editingDisabled prop is properly implemented and used correctly

The verification confirms that both AccessibilityPopUp and SecurityPopUp components properly implement the editingDisabled prop:

  1. Both components accept editingDisabled with a default value of false
  2. The prop is correctly used to:
    • Disable radio buttons in SecurityPopUp
    • Disable dropdown selections in AccessibilityPopUp
    • Disable the save buttons in both components

The implementation in FacilityPopup.js passing editingDisabled={true} is consistent with the intended behavior to prevent editing.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check implementation of editingDisabled prop in popup components
# Expected: Find the prop usage in both AccessibilityPopUp and SecurityPopUp components

# Search for the editingDisabled prop implementation
rg -l "editingDisabled.*prop|interface.*editingDisabled" --type js

# Check the components' implementation
ast-grep --pattern 'const $name = ({ $$$, editingDisabled, $$$ }) => {
  $$$
}'

Length of output: 150


Script:

#!/bin/bash
# Let's try a broader search for the popup components and their props
# First, find the relevant popup component files
fd -e js -e jsx "Popup|PopUp" 

# Then search for editingDisabled usage with more context
rg -A 5 -B 5 "editingDisabled" --type js

# Also search for the specific component names mentioned in FacilityPopup
rg -A 5 -B 5 "AccessibilityPopUp|SecurityPopUp" --type js

Length of output: 27986

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.

1 participant