浏览代码

Update SendMessage.tsx (#745)

Alexander Krivonosov 3 年之前
父节点
当前提交
a9d659642e
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      kafka-ui-react-app/src/components/Topics/Topic/SendMessage/SendMessage.tsx

+ 8 - 1
kafka-ui-react-app/src/components/Topics/Topic/SendMessage/SendMessage.tsx

@@ -43,6 +43,7 @@ const SendMessage: React.FC<Props> = ({
 }) => {
 }) => {
   const [keyExampleValue, setKeyExampleValue] = React.useState('');
   const [keyExampleValue, setKeyExampleValue] = React.useState('');
   const [contentExampleValue, setContentExampleValue] = React.useState('');
   const [contentExampleValue, setContentExampleValue] = React.useState('');
+  const [schemaIsReady, setSchemaIsReady] = React.useState(false);
   const [schemaErrorString, setSchemaErrorString] = React.useState('');
   const [schemaErrorString, setSchemaErrorString] = React.useState('');
   const {
   const {
     register,
     register,
@@ -62,6 +63,7 @@ const SendMessage: React.FC<Props> = ({
         setKeyExampleValue(
         setKeyExampleValue(
           JSON.stringify(getFakeData(validateKey), null, '\t')
           JSON.stringify(getFakeData(validateKey), null, '\t')
         );
         );
+        setSchemaIsReady(true);
       }
       }
 
 
       const validateContent = convertToYup(
       const validateContent = convertToYup(
@@ -71,6 +73,11 @@ const SendMessage: React.FC<Props> = ({
         setContentExampleValue(
         setContentExampleValue(
           JSON.stringify(getFakeData(validateContent), null, '\t')
           JSON.stringify(getFakeData(validateContent), null, '\t')
         );
         );
+        setSchemaIsReady(true);
+      }
+
+      if (!validateKey && !validateContent) {
+        setSchemaIsReady(true);
       }
       }
     }
     }
   }, [schemaIsFetched]);
   }, [schemaIsFetched]);
@@ -109,7 +116,7 @@ const SendMessage: React.FC<Props> = ({
     }
     }
   };
   };
 
 
-  if (!keyExampleValue && !contentExampleValue) {
+  if (!schemaIsReady) {
     return <PageLoader />;
     return <PageLoader />;
   }
   }
   return (
   return (