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

Try to request the chart again to update the data

jnfrati 3 лет назад
Родитель
Сommit
274bed18dd

+ 20 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -507,7 +507,26 @@ const ExpandedChart: React.FC<Props> = (props) => {
           />
         );
       case "build-settings":
-        return <BuildSettingsTab chart={chart} isPreviousVersion={isPreview} />;
+        return (
+          <BuildSettingsTab
+            chart={chart}
+            isPreviousVersion={isPreview}
+            onSave={(data) => {
+              getChartData(currentChart);
+              // setCurrentChart((prev) => {
+              //   const newChart = { ...prev };
+
+              //   newChart.git_action_config = data.gitActionConfig;
+
+              //   if (data.buildConfig) {
+              //     newChart.build_config = data.buildConfig;
+              //   }
+
+              //   return { ...newChart };
+              // });
+            }}
+          />
+        );
       default:
     }
   };

+ 26 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/build-settings/BuildSettingsTab.tsx

@@ -11,7 +11,7 @@ import {
   ChartTypeWithExtendedConfig,
   FullActionConfigType,
 } from "shared/types";
-import styled, { keyframes } from "styled-components";
+import styled from "styled-components";
 import yaml from "js-yaml";
 import { AxiosError } from "axios";
 import BranchList from "components/repo-selector/BranchList";
@@ -19,12 +19,22 @@ import Banner from "components/Banner";
 import { UpdateBuildconfigResponse } from "./types";
 import BuildpackConfigSection from "./_BuildpackConfigSection";
 
+type OnSaveProps = {
+  buildConfig: BuildConfig;
+  gitActionConfig: FullActionConfigType;
+};
+
 type Props = {
   chart: ChartTypeWithExtendedConfig;
   isPreviousVersion: boolean;
+  onSave: (props: OnSaveProps) => void;
 };
 
-const BuildSettingsTab: React.FC<Props> = ({ chart, isPreviousVersion }) => {
+const BuildSettingsTab: React.FC<Props> = ({
+  chart,
+  isPreviousVersion,
+  onSave,
+}) => {
   const { currentCluster, currentProject, setCurrentError } = useContext(
     Context
   );
@@ -241,6 +251,13 @@ const BuildSettingsTab: React.FC<Props> = ({ chart, isPreviousVersion }) => {
       setCurrentError(error);
     } finally {
       clearButtonStatus();
+      onSave({
+        buildConfig,
+        gitActionConfig: {
+          ...chart.git_action_config,
+          git_branch: currentBranch,
+        },
+      });
     }
   };
 
@@ -266,6 +283,13 @@ const BuildSettingsTab: React.FC<Props> = ({ chart, isPreviousVersion }) => {
       setCurrentError(error);
     } finally {
       clearButtonStatus();
+      onSave({
+        buildConfig,
+        gitActionConfig: {
+          ...chart.git_action_config,
+          git_branch: currentBranch,
+        },
+      });
     }
   };