-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
FEAT: Open shop preview link and nessecary links in UserDropdownComponent in new Browser Tab #18341
Description
Description
Currently, when you click on the shop preview link, or the documentation or slack join link in the user component dropdown, the links does open in the same window. But since those links are external (out of the admin page) they should open in a new browser window.
Example
Shop Preview link
To archieve this functionality there, the shop_preview.html.twig can be adjusted by only adding the target="_blank" attribute where the <a> tag link is generated.
User Dropdown Component
My idea was to adjust the UserDropdownComponent.php in the AdminBundle and add the new target property value for the slack link, documentation link, and github issue link:
[
'title' => 'sylius.ui.report_an_issue',
'url' => 'https://github.com/Sylius/Sylius/issues',
'class' => 'small text-muted',
'target' => '_blank'
],Then, in the dropdown.html.twig helper in the AdminBundle the target="_blank should only be set, when the item.target is actually _blank. To make sure that other places where this component is used nothing gets broken:
{% set item = {
...,
target: null,
}|merge(item) %}
<a class="dropdown-item{{ item.class ? extra_class }}"
href="{{ item.url }}" {{ sylius_test_html_attribute('user-dropdown-item', item.title|trans({}, null, 'en_US')) }}
{% for attr, value in item.attributes %}{{ attr }}="{{ value }}" {% endfor %}
{% if item.target == '_blank' %}target="{{ item.target }}" rel="noopener"{% endif %}
>
{{ item.icon ? ux_icon(item.icon, {'class': 'icon dropdown-item-icon ' ~ extra_class }) }}
{{ item.title|trans }}
</a>