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

fix: check for agent not triggering

Soham Parekh 3 лет назад
Родитель
Сommit
475e16276d

+ 24 - 22
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -72,7 +72,6 @@ const ExpandedChart: React.FC<Props> = (props) => {
   const [imageIsPlaceholder, setImageIsPlaceholer] = useState<boolean>(false);
   const [newestImage, setNewestImage] = useState<string>(null);
   const [isLoadingChartData, setIsLoadingChartData] = useState<boolean>(true);
-  const [showRepoTooltip, setShowRepoTooltip] = useState(false);
   const [isAuthorized] = useAuth();
   const [fullScreenLogs, setFullScreenLogs] = useState<boolean>(false);
   const [isFullscreen, setIsFullscreen] = useState<boolean>(false);
@@ -316,7 +315,6 @@ const ExpandedChart: React.FC<Props> = (props) => {
 
     setSaveValueStatus("loading");
 
-    // console.log("valuesYaml", valuesYaml);
     try {
       await api.upgradeChartValues(
         "<token>",
@@ -334,25 +332,6 @@ const ExpandedChart: React.FC<Props> = (props) => {
         }
       );
 
-      await api.detectPorterAgent(
-        "<token>",
-        {},
-        {
-          project_id: currentProject.id,
-          cluster_id: currentCluster.id,
-        }
-      )
-      .then(() => setIsAgentInstalled(true))
-      .catch((err) => {
-        setIsAgentInstalled(false);
-
-        if (err.status !== 404) {
-          setCurrentError(
-            "We could not detect the Porter agent installation status, please try again."
-          );
-        }
-      });
-
       getChartData(currentChart);
 
       setSaveValueStatus("successful");
@@ -727,6 +706,29 @@ const ExpandedChart: React.FC<Props> = (props) => {
     }
   };
 
+  // Check if porter agent is installed. If not installed hide the `Logs` component
+  useEffect(() => {
+    api
+      .detectPorterAgent(
+        "<token>",
+        {},
+        {
+          project_id: currentProject.id,
+          cluster_id: currentCluster.id,
+        }
+      )
+      .then(() => setIsAgentInstalled(true))
+      .catch((err) => {
+        setIsAgentInstalled(false);
+
+        if (err.status !== 404) {
+          setCurrentError(
+            "We could not detect the Porter agent installation status, please try again."
+          );
+        }
+      });
+  }, []);
+
   useEffect(() => {
     window.analytics?.track("Opened Chart", {
       chart: currentChart.name,
@@ -753,7 +755,7 @@ const ExpandedChart: React.FC<Props> = (props) => {
   useEffect(() => {
     updateTabs();
     localStorage.setItem("devOpsMode", devOpsMode.toString());
-  }, [devOpsMode, currentChart?.form, isPreview]);
+  }, [devOpsMode, currentChart?.form, isPreview, isAgentInstalled]);
 
   useEffect((): any => {
     let isSubscribed = true;

+ 7 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/events/EventList.tsx

@@ -209,10 +209,10 @@ const EventList: React.FC<Props> = ({ filters, setLogData }) => {
             </TableWrapper>
           ) : (
             <Placeholder>
-              <div>
+              <NoResultsFoundWrapper>
                 <Title>No results found</Title>
                 There were no results found for this filter.
-              </div>
+              </NoResultsFoundWrapper>
             </Placeholder>
           )}
         </>
@@ -378,3 +378,8 @@ const StyledMonitorList = styled.div`
   border-radius: 5px;
   border: 1px solid #aaaabb33;
 `;
+
+const NoResultsFoundWrapper = styled(Flex)`
+  flex-direction: column;
+  justify-contents: center;
+`;