Browse Source

Prevent redirect to topic details before topic create/update response arrives.

Sofia Shnaidman 4 years ago
parent
commit
6673bd53c4

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

@@ -110,8 +110,8 @@ const Edit: React.FC<Props> = ({
   });
 
   const onSubmit = async (data: TopicFormData) => {
-    setIsSubmitting(true);
     updateTopic(clusterName, data);
+    setIsSubmitting(true); // Keep this action after updateTopic to prevent redirect before update.
   };
 
   return (

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

@@ -34,10 +34,9 @@ const New: React.FC<Props> = ({
   const onSubmit = async (data: TopicFormData) => {
     // TODO: need to fix loader. After success loading the first time, we won't wait for creation any more, because state is
     // loaded, and we will try to get entity immediately after pressing the button, and we will receive null
-    // going to object page on the second creation. Resetting loaded state is workaround, need to tweak loader logic
-    resetUploadedState();
-    setIsSubmitting(true);
+    // going to object page on the second creation. Setting of isSubmitting after createTopic is a workaround, need to tweak loader logic
     createTopic(clusterName, data);
+    setIsSubmitting(true); // Keep this action after createTopic to prevent redirect before create.
   };
 
   return (