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

fix: home widget reorder fix #6386

Merged
merged 1 commit into from
Jan 13, 2025
Merged

Conversation

sriramveeraghanta
Copy link
Contributor

@sriramveeraghanta sriramveeraghanta commented Jan 13, 2025

Description

Fixed manage widget reorder is not persisting.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Summary by CodeRabbit

Release Notes

  • Refactor

    • Updated workspace preference-related components and views
    • Corrected serializer field names for workspace home preferences
    • Improved user-specific preference retrieval
  • Bug Fixes

    • Fixed typos in workspace serializer read-only fields
    • Enhanced security for workspace home preferences by adding user-specific filtering

These changes improve the workspace preference management system with more precise naming and user-specific access controls.

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Walkthrough

This pull request involves renaming and refactoring workspace preference-related components across multiple files in the Plane application. The changes primarily focus on updating the naming convention from WorkspacePreference to WorkspaceHomePreference, including modifications to serializers, views, URLs, and frontend components. The key modifications ensure consistency in naming and improve user-specific preference handling by adding more precise filtering in the view methods.

Changes

File Change Summary
apiserver/plane/app/serializers/workspace.py Fixed typos in read_only_fields: corrected worspaceworkspace, update_byupdated_by
apiserver/plane/app/urls/workspace.py Replaced WorkspacePreferenceViewSet with WorkspaceHomePreferenceViewSet in URL patterns
apiserver/plane/app/views/__init__.py Updated imports: removed WorkspacePreferenceViewSet, added WorkspaceHomePreferenceViewSet
apiserver/plane/app/views/workspace/home.py Renamed class to WorkspaceHomePreferenceViewSet, added user-specific filtering in patch method
web/app/[workspaceSlug]/(projects)/page.tsx Replaced WorkspaceDashboardView with WorkspaceHomeView, updated import path

Sequence Diagram

sequenceDiagram
    participant User
    participant WorkspaceHomePreferenceViewSet
    participant Database
    
    User->>WorkspaceHomePreferenceViewSet: Request workspace home preferences
    WorkspaceHomePreferenceViewSet->>Database: Fetch preferences with user filter
    Database-->>WorkspaceHomePreferenceViewSet: Return user-specific preferences
    WorkspaceHomePreferenceViewSet-->>User: Respond with preferences
Loading

Possibly related PRs

Suggested labels

⚙️backend, 📡api, 🔄migrations

Suggested reviewers

  • pablohashescobar
  • NarayanBavisetti

Poem

🐰 Hopping through code with glee,
Workspace preferences, now set free!
From typos to clarity we leap,
Refactoring's a rabbit's keep,
Home views dancing, clean and bright,
Our code hops with pure delight! 🏠✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 25eb727 and 09a0f6d.

📒 Files selected for processing (5)
  • apiserver/plane/app/serializers/workspace.py (1 hunks)
  • apiserver/plane/app/urls/workspace.py (2 hunks)
  • apiserver/plane/app/views/__init__.py (1 hunks)
  • apiserver/plane/app/views/workspace/home.py (2 hunks)
  • web/app/[workspaceSlug]/(projects)/page.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apiserver/plane/app/serializers/workspace.py
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-apiserver
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (6)
web/app/[workspaceSlug]/(projects)/page.tsx (1)

6-6: LGTM! Component rename improves clarity

The rename from WorkspaceDashboardView to WorkspaceHomeView better reflects its purpose and aligns with the backend changes.

Also applies to: 22-22

apiserver/plane/app/views/workspace/home.py (3)

13-13: LGTM! Class rename improves clarity

The rename to WorkspaceHomePreferenceViewSet better reflects its specific purpose of managing home widget preferences.

Also applies to: 13-13


70-70: Security improvement: Added user filter

Adding the user filter ensures that users can only modify their own preferences. This is likely the fix for the widget reordering persistence issue.

Also applies to: 70-70


Line range hint 32-42: Verify the sort order calculation logic

The sort order calculation (1000 - sort_order_counter) seems to handle widget positioning. Please verify:

  1. Why start from 1000?
  2. Is this order maintained when widgets are reordered?
  3. Are there any edge cases when many widgets are added?
✅ Verification successful

Sort order implementation is well-designed and consistent with codebase patterns

The sort order calculation starting from 1000:

  1. Provides reasonable headroom for inserting widgets at the top (0-999)
  2. Supports proper widget reordering through decrementing values
  3. Can handle hundreds of widgets which is more than sufficient for the UI

The implementation follows established patterns seen throughout the codebase for sortable items and is safe as preferences are scoped per user/workspace.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any existing sort order implementations or tests
rg -A 5 "sort_order" --type python

Length of output: 65


Script:

#!/bin/bash
# Search for sort_order usage in all files
rg -A 5 "sort_order"

# Search for widget and preference related files
fd "widget|preference" --type f

# Search for preference model definition
ast-grep --pattern 'class $_ (models.Model):
  $$$
  sort_order = $_
  $$$'

Length of output: 113791

apiserver/plane/app/views/__init__.py (1)

44-45: LGTM! Import changes are consistent

The import changes align with the class rename from WorkspacePreferenceViewSet to WorkspaceHomePreferenceViewSet.

apiserver/plane/app/urls/workspace.py (1)

32-32: LGTM! URL patterns maintain compatibility

The view reference updates are consistent with the class rename while maintaining the same URL patterns for API compatibility.

Also applies to: 236-236, 241-241

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.

@sriramveeraghanta sriramveeraghanta merged commit b5493a3 into preview Jan 13, 2025
10 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-home-widget-reorder branch January 13, 2025 10:57
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.

2 participants