Skip to content

[Admin] Plus features clickbaits#17827

Merged
GSadee merged 8 commits intoSylius:2.0from
PiotrTulacz:SYL-4312/Plus-features-clickbaits
May 6, 2025
Merged

[Admin] Plus features clickbaits#17827
GSadee merged 8 commits intoSylius:2.0from
PiotrTulacz:SYL-4312/Plus-features-clickbaits

Conversation

@PiotrTulacz
Copy link
Copy Markdown

@PiotrTulacz PiotrTulacz commented Apr 3, 2025

Added support for displaying Sylius Plus logo in the admin navbar via menu.
Included an example usage in the Administration section of the main menu.

image
image

image
image

Summary by CodeRabbit

  • New Features

    • Enhanced the main navigation by adding an Administration section that offers new access options for administration-related content, including links to roles information.
  • Style

    • Introduced a new badge element in the navigation and refined dropdown layouts, improving visual consistency and usability through enhanced logo and icon displays.

@PiotrTulacz PiotrTulacz requested review from a team as code owners April 3, 2025 11:04
@probot-autolabeler probot-autolabeler bot added the Admin AdminBundle related issues and PRs. label Apr 3, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes enhance the administration menu functionality by adding a new private method in the main menu builder that constructs an "Administration" submenu with designated child items and extra metadata. The menu template is updated to incorporate extra Bootstrap classes and conditional logic to render a Sylius Plus logo or an external link icon based on data. Additionally, a new CSS class is introduced to style a badge element, setting its width to 50px.

Changes

File(s) Change Summary
src/.../MainMenuBuilder.php
src/.../menu.html.twig
Introduced new administration submenu functionality. In MainMenuBuilder.php, added the private method addAdministrationSubMenu to include child submenu items with icons and metadata. In the Twig template, updated the anchor classes and added conditional logic to render a logo (or an external link icon) based on the item's extra attributes.
src/.../_navbar.scss Added new CSS class .navbar-plus-badge with a width of 50px.

Sequence Diagram(s)

sequenceDiagram
    participant Client as UI Request
    participant MMB as MainMenuBuilder
    participant Menu as MenuStructure
    Client->>MMB: createMenu()
    MMB->>Menu: Build base menu
    MMB->>MMB: addAdministrationSubMenu(Menu)
    MMB->>Menu: Append Administration submenu<br/>with child items and metadata
    Menu-->>MMB: Menu updated
    MMB-->>Client: Return complete menu
Loading
sequenceDiagram
    participant Template as Twig Template
    participant Logic as Conditional Checker
    Template->>Logic: Check if plus_logo exists
    alt plus_logo exists
        Logic-->>Template: Render Sylius Plus logo image
    else plus_logo absent
        Template->>Logic: Check if target == "_blank"
        alt target is _blank
            Logic-->>Template: Render external link icon
        else
            Logic-->>Template: Render plain label
        end
    end
    Template-->>User: Rendered dropdown item
Loading

Poem

I’m a bunny who hops through lines of code,
Adding admin menus in a joyful mode.
With new methods and CSS so neat,
My whiskers twitch with every feat.
A logo or icon, the choice I cheer,
CodeRabbit leaps in springtime cheer!
🐰✨


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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@PiotrTulacz PiotrTulacz force-pushed the SYL-4312/Plus-features-clickbaits branch from 9b6c6ad to d875964 Compare April 3, 2025 11:15
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands:

  • 🚀 /bns:deploy to redeploy the environment

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 (1)
src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php (1)

397-417: Improve consistency in menu item naming convention

The implementation of the Administration submenu has some inconsistencies with the established naming patterns:

  1. The submenu ID addAdministration_support uses mixed conventions (camelCase with underscore) and includes an "add" prefix unlike other menu items
  2. The child item name Roles is capitalized, while other child items use lowercase

For better consistency with the rest of the codebase, consider these changes:

 private function addAdministrationSubMenu(ItemInterface $menu): void
 {
     $configuration = $menu
-        ->addChild('addAdministration_support')
+        ->addChild('administration_submenu')
         ->setLabel('sylius.ui.administration')
         ->setLabelAttribute('icon', 'tabler:lock')
     ;

     $sylius_plus = $configuration
-        ->addChild('Roles')
+        ->addChild('roles')
         ->setUri('https://sylius.com/plus/')
         ->setLinkAttribute('target', '_blank')
         ->setLabel('sylius.ui.roles')
         ->setLabelAttribute('icon', 'tabler:plus')
     ;

     $sylius_plus
         ->setExtra('plus_logo', '/sylius-plus-sidebar.svg')
         ->setExtra('safe_label', true)
     ;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 47c8c92 and d875964.

⛔ Files ignored due to path filters (1)
  • src/Sylius/Bundle/AdminBundle/Resources/assets/images/sylius-plus-sidebar.svg is excluded by !**/*.svg
📒 Files selected for processing (4)
  • src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php (2 hunks)
  • src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js (1 hunks)
  • src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_navbar.scss (1 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: End-to-end tests (MySQL) / Non-JS, PHP 8.3, Symfony ^7.1 (test_cached), MySQL 8.4, Twig ^3.3
  • GitHub Check: End-to-end tests (MySQL) / Non-JS, PHP 8.2, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
  • GitHub Check: End-to-end tests (MySQL) / JS with Panther, PHP 8.3, Symfony ^7.1 (test_cached), MySQL 8.4, Twig ^3.3
  • GitHub Check: End-to-end tests (MySQL) / JS with Panther, PHP 8.2, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
  • GitHub Check: End-to-end tests (MySQL) / JS with Chromedriver, PHP 8.3, Symfony ^7.1 (test_cached), MySQL 8.4, Twig ^3.3
  • GitHub Check: End-to-end tests (MySQL) / JS with Chromedriver, PHP 8.2, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
  • GitHub Check: End-to-end tests (PostgreSQL) / Non-JS, PHP 8.3, Symfony ^7.1, PostgreSQL 16.4
  • GitHub Check: End-to-end tests (PostgreSQL) / Non-JS, PHP 8.2, Symfony ^6.4, PostgreSQL 15.8
  • GitHub Check: Frontend / NodeJS 20.x
  • GitHub Check: End-to-end tests (MariaDB) / Non-JS, PHP 8.3, Symfony ^7.1, MariaDB 11.4.3, State Machine Adapter winzou_state_machine
  • GitHub Check: End-to-end tests (MariaDB) / Non-JS, PHP 8.3, Symfony ^7.1, MariaDB 11.4.3, State Machine Adapter symfony_workflow
  • GitHub Check: End-to-end tests (MariaDB) / Non-JS, PHP 8.2, Symfony ^6.4, MariaDB 10.11.9, State Machine Adapter symfony_workflow
  • GitHub Check: Packages / PHP 8.3, Symfony ^7.1
  • GitHub Check: Packages / PHP 8.2, Symfony ^6.4
🔇 Additional comments (4)
src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js (1)

29-29: Looks good: Added import for Sylius Plus logo

The addition of the Sylius Plus sidebar SVG import is appropriate for the objectives of this PR, which aims to enhance the admin UI by displaying the Sylius Plus logo in the navigation.

src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_navbar.scss (1)

29-31: Looks good: New CSS class for the Plus badge

The new CSS class .navbar-plus-badge with a fixed width of 50px is appropriate for consistently sizing the Sylius Plus logo in the navigation menu.

src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php (1)

44-44: Looks good: Integration of the new submenu

The invocation of the new method in the menu creation chain is appropriate and follows the existing pattern.

src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig (1)

92-98:

Details

✅ Verification successful

Looks good: Enhanced dropdown item with conditional logo rendering

The changes to the template are well-implemented:

  1. The added Bootstrap utility classes improve the layout
  2. The conditional rendering of the Plus logo is implemented correctly
  3. Backward compatibility is maintained with the existing external link icon display

🌐 Web query:

What are Bootstrap's justify-content-lg-between and gap-2 utility classes used for?

💡 Result:

Bootstrap's justify-content-lg-between and gap-2 are utility classes for controlling layout in responsive designs:

justify-content-lg-between

This flexbox utility:

  • Applies justify-content: space-between only on large screens (≥ 992px) [4][10]
  • Distributes flex items with:
    • First item at container start
    • Last item at container end
    • Equal spacing between items [1][10]
  • Becomes active at breakpoint lg while using default alignment on smaller screens [3][7]

Example usage:

<div class="d-flex justify-content-lg-between">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</div>

gap-2

This spacing utility:

  • Adds 0.5rem gap between grid/flex items
    • (Based on Bootstrap's spacer value where $spacer = 1rem) [2][5][6]
  • Applies to both horizontal and vertical spacing
  • Works with both CSS Grid (display: grid) and Flexbox layouts [6]
<div class="d-flex gap-2">
  <div>Item A</div>
  <div>Item B</div>
</div>

Combined Use Case

When used together:

<div class="d-flex justify-content-lg-between gap-2">
  <div>Left item</div>
  <div>Middle item</div>
  <div>Right item</div>
</div>

This creates:

  • Large screens: Items spread edge-to-edge with equal spacing between them
  • Smaller screens: Default alignment (usually left) with consistent 0.5rem gaps
  • Responsive spacing maintained across all screen sizes [6][9]

Key benefits include eliminating manual margin calculations and ensuring consistent spacing while maintaining responsive layout control [2][5]. The gap utility is particularly useful in modern grid/flex layouts where direct child margins can cause unintended overflow issues [6].

Citations:


Approval: Enhanced Dropdown Responsiveness and Logo Rendering Verified

The updated template looks solid:

  • The use of Bootstrap's justify-content-lg-between correctly applies space-between layout on large screens, ensuring items are spread out appropriately.
  • The gap-2 class reliably provides a consistent 0.5rem gap between elements.
  • The conditional rendering of the Plus logo (or external link icon for _blank targets) is implemented correctly, maintaining backward compatibility.

@PiotrTulacz PiotrTulacz force-pushed the SYL-4312/Plus-features-clickbaits branch from d875964 to 84bc1cd Compare April 3, 2025 11:50
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d875964 and 74f1b0e.

📒 Files selected for processing (2)
  • src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php (2 hunks)
  • src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig
🔇 Additional comments (3)
src/Sylius/Bundle/AdminBundle/Menu/MainMenuBuilder.php (3)

44-44: New menu call integration looks good

The integration of the new Administration submenu into the main menu structure is consistent with how other submenus are added.


397-417: Verify the purpose of this submenu and potential duplication

This administration submenu links to the same URL as the "sylius_plus" item in the "Official Support" submenu. Both point to "https://sylius.com/plus/", which may cause confusion for users.

Consider either:

  1. Adding different menu items to the administration submenu that are actually related to administration
  2. Removing this new submenu if it's intended to simply provide another way to access Sylius Plus

Please check if this is intentional duplication or if the new submenu should contain different administrative functionality.


413-416:

Details

✅ Verification successful

Verify SVG path and review usage

The code sets plus_logo to /sylius-plus-sidebar.svg, but this needs to be confirmed:

  1. Does this SVG file exist at the specified path?
  2. Is the template designed to handle the plus_logo extra parameter?

🏁 Script executed:

#!/bin/bash
# Check if the SVG file exists
fd -t f "sylius-plus-sidebar.svg"

# Check if any template is using the "plus_logo" extra parameter
rg "plus_logo" --type=twig -A 5 -B 5

Length of output: 2176


SVG resource verified and template usage confirmed.

  • The SVG file exists at src/Sylius/Bundle/AdminBundle/Resources/assets/images/sylius-plus-sidebar.svg.
  • The Twig template (src/Sylius/Bundle/AdminBundle/templates/shared/crud/common/sidebar/menu/menu.html.twig) correctly checks for plus_logo and renders it when available.

@PiotrTulacz PiotrTulacz force-pushed the SYL-4312/Plus-features-clickbaits branch 2 times, most recently from c6c41e5 to 84bc1cd Compare April 3, 2025 12:20
@PiotrTulacz PiotrTulacz changed the base branch from 2.1 to 2.0 April 4, 2025 06:57
@PiotrTulacz PiotrTulacz force-pushed the SYL-4312/Plus-features-clickbaits branch 2 times, most recently from 01b1543 to a3abc51 Compare April 8, 2025 10:31
@PiotrTulacz PiotrTulacz force-pushed the SYL-4312/Plus-features-clickbaits branch from 2393e7b to d86ab9d Compare April 30, 2025 19:17
@PiotrTulacz PiotrTulacz force-pushed the SYL-4312/Plus-features-clickbaits branch from d86ab9d to 82624da Compare May 5, 2025 11:01
@GSadee GSadee merged commit ee2a9f2 into Sylius:2.0 May 6, 2025
27 checks passed
This was referenced May 6, 2025
@GSadee GSadee mentioned this pull request May 6, 2025
GSadee added a commit that referenced this pull request May 6, 2025
Updated plus utm link

Fixes #17827
This was referenced May 7, 2025
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants