Skip to content

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Oct 23, 2024

Changes:

This PR addresses an issue where the custom properties data would be lost when clicking outside the draft issue form. Previously, the correct custom properties endpoint was not being triggered when the user filled out the "create issue" form and click outside. I've made the necessary changes to ensure the endpoint is now properly hit, resolving the issue.

Reference:

[WEB-2715]

Summary by CodeRabbit

  • New Features

    • Enhanced issue creation and updating logic.
    • Improved management of draft status for issues.
  • Bug Fixes

    • Refined error handling for issue creation and updates to ensure accurate error messages.
  • Refactor

    • Updated component state management related to project and issue details.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

The changes in this pull request focus on the CreateUpdateIssueModalBase component within the base.tsx file. Key modifications include updating method parameters for handling draft statuses, enhancing error handling in issue creation and updates, and refining state management related to project and issue details. The fetchIssueDetail function has been adjusted to set the issue description appropriately, and the handleClose function now includes logic to save drafts when necessary. Overall, these changes improve the functionality and reliability of the issue modal.

Changes

File Path Change Summary
web/core/components/issues/issue-modal/base.tsx Updated handleCreateIssue, handleUpdateIssue, and handleFormSubmit methods to adjust draft handling. Refined error handling and state management in fetchIssueDetail and handleClose.

Possibly related PRs

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

Poem

🐰 In the meadow where issues bloom,
A modal dances, dispelling gloom.
Drafts are saved with a gentle touch,
Error messages, clearer as such.
With each change, a hop and a cheer,
Creating updates, we hold so 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.

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 (3)
web/core/components/issues/issue-modal/base.tsx (3)

Line range hint 144-150: Consider adding visual feedback for draft auto-save

When changes are auto-saved as draft on modal close, users might benefit from a visual indication. Consider showing a toast notification to inform users their changes were preserved.

   if (changesMade && saveAsDraft && !data) {
     handleCreateIssue(changesMade, true);
+    setToast({
+      type: TOAST_TYPE.SUCCESS,
+      title: "Draft Saved",
+      message: "Your changes have been saved as a draft."
+    });
   }

Line range hint 235-246: Enhance error tracking for better debugging

Consider including more detailed error information in the event tracking to aid debugging.

   } catch (error) {
     setToast({
       type: TOAST_TYPE.ERROR,
       title: "Error!",
-      message: `${is_draft_issue ? "Draft issue" : "Issue"} could not be created. Please try again.`,
+      message: `${is_draft_issue ? "Draft issue" : "Issue"} could not be created: ${error.message || 'Unknown error'}`,
     });
     captureIssueEvent({
       eventName: ISSUE_CREATED,
       payload: { 
         ...payload, 
-        state: "FAILED" 
+        state: "FAILED",
+        error: error.message
       },
       path: pathname,
     });
     throw error;
   }

Line range hint 89-108: Consider more thorough state cleanup

The cleanup function only resets the description state. Consider resetting all component-level states in the cleanup function to prevent potential stale states.

   useEffect(() => {
     // ... existing code ...

-    return () => setDescription(undefined);
+    return () => {
+      setDescription(undefined);
+      setChangesMade(null);
+      setCreateMore(false);
+      setUploadedAssetIds([]);
+    };
   }, [data, projectId, isOpen, activeProjectId]);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 25a4107 and 486f278.

📒 Files selected for processing (1)
  • web/core/components/issues/issue-modal/base.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
web/core/components/issues/issue-modal/base.tsx (2)

207-207: LGTM: Parameter rename improves consistency

The rename from isDraft to is_draft_issue aligns with the codebase's naming convention and ensures consistent draft state handling.


Line range hint 144-150: Verify consistent draft handling across codebase

Let's verify that the draft issue handling is consistent across the codebase.

Also applies to: 207-207

✅ Verification successful

Based on the search results, I can now generate the final response as I have sufficient information about the draft handling implementation across the codebase.

Draft issue handling is consistently implemented across the codebase

The codebase shows a well-structured and consistent implementation of draft issue handling:

  • The isDraft flag is consistently used across components and properly propagated through the component hierarchy
  • The is_draft_issue parameter is consistently used in create/update operations
  • Draft-specific UI states and messages are properly handled
  • Draft-specific storage and API calls are properly segregated

The implementation in the reviewed code aligns with the rest of the codebase's patterns for handling draft issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent draft issue handling across the codebase

# Check for any inconsistent draft parameter naming
echo "Checking for inconsistent draft parameter naming..."
rg -g '*.{ts,tsx}' -A 2 -B 2 'isDraft|is_draft_issue'

# Check for potential places where draft handling might be needed
echo "Checking for other modal close handlers that might need draft handling..."
ast-grep --pattern 'handleClose() {
  $$$
}'

Length of output: 27542

Copy link
Contributor

@rahulramesha rahulramesha left a comment

Choose a reason for hiding this comment

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

@anmolsinghbhatia approving this since the name was already there but please use camelCase going forward.

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.

4 participants