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

Pagination added to microplan search and my microplan #1706

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

Conversation

abishekTa-egov
Copy link
Collaborator

@abishekTa-egov abishekTa-egov commented Oct 30, 2024

Added pagination to microplan search and my microplan

Summary by CodeRabbit

  • New Features

    • Updated tab label for better clarity in the user interface.
    • Enhanced response structure by adding total count of plans in search results.
  • Improvements

    • Refined logic for UI component customizations based on microplan status.
    • Improved error handling for more informative feedback during API calls.
  • Bug Fixes

    • Adjusted conditions for button states to ensure correct functionality based on microplan status.

@abishekTa-egov abishekTa-egov requested a review from a team as a code owner October 30, 2024 04:47
Copy link
Contributor

coderabbitai bot commented Oct 30, 2024

Warning

Rate limit exceeded

@abishekTa-egov has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between 4063ccd and f7a9c34.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request includes several modifications across multiple files related to the microplan user interface. Key changes involve updating the label in the TabSearchconfig object, enhancing the additionalCustomizations method in UICustomizations.js for handling action buttons and logging, and adding a TotalCount property to the response objects in both searchSavedPlans.js and searchSavedPlansWithCampaign.js. These adjustments refine the user interface configuration and improve data handling in the search functionality.

Changes

File Change Summary
.../MicroplanSearchConfig.js Updated label from "MY_MICROPLANS" to "MY_MICROPLANS_HEADER" in TabSearchconfig.
.../UICustomizations.js Enhanced additionalCustomizations method for MyMicroplanSearchConfig and UserManagementConfig to improve button handling and logging; refined preProcess method and added rolesForFilter method.
.../searchSavedPlans.js Added TotalCount property to finalResponse object in SearchSavedPlans function.
.../searchSavedPlansWithCampaign.js Added totalCount property to finalResponse in SearchSavedPlansWithCampaign; refined error handling logic.

Possibly related PRs

Suggested reviewers

  • nipunarora-eGov
  • nabeelmd-eGov

🐰 In the fields where microplans bloom,
A header change dispels the gloom.
With buttons now more wise and bright,
Our search for plans takes flight!
So hop along, let's celebrate,
For UI's charm has grown so great! 🌼


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

🧹 Outside diff range comments (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchSavedPlansWithCampaign.js (1)

Line range hint 77-82: Enhance error handling with context and logging

The error handling could be more informative and maintainable:

  1. Add operation context to the generic error message
  2. Consider adding error logging for debugging
     if (error?.response?.data?.Errors) {
+      console.error("Plan search failed:", error.response.data);
       throw new Error(error.response.data.Errors[0].message);
     }
-    throw new Error("An unknown error occurred");
+    console.error("Unexpected error in plan search:", error);
+    throw new Error("Failed to search saved plans with campaign");
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MicroplanSearchConfig.js (2)

Line range hint 15-106: Add pagination configuration to support the new pagination feature.

The PR objective mentions adding pagination, but the configuration lacks pagination-specific parameters that are typically required for table pagination (e.g., page size, default page number).

Consider adding pagination configuration like this:

 apiDetails: {
   serviceName: "/plan-service/config/_search", 
   requestParam: {},
-  requestBody: {},
+  requestBody: {
+    PlanConfigurationSearchCriteria: {
+      pagination: {
+        limit: 10,
+        offset: 0,
+        sortBy: "name",
+        order: "DESC"
+      }
+    }
+  },
   masterName: "commonUiConfig",

Also, update the searchResult configuration to handle pagination:

 searchResult: {
   uiConfig: {
+    pagination: {
+      enabled: true,
+      defaultPageSize: 10,
+      pageSizeOptions: [10, 20, 50]
+    },
     columns: [

Line range hint 77-82: Consider adding tooltips for status columns.

The status column might benefit from tooltips explaining what each status means, especially for states like "EXECUTION_TO_BE_DONE" vs "EXECUTION_IN_PROGRESS".

 {label: "DRAFTED_SETUP"},
-{label: "EXECUTION_TO_BE_DONE",},
-{label:"EXECUTION_IN_PROGRESS"},
-{label:"MICROPLAN_EXECUTED"},
+{
+  label: "EXECUTION_TO_BE_DONE",
+  tooltip: "Plans that are ready for execution"
+},
+{
+  label: "EXECUTION_IN_PROGRESS",
+  tooltip: "Plans currently being executed"
+},
+{
+  label: "MICROPLAN_EXECUTED",
+  tooltip: "Plans that have completed execution"
+},
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 47017f0 and 4063ccd.

📒 Files selected for processing (4)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MicroplanSearchConfig.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (3 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchSavedPlans.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchSavedPlansWithCampaign.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MicroplanSearchConfig.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchSavedPlans.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchSavedPlansWithCampaign.js (1)

Pattern **/*.js: check

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

Line range hint 10-53: Verify pagination implementation completeness.

The function now returns totalCount, but there are several aspects to verify:

  1. Ensure the body parameter includes pagination parameters (offset/limit)
  2. Verify if the project-factory API call needs pagination
  3. Confirm that mergePlanAndCampaign function correctly handles paginated data

Let's verify the implementation:

✅ Verification successful

Let me gather more specific information about the pagination implementation in related files.


Based on the gathered information, I can now provide a final response:

Pagination implementation is properly handled

The pagination implementation is complete and correct:

  • The plan-service/config/_search API receives pagination parameters through PlanConfigurationSearchCriteria.pagination in the request body
  • The SearchSavedPlans function correctly:
    • Accepts pagination parameters through the body argument
    • Returns TotalCount from the plan service response
    • Properly merges paginated data from both APIs using mergePlanAndCampaign
  • The UI configuration in MicroplanSearchConfig.js and MyMicroplanSearchConfig.js properly maps pagination parameters through tableFormJsonPath: "requestBody.PlanConfigurationSearchCriteria.pagination"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for pagination parameters in API calls and related components

# Check for pagination parameter handling in related files
echo "Checking for pagination parameter handling..."
rg -l 'offset|limit|page' --type js

# Check for other pagination-related changes
echo "Checking for pagination UI components..."
rg -l 'Pagination|paginate|pageSize' --type js

# Look for similar implementations
echo "Checking for similar pagination patterns..."
ast-grep --pattern 'TotalCount|totalCount'

Length of output: 19425


Script:

#!/bin/bash
# Check the implementation of pagination in related microplan files
echo "Checking microplan pagination implementation..."
rg -A 10 -B 10 'plan-service/config/_search' --type js

# Check the usage of the SearchSavedPlans hook
echo "Checking usage of SearchSavedPlans..."
rg -A 5 -B 5 'SearchSavedPlans' --type js

# Check the mergePlanAndCampaign implementation
echo "Checking mergePlanAndCampaign implementation..."
ast-grep --pattern 'mergePlanAndCampaign'

Length of output: 48235

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchSavedPlansWithCampaign.js (1)

Line range hint 38-46: Verify pagination parameter handling

While the pagination implementation looks functional, consider adding these safeguards:

  1. Validate limit/offset values
  2. Enforce maximum page size
  3. Handle edge cases where offset exceeds total count
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MicroplanSearchConfig.js (1)

15-15: LGTM: Label update is consistent with the codebase.

The label change from "MY_MICROPLANS" to "MY_MICROPLANS_HEADER" looks good.

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

Line range hint 192-195: Pagination implementation looks good.

The preProcess method correctly handles pagination parameters (limit and offset) for the search criteria, which aligns with the PR objective of adding pagination to microplan search.

🧰 Tools
🪛 Biome

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant