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

added the Workbench module patches which was done as part of Mukta ro… #1967

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

Conversation

Swathi-eGov
Copy link
Contributor

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

…llout.

Choose the appropriate template for your PR:

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced form validation and error handling in the DigitJSONForm component.
    • Added dynamic data fetching capabilities in the CustomSelectWidget component.
    • Introduced new utility functions for date conversions in the UICustomizations module.
    • Implemented a custom hook for schema data management in useMDMSPopupSearch.
    • Improved dropdown options handling and navigation in MDMSSearchv2.
    • Enhanced breadcrumb navigation with dynamic path determination.
    • Added new configurations for action item fetching and validation in the UICustomizations module.
  • Bug Fixes

    • Addressed error message translations and visibility in form submissions.
  • Improvements

    • Refined control flow and state management across various components to enhance user experience.
    • Enhanced the visibility of action menus based on user permissions in the ActionBar.

@Swathi-eGov Swathi-eGov requested a review from a team as a code owner December 3, 2024 08:02
Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces a series of enhancements across multiple components within the micro-ui application. Key updates include modifications to the DigitJSONForm for improved error handling and form control, the addition of a custom hook for managing schema data in inbox.js, and enhancements to the UICustomizations for better date handling and action management. Other changes involve adjustments to dropdown logic in MDMSSearchv2, breadcrumb navigation in index.js, and utility functions for date formatting. Overall, these changes aim to refine user interactions and data management throughout the application.

Changes

File Change Summary
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/DigitJSONForm.js Updated uiSchema with new props, modified transformErrors for error message translation, added formDisabled logic, and adjusted ActionBar rendering based on viewActions.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/MultiSelect.js Adjusted limit in reqCriteriaForData, added formattedOptions2 state, and introduced fetchDetailsForSelectedOption for dynamic option management.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/UICustomizations.js Added convertDateToEpoch and convertEpochToDate functions, expanded configurations with ViewMdmsConfig, AddMdmsConfig, and updated sorting in SearchMDMSConfig.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfigPopup.js Added customHook property to Config object for search functionality.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/inbox.js Introduced useMDMSPopupSearch hook for managing schema data fetching with error handling and caching.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/index.js Added useMDMSPopupSearch to Hooks object under inbox property.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSAddV2.js Enhanced onSubmit function with validation logic and error handling, modified jsonPath logic, and adjusted rendering hooks.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSEdit.js Updated handleUpdate function with new URL utility and data transformation logic, including validation and error handling.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js Modified dropdown option construction, added conditional redirect logic in onClickRow, and refined access control in the ActionBar.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSView.js Redefined fetchActionItems function for dynamic action fetching, introduced new request criteria, and updated loading state management.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/index.js Updated WorkbenchBreadCrumb component to include initialContextPath, refined breadcrumb display logic, and enhanced session management.
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/utils/index.js Added key parameter to formatDates and formatData functions, enhancing date handling logic.
micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/BreadCrumb.js Introduced handleRedirect function for external path handling in breadcrumb navigation.

Possibly related PRs

  • Finalised microplan download #1762: Enhancements to the SearchJurisdiction component for dropdown functionality may relate to dropdown updates in this PR.
  • Audit fixes main #1926: Modifications to the UICustomizations object for MicroplanSearchConfig may connect to form handling improvements in this PR.
  • width fix for module card #1929: Updates to the CSS stylesheet link may ensure the latest styles are applied, indirectly relating to UI changes in this PR.
  • Updated Bread crumbs #1954: Changes in the BreadCrumbNew component for internal navigation may relate to breadcrumb navigation enhancements in this PR.

Suggested reviewers

  • jagankumar-egov

🐇 In the meadow, we hop with glee,
New forms and hooks, oh what a spree!
With breadcrumbs guiding, we find our way,
Enhancements abound, brightening our day!
So let’s celebrate this joyful dance,
With code so sweet, we take a chance! 🌼✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 6174664 and ada66ec.

📒 Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/index.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/index.js (1)

Pattern **/*.js: check

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

7-7: LGTM! Import statement is correctly placed

The import of useMDMSPopupSearch is properly organized with other hook imports and follows the project's import structure.


31-33: Structure looks good, but let's verify the integration

The new inbox configuration follows the established pattern. However, we should verify:

  1. The hook's integration with MDMS popup search functionality
  2. Test coverage for this new hook integration
✅ Verification successful

Let me check the actual implementation and usage of this hook to provide a more detailed verification.


Integration verified and properly implemented

The hook is correctly integrated and follows best practices:

  • Properly implemented in inbox.js using React Query for data fetching
  • Correctly referenced in searchMDMSConfigPopup.js via customHook configuration
  • Handles schema validation, filtering, and pagination as expected
  • Includes proper error handling and cache invalidation

While test coverage is missing, the implementation is sound and follows the established patterns for MDMS popup search functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the hook's usage and test coverage

# Check for hook usage in MDMS popup related files
echo "Checking hook usage in MDMS popup components:"
rg -l "useMDMSPopupSearch" --type js

# Check for corresponding test files
echo -e "\nChecking for test coverage:"
fd -e test.js -e spec.js inbox

Length of output: 493


Script:

#!/bin/bash
# Check the hook implementation
echo "Hook implementation in inbox.js:"
cat "micro-ui/web/micro-ui-internals/packages/modules/workbench/src/hooks/inbox.js"

echo -e "\nUsage in searchMDMSConfigPopup.js:"
cat "micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfigPopup.js"

Length of output: 9250


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

🧹 Outside diff range comments (4)
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js (2)

Line range hint 112-131: Optimize dropdown options sorting logic and add safety checks

The current implementation has redundant conditional checks and potential runtime safety issues.

Consider refactoring to:

- dropDownOptions =
-   dropDownOptions?.length > 0 &&
-   Digit?.Customizations?.["commonUiConfig"]?.["SearchMDMSv2Config"]?.[schemaCodeToValidate]?.sortValidDatesFirst(dropDownOptions)
-     ? Digit?.Customizations?.["commonUiConfig"]?.["SearchMDMSv2Config"]?.[schemaCodeToValidate]?.sortValidDatesFirst(dropDownOptions)
-     : dropDownOptions;
+ const sortFn = Digit?.Customizations?.["commonUiConfig"]?.["SearchMDMSv2Config"]?.[schemaCodeToValidate]?.sortValidDatesFirst;
+ dropDownOptions = dropDownOptions?.length > 0 && typeof sortFn === 'function' ? sortFn(dropDownOptions) : dropDownOptions;

Line range hint 200-204: Improve conditional readability and function naming

The current condition chain is hard to read and the function name has grammatical issues.

Consider refactoring to:

- updatedConfig && Digit.Utils.didEmployeeHasAtleastOneRole(updatedConfig?.actionRoles) && Digit.Utils.didEmployeeisAllowed(master,modulee)
+ const hasRequiredRole = Digit.Utils.didEmployeeHasAtleastOneRole(updatedConfig?.actionRoles);
+ const isAllowedAccess = Digit.Utils.didEmployeeisAllowed(master, modulee);
+ updatedConfig && hasRequiredRole && isAllowedAccess

Also, consider renaming the function to isEmployeeAllowed for better grammar.

🧰 Tools
🪛 Biome (1.9.4)

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 198-198: 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/pages/employee/index.js (1)

Line range hint 91-108: Simplify session storage management

The session storage clearing logic is complex and scattered. Consider consolidating this into a custom hook for better maintainability.

const useSessionStorageCleanup = (prefixes, dependencies) => {
  useEffect(() => {
    const clearSessionStorageWithPrefix = (prefix) => {
      Object.keys(sessionStorage)
        .filter(key => key.startsWith(`Digit.${prefix}`))
        .forEach(key => sessionStorage.removeItem(key));
    };

    const currentUrl = window.location.href;
    const cleanupRules = {
      'MDMS_add': !currentUrl.includes('mdms-add-v2') && !currentUrl.includes('mdms-add-v4') && !currentUrl.includes('mdms-view'),
      'MDMS_view': !currentUrl.includes('mdms-view'),
      'MDMS_edit': !currentUrl.includes('mdms-edit')
    };

    prefixes.forEach(prefix => {
      if (cleanupRules[prefix]) {
        clearSessionStorageWithPrefix(prefix);
      }
    });
  }, dependencies);
};
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/utils/index.js (1)

Line range hint 194-279: Add unit tests for date handling functions

The date handling functions are critical components that should be thoroughly tested. Consider adding unit tests to cover:

  • Different timezone scenarios
  • Edge cases for start/end of day
  • Various key parameter values
  • Date format conversions

Would you like me to help create a test suite for these date handling functions?

🧰 Tools
🪛 Biome (1.9.4)

[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)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between fb39080 and 6174664.

⛔ Files ignored due to path filters (10)
  • 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/dss/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 (13)
  • 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 (5 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 (4 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/index.js (4 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 (13)
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/hooks/index.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/pages/employee/MDMSEdit.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/pages/employee/index.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/utils/index.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/components/DigitJSONForm.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/hooks/index.js

[error] 2-2: Declarations inside of a import declaration may not have duplicates

a second declaration of isSchemaCodeInMDMSAction is not allowed

isSchemaCodeInMDMSAction is first declared here

(parse)

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

[error] 162-162: 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] 192-192: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 198-198: 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/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/pages/employee/index.js

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


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

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

[error] 157-157: 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/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/pages/employee/MDMSView.js

[error] 68-68: 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] 77-77: This let declares a variable that is only assigned once.

'propsToSendButtons' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 137-137: 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 (13)
micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js (1)

161-162: LGTM! Good handling of EPOC date format

The conditional additionalCustomization based on format type is a good approach for handling EPOC dates.

🧰 Tools
🪛 Biome (1.9.4)

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

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

30-32: 🧹 Nitpick (assertive)

Consider using React Router's navigation for better UX

Full page reloads via window.location.href can disrupt the user experience. Consider using React Router's navigation methods for smoother transitions.

- crumb?.externalPath ? (
-   <Link onClick={() => handleRedirect(crumb?.path)}>{crumb.content} </Link>) : 
-   (<Link to={{ pathname:crumb.path, state: {count : crumb?.count }, search: crumb?.query }}>{crumb.content}</Link>)
+ crumb?.externalPath ? (
+   <Link to={crumb.path} target={crumb.openInNewTab ? "_blank" : "_self"}>{crumb.content}</Link>
+ ) : (
+   <Link to={{ pathname:crumb.path, state: {count : crumb?.count }, search: crumb?.query }}>{crumb.content}</Link>
+ )

Likely invalid or redundant comment.

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

83-83: Consider implications of useRef for initialContextPath

Using useRef for initialContextPath means the value won't trigger re-renders if window.contextPath changes. Verify if this is the intended behavior.

Also applies to: 125-125

✅ Verification successful

Based on the search results, I can see that window.contextPath is a critical configuration value used extensively throughout the application for routing and navigation. The value is:

  1. Initially set at the application level from global configs:
window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH");
  1. In some cases, it's dynamically updated with tenant information:
window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH") + `${tenant ? `/${tenant}` : ""}` || "digit-ui";

Using useRef for initialContextPath is actually the correct approach here because:

  1. The initial context path needs to be preserved as a reference point, regardless of any subsequent changes to window.contextPath
  2. The component doesn't need to re-render when this reference value changes since it's used as an initial snapshot
  3. This pattern helps compare the initial route context with any subsequent changes

Using useRef is the correct implementation here

The current implementation correctly captures the initial context path value that can be used as a reference point throughout the component lifecycle, without triggering unnecessary re-renders.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if contextPath is used consistently across the codebase
rg "window\.contextPath" -A 2 -B 2

Length of output: 39359

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

35-35: Ensure Proper Handling of URL Generation

The url is constructed using Digit.Utils.workbench.getMDMSActionURL(moduleName, masterName, "update"). Please verify that moduleName and masterName are always defined and valid strings to prevent potential runtime errors due to undefined or null values.


124-124: Validate Structure of transformedData Before Mutation

When passing transformedData in the mutation's body, ensure that it matches the expected schema required by the backend API. An incorrect data structure may result in failed updates or unexpected behavior.

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

21-21: LGTM: Custom hook integration looks good.

The addition of customHook property to use useMDMSPopupSearch is a clean way to integrate search functionality.

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

96-104: Good addition of validation logic.

The validation implementation is well-structured and handles error cases appropriately by:

  1. Validating form data before submission
  2. Showing translated error messages
  3. Preventing form submission on validation failure

120-120: LGTM: Improved error message formatting.

The error message now includes both the generic error message and the specific error code, making it more informative for users.

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

221-221: LGTM: Improved tooltip readability.

Setting max-width for tooltips prevents them from becoming too wide and ensures better readability.


282-282: LGTM: Better form disabled state management.

Centralizing the form disabled state logic into a single variable improves code maintainability and readability.

Also applies to: 317-317


336-336: LGTM: Enhanced menu visibility check.

The additional check for viewActions length prevents rendering an empty menu container when there are no actions.

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

Line range hint 233-242: LGTM: Changes correctly propagate the key parameter

The changes to formatData appropriately pass the key parameter to the formatDates function.

🧰 Tools
🪛 Biome (1.9.4)

[error] 239-239: Duplicate case label.

The first similar label is here:

(lint/suspicious/noDuplicateCase)


[error] 238-238: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)


257-257: Verify the impact of key parameter changes

The changes correctly propagate the key parameter. However, let's verify all usages to ensure consistent behavior.

Also applies to: 279-279

✅ Verification successful

Key parameter changes are correctly implemented

The verification shows that the key parameter is properly implemented and serves a specific purpose:

  • The formatData function correctly passes the key parameter to formatDates
  • The formatDates function uses the key parameter to handle special cases for "validTo" and "effectiveTo" fields, setting appropriate time values (23:59:59.999 for end dates, 00:00:00.000 for others)
  • The changes are localized to the workbench module and don't require modifications elsewhere
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all calls to formatData to verify key parameter usage

# Search for formatData calls
echo "Searching for formatData calls..."
rg -A 2 "formatData\(" 

# Search for date-related fields in schema files
echo "Searching for date fields in schema files..."
rg -l '"type":\s*"(date|datetime|EPOC)"' --type json

Length of output: 944


Script:

#!/bin/bash
# Let's find the formatData function definition and its usages in a more comprehensive way

# Find the formatData function definition
echo "Searching for formatData function definition..."
ast-grep --pattern 'const formatData = $_'

# Search for any other files that might import and use formatData
echo "Searching for files importing formatData..."
rg "import.*formatData"

# Look for the schema structure to understand the formatType usage
echo "Searching for schema structure..."
rg -A 5 "formatType.*:" 

Length of output: 2625


Script:

#!/bin/bash
# Let's examine the formatDates function since it's using the key parameter

# Find the formatDates function definition
echo "Searching for formatDates function definition..."
ast-grep --pattern 'const formatDates = $_'

# Look for any date-related schema configurations
echo "Searching for EPOC type configurations in the codebase..."
rg -B 2 -A 2 '"formatType":\s*"EPOC"'

# Search for any test files that might validate this functionality
echo "Searching for related test files..."
fd -e test.js -e spec.js -e test.jsx -e spec.jsx

Length of output: 2943

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 3, 2024
@@ -279,6 +279,8 @@ const DigitJSONForm = ({
};
const person = { t: t };

const formDisabled = screenType === "view" ? true : disabled;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is already done as part of view screen wrapper right @Swathi-eGov

@@ -49,14 +49,15 @@ const CustomSelectWidget = (props) => {
/*
logic added to fetch data of schemas in each component itself
*/
const limit = schemaCode === "WORKS-SOR.SOR" ? 1000 : 100;
Copy link
Collaborator

Choose a reason for hiding this comment

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

even with 1000 data it didnt solve the issue right ?

const [limitedOptions, setLimitedOptions] = useState([]);
const [selectedDetails, setSelectedDetails] = useState(null);
const [showDetails, setShowDetails] = useState(null);
const [isSelect, setIsSelect] = useState(false);
const [showModal, setShowModal] = useState(false);
const [isSeeAll, setIsSeeAll] = useState(false);

const fetchDetailsForSelectedOption = async (value) => {
const response = await fetch(`/${Digit.Hooks.workbench.getMDMSContextPath()}/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 custom service instead of fetch

@@ -190,7 +224,8 @@ const CustomSelectWidget = (props) => {
isSearchable={true}
isMulti={multiple}
styles={customStyles}
components={isSeeAll ? { MenuList: SelectMenuButton, Option: OptionWithInfo } : { Option: OptionWithInfo }}
// components={isSeeAll ? { MenuList: SelectMenuButton, Option: OptionWithInfo } : { Option: OptionWithInfo }}
components={schema?.schemaCode ? { MenuList: SelectMenuButton, Option: OptionWithInfo } : { Option: OptionWithInfo }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

can u check what was that seeall and from where it is calculated

const crumbs = [
{
path: `/${window?.contextPath}/employee`,
path: getHomePath(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert this change

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