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

FEATURE/HCMPRE-1425 : Added the Workbench module patches into develop branch #2089

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Swathi-eGov
Copy link
Contributor

@Swathi-eGov Swathi-eGov commented Dec 30, 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

    • Enhanced form control with dynamic disabling and action bar rendering
    • Improved multi-select component with dynamic data fetching
    • Added new utility functions for date conversions and data validation
    • Introduced custom hook for MDMS popup search
    • Updated search and view configurations with more flexible permissions
  • Bug Fixes

    • Refined error handling in form submissions
    • Improved data transformation and validation processes
  • Refactor

    • Modularized configuration management
    • Enhanced component logic for better flexibility and user experience

@Swathi-eGov Swathi-eGov requested a review from a team as a code owner December 30, 2024 12:33
Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

📝 Walkthrough

Walkthrough

This pull request introduces several enhancements across multiple components in the micro-ui workbench module. The changes focus on improving form handling, data fetching, validation, and user interface interactions. Key modifications include dynamic form disabling, advanced option selection in multi-select components, new utility functions for date conversions, enhanced configuration management, and improved action item fetching based on user roles.

Changes

File Change Summary
DigitJSONForm.js Added formDisabled variable to control form state, updated action bar rendering logic
MultiSelect.js Introduced dynamic data limit, added fetchDetailsForSelectedOption function, enhanced state management
UICustomizations.js Added date conversion utilities, new configuration methods for MDMS actions and validations
searchMDMSConfigPopup.js Added customHook property to config
inbox.js Created new useMDMSPopupSearch custom hook for schema data fetching
MDMSAddV2.js Updated submission validation, added schema code validation
MDMSEdit.js Enhanced URL construction, added data transformation and validation
MDMSSearchv2.js Improved dropdown population, refined action bar rendering
MDMSView.js Refactored action item fetching, added conditional SOR data retrieval
utils/index.js Updated date formatting functions with more context-aware processing
BreadCrumb.js Added handleRedirect for managing external link navigation

Suggested Reviewers

  • nipunarora-eGov
  • jagankumar-egov

Poem

🐰 Hop, hop, through the code we go,
Refactoring paths both high and low,
Forms dance with newfound grace,
Dates transform at lightning pace,
Workbench magic, watch it grow! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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.

@Swathi-eGov Swathi-eGov changed the title added the Workbench module patches into develop branch FEATURE/HCMPRE-1425 : Added the Workbench module patches into develop branch Dec 30, 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: 23

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e2fe14 and 817ba82.

⛔ Files ignored due to path filters (9)
  • micro-ui/web/core/package.json is excluded by !**/*.json
  • micro-ui/web/micro-ui-internals/example/package.json is excluded by !**/*.json
  • micro-ui/web/micro-ui-internals/package.json is excluded by !**/*.json
  • micro-ui/web/micro-ui-internals/packages/modules/core/package.json is excluded by !**/*.json
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json is excluded by !**/*.json
  • micro-ui/web/micro-ui-internals/packages/react-components/package.json is excluded by !**/*.json
  • micro-ui/web/package.json is excluded by !**/*.json
  • micro-ui/web/sandbox/package.json is excluded by !**/*.json
  • micro-ui/web/workbench/package.json is excluded by !**/*.json
📒 Files selected for processing (12)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/DigitJSONForm.js (4 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/MultiSelect.js (4 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/UICustomizations.js (4 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfigPopup.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/inbox.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/index.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSAddV2.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSEdit.js (4 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js (4 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSView.js (3 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/utils/index.js (4 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/BreadCrumb.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/index.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/DigitJSONForm.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfigPopup.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/BreadCrumb.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/utils/index.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSAddV2.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/inbox.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/MultiSelect.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSView.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSEdit.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/UICustomizations.js (1)

Pattern **/*.js: check

🪛 Biome (1.9.4)
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js

[error] 161-161: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


[error] 191-191: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 197-197: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/utils/index.js

[error] 200-200: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 201-201: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 206-206: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 196-196: Reassigning a function parameter is confusing.

The parameter is declared here:

Use a local variable instead.

(lint/style/noParameterAssign)

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/inbox.js

[error] 5-5: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 83-83: This let declares a variable that is only assigned once.

'updatedPath' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/MultiSelect.js

[error] 156-156: This let declares a variable that is only assigned once.

'newFormattedOptions2' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSView.js

[error] 70-70: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


[error] 79-79: This let declares a variable that is only assigned once.

'propsToSendButtons' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 139-139: This let declares a variable that is only assigned once.

'propsToSend' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/UICustomizations.js

[error] 843-843: This let declares a variable that is only assigned once.

'hostname' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 845-845: This let declares a variable that is only assigned once.

'roleActions' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

🔇 Additional comments (24)
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/MultiSelect.js (1)

62-62: Usage of newly introduced limit looks correct.
This integrates well with the MdmsCriteria body, ensuring the dynamic limit is applied during data fetch.

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSEdit.js (5)

35-35: Dynamic URL usage
Good use of Digit.Utils.workbench.getMDMSActionURL() to generate dynamic endpoints.


85-96: Ensure error messages are contextual
You’re showing a generic error toast “RA_DATE_RANGE_ERROR” for date validation. Confirm that this is indeed the correct localized message for the validation scenario.


124-124: Enhance partial updates
You assign transformedData directly to the request. Ensure your upstream code only expects changed fields or merges them correctly if partial updates are possible.


147-153: Conditional date conversion
Good approach for only converting dates when available. Verify that “NA” is the desired fallback for relevant use cases.


