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(suite): refactor advanced coin settings modal #17434

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

seibei-iguchi
Copy link
Contributor

@seibei-iguchi seibei-iguchi commented Mar 6, 2025

Screenshots:

Before

Screenshot 2025-03-06 at 11 53 28 Screenshot 2025-03-06 at 11 53 35 Screenshot 2025-03-06 at 11 55 09

After

Screenshot 2025-03-06 at 11 51 21 Screenshot 2025-03-06 at 11 51 13 Screenshot 2025-03-06 at 11 52 42

@seibei-iguchi seibei-iguchi force-pushed the feat/refactor-advanced-settings-modal branch 3 times, most recently from 589c81f to caf1784 Compare March 6, 2025 10:51
@seibei-iguchi seibei-iguchi self-assigned this Mar 6, 2025
@seibei-iguchi seibei-iguchi marked this pull request as ready for review March 6, 2025 10:57
@seibei-iguchi seibei-iguchi requested review from MiroslavProchazka and a team as code owners March 6, 2025 10:57
@seibei-iguchi seibei-iguchi force-pushed the feat/refactor-advanced-settings-modal branch from caf1784 to 869bc6c Compare March 6, 2025 10:58
Copy link

coderabbitai bot commented Mar 6, 2025

Walkthrough

The pull request introduces several adjustments across multiple components. In the components package, a new optional prop for test identification is added to a List item while modal and typography components receive updates for conditional styling and additional text casing options. The accompanying utilities have been updated to support the new text casing properties, including the definition of allowed cases. In the suite package, the Advanced Coin Settings modal undergoes significant restructuring with a shift to a component-based approach using updated modal components. Several components related to backend settings are removed or refactored, including updates to backend URL management and interaction with Tor settings. Additionally, a new translation message is introduced, and the submodule reference for a common dependency is updated to a newer commit. All changes are purely additive or refactoring, without affecting existing functionality.

✨ 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

@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)
packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/ConnectionInfo.tsx (1)

17-34: Avoid using <br /> tags for spacing.
Repeated <br /> tags can lead to inconsistent layout, especially if theming or translations change lengths. Prefer separate <Paragraph> components or styling with spacing tokens.

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/AdvancedCoinSettingsModal.tsx (1)

86-197: Consider reducing component complexity.
The large rendering block shows multiple UI elements: arrangement within a Card, Column, List, CollapsibleBox, and more. Extracting subcomponents (e.g., for the URL list) would improve maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between df87b52 and 869bc6c.

📒 Files selected for processing (12)
  • packages/components/src/components/List/ListItem.tsx (1 hunks)
  • packages/components/src/components/NewModal/NewModal.tsx (1 hunks)
  • packages/components/src/components/typography/Text/Text.tsx (1 hunks)
  • packages/components/src/components/typography/utils.tsx (5 hunks)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/AdvancedCoinSettingsModal.tsx (1 hunks)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/BackendInput.tsx (0 hunks)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/BackendTypeSelect.tsx (1 hunks)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/ConnectionInfo.tsx (1 hunks)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/CustomBackends.tsx (0 hunks)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/TorModal.tsx (2 hunks)
  • packages/suite/src/support/messages.ts (1 hunks)
  • submodules/trezor-common (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/BackendInput.tsx
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/CustomBackends.tsx
✅ Files skipped from review due to trivial changes (2)
  • submodules/trezor-common
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/BackendTypeSelect.tsx
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Unit Tests
  • GitHub Check: Releases revision Checks
  • GitHub Check: Build libs for publishing
  • GitHub Check: Type Checking
  • GitHub Check: Linting and formatting
  • GitHub Check: build-web
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (17)
packages/suite/src/support/messages.ts (1)

4514-4517: New translation entry looks good.

The addition of the TR_REMOVE translation entry follows the established pattern of the message definitions file and will support the refactored advanced coin settings modal mentioned in the PR objectives.

packages/components/src/components/typography/Text/Text.tsx (1)

27-27: Enhances text styling options by adding case control

The addition of 'case' to the allowedTextTextProps array extends the Text component's capabilities, allowing developers to control text casing (uppercase, lowercase, titlecase) through this prop.

packages/components/src/components/NewModal/NewModal.tsx (1)

107-107: Improves header alignment for better visual hierarchy

This change enhances the modal's header layout by conditionally aligning items to the top (flex-start) when a description is present, while maintaining center alignment when there's only a heading. This creates a more natural reading flow and cleaner visual hierarchy.

packages/components/src/components/List/ListItem.tsx (1)

45-45: Added test identification support to ListItem

The addition of the data-testid property improves the component's testability, making it easier to select specific list items in automated tests.

Also applies to: 48-52, 56-56

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/TorModal.tsx (1)

1-1: Successfully refactored TorModal to use the new modal system

The modal has been completely refactored to use the NewModal component instead of the previous custom styled modal. This change:

  1. Simplifies the component structure
  2. Adds consistent styling with size="small" and the Tor icon
  3. Uses appropriate typography components (H3, Paragraph) for better accessibility
  4. Implements the new button pattern with NewModal.Button

These changes align with the PR objective to refactor the advanced coin settings modal for a more consistent user experience.

Also applies to: 4-4, 18-44

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/CustomBackends/ConnectionInfo.tsx (1)

7-9: Use of type alias is fine.
Good switch from interface to type alias. This is purely stylistic, and it remains compatible with advanced type compositions.

packages/components/src/components/typography/utils.tsx (7)

11-13: Introduction of textCase is well-implemented.
Defining all possible case options as a const assertion with a derived type is concise and clear.


19-19: Optional 'case' property.
Adding case?: TextCase; is a straightforward extension to support text transformations.


39-39: Adding $case to transient props.
Forwarding $case ensures it’s available in the styled interpolation. This aligns well with your approach.


50-66: Check cross-browser support for multiline ellipses.
Ensuring text-overflow: ellipsis and multi-line clamps are supported across all required browsers is crucial. Edge cases might need fallback logic.

Would you like me to generate a script to scan usage patterns of line clamp, or do you plan to rely on a documented support matrix?


67-77: "titlecase" only capitalizes the first letter of the entire string.
If the requirement is to capitalize each word (typical “title case”), additional logic is needed. Otherwise, this only changes the first character.


110-116: Storybook integration.
Including the new “case” control is a helpful addition for testing transformations.


146-146: Default arg for 'case' prop.
Providing a default of undefined prevents unintentional transformations and keeps stories consistent.

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/AdvancedCoinSettingsModal/AdvancedCoinSettingsModal.tsx (4)

28-31: Consistent use of type alias for props.
Declaring AdvancedCoinSettingsModalProps as a type is stylistically fine, matching other components’ newer patterns.


51-58: Conditional Tor enablement logic.
The check for onion URLs before enabling Tor is logical. However, consider user feedback if they have multiple onion-only backends inadvertently.


60-76: Potential consistency gap after 'use-defaults'.
When the user chooses "use-defaults", you call changeType('default') but do not finalize or close the modal. Confirm this meets user expectations.


83-85: Modal toggling approach is valid.
Swapping the entire component content based on torModalOpen is straightforward and clear.

@@ -24,6 +24,7 @@ export const allowedTextTextProps = [
'textWrap',
'align',
'ellipsisLineCount',
'case',
Copy link
Contributor

Choose a reason for hiding this comment

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

This prop name seems to me very confusing. Why not keep textTransform?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I know why you did it. It's because titlecase is non-standard. OK then...

Copy link
Contributor

Choose a reason for hiding this comment

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

git submodule update --init --recursive

const { isTorEnabled } = useSelector(selectTorState);
const blockchain = useSelector(state => state.wallet.blockchain);
const dispatch = useDispatch();
const [torModalOpen, setTorModalOpen] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: maybe torModalOpened or isTorModalOpened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔎 Needs review
Development

Successfully merging this pull request may close these issues.

2 participants