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-2370]chore: activity filters #6324

Merged
merged 2 commits into from
Jan 6, 2025
Merged

[WEB-2370]chore: activity filters #6324

merged 2 commits into from
Jan 6, 2025

Conversation

mathalav55
Copy link
Collaborator

@mathalav55 mathalav55 commented Jan 6, 2025

Description

Added activity filters to local storage.
Added indicator to filters button to indicate modified filters.
Moved activity sort order from store to local storage.

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

References

WEB-2370

Summary by CodeRabbit

Release Notes

  • New Features

    • Added persistent local storage for issue activity filters and sort order
    • Introduced visual indicator for active filters
  • Improvements

    • Enhanced sorting functionality for issue activity comments
    • Refined filter and sort management in issue activity view
  • Technical Updates

    • Standardized sort order management using a new enum
    • Updated component logic to support more flexible sorting and filtering

@mathalav55 mathalav55 added 🌟enhancement New feature or request 🌐frontend labels Jan 6, 2025
@mathalav55 mathalav55 added this to the v0.24.2 milestone Jan 6, 2025
@mathalav55 mathalav55 self-assigned this Jan 6, 2025
Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

Walkthrough

The pull request introduces changes to the issue activity management system, focusing on sorting and filtering mechanisms. The modifications include updating the IssueActivityStore to remove internal sort order state, introducing a new TSORT_ORDER enum, and implementing local storage for persistent filter and sort order settings. The changes aim to make the sorting and filtering of issue activities more flexible and user-friendly by passing sort order as a parameter and storing user preferences.

Changes

File Change Summary
web/ce/store/issue/issue-details/activity.store.ts - Removed sortOrder property and toggleSortOrder method
- Updated getActivityCommentByIssueId method signature to accept sortOrder parameter
web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx - Added sortOrder to TIssueActivityCommentRoot type
- Modified getActivityCommentByIssueId call to include sortOrder
web/core/components/issues/issue-detail/issue-activity/activity-filter.tsx - Added conditional rendering of a filter indicator dot
web/core/components/issues/issue-detail/issue-activity/root.tsx - Implemented useLocalStorage for selectedFilters and sortOrder
- Added toggleSortOrder functionality
web/core/components/issues/issue-detail/issue-activity/sort-root.tsx - Updated TActivitySortRoot type to use TSORT_ORDER
web/core/constants/common.ts - Added TSORT_ORDER enum with ASC and DESC values

Sequence Diagram

sequenceDiagram
    participant User
    participant Component
    participant LocalStorage
    participant Store
    
    User->>Component: Interact with sort/filter
    Component->>LocalStorage: Save sort order/filters
    LocalStorage-->>Component: Retrieve stored values
    Component->>Store: Call method with sort order
    Store->>Store: Apply sorting
    Store-->>Component: Return sorted activities
    Component->>User: Display sorted activities
Loading

Possibly related PRs

Suggested labels

🧹chore

Suggested reviewers

  • SatishGandham
  • sriramveeraghanta
  • rahulramesha

Poem

🐰 Sorting comments with grace and might,
Local storage now shines so bright!
Filters dance, order takes flight,
A rabbit's code, a pure delight!
Persistent state, oh what a sight! 🔍


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 (3)
web/core/components/issues/issue-detail/issue-activity/sort-root.tsx (1)

6-11: Use the enum values directly in conditionals.

Currently, the conditional checks rely on the literal strings "asc" or "desc". Since sortOrder is defined as TSORT_ORDER, consider using TSORT_ORDER.ASC or TSORT_ORDER.DESC to maintain strict typing and avoid potential mismatches.

 {props.sortOrder === TSORT_ORDER.ASC ? (
   <ArrowUpWideNarrow className={cn("size-4", props.iconClassName)} />
 ) : (
   <ArrowDownWideNarrow className={cn("size-4", props.iconClassName)} />
 )}
web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx (1)

30-39: Redundant empty object destructuring.

The comment: {} destructuring returns an empty pattern. If it's not used, remove it to avoid confusion or consider expanding it if there are intended properties.

-  const {
-    activity: { getActivityCommentByIssueId },
-    comment: {},
-  } = useIssueDetail();
+  const {
+    activity: { getActivityCommentByIssueId },
+    // comment: {}, // Remove or include relevant properties if needed.
+  } = useIssueDetail();
web/core/components/issues/issue-detail/issue-activity/root.tsx (1)

45-49: Encourage fallback checks.

Storing filters in local storage is useful. However, if the stored data is corrupted or an unexpected type, consider adding a fallback or validation to avoid potential runtime errors.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a6216be and 4c83fcb.

📒 Files selected for processing (6)
  • web/ce/store/issue/issue-details/activity.store.ts (4 hunks)
  • web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx (2 hunks)
  • web/core/components/issues/issue-detail/issue-activity/activity-filter.tsx (1 hunks)
  • web/core/components/issues/issue-detail/issue-activity/root.tsx (6 hunks)
  • web/core/components/issues/issue-detail/issue-activity/sort-root.tsx (1 hunks)
  • web/core/constants/common.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx

[error] 43-43: Unexpected empty object pattern.

(lint/correctness/noEmptyPattern)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-web
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (17)
web/core/constants/common.ts (1)

31-35: Well-defined enum for sort order.

Declaring a dedicated enum for ASC and DESC fosters strong type checks and simplifies the promotion of consistent usage across the codebase.

web/core/components/issues/issue-detail/issue-activity/activity-filter.tsx (1)

29-31: Nicely implemented indicator for modified filters.

Displaying a small dot to indicate partially selected filters is a clear visual cue. Good job.

web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx (3)

3-4: Enum import is appropriate.

Importing TSORT_ORDER from the common constants ensures consistent usage of the sort order enum.


26-26: Good property addition for maintaining consistent sorting.

Adding sortOrder to the prop list aligns well with the new sorting approach.


46-46: Sorting query usage is clear.

Calling getActivityCommentByIssueId(issueId, sortOrder) is consistent with the new enum-based approach. Validate that the store function behaves correctly and returns results in the specified order.

✅ Verification successful

Sort order implementation is correctly handling comment ordering.

The getActivityCommentByIssueId function properly implements sorting using the sortOrder parameter to order comments by their creation timestamp. The implementation is type-safe and correctly handles the sorting direction.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that getActivityCommentByIssueId responds correctly to the 'sortOrder' argument.
rg -A 5 $'getActivityCommentByIssueId(issueId, sortOrder)'

Length of output: 59


Script:

#!/bin/bash
# Find function definition
ast-grep --pattern 'function getActivityCommentByIssueId($_) { $$$ }'

# Find export of this function
ast-grep --pattern 'export const getActivityCommentByIssueId = $_'

# Look for imports and usage
rg "getActivityCommentByIssueId"

# Look for sort order related code
rg -i "sortorder" -A 5

Length of output: 34568

web/ce/store/issue/issue-details/activity.store.ts (4)

19-19: Consistent introduction of a typed sort order.

Importing TSORT_ORDER clarifies the valid sort values and improves type safety throughout.


87-87: Leverage computedFn for memoization.

Using mobx-utils’ computedFn is great for memoization based on strict arguments. Make sure there’s no global state usage inside that could invalidate or incorrectly cache results.


118-118: Validate date parsing edge cases.

new Date(e.created_at || 0) might parse a fallback epoch date when created_at is undefined or null. Consider verifying all activities consistently have valid timestamps or provide a fallback strategy.


46-46: Ensure all callsites provide the new parameter.

Accepting sortOrder as a required parameter is a breaking change. Verify that all existing code that calls getActivityCommentByIssueId is updated to supply sortOrder.

✅ Verification successful

All callsites properly provide the new sortOrder parameter

The only callsite in web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx correctly provides both issueId and sortOrder parameters.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all callsites of getActivityCommentByIssueId to confirm they pass the new parameter
rg -A 4 'getActivityCommentByIssueId\('

Length of output: 720


Script:

#!/bin/bash
# Search for any destructuring or references of getActivityCommentByIssueId
rg 'getActivityCommentByIssueId'

# Search for potential destructuring patterns using AST
ast-grep --pattern 'const { $$$, getActivityCommentByIssueId, $$$ } = $_'

Length of output: 698

web/core/components/issues/issue-detail/issue-activity/root.tsx (8)

3-3: Minimal import changes are fine.

The addition of FC, useMemo import is consistent with React conventions.


5-5: Local storage hook usage is a good approach.

Using useLocalStorage is an elegant solution for persisting user preferences across sessions.


68-78: Prevent empty filters edge cases.

By returning early when selectedFilters is empty or undefined, you avoid unintended states. Confirm that UI components gracefully handle scenarios where no filters remain.


80-81: Simple and effective sort toggling.

This toggle logic is clean and easy to follow. Good job avoiding in-place mutations.


177-177: Clear usage of sort order props.

Passing sortOrder and a toggle function to ActivitySortRoot is consistent with the store changes. Great decoupling of UI from store logic.


179-179: Use typed local storage defaults.

Using selectedFilters || defaultActivityFilters ensures a robust fallback. Continue verifying that the UI gracefully handles corner cases.


195-195: Confirm consistent filter handling.

Make sure the logic in IssueActivityCommentRoot aligns with any updates you make in the toggle logic and filter array structure.


199-199: Synchronized sort order prop usage.

Passing sortOrder to IssueActivityCommentRoot ensures the comment component respects current user preferences. This is a great extension of your local storage approach.

@pushya22 pushya22 merged commit 208df80 into preview Jan 6, 2025
13 of 14 checks passed
@pushya22 pushya22 deleted the chore-activity_filters branch January 6, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟enhancement New feature or request 🌐frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants