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

feat(web): add user remove button and improve remove users modal #1288

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

caichi-t
Copy link
Contributor

@caichi-t caichi-t commented Oct 29, 2024

Overview

This PR adds the user remove button on the action column and improves remove users modal.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new icon, UsergroupDeleteOutlined, for enhanced visual representation.
    • Improved the MemberTable component with detailed user information in the confirmation modal during member deletion.
  • Bug Fixes

    • Enhanced the member deletion process to provide clearer feedback and improved user experience.
  • Documentation

    • Updated translation files for English and Japanese, ensuring comprehensive coverage of user interface strings and functionalities.
  • Chores

    • Simplified type definitions for user management, improving code clarity.

Copy link

coderabbitai bot commented Oct 29, 2024

Walkthrough

The changes in this pull request introduce a new icon, UsergroupDeleteOutlined, to the icon exports and refactor the MemberTable component to enhance user deletion functionality. The handleMemberDelete method now accepts an array of User objects, improving the confirmation modal to display user details. Additionally, the User type is imported from another module to simplify type definitions, and the content of translation files for English and Japanese has been completely replaced with new key-value pairs, primarily as placeholders.

Changes

File Path Change Summary
web/src/components/atoms/Icon/icons.ts Added new icon UsergroupDeleteOutlined and new property userGroupDelete to exports.
web/src/components/molecules/Member/MemberTable/index.tsx Refactored handleMemberDelete to accept User[], updated confirmation modal, and added styled components for user info.
web/src/components/molecules/Workspace/types.ts Removed previous User type definition and updated UserMember to reference the imported User type.
web/src/i18n/translations/en.yml Replaced all key-value pairs with new keys for UI strings, currently set as placeholders.
web/src/i18n/translations/ja.yml Replaced all content with new key-value pairs for Japanese translations across various functionalities.

Possibly related PRs

  • fix(web): add some missing styling #1257: This PR adds a new icon, FolderOpenOutlined, to the same file (web/src/components/atoms/Icon/icons.ts) where the main PR adds UsergroupDeleteOutlined, indicating a related change in the icon exports.
  • fix(web): add some missing styling #1279: This PR introduces a new icon, CommentOutlined, in the same file (web/src/components/atoms/Icon/icons.ts) as the main PR, which also modifies the exports of icons, showing a direct connection in the context of icon management.

Suggested reviewers

  • nourbalaha

🐰 In the meadow, changes bloom,
New icons added, dispelling gloom.
Members now with clearer view,
Deleting users, easier to do!
Translations fresh, a vibrant hue,
Hop along, the code is new! 🌼


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 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.

@github-actions github-actions bot added the web label Oct 29, 2024
Copy link

netlify bot commented Oct 29, 2024

Deploy Preview for reearth-cms canceled.

Name Link
🔨 Latest commit 18782c9
🔍 Latest deploy log https://app.netlify.com/sites/reearth-cms/deploys/672091c02d66d100088728d4

Copy link

@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: 3

🧹 Outside diff range and nitpick comments (4)
web/src/components/molecules/Workspace/types.ts (1)

19-19: LGTM! Type simplification improves maintainability.

The change to use the imported User type instead of an inline definition promotes better type reuse and maintainability. This is a good refactoring that follows the DRY principle.

Consider documenting the User type dependencies in a central location (e.g., README.md) to help other developers understand the type hierarchy and relationships.

web/src/components/molecules/Member/MemberTable/index.tsx (1)

297-325: LGTM: Well-structured styled components.

The styled components create a clean and maintainable UI structure with proper handling of text overflow and spacing.

Consider adding a comment above the styled components section to document the component hierarchy:

// Styled components for the remove users modal
// RemoveUsers
//   └─ RemoveUser
//        ├─ UserAvatar (imported)
//        └─ UserInfoWrapper
//             ├─ UserInfo
//             └─ Email
web/src/i18n/translations/ja.yml (2)

436-560: Standardize punctuation in system messages.

There's inconsistent usage of periods in system messages. Some messages end with periods while others don't. In Japanese UI messages, it's conventional to omit the period (。) at the end unless it's a complex sentence.

Consider removing trailing periods from messages like:

-Failed to update user.: ユーザーの更新に失敗しました。
+Failed to update user.: ユーザーの更新に失敗しました
-Successfully updated user!: ユーザーの更新に成功しました。
+Successfully updated user!: ユーザーの更新に成功しました

227-227: Translate technical terms for better localization.

Some technical terms are left untranslated, which might affect the user experience for Japanese users who are not familiar with English technical terms.

Consider translating:

-Webhook: ''
+Webhook: 'ウェブフック'

Also applies to: 228-228, 229-229

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 859fc79 and c66aadf.

📒 Files selected for processing (5)
  • web/src/components/atoms/Icon/icons.ts (2 hunks)
  • web/src/components/molecules/Member/MemberTable/index.tsx (6 hunks)
  • web/src/components/molecules/Workspace/types.ts (2 hunks)
  • web/src/i18n/translations/en.yml (1 hunks)
  • web/src/i18n/translations/ja.yml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/src/i18n/translations/en.yml
🧰 Additional context used
🪛 Biome
web/src/components/molecules/Member/MemberTable/index.tsx

