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

how it works and user manual link added in the card #1570

Merged
merged 4 commits into from
Oct 19, 2024

Conversation

mithunhegde-egov
Copy link

@mithunhegde-egov mithunhegde-egov commented Oct 18, 2024

added how it works and user manual. extended the same logic for new url and added the buttons in the array. data and role actions in mdms is udpated

Summary by CodeRabbit

  • New Features
    • Introduced "How it works" and "Read User Manual" buttons for enhanced navigation.
    • Updated user manual link to open in a new tab.
  • Improvements
    • Enhanced link filtering for a more relevant display of navigation options based on module type.
    • Improved overall user interface with additional navigation options while preserving existing functionality.

@mithunhegde-egov mithunhegde-egov requested a review from a team as a code owner October 18, 2024 11:40
Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request involve modifications to the RoleBasedEmployeeHome component within the specified file. New functions are introduced to retrieve specific links for "How It Works" and "User Manual" based on the module type. The links array is updated to filter these buttons for multi-root tenants, and the centreChildren and endChildren arrays are enhanced with new buttons that open their respective links in a new tab. The overall structure of the component remains intact.

Changes

File Change Summary
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js Added functions for retrieving "How It Works" and "User Manual" links; updated links, centreChildren, and endChildren arrays accordingly.

Possibly related PRs

  • card order and link order #1443: Modifies the RoleBasedEmployeeHome.js file, adding sorting functionality for sidebar modules and links, which is directly related to the changes made in the main PR that also involves modifications to the RoleBasedEmployeeHome component.
  • side bar mobileview and sidebar link order fixes #1481: Addresses sidebar functionality and link order, which is relevant as the main PR enhances navigation options within the sidebar of the RoleBasedEmployeeHome component.
  • Role screen #1535: Introduces a new role selection screen that includes links to the employee home page, which relates to the overall navigation and link management enhancements in the main PR.

Suggested reviewers

  • jagankumar-egov
  • nabeelmd-eGov

🐰 In the meadow, buttons bloom,
"How it works" dispels the gloom.
"Read User Manual" takes its flight,
Opening tabs, oh what a sight!
With links that guide us on our way,
A joyful hop, we greet the day! 🌼


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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between bdb9943 and b110249.

📒 Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (1)

Pattern **/*.js: check

🪛 Biome
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js

[error] 154-154: 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)


[error] 155-163: 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)


[error] 176-184: 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 (3)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (3)

82-85: LGTM: New icon selections added consistently.

The new icon selections for user manuals and functional specifications have been added consistently with the existing pattern. This improves the visual representation of different types of links.


153-153: LGTM: Appropriate filtering for multi-root tenants.

The links array is now correctly filtered to exclude "How it Works" and "Read User Manual" links for multi-root tenants, which aligns with the PR objectives.


Line range hint 1-200: Overall implementation looks good with minor improvements needed.

The changes successfully implement the new "How it works" and "Read User Manual" buttons, and update the links array as intended. The code is consistent with the existing patterns and achieves the PR objectives.

To improve the implementation:

  1. Add key props to React elements in arrays as suggested in the previous comments.
  2. Consider adding error handling for cases where userManual or howItWorks might be undefined.

Great job on implementing these new features!

🧰 Tools
🪛 Biome

[error] 154-154: 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)


[error] 155-163: 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)

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between b110249 and 510c4ab.

📒 Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (1)

Pattern **/*.js: check

🪛 Biome
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js

[error] 154-154: 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)


[error] 155-163: 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)


[error] 176-184: 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 (3)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (3)

82-85: LGTM: Icon selection logic extended appropriately.

The new conditions for "user-manual" and "functional-specifications" links have been added consistently with the existing pattern. This change aligns well with the PR objectives of adding new functionalities.


147-148: LGTM: New variables added for "How it works" and "Read User Manual" links.

The new variables howItWorks and userManual are correctly implemented to find the respective links in the moduleData.links array. This change supports the PR objectives of adding new functionalities.


153-153: LGTM: Links filtering updated for multi-root tenants.

The links property has been correctly updated to filter out "Configure", "How it works", and "Read User Manual" links for multi-root tenants. This change ensures these links are handled separately and don't appear in the module card links for multi-root tenants, aligning with the PR objectives.

Comment on lines +154 to +164
centreChildren: [<div>{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>,
<Button
variation="teritiary"
label={userManual?.label}
icon={userManual?.icon}
type="button"
size={"medium"}
onClick={() => window.open(userManual?.link, "_blank")}
style={{ padding: "0px" }}
/>,
],
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

Add key prop to React elements in centreChildren array.

The new button for the user manual has been added correctly and aligns with the PR objectives. However, React elements in an array should have a unique key prop to help React identify which items have changed, been added, or been removed.

Please add a unique key prop to each element in the centreChildren array. For example:

centreChildren: [
  <div key="description">{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>,
  <Button
    key="userManual"
    variation="teritiary"
    label={userManual?.label}
    icon={userManual?.icon}
    type="button"
    size={"medium"}
    onClick={() => window.open(userManual?.link, "_blank")}
    style={{ padding: "0px" }}
  />,
],
🧰 Tools
🪛 Biome

[error] 154-154: 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)


[error] 155-163: 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)

const propsForModuleCard = {
icon: "SupervisorAccount",
moduleName: t(moduleData?.label),
metrics: [],
links: Digit.Utils.getMultiRootTenant() ? moduleData.links?.filter((item) => item.label !== "Configure") : moduleData.links,
centreChildren: [<div>{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>],
links: Digit.Utils.getMultiRootTenant() ? moduleData.links?.filter((item) => item.label !== "Configure" && item.label !== "How it works" && item.label !== "Read User Manual") : moduleData.links,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why directly add the message ?
u will have to compare the message only

@@ -79,6 +79,10 @@ export const RoleBasedEmployeeHome = ({ modules, additionalComponent }) => {
? "Edit"
: linkUrl.includes("dss")
? "Dashboard"
: linkUrl.includes("user-manual")
Copy link
Collaborator

Choose a reason for hiding this comment

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

clean it up

    // link: linkUrl,
    link: linkUrl,
    icon: linkUrl.includes("create")
      ? "Person"
      : linkUrl.includes("inbox")
      ? "AllInbox"
      : linkUrl.includes("search")
      ? "Search"
      : linkUrl.includes("edit")
      ? "Edit"
      : linkUrl.includes("dss")
      ? "Dashboard"
      : linkUrl.includes("user-manual")
      ? "SpeakerNotes"
      : linkUrl.includes("functional-specifications")
      ? "Book"
      : "PhonelinkSetup",
      
      
      it should be separate master

Copy link
Collaborator

Choose a reason for hiding this comment

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

downt have hardcoded into 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: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 510c4ab and 9af2089.

📒 Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (1)

Pattern **/*.js: check

🪛 Biome
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js

[error] 185-185: 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)


[error] 186-194: 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)


[error] 207-215: 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 (2)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/RoleBasedEmployeeHome.js (2)

Line range hint 72-77: LGTM: Simplified icon assignment and code cleanup

The changes in this segment look good. The direct assignment of item.leftIcon to the icon property simplifies the code. The removal of commented-out code for link improves code cleanliness.


177-179: LGTM: Enhanced link retrieval

The changes in this segment look good. The configureData variable now correctly finds the "Configure_master" link. The introduction of howItWorks and userManual variables, using the newly defined functions, enhances the component's functionality and aligns with the PR objectives.

Comment on lines +130 to +152
const getHowItWorksLink = (moduleData) => {
return moduleData?.links?.find((item) => {
if (moduleData.module === "PGR") {
return item?.displayName === "HOW_IT_WORKS_PGR";
} else if (moduleData.module === "HRMS") {
return item?.displayName === "HOW_IT_WORKS_HRMS";
} else {
return false;
}
});
};

const getUserManualLink = (moduleData) => {
return moduleData?.links?.find((item) => {
if (moduleData.module === "PGR") {
return item?.displayName === "PGR_INFO_LINK";
} else if (moduleData.module === "HRMS") {
return item?.displayName === "HRMS_INFO_LINK";
} else {
return false; // No match for other modules
}
});
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM: New functions for retrieving specific links

The introduction of getHowItWorksLink and getUserManualLink functions is a good addition. They effectively retrieve specific links based on the module type, aligning with the PR objectives.

Consider using a switch statement or object lookup for better scalability if more modules are expected in the future. For example:

const getHowItWorksLink = (moduleData) => {
  const howItWorksMap = {
    PGR: "HOW_IT_WORKS_PGR",
    HRMS: "HOW_IT_WORKS_HRMS"
  };
  return moduleData?.links?.find(item => item?.displayName === howItWorksMap[moduleData.module]);
};

This approach would make it easier to add new modules in the future.

Comment on lines +154 to +173
const getFilteredLinks = (moduleData) => {
return moduleData.links?.filter((item) => {
const displayName = item.displayName;
const isPGR = moduleData.module === "PGR";
const isHRMS = moduleData.module === "HRMS";
const isNotConfigureMaster = displayName !== "Configure_master";
const isNotHowItWorksPGR = !(isPGR && displayName === "HOW_IT_WORKS_PGR");
const isNotHRMSInfoLink = !(isHRMS && displayName === "HRMS_INFO_LINK");
const isNotHowItWorksHRMS = !(isHRMS && displayName === "HOW_IT_WORKS_HRMS");
const isNotPGRInfoLink = !(isPGR && displayName === "PGR_INFO_LINK");

return (
isNotConfigureMaster &&
isNotHowItWorksPGR &&
isNotHRMSInfoLink &&
isNotHowItWorksHRMS &&
isNotPGRInfoLink
);
});
};
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

Refactor suggestion: Simplify link filtering logic

The getFilteredLinks function effectively filters out unwanted links. However, the current implementation could be simplified for better readability and maintainability. Consider refactoring the function as follows:

const getFilteredLinks = (moduleData) => {
  const excludedLinks = {
    PGR: ["Configure_master", "HOW_IT_WORKS_PGR", "PGR_INFO_LINK"],
    HRMS: ["Configure_master", "HRMS_INFO_LINK", "HOW_IT_WORKS_HRMS"],
    default: ["Configure_master"]
  };

  const excludeList = excludedLinks[moduleData.module] || excludedLinks.default;

  return moduleData.links?.filter(item => !excludeList.includes(item.displayName));
};

This refactored version:

  1. Uses an object to define excluded links for each module type.
  2. Simplifies the filtering logic, making it more maintainable.
  3. Allows for easy addition of new module types in the future.

Comment on lines +184 to +195
links: Digit.Utils.getMultiRootTenant()? getFilteredLinks(moduleData): moduleData.links,
centreChildren: [<div>{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>,
<Button
variation="teritiary"
label={userManual?.label}
icon={userManual?.icon}
type="button"
size={"medium"}
onClick={() => window.open(userManual?.link, "_blank")}
style={{ padding: "0px" }}
/>,
],
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

LGTM with minor improvements: Enhanced link filtering and new user manual button

The changes in this segment look good overall:

  1. The use of getFilteredLinks for multi-root tenants enhances the component's functionality.
  2. The new user manual button is correctly implemented and aligns with the PR objectives.

However, there's a minor issue to address:

Add key props to the React elements in the centreChildren array to help React identify which items have changed, been added, or been removed. For example:

centreChildren: [
  <div key="description">{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>,
  <Button
    key="userManual"
    variation="teritiary"
    label={userManual?.label}
    icon={userManual?.icon}
    type="button"
    size={"medium"}
    onClick={() => window.open(userManual?.link, "_blank")}
    style={{ padding: "0px" }}
  />,
],
🧰 Tools
🪛 Biome

[error] 185-185: 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)


[error] 186-194: 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)

Comment on lines +207 to +215
<Button
variation="teritiary"
label={howItWorks?.label}
icon={howItWorks?.icon}
type="button"
size={"medium"}
onClick={() => window.open(howItWorks?.link, "_blank")}
style={{ padding: "0px" }}
/>,
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

LGTM with minor improvements: New "How it works" button added

The addition of the "How it works" button to the endChildren array is a good improvement and aligns with the PR objectives. The button is correctly implemented to open the link in a new tab.

However, there's a minor issue to address:

Add key props to the React elements in the endChildren array to help React identify which items have changed, been added, or been removed. For example:

endChildren: Digit.Utils.getMultiRootTenant()
  ? [
      <Button
        key="configure"
        variation="teritiary"
        label={configureData?.label}
        icon={configureData?.icon}
        type="button"
        size={"medium"}
        onClick={() => history?.push(configureData?.link)}
        style={{ padding: "0px" }}
      />,
      <Button
        key="howItWorks"
        variation="teritiary"
        label={howItWorks?.label}
        icon={howItWorks?.icon}
        type="button"
        size={"medium"}
        onClick={() => window.open(howItWorks?.link, "_blank")}
        style={{ padding: "0px" }}
      />,
    ]
  : null,
🧰 Tools
🪛 Biome

[error] 207-215: 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)

@jagankumar-egov jagankumar-egov merged commit b43f9b6 into develop Oct 19, 2024
3 checks passed
@jagankumar-egov jagankumar-egov deleted the how-it-works branch October 19, 2024 04:51
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