From b6b5935992f4aa8a962ab075ff780855cb66aeff Mon Sep 17 00:00:00 2001 From: Dan83 Date: Wed, 21 Feb 2024 12:56:04 +0100 Subject: [PATCH] Chore: Remove Form usage in NewFolderForm components (#83028) * Chore: Remove Form usage from NewFolderForm * Chore: Remove Form usage from NewFolderForm * Chore: Remove Form usage from NewFolderForm * Replace HorizontalGroup with Stack * add Default Values and launch prettier --- .../components/NewFolderForm.tsx | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/public/app/features/browse-dashboards/components/NewFolderForm.tsx b/public/app/features/browse-dashboards/components/NewFolderForm.tsx index d201f8a4e0b..a31594be7f3 100644 --- a/public/app/features/browse-dashboards/components/NewFolderForm.tsx +++ b/public/app/features/browse-dashboards/components/NewFolderForm.tsx @@ -1,7 +1,8 @@ import React from 'react'; +import { useForm } from 'react-hook-form'; import { selectors } from '@grafana/e2e-selectors'; -import { Button, Input, Form, Field, HorizontalGroup } from '@grafana/ui'; +import { Button, Input, Field, Stack } from '@grafana/ui'; import { Trans, t } from 'app/core/internationalization'; import { validationSrv } from '../../manage-dashboards/services/ValidationSrv'; @@ -18,6 +19,12 @@ interface FormModel { const initialFormModel: FormModel = { folderName: '' }; export function NewFolderForm({ onCancel, onConfirm }: Props) { + const { + handleSubmit, + register, + formState: { errors }, + } = useForm({ defaultValues: initialFormModel }); + const translatedFolderNameRequiredPhrase = t( 'browse-dashboards.action.new-folder-name-required-phrase', 'Folder name is required.' @@ -38,37 +45,34 @@ export function NewFolderForm({ onCancel, onConfirm }: Props) { const fieldNameLabel = t('browse-dashboards.new-folder-form.name-label', 'Folder name'); return ( -
onConfirm(form.folderName)} + onConfirm(form.folderName))} data-testid={selectors.pages.BrowseDashboards.NewFolderForm.form} > - {({ register, errors }) => ( - <> - - await validateFolderName(v), - })} - /> - - - - - - - )} -
+ + await validateFolderName(v), + })} + /> + + + + + + ); }