فهرست منبع

fix revision selection bug

Alexander Belanger 3 سال پیش
والد
کامیت
9561295268
1فایلهای تغییر یافته به همراه13 افزوده شده و 8 حذف شده
  1. 13 8
      dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

+ 13 - 8
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -603,6 +603,13 @@ const ExpandedChart: React.FC<Props> = (props) => {
   };
   };
 
 
   const setRevision = (chart: ChartType, isCurrent?: boolean) => {
   const setRevision = (chart: ChartType, isCurrent?: boolean) => {
+    // if we've set the revision, we also override the revision in log data
+    let newLogData = logData;
+
+    newLogData.revision = `${chart.version}`;
+
+    setLogData(newLogData);
+
     setIsPreview(!isCurrent);
     setIsPreview(!isCurrent);
     getChartData(chart);
     getChartData(chart);
   };
   };
@@ -738,7 +745,7 @@ const ExpandedChart: React.FC<Props> = (props) => {
   useEffect(() => {
   useEffect(() => {
     if (logData.revision) {
     if (logData.revision) {
       api
       api
-        .getRevisions(
+        .getChart(
           "<token>",
           "<token>",
           {},
           {},
           {
           {
@@ -746,15 +753,11 @@ const ExpandedChart: React.FC<Props> = (props) => {
             namespace: props.currentChart.namespace,
             namespace: props.currentChart.namespace,
             cluster_id: currentCluster.id,
             cluster_id: currentCluster.id,
             name: props.currentChart.name,
             name: props.currentChart.name,
+            revision: parseInt(logData.revision),
           }
           }
         )
         )
         .then((res) => {
         .then((res) => {
-          const chart = res.data?.find(
-            (revision: ChartType) =>
-              revision.version.toString() === logData.revision
-          );
-
-          setCurrentChart(chart ?? props.currentChart);
+          setCurrentChart(res.data || props.currentChart);
         })
         })
         .catch(console.log);
         .catch(console.log);
 
 
@@ -979,7 +982,9 @@ const ExpandedChart: React.FC<Props> = (props) => {
                             onTabChange={(newTab) => {
                             onTabChange={(newTab) => {
                               if (newTab !== "logs") {
                               if (newTab !== "logs") {
                                 setOverrideCurrentTab("");
                                 setOverrideCurrentTab("");
-                                setLogData({});
+                                setLogData({
+                                  revision: `${currentChart.version}`,
+                                });
                               }
                               }
                             }}
                             }}
                           />
                           />