159-159: Conditional form data
Nicely implemented logic to switch between formattedData and data?.data based on the schema. Ensures a specialized approach without duplicating fields.

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/UICustomizations.js (3)

5-5: Check library usage
Axios is imported. Confirm if all calls in this file use the same library (axios or Digit’s HTTP layers) for consistency.


20-29: Focus on date parsing reliability
convertDateToEpoch returns "NA" if !dateString. This might be loosely typed in downstream usage. Ensure no type mismatch occurs if you later treat "NA" as a numeric epoch.


531-535: Ensure numeric conversion
At lines 531-535, Number(value) is used for epoch conversion. Verify that all values will be valid integers or handle parsing errors.

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/index.js (2)

7-7: Hook import
useMDMSPopupSearch is introduced. Verify this hook is already tested or has coverage to ensure stability.


31-33: Added inbox property
Excellent approach to grouping hooks under modules. This keeps the code structure consistent.

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/inbox.js (1)

5-5: Check for undefined schemaCode before splitting.
If schemaCode becomes undefined, the chained .split() will throw an error. A quick safeguard would be to default to an empty string or check for its presence beforehand.

- const [moduleName, masterName] = criteria?.body?.MdmsCriteria?.schemaCode?.split(".");
+ const schemaVal = criteria?.body?.MdmsCriteria?.schemaCode;
+ const [moduleName, masterName] = schemaVal ? schemaVal.split(".") : [null, null];
🧰 Tools
🪛 Biome (1.9.4)

[error] 5-5: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfigPopup.js (1)

21-21: Addition of customHook property looks good.
The customHook inclusion is straightforward and aligns with the new hook usage.

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js (2)

112-114: Check fallback for empty properties array before iteration.
Ensure that properties is always an object with valid keys. If properties is undefined or null, this loop will throw an error.


188-191: 🧹 Nitpick (assertive)

Use template literals.
String concatenation can be replaced with templated strings for clarity.

- window.location.href = "/works-ui/employee/rateanalysis/view-rate-analysis?sorId="+row?.data?.sorId+"&fromeffective="+row?.data?.effectiveFrom
+ window.location.href = `/works-ui/employee/rateanalysis/view-rate-analysis?sorId=${row?.data?.sorId}&fromeffective=${row?.data?.effectiveFrom}`

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 191-191: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/DigitJSONForm.js (3)

221-221: Tooltip styling update is valid.
Applying a maxWidth helps improve readability for lengthy tooltip text.


282-283: Extract formDisabled logic into a single conditional.
Nice approach to clearly separate the disabled logic based on screenType. This keeps form usage straightforward.


336-336: Validate 'viewActions' usage.
You're conditionally rendering the ActionBar if viewActions exists and has length. This is a good approach to avoid empty UI elements. Ensure no leftover references exist to the older logic.

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/utils/index.js (3)

233-236: Propagate the new parameter consistently.
The additional key parameter is correctly passed to formatDates. Confirm that callers of formatData properly supply key when needed.


257-257: Validate that the formatType matches known types.
Before calling formatData with schema?.[key]?.formatType, ensure it adheres to expected values (EPOC, date, datetime, etc.) to avoid unexpected behaviors.


279-279: Use consistent naming for reverse EPOC conversions.
Here, REVERT-EPOC is appended to the format type, but ensure that all calling sites handle this naming pattern correctly.

micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSAddV2.js (3)

96-96: Great clarity through explicit schema code pointer.
Defining schemaCodeToValidate makes the code more maintainable and readable.


97-104: Async form submission plus validation—good approach.
Ensure that any form validations or side effects do not block the UI thread. Consider providing user feedback (e.g., a spinner) while validating.


120-120: Enhanced error messaging.
Appending an exclamation mark is helpful for visibility. Confirm the potential presence or length of resp?.response?.data?.Errors.

if(isLoading || isLoadingSchema || renderLoader ) return <Loader />

return (
<React.Fragment>
<MDMSAdd defaultFormData = {data?.data} screenType={"edit"} onSubmitEditAction={handleUpdate} updatesToUISchema ={schemaData?.updatesToUiSchema} />
<MDMSAdd defaultFormData = {(`${moduleName}.${masterName}` === "WORKS-SOR.Rates" || `${moduleName}.${masterName}` === "WORKS-SOR.Composition") ? formattedData : data?.data} screenType={"edit"} onSubmitEditAction={handleUpdate} updatesToUISchema ={schemaData?.updatesToUiSchema} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove rates related checks

@@ -153,7 +157,8 @@ const MDMSSearchv2 = () => {
label:option.i18nKey,
i18nKey:option.i18nKey,
jsonPath:`data.${option.code}`,
dontShowNA:true
dontShowNA:true,
additionalCustomization: currentSchema?.definition?.["x-ui-schema"]?.[option?.name]?.formatType === "EPOC" ? true : false
Copy link
Collaborator

Choose a reason for hiding this comment

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

add comments what and why this is needed

params: {},
body: {
MdmsCriteria: {
tenantId: tenantId?.split(".")[0],
Copy link
Collaborator

Choose a reason for hiding this comment

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

why tenant id .spit ?

MdmsCriteria: {
tenantId: tenantId?.split(".")[0],
uniqueIdentifiers: [uniqueIdentifier?.split(".")[0]],
schemaCode: `${moduleName}.${"SOR"}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

sor cant be there here also add comments

},
validateForm: async (data, props) => {
try {
const response = await axios.post("/mdms-v2/v2/_search", {
Copy link
Collaborator

Choose a reason for hiding this comment

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

use generic service instead of axios

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