Просмотр исходного кода

fixing cannot create a topic issue,added some default values to pass … (#1467)

* fixing cannot create a topic issue,added some default values to pass validation

* fixed default values in other forms

Co-authored-by: Ekaterina Petrova <epetrova@provectus.com>
NelyDavtyan 3 лет назад
Родитель
Сommit
05174fd684

+ 1 - 0
kafka-ui-react-app/src/components/Connect/New/New.tsx

@@ -127,6 +127,7 @@ const New: React.FC<NewProps> = ({
         <div className={['field', connectNameFieldClassName].join(' ')}>
         <div className={['field', connectNameFieldClassName].join(' ')}>
           <InputLabel>Connect *</InputLabel>
           <InputLabel>Connect *</InputLabel>
           <Controller
           <Controller
+            defaultValue={connectOptions[0].value}
             control={control}
             control={control}
             name="connectName"
             name="connectName"
             render={({ field: { name, onChange } }) => (
             render={({ field: { name, onChange } }) => (

+ 4 - 0
kafka-ui-react-app/src/components/Schemas/Edit/Edit.tsx

@@ -86,6 +86,7 @@ const Edit: React.FC = () => {
             <div>
             <div>
               <InputLabel>Type</InputLabel>
               <InputLabel>Type</InputLabel>
               <Controller
               <Controller
+                defaultValue={schema.schemaType}
                 control={control}
                 control={control}
                 rules={{ required: true }}
                 rules={{ required: true }}
                 name="schemaType"
                 name="schemaType"
@@ -108,6 +109,9 @@ const Edit: React.FC = () => {
             <div>
             <div>
               <InputLabel>Compatibility level</InputLabel>
               <InputLabel>Compatibility level</InputLabel>
               <Controller
               <Controller
+                defaultValue={
+                  schema.compatibilityLevel as CompatibilityLevelCompatibilityEnum
+                }
                 control={control}
                 control={control}
                 name="compatibilityLevel"
                 name="compatibilityLevel"
                 render={({ field: { name, onChange } }) => (
                 render={({ field: { name, onChange } }) => (

+ 1 - 0
kafka-ui-react-app/src/components/Schemas/New/New.tsx

@@ -99,6 +99,7 @@ const New: React.FC = () => {
         <div>
         <div>
           <InputLabel>Schema Type *</InputLabel>
           <InputLabel>Schema Type *</InputLabel>
           <Controller
           <Controller
+            defaultValue={SchemaTypeOptions[0].value as SchemaType}
             control={control}
             control={control}
             rules={{ required: 'Schema Type is required.' }}
             rules={{ required: 'Schema Type is required.' }}
             name="schemaType"
             name="schemaType"

+ 2 - 1
kafka-ui-react-app/src/components/Topics/New/New.tsx

@@ -21,9 +21,10 @@ interface RouterParams {
 
 
 const New: React.FC = () => {
 const New: React.FC = () => {
   const methods = useForm<TopicFormData>({
   const methods = useForm<TopicFormData>({
-    mode: 'onTouched',
+    mode: 'all',
     resolver: yupResolver(topicFormValidationSchema),
     resolver: yupResolver(topicFormValidationSchema),
   });
   });
+
   const { clusterName } = useParams<RouterParams>();
   const { clusterName } = useParams<RouterParams>();
   const history = useHistory();
   const history = useHistory();
   const dispatch = useDispatch();
   const dispatch = useDispatch();

+ 2 - 0
kafka-ui-react-app/src/components/Topics/shared/Form/TopicForm.tsx

@@ -115,6 +115,7 @@ const TopicForm: React.FC<Props> = ({
           <div>
           <div>
             <InputLabel>Cleanup policy</InputLabel>
             <InputLabel>Cleanup policy</InputLabel>
             <Controller
             <Controller
+              defaultValue={CleanupPolicyOptions[0].value}
               control={control}
               control={control}
               name="cleanupPolicy"
               name="cleanupPolicy"
               render={({ field: { name, onChange } }) => (
               render={({ field: { name, onChange } }) => (
@@ -142,6 +143,7 @@ const TopicForm: React.FC<Props> = ({
               <Controller
               <Controller
                 control={control}
                 control={control}
                 name="retentionBytes"
                 name="retentionBytes"
+                defaultValue={0}
                 render={({ field: { name, onChange } }) => (
                 render={({ field: { name, onChange } }) => (
                   <Select
                   <Select
                     name={name}
                     name={name}