Skip to content

Commit 5d3bcdc

Browse files
authored
Merge branch 'latest' into docs/auto-responsive-form-layout
2 parents 3b14966 + db36e83 commit 5d3bcdc

File tree

37 files changed

+2796
-3898
lines changed

37 files changed

+2796
-3898
lines changed

articles/building-apps/security/add-login/flow.adoc

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,32 @@ public final class MainLayout extends AppLayout {
263263
}
264264
----
265265
266-
.TodoView.java
266+
.MainView.java
267267
[source,java]
268268
----
269269
import jakarta.annotation.security.PermitAll;
270270
271-
@Route("")
271+
@Route
272+
// tag::snippet[]
273+
@PermitAll
274+
// end::snippet[]
275+
public final class MainView extends Main {
276+
...
277+
}
278+
----
279+
280+
.TaskListView.java
281+
[source,java]
282+
----
283+
import jakarta.annotation.security.PermitAll;
284+
285+
@Route("task-list")
272286
@PageTitle("Task List")
273287
@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Task List")
274288
// tag::snippet[]
275289
@PermitAll
276290
// end::snippet[]
277-
public class TodoView extends Main {
291+
public class TaskListView extends Main {
278292
...
279293
}
280294
----
@@ -295,7 +309,7 @@ You should now see the login screen. Login with one of the following credentials
295309
* *User:* user / *Password:* password
296310
* *Admin:* admin / *Password:* admin
297311
298-
After logging in, you should be able to access the todo view.
312+
After logging in, you should be able to access the task list view.
299313
====
300314

301315

articles/building-apps/security/add-login/hilla.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ You should now see the login screen. Login with one of the following credentials
442442
* *User:* user / *Password:* password
443443
* *Admin:* admin / *Password:* admin
444444
445-
After logging in, you should be able to access the todo view.
445+
After logging in, you should be able to access the task list view.
446446
====
447447

448448

articles/building-apps/security/add-logout/hilla.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ In this mini-tutorial, you'll add logout functionality to a real Vaadin applicat
8585
====
8686
Import `useAuth` into `src/main/frontend/views/@layout.tsx`:
8787
88-
88+
.frontend/views/@layout.tsx
8989
[source,tsx]
9090
----
9191
import {useAuth} from "Frontend/security/auth";
@@ -99,7 +99,7 @@ import {useAuth} from "Frontend/security/auth";
9999
====
100100
The *user menu* in `@layout.tsx` already contains a *logout item*, but it does nothing. Modify it to call `logout()` when clicked:
101101
102-
102+
.frontend/views/@layout.tsx
103103
[source,tsx]
104104
----
105105
...

articles/building-apps/security/protect-services/flow.adoc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,32 +117,32 @@ class SecurityConfig extends VaadinWebSecurity {
117117
====
118118

119119

120-
.Secure the Todo Service
120+
.Secure the Task Service
121121
[%collapsible]
122122
====
123123
In an earlier tutorial, you made the task list read-only for users, allowing only admins to create tasks.
124124
125-
Open [classname]`TodoService` and add [annotationname]`@PreAuthorize` annotations like this:
125+
Open [classname]`TaskService` and add [annotationname]`@PreAuthorize` annotations like this:
126126
127-
.TodoService.java
127+
.TaskService.java
128128
[source,java]
129129
----
130130
@Service
131131
// tag::snippet[]
132132
@PreAuthorize("isAuthenticated()")
133133
// end::snippet[]
134134
@Transactional(propagation = Propagation.REQUIRES_NEW)
135-
public class TodoService {
135+
public class TaskService {
136136
...
137137
138138
// tag::snippet[]
139139
@PreAuthorize("hasRole('" + Roles.ADMIN + "')")
140140
// end::snippet[]
141-
public void createTodo(String description, @Nullable LocalDate dueDate) {
141+
public void createTask(String description, @Nullable LocalDate dueDate) {
142142
// ...
143143
}
144144
145-
public List<Todo> list(Pageable pageable) {
145+
public List<Task> list(Pageable pageable) {
146146
// ...
147147
}
148148
}
@@ -154,21 +154,21 @@ Log in as `ADMIN` and create some tasks. Everything should work as before.
154154
====
155155

156156

157-
.Break the Task List
157+
.Break the Task List View
158158
[%collapsible]
159159
====
160-
To see that the service is actually protected, you're going to break the task list. Open [classname]`TodoView` and comment out the lines that check whether the user is an admin or not:
160+
To see that the service is actually protected, you're going to break the task list. Open [classname]`TaskListView` and comment out the lines that check whether the user is an admin or not:
161161
162-
.TodoView.java
162+
.TaskListView.java
163163
[source,java]
164164
----
165-
@Route("")
165+
@Route("task-list")
166166
@PageTitle("Task List")
167167
@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Task List")
168168
@PermitAll
169-
public class TodoView extends Main {
169+
public class TaskListView extends Main {
170170
171-
public TodoView(TodoService todoService, Clock clock,
171+
public TaskListView(TaskService taskService, Clock clock,
172172
AuthenticationContext authenticationContext) {
173173
174174
// The rest of the constructor omitted
@@ -183,14 +183,14 @@ public class TodoView extends Main {
183183
// add(new ViewToolbar("Task List"));
184184
//}
185185
// end::snippet[]
186-
add(todoGrid);
186+
add(taskGrid);
187187
}
188188
...
189189
}
190190
----
191191
Then go back to the browser, logout, and login as `USER`. If you now try to create a task, you should get an error message.
192192
193-
Now change `TodoView()` back again by removing the comments.
193+
Now change `TaskListView()` back again by removing the comments.
194194
// TODO This should be replaced with an integration test that checks the security.
195195
====
196196

articles/building-apps/security/protect-services/hilla.adoc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,32 +194,32 @@ class SecurityConfig extends VaadinWebSecurity {
194194
====
195195

196196

197-
.Secure the Todo Service
197+
.Secure the Task Service
198198
[%collapsible]
199199
====
200200
In an earlier tutorial, you made the task list read-only for users, allowing only admins to create tasks.
201201
202-
Open [classname]`TodoService` and replace [annotationname]`@AnonymousAllowed` with [annotationname]`@PermitAll`. Then, add [annotationname]`@RolesAllowed` to `createTodo()`:
202+
Open [classname]`TaskService` and replace [annotationname]`@AnonymousAllowed` with [annotationname]`@PermitAll`. Then, add [annotationname]`@RolesAllowed` to `createTask()`:
203203
204-
.TodoService.java
204+
.TaskService.java
205205
[source,java]
206206
----
207207
@BrowserCallable
208208
// tag::snippet[]
209209
@PermitAll
210210
// end::snippet[]
211211
@Transactional(propagation = Propagation.REQUIRES_NEW)
212-
public class TodoService {
212+
public class TaskService {
213213
...
214214
215215
// tag::snippet[]
216216
@RolesAllowed(Roles.ADMIN)
217217
// end::snippet[]
218-
public void createTodo(String description, @Nullable LocalDate dueDate) {
218+
public void createTask(String description, @Nullable LocalDate dueDate) {
219219
//...
220220
}
221221
222-
public List<Todo> list(Pageable pageable) {
222+
public List<Task> list(Pageable pageable) {
223223
// ...
224224
}
225225
}
@@ -234,16 +234,16 @@ Log in as `ADMIN` and create some tasks. Everything should work as before.
234234
.Break the Task List
235235
[%collapsible]
236236
====
237-
To see that the service is actually protected, you're going to break the task list. Open `src/main/frontend/views/@index.tsx` and change `TodoView()` so that `isAdmin` is always `true`:
237+
To see that the service is actually protected, you're going to break the task list. Open `src/main/frontend/views/task-list.tsx` and change `TaskListView()` so that `isAdmin` is always `true`:
238238
239-
.frontend/views/@index.tsx
239+
.frontend/views/task-list.tsx
240240
[source,tsx]
241241
----
242242
...
243243
244-
export default function TodoView() {
245-
const dataProvider = useDataProvider<Todo>({
246-
list: (pageable) => TodoService.list(pageable),
244+
export default function TaskListView() {
245+
const dataProvider = useDataProvider<Task>({
246+
list: (pageable) => TaskService.list(pageable),
247247
});
248248
const auth = useAuth();
249249
// tag::snippet[]
@@ -255,7 +255,7 @@ export default function TodoView() {
255255
256256
Then go back to the browser, logout, and login as `USER`. If you now try to create a task, you should get an error message.
257257
258-
Now change `TodoView()` back again.
258+
Now change `TaskListView()` back again.
259259
// TODO This should be replaced with an integration test that checks the security, if that is even possible to write at the moment.
260260
====
261261

articles/building-apps/security/protect-views/flow.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class SecurityConfig extends VaadinWebSecurity {
320320
.Create Admin View
321321
[%collapsible]
322322
====
323-
Create a new class [classname]`AdminView` in the [packagename]`[application package].todo.ui.view` package:
323+
Create a new class [classname]`AdminView` in the [packagename]`[application package].taskmanagement.ui.view` package:
324324
325325
.AdminView.java
326326
[source,java]
@@ -359,18 +359,18 @@ Attempt to access http://localhost:8080/admin directly. You should see an access
359359
.Make the Task List Read-Only For Users
360360
[%collapsible]
361361
====
362-
So far all authenticated users have been able to add tasks to [classname]`TodoView`. You'll now change it so that only users with the `ADMIN` role can add tasks. Open [classname]`TodoView` and change the constructor as follows:
362+
So far all authenticated users have been able to add tasks to [classname]`TaskListView`. You'll now change it so that only users with the `ADMIN` role can add tasks. Open [classname]`TaskListView` and change the constructor as follows:
363363
364-
.TodoView.java
364+
.TaskListView.java
365365
[source,java]
366366
----
367-
@Route("")
367+
@Route("task-list")
368368
@PageTitle("Task List")
369369
@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Task List")
370370
@PermitAll
371-
public class TodoView extends Main {
371+
public class TaskListView extends Main {
372372
373-
public TodoView(TodoService todoService, Clock clock,
373+
public TaskListView(TaskService taskService, Clock clock,
374374
// tag::snippet[]
375375
AuthenticationContext authenticationContext) {
376376
// end::snippet[]
@@ -385,7 +385,7 @@ public class TodoView extends Main {
385385
add(new ViewToolbar("Task List")); // <2>
386386
}
387387
// end::snippet[]
388-
add(todoGrid);
388+
add(taskGrid);
389389
}
390390
...
391391
}

articles/building-apps/security/protect-views/hilla.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,18 +239,18 @@ Attempt to access http://localhost:8080/admin directly. You should end up on the
239239
.Make the Task List Read-Only For Users
240240
[%collapsible]
241241
====
242-
So far all authenticated users have been able to add tasks to the todo view. You'll now change it so that only users with the `ADMIN` role can add tasks. Open `src/main/frontend/views/index.tsx` and change it as follows:
242+
So far all authenticated users have been able to add tasks to the task list view. You'll now change it so that only users with the `ADMIN` role can add tasks. Open `src/main/frontend/views/task-list.tsx` and change it as follows:
243243
244-
.frontend/views/index.tsx
244+
.frontend/views/task-list.tsx
245245
[source,tsx]
246246
----
247247
// tag::snippet[]
248248
import { useAuth } from "Frontend/security/auth";
249249
// end::snippet[]
250250
...
251-
export default function TodoView() {
252-
const dataProvider = useDataProvider<Todo>({
253-
list: (pageable) => TodoService.list(pageable),
251+
export default function TaskListView() {
252+
const dataProvider = useDataProvider<Task>({
253+
list: (pageable) => TaskService.list(pageable),
254254
});
255255
// tag::snippet[]
256256
const auth = useAuth();
@@ -262,7 +262,7 @@ export default function TodoView() {
262262
<ViewToolbar title="Task List">
263263
{/* tag::snippet[] */}
264264
{isAdmin && <Group> {/* <1> */}
265-
<TodoEntryForm onTodoCreated={dataProvider.refresh} />
265+
<TaskEntryForm onTaskCreated={dataProvider.refresh} />
266266
</Group>}
267267
{/* end::snippet[] */}
268268
</ViewToolbar>

articles/building-apps/views/add-router-layout/hilla.adoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To create a router layout, create a file named `@layout.tsx` in any directory un
2424
Here's an example of a basic router layout created directly under the `views` directory that wraps all views in the application, as it is located in the root of `views` directory:
2525

2626
[source,tsx]
27-
./views/@layout.tsx
27+
.frontend/views/@layout.tsx
2828
----
2929
// tag::snippet[]
3030
import { Outlet } from 'react-router';
@@ -56,7 +56,7 @@ In this example, the `MainLayout` component wraps all views in the application w
5656
Here's an example of a layout that wraps the views defined in the `customers` directory and any possible subdirectories:
5757

5858
[source,tsx]
59-
./views/customers/@layout.tsx
59+
.frontend/views/customers/@layout.tsx
6060
----
6161
import { Outlet } from 'react-router';
6262
@@ -100,7 +100,7 @@ views
100100
There are certain views and routes that should not be rendered inside any layouts. A `login` view is common example of such a view that should escape being rendered within the application layout. You can skip the layouts that are applied to views using the `ViewConfig` configuration object. Export this object from your view file to instruct the router not to wrap this view inside any layout available in the directory structure:
101101

102102
[source,tsx]
103-
./views/login.tsx
103+
.frontend/views/login.tsx
104104
----
105105
// tag::snippet[]
106106
import { ViewConfig } from '@vaadin/hilla-file-router/types.js';
@@ -126,7 +126,7 @@ export const config: ViewConfig = {
126126
The Hilla router provides utilities to create navigation menus based on your route structure. Use the `createMenuItems()` utility to automatically generate menu items:
127127

128128
[source,tsx]
129-
./views/@layout.tsx
129+
.frontend/views/@layout.tsx
130130
----
131131
// tag::snippet[]
132132
import { createMenuItems } from '@vaadin/hilla-file-router/runtime.js';
@@ -190,7 +190,7 @@ The skeleton already contains a main layout. Instead of implementing one from sc
190190
191191
The main layout is based on <<{articles}/components/app-layout#,App Layout>>:
192192
193-
./views/@layout.tsx
193+
.frontend/views/@layout.tsx
194194
[source,tsx]
195195
----
196196
// imports and interal components
@@ -321,7 +321,7 @@ The <<{articles}/building-apps/security#,Security>> guides show you how to add r
321321
Create a new directory named as `customers` under `views`. Inside this directory, create a new file called [filename]`@layout.tsx`, like this:
322322
323323
[source,tsx]
324-
./views/customers/@layout.tsx
324+
.frontend/views/customers/@layout.tsx
325325
----
326326
import { Outlet } from 'react-router';
327327
@@ -353,7 +353,7 @@ You can't see what your new layout looks like yet, because you don't have any vi
353353
====
354354
You'll now create two views that both use the new nested layout automatically. Inside the [directoryname]`views` directory, create two new views; [filename]`new.tsx` and [filename]`@index.tsx`:
355355
356-
./views/customers/new.tsx
356+
.frontend/views/customers/new.tsx
357357
[source,tsx]
358358
----
359359
export default function NewCustomerView() {
@@ -368,7 +368,7 @@ export default function NewCustomerView() {
368368
----
369369
<1> A red background is added to the view to make it visually distinct from the main layout and the nested layout.
370370
371-
./views/customers/@index.tsx
371+
.frontend/views/customers/@index.tsx
372372
[source,tsx]
373373
----
374374
export default function CustomerListView() {
@@ -403,7 +403,7 @@ Navigate back and forth between them, and verify that the nested layout is appli
403403
====
404404
Add a [filename]`login.tsx` under the `views` directory:
405405
406-
.views/login.tsx
406+
.frontend/views/login.tsx
407407
[source,tsx]
408408
----
409409
export default function LoginView() {
@@ -428,7 +428,7 @@ Navigate to the login view using the menu or by navigating to http://localhost:8
428428
====
429429
To skip the automatic layout for the login view, you need to export a `config` object from the view file. Add the following code to the `login.tsx` file:
430430
431-
./views/login.tsx
431+
.frontend/views/login.tsx
432432
[source,tsx]
433433
----
434434
import { ViewConfig } from '@vaadin/hilla-file-router/types.js';

0 commit comments

Comments
 (0)