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

fix: cycles import issues for ee #5732

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Oct 1, 2024

Summary
Added mock files in EE folder to fix imports

Summary by CodeRabbit

  • New Features

    • Enhanced functionality for the Cycle Analytics Progress component, improving data handling and user interactions.
    • Added error handling for fetching cycle details, enhancing user experience.
    • Introduced new exports for active-cycle and analytics-sidebar modules, simplifying access to their functionalities.
  • Bug Fixes

    • Improved validation logic for cycle snapshots to ensure accurate updates based on the presence of progress data.

Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

Walkthrough

The pull request introduces several modifications to the cycle management components, specifically improving the CycleAnalyticsProgress component's handling of cycle details and user interactions. It also includes re-exports for the active-cycle and analytics-sidebar modules, enhancing accessibility for their functionalities. The changes aim to refine state management, error handling, and data processing within the components.

Changes

Files Change Summary
web/core/components/cycles/analytics-sidebar/issue-progress.tsx Modified import paths, updated validateCycleSnapshot function, refined state management, and enhanced error handling.
web/ee/components/cycles/active-cycle/index.ts Added export statement to re-export all entities from ce/components/cycles/active-cycle.
web/ee/components/cycles/analytics-sidebar/index.ts Added export statement to re-export all entities from ce/components/cycles/analytics-sidebar.
web/ee/components/cycles/index.ts Introduced new exports from active-cycle and analytics-sidebar modules.

Possibly related PRs

Suggested labels

⚙️backend, 🐛bug, 🧹chore

Suggested reviewers

  • SatishGandham
  • pablohashescobar

🐇 In the meadow where cycles spin,
I hop and cheer for the changes within.
With progress refined and exports anew,
The components now dance, oh so true!
Let users rejoice, their paths made clear,
In the world of cycles, we hold dear! 🌼


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.

@gakshita gakshita requested a review from SatishGandham October 1, 2024 14:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
web/ee/components/cycles/active-cycle/index.ts (1)

1-1: LGTM! This change effectively addresses the import cycle issue.

The addition of this re-export statement aligns well with the PR objectives by resolving import issues in the EE folder. It provides a clean way to make CE components available in the EE context, promoting modularity and separation of concerns between CE and EE.

For future consideration: If only specific components from the CE active-cycle module are needed in the EE context, you might want to consider explicitly naming the exports. This could potentially improve performance and make the dependencies clearer. For example:

export { ComponentA, ComponentB } from "ce/components/cycles/active-cycle";

However, this is just a suggestion for future optimization and is not necessary for the current implementation.

web/ee/components/cycles/analytics-sidebar/index.ts (1)

1-1: Approved: Good solution for resolving import cycles

This change aligns well with the PR objectives by creating a mock file in the EE folder to resolve import cycle issues. Re-exporting the CE components allows for easy extension or overriding in the EE context if needed in the future.

To further improve this solution:

  1. Consider adding a comment explaining the purpose of this file and the pattern being used.
  2. Ensure this pattern is consistently applied to other components that may face similar import cycle issues.
  3. Update the project documentation to explain this architectural decision for future developers.

Would you like assistance in drafting a comment for this file or updating the project documentation?

web/core/components/cycles/analytics-sidebar/issue-progress.tsx (2)

Line range hint 106-120: Refactor groupedIssues to reduce repetition and enhance maintainability.

The current implementation of groupedIssues contains repetitive code when assigning values based on estimateType. Refactoring this logic can simplify the code and make it more maintainable.

Consider applying the following refactor:

-const groupedIssues = useMemo(
-  () => ({
-    backlog:
-      estimateType === "points" ? cycleDetails?.backlog_estimate_points || 0 : cycleDetails?.backlog_issues || 0,
-    unstarted:
-      estimateType === "points" ? cycleDetails?.unstarted_estimate_points || 0 : cycleDetails?.unstarted_issues || 0,
-    started:
-      estimateType === "points" ? cycleDetails?.started_estimate_points || 0 : cycleDetails?.started_issues || 0,
-    completed:
-      estimateType === "points" ? cycleDetails?.completed_estimate_points || 0 : cycleDetails?.completed_issues || 0,
-    cancelled:
-      estimateType === "points" ? cycleDetails?.cancelled_estimate_points || 0 : cycleDetails?.cancelled_issues || 0,
-  }),
-  [estimateType, cycleDetails]
-);
+const groupedIssues = useMemo(() => {
+  const statuses = ["backlog", "unstarted", "started", "completed", "cancelled"];
+  const result: { [key: string]: number } = {};
+  statuses.forEach((status) => {
+    const pointsKey = `${status}_estimate_points` as keyof ICycle;
+    const issuesKey = `${status}_issues` as keyof ICycle;
+    result[status] = estimateType === "points"
+      ? cycleDetails?.[pointsKey] || 0
+      : cycleDetails?.[issuesKey] || 0;
+  });
+  return result;
+}, [estimateType, cycleDetails]);

This refactor reduces duplication and makes it easier to manage if additional statuses are added in the future.


Line range hint 160-162: Provide feedback or loading state when cycleDetails is not available.

Currently, if cycleDetails is null or undefined, the component returns an empty fragment (<></>). Consider enhancing the user experience by displaying a loading indicator or an informative message in this scenario.

For example, you could modify the code to display a loader:

-if (!cycleDetails) return <></>;
+if (!cycleDetails) return <Spinner />; // Assuming Spinner is a loading indicator component

Or display a message:

-if (!cycleDetails) return <></>;
+if (!cycleDetails) return <p>Loading cycle details...</p>;

This provides users with visual feedback that data is being fetched.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4940dc2 and 8da4a48.

📒 Files selected for processing (4)
  • web/core/components/cycles/analytics-sidebar/issue-progress.tsx (1 hunks)
  • web/ee/components/cycles/active-cycle/index.ts (1 hunks)
  • web/ee/components/cycles/analytics-sidebar/index.ts (1 hunks)
  • web/ee/components/cycles/index.ts (1 hunks)
🔇 Additional comments (2)
web/ee/components/cycles/index.ts (1)

1-2: LGTM! Verify the existence of imported modules.

The changes look good and align with the PR objectives. The index file is correctly set up to re-export all entities from the "active-cycle" and "analytics-sidebar" modules, which should help resolve the import issues mentioned in the PR description.

To ensure the imported modules exist, please run the following script:

This script will help confirm that the imported modules exist in the expected location or elsewhere in the web/ee directory.

web/core/components/cycles/analytics-sidebar/issue-progress.tsx (1)

21-21: Verify the updated import path for SidebarBaseChart.

The import path for SidebarBaseChart has been changed to "@/plane-web/components/cycles/analytics-sidebar". Please ensure that this new path is correct and does not introduce any import cycle issues or module resolution problems.

To verify the correctness of the new import path and check for potential import cycles, you can run the following script:

@SatishGandham SatishGandham merged commit 5474ab3 into preview Oct 1, 2024
14 of 15 checks passed
@SatishGandham SatishGandham deleted the fix-cycles-ee-imports-issues branch October 1, 2024 14:22
This was referenced Oct 3, 2024
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