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

BUGFIX/HCMPRE-1585 fixed tootltip icon position according to the label #2010

Merged
merged 2 commits into from
Dec 10, 2024

Conversation

Swathi-eGov
Copy link
Contributor

@Swathi-eGov Swathi-eGov commented Dec 10, 2024

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 CSS styles for improved layout and visual coherence in health UI components.
    • Enhanced error handling and user feedback for formula and assumption management.
    • Improved state management and search functionality in the MultiSelectDropdown component.
  • Bug Fixes

    • Improved validation checks for formula and assumption names to prevent invalid entries.
  • Documentation

    • Updated stylesheet links to the latest version for health UI components.

@Swathi-eGov Swathi-eGov requested a review from a team as a code owner December 10, 2024 10:45
@Swathi-eGov Swathi-eGov changed the title fixed tootltip icon position according to the label BUGFIX/HCMPRE-1585 fixed tootltip icon position according to the label Dec 10, 2024
Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request includes updates to several files, primarily focusing on modifying the stylesheet links in HTML files to a newer version of the CSS for the health UI component. Additionally, there are changes in CSS files that adjust layout properties for specific classes and enhancements to rendering logic and error handling in JavaScript components related to formula and assumption management. These changes aim to improve the visual layout and user experience within the health micro UI.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/example/public/index.html Updated stylesheet link from version 0.2.1 to 0.2.2.
health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss Modified layout properties for classes, added .assumption-label-icon-wrapper-label, and adjusted margins.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FormulaConfiguration.js Enhanced rendering logic, added error handling for formulas, and refined state management.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/Hypothesis.js Updated rendering logic for assumption labels and improved error handling for assumption names.
health/micro-ui/web/public/index.html Updated stylesheet link from version 0.2.1 to 0.2.2.

Possibly related PRs

Suggested reviewers

  • jagankumar-egov

🐇 In the garden, I hop with glee,
Styles updated, as fresh as can be!
With formulas clear and assumptions bright,
Our health UI shines, a beautiful sight!
Let's celebrate changes, both big and small,
A leap towards better, for one and for all! 🌼


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
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 (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FormulaConfiguration.js (2)

Line range hint 516-584: Consider consolidating validation logic

The validation checks for formula names are comprehensive but scattered. Consider extracting them into a separate validation function for better maintainability.

Here's a suggested refactor:

+ const validateFormulaInput = (selectedFormula) => {
+   if (!selectedFormula) {
+     return { isValid: false, error: "ERR_FORMULA_SELECT_OPTION" };
+   }
+   if (!selectedFormula?.name && selectedFormula?.code === "NEW_FORMULA") {
+     return { isValid: false, error: "ERR_FORMULA_ENTER_FORMULA_NAME" };
+   }
+   if (selectedFormula?.code === "NEW_FORMULA" && selectedFormula?.name?.length > 100) {
+     return { isValid: false, error: "SELECT_FORMULA_NAME_LONG_THAN_100" };
+   }
+   if (category !== "FORMULA_CAMPAIGN_VEHICLES" && filteredFormulas.some((i) => i.output === selectedFormula?.name)) {
+     return { isValid: false, error: "FORMULA_ALREADY_PRESENT" };
+   }
+   return { isValid: true };
+ };

- if(!selectedDeletedFormula){
-   setShowToast({
-     key: "error",
-     label: t("ERR_FORMULA_SELECT_OPTION"),
-     transitionTime: 3000,
-     style: { zIndex: 1000000 },
-   });
-   return;
- }
- // ... other validation checks ...

+ const validationResult = validateFormulaInput(selectedDeletedFormula);
+ if (!validationResult.isValid) {
+   setShowToast({
+     key: "error",
+     label: t(validationResult.error),
+     transitionTime: 3000,
+     style: { zIndex: 1000000 },
+   });
+   return;
+ }

Line range hint 196-284: Optimize state management in addNewFormula

The state management in addNewFormula could be improved to be more efficient and maintainable:

  1. Consider using useReducer for complex state updates
  2. Batch related state updates
  3. Remove commented code to improve readability

Here's a suggested approach:

+ const formulaReducer = (state, action) => {
+   switch (action.type) {
+     case 'ADD_CUSTOM_FORMULA':
+       return {
+         ...state,
+         formulas: [...state.formulas, action.payload.formula],
+         formulaConfigValues: insertFormulaInCategory(
+           state.formulaConfigValues,
+           action.payload.newFormula,
+           action.payload.category
+         )
+       };
+     // ... other cases
+     default:
+       return state;
+   }
+ };

+ const [state, dispatch] = useReducer(formulaReducer, {
+   formulas: initialFormulas,
+   formulaConfigValues: [],
+ });

  const addNewFormula = () => {
    if (selectedDeletedFormula?.code === "NEW_FORMULA") {
-     // Current implementation
+     dispatch({
+       type: 'ADD_CUSTOM_FORMULA',
+       payload: {
+         formula: { 
+           source: "CUSTOM",
+           output: selectedDeletedFormula?.name,
+           category,
+           input: "",
+           operatorName: "",
+           assumptionValue: ""
+         },
+         category
+       }
+     });
    }
    // ... rest of the function
  };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 5b69794 and bde8f0b.

⛔ Files ignored due to path filters (1)
  • health/micro-ui/web/micro-ui-internals/packages/css/package.json is excluded by !**/*.json
📒 Files selected for processing (5)
  • health/micro-ui/web/micro-ui-internals/example/public/index.html (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FormulaConfiguration.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/Hypothesis.js (1 hunks)
  • health/micro-ui/web/public/index.html (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FormulaConfiguration.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

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

164-164: LGTM! Label structure properly updated.

The addition of the wrapper span with the new CSS class properly implements the label styling for consistent alignment with the tooltip icon.

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

320-320: LGTM: UI enhancement for tooltip positioning

The addition of the wrapper span with class "assumption-label-icon-wrapper-label" improves the structure and positioning of the formula label and tooltip icon.

health/micro-ui/web/public/index.html (1)

13-13: LGTM! Version update is consistent with example environment

The CSS version update matches the example environment, maintaining consistency across files.

Let's verify version consistency across all environments:

✅ Verification successful

Version consistency verified across all environments

The CSS version 0.2.2 is consistently used in both production (web/public/index.html) and example (example/public/index.html) environments.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any inconsistent CSS versions across all HTML files

# Find all HTML files and grep for the health CSS package version
fd -e html | xargs grep -l "digit-ui-health-css@" | xargs grep "digit-ui-health-css@"

Length of output: 402

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 10, 2024
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

🧹 Outside diff range comments (4)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/MultiSelectDropdown.js (4)

Line range hint 315-324: Avoid side effects in reducer functions

The reducer function contains side effects such as calling onSelect, onClose, and setSearchQuery(""), which violates the principles of pure functions in reducers. Reducer functions should be pure and not contain side effects. Consider moving these side effects to a useEffect hook or handling them after dispatching the action.

Apply this diff to remove side effects from the reducer:

 function reducer(state, action) {
   switch (action.type) {
     case "REMOVE_FROM_SELECTED_EVENT_QUEUE":
       const newState = state.filter((e) => e?.code !== action.payload?.[1]?.code);
-      onSelect(
-        newState.map((e) => e.propsData),
-        getCategorySelectAllState(),
-        props
-      );
-      if (onClose && !active) {
-        setSearchQuery("");
-        onClose(
-          newState.map((e) => e.propsData),
-          getCategorySelectAllState(),
-          props
-        );
-      }
       return newState;
     case "REPLACE_COMPLETE_STATE":
       return action.payload;
     default:
       return state;
   }
 }

Then, handle the side effects in a useEffect hook:

useEffect(() => {
  onSelect(
    alreadyQueuedSelectedState?.map((e) => e.propsData),
    getCategorySelectAllState(),
    props
  );
  if (onClose && !active) {
    setSearchQuery("");
    onClose(
      alreadyQueuedSelectedState?.map((e) => e.propsData),
      getCategorySelectAllState(),
      props
    );
  }
}, [alreadyQueuedSelectedState, active]);

Line range hint 354-364: Ensure consistent side effect handling when dropdown closes

In the useEffect that listens to changes in active, you're calling setSearchQuery(""), onSelect, and onClose when active is false. Ensure that this logic aligns with the intended behavior when the dropdown closes, and avoid redundant or unnecessary calls to onSelect and onClose.


Line range hint 525-533: Use stable keys for list items in chips rendering

When rendering Chip components, using key={index} can lead to rendering issues if the list items change order or if items are added or removed. If value.code is unique, consider using key={value.code} to ensure each item has a stable and unique key.

Apply this diff:

{items.map((value, index) => {
  const translatedText = t(value.code);
  const isClose = frozenData.some((frozenOption) => frozenOption.code === value.code);
  return (
    <Chip
-     key={index}
+     key={value.code}
      text={translatedText?.length > 64 ? `${translatedText.slice(0, 64)}...` : translatedText}
      onClick={(e) => removeFromDummySelected(e, value)}
      className="multiselectdropdown-tag"
      hideClose={isClose}
    />
  );
})}

Line range hint 872-898: Use unique keys for MenuItem components

In the MenuItem component, using key={index} is not recommended because it may cause rendering issues if the list changes. If option.code is unique, use key={option.code} instead to provide a stable identity for each item.

Apply this diff:

const MenuItem = ({ option, index }) => {
  // ...
  return (
    <div
-     key={index}
+     key={option.code}
      className={`digit-multiselectdropodwn-menuitem ${variant ? variant : ""} ${
        alreadyQueuedSelectedState.find((selectedOption) => selectedOption.code === option.code) ? "checked" : ""
      } ${
        index === optionIndex && !alreadyQueuedSelectedState.find((selectedOption) => selectedOption.code === option.code)
          ? "keyChange"
          : ""
      }${isFrozen ? "frozen" : ""}`}
      // ...
    >
      {/* ... */}
    </div>
  );
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between bde8f0b and 8863237.

📒 Files selected for processing (1)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/MultiSelectDropdown.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/MultiSelectDropdown.js (1)

Pattern **/*.js: check

@nipunarora-eGov nipunarora-eGov merged commit 1f0888b into console Dec 10, 2024
4 checks passed
@nipunarora-eGov nipunarora-eGov deleted the BUGFIX/HCMPRE-1585 branch December 10, 2024 14:05
@coderabbitai coderabbitai bot mentioned this pull request Dec 12, 2024
nipunarora-eGov added a commit that referenced this pull request Dec 12, 2024
* BUGFIX/HCMPRE-1585 fixed tootltip icon position according to the label (#2010)

* Update UserManagement.js (#2017)

Co-authored-by: Nipun Arora <aroranipun1@gmail.com>

---------

Co-authored-by: Nipun Arora <aroranipun1@gmail.com>
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