Skip to content

[WEB-3712] improvement: create draft work item logic#6847

Merged
sriramveeraghanta merged 1 commit intopreviewfrom
improvement-draft-work-item
Apr 1, 2025
Merged

[WEB-3712] improvement: create draft work item logic#6847
sriramveeraghanta merged 1 commit intopreviewfrom
improvement-draft-work-item

Conversation

@prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Mar 28, 2025

Description

Type of Change

  • Improvement (change that would cause existing functionality to not work as expected)

Summary by CodeRabbit

  • New Features
    • Added customization for the "no results" message in search dropdowns, giving users a more tailored experience when no options are available.
    • Enhanced issue modal interactions by introducing refined closing behavior and draft handling, ensuring smoother transitions and improved form submissions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

Walkthrough

This pull request introduces new customizable properties in dropdown and modal components. The noResultsMessage property is added to dropdown components for flexible messaging when no results are found. In addition, the issues modal components now include enhanced handling for closing the modal and drafting issues via new functions (sanitizeChanges and handleDraftAndClose) and updated type definitions. A new property to handle modal closure (handleModalClose) is also added to a related type.

Changes

File(s) Change Summary
packages/ui/.../custom-search-select.tsx
packages/ui/.../helper.tsx
Added new property noResultsMessage to enable customizable messaging when no dropdown options are available.
web/ce/.../template-select.tsx Added new required property handleModalClose for handling modal closure events.
web/core/.../draft-issue-layout.tsx
web/core/.../form.tsx
Introduced sanitizeChanges and handleDraftAndClose functions to manage issue draft creation and modal closing; updated method signatures accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IssueFormRoot
    participant DraftIssueLayout
    User->>IssueFormRoot: Triggers modal close
    IssueFormRoot->>DraftIssueLayout: Calls handleClose
    DraftIssueLayout->>DraftIssueLayout: Calls sanitizeChanges to filter changes
    alt If valid changes exist
        DraftIssueLayout->>DraftIssueLayout: Calls handleDraftAndClose to draft issue and close modal
    else No valid changes
        DraftIssueLayout->>User: Closes modal without drafting
    end
Loading

Possibly related PRs

Suggested labels

🌟improvement, 🌐frontend, 🧹chore

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham
  • rahulramesha

Poem

I'm a rabbit hopping through lines of code,
New props and functions lighten the load.
Custom messages now gracefully unfold,
Modal closings and drafts, so smartly told.
With nibbling joy, I celebrate this upgrade—
Leaping into change, in a whimsical parade!
🐇🥕

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@makeplane
Copy link

makeplane bot commented Mar 28, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

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

🧹 Nitpick comments (1)
web/core/components/issues/issue-modal/draft-issue-layout.tsx (1)

41-58: Good implementation of centralizing sanitization logic.

The new sanitizeChanges function effectively centralizes the logic for determining what constitutes a meaningful change, which improves code maintainability and consistency.

Consider addressing the static analysis warnings about the delete operator by using an alternative approach that may be more performant:

- if (value === null || value === undefined || value === "") delete sanitizedChanges[issueKey];
+ if (value === null || value === undefined || value === "") sanitizedChanges[issueKey] = undefined;

- if (typeof value === "object" && isEmpty(value)) delete sanitizedChanges[issueKey];
+ if (typeof value === "object" && isEmpty(value)) sanitizedChanges[issueKey] = undefined;

- if (Array.isArray(value) && value.length === 0) delete sanitizedChanges[issueKey];
+ if (Array.isArray(value) && value.length === 0) sanitizedChanges[issueKey] = undefined;

- if (issueKey === "project_id") delete sanitizedChanges.project_id;
+ if (issueKey === "project_id") sanitizedChanges.project_id = undefined;

- if (issueKey === "priority" && value && value === "none") delete sanitizedChanges.priority;
+ if (issueKey === "priority" && value && value === "none") sanitizedChanges.priority = undefined;

- delete sanitizedChanges.description_html;
+ sanitizedChanges.description_html = undefined;
🧰 Tools
🪛 Biome (1.9.4)

[error] 48-48: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 49-49: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 55-55: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 921dfe3 and 9ec0b6f.

📒 Files selected for processing (5)
  • packages/ui/src/dropdowns/custom-search-select.tsx (3 hunks)
  • packages/ui/src/dropdowns/helper.tsx (1 hunks)
  • web/ce/components/issues/issue-modal/template-select.tsx (1 hunks)
  • web/core/components/issues/issue-modal/draft-issue-layout.tsx (3 hunks)
  • web/core/components/issues/issue-modal/form.tsx (4 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
web/core/components/issues/issue-modal/form.tsx (1)
packages/constants/src/issue/modal.ts (1)
  • DEFAULT_WORK_ITEM_FORM_VALUES (4-19)
web/core/components/issues/issue-modal/draft-issue-layout.tsx (1)
web/core/components/issues/issue-modal/form.tsx (1)
  • IssueFormRoot (69-590)
🪛 Biome (1.9.4)
web/core/components/issues/issue-modal/draft-issue-layout.tsx

[error] 48-48: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 49-49: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 55-55: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (10)
packages/ui/src/dropdowns/helper.tsx (1)

46-46: Good addition of customizable messaging.

Adding the optional noResultsMessage property to the CustomSearchSelectProps interface enables greater flexibility for users of this component, allowing them to customize the message shown when no search results are found.

packages/ui/src/dropdowns/custom-search-select.tsx (2)

36-36: Good implementation with backward compatibility.

Adding the noResultsMessage prop with a default value ensures backward compatibility while allowing for customization. This is a clean implementation of the interface change.


202-202: Proper implementation of the customizable message.

The implementation correctly uses the noResultsMessage prop to display a custom message when no results are found, replacing the hardcoded text with the configurable property.

web/core/components/issues/issue-modal/form.tsx (4)

64-64: Well-defined optional property for draft handling.

Adding the optional handleDraftAndClose method to the IssueFormProps interface is a good approach for extending functionality without breaking existing code. This aligns with the PR objective of improving draft work item handling.


90-90: Properly destructured from props.

The handleDraftAndClose property is correctly destructured from the props, maintaining the pattern used for other properties in this component.


240-255: Improved form reset logic with template handling.

The enhanced reset logic that conditionally applies templates is a good improvement. When creating multiple items with a template, this ensures the template is consistently applied between submissions.


402-408: Good implementation of the modal close handler.

The conditional logic for handling modal closure is well-implemented. It appropriately delegates to either the draft-specific handler or the standard close handler based on availability.

web/core/components/issues/issue-modal/draft-issue-layout.tsx (3)

66-68: Good use of the sanitizeChanges function.

Using the newly created sanitizeChanges function here ensures consistent handling of the changes object and improves readability by abstracting the sanitization logic.


129-135: Well-implemented draft and close functionality.

The new handleDraftAndClose function provides a streamlined way to create a draft issue and close the modal in one step, enhancing the user experience.


149-149: Correctly integrates the new functionality with the form component.

Now that the handleDraftAndClose function is passed to the IssueFormRoot component, it can be used by child components to offer a "draft and close" workflow.

placeholder?: string;
renderChevron?: boolean;
dropDownContainerClassName?: string;
handleModalClose: () => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Consider making this property optional to maintain backward compatibility.

Adding a required property handleModalClose to an existing type could break existing implementations. If this component is already used elsewhere in the codebase, consider making this property optional with a default behavior.


🏁 Script executed:

#!/bin/bash
# Check for existing usages of the WorkItemTemplateSelect component
echo "Searching for usages of WorkItemTemplateSelect component..."
rg "WorkItemTemplateSelect" --type tsx --type jsx

Length of output: 206


Action Required: Verify the Optionality of the handleModalClose Property

  • The addition of the required handleModalClose property in web/ce/components/issues/issue-modal/template-select.tsx may break components that rely on a default behavior.
  • Our initial search encountered file type issues, so we recommend re-running the search (as done in the updated script above) to check if there are any usages of the WorkItemTemplateSelect component.
  • If further verification confirms that the component is used without explicitly providing a handleModalClose prop, adjust the interface to make this property optional and implement a suitable default behavior.

🏁 Script executed:

#!/bin/bash
# Updated search for usages of WorkItemTemplateSelect component using explicit file globs for tsx and jsx files
echo "Searching for usages of WorkItemTemplateSelect in .tsx and .jsx files..."
rg "WorkItemTemplateSelect" -g "*.tsx" -g "*.jsx"

Length of output: 605


Action Required: Make handleModalClose Optional to Maintain Backward Compatibility

  • Our updated search confirms that the WorkItemTemplateSelect component is used in web/core/components/issues/issue-modal/form.tsx without an explicit handleModalClose prop.
  • Keeping handleModalClose as a required property risks breaking existing implementations.
  • Please update the type in web/ce/components/issues/issue-modal/template-select.tsx by marking handleModalClose as optional (for example, change it from
      handleModalClose: () => void;
    to
      handleModalClose?: () => void;
    ) and implement a default behavior if none is provided.

@sriramveeraghanta sriramveeraghanta merged commit 7bb2914 into preview Apr 1, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the improvement-draft-work-item branch April 1, 2025 15:17
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.

3 participants