Skip to content

[Admin] Improve order history UI#17641

Merged
GSadee merged 2 commits intoSylius:2.0from
kulczy:SYL-4277/order-history
Feb 3, 2025
Merged

[Admin] Improve order history UI#17641
GSadee merged 2 commits intoSylius:2.0from
kulczy:SYL-4277/order-history

Conversation

@kulczy
Copy link
Copy Markdown
Contributor

@kulczy kulczy commented Jan 23, 2025

Before

image

After

image

Summary by CodeRabbit

  • UI/UX Improvements
    • Simplified address section layout in order history.
    • Redesigned address log display with a more responsive, row-based format.
    • Updated action label styling with new status classes for improved clarity.
    • Enhanced visual feedback for different log action types through conditional alert classes.

@kulczy kulczy requested review from a team as code owners January 23, 2025 11:58
@probot-autolabeler probot-autolabeler bot added the Admin AdminBundle related issues and PRs. label Jan 23, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 23, 2025

Walkthrough

The pull request focuses on refactoring the HTML templates for order address history in the Sylius Admin Bundle. The changes simplify the markup structure, remove unnecessary card and table layouts, and update CSS classes for action labels. The modifications aim to improve the visual presentation and responsiveness of address log displays by transitioning from a rigid table-based design to a more flexible, row-based layout with enhanced styling.

Changes

File Change Summary
src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses.html.twig Removed card layout and nested <div> elements, simplifying the markup around the 'addresses' hook.
src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses/address.html.twig Restructured HTML layout, replaced table with row-based design, simplified card component, and enhanced log entry display.
src/Sylius/Bundle/AdminBundle/templates/order/history/macro/action_label.html.twig Updated CSS classes from badge to status, modified action label styling with new class names.

Possibly related PRs

  • Fullscreen order table view #17620: The changes in the items.html.twig file include modifications to the HTML structure that enhance the functionality for fullscreen display, which is related to the simplification of the markup in the main PR's addresses.html.twig and address.html.twig templates.

Suggested labels

UX

Suggested reviewers

  • GSadee

Poem

🐰 In the realm of admin's delight,
Templates dance with newfound might.
Rows replace the tables old,
A cleaner view, both sleek and bold.
Rabbit's code, a UI's sweet song! 🎨


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.

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
Copy Markdown

@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

🧹 Nitpick comments (1)
src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses/address.html.twig (1)

14-15: Consider using localized date/time format.

Instead of hardcoding the date/time format, consider using Sylius's localization features for better internationalization support.

-    <span class="text-nowrap">{{ log.loggedAt|date('Y-m-d') }}</span>
-    <span class="text-nowrap">{{ log.loggedAt|date('H:i:s') }}</span>
+    <span class="text-nowrap">{{ log.loggedAt|format_datetime('short', 'none') }}</span>
+    <span class="text-nowrap">{{ log.loggedAt|format_datetime('none', 'short') }}</span>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 27c5ab5 and 63ba951.

📒 Files selected for processing (3)
  • src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses/address.html.twig (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/order/history/macro/action_label.html.twig (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses.html.twig
  • src/Sylius/Bundle/AdminBundle/templates/order/history/macro/action_label.html.twig
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Static checks / PHP 8.3, Symfony ^7.1
  • GitHub Check: Static checks / PHP 8.2, Symfony ^6.4
🔇 Additional comments (2)
src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses/address.html.twig (2)

5-33: Overall implementation looks good!

The template implements a clean, responsive layout with proper semantic structure and accessibility considerations. The use of Bootstrap's grid system and responsive utilities is well-thought-out.


6-6: Check Bootstrap spacing utility class.

The mb-6 class appears to be non-standard, as Bootstrap's spacing utilities typically only go up to mb-5. This might lead to inconsistent spacing across different Bootstrap versions.

✅ Verification successful

The mb-6 class is valid and intentionally supported.

The codebase includes custom Bootstrap spacing configuration in src/Sylius/Bundle/ShopBundle/Resources/assets/styles/_variables.scss that explicitly defines level 6 spacing ($spacer * 5), making this a legitimate utility class.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any custom Bootstrap utility extensions in the codebase
rg -g '*.{scss,css}' -l '^\$spacers:|\.mb-6'

Length of output: 115


Script:

#!/bin/bash
# Check the content of the variables file for spacer definitions
cat src/Sylius/Bundle/ShopBundle/Resources/assets/styles/_variables.scss

Length of output: 2570

</div>
</div>
<div class="col-12 col-sm-8 col-md-9">
<div class="alert alert-{{ log.action == 'create' ? 'success' : (log.action == 'update' ? 'yellow') }}">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use standard Bootstrap alert class.

The alert-yellow class is non-standard in Bootstrap. Consider using a standard Bootstrap alert class like alert-warning for consistency.

-    <div class="alert alert-{{ log.action == 'create' ? 'success' : (log.action == 'update' ? 'yellow') }}">
+    <div class="alert alert-{{ log.action == 'create' ? 'success' : (log.action == 'update' ? 'warning') }}">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div class="alert alert-{{ log.action == 'create' ? 'success' : (log.action == 'update' ? 'yellow') }}">
<div class="alert alert-{{ log.action == 'create' ? 'success' : (log.action == 'update' ? 'warning') }}">

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 23, 2025

Bunnyshell Preview Environment deleted

Available commands:

  • /bns:deploy to redeploy the environment

@kulczy kulczy force-pushed the SYL-4277/order-history branch from 0d2653e to a818aa8 Compare January 24, 2025 14:37
Copy link
Copy Markdown

@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)
src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses/address.html.twig (3)

6-6: Replace non-standard Bootstrap margin class.

The mb-6 class is not a standard Bootstrap utility class. Bootstrap's spacing utilities only go up to 5.

-    <div class="mb-6 border-bottom">
+    <div class="mb-5 border-bottom">

20-28: Simplify the table structure.

The current table structure with table-responsive might be overly complex for a two-column layout. Consider using a simpler grid-based approach.

-                    <div class="table-responsive text-secondary">
-                        <table class="table table-sm table-vcenter">
-                            {%- for field, data in log.data|filter(data => not data is empty) -%}
-                                <tr>
-                                    <td class="col-4 border-0"><strong>{{ ('sylius.ui.' ~ field|u.snake)|trans }}</strong></td>
-                                    <td class="col-8 border-0 text-body w-full"><span>{{ data }}</span></td>
-                                </tr>
-                            {%- endfor -%}
-                        </table>
-                    </div>
+                    <div class="text-secondary">
+                        {%- for field, data in log.data|filter(data => not data is empty) -%}
+                            <div class="row g-3 mb-2">
+                                <div class="col-4"><strong>{{ ('sylius.ui.' ~ field|u.snake)|trans }}</strong></div>
+                                <div class="col-8 text-body">{{ data }}</div>
+                            </div>
+                        {%- endfor -%}
+                    </div>

14-15: Use semantic HTML time elements.

For better semantics and accessibility, consider using the HTML time element for dates and times.

-                    <span class="text-nowrap">{{ log.loggedAt|date('Y-m-d') }}</span>
-                    <span class="text-nowrap">{{ log.loggedAt|date('H:i:s') }}</span>
+                    <time class="text-nowrap" datetime="{{ log.loggedAt|date('Y-m-d') }}">{{ log.loggedAt|date('Y-m-d') }}</time>
+                    <time class="text-nowrap" datetime="{{ log.loggedAt|date('H:i:s') }}">{{ log.loggedAt|date('H:i:s') }}</time>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d2653e and a818aa8.

📒 Files selected for processing (1)
  • src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses/address.html.twig (1 hunks)
🔇 Additional comments (2)
src/Sylius/Bundle/AdminBundle/templates/order/history/content/sections/addresses/address.html.twig (2)

10-17: Well-structured responsive layout!

The grid system implementation with proper breakpoints and alignment classes creates a clean, responsive layout.


19-19: Use standard Bootstrap alert class.

The alert-yellow class is non-standard in Bootstrap. Consider using a standard Bootstrap alert class like alert-warning for consistency.

@GSadee GSadee added the UX Issues and PRs aimed at improving User eXperience. label Feb 3, 2025
@GSadee GSadee merged commit 4f0ab4b into Sylius:2.0 Feb 3, 2025
22 checks passed
@GSadee
Copy link
Copy Markdown
Member

GSadee commented Feb 3, 2025

Thank you @kulczy! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin AdminBundle related issues and PRs. UX Issues and PRs aimed at improving User eXperience.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants