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/config/routes.php b/src/AdminUi/config/routes.php index a02e4abe..18f91d45 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 { @@ -22,5 +23,13 @@ $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..b7597092 --- /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/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/tests/Functional/BookTest.php b/tests/Functional/BookTest.php index 2b329a58..129607b9 100644 --- a/tests/Functional/BookTest.php +++ b/tests/Functional/BookTest.php @@ -7,7 +7,6 @@ use App\Entity\Book; use App\Factory\BookFactory; use App\Factory\UserFactory; -use App\Story\DefaultUsersStory; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Response; diff --git a/tests/Functional/DashboardTest.php b/tests/Functional/DashboardTest.php new file mode 100644 index 00000000..f4e1d6d4 --- /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'); + } +}