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

fix(web): link to asset and refer to item icons #1272

Merged
merged 5 commits into from
Oct 24, 2024
Merged

Conversation

caichi-t
Copy link
Contributor

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

Overview

This PR fixes the link to asset and refer to item icons.

Memo

Small styling fixes are included.

Summary by CodeRabbit

  • New Features

    • Updated modals (LinkAssetModal, LinkItemRequestModal) now have a fixed height of 70vh for improved layout and visibility.
    • Enhanced button functionality and appearance in ReferenceFormItem with the new UnreferButton.
    • Added new icon (arrowUpRightSlash) for improved visual representation.
  • Bug Fixes

    • Simplified state management in LinkAssetModal, improving the rendering of link buttons without hover effects.
    • Updated toolbar layout in ResizableProTable for better styling and usability.
  • Documentation

    • Complete replacement of English and Japanese translations for various user interface elements and messages.

@caichi-t caichi-t requested a review from nourbalaha as a code owner October 18, 2024 09:29
Copy link

coderabbitai bot commented Oct 18, 2024

Walkthrough

The pull request involves modifications to several components within the web application, primarily focusing on modal adjustments. The LinkItemRequestModal and LinkAssetModal components have had their heights set to a fixed "70vh," simplifying state management by removing hover-related state hooks. The ReferenceFormItem component introduces a new styled button, UnreferButton, with updated functionality. Additionally, the ResizableProTable component received styling updates for its toolbar layout. Significant changes were also made to the translation files, replacing all previous entries with new key-value pairs.

Changes

File Path Change Summary
web/src/components/molecules/Common/LinkAssetModal/LinkAssetModal.tsx Removed useState for hoveredAssetId, simplified link status logic, updated columns dependencies, set height to 70vh.
web/src/components/molecules/Content/LinkItemRequestModal/LinkItemRequestModal.tsx Set height to 70vh, retained afterClose callback, padding unchanged.
web/src/components/molecules/Content/Form/ReferenceFormItem/index.tsx Introduced UnreferButton, updated button icon and text based on value.
web/src/components/molecules/Common/ResizableProTable/index.tsx Updated styles for StyledProTable, adjusted toolbar layout and flex properties.
web/src/components/atoms/Icon/icons.ts Added new icon arrowUpRightSlash to the export object.
web/src/i18n/translations/en.yml Replaced all previous entries with new key-value pairs for translations.
web/src/i18n/translations/ja.yml Replaced all previous entries with new translations.

Possibly related PRs

Suggested reviewers

  • nourbalaha

🐇 In the modals, we’ve made a change,
To simplify and rearrange.
No more hover, just a link,
With fixed heights, we pause to think.
A toolbar styled with care and grace,
In our UI, it finds its place! ✨


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 18, 2024
Copy link

netlify bot commented Oct 18, 2024

Deploy Preview for reearth-cms ready!

Name Link
🔨 Latest commit 0feba01
🔍 Latest deploy log https://app.netlify.com/sites/reearth-cms/deploys/6719bf46b95a590008e88454
😎 Deploy Preview https://deploy-preview-1272--reearth-cms.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: 1

🧹 Outside diff range and nitpick comments (4)
web/src/components/molecules/Common/ResizableProTable/index.tsx (1)

Line range hint 139-155: Styling improvements with considerations for responsiveness

The changes to the StyledProTable component improve the toolbar layout, which aligns with the PR objectives. Here are some observations and suggestions:

  1. Setting flex-direction: row for .ant-pro-table-list-toolbar-container ensures horizontal alignment of toolbar elements, which is good for desktop views.

  2. The updates to .ant-pro-table-list-toolbar-left remove the margin and set a max-width, which can improve the layout consistency.

  3. Changing .ant-pro-table-list-toolbar-right to flex: inherit might affect its sizing behavior.

These changes enhance the desktop layout, but consider the following:

  • Ensure the layout remains usable on smaller screens. Consider adding media queries for responsive behavior.
  • The fixed max-width for .ant-input-group-wrapper might not scale well for all screen sizes. Consider using relative units or a responsive approach.

Example of a more responsive approach:

.ant-pro-table-list-toolbar-left {
  flex: 1;
  max-width: calc(100% - 150px);
  margin: 0;
  .ant-pro-table-list-toolbar-search {
    width: 100%;
  }
  .ant-input-group-wrapper {
    min-width: 200px;
    max-width: 100%; /* Allow full width on smaller screens */
    width: 100%; /* Ensure it takes full width of its container */
  }
}

@media (min-width: 768px) {
  .ant-input-group-wrapper {
    max-width: 230px; /* Apply max-width on larger screens */
  }
}

This approach allows for better adaptability across different screen sizes while maintaining the intended layout on larger screens.

web/src/components/molecules/Content/LinkItemModal/index.tsx (1)

112-117: LGTM: Simplified link status logic

The simplification of the link status logic improves code readability and reduces complexity. This change aligns well with the removal of the hoveredAssetId state.

Consider extracting the link status check into a separate variable for improved readability:

-          const isLink = item.id !== linkedItem;
+          const isUnlinked = item.id !== linkedItem;
           return (
             <Button
               type="link"
-              icon={<Icon icon={isLink ? "linkSolid" : "unlinkSolid"} size={16} />}
-              onClick={() => handleClick(isLink, item)}
+              icon={<Icon icon={isUnlinked ? "linkSolid" : "unlinkSolid"} size={16} />}
+              onClick={() => handleClick(isUnlinked, item)}
             />
           );

This small change makes the intent clearer and aligns the variable name with its usage.

web/src/components/molecules/Content/LinkItemRequestModal/LinkItemRequestModal.tsx (1)

172-172: Approved, but consider responsive design implications.

The change from a minimum height of "50vh" to a fixed height of "70vh" for the modal body is acceptable and aligns with the PR objectives of making styling adjustments. This change will provide a consistent height across different screen sizes and potentially make better use of vertical space on most screens.

However, it's important to consider the implications for responsive design:

  1. On smaller screens or window sizes, a fixed height of 70vh might lead to content overflow or a suboptimal user experience.
  2. The loss of flexibility (changing from min-height to height) might affect how the modal adapts to different content lengths.

Consider the following suggestions to enhance responsiveness:

  1. Use a media query to adjust the height for smaller screens:

    @media (max-height: 600px) {
      height: 90vh;
    }
  2. Alternatively, retain some flexibility by using min-height instead of height:

    min-height: "70vh",
    max-height: "90vh",

These approaches would maintain the intended design while ensuring better adaptability across different devices and screen sizes.

web/src/components/molecules/Common/LinkAssetModal/LinkAssetModal.tsx (1)

240-240: Consider flexible modal sizing for better responsiveness

The modal's body height has been changed from a minimum of "50vh" to a fixed "70vh". While this increases the visible content area, it may lead to responsiveness issues on smaller screens or devices with limited vertical space.

Consider using a more flexible approach, such as:

  1. Combining min-height with max-height to ensure the modal is neither too small nor too large.
  2. Using media queries to adjust the height based on screen size.
  3. Implementing a resizable modal component that allows users to adjust the size as needed.

Example:

height: clamp(50vh, 70vh, calc(100vh - 100px));

This would set a minimum height of 50vh, a preferred height of 70vh, and a maximum height of the viewport height minus 100px for padding.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 803c54f and c4fa544.

📒 Files selected for processing (4)
  • web/src/components/molecules/Common/LinkAssetModal/LinkAssetModal.tsx (4 hunks)
  • web/src/components/molecules/Common/ResizableProTable/index.tsx (1 hunks)
  • web/src/components/molecules/Content/LinkItemModal/index.tsx (4 hunks)
  • web/src/components/molecules/Content/LinkItemRequestModal/LinkItemRequestModal.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (6)
web/src/components/molecules/Content/LinkItemModal/index.tsx (2)

2-2: LGTM: Simplified import statement

The removal of useState from the import statement aligns with the simplification of state management in this component. This change reduces unnecessary imports and improves code clarity.


156-156: LGTM: Updated useMemo dependencies

The removal of hoveredAssetId from the dependencies array of the useMemo hook is consistent with the overall changes in state management. This update ensures that the memoized columns are only recalculated when necessary, potentially improving performance.

web/src/components/molecules/Common/LinkAssetModal/LinkAssetModal.tsx (4)

2-2: Removal of useState hook: Simplification of state management

The removal of the useState hook from the import statement suggests a simplification of the component's state management. This change aligns with the removal of hover state tracking mentioned in the summary.


129-129: Simplified link status logic: Improved readability and performance

The logic for determining the isLink status has been simplified to a direct comparison between the asset ID and the linked asset ID. This change eliminates the need for hover state management, potentially improving performance by reducing unnecessary state updates. The code is now more straightforward and easier to understand.


182-182: Updated useMemo dependencies: Consistent with hover state removal

The removal of hoveredAssetId from the useMemo dependencies is consistent with the earlier changes that eliminated hover state management. This update ensures that the memoized columns array is only recomputed when necessary, potentially improving performance.


Line range hint 1-270: Overall assessment: Improved component with simplified state management

The changes to the LinkAssetModal component have generally improved its implementation by:

  1. Removing unnecessary hover state management, simplifying the code and potentially improving performance.
  2. Updating the modal size to show more content.

These changes align well with the PR objectives of fixing asset linking issues. The code is now more maintainable and efficient. However, consider revisiting the modal sizing approach to ensure optimal responsiveness across different devices and screen sizes.

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

🧹 Outside diff range and nitpick comments (4)
web/src/components/molecules/Content/Form/ReferenceFormItem/index.tsx (2)

Line range hint 92-98: Approved: UI enhancement with custom styled button

The replacement of Button with UnreferButton and the icon change improve the UI consistency and visual representation. The functionality remains intact.

Consider adding a tooltip to the button to explain its function, especially since it's only an icon now:

 <UnreferButton
   type="link"
   icon={<Icon icon={"arrowUpRightSlash"} size={16} />}
   onClick={() => {
     onChange?.();
   }}
+  title={t("Unrefer item")}
 />

133-136: Approved: New styled component for consistent UI

The addition of the UnreferButton styled component enhances UI consistency for unrefer actions throughout the application.

Consider using a color variable instead of a hardcoded hex value for better maintainability:

 const UnreferButton = styled(Button)`
-  color: #000000d9;
+  color: var(--color-text-primary);
 `;

This assumes you have a color variable defined for primary text. If not, consider adding one to your global styles.

web/src/i18n/translations/ja.yml (2)

12-24: Consider revising the translation for "Delete Personal Account"

The current translation for "Delete Personal Account" (アカウントを削除) on line 22 is somewhat ambiguous. It translates to "Delete Account" without specifying that it's a personal account.

Consider changing the translation to "個人アカウントを削除" to more accurately reflect the English meaning and distinguish it from other types of account deletion.


47-53: Consider translating file format strings

The translations for various file formats (lines 47-53) are currently left as-is in English. While this is often acceptable for technical terms, you might want to consider adding Japanese explanations for better user understanding.

For example:

  • "PNG/JPEG/TIFF/GIF" could be "PNG/JPEG/TIFF/GIF画像ファイル"
  • "3D Tiles" could be "3Dタイル"
  • "GLTF/GLB" could be "GLTF/GLB 3Dモデルファイル"

This approach maintains the technical accuracy while providing additional context for Japanese users.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c4fa544 and f5b7b78.

⛔ Files ignored due to path filters (1)
  • web/src/components/atoms/Icon/Icons/arrowUpRightSlash.svg is excluded by !**/*.svg
📒 Files selected for processing (5)
  • web/src/components/atoms/Icon/icons.ts (2 hunks)
  • web/src/components/molecules/Content/Form/ReferenceFormItem/index.tsx (3 hunks)
  • web/src/components/molecules/Content/LinkItemModal/index.tsx (4 hunks)
  • web/src/i18n/translations/en.yml (1 hunks)
  • web/src/i18n/translations/ja.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/components/molecules/Content/LinkItemModal/index.tsx
🧰 Additional context used
🪛 yamllint
web/src/i18n/translations/en.yml

[error] 1-1: wrong new line character: expected \n

(new-lines)

web/src/i18n/translations/ja.yml

[error] 1-1: wrong new line character: expected \n

(new-lines)

🔇 Additional comments (7)
web/src/components/molecules/Content/Form/ReferenceFormItem/index.tsx (1)

104-104: Approved: Improved context-aware button text

The conditional text for the StyledButton enhances user experience by clearly indicating the action based on the current state (replace or refer). The use of the t function ensures proper internationalization.

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

58-58: LGTM: New icon import follows existing conventions.

The import statement for the new ArrowUpRightSlash icon is consistent with the existing import pattern and naming conventions used in this file.


127-127: LGTM: New icon correctly added to the export object.

The new arrowUpRightSlash icon is properly added to the default export object, maintaining consistency with existing entries and preserving alphabetical order.


58-58: Verify usage of the new icon in relation to PR objectives.

The new ArrowUpRightSlash icon has been successfully added. To ensure it aligns with the PR objectives of "fix(web): link to asset and refer to item icons", please confirm that this icon is being utilized in the relevant components for linking assets or referring to item icons.

Also applies to: 127-127

✅ Verification successful

Usage of the new ArrowUpRightSlash icon is correctly implemented and aligns with the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usage of the new ArrowUpRightSlash icon in relevant components

# Test: Look for imports or usage of ArrowUpRightSlash in web components
rg --type typescript --type tsx 'ArrowUpRightSlash|arrowUpRightSlash' web/src/components

Length of output: 125


Script:

#!/bin/bash
# Description: Search for usage of the new ArrowUpRightSlash icon in relevant components

# Test: Look for imports or usage of ArrowUpRightSlash in web components
rg 'ArrowUpRightSlash|arrowUpRightSlash' web/src/components --glob '*.ts' --glob '*.tsx'

Length of output: 562

web/src/i18n/translations/en.yml (1)

1-557: LGTM: Comprehensive translation key structure

The translation file structure looks good and appears to cover a wide range of functionalities for the Re:Earth CMS application. The keys are descriptive and follow a consistent naming convention. The empty string values are appropriate for a template translation file, allowing for easy addition of actual translations later.

A few observations:

  1. The file includes translations for various UI elements, error messages, and system notifications.
  2. The keys are organized in a flat structure, which is suitable for most translation management systems.
  3. Some keys use interpolation (e.g., line 285: Are you sure you want to delete this model: Are you sure you want to delete this model <strong>{{name}}</strong>?), which is good for dynamic content.

As development progresses, ensure that:

  1. All used translation keys in the application are present in this file.
  2. Actual translations are added for each key before deployment.
  3. Any unused keys are removed to keep the file maintainable.
🧰 Tools
🪛 yamllint

[error] 1-1: wrong new line character: expected \n

(new-lines)

web/src/i18n/translations/ja.yml (2)

1-557: Overall, the translations appear comprehensive and well-structured.

The file contains a wide range of translations covering various aspects of the application, including account management, project settings, asset uploads, and workspace management. The translations seem to be appropriate for a Japanese audience.

However, here are a few suggestions for improvement:

  1. Consider reviewing the translation for "Oops!" (line 3). The current translation is an empty string, which might not be the intended behavior. You may want to use a culturally appropriate expression of surprise or apology.

  2. The translation for "OK" (line 105) is also an empty string. Consider using "OK" or "はい" depending on the context.

  3. The translation for "example" (line 393) is also an empty string. Consider translating it to "例" or "例えば".

  4. The translation for "is used in" (line 509) is an empty string. Consider translating it to "で使用されています".

These suggestions aim to improve the completeness and consistency of the translations.

🧰 Tools
🪛 yamllint

[error] 1-1: wrong new line character: expected \n

(new-lines)


1-557: Overall, the translations are well done and comprehensive

The translations cover a wide range of functionality and seem to be appropriate for a Japanese audience. The language used is polite and professional, which is suitable for a business application.

Great job on providing such a comprehensive set of translations! The suggestions provided in the review comments are minor improvements that can enhance the overall quality and consistency of the translations.

🧰 Tools
🪛 yamllint

[error] 1-1: wrong new line character: expected \n

(new-lines)

web/src/i18n/translations/en.yml Show resolved Hide resolved
web/src/i18n/translations/ja.yml Show resolved Hide resolved
web/src/i18n/translations/ja.yml Show resolved Hide resolved
web/src/i18n/translations/ja.yml Show resolved Hide resolved
web/src/i18n/translations/ja.yml Show resolved Hide resolved
web/src/i18n/translations/ja.yml Show resolved Hide resolved
@caichi-t caichi-t enabled auto-merge (squash) October 24, 2024 03:30
@caichi-t caichi-t merged commit 00acd2f into main Oct 24, 2024
15 checks passed
@caichi-t caichi-t deleted the fix-web/asset-ref-icon branch October 24, 2024 03:33
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f5b7b78 and 0feba01.

📒 Files selected for processing (1)
  • web/src/components/atoms/Icon/icons.ts (2 hunks)
🔇 Additional comments (1)
web/src/components/atoms/Icon/icons.ts (1)

59-59: LGTM!

The import follows the established pattern and naming convention.

@@ -124,6 +125,7 @@ export default {
asset: Asset,
listBullets: ListBullets,
arrowUpRight: ArrowUpRight,
arrowUpRightSlash: ArrowUpRightSlash,
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Migration to arrowUpRightSlash icon is incomplete - found remaining unlinkSolid usages

The verification revealed that while arrowUpRightSlash is being used in some components, there are still two components using the old unlinkSolid icon:

  • web/src/components/molecules/Common/Form/AssetItem/index.tsx
  • web/src/components/molecules/Common/LinkAssetModal/LinkAssetModal.tsx

These components should be updated to use the new arrowUpRightSlash icon for consistency with the rest of the codebase.

🔗 Analysis chain

Verify the icon replacement across the codebase.

The icon mapping is correctly added. Since this icon is replacing unlinkSolid in the ReferenceFormItem component, let's verify there are no other components still using the old icon.


Let me try with a different command that doesn't rely on file type specifications.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of unlinkSolid icon
# to ensure complete migration to arrowUpRightSlash

echo "Checking for remaining unlinkSolid icon usage..."
rg -l "unlinkSolid" --type ts --type tsx

echo "Checking for new arrowUpRightSlash icon usage..."
rg -l "arrowUpRightSlash" --type ts --type tsx

Length of output: 357


Script:

#!/bin/bash
# Search for unlinkSolid usage across all files
echo "Checking for remaining unlinkSolid icon usage..."
rg "unlinkSolid"

echo -e "\nChecking for new arrowUpRightSlash icon usage..."
rg "arrowUpRightSlash"

Length of output: 1074

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