Skip to content

[WEB-3207] chore: add state_id, priority and assignee_ids to create issue relation response#6448

Merged
pushya22 merged 1 commit intopreviewfrom
fix/issue-relation-response
Jan 23, 2025
Merged

[WEB-3207] chore: add state_id, priority and assignee_ids to create issue relation response#6448
pushya22 merged 1 commit intopreviewfrom
fix/issue-relation-response

Conversation

@prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Jan 23, 2025

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced issue serialization with additional fields for state, priority, and assignees
    • Improved support for epic-related operations in issue management
  • Improvements

    • Streamlined issue and epic operation handling in relation components
    • Simplified menu item rendering and text labels for issue relations
  • Bug Fixes

    • Updated operation handling to correctly manage different issue types (standard issues and epics)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

This pull request introduces enhancements to issue serializers and components related to issue relations, focusing on expanding the data representation for issues. The changes primarily involve adding new fields like state_id, priority, and assignee_ids to serializers, and modifying components to handle different issue types (such as epics) more dynamically. The modifications aim to provide more comprehensive information about issues and improve the flexibility of issue-related operations.

Changes

File Change Summary
apiserver/plane/app/serializers/issue.py Added state_id, priority, and assignee_ids fields to IssueRelationSerializer and RelatedIssueSerializer
web/core/components/issues/issue-detail-widgets/relations/content.tsx Updated to handle epic and issue operations differently, added conditional modal rendering
web/core/components/issues/issue-detail-widgets/relations/helper.tsx Introduced dynamic entityName for customized toast messages
web/core/components/issues/relations/issue-list-item.tsx Removed issueOperations prop, added useRelationOperations hook
web/core/components/issues/relations/issue-list.tsx Removed issueOperations property from Props type

Possibly related PRs

Suggested labels

⚙️backend, 🧹chore, 📡api

Suggested reviewers

  • sriramveeraghanta
  • rahulramesha
  • pushya22

Poem

🐰 In the realm of issues, a rabbit's delight,
New fields bloom, making serializers bright!
Epics and tasks, now dancing with grace,
Flexibility leaps with a technological embrace! 🚀
Code evolves, complexity takes flight! 🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 1

🧹 Nitpick comments (4)
web/core/components/issues/issue-detail-widgets/relations/content.tsx (3)

152-152: Simplify condition by removing redundant double-negation

The use of !! is unnecessary here because the ternary operator already evaluates the condition as a boolean. Removing the double-negation improves code readability.

Apply this diff to simplify the condition:

-                const deleteOperation = !!issueCrudState.delete.issue?.is_epic
+                const deleteOperation = issueCrudState.delete.issue?.is_epic
🧰 Tools
🪛 Biome (1.9.4)

[error] 152-152: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


163-163: Simplify condition by removing redundant double-negation

Similarly, the double-negation !! in this conditional expression is unnecessary. Removing it will make the code cleaner and more straightforward.

Apply this diff to simplify the condition:

-              {!!issueCrudState?.update?.issue?.is_epic ? (
+              {issueCrudState?.update?.issue?.is_epic ? (
🧰 Tools
🪛 Biome (1.9.4)

[error] 163-163: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


162-188: Remove unnecessary Fragment to streamline JSX

The Fragment (<> and </>) wrapping this section is not needed because it contains only one child element. Eliminating the Fragment simplifies the JSX structure.

Apply this diff to remove the unnecessary Fragment:

-            <>
               {issueCrudState?.update?.issue?.is_epic ? (
                 <CreateUpdateEpicModal
                   isOpen={issueCrudState?.update?.toggle}
                   onClose={() => {
                     handleIssueCrudState("update", null, null);
                     toggleCreateIssueModal(false);
                   }}
                   data={issueCrudState?.update?.issue ?? undefined}
                   onSubmit={async (_issue: TIssue) => {
                     await epicOperations.update(workspaceSlug, projectId, _issue.id, _issue);
                   }}
                 />
               ) : (
                 <CreateUpdateIssueModal
                   isOpen={issueCrudState?.update?.toggle}
                   onClose={() => {
                     handleIssueCrudState("update", null, null);
                     toggleCreateIssueModal(false);
                   }}
                   data={issueCrudState?.update?.issue ?? undefined}
                   onSubmit={async (_issue: TIssue) => {
                     await issueOperations.update(workspaceSlug, projectId, _issue.id, _issue);
                   }}
                 />
               )}
-            </>
🧰 Tools
🪛 Biome (1.9.4)

[error] 163-163: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 162-188: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

web/core/components/issues/relations/issue-list-item.tsx (1)

58-58: Simplify condition by removing redundant double-negation

The double-negation !! is unnecessary since the ternary operator will coerce the condition to a boolean. Removing it enhances code readability.

Apply this diff to simplify the condition:

-      const issueOperations = useRelationOperations(!!issue?.is_epic ? EIssueServiceType.EPICS : EIssueServiceType.ISSUES);
+      const issueOperations = useRelationOperations(issue?.is_epic ? EIssueServiceType.EPICS : EIssueServiceType.ISSUES);
🧰 Tools
🪛 Biome (1.9.4)

[error] 58-58: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 586a320 and 034ed03.

📒 Files selected for processing (5)
  • apiserver/plane/app/serializers/issue.py (2 hunks)
  • web/core/components/issues/issue-detail-widgets/relations/content.tsx (4 hunks)
  • web/core/components/issues/issue-detail-widgets/relations/helper.tsx (4 hunks)
  • web/core/components/issues/relations/issue-list-item.tsx (3 hunks)
  • web/core/components/issues/relations/issue-list.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • web/core/components/issues/relations/issue-list.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
web/core/components/issues/relations/issue-list-item.tsx

[error] 58-58: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

web/core/components/issues/issue-detail-widgets/relations/content.tsx

[error] 152-152: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 163-163: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 162-188: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-apiserver
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
web/core/components/issues/issue-detail-widgets/relations/helper.tsx (1)

26-27: Dynamic entity names enhance user feedback

Introducing the entityName variable to customize messages based on issueServiceType improves clarity and provides a better user experience.

apiserver/plane/app/serializers/issue.py (1)

319-323: Fix inconsistency in assignee_ids field implementation.

The same issue exists here as in IssueRelationSerializer. The field is marked as write_only=True but lacks the necessary implementation.

Comment on lines +288 to +292
assignee_ids = serializers.ListField(
child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()),
write_only=True,
required=False,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix inconsistency in assignee_ids field implementation.

The assignee_ids field is marked as write_only=True but:

  1. It's not sourced from related_issue like other fields
  2. There are no create/update methods to handle the write operations

Consider one of these fixes:

-    assignee_ids = serializers.ListField(
-        child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()),
-        write_only=True,
-        required=False,
-    )
+    # Option 1: Make it read-only like other fields
+    assignee_ids = serializers.ListField(
+        child=serializers.UUIDField(),
+        source="related_issue.assignees.all",
+        read_only=True,
+    )
+
+    # Option 2: Add create/update methods to handle write operations
+    assignee_ids = serializers.ListField(
+        child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()),
+        write_only=True,
+        required=False,
+    )
+
+    def create(self, validated_data):
+        assignees = validated_data.pop("assignee_ids", None)
+        instance = super().create(validated_data)
+        if assignees is not None:
+            instance.related_issue.assignees.set(assignees)
+        return instance

Committable suggestion skipped: line range outside the PR's diff.

@pushya22 pushya22 merged commit 0b53912 into preview Jan 23, 2025
11 of 14 checks passed
@pushya22 pushya22 deleted the fix/issue-relation-response branch January 23, 2025 08:46
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.

4 participants