Skip to content

Conversation

@gakshita
Copy link
Collaborator

@gakshita gakshita commented Jan 9, 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

  • Refactor

    • Removed workspace dashboard header and page components.
    • Introduced a new ContentOverflowWrapper for improved layout and overflow handling.
    • Enhanced structure and styling for project links and recent activities widgets.
  • Bug Fixes

    • Filtered recent activities widget to exclude incomplete data entries.
  • Performance

    • Improved state management and transitions for a smoother user experience.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request involves significant changes to the web application's frontend structure, primarily focusing on removing the WorkspaceDashboardHeader and WorkspaceDashboardPage components. It also introduces enhancements to content overflow handling and modifies the rendering logic for project links and recent activities. These changes include the addition of a new ContentOverflowWrapper component and improved transition effects, aimed at refining the overall user interface and experience.

Changes

File Change Summary
web/app/[workspaceSlug]/(projects)/home/header.tsx Completely removed WorkspaceDashboardHeader component
web/app/[workspaceSlug]/(projects)/home/page.tsx Removed WorkspaceDashboardPage component
web/core/components/core/content-overflow-HOC.tsx Added isTransitioning state, containerRef, and enhanced transition handling
web/core/components/home/widgets/links/links.tsx Restructured JSX and updated container styling
web/core/components/home/widgets/recents/index.tsx Introduced ContentOverflowWrapper and added filter for recent activities
apiserver/plane/app/views/workspace/recent_visit.py Modified list method to refine filtering logic for user recent visits

Possibly related PRs

  • [WEB-2937] feat: home recent activies list endpoint #6295: The main PR involves the removal of the WorkspaceDashboardHeader component, which is related to the overall workspace functionality. The retrieved PR introduces a List API for recent activities associated with a workspace, indicating a connection to workspace management and user interactions.
  • fix: manage widgets integrations #6331: This PR includes changes related to managing widget integrations, which may involve the WorkspaceDashboardHeader component's previous functionality, as it was part of the workspace dashboard layout.

Suggested labels

🐛bug, 🌐frontend, ⚙️backend

Suggested reviewers

  • sriramveeraghanta
  • rahulramesha
  • SatishGandham

Poem

🐰 Hop, skip, and a code leap,
Components dance, no more to keep,
Headers fade, transitions flow,
A rabbit's refactor puts on a show!
Clean and swift, the changes gleam 🌟

Finishing Touches

  • 📝 Generate Docstrings

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

🧹 Nitpick comments (6)
web/core/components/core/content-overflow-HOC.tsx (3)

75-87: Add cleanup for transition event listener when showAll changes

The transition event listener cleanup might miss some cases since it only runs on unmount. Consider adding showAll to the effect dependencies to properly cleanup and reattach the listener when the state changes.

- useEffect(() => {
+ useEffect(() => {
    if (!containerRef.current) return;

    const handleTransitionEnd = () => {
      setIsTransitioning(false);
    };

    containerRef.current.addEventListener("transitionend", handleTransitionEnd);

    return () => {
      containerRef.current?.removeEventListener("transitionend", handleTransitionEnd);
    };
-  }, []);
+  }, [showAll]);

135-140: Enhance button accessibility

The show more/less button should have proper ARIA attributes for better screen reader support.

 <button
   className={cn(
     "gap-1 w-full text-custom-primary-100 text-sm font-medium transition-opacity duration-300",
     buttonClassName
   )}
   onClick={handleToggle}
   disabled={isTransitioning}
+  aria-expanded={showAll}
+  aria-controls={contentRef.current?.id}
+  aria-label={showAll ? "Show less content" : "Show more content"}
 >

110-117: Add unique ID for ARIA controls reference

The content div needs a unique ID to be referenced by the button's aria-controls attribute.

 <div
   ref={contentRef}
+  id={`content-${Math.random().toString(36).substr(2, 9)}`}
   className={cn("h-auto", {
     "pb-6": showAll,
   })}
 >
   {children}
 </div>
web/core/components/home/widgets/recents/index.tsx (1)

98-100: Add error boundary or fallback for invalid activities

While filtering out activities without entity_data is good, consider adding error handling for malformed activity data to prevent rendering failures.

 recents
-  .filter((recent: TActivityEntityData) => recent.entity_data)
+  .filter((recent: TActivityEntityData) => {
+    try {
+      return recent && recent.entity_data && recent.id;
+    } catch (error) {
+      console.error("Invalid activity data:", error);
+      return false;
+    }
+  })
web/core/components/home/widgets/links/links.tsx (2)

37-37: Remove unnecessary empty fragment

The empty fragment as fallback can be replaced with null.

-  fallback={<></>}
+  fallback={null}
🧰 Tools
🪛 Biome (1.9.4)

[error] 37-37: 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.

(lint/complexity/noUselessFragments)


Line range hint 83-102: Great architectural decision with ContentOverflowWrapper

The implementation of ContentOverflowWrapper as a reusable component for handling content overflow is a solid architectural decision. It provides:

  1. Consistent overflow behavior across components
  2. Smooth transitions with proper state management
  3. Dynamic content handling with ResizeObserver
  4. Performance optimization by preventing multiple clicks during transitions

Consider documenting these capabilities in the component's JSDoc for better maintainability.

🧰 Tools
🪛 Biome (1.9.4)

[error] 37-37: 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.

(lint/complexity/noUselessFragments)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 448a34a and d0cce0d.

📒 Files selected for processing (5)
  • web/app/[workspaceSlug]/(projects)/home/header.tsx (0 hunks)
  • web/app/[workspaceSlug]/(projects)/home/page.tsx (0 hunks)
  • web/core/components/core/content-overflow-HOC.tsx (2 hunks)
  • web/core/components/home/widgets/links/links.tsx (1 hunks)
  • web/core/components/home/widgets/recents/index.tsx (3 hunks)
💤 Files with no reviewable changes (2)
  • web/app/[workspaceSlug]/(projects)/home/header.tsx
  • web/app/[workspaceSlug]/(projects)/home/page.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
web/core/components/home/widgets/links/links.tsx

[error] 37-37: 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.

(lint/complexity/noUselessFragments)

web/core/components/home/widgets/recents/index.tsx

[error] 86-86: 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.

(lint/complexity/noUselessFragments)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)

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

🧹 Nitpick comments (2)
apiserver/plane/app/views/workspace/recent_visit.py (2)

25-32: Consider optimizing the entity filtering logic

The current implementation uses two separate filters for entity_name. Consider:

  1. Combining the filters for better query efficiency
  2. Moving the entity types to a constant/enum for better maintainability

Here's a suggested improvement:

+VALID_ENTITY_TYPES = ["issue", "page", "project"]

 class UserRecentVisitViewSet(BaseViewSet):
     # ... existing code ...

     def list(self, request, slug):
         user_recent_visits = UserRecentVisit.objects.filter(
             workspace__slug=slug, user=request.user
         )

         entity_name = request.query_params.get("entity_name")
-        if entity_name:
-            user_recent_visits = user_recent_visits.filter(entity_name=entity_name)
-
-        user_recent_visits = user_recent_visits.filter(
-            entity_name__in=["issue", "page", "project"]
-        )
+        user_recent_visits = user_recent_visits.filter(
+            entity_name__in=[entity_name] if entity_name in VALID_ENTITY_TYPES else VALID_ENTITY_TYPES
+        )

34-35: Optimize query performance with database-level limiting

Instead of fetching all records and slicing in memory, consider using .order_by() and [:20] at the query level for better performance with large datasets.

-        serializer = WorkspaceRecentVisitSerializer(user_recent_visits[:20], many=True)
+        user_recent_visits = user_recent_visits.order_by('-created_at')[:20]
+        serializer = WorkspaceRecentVisitSerializer(user_recent_visits, many=True)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d0cce0d and 10ea059.

📒 Files selected for processing (1)
  • apiserver/plane/app/views/workspace/recent_visit.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
apiserver/plane/app/views/workspace/recent_visit.py (3)

Line range hint 12-20: LGTM! Well-structured ViewSet with appropriate permissions

The ViewSet is properly configured with:

  • Correct inheritance from BaseViewSet
  • Appropriate serializer class selection
  • Proper workspace-level permission checks for all user roles

21-23: Great security improvement with user-specific filtering!

The addition of user=request.user ensures that users can only access their own recent visits within the workspace context.


21-35: Verify the impact on the recent activities widget

The changes properly fix the recent visits functionality by:

  1. Ensuring proper user scoping
  2. Filtering valid entity types
  3. Limiting results appropriately

However, since this is part of the "fixed recents" PR objective, please verify:

✅ Verification successful

Recent visits API changes are compatible with frontend implementation

The backend changes align perfectly with the frontend service implementation in web/core/services/workspace.service.ts. The fetchWorkspaceRecents method correctly handles the optional entity_name parameter and the API endpoint matches the backend implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any related frontend changes that might depend on these backend changes
rg -l "UserRecentVisit|recent.*visit" web/

Length of output: 83


Script:

#!/bin/bash
# Check the implementation details in the frontend service
cat web/core/services/workspace.service.ts

Length of output: 11455

@pushya22 pushya22 merged commit add35b5 into preview Jan 9, 2025
11 of 14 checks passed
@pushya22 pushya22 deleted the fix-home-improvements branch January 9, 2025 11:56
@coderabbitai coderabbitai bot mentioned this pull request Jan 16, 2025
3 tasks
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.

5 participants