diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d74324c0..e9ad24be 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -102,6 +102,9 @@ jobs: - name: Run PHPUnit (Admin Ui) run: (cd src/AdminUi/ && vendor/bin/phpunit) + - name: Clean package (Admin Ui) + run: (cd src/AdminUi/ && rm -rf vendor) + - name: "Restrict packages' versions (Bootstrap Admin Ui)" run: | (cd src/BootstrapAdminUi/ && composer global config --no-plugins allow-plugins.symfony/flex true) @@ -115,6 +118,9 @@ jobs: - name: Run PHPUnit (Bootstrap Admin Ui) run: (cd src/BootstrapAdminUi/ && vendor/bin/phpunit) + - name: Clean package (Bootstrap Admin Ui) + run: (cd src/BootstrapAdminUi/ && rm -rf vendor) + - name: "Restrict packages' versions (Twig Hooks)" run: | (cd src/TwigHooks/ && composer global config --no-plugins allow-plugins.symfony/flex true) @@ -128,6 +134,9 @@ jobs: - name: Run PHPUnit (Twig Hooks) run: (cd src/TwigHooks/ && vendor/bin/phpunit) + - name: Clean package (Twig Hooks) + run: (cd src/TwigHooks/ && rm -rf vendor) + - name: "Restrict packages' versions (Twig Extra)" run: | (cd src/TwigExtra/ && composer global config --no-plugins allow-plugins.symfony/flex true) @@ -139,7 +148,12 @@ jobs: run: (cd src/TwigExtra/ && composer update --no-interaction --no-scripts) - name: Run PHPUnit (Twig Extra) - run: (cd src/TwigExtra/ && vendor/bin/phpunit) + run: | + (cd src/TwigExtra/ && vendor/bin/phpunit) + (cd src/TwigExtra/ && rm -rf vendor) + + - name: Clean package (Twig TwigExtra) + run: (cd src/TwigExtra/ && rm -rf vendor) - name: "Restrict packages' versions (Ui Translations)" run: | @@ -154,3 +168,6 @@ jobs: - name: Run PHPUnit (Ui Translations) run: (cd src/UiTranslations/ && vendor/bin/phpunit) + - name: Clean package (Ui Translations) + run: (cd src/UiTranslations/ && rm -rf vendor) + diff --git a/app/Menu/AdminMenuBuilder.php b/app/Menu/AdminMenuBuilder.php index 9c6a09a3..eb583618 100644 --- a/app/Menu/AdminMenuBuilder.php +++ b/app/Menu/AdminMenuBuilder.php @@ -29,7 +29,9 @@ public function createMenu(array $options): ItemInterface $menu = $this->menuBuilder->createMenu($options); $menu - ->addChild('dashboard') + ->addChild('dashboard', [ + 'route' => 'sylius_admin_ui_dashboard', + ]) ->setLabel('sylius.ui.dashboard') ->setLabelAttribute('icon', 'dashboard') ; diff --git a/src/AdminUi/composer.json b/src/AdminUi/composer.json index b04766e5..8f3dad93 100644 --- a/src/AdminUi/composer.json +++ b/src/AdminUi/composer.json @@ -4,7 +4,7 @@ "require": { "php": "^8.1", "knplabs/knp-menu-bundle": "^3.0", - "sylius/twig-hooks": "^0.3 || dev-main", + "sylius/twig-hooks": "dev-main", "symfony/http-kernel": "^6.4 || ^7.0", "symfony/security-bundle": "^6.4 || ^7.0", "symfony/security-http": "^6.4 || ^7.0", @@ -39,7 +39,7 @@ "repositories": [ { "type": "path", - "url": "../*/*" + "url": "../*" } ], "extra": { diff --git a/src/AdminUi/config/routes.php b/src/AdminUi/config/routes.php index a02e4abe..035696d2 100644 --- a/src/AdminUi/config/routes.php +++ b/src/AdminUi/config/routes.php @@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; +use Symfony\Bundle\FrameworkBundle\Controller\TemplateController; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; return function (RoutingConfigurator $routes): void { @@ -21,6 +22,15 @@ ; $routes->add('sylius_admin_ui_login_check', '/login_check'); + $routes->add('sylius_admin_ui_logout', '/logout') - ->methods(['GET']); + ->methods(['GET']) + ; + + $routes->add('sylius_admin_ui_dashboard', '/') + ->controller(TemplateController::class) + ->defaults([ + 'template' => '@SyliusAdminUi/dashboard/index.html.twig', + ]) + ; }; diff --git a/src/AdminUi/templates/dashboard/index.html.twig b/src/AdminUi/templates/dashboard/index.html.twig new file mode 100644 index 00000000..15edbbe5 --- /dev/null +++ b/src/AdminUi/templates/dashboard/index.html.twig @@ -0,0 +1,9 @@ +{% extends '@SyliusAdminUi/base.html.twig' %} + +{% block title %} + {{ 'sylius.ui.dashboard'|trans }} {{ parent() }} +{% endblock %} + +{% block body %} + {% hook ['sylius_admin.dashboard.index', 'sylius_admin.common.index'] %} +{% endblock %} diff --git a/src/BootstrapAdminUi/composer.json b/src/BootstrapAdminUi/composer.json index b736e21a..7395cb7b 100644 --- a/src/BootstrapAdminUi/composer.json +++ b/src/BootstrapAdminUi/composer.json @@ -8,7 +8,7 @@ "sylius/grid-bundle": "^1.13@alpha", "sylius/resource-bundle": "^1.11 || ^1.12@alpha", "sylius/twig-extra": "dev-main", - "sylius/twig-hooks": "^0.3 || dev-main", + "sylius/twig-hooks": "dev-main", "symfony/asset": "^6.4 || ^7.0", "symfony/http-kernel": "^6.4 || ^7.0", "symfony/ux-autocomplete": "^2.17", @@ -33,7 +33,6 @@ }, "autoload-dev": { "psr-4": { - "Sylius\\TwigHooks\\": "../TwigHooks/src/", "TestApplication\\Sylius\\BootstrapAdminUi\\": "tests/Functional/.application/src/", "Tests\\Sylius\\BootstrapAdminUi\\": "tests/" } @@ -47,7 +46,8 @@ "repositories": [ { "type": "path", - "url": "../*/*" + "url": "../*", + "canonical": true } ], "extra": { diff --git a/src/BootstrapAdminUi/config/app/twig_hooks/dashboard/index.php b/src/BootstrapAdminUi/config/app/twig_hooks/dashboard/index.php new file mode 100644 index 00000000..1c7450fb --- /dev/null +++ b/src/BootstrapAdminUi/config/app/twig_hooks/dashboard/index.php @@ -0,0 +1,63 @@ +extension('sylius_twig_hooks', [ + 'hooks' => [ + 'sylius_admin.dashboard.index' => [ + 'sidebar' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/sidebar.html.twig', + ], + 'navbar' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/navbar.html.twig', + ], + 'content' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content.html.twig', + ], + ], + + 'sylius_admin.dashboard.index.content' => [ + 'header' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header.html.twig', + ], + 'grid' => [ + 'enabled' => false, + ], + ], + + 'sylius_admin.dashboard.index.content.header' => [ + 'breadcrumbs' => [ + 'enabled' => false, + ], + 'title_block' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block.html.twig', + ], + ], + + 'sylius_admin.dashboard.index.content.header.title_block' => [ + 'title' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/title.html.twig', + 'configuration' => [ + 'title' => 'sylius.ui.dashboard', + 'sylius_test_html_attribute' => 'dashboard-header', + ], + ], + 'actions' => [ + 'enabled' => false, + ], + ], + ], + ]); +}; diff --git a/src/BootstrapAdminUi/templates/shared/crud/common/navbar.html.twig b/src/BootstrapAdminUi/templates/shared/crud/common/navbar.html.twig new file mode 100644 index 00000000..a83a22eb --- /dev/null +++ b/src/BootstrapAdminUi/templates/shared/crud/common/navbar.html.twig @@ -0,0 +1,5 @@ + diff --git a/src/BootstrapAdminUi/templates/shared/crud/common/sidebar/logo.html.twig b/src/BootstrapAdminUi/templates/shared/crud/common/sidebar/logo.html.twig index 30e7acb7..cc175cbe 100644 --- a/src/BootstrapAdminUi/templates/shared/crud/common/sidebar/logo.html.twig +++ b/src/BootstrapAdminUi/templates/shared/crud/common/sidebar/logo.html.twig @@ -1,4 +1,4 @@ -{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %} +{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default(path('sylius_admin_ui_dashboard')) %}

diff --git a/src/BootstrapAdminUi/templates/shared/crud/create/content/header/breadcrumbs.html.twig b/src/BootstrapAdminUi/templates/shared/crud/create/content/header/breadcrumbs.html.twig index 21372dcc..8284ceab 100644 --- a/src/BootstrapAdminUi/templates/shared/crud/create/content/header/breadcrumbs.html.twig +++ b/src/BootstrapAdminUi/templates/shared/crud/create/content/header/breadcrumbs.html.twig @@ -14,7 +14,7 @@ ) %} -{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %} +{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default(path('sylius_admin_ui_dashboard')) %} {{ breadcrumbs([ { name: 'sylius.ui.dashboard', url: dashboard_path, active: false }, diff --git a/src/BootstrapAdminUi/templates/shared/crud/index/content/header/breadcrumbs.html.twig b/src/BootstrapAdminUi/templates/shared/crud/index/content/header/breadcrumbs.html.twig index dc15931b..259c4f3c 100644 --- a/src/BootstrapAdminUi/templates/shared/crud/index/content/header/breadcrumbs.html.twig +++ b/src/BootstrapAdminUi/templates/shared/crud/index/content/header/breadcrumbs.html.twig @@ -9,7 +9,7 @@ {% set title = hookable_metadata.configuration.title %} {% endif %} -{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %} +{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default(path('sylius_admin_ui_dashboard')) %} {{ breadcrumbs([ { 'name': 'sylius.ui.dashboard', 'url': dashboard_path, 'active': false }, diff --git a/src/BootstrapAdminUi/templates/shared/crud/show/content/header/breadcrumbs.html.twig b/src/BootstrapAdminUi/templates/shared/crud/show/content/header/breadcrumbs.html.twig index 9b5a8d68..c1360668 100644 --- a/src/BootstrapAdminUi/templates/shared/crud/show/content/header/breadcrumbs.html.twig +++ b/src/BootstrapAdminUi/templates/shared/crud/show/content/header/breadcrumbs.html.twig @@ -28,7 +28,7 @@ {% set resource_show = { name: resource_show_name, active: true} %} {% endif %} -{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %} +{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default(path('sylius_admin_ui_dashboard')) %} {{ breadcrumbs([ { name: 'sylius.ui.dashboard', url: dashboard_path, active: false }, diff --git a/src/BootstrapAdminUi/templates/shared/crud/update/content/header/breadcrumbs.html.twig b/src/BootstrapAdminUi/templates/shared/crud/update/content/header/breadcrumbs.html.twig index e05fa6eb..3075fc2e 100644 --- a/src/BootstrapAdminUi/templates/shared/crud/update/content/header/breadcrumbs.html.twig +++ b/src/BootstrapAdminUi/templates/shared/crud/update/content/header/breadcrumbs.html.twig @@ -24,7 +24,7 @@ {% set resource_edit = { name: resource_edit_name, active: true} %} {% endif %} -{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %} +{% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default(path('sylius_admin_ui_dashboard')) %} {{ breadcrumbs([ { name: 'sylius.ui.dashboard', url: dashboard_path, active: false }, diff --git a/src/BootstrapAdminUi/tests/Functional/.application/config/bundles.php b/src/BootstrapAdminUi/tests/Functional/.application/config/bundles.php index 7791cd48..81974932 100644 --- a/src/BootstrapAdminUi/tests/Functional/.application/config/bundles.php +++ b/src/BootstrapAdminUi/tests/Functional/.application/config/bundles.php @@ -24,4 +24,5 @@ Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], Sylius\AdminUi\Symfony\SyliusAdminUiBundle::class => ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], ]; diff --git a/src/BootstrapAdminUi/tests/Functional/.application/config/packages/security.yaml b/src/BootstrapAdminUi/tests/Functional/.application/config/packages/security.yaml new file mode 100644 index 00000000..fbd7d5fa --- /dev/null +++ b/src/BootstrapAdminUi/tests/Functional/.application/config/packages/security.yaml @@ -0,0 +1,4 @@ +security: + firewalls: + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ diff --git a/src/BootstrapAdminUi/tests/Functional/.application/config/routes/sylius_admin_ui.yaml b/src/BootstrapAdminUi/tests/Functional/.application/config/routes/sylius_admin_ui.yaml new file mode 100644 index 00000000..00a7d5b6 --- /dev/null +++ b/src/BootstrapAdminUi/tests/Functional/.application/config/routes/sylius_admin_ui.yaml @@ -0,0 +1,4 @@ +sylius_admin_ui: + resource: '@SyliusAdminUiBundle/config/routes.php' + #resource: '../../../../../../AdminUi/config/routes.php' + prefix: /admin diff --git a/tests/Functional/DashboardTest.php b/tests/Functional/DashboardTest.php new file mode 100644 index 00000000..5b8f3a58 --- /dev/null +++ b/tests/Functional/DashboardTest.php @@ -0,0 +1,40 @@ +client = self::createClient(); + + $user = UserFactory::new() + ->admin() + ->create() + ; + + $this->client->loginUser($user->_real()); + } + + public function testDashboard(): void + { + $this->client->request('GET', '/admin/'); + + self::assertResponseIsSuccessful(); + + self::assertSelectorTextContains('h1.page-title', 'Dashboard'); + } +}