Skip to content

Conversation

gamalielhere
Copy link
Contributor

@gamalielhere gamalielhere commented Jan 3, 2025

Summary by CodeRabbit

  • New Features
    • Improved token name display by truncating long names to 25 characters with an ellipsis in multiple components.
    • Enhanced UI readability for token selection and asset lists.
    • Stream

Copy link

coderabbitai bot commented Jan 3, 2025

Walkthrough

The pull request introduces a consistent text truncation mechanism across multiple Vue components by implementing the $filters.truncate method. This method is applied to various token names and NFT item names, limiting their display length to a maximum of 25 or 50 characters, depending on the context. The changes simplify the template rendering by removing inline conditional logic and enhance the overall presentation without altering the existing functionality or control flow.

Changes

File Change Summary
packages/extension/src/ui/action/views/assets-select-list/components/assets-select-list-item.vue Updated token name display in <h4> element to use $filters.truncate, limiting to 25 characters.
packages/extension/src/ui/action/views/swap/components/swap-token-select/index.vue Updated token name display in <h5> element to use $filters.truncate, limiting to 25 characters.
packages/extension/src/providers/common/ui/send-transaction/nft-select-list/components/nft-select-list-item.vue Updated NFT item and collection name displays to use $filters.truncate, limiting item name to 25 characters and collection name to 50 characters.
packages/extension/src/providers/common/ui/send-transaction/send-nft-select.vue Updated NFT item and collection name displays to use $filters.truncate, limiting item name to 25 characters and collection name to 50 characters.
packages/extension/src/ui/action/types/filters.ts Introduced truncate function to the global $filters namespace.
packages/extension/src/ui/action/utils/filters.ts Added truncate function to truncate strings based on specified length.
packages/extension/src/ui/action/views/network-activity/components/network-activity-transaction.vue Updated token symbol display to use $filters.truncate, limiting to 40 characters.

Possibly related PRs

  • fix: error message for send when address has no balance for rent #561: The changes in this PR involve the use of a filter for truncating strings in the send-alert.vue component, similar to the truncation applied in the assets-select-list-item.vue component of the main PR. Both PRs utilize the $filters.truncate method for managing the display of text.

Suggested reviewers

  • NickKelly1
  • kvhnuke

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.

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

github-actions bot commented Jan 3, 2025

💼 Build Files
chrome: enkrypt-chrome-c8af63c1.zip
firefox: enkrypt-firefox-c8af63c1.zip

💉 Virus total analysis
chrome: c8af63c1
firefox: c8af63c1

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/extension/src/ui/action/views/swap/components/swap-token-select/index.vue (1)

7-13: Consider centralizing the truncation length in a single constant.

This logic effectively prevents layout disruption and improves readability. However, the hardcoded truncation length (25) might be more maintainable and consistent if declared as a constant or extracted to a shared utility. This helps ensure uniform updates across multiple components if the truncation length changes.

packages/extension/src/ui/action/views/assets-select-list/components/assets-select-list-item.vue (1)

8-14: Avoid duplication by reusing the truncation approach across components.

Similar to the other component, this logic works as intended, but storing the truncation length in a shared constant or helper function can enhance maintainability and consistency in the codebase. Consider extracting this logic to promote DRY (Don’t Repeat Yourself) principles.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eec3ed6 and 3f5e189.

📒 Files selected for processing (2)
  • packages/extension/src/ui/action/views/assets-select-list/components/assets-select-list-item.vue (1 hunks)
  • packages/extension/src/ui/action/views/swap/components/swap-token-select/index.vue (1 hunks)

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 (3)
packages/extension/src/ui/action/utils/filters.ts (1)

21-25: Consider handling multibyte characters.

This logic works for simple strings, but multi-byte characters might be split incorrectly. If your UI must handle emojis or non-Latin scripts, you may want to use methods that account for Unicode grapheme clusters, such as using Intl.Segmenter.

packages/extension/src/providers/common/ui/send-transaction/send-nft-select.vue (1)

12-12: Apply same logic for shorter collection names.

For clarity, consider whether shorter collection names (less than 50 characters) should be displayed without the ellipsis. The current filter logic is correct, but be mindful of the user experience.

packages/extension/src/providers/common/ui/send-transaction/nft-select-list/components/nft-select-list-item.vue (1)

8-8: Consider documenting the truncation length choices.

While the truncation lengths (25 for name, 50 for collection name) seem appropriate, it would be helpful to document why these specific lengths were chosen, perhaps as a comment or in component documentation.

Add a comment above the template section explaining the truncation lengths:

 <template>
+  <!-- 
+    NFT item display with truncated text:
+    - Name: 25 chars (compact display for main identifier)
+    - Collection: 50 chars (allows for longer collection names)
+  -->
   <a class="nft-select-list__token" @click="$emit('selectNft', item)">

Also applies to: 11-11

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f5e189 and c8af63c.

📒 Files selected for processing (7)
  • packages/extension/src/providers/common/ui/send-transaction/nft-select-list/components/nft-select-list-item.vue (1 hunks)
  • packages/extension/src/providers/common/ui/send-transaction/send-nft-select.vue (1 hunks)
  • packages/extension/src/ui/action/types/filters.ts (2 hunks)
  • packages/extension/src/ui/action/utils/filters.ts (1 hunks)
  • packages/extension/src/ui/action/views/assets-select-list/components/assets-select-list-item.vue (1 hunks)
  • packages/extension/src/ui/action/views/network-activity/components/network-activity-transaction.vue (1 hunks)
  • packages/extension/src/ui/action/views/swap/components/swap-token-select/index.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/extension/src/ui/action/views/assets-select-list/components/assets-select-list-item.vue
  • packages/extension/src/ui/action/views/swap/components/swap-token-select/index.vue
🔇 Additional comments (5)
packages/extension/src/ui/action/types/filters.ts (2)

7-7: Great addition of the truncate method to $filters.

Exporting truncate within $filters keeps the code consistent with other utilities like formatDuration and replaceWithEllipsis.


16-16: Ensure full coverage in unit tests.

If there are tests for $filters, consider adding test cases for truncate to verify various input lengths, including zero-length, longer strings, non-ASCII characters, etc.

packages/extension/src/providers/common/ui/send-transaction/send-nft-select.vue (1)

9-9: Consistent usage of $filters.truncate.

This approach aligns well with the rest of the codebase. Ensure you verify that all references to item.name are truncated the same way for UI consistency.

packages/extension/src/ui/action/views/network-activity/components/network-activity-transaction.vue (1)

114-114: Truncation for the token symbol is properly handled.

Truncating the symbol avoids potential UI overflow. Confirm any swap providers or contract addresses that might produce extremely long tokens are properly truncated as well.

packages/extension/src/providers/common/ui/send-transaction/nft-select-list/components/nft-select-list-item.vue (1)

8-8: Implementation looks good, verify filter registration.

The use of $filters.truncate is a good approach for consistent text truncation across components. The different truncation lengths (25 for name, 50 for collection name) make sense given their UI context.

Let's verify the filter registration and consistent usage across components:

Also applies to: 11-11

@gamalielhere gamalielhere merged commit 5deedd9 into develop Jan 9, 2025
4 checks passed
@gamalielhere gamalielhere deleted the fix/long-token-names branch January 9, 2025 22:24
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