[error] 76-76: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (6)
web/src/components/molecules/Workspace/types.ts (1)

3-3: Verify the imported User type usage across the codebase.

The addition of this import and removal of the local User type definition could impact other components that were using the previous definition.

Let's verify the usage and compatibility:

✅ Verification successful

Let me analyze the results and generate one more verification to ensure type compatibility:

The results will help us verify if there are any incompatibilities between the User type definitions that could cause issues.


Let me try one more time with a corrected regex:


Potential type incompatibility detected between User type definitions

The imported User type from Member/types.ts has fewer fields than the one in AccountSettings/types.ts. However, based on the usage patterns found earlier, the import in Workspace/types.ts correctly uses the Member-specific User type, which is also consistently used across related member management components. The removal of the local User type definition and importing from Member/types.ts is appropriate in this context.

  • Member/types.ts User: { id, name, email }
  • Used by: Workspace, MemberTable, MemberAddModal, Request, and Members components
  • All usages are within the member management context
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining local User type definitions and verify usage patterns

# Test 1: Check if there are any remaining local User type definitions that might conflict
rg -g '*.ts' -g '*.tsx' 'type User = \{'

# Test 2: Check usage patterns of User type to ensure compatibility
rg -g '*.ts' -g '*.tsx' -A 3 'import.*User.*from.*Member/types'

Length of output: 2355


Script:

#!/bin/bash
# Check the User type definitions in both locations to verify compatibility
echo "=== User type in Member/types.ts ==="
rg -A 10 "export type User = {" web/src/components/molecules/Member/types.ts

echo -e "\n=== User type in AccountSettings/types.ts ==="
rg -A 10 "export type User = {" web/src/components/molecules/AccountSettings/types.ts

Length of output: 564


Script:

#!/bin/bash
# Check the User type definitions in both locations to verify compatibility
echo "=== User type in Member/types.ts ==="
rg -A 10 '^export type User' web/src/components/molecules/Member/types.ts

echo -e "\n=== User type in AccountSettings/types.ts ==="
rg -A 10 '^export type User' web/src/components/molecules/AccountSettings/types.ts

Length of output: 579

web/src/components/atoms/Icon/icons.ts (2)

8-8: LGTM! Clean import addition.

The UsergroupDeleteOutlined import is properly placed and maintains the file's alphabetical ordering convention.


102-102: LGTM! Well-structured icon mapping.

The new userGroupDelete mapping follows the established naming conventions and is appropriately positioned in the export object.

web/src/components/molecules/Member/MemberTable/index.tsx (3)

14-14: LGTM: Clean type import.

The import of the User type from a centralized location promotes better type consistency across the application.


150-151: LGTM: Well-implemented action column improvements.

The changes effectively handle:

  • Appropriate width adjustment for the new remove button
  • Proper conditional rendering between remove/leave actions
  • Correct permission checks

Also applies to: 173-190


65-90: Verify test coverage for the new modal implementation.

The modal improvements look good, but we should ensure proper test coverage for the new user removal flow.

🧰 Tools
🪛 Biome

[error] 76-76: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

web/src/components/molecules/Member/MemberTable/index.tsx Outdated Show resolved Hide resolved
web/src/i18n/translations/ja.yml Show resolved Hide resolved
web/src/i18n/translations/ja.yml Show resolved Hide resolved
Copy link

@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

🧹 Outside diff range and nitpick comments (2)
web/src/components/molecules/Member/MemberTable/index.tsx (2)

72-90: Consider improving modal content accessibility.

While the modal content provides good visual feedback, consider these accessibility improvements:

  • Add ARIA labels for the user list
  • Use semantic HTML elements for the user list (e.g., <ul> and <li>)

Apply this diff to improve accessibility:

       content: (
         <>
-            <RemoveUsers>
+            <RemoveUsers role="list" aria-label="Users to be removed">
               {users.map(user => (
-                <RemoveUser key={user.id}>
+                <RemoveUser key={user.id} role="listitem">
                   <UserAvatar username={user.name} />
                   <UserInfoWrapper>
                     <UserInfo>{user.name}</UserInfo>
                     <Email>{user.email}</Email>
                   </UserInfoWrapper>
                 </RemoveUser>
               ))}
             </RemoveUsers>
-            <div>
+            <p>
               {t(
                 "Remove this member from workspace means this member will not view any content of this workspace.",
               )}
-            </div>
+            </p>
         </>
       ),

323-325: Consider using theme variables for colors.

Instead of hardcoding the color value, consider using a theme variable for better maintainability and consistency.

 const Email = styled(UserInfo)`
-  color: #00000073;
+  color: ${props => props.theme.colors.text.secondary};
 `;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c66aadf and 36f68b2.

📒 Files selected for processing (1)
  • web/src/components/molecules/Member/MemberTable/index.tsx (6 hunks)

Copy link
Contributor

@nourbalaha nourbalaha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with suggestions!

@caichi-t caichi-t enabled auto-merge (squash) October 29, 2024 07:41
@caichi-t caichi-t merged commit af0bd0d into main Oct 29, 2024
12 checks passed
@caichi-t caichi-t deleted the fix-web/remove-member branch October 29, 2024 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants