Skip to content
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

docs: address DX test feedback for Hilla 2.4 #2970

Merged
merged 5 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion articles/react/components/auto-crud/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ include::{root}/src/main/java/com/vaadin/demo/fusion/crud/EmployeeRepository.jav

Hilla generates TypeScript objects for each `@BrowserCallable` service implementing the `CrudService<T, ID>` interface. These TypeScript objects have callable methods that execute the corresponding Java service methods, enabling the Add, Update, and Delete operations as well as lazy data loading with sorting and filtering.

For the `EmployeeService` example, you can import the generated TypeScript object in your React view, and use it as a value for the `service` property to render automatically grid columns and form fields. Here's what the rendered component looks like:
For the example above, you can import the generated TypeScript objects in your React view and configure the component like so:

[source,tsx]
----
<AutoCrud service={EmployeeService} model={EmployeeModel} />
----

Here's what the rendered component looks like:
taefi marked this conversation as resolved.
Show resolved Hide resolved

[.example.desktop]
--
Expand Down
15 changes: 10 additions & 5 deletions articles/react/components/auto-form/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ include::{root}/src/main/java/com/vaadin/demo/fusion/crud/EmployeeRepository.jav

Hilla generates TypeScript objects for each `@BrowserCallable` service implementing the `CrudService<T, ID>` interface. These TypeScript objects have callable methods that execute the corresponding Java service methods, enabling the Add, Update, and Delete operations as well as lazy data loading with sorting and filtering.

For the `EmployeeService` example, you can import the generated TypeScript object in your React view, and use it as a value for the `<AutoForm service={EmployeeService} />` property to render the form.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some testers referred to the example code in this paragraph when creating the initial component, and also missed to expand the code snippet in the example below. They were then confused why they ended up with a partially configured component and had compiler errors. Changed this in both articles to show a proper code snippet with a fully configured component.

For the example above, you can import the generated TypeScript objects in your React view and configure the component like so:

[source,tsx]
----
<AutoForm service={EmployeeService} model={EmployeeModel} />
----

Here's what the rendered form looks like:

Expand Down Expand Up @@ -180,9 +185,9 @@ The following properties are available for managing the form state or reacting t

- `item`: the item to be edited. If the item is `null`, the form is in _new_ mode, otherwise it is in _edit_ mode.
- `disabled`: disables the whole form.
- `afterSubmit`: a callback function that is called after the form is submitted successfully.
- `onSubmitSuccess`: a callback function that is called after the form is submitted successfully.

The following example shows how to use the `item` property to manage switching between _new_ and _edit_ modes, and `afterSubmit` for informing the user about the form submission success. In addition, it uses `disabled` property is also used to toggle the form's disabled state:
The following example shows how to use the `item` property to manage switching between _new_ and _edit_ modes, and `onSubmitSuccess` for informing the user about the form submission success. In addition, it uses `disabled` property is also used to toggle the form's disabled state:

[.example.desktop]
--
Expand All @@ -195,9 +200,9 @@ include::{root}/frontend/demo/component/auto-form/react/auto-form-edit-new-modes
Auto Form component supports Deletion functionality out-of-the-box, which is associated with calling the `delete` method from the `CrudService` introduced to the Auto Form. The following properties are associated with managing this functionality:

- `deleteButtonVisible`: whether to show the delete button in the form which is hidden by default. If enabled, the delete button is only shown when editing an existing item, that means that `item` property is not null.
- `afterDelete`: a callback function that is called after the item is deleted successfully.
- `onDeleteSuccess`: a callback function that is called after the item is deleted successfully.

The following example shows how to use the `deleteButtonVisible` property to show the Delete button, and uses the `afterDelete` property to inform the user about the deletion success. You can toggle between the _edit_ and _new_ modes to see its effect on the visibility of the Delete button in action:
The following example shows how to use the `deleteButtonVisible` property to show the Delete button, and uses the `onDeleteSuccess` property to inform the user about the deletion success. You can toggle between the _edit_ and _new_ modes to see its effect on the visibility of the Delete button in action:

[.example.desktop]
--
Expand Down
2 changes: 1 addition & 1 deletion articles/react/guides/routing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function ProductDetailView() {
const { productId } = useParams();

// Fetch product details for the given ID
const { product, setProduct } = useState<Product>();
const [ product, setProduct ] = useState<Product>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only semi-related, but discovered this syntax issue as part of the tests.


useEffect(() => {
ProductEndpoint.getProduct(productId).then(setProduct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ function Example() {
fieldOptions: {
firstName: { label: 'Name' },
description: {
renderer: ({ field }) => (
<TextArea key={field.name} {...field} label="Full description" />
),
renderer: ({ field }) => <TextArea {...field} label="Full description" />,
taefi marked this conversation as resolved.
Show resolved Hide resolved
},
},
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ function Example() {
model={EmployeeModel}
fieldOptions={{
description: {
renderer: ({ field }) => (
<TextArea key={field.name} {...field} label="Full description" />
),
renderer: ({ field }) => <TextArea {...field} label="Full description" />,
},
}}
/>
Expand Down