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), + })} + /> + + + + + + ); }