-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Init Admin ui package #20
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,15 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
php: [ "8.1", "8.2", "8.3" ] | ||
postgres: ["14.6"] | ||
symfony: [ "^6.4", "^7.0" ] | ||
exclude: | ||
- php: "8.1" | ||
symfony: "^7.0" | ||
name: "PHP ${{ matrix.php }} / Symfony ${{ matrix.symfony }}" | ||
env: | ||
APP_ENV: test | ||
DATABASE_URL: "pgsql://postgres:[email protected]/sylius_stack?charset=utf8&serverVersion=${{ matrix.postgres }}" | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v3 | ||
|
@@ -32,6 +34,15 @@ jobs: | |
tools: symfony | ||
coverage: none | ||
|
||
- name: Shutdown default MySQL | ||
run: sudo service mysql stop | ||
|
||
- name: Setup PostgreSQL | ||
uses: harmon758/postgresql-action@v1 | ||
with: | ||
postgresql version: "${{ matrix.postgres }}" | ||
postgresql password: "postgres" | ||
|
||
- name: "Restrict packages' versions" | ||
run: | | ||
composer global config --no-plugins allow-plugins.symfony/flex true | ||
|
@@ -70,6 +81,11 @@ jobs: | |
- name: Run PHPStan | ||
run: vendor/bin/phpstan analyse | ||
|
||
- name: Create Testing database | ||
run: | | ||
bin/console doctrine:database:create | ||
bin/console doctrine:schema:create | ||
- name: Run PHPUnit | ||
run: vendor/bin/phpunit | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?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 App\Grid; | ||
|
||
use App\Entity\Book; | ||
use Sylius\Bundle\GridBundle\Builder\Action\CreateAction; | ||
use Sylius\Bundle\GridBundle\Builder\Action\DeleteAction; | ||
use Sylius\Bundle\GridBundle\Builder\Action\ShowAction; | ||
use Sylius\Bundle\GridBundle\Builder\Action\UpdateAction; | ||
use Sylius\Bundle\GridBundle\Builder\ActionGroup\BulkActionGroup; | ||
use Sylius\Bundle\GridBundle\Builder\ActionGroup\ItemActionGroup; | ||
use Sylius\Bundle\GridBundle\Builder\ActionGroup\MainActionGroup; | ||
use Sylius\Bundle\GridBundle\Builder\Field\StringField; | ||
use Sylius\Bundle\GridBundle\Builder\Filter\StringFilter; | ||
use Sylius\Bundle\GridBundle\Builder\GridBuilderInterface; | ||
use Sylius\Bundle\GridBundle\Grid\AbstractGrid; | ||
use Sylius\Bundle\GridBundle\Grid\ResourceAwareGridInterface; | ||
|
||
final class BookGrid extends AbstractGrid implements ResourceAwareGridInterface | ||
{ | ||
public static function getName(): string | ||
{ | ||
return 'app_book'; | ||
} | ||
|
||
public function buildGrid(GridBuilderInterface $gridBuilder): void | ||
{ | ||
$gridBuilder | ||
->orderBy('title') | ||
->addFilter( | ||
StringFilter::create('search', ['title', 'authorName']) | ||
->setLabel('sylius.ui.search'), | ||
) | ||
->addField( | ||
StringField::create('title') | ||
->setLabel('Title') | ||
->setSortable(true), | ||
) | ||
->addField( | ||
StringField::create('authorName') | ||
->setLabel('Author Name') | ||
->setSortable(true), | ||
) | ||
->addActionGroup( | ||
MainActionGroup::create( | ||
CreateAction::create(), | ||
), | ||
) | ||
->addActionGroup( | ||
ItemActionGroup::create( | ||
// ShowAction::create(), | ||
UpdateAction::create(), | ||
DeleteAction::create(), | ||
), | ||
) | ||
->addActionGroup( | ||
BulkActionGroup::create( | ||
DeleteAction::create(), | ||
), | ||
) | ||
; | ||
} | ||
|
||
public function getResourceClass(): string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand it comes from grid configuration, but conceptually it's strange it's not a static method. --- public function getResourceClass(): string
+++ public static function getResourceClass(): string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the first iteration of the grid, it was a static method, but we remove that static in order to use the class model parameter from Sylius. in this example: |
||
{ | ||
return Book::class; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sylius_admin_ui: | ||
routing: | ||
#dashboard_path: '/admin' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "sylius/admin-ui", | ||
"type": "library", | ||
"require": { | ||
"php": "^8.1", | ||
"knplabs/knp-menu-bundle": "^3.0", | ||
"sylius/twig-hooks": "^0.2", | ||
"symfony/http-kernel": "^6.4 || ^7.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Sylius\\AdminUi\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\Sylius\\AdminUi\\": "tests/" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?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\AdminUi\Knp\Menu\MenuBuilder; | ||
use Sylius\AdminUi\Knp\Menu\MenuBuilderInterface; | ||
use Sylius\AdminUi\TwigHooks\Hookable\Metadata\RoutingHookableMetadataFactory; | ||
|
||
return function (ContainerConfigurator $configurator): void { | ||
$services = $configurator->services(); | ||
|
||
$services->set('sylius_admin_ui.knp.menu_builder', MenuBuilder::class) | ||
->args([service('knp_menu.factory')]) | ||
->tag(name: 'knp_menu.menu_builder', attributes: ['method' => 'createMenu', 'alias' => 'sylius_admin_ui.menu.sidebar']) | ||
; | ||
$services->alias(MenuBuilderInterface::class, 'sylius_admin_ui.knp.menu_builder'); | ||
|
||
$services->set('sylius_admin_ui.twig_hooks.factory.hookable_metadata', RoutingHookableMetadataFactory::class) | ||
->decorate('twig_hooks.factory.hookable_metadata') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there plans to fix namespace for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have to discuss about it in the core team channel, but I agree, it's a bit risky to have no sylius prefix. |
||
->args([ | ||
service('.inner'), | ||
param('sylius_admin_ui.routing'), | ||
]) | ||
; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll have to build a default show template as the internal core team did in the 2.0 branch.