Skip to content

[WEB-3262]fix: incomplete activity render for activity in notifications#6777

Merged
sriramveeraghanta merged 2 commits intopreviewfrom
fix-notifications-activity
Mar 20, 2025
Merged

[WEB-3262]fix: incomplete activity render for activity in notifications#6777
sriramveeraghanta merged 2 commits intopreviewfrom
fix-notifications-activity

Conversation

@vamsikrishnamathala
Copy link
Member

@vamsikrishnamathala vamsikrishnamathala commented Mar 19, 2025

Description

This update handles the incomoplete activity render in notifications.
Refactored notification content for better code readability.

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

WEB-3262

Summary by CodeRabbit

  • New Features

    • Enhanced the workspace notifications display with clear details that include trigger information, descriptive actions, and corresponding values.
    • Introduced a comment box option for notifications involving comments.
  • Refactor

    • Streamlined the notification rendering logic with additional workspace and project validations for a more consistent user experience.

4 similar comments
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2025

Walkthrough

A new React functional component named NotificationContent is introduced to handle the display logic for workspace notifications. The component extracts and formats data from a notification and conditionally renders a comment box. Additionally, the module's export in the index file is updated to include the new component, and the NotificationItem component is refactored to utilize NotificationContent along with enhanced workspace checks.

Changes

File(s) Summary
web/core/components/workspace-notifications/sidebar/notification-card/content.tsx
web/core/components/workspace-notifications/sidebar/notification-card/index.ts
Added new NotificationContent component to render notification details and updated the index file to export the new content module.
web/core/components/workspace-notifications/sidebar/notification-card/item.tsx Refactored NotificationItem to incorporate NotificationContent and enhanced workspace retrieval using the useWorkspace hook.

Sequence Diagram(s)

sequenceDiagram
    participant NI as NotificationItem
    participant WS as useWorkspace
    participant NC as NotificationContent
    participant UI as Renderer

    NI ->> WS: Retrieve workspace using workspaceSlug
    WS -->> NI: Return workspace.id
    NI ->> NC: Pass notification data and workspace information
    NC ->> UI: Render trigger, action, and value details
Loading

Possibly related PRs

Suggested labels

🌟enhancement

Suggested reviewers

  • rahulramesha
  • SatishGandham
  • sriramveeraghanta

Poem

Hopping through branches of code so bright,
I nibble on bugs in the soft daylight.
New features bloom like carrots in spring,
As my little hops make the codebase sing.
With whiskered joy, I celebrate each new insight!
(_/)

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ 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 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 (3)
web/core/components/workspace-notifications/sidebar/notification-card/content.tsx (3)

23-27: Add optional chaining for nested properties.

In the renderTriggerName function, you're safely using optional chaining for triggeredBy?.is_bot and triggeredBy?.display_name, but not for triggeredBy.first_name. If triggeredBy is undefined, accessing first_name directly would cause a runtime error.

const renderTriggerName = () => (
  <span className="text-custom-text-100 font-medium">
-    {triggeredBy?.is_bot ? triggeredBy.first_name : triggeredBy?.display_name}{" "}
+    {triggeredBy?.is_bot ? triggeredBy?.first_name : triggeredBy?.display_name}{" "}
  </span>
);

29-59: Consider refactoring conditional logic for better maintainability.

The renderAction function has multiple conditionals for different notification fields. While the current implementation works, consider using a map/object approach for better maintainability as the number of fields grows.

const renderAction = () => {
  if (!notificationField) return "";
+  
+  const actionMap = {
+    duplicate: () => verb === "created" 
+      ? "marked that this work item is a duplicate of" 
+      : "marked that this work item is not a duplicate",
+    assignees: () => newValue !== "" ? "added assignee" : "removed assignee",
+    start_date: () => newValue !== "" ? "set start date" : "removed the start date",
+    target_date: () => newValue !== "" ? "set due date" : "removed the due date",
+    labels: () => newValue !== "" ? "added label" : "removed label",
+    parent: () => newValue !== "" ? "added parent" : "removed parent",
+    relates_to: () => "marked that this work item is related to",
+    comment: () => "commented",
+    archived_at: () => newValue === "restore" ? "restored the work item" : "archived the work item",
+    None: () => null,
+  };
+  
+  if (actionMap[notificationField]) {
+    return actionMap[notificationField]();
+  }
+  
+  const baseAction = !["comment", "archived_at"].includes(notificationField) ? verb : "";
+  return `${baseAction} ${replaceUnderscoreIfSnakeCase(notificationField)}`;

-  if (notificationField === "duplicate")
-    return verb === "created"
-      ? "marked that this work item is a duplicate of"
-      : "marked that this work item is not a duplicate";
-  if (notificationField === "assignees") {
-    return newValue !== "" ? "added assignee" : "removed assignee";
-  }
-  if (notificationField === "start_date") {
-    return newValue !== "" ? "set start date" : "removed the start date";
-  }
-  if (notificationField === "target_date") {
-    return newValue !== "" ? "set due date" : "removed the due date";
-  }
-  if (notificationField === "labels") {
-    return newValue !== "" ? "added label" : "removed label";
-  }
-  if (notificationField === "parent") {
-    return newValue !== "" ? "added parent" : "removed parent";
-  }
-  if (notificationField === "relates_to") return "marked that this work item is related to";
-  if (notificationField === "comment") return "commented";
-  if (notificationField === "archived_at") {
-    return newValue === "restore" ? "restored the work item" : "archived the work item";
-  }
-  if (notificationField === "None") return null;
-
-  const baseAction = !["comment", "archived_at"].includes(notificationField) ? verb : "";
-  return `${baseAction} ${replaceUnderscoreIfSnakeCase(notificationField)}`;
};

A similar approach could be applied to the renderValue function.


95-101: Provide a meaningful ID for the LiteTextReadOnlyEditor.

The id prop for the LiteTextReadOnlyEditor component is set to an empty string. For better accessibility and debugging, provide a meaningful ID such as a combination of notification ID and field type.

<LiteTextReadOnlyEditor
-  id=""
+  id={`notification-comment-${notification.id}`}
  initialValue={newValue ?? ""}
  workspaceId={workspaceId}
  workspaceSlug={workspaceSlug}
  projectId={projectId}
/>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f82d4a9 and 8422161.

📒 Files selected for processing (3)
  • web/core/components/workspace-notifications/sidebar/notification-card/content.tsx (1 hunks)
  • web/core/components/workspace-notifications/sidebar/notification-card/index.ts (1 hunks)
  • web/core/components/workspace-notifications/sidebar/notification-card/item.tsx (4 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
web/core/components/workspace-notifications/sidebar/notification-card/item.tsx (1)
web/core/components/workspace-notifications/sidebar/notification-card/content.tsx (1) (1)
  • NotificationContent (10-109)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (5)
web/core/components/workspace-notifications/sidebar/notification-card/index.ts (1)

3-3: LGTM! Added export for the new component.

The additional export for the new NotificationContent component is correctly added.

web/core/components/workspace-notifications/sidebar/notification-card/item.tsx (4)

14-15: Added necessary imports.

The imports have been correctly updated to include the new useWorkspace hook and the NotificationContent component.


28-36: Added workspace retrieval.

Good addition of the workspace retrieval using the getWorkspaceBySlug function.


61-62: Improved safety checks before rendering.

The conditional check has been properly enhanced to include checks for workspace?.id and projectId, which improves the robustness of the component.


93-98: Well-implemented refactoring to use the new component.

The notification content rendering has been effectively refactored to use the new NotificationContent component, which improves code organization and maintainability.

@sriramveeraghanta sriramveeraghanta merged commit ca5cf27 into preview Mar 20, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-notifications-activity branch March 20, 2025 08:32
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
…ns (#6777)

* fix: incomplete activity render for activity in notifications

* fix: handled content overflow for long notification messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛bug Something isn't working 🌐frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants