Skip to content

Conversation

@mindmonk
Copy link
Contributor

This PR addresses #173 by displaying the number of members for shared groups in the VaultDetail view.

The member count appears as italicized gray text (e.g., 3 Members) next to group names.

This information is visible both in the search results and the "Shared with" list, helping distinguish groups from individual users.

Search output Search selected Shared with list

@mindmonk mindmonk requested a review from SailReal March 10, 2025 11:24
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2025

Walkthrough

The changes introduce functionality to support the retrieval and display of the member size for group entities. In the backend, an overloaded method in the AuthorityDto class allows for the conversion of entities with an optional boolean flag to include member size data. The GroupDto and MemberDto classes have been updated to include a new property, memberSize, and their conversion methods now conditionally populate this property based on the provided flag. A transient method getMemberSize() has been added to the Group entity to compute the size of its member set. The search method in AuthorityResource has been modified to accept a query parameter to toggle the inclusion of member size and is executed within a transactional context. Corresponding tests in AuthorityResourceIT and VaultResourceIT have been modified or added to validate the new member size functionality. On the frontend, the GroupDto type and UI components have been updated to handle and display the member size, along with a new localization entry for member count representation.

Suggested reviewers

  • overheadhunter

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.

📜 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 c7a6b5b and c76877e.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🔇 Additional comments (1)
CHANGELOG.md (1)

23-23: Changelog Entry for Group Member Count

The new changelog entry clearly indicates the addition of direct member count data in vault details and correctly references issue (#329). The description is concise and fits well into the "Added" category.


🪧 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)
frontend/src/common/backend.ts (1)

287-287: Consider handling singular/plural forms for member count.

The search method properly includes the new withMemberSize=true parameter. However, you might want to consider handling singular/plural forms when displaying member counts in the UI (e.g., "1 Member" vs. "2 Members").

This could be implemented with a conditional in the template or by adding additional translation keys:

// In the i18n file
"vaultDetails.sharedWith.member": "Member",
"vaultDetails.sharedWith.members": "Members",

// Then in the component template
{{ member.memberSize }} {{ member.memberSize === 1 ? t('vaultDetails.sharedWith.member') : t('vaultDetails.sharedWith.members') }}
frontend/src/components/VaultDetails.vue (1)

50-52: LGTM! Good implementation of member count display.

The implementation correctly displays the member size for group entities with appropriate styling. The italicized gray text matches the requirements specified in the PR objectives.

Consider adding a fallback value in case memberSize is undefined:

- {{ member.memberSize }} {{ t('vaultDetails.sharedWith.members') }}
+ {{ member.memberSize || 0 }} {{ t('vaultDetails.sharedWith.members') }}

Additionally, for better user experience, consider handling singular/plural forms as mentioned in the previous comment.

backend/src/test/java/org/cryptomator/hub/api/VaultResourceIT.java (1)

59-59: Unused import detected.

The import for nullValue from Hamcrest Matchers is not used in the changed code.

-import static org.hamcrest.Matchers.nullValue;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c640f87 and fa2b899.

📒 Files selected for processing (11)
  • backend/src/main/java/org/cryptomator/hub/api/AuthorityDto.java (1 hunks)
  • backend/src/main/java/org/cryptomator/hub/api/AuthorityResource.java (2 hunks)
  • backend/src/main/java/org/cryptomator/hub/api/GroupDto.java (1 hunks)
  • backend/src/main/java/org/cryptomator/hub/api/MemberDto.java (1 hunks)
  • backend/src/main/java/org/cryptomator/hub/entities/Group.java (2 hunks)
  • backend/src/test/java/org/cryptomator/hub/api/AuthorityResourceIT.java (3 hunks)
  • backend/src/test/java/org/cryptomator/hub/api/VaultResourceIT.java (2 hunks)
  • frontend/src/common/backend.ts (2 hunks)
  • frontend/src/components/SearchInputGroup.vue (2 hunks)
  • frontend/src/components/VaultDetails.vue (1 hunks)
  • frontend/src/i18n/en-US.json (1 hunks)
🔇 Additional comments (26)
backend/src/main/java/org/cryptomator/hub/entities/Group.java (2)

12-12: Ensure Jakarta Persistence API import is used consistently.

Good addition of the @Transient annotation import from the Jakarta Persistence API, maintaining consistency with the existing imports.


37-40: LGTM! Clean implementation of the member size method.

The @Transient annotation correctly indicates this is a calculated field rather than a persisted property. The implementation is straightforward and efficient, simply returning the size of the members collection.

frontend/src/i18n/en-US.json (1)

266-266: LGTM! Good addition of localization entry.

The new localization entry "Members" will support displaying the member count in the UI, maintaining the application's internationalization capabilities.

frontend/src/common/backend.ts (1)

89-89: LGTM! Good addition of the memberSize property.

The optional memberSize property is correctly added to the GroupDto type, making it available for display in the UI while maintaining backward compatibility with existing code.

backend/src/main/java/org/cryptomator/hub/api/AuthorityResource.java (3)

5-5: LGTM! Added import for Transactional annotation.

The import for jakarta.transaction.Transactional is appropriate for the changes in this file.


32-33: Good addition of @transactional annotation with updated method signature.

Adding the @Transactional annotation ensures that the database operations occur within a transaction context, which is important when retrieving related entities like group members to calculate the member size.


34-34: LGTM! Implementation properly uses the new withMemberSize parameter.

The implementation correctly passes the withMemberSize parameter to the AuthorityDto.fromEntity method, enabling the retrieval of member size information when requested.

backend/src/test/java/org/cryptomator/hub/api/VaultResourceIT.java (2)

617-617: LGTM! Updated test display name to reflect member size checking.

The test name now accurately describes what is being tested - verifying that group2 has a member size of 2.


621-621: Good implementation of member size validation in test.

The assertion has been updated to use Groovy-style closure syntax to find the object with id 'group2' and assert that its memberSize equals 2, which properly tests the new functionality.

frontend/src/components/SearchInputGroup.vue (4)

12-17: Great enhancement to show member count for selected groups.

The implementation elegantly displays the member count as italicized gray text next to the group name when a group is selected, which aligns with the PR objectives.


25-27: LGTM! Consistent display of member count in dropdown options.

This implementation maintains UI consistency by showing the member count in the dropdown list in the same style as the selected item display.


49-49: Good addition of new properties to support member size display.

The Item type has been properly updated with optional type and memberSize properties, and the i18n import has been added to support localization of the "members" text.

Also applies to: 55-56


59-59: LGTM! Properly initialized i18n for localization.

The internationalization setup is correctly implemented, allowing for localized display of the "members" text.

backend/src/main/java/org/cryptomator/hub/api/AuthorityDto.java (3)

33-35: Good implementation of backward compatibility.

The original fromEntity method has been updated to call the new overloaded method with a default value of false for the withMemberSize parameter, maintaining backward compatibility.


37-37: LGTM! Well-designed overloaded method.

Adding an overloaded method with the withMemberSize parameter is a clean approach to extend functionality while maintaining API compatibility.


40-40: LGTM! Correctly passes the withMemberSize parameter.

The switch statement properly passes the withMemberSize parameter to the GroupDto.fromEntity method, enabling conditional retrieval of member size information.

backend/src/test/java/org/cryptomator/hub/api/AuthorityResourceIT.java (2)

81-83: Good update to existing test to verify memberSize is null by default

The updated test assertions correctly verify that both user and group entities don't include the memberSize property when the withMemberSize parameter is not provided. This ensures backward compatibility with existing API clients.


85-92: Well-structured test for withMemberSize parameter

This test properly verifies the new functionality by checking that:

  1. When withMemberSize=true is passed, groups include their member count (1 in this case)
  2. Users still have null memberSize even with the parameter set

The test clearly documents the expected behavior and helps ensure the feature works as intended.

backend/src/main/java/org/cryptomator/hub/api/MemberDto.java (4)

16-17: Good addition of memberSize property with proper annotation

The memberSize property is correctly annotated with @JsonProperty to ensure proper JSON serialization.


19-25: Constructor properly updated to include memberSize parameter

The constructor has been correctly updated to include the new memberSize parameter with proper JSON annotation, maintaining the class's immutability pattern.


28-28: Appropriate null value for user memberSize

Correctly passing null for memberSize when creating a MemberDto from a User entity, as users don't have members.


32-32: Group member size correctly passed to DTO

Properly retrieving and passing the group's member size when creating a MemberDto from a Group entity.

backend/src/main/java/org/cryptomator/hub/api/GroupDto.java (4)

8-9: Well-defined memberSize property with JSON annotation

The memberSize property is correctly defined as an Integer (allowing for null values) and properly annotated for JSON serialization.


11-14: Constructor properly updated to handle memberSize

The constructor has been correctly modified to accept and initialize the new memberSize field, maintaining the class's immutability pattern.


16-18: Good backward compatibility approach

The original fromEntity method now calls the new overloaded version with false for withMemberSize, maintaining backward compatibility with existing code while supporting the new functionality.


20-23: Well-implemented conditional member size inclusion

The new overloaded fromEntity method properly:

  1. Conditionally retrieves the member size based on the withMemberSize flag
  2. Sets it to null when not needed to avoid unnecessary calculation
  3. Creates the DTO with the appropriate values

This implementation aligns perfectly with the PR objective to display member counts for groups.

@mindmonk mindmonk requested a review from SailReal March 17, 2025 11:57
[ci skip]
@SailReal SailReal merged commit 713b75a into develop Mar 17, 2025
2 checks passed
@SailReal SailReal deleted the feature/group-member-label branch March 17, 2025 15:45
@SailReal SailReal added this to the 1.4.0 milestone Mar 17, 2025
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.

3 participants