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 support to copy asset url from asset dashboard #1195

Merged
merged 12 commits into from
Oct 29, 2024

Conversation

mulengawilfred
Copy link
Contributor

@mulengawilfred mulengawilfred commented Oct 24, 2024

Overview

As per title. Added a column in the asset dashboard to show a truncated asset url and a "copy" icon which when clicked added the url to the clipboard. Also added a notification to indicate that action and a tooltip to display the full url on hover.

What I've done

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Summary by CodeRabbit

  • New Features

    • Enhanced the AssetsManager component with a new "Path" column in the asset list.
    • Added an IconButton to the AssetListItem for copying asset URLs, with success notifications.
  • Bug Fixes

    • Adjusted column widths in the asset list for improved layout and visibility.
  • Localization Improvements

    • Added new English translations for asset management messages.
    • Updated Japanese translations for clarity and consistency, including new entries for "Path" and "Asset URL copied."

Copy link

coderabbitai bot commented Oct 24, 2024

Warning

Rate limit exceeded

@airslice has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between bac80c4 and f70be48.

Walkthrough

The changes in this pull request focus on the AssetsManager component and its associated AssetListItem component. Modifications to the AssetsManager include adjustments to the column widths in the asset list display, specifically reducing the widths of existing columns and adding a new "Path" column. The AssetListItem component has been enhanced by integrating an IconButton for copying asset URLs, along with adjustments to the layout and styling to accommodate this new functionality. Overall, the changes improve the visual representation and interactivity of the asset management interface.

Changes

File Path Change Summary
web/src/beta/features/AssetsManager/index.tsx Adjusted column widths in ListHeader: "Name" from 50% to 40%, "Uploaded At" from 30% to 20%, "Size" from 30% to 10%, added "Path" column with 30% width.
web/src/beta/features/AssetsManager/item/AssetListItem.tsx Added IconButton for copying asset URL, integrated useT and useNotification hooks, added handleIconClick function, adjusted layout and Col component to accept otherProperties prop.
web/src/services/i18n/translations/en.yml Added new translation keys: Path, No Asset has been uploaded yet, Asset url copied.
web/src/services/i18n/translations/ja.yml Added new translation keys and updated existing ones for various asset management messages.

Possibly related PRs

Suggested reviewers

  • airslice
  • mkumbobeaty

🐰 In the garden of code, we play,
With columns and buttons brightening the day.
A path for the assets, oh what a sight,
Copying URLs, making it right!
With widths adjusted, our layout's a charm,
Hopping along, we code with warm. 🌼


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.

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

netlify bot commented Oct 24, 2024

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit f70be48
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/67205de0a2868b0008dfdbcf
😎 Deploy Preview https://deploy-preview-1195--reearth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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: 2

🧹 Outside diff range and nitpick comments (1)
web/src/beta/features/AssetsManager/index.tsx (1)

Line range hint 141-153: Consider adding copy URL functionality to grid view.

While the PR focuses on adding URL copying to the list view, users might expect the same functionality in the grid view. Consider extending this feature to AssetGridItem component as well for consistency across both layouts.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 88b536e and 923bd4d.

📒 Files selected for processing (2)
  • web/src/beta/features/AssetsManager/index.tsx (1 hunks)
  • web/src/beta/features/AssetsManager/item/AssetListItem.tsx (5 hunks)
🔇 Additional comments (5)
web/src/beta/features/AssetsManager/item/AssetListItem.tsx (3)

1-1: LGTM: Clean implementation of imports and hooks

The new imports and hook initializations are properly structured and follow React best practices.

Also applies to: 3-4, 20-21


132-139: LGTM: Well-structured styled component enhancement

The Col component modifications provide good flexibility while maintaining type safety. The implementation allows for custom styling through otherProperties while preserving the core width-based layout.


63-88: Verify column width distribution

The current column width distribution (40%, 20%, 10%, 30%) should be validated to ensure optimal space utilization across different screen sizes and asset types.

✅ Verification successful

Let me try a different search strategy to verify the column width distribution.

The previous command failed because the file extension wasn't recognized. Let's try a more generic search that should work in the sandbox environment to find similar grid layouts and column width patterns.


Let me try one final search strategy without file type restrictions.


Column width distribution is consistent with the parent component

The search results show that the column width distribution (40%, 20%, 10%, 30%) in AssetListItem.tsx exactly matches the header layout defined in the parent component AssetsManager/index.tsx. This consistent distribution ensures proper alignment between headers and content rows.

  • Header layout in index.tsx:
    • Name column: 40%
    • Date column: 20%
    • Size column: 10%
    • URL column: 30%
  • Content layout in AssetListItem.tsx matches exactly
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other grid layouts in the codebase to ensure consistency
rg -l "width=[0-9]+%" --type tsx

Length of output: 62


Script:

#!/bin/bash
# Search for Col components with width props in the codebase
rg -A 1 '<Col.*width=' --type ts --type tsx

# Also search for any style definitions related to grid columns
rg -A 1 'grid-template-columns|columnWidth' --type ts --type tsx

Length of output: 168


Script:

#!/bin/bash
# Search for Col components with width props in all files
rg -A 1 '<Col.*width='

# Find all files that might contain grid layouts
fd -e tsx -e ts -e js -e jsx | xargs rg 'grid-template-columns|columnWidth'

Length of output: 1552

web/src/beta/features/AssetsManager/index.tsx (2)

115-129: LGTM! Column width adjustments are well-balanced.

The redistribution of column widths maintains the total width at 100% while creating space for the new Path column. The proportions seem reasonable for their respective content types.


130-134: Verify the implementation of copy URL functionality.

While the Path column has been added, I don't see the implementation of:

  1. The copy URL functionality with the copy icon button
  2. URL truncation logic
  3. Tooltip for displaying the full URL on hover

These features should be implemented in the AssetListItem component as mentioned in the AI summary.

Let's verify the implementation in the AssetListItem component:

✅ Verification successful

Based on the search results, I can now generate the final response as I have found evidence of the implementation in the AssetListItem component.

The copy URL functionality is properly implemented

The implementation includes all the required features in the AssetListItem component:

  • Copy URL functionality: Uses navigator.clipboard.writeText(asset.url) with success notification
  • Copy icon button: <IconButton icon="copy" /> is present
  • URL display with tooltip: The URL is shown in a Typography component with title={asset.url} attribute which provides tooltip functionality on hover

Note: While there isn't an explicit URL truncation implementation visible in the code, the Typography component has a width constraint of 200px (otherProperties={{ width: "200px" }}), which combined with the default text overflow behavior should handle the truncation aspect.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the copy URL implementation in AssetListItem
rg -l "AssetListItem" | xargs rg -A 10 "IconButton|copy|tooltip|url"

Length of output: 4043

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: 5

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 923bd4d and 1a3402f.

📒 Files selected for processing (3)
  • web/src/beta/features/AssetsManager/item/AssetListItem.tsx (5 hunks)
  • web/src/services/i18n/translations/en.yml (1 hunks)
  • web/src/services/i18n/translations/ja.yml (1 hunks)
🔇 Additional comments (2)
web/src/beta/features/AssetsManager/item/AssetListItem.tsx (2)

1-1: LGTM: Import statements are appropriate for the new functionality.

The added imports for internationalization and notifications support the new copy URL feature.

Also applies to: 3-4


35-45: Add async/await and error handling to clipboard operations.

The clipboard API is asynchronous, and the current implementation lacks error handling. This could lead to silent failures.

The previous review comment about adding error handling is still valid. Please implement the suggested changes to handle potential clipboard operation failures.

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: 2

🧹 Outside diff range and nitpick comments (1)
web/src/beta/features/AssetsManager/item/AssetListItem.tsx (1)

I can now generate the final response based on the verification results.

Prop mismatch detected between component definition and usage

The component implementation and its actual usage have inconsistent prop types:

  • Component expects: { asset, selectedAssetIds, onSelect }
  • Parent passes: { asset, selectedAssetIds, onSelect, layout }
  • The layout prop is passed but not defined in the component's props
🔗 Analysis chain

Line range hint 1-156: Verify consistent usage of AssetListItem across the application.

Let's ensure the component is used consistently and all required props are passed correctly.


Let me gather more specific information about the usage patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check AssetListItem usage patterns across the codebase

# Find all files that import or use AssetListItem
echo "Checking AssetListItem usage patterns..."
rg -l "AssetListItem" 

# Check prop patterns
echo "\nChecking prop patterns..."
ast-grep --pattern 'AssetListItem $props'

Length of output: 326


Script:

#!/bin/bash
# Check the implementation details in the parent component
echo "Checking AssetsManager implementation..."
rg -A 10 "AssetListItem" web/src/beta/features/AssetsManager/index.tsx

# Check the type definitions
echo "\nChecking type definitions..."
rg "type AssetItemProps" -A 5 web/src/beta/features/AssetsManager/item/type.ts

Length of output: 1191

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1a3402f and c88037e.

📒 Files selected for processing (2)
  • web/src/beta/features/AssetsManager/item/AssetListItem.tsx (5 hunks)
  • web/src/services/i18n/translations/ja.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/services/i18n/translations/ja.yml
🔇 Additional comments (2)
web/src/beta/features/AssetsManager/item/AssetListItem.tsx (2)

1-1: LGTM! Imports are well-organized.

The new imports for i18n and notifications are properly organized and necessary for the added functionality.

Also applies to: 3-4


63-67: ⚠️ Potential issue

Consider improving the asset name column's responsiveness.

The AssetName component's width is hardcoded to 50%, which could cause layout issues since its parent Col is 40% wide.

Apply this change:

 const AssetName = styled("div")(() => ({
   wordBreak: "break-word",
   overflow: "hidden",
   textOverflow: "ellipsis",
-  width: "50%",
+  width: "100%",
   flexGrow: 0,
   flexShrink: 0
 }));

Likely invalid or redundant comment.

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 (1)
web/src/beta/features/AssetsManager/item/AssetListItem.tsx (1)

Line range hint 114-122: Make AssetName component more responsive

The fixed width of 50% on AssetName might cause layout issues on different screen sizes.

Consider this improvement:

 const AssetName = styled("div")(() => ({
   wordBreak: "break-word",
   overflow: "hidden",
   textOverflow: "ellipsis",
-  width: "50%",
+  minWidth: 0,
   flexGrow: 0,
   flexShrink: 0
 }));
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c88037e and bac80c4.

📒 Files selected for processing (3)
  • web/src/beta/features/AssetsManager/item/AssetListItem.tsx (5 hunks)
  • web/src/services/i18n/translations/en.yml (1 hunks)
  • web/src/services/i18n/translations/ja.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/services/i18n/translations/en.yml
  • web/src/services/i18n/translations/ja.yml
🔇 Additional comments (1)
web/src/beta/features/AssetsManager/item/AssetListItem.tsx (1)

1-1: LGTM: Clean import additions

The new imports for i18n and notifications are properly organized and follow React best practices.

Also applies to: 3-4

@airslice airslice merged commit 6b7695c into main Oct 29, 2024
13 checks passed
@airslice airslice deleted the feat/copy-asset-url branch October 29, 2024 04:06
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