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-2629] fix: workspace draft delete and move mutation #5822

Merged
merged 4 commits into from
Oct 14, 2024

Conversation

anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Oct 14, 2024

Changes:

This PR includes following changes:

  • Fixed the mutation for deleting and moving workspace draft issues.
  • Removed unnecessary code.

Reference:

[WEB-2629]

Summary by CodeRabbit

  • New Features

    • Introduced the WorkspaceDraftIssuesRoot component for improved management of workspace draft issues.
    • Implemented a new hook, useWorkspaceIssueProperties, to fetch issue properties based on the workspace.
  • Bug Fixes

    • Enhanced rendering logic for displaying empty states and loaders based on issue availability.
  • Refactor

    • Streamlined the methods for deleting and moving issues, improving clarity and maintainability.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

The changes in this pull request involve the introduction of the WorkspaceDraftIssuesRoot component, which utilizes the useWorkspaceIssueProperties hook to fetch issue properties based on the workspaceSlug. The rendering logic for the WorkspaceDraftEmptyState and WorkspaceDraftIssuesLoader components has been streamlined. Additionally, modifications were made to the deleteIssue and moveIssue methods in the WorkspaceDraftIssues class, enhancing the clarity of the issue removal process.

Changes

File Path Change Summary
web/core/components/issues/workspace-draft/root.tsx Introduced WorkspaceDraftIssuesRoot component; removed WorkspaceDraftIssueLayoutRoot component; updated rendering logic for empty state and loader.
web/core/store/issue/workspace-draft/issue.store.ts Updated deleteIssue and moveIssue methods to use filter and delete for removing issues from maps.

Possibly related PRs

Suggested reviewers

  • sriramveeraghanta
  • rahulramesha
  • SatishGandham

🐇 In the meadow, where issues once lay,
A component has hopped on its way.
With filters and drafts, we’ve made it clear,
Removing the clutter, let’s give a cheer!
Quick actions await, in the workspace bright,
A new dawn for issues, all set for flight! 🌼


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/store/issue/workspace-draft/issue.store.ts (2)

302-305: Improved implementation for removing issues.

The new implementation is more explicit and easier to understand. It correctly removes the issue from both issueMapIds and issuesMap.

Consider combining the operations to reduce the number of property accesses:

-this.issueMapIds[workspaceSlug] = (this.issueMapIds[workspaceSlug] || []).filter((id) => id !== issueId);
-delete this.issuesMap[issueId];
+const workspaceIssueIds = this.issueMapIds[workspaceSlug];
+if (workspaceIssueIds) {
+  this.issueMapIds[workspaceSlug] = workspaceIssueIds.filter((id) => id !== issueId);
+  delete this.issuesMap[issueId];
+}

This change ensures that we only perform the delete operation if the workspace actually exists in issueMapIds, potentially avoiding unnecessary operations.


Line range hint 1-424: Summary of changes and their impact

The modifications to deleteIssue and moveIssue methods improve the clarity of the code by using more explicit operations to remove issues from issueMapIds and issuesMap. These changes align with the PR objectives of fixing the mutation process for deleting and moving workspace draft issues.

However, there are two points that require attention:

  1. The deleteIssue method could be optimized to reduce property accesses.
  2. The moveIssue method's implementation is identical to deleteIssue, which may not be the intended behavior for a move operation.

These changes should improve the overall functionality and maintainability of the workspace draft issue management. Once the moveIssue behavior is clarified and the suggested optimizations are considered, this update will significantly contribute to resolving the issues mentioned in [WEB-2629].

Consider adding unit tests for these methods to ensure their correct behavior and prevent future regressions. This is especially important given the critical nature of these operations in managing workspace draft issues.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 701af73 and eb380a0.

📒 Files selected for processing (2)
  • web/core/components/issues/issue-layouts/filters/applied-filters/roots/workspace-draft-root.tsx (0 hunks)
  • web/core/store/issue/workspace-draft/issue.store.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • web/core/components/issues/issue-layouts/filters/applied-filters/roots/workspace-draft-root.tsx
🧰 Additional context used
🔇 Additional comments (1)
web/core/store/issue/workspace-draft/issue.store.ts (1)

329-332: ⚠️ Potential issue

Clarify the intended behavior of moveIssue.

The current implementation of moveIssue is identical to deleteIssue, removing the issue entirely from issueMapIds and issuesMap. However, the method name suggests that the issue should be moved, not deleted.

Please clarify if this is the intended behavior. If not, consider updating the implementation to reflect a move operation, such as updating the issue's position or associated data instead of removing it completely.

To verify the intended behavior, we can check the API implementation:

This will help us understand if the backend treats move and delete operations differently, which should inform our frontend implementation.

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/root.tsx (2)

32-34: LGTM: New hook usage implemented correctly.

The useWorkspaceIssueProperties hook is correctly implemented with the workspaceSlug prop. The comment provides clarity on its purpose.

Consider updating the comment to be more specific:

-//swr hook for fetching issue properties
+// Hook for fetching workspace issue properties

This change would more accurately describe the hook's specific functionality.


60-62: LGTM: Updated rendering logic for WorkspaceDraftIssuesLoader.

The condition for rendering the loader has been appropriately updated to display only during the initial loading state. This change improves the component's behavior and user experience.

For consistency with the previous condition, consider using the same comparison operator:

-if (loader === "init-loader") {
+if (loader === "init-loader") {

This change maintains a consistent coding style throughout the component.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between eb380a0 and 5020a2c.

📒 Files selected for processing (1)
  • web/core/components/issues/workspace-draft/root.tsx (3 hunks)
🧰 Additional context used
🔇 Additional comments (3)
web/core/components/issues/workspace-draft/root.tsx (3)

15-15: LGTM: New hook import added.

The import for useWorkspaceIssueProperties is correctly placed and seems relevant to the component's functionality.


58-59: LGTM: Simplified rendering logic for WorkspaceDraftEmptyState.

The condition for rendering the empty state has been streamlined, making it more readable and straightforward. This change correctly handles the case when there are no issues to display.


Line range hint 1-96: Overall assessment: Changes improve component functionality and readability.

The modifications to WorkspaceDraftIssuesRoot align well with the PR objectives. The introduction of the useWorkspaceIssueProperties hook and the streamlined rendering logic for empty states and loaders enhance the component's functionality and readability. The changes are well-implemented and no major issues were identified.

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.

2 participants