Jelajahi Sumber

fix issue where users were not prompted to install agent (#3142)

Feroze Mohideen 2 tahun lalu
induk
melakukan
d758fb1e1d

+ 14 - 10
dashboard/src/main/home/app-dashboard/expanded-app/activity-feed/ActivityFeed.tsx

@@ -81,6 +81,8 @@ const ActivityFeed: React.FC<Props> = ({ chart, stackName, appData }) => {
         if (err.response?.status === 404) {
           setHasPorterAgent(false);
         }
+      } finally {
+        setLoading(false);
       }
     };
 
@@ -89,7 +91,8 @@ const ActivityFeed: React.FC<Props> = ({ chart, stackName, appData }) => {
     } else {
       getEvents();
     }
-  }, [currentProject, currentCluster, hasPorterAgent]);
+
+  }, [currentProject, currentCluster, hasPorterAgent, page]);
 
 
   const installAgent = async () => {
@@ -97,20 +100,21 @@ const ActivityFeed: React.FC<Props> = ({ chart, stackName, appData }) => {
     const cluster_id = currentCluster?.id;
 
     setIsPorterAgentInstalling(true);
-
-    api
-      .installPorterAgent("<token>", {}, { project_id, cluster_id })
-      .then()
-      .catch((err) => {
-        setIsPorterAgentInstalling(false);
-        console.log(err);
-      });
+    try {
+      await api.installPorterAgent("<token>", {}, { project_id, cluster_id });
+      window.location.reload();
+    } catch (err) {
+      setIsPorterAgentInstalling(false);
+      console.log(err);
+    }
   };
 
   if (isPorterAgentInstalling) {
     return (
       <Fieldset>
         <Text size={16}>Installing agent...</Text>
+        <Spacer y={0.5} />
+        <Text color="helper">If you are not redirected automatically after a minute, you may need to refresh this page.</Text>
       </Fieldset>
     );
   }
@@ -142,7 +146,7 @@ const ActivityFeed: React.FC<Props> = ({ chart, stackName, appData }) => {
         </Text>
         <Spacer y={0.5} />
         <Text color="helper">
-          In order to use the events tab, you need to install the Porter agent.
+          In order to use the Activity tab, you need to install the Porter agent.
         </Text>
         <Spacer y={1} />
         <Button onClick={() => installAgent()}>