diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 4ca1616..6d4a938 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -19,7 +19,7 @@ jobs: - 8.2 - 8.3 symfony: - - '6.4.*' + - '7.1.*' env: APP_ENV: test steps: diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index 33dc57f..476b6a1 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -19,13 +19,11 @@ jobs: - 8.2 - 8.3 sylius: - - 1.12.0 - - 1.13.0 - - 1.14.0 + - 2.0.0 symfony: - - 6.4 + - 7.1 node: - - 14.x + - 20.x env: APP_ENV: test package-name: synolia/sylius-maintenance-plugin diff --git a/Makefile b/Makefile index 52e22ea..69339c6 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,9 @@ CONSOLE=cd ${TEST_DIRECTORY} && php bin/console -e test COMPOSER=cd ${TEST_DIRECTORY} && composer YARN=cd ${TEST_DIRECTORY} && yarn -SYLIUS_VERSION=1.14.0 -SYMFONY_VERSION=6.4 -PHP_VERSION=8.2 +SYLIUS_VERSION=2.0 +SYMFONY_VERSION=7.1 +PHP_VERSION=8.3 PLUGIN_NAME=synolia/sylius-maintenance-plugin ### diff --git a/README.md b/README.md index 2c7a7e8..5a91833 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ | | Version | |:-------|:--------| | PHP | ^8.2 | -| Sylius | ^1.12 | +| Sylius | ~2.0 | ## Installation diff --git a/composer.json b/composer.json index 14aadc5..e8eab61 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": "^8.2", "jaybizzle/crawler-detect": "^1.2", - "sylius/sylius": "^1.12", + "sylius/sylius": "~2.0.0", "webmozart/assert": "^1.11" }, "require-dev": { diff --git a/config/twig_hooks/admin/maintenance/update.yaml b/config/twig_hooks/admin/maintenance/update.yaml new file mode 100644 index 0000000..d2d46fc --- /dev/null +++ b/config/twig_hooks/admin/maintenance/update.yaml @@ -0,0 +1,52 @@ +sylius_twig_hooks: + hooks: + 'synolia.sylius_admin.maintenance': + sidebar: + template: '@SyliusAdmin/shared/crud/common/sidebar.html.twig' + priority: 200 + navbar: + template: '@SyliusAdmin/shared/crud/common/navbar.html.twig' + priority: 100 + content: + template: '@SyliusAdmin/shared/crud/common/content.html.twig' + priority: 0 + + 'synolia.sylius_admin.maintenance.content': + flashes: + template: '@SyliusAdmin/shared/crud/common/content/flashes.html.twig' + priority: 400 + header: + template: '@SyliusAdmin/shared/crud/common/content/header.html.twig' + priority: 300 + form: + template: '@SynoliaSyliusMaintenancePlugin/admin/maintenance/content/form.html.twig' + priority: 200 + footer: + template: '@SyliusAdmin/shared/crud/common/content/footer.html.twig' + priority: 100 + + 'synolia.sylius_admin.maintenance.content.header': + breadcrumbs: + template: '@SynoliaSyliusMaintenancePlugin/admin/maintenance/content/header/breadcrumbs.html.twig' + priority: 100 + title_block: + template: '@SyliusAdmin/shared/crud/common/content/header/title_block.html.twig' + priority: 0 + + 'synolia.sylius_admin.maintenance.content.header.title_block': + title: + template: '@SyliusAdmin/shared/crud/common/content/header/title_block/title.html.twig' + configuration: + title: 'maintenance.ui.title' + priority: 100 + actions: + template: '@SyliusAdmin/shared/crud/update/content/header/title_block/actions.html.twig' + priority: 0 + + 'synolia.sylius_admin.maintenance.content.header.title_block.actions': + cancel: + template: '@SynoliaSyliusMaintenancePlugin/admin/maintenance/content/header/title_block/actions/cancel.html.twig' + priority: 100 + update: + template: '@SyliusAdmin/shared/crud/common/content/header/title_block/actions/update.html.twig' + priority: 0 \ No newline at end of file diff --git a/images/maintenance.png b/images/maintenance.png index a9ae8c2..92a11c9 100644 Binary files a/images/maintenance.png and b/images/maintenance.png differ diff --git a/templates/admin/maintenance/content/form.html.twig b/templates/admin/maintenance/content/form.html.twig new file mode 100644 index 0000000..f6bd10f --- /dev/null +++ b/templates/admin/maintenance/content/form.html.twig @@ -0,0 +1,57 @@ +{% from '@SyliusAdmin/shared/helper/button.html.twig' import default as btn %} + +{% if form is not defined %} + {% set form = hookable_metadata.context.form %} +{% endif %} + +{% form_theme form '@SyliusAdmin/shared/form_theme.html.twig' %} + +
+ {{ form_start(form, {'attr': {'novalidate': 'novalidate', 'id': form.vars.id}}) }} +
+
+
+
+
+
+ {{ form_row(form.enabled) }} +
+
+ {% if form.channels is defined %} + {{ form_row(form.channels) }} + {% endif %} +
+
+ {{ form_row(form.ipAddresses) }} +
+
+
+ + {{ btn({ + class: 'btn-secondary', + url: path('sylius_admin_maintenance_token_storage'), + text: 'maintenance.ui.form.token_storage.button'|trans + }) }} +
+
+
+ {{ form_row(form.customMessage) }} +
+
+ {{ form_row(form.startDate) }} +
+
+ {{ form_row(form.endDate) }} +
+
+ {{ form_row(form.allowBots) }} +
+
+
+
+
+
+ {{ form_end(form) }} +
diff --git a/templates/admin/maintenance/content/header/breadcrumbs.html.twig b/templates/admin/maintenance/content/header/breadcrumbs.html.twig new file mode 100644 index 0000000..a1eca98 --- /dev/null +++ b/templates/admin/maintenance/content/header/breadcrumbs.html.twig @@ -0,0 +1,7 @@ +{% from '@SyliusAdmin/shared/helper/breadcrumbs.html.twig' import breadcrumbs %} + +{{ breadcrumbs([ + { name: 'sylius.ui.dashboard', url: path('sylius_admin_dashboard'), active: false }, + { name: 'maintenance.ui.title'|trans, active: false}, + { name: 'sylius.ui.edit'|trans, active: false } +]) }} diff --git a/templates/admin/maintenance/content/header/title_block/actions/cancel.html.twig b/templates/admin/maintenance/content/header/title_block/actions/cancel.html.twig new file mode 100644 index 0000000..67fbc94 --- /dev/null +++ b/templates/admin/maintenance/content/header/title_block/actions/cancel.html.twig @@ -0,0 +1,5 @@ +{% import '@SyliusAdmin/shared/helper/button.html.twig' as button %} + +{% set index_url = sylius_generate_redirect_path(app.request.headers.get('referer')) %} + +{{ button.cancel(sylius_test_form_attribute('cancel-changes-button')|merge({ text: 'sylius.ui.cancel'|trans, url: index_url, class: 'btn' })) }} diff --git a/templates/admin/maintenance/layout.html.twig b/templates/admin/maintenance/layout.html.twig new file mode 100644 index 0000000..0c18d03 --- /dev/null +++ b/templates/admin/maintenance/layout.html.twig @@ -0,0 +1,11 @@ +{% extends '@SyliusAdmin/shared/layout/base.html.twig' %} + +{% block title %} + {{ 'maintenance.ui.title'|trans }} +{% endblock %} + +{% block body %} +
+ {% hook 'synolia.sylius_admin.maintenance' %} +
+{% endblock %} diff --git a/tests/PHPUnit/AssertTrait.php b/tests/PHPUnit/AssertTrait.php index 43c3e2d..c521e33 100644 --- a/tests/PHPUnit/AssertTrait.php +++ b/tests/PHPUnit/AssertTrait.php @@ -10,7 +10,7 @@ protected function assertSiteIsUp(): void { self::assertResponseIsSuccessful(); self::assertPageTitleContains('Fashion Web Store'); - self::assertSelectorTextContains('#footer', 'Powered by Sylius'); + self::assertSelectorTextContains('footer', 'Powered by Sylius'); } protected function assertSiteIsInMaintenance(string $message = 'maintenance.ui.message'): void