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

[WEB-2707] fix: draft issue module update and code refactor #5889

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Oct 22, 2024

Changes:

This PR fixes a bug where the module multi-select functionality was not working correctly for draft issues.

Reference:

[WEB-2707]

Summary by CodeRabbit

  • New Features

    • Introduced functionality to move issues to another project via a new modal.
    • Enhanced the CreateUpdateIssueModal to handle moving issues based on user input.
  • Bug Fixes

    • Improved responsiveness of the DraftIssueBlock component to sidebar state changes.
  • Refactor

    • Streamlined the DraftIssueProperties component by removing unnecessary imports and simplifying module management logic.
    • Removed the activeLayout property from the IIssueProperties interface.

Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

The changes introduce a new state variable moveToIssue in the DraftIssueBlock component, enabling tracking of user intent to move issues to different projects. The MENU_ITEMS array is updated to include a move action, triggering the CreateUpdateIssueModal with the new state. The modal's onSubmit function is modified to accommodate this state. The DraftIssueProperties component sees the removal of the activeLayout prop and several adjustments in its internal logic, including imports and method signatures, streamlining the component's functionality.

Changes

File Path Change Summary
web/core/components/issues/workspace-draft/draft-issue-block.tsx - Added state variable moveToIssue to track moving issues.
- Updated MENU_ITEMS to include move action.
- Modified CreateUpdateIssueModal to receive moveToIssue prop.
- Adjusted onSubmit function to check issueToEdit before updating.
web/core/components/issues/workspace-draft/draft-issue-properties.tsx - Removed imports of xor and usePathname.
- Updated IIssueProperties interface to remove activeLayout.
- Simplified DraftIssueProperties logic by removing useEventTracker and adjusting module operations.

Possibly related PRs

Suggested labels

⚙️backend

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐇 In the meadow, issues take flight,
With moveToIssue, we set things right.
Modals open, layouts shift,
Drafts now dance, a seamless gift.
Hop along, let changes bloom,
In our projects, there's always room! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 98e4db2 and ee4aedc.

📒 Files selected for processing (1)
  • web/core/components/issues/workspace-draft/draft-issue-properties.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/issues/workspace-draft/draft-issue-properties.tsx

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

🧹 Outside diff range and nitpick comments (2)
web/core/components/issues/workspace-draft/draft-issue-properties.tsx (2)

55-58: LGTM! Consider adding error handling.

The addition of the updateModulesToIssue method simplifies the process of updating modules for an issue, which is a good improvement. This change aligns well with the simplification mentioned in the AI summary.

Consider adding basic error handling to improve robustness:

 updateModulesToIssue: async (moduleIds: string[]) => {
   if (!workspaceSlug || !issue.id) return;
-  await addModulesToIssue(workspaceSlug.toString(), issue.id, moduleIds);
+  try {
+    await addModulesToIssue(workspaceSlug.toString(), issue.id, moduleIds);
+  } catch (error) {
+    console.error("Failed to update modules:", error);
+    // Consider adding user feedback here
+  }
 },

87-89: LGTM! Consider improving type safety.

The simplification of the handleModule function and the update to its dependency array are good improvements. These changes align well with the modifications made to the issueOperations object.

To improve type safety, consider using a non-null assertion or a type guard:

 const handleModule = useCallback(
   (moduleIds: string[] | null) => {
-    if (!issue || !issue.module_ids || !moduleIds) return;
+    if (!issue?.module_ids || !moduleIds) return;
     issueOperations.updateModulesToIssue(moduleIds);
   },
   [issueOperations, issue]
 );

This change ensures that issue is defined when updateModulesToIssue is called.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4c20be6 and 98e4db2.

📒 Files selected for processing (2)
  • web/core/components/issues/workspace-draft/draft-issue-block.tsx (0 hunks)
  • web/core/components/issues/workspace-draft/draft-issue-properties.tsx (6 hunks)
💤 Files with no reviewable changes (1)
  • web/core/components/issues/workspace-draft/draft-issue-block.tsx
🧰 Additional context used
🔇 Additional comments (4)
web/core/components/issues/workspace-draft/draft-issue-properties.tsx (4)

98-98: LGTM! Dependency array update is consistent.

The update to the dependency array of the handleCycle function, removing currentLayout and pathname, is consistent with the overall changes in the component. This aligns well with the removal of the activeLayout prop and related logic.


Line range hint 1-269: Overall changes improve component simplicity and maintainability.

The modifications to this component, including the removal of layout-related props and logic, the simplification of module and cycle handling, and the updates to import statements, collectively contribute to a more streamlined and maintainable codebase. These changes align well with the PR objectives and the AI-generated summary.

Key improvements:

  1. Simplified module and cycle handling logic
  2. Removal of unused layout-related code
  3. Updated import statements for better type safety

The changes suggest a shift in how layout is managed, possibly at a higher level in the component tree. This refactoring appears to be part of a larger effort to improve the draft issue module's architecture.

To ensure these changes haven't introduced any regressions, please verify:

  1. The functionality of module and cycle management in the draft issue interface
  2. The correct rendering of the component without the previously used activeLayout prop

Consider running relevant unit and integration tests, and perform manual testing of the draft issue interface to confirm all functionalities are working as expected.


38-38: LGTM! Verify impact on component functionality.

The removal of the activeLayout prop from the destructuring is consistent with the changes mentioned in the AI summary. This suggests a shift in how layout management is handled in the component.

To ensure this change doesn't negatively impact the component's functionality, please verify:

  1. That activeLayout is not used elsewhere in the component.
  2. That any parent components passing activeLayout have been updated.

Run the following command to check for any remaining references to activeLayout in this file:

#!/bin/bash
# Description: Check for references to activeLayout in the file

rg 'activeLayout' web/core/components/issues/workspace-draft/draft-issue-properties.tsx

5-5: LGTM! Consider verifying unused imports.

The changes to the import statements look good. The addition of useParams and specific types from '@plane/types' suggests improved type safety and routing functionality. The removal of useEventTracker from the hooks import indicates a potential shift in how events are tracked or that this functionality is no longer needed in this component.

To ensure code cleanliness, please run the following command to check for any unused imports:

Also applies to: 9-9, 24-24

✅ Verification successful

No unused imports found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for unused imports in the file

rg --no-filename --no-line-number --only-matching '^import .* from .*' web/core/components/issues/workspace-draft/draft-issue-properties.tsx | while read -r import; do
  if ! rg -q "${import#import * from }" web/core/components/issues/workspace-draft/draft-issue-properties.tsx; then
    echo "Potentially unused import: $import"
  fi
done

Length of output: 263


Script:

#!/bin/bash
# Description: Check for unused imports in the file

rg --no-filename --no-line-number --only-matching '^import .* from .*' web/core/components/issues/workspace-draft/draft-issue-properties.tsx | while read -r import; do
  if ! rg -q "${import#import * from }" web/core/components/issues/workspace-draft/draft-issue-properties.tsx; then
    echo "Potentially unused import: $import"
  fi
done

Length of output: 1323


Script:

#!/bin/bash
# Description: Check for unused imports in the file

rg --no-filename --no-line-number --only-matching '^import .* from .*' web/core/components/issues/workspace-draft/draft-issue-properties.tsx | while read -r import; do
  module=$(echo "$import" | sed -E 's/import .* from "(.*)";/\1/')
  if ! rg -q "$module" web/core/components/issues/workspace-draft/draft-issue-properties.tsx; then
    echo "Potentially unused import: $import"
  fi
done

Length of output: 2682

@pushya22 pushya22 merged commit 36b868e into preview Oct 22, 2024
14 of 15 checks passed
@pushya22 pushya22 deleted the chore-draft-issue-module-update branch October 22, 2024 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants