From 3bb1d93f3e3b022fbbaa47ad6aa211604a156bd2 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Tue, 11 Jun 2024 12:29:50 +0100 Subject: [PATCH] feat: Add forceNavigate option when navigating to new item The DuplicateModel component in CommonUI has been updated to include a new option, forceNavigate, when navigating to a new item. This option allows for forced navigation to the new item, bypassing any checks or validations. This change provides more control over the navigation behavior and ensures consistent navigation to the new item. --- CommonUI/src/Components/DuplicateModel/DuplicateModel.tsx | 5 ++++- CommonUI/src/Components/Forms/Fields/FormField.tsx | 3 ++- Dashboard/src/Pages/Monitor/View/Settings.tsx | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CommonUI/src/Components/DuplicateModel/DuplicateModel.tsx b/CommonUI/src/Components/DuplicateModel/DuplicateModel.tsx index fcc032c64d..6b2a963e56 100644 --- a/CommonUI/src/Components/DuplicateModel/DuplicateModel.tsx +++ b/CommonUI/src/Components/DuplicateModel/DuplicateModel.tsx @@ -86,7 +86,10 @@ const DuplicateModel: ( Navigation.navigate( new Route(props.navigateToOnSuccess.toString()).addRoute( `/${newItem.data.id!.toString()}` - ) + ), + { + forceNavigate: true, + } ); } } catch (err) { diff --git a/CommonUI/src/Components/Forms/Fields/FormField.tsx b/CommonUI/src/Components/Forms/Fields/FormField.tsx index 8d266d7837..8783d7e6b2 100644 --- a/CommonUI/src/Components/Forms/Fields/FormField.tsx +++ b/CommonUI/src/Components/Forms/Fields/FormField.tsx @@ -632,7 +632,8 @@ const FormField: ( ? (props.currentValues as any)[ props.fieldName ] - : false + : (props.field.defaultValue as boolean) || + false } /> )} diff --git a/Dashboard/src/Pages/Monitor/View/Settings.tsx b/Dashboard/src/Pages/Monitor/View/Settings.tsx index f20ea4ea59..a0073c683f 100644 --- a/Dashboard/src/Pages/Monitor/View/Settings.tsx +++ b/Dashboard/src/Pages/Monitor/View/Settings.tsx @@ -226,8 +226,8 @@ const MonitorCriteria: FunctionComponent = ( title: 'Disable Monitor', description: 'Should the new monitor be disabled when its duplicated?', - defaultValue: true, fieldType: FormFieldSchemaType.Toggle, + defaultValue: true, required: false, }, ]}