Skip to content

Commit 0663b87

Browse files
authored
2 parents 2379fe9 + ee2ae8a commit 0663b87

File tree

18 files changed

+138
-65
lines changed

18 files changed

+138
-65
lines changed

config/packages/sylius_twig_hooks.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,27 @@ sylius_twig_hooks:
1919

2020
'sylius_admin.book.show.content.header.title_block':
2121
title:
22-
template: '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/title.html.twig'
22+
template: '@SyliusBootstrapAdminUi/shared/crud/show/content/header/title_block/title.html.twig'
2323
configuration:
2424
title: '@=_context.book.getTitle()'
25+
icon: 'tabler:book'
26+
subheader: '@=_context.book.getAuthorName()'
27+
28+
'sylius_admin.conference.create.content.header.title_block':
29+
title:
30+
template: '@SyliusBootstrapAdminUi/shared/crud/create/content/header/title_block/title.html.twig'
31+
configuration:
32+
title: 'app.ui.new_conference'
33+
icon: 'tabler:plus'
34+
subheader: app.ui.managing_your_conferences
35+
36+
'sylius_admin.conference.update.content.header.title_block':
37+
title:
38+
template: '@SyliusBootstrapAdminUi/shared/crud/update/content/header/title_block/title.html.twig'
39+
configuration:
40+
title: app.ui.edit_conference
41+
icon: 'tabler:pencil'
42+
subheader: app.ui.managing_your_conferences
2543

2644
'sylius_admin.talk.create.content':
2745
form:

src/AdminUi/tests/Functional/.application/src/State/Provider/BookCollectionProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BookCollectionProvider implements ProviderInterface
2323
public function provide(Operation $operation, Context $context): array
2424
{
2525
return [
26-
new BookResource('shinning', 'Shinning'),
26+
new BookResource('the-shining', 'The Shining'),
2727
new BookResource('carrie', 'Carrie'),
2828
];
2929
}

src/AdminUi/tests/Functional/.application/src/State/Provider/BookItemProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ class BookItemProvider implements ProviderInterface
2222
{
2323
public function provide(Operation $operation, Context $context): BookResource
2424
{
25-
return new BookResource('shinning', 'Shinning');
25+
return new BookResource('the shining', 'The Shining');
2626
}
2727
}

src/AdminUi/tests/Functional/TemplatesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testIndexTemplate(): void
4040
self::assertResponseIsSuccessful();
4141
self::assertSelectorTextContains('[data-test-title]', 'Books');
4242
self::assertSelectorTextContains('[data-test-description]', 'List of books');
43-
self::assertSelectorTextContains('[data-test-book-name-shinning]', 'Shinning');
43+
self::assertSelectorTextContains('[data-test-book-name-the-shining]', 'The Shining');
4444
self::assertSelectorTextContains('[data-test-book-name-carrie]', 'Carrie');
4545
}
4646

@@ -53,7 +53,7 @@ public function testCreateTemplate(): void
5353

5454
public function testUpdateTemplate(): void
5555
{
56-
$this->client->request('GET', '/books/shinning/edit');
56+
$this->client->request('GET', '/books/the-shining/edit');
5757

5858
self::assertResponseIsSuccessful();
5959
}

src/BootstrapAdminUi/templates/shared/crud/create/content/header/title_block/title.html.twig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
{% set metadata = hookable_metadata.context.metadata %}
66

77
{% set singular_name = hookable_metadata.configuration.resource_name|default(metadata.applicationName ~ '.ui.' ~ _context.metadata.name) %}
8-
{% set header = hookable_metadata.configuration.header|default(null) %}
8+
{% set header = hookable_metadata.configuration.title|default(hookable_metadata.configuration.header|default(null)) %}
99
{% else %}
1010
{% set singular_name = hookable_metadata.configuration.resource_name %}
11-
{% set header = hookable_metadata.configuration.header %}
11+
{% set header = hookable_metadata.configuration.title|default(hookable_metadata.configuration.header) %}
1212
{% endif %}
1313

14+
{% set icon = hookable_metadata.configuration.icon|default(null) %}
15+
{% set subheader = hookable_metadata.configuration.subheader|default(null) %}
16+
{% set test_attribute = hookable_metadata.configuration.sylius_test_html_attribute is defined ? sylius_test_html_attribute(hookable_metadata.configuration.sylius_test_html_attribute) : null %}
17+
1418
<div class="col-12 col-md-6">
1519
<div class="d-md-flex gap-2 align-items-center">
16-
{{ header.h1(header is not null ? header|trans : 'sylius.ui.new'|trans ~ ' ' ~ singular_name|trans) }}
20+
{{ header.h1(header is not null ? header|trans : 'sylius.ui.new'|trans ~ ' ' ~ singular_name|trans, icon, subheader|trans) }}
1721
</div>
1822
</div>

src/BootstrapAdminUi/templates/shared/crud/index/content/header/title_block/title.html.twig

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/BootstrapAdminUi/templates/shared/crud/show/content/header/title_block/title.html.twig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
{% set metadata = hookable_metadata.context.metadata %}
66

77
{% set singular_name = hookable_metadata.configuration.resource_name|default(metadata.applicationName ~ '.ui.' ~ _context.metadata.name) %}
8-
{% set header = hookable_metadata.configuration.header|default(null) %}
8+
{% set header = hookable_metadata.configuration.title|default(hookable_metadata.configuration.header|default(null)) %}
99
{% else %}
1010
{% set singular_name = hookable_metadata.configuration.resource_name %}
11-
{% set header = hookable_metadata.configuration.header %}
11+
{% set header = hookable_metadata.configuration.title|default(hookable_metadata.configuration.header) %}
1212
{% endif %}
1313

14+
{% set icon = hookable_metadata.configuration.icon|default(null) %}
15+
{% set subheader = hookable_metadata.configuration.subheader|default(null) %}
16+
{% set test_attribute = hookable_metadata.configuration.sylius_test_html_attribute is defined ? sylius_test_html_attribute(hookable_metadata.configuration.sylius_test_html_attribute) : null %}
17+
1418
<div class="col-12 col-md-6">
1519
<div class="d-md-flex gap-2 align-items-center">
16-
{{ header.h1(header is not null ? header|trans : 'sylius.ui.show'|trans ~ ' ' ~ singular_name|trans) }}
20+
{{ header.h1(header is not null ? header|trans : 'sylius.ui.show'|trans ~ ' ' ~ singular_name|trans, icon, subheader|trans) }}
1721
</div>
1822
</div>

src/BootstrapAdminUi/templates/shared/crud/update/content/header/title_block/title.html.twig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
{% set metadata = hookable_metadata.context.metadata %}
66

77
{% set singular_name = hookable_metadata.configuration.resource_name|default(metadata.applicationName ~ '.ui.' ~ _context.metadata.name) %}
8-
{% set header = hookable_metadata.configuration.header|default(null) %}
8+
{% set header = hookable_metadata.configuration.title|default(hookable_metadata.configuration.header|default(null)) %}
99
{% else %}
1010
{% set singular_name = hookable_metadata.configuration.resource_name %}
11-
{% set header = hookable_metadata.configuration.header %}
11+
{% set header = hookable_metadata.configuration.title|default(hookable_metadata.configuration.header) %}
1212
{% endif %}
1313

14-
<div class="col-12 col-md-6">
14+
{% set icon = hookable_metadata.configuration.icon|default(null) %}
15+
{% set subheader = hookable_metadata.configuration.subheader|default(null) %}
16+
{% set test_attribute = hookable_metadata.configuration.sylius_test_html_attribute is defined ? sylius_test_html_attribute(hookable_metadata.configuration.sylius_test_html_attribute) : null %}
17+
18+
<div class="col-12 col-md-6" {{ test_attribute }}>
1519
<div class="d-md-flex gap-2 align-items-center">
16-
{{ header.h1(header is not null ? header|trans : 'sylius.ui.edit'|trans ~ ' ' ~ singular_name|trans) }}
20+
{{ header.h1(header is not null ? header|trans : 'sylius.ui.edit'|trans ~ ' ' ~ singular_name|trans, icon, subheader|trans) }}
1721
</div>
1822
</div>

src/BootstrapAdminUi/tests/Functional/.application/src/Grid/Provider/BookGridProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BookGridProvider implements DataProviderInterface
2525
public function getData(Grid $grid, Parameters $parameters): Pagerfanta
2626
{
2727
return new Pagerfanta(new ArrayAdapter([
28-
new BookResource('shinning', 'Shinning'),
28+
new BookResource('the-shining', 'The Shining'),
2929
new BookResource('carrie', 'Carrie'),
3030
]));
3131
}

src/BootstrapAdminUi/tests/Functional/.application/src/State/Provider/BookItemProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ class BookItemProvider implements ProviderInterface
2222
{
2323
public function provide(Operation $operation, Context $context): BookResource
2424
{
25-
return new BookResource('shinning', 'Shinning');
25+
return new BookResource('the-shining', 'The Shining');
2626
}
2727
}

src/BootstrapAdminUi/tests/Functional/TemplatesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testIndexTemplate(): void
3131

3232
self::assertResponseIsSuccessful();
3333
self::assertSelectorTextContains('title', 'app.ui.books | Sylius');
34-
self::assertSelectorTextContains('tr.item:first-child[data-test-resource-id]', 'Shinning');
34+
self::assertSelectorTextContains('tr.item:first-child[data-test-resource-id]', 'The Shining');
3535
self::assertSelectorTextContains('tr.item:last-child[data-test-resource-id]', 'Carrie');
3636
}
3737
}

tests/Functional/BookTest.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function setUp(): void
3636
public function testShowingBook(): void
3737
{
3838
$book = BookFactory::new()
39-
->withTitle('Shinning')
39+
->withTitle('The Shining')
4040
->withAuthorName('Stephen King')
4141
->create()
4242
;
@@ -46,7 +46,9 @@ public function testShowingBook(): void
4646
self::assertResponseIsSuccessful();
4747

4848
// Validate Header
49-
self::assertSelectorTextContains('[data-test-page-title]', 'Shinning');
49+
self::assertSelectorTextContains('[data-test-page-title]', 'The Shining');
50+
self::assertSelectorTextContains('[data-test-subheader]', 'Stephen King');
51+
self::assertSelectorExists('[data-test-icon="tabler:book"]');
5052

5153
// Validate page body
5254
self::assertSelectorTextContains('[data-test-author-name]', 'Stephen King');
@@ -55,7 +57,7 @@ public function testShowingBook(): void
5557
public function testBrowsingBooks(): void
5658
{
5759
BookFactory::new()
58-
->withTitle('Shinning')
60+
->withTitle('The Shining')
5961
->withAuthorName('Stephen King')
6062
->create()
6163
;
@@ -89,7 +91,7 @@ public function testBrowsingBooks(): void
8991
self::assertSelectorExists('tr.item:first-child [data-bs-title=Edit]');
9092
self::assertSelectorExists('tr.item:first-child [data-bs-title=Delete]');
9193

92-
self::assertSelectorTextContains('tr.item:last-child', 'Shinning');
94+
self::assertSelectorTextContains('tr.item:last-child', 'The Shining');
9395
self::assertSelectorTextContains('tr.item:last-child', 'Stephen King');
9496
self::assertSelectorExists('tr.item:last-child [data-bs-title=Show]');
9597
self::assertSelectorExists('tr.item:last-child [data-bs-title=Edit]');
@@ -99,7 +101,7 @@ public function testBrowsingBooks(): void
99101
public function testSortingBooks(): void
100102
{
101103
BookFactory::new()
102-
->withTitle('Shinning')
104+
->withTitle('The Shining')
103105
->withAuthorName('Stephen King')
104106
->create();
105107

@@ -116,14 +118,14 @@ public function testSortingBooks(): void
116118
self::assertResponseIsSuccessful();
117119

118120
// Validate it's sorted by title desc
119-
self::assertSelectorTextContains('tr.item:first-child', 'Shinning');
121+
self::assertSelectorTextContains('tr.item:first-child', 'The Shining');
120122
self::assertSelectorTextContains('tr.item:last-child', 'Carrie');
121123
}
122124

123125
public function testFilteringBooks(): void
124126
{
125127
BookFactory::new()
126-
->withTitle('Shinning')
128+
->withTitle('The Shining')
127129
->withAuthorName('Stephen King')
128130
->create();
129131

@@ -135,13 +137,13 @@ public function testFilteringBooks(): void
135137
$this->client->request('GET', '/admin/books');
136138

137139
$this->client->submitForm(button: 'Filter', fieldValues: [
138-
'criteria[search][value]' => 'Shinn',
140+
'criteria[search][value]' => 'Shin',
139141
], method: 'GET');
140142

141143
self::assertResponseIsSuccessful();
142144

143145
self::assertSelectorCount(1, 'tr.item');
144-
self::assertSelectorTextContains('tr.item:first-child', 'Shinning');
146+
self::assertSelectorTextContains('tr.item:first-child', 'The Shining');
145147
}
146148

147149
public function testAddingBookContent(): void
@@ -159,7 +161,7 @@ public function testAddingBook(): void
159161
$this->client->request('GET', '/admin/books/new');
160162

161163
$this->client->submitForm('Create', [
162-
'sylius_resource[title]' => 'Shinning',
164+
'sylius_resource[title]' => 'The Shining',
163165
'sylius_resource[authorName]' => 'Stephen King',
164166
]);
165167

@@ -171,9 +173,9 @@ public function testAddingBook(): void
171173
self::assertSelectorTextContains('[data-test-sylius-flash-message]', 'Book has been successfully created.');
172174

173175
/** @var Proxy<Book> $book */
174-
$book = BookFactory::find(['title' => 'Shinning']);
176+
$book = BookFactory::find(['title' => 'The Shining']);
175177

176-
self::assertSame('Shinning', $book->getTitle());
178+
self::assertSame('The Shining', $book->getTitle());
177179
self::assertSame('Stephen King', $book->getAuthorName());
178180
}
179181

@@ -195,22 +197,22 @@ public function testValidationErrorsWhenAddingBook(): void
195197
public function testEditingBookContent(): void
196198
{
197199
$book = BookFactory::new()
198-
->withTitle('Shinning')
200+
->withTitle('The Shining')
199201
->withAuthorName('Stephen King')
200202
->create();
201203

202204
$this->client->request('GET', sprintf('/admin/books/%s/edit', $book->getId()));
203205

204206
self::assertResponseIsSuccessful();
205207

206-
self::assertInputValueSame('sylius_resource[title]', 'Shinning');
208+
self::assertInputValueSame('sylius_resource[title]', 'The Shining');
207209
self::assertInputValueSame('sylius_resource[authorName]', 'Stephen King');
208210
}
209211

210212
public function testEditingBook(): void
211213
{
212214
$book = BookFactory::new()
213-
->withTitle('Shinning')
215+
->withTitle('The Shining')
214216
->withAuthorName('Stephen King')
215217
->create();
216218

@@ -238,7 +240,7 @@ public function testEditingBook(): void
238240
public function testValidationErrorsWhenEditingBook(): void
239241
{
240242
$book = BookFactory::new()
241-
->withTitle('Shinning')
243+
->withTitle('The Shining')
242244
->withAuthorName('Stephen King')
243245
->create();
244246

@@ -258,7 +260,7 @@ public function testValidationErrorsWhenEditingBook(): void
258260
public function testRemovingBook(): void
259261
{
260262
BookFactory::new()
261-
->withTitle('Shinning')
263+
->withTitle('The Shining')
262264
->withAuthorName('Stephen King')
263265
->create();
264266

tests/Functional/ConferenceTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ public function testBrowsingConferences(): void
7575
self::assertSelectorExists('tr.item:last-child [data-bs-title=Delete]');
7676
}
7777

78+
public function testAddingConferenceContent(): void
79+
{
80+
$this->client->request('GET', '/admin/conferences/new');
81+
82+
// Test header
83+
self::assertSelectorTextContains('[data-test-page-title]', 'New conference');
84+
self::assertSelectorExists('[data-test-icon="tabler:plus"]');
85+
self::assertSelectorTextContains('[data-test-subheader]', 'Managing your conferences');
86+
}
87+
7888
public function testAddingConference(): void
7989
{
8090
$this->client->request('GET', '/admin/conferences/new');
@@ -99,6 +109,20 @@ public function testAddingConference(): void
99109
self::assertSame('2024-11-13 18:00', $conference->getEndsAt()?->format('Y-m-d H:i'));
100110
}
101111

112+
public function testEditingConferenceContent(): void
113+
{
114+
$conference = ConferenceFactory::new()
115+
->withName('SyliusCon 2023')
116+
->create();
117+
118+
$this->client->request('GET', sprintf('/admin/conferences/%s/edit', $conference->getId()));
119+
120+
// Test header
121+
self::assertSelectorTextContains('[data-test-page-title]', 'Edit conference');
122+
self::assertSelectorExists('[data-test-icon="tabler:pencil"]');
123+
self::assertSelectorTextContains('[data-test-subheader]', 'Managing your conferences');
124+
}
125+
102126
public function testEditingConference(): void
103127
{
104128
$conference = ConferenceFactory::new()

tests/Functional/LegacyBookTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp(): void
3333
public function testBrowsingBooks(): void
3434
{
3535
BookFactory::new()
36-
->withTitle('Shinning')
36+
->withTitle('The Shining')
3737
->withAuthorName('Stephen King')
3838
->create()
3939
;
@@ -59,7 +59,7 @@ public function testAddingBookContent(): void
5959
public function testEditingBookContent(): void
6060
{
6161
$book = BookFactory::new()
62-
->withTitle('Shinning')
62+
->withTitle('The Shining')
6363
->withAuthorName('Stephen King')
6464
->create();
6565

0 commit comments

Comments
 (0)