-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/BootstrapAdminUi/config/app/twig_hooks/layout/navbar.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
return static function (ContainerConfigurator $container): void { | ||
$container->extension('sylius_twig_hooks', [ | ||
'hooks' => [ | ||
'sylius_admin.common.component.navbar' => [ | ||
'menu' => [ | ||
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/navbar/menu.html.twig', | ||
], | ||
'items' => [ | ||
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/navbar/items.html.twig', | ||
], | ||
], | ||
|
||
'sylius_admin.common.component.navbar.items' => [ | ||
'user' => [ | ||
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/navbar/items/user.html.twig', | ||
], | ||
], | ||
], | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
return function (ContainerConfigurator $configurator): void { | ||
$configurator->import('./services/**/**.php'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
use Sylius\BootstrapAdminUi\Twig\Component\UserDropdownComponent; | ||
|
||
return function (ContainerConfigurator $configurator): void { | ||
$services = $configurator->services(); | ||
|
||
$services->set('sylius_bootstrap_admin_ui.twig.component.navbar.user_dropdown', UserDropdownComponent::class) | ||
->public() | ||
->args([ | ||
param('sylius_admin_ui.routing'), | ||
service('security.token_storage'), | ||
service('router'), | ||
]) | ||
->tag('twig.component', [ | ||
'key' => 'sylius_bootstrap_admin_ui:navbar:user_dropdown', | ||
'template' => '@SyliusBootstrapAdminUi/shared/components/navbar/user.html.twig', | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/BootstrapAdminUi/src/Twig/Component/UserDropdownComponent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\BootstrapAdminUi\Twig\Component; | ||
|
||
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
use Symfony\UX\TwigComponent\Attribute\ExposeInTemplate; | ||
|
||
#[AsTwigComponent( | ||
name: 'sylius_bootstrap_admin_ui:navbar:user_dropdown', | ||
template: '@SyliusBootstrapAdminUi/shared/components/navbar/user.html.twig', | ||
)] | ||
class UserDropdownComponent | ||
{ | ||
public function __construct( | ||
private readonly array $routing, | ||
private TokenStorageInterface $tokenStorage, | ||
private RouterInterface $router, | ||
) { | ||
} | ||
|
||
#[ExposeInTemplate(name: 'user')] | ||
public function getUser(): ?UserInterface | ||
{ | ||
return $this->tokenStorage->getToken()?->getUser(); | ||
} | ||
|
||
/** | ||
* @return array<array-key, array{title?: string, url?: string, icon?: string, type?: string, class?: string}> | ||
*/ | ||
#[ExposeInTemplate(name: 'menu_items')] | ||
public function getMenuItems(): array | ||
{ | ||
return [ | ||
[ | ||
'title' => 'sylius.ui.logout', | ||
'url' => $this->routing['logout_path'] ?? $this->router->generate('sylius_admin_ui_logout'), | ||
'icon' => 'logout', | ||
], | ||
]; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/BootstrapAdminUi/templates/shared/components/navbar/user.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% import '@SyliusBootstrapAdminUi/shared/helper/avatar.html.twig' as avatar %} | ||
{% import '@SyliusBootstrapAdminUi/shared/helper/dropdown.html.twig' as dropdown %} | ||
|
||
{% if app.user %} | ||
{% set dropdown_trigger %} | ||
<div class="d-flex lh-1 text-reset p-0 cursor-pointer"> | ||
<div> | ||
{{ avatar.small() }} | ||
</div> | ||
<div class="d-none d-xl-block ps-2"> | ||
<div class="mb-1 small text-muted">{{ 'sylius.ui.hello'|trans }}</div> | ||
<div>{{ user.userIdentifier }}</div> | ||
</div> | ||
</div> | ||
{% endset %} | ||
|
||
{{ dropdown.list({ customTrigger: dropdown_trigger, direction: 'down-end' }, menu_items) }} | ||
{% endif %} |
3 changes: 3 additions & 0 deletions
3
src/BootstrapAdminUi/templates/shared/crud/common/navbar/items.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="nav align-items-center gap-3"> | ||
{% hook 'items' %} | ||
</div> |
3 changes: 3 additions & 0 deletions
3
src/BootstrapAdminUi/templates/shared/crud/common/navbar/items/user.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="nav-item"> | ||
{{ component('sylius_bootstrap_admin_ui:navbar:user_dropdown') }} | ||
</div> |
3 changes: 3 additions & 0 deletions
3
src/BootstrapAdminUi/templates/shared/crud/common/navbar/menu.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div id="navbar-menu"> | ||
{% hook 'menu' %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters