From 8a814d66ae8aa3672e5c812d650482268de8ba51 Mon Sep 17 00:00:00 2001 From: Vaadin Bot Date: Thu, 6 Mar 2025 12:33:31 +0100 Subject: [PATCH] fix(crud): use `noNewButton` name and fix form visibility (#3326) (CP: 24.7) (#3327) --- packages/ts/react-crud/src/autocrud.tsx | 57 +++++++++++-------- packages/ts/react-crud/test/autocrud.spec.tsx | 17 +++++- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/packages/ts/react-crud/src/autocrud.tsx b/packages/ts/react-crud/src/autocrud.tsx index 4bae6606de..dd35b7600c 100644 --- a/packages/ts/react-crud/src/autocrud.tsx +++ b/packages/ts/react-crud/src/autocrud.tsx @@ -77,14 +77,15 @@ export type AutoCrudProps = Compon */ itemIdProperty?: string; /** - * Determines whether to display the "New" button in the toolbar. By default, - * this is set to `true`, meaning the button will be shown. + * Determines whether to hide the "New" button in the toolbar. * * NOTE: This setting only hides the button; it does not prevent new items * from being sent to the service. Ensure your backend Java service is * properly secured to prevent unauthorized creation of new items. + * + * @defaultValue `false` meaning the button will be shown. */ - newButton?: boolean; + noNewButton?: boolean; /** * Props to pass to the form. See the `AutoForm` component for details. */ @@ -119,7 +120,7 @@ export function AutoCrud({ service, model, itemIdProperty, - newButton, + noNewButton, formProps, gridProps, style, @@ -162,7 +163,7 @@ export function AutoCrud({ > {/* As the toolbar only contains the "New" button at the moment, and as an empty toolbar renders as a half-height bar, let's hide it completely when the button is hidden */} - {newButton !== false && ( + {!noNewButton && (