Переглянути джерело

support paused jobs and case rerun button on expanded jobs

Alexander Belanger 5 роки тому
батько
коміт
55dc4a38e5

+ 2 - 1
dashboard/src/components/values-form/FormWrapper.tsx

@@ -12,6 +12,7 @@ type PropsType = {
   formData: any;
   onSubmit?: (formValues: any) => void;
   saveValuesStatus?: string | null;
+  saveButtonText?: string | null;
 
   // Handle additional non-form tabs
   // TODO: find cleaner way to share submitValues w/ rerun jobs button
@@ -385,7 +386,7 @@ export default class FormWrapper extends Component<PropsType, StateType> {
         {showSave && (
           <SaveButton
             disabled={this.isDisabled()}
-            text="Deploy"
+            text={this.props.saveButtonText || "Deploy"}
             onClick={this.handleSubmit}
             status={
               this.isDisabled() && this.props.saveValuesStatus != "loading"

+ 23 - 8
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -251,7 +251,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
     return ws;
   };
 
-  handleSaveValues = (config?: any) => {
+  handleSaveValues = (config?: any, runJob?: boolean) => {
     let { currentCluster, setCurrentError, currentProject } = this.context;
     this.setState({ saveValuesStatus: "loading" });
 
@@ -303,6 +303,12 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
         _.set(values, "image.tag", `${tag}`);
       }
 
+      if (runJob) {
+        _.set(values, "paused", false);
+      } else {
+        _.set(values, "paused", true);
+      }
+
       // Weave in preexisting values and convert to yaml
       conf = yaml.dump(
         {
@@ -392,6 +398,18 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
   };
 
   renderTabContents = (currentTab: string, submitValues?: any) => {
+    console.log("CHART CONFIG", this.props.currentChart.config?.schedule?.enabled)
+    let saveButton = null
+
+    if (!this.props.currentChart.config?.schedule?.enabled) {
+      saveButton = <SaveButton
+        text="Rerun Job"
+        onClick={() => this.handleSaveValues(submitValues, true)}
+        status={this.state.saveValuesStatus}
+        makeFlush={true}
+      />
+    }
+
     switch (currentTab) {
       case "jobs":
         if (this.state.imageIsPlaceholder) {
@@ -410,12 +428,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
         return (
           <TabWrapper>
             <JobList jobs={this.state.jobs} />
-            <SaveButton
-              text="Rerun Job"
-              onClick={() => this.handleSaveValues(submitValues)}
-              status={this.state.saveValuesStatus}
-              makeFlush={true}
-            />
+            {saveButton}
           </TabWrapper>
         );
       case "settings":
@@ -427,6 +440,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
             setShowDeleteOverlay={(x: boolean) =>
               this.setState({ showDeleteOverlay: x })
             }
+            saveButtonText="Save Config"
           />
         );
       default:
@@ -584,8 +598,9 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
               isInModal={true}
               renderTabContents={this.renderTabContents}
               tabOptionsOnly={true}
-              onSubmit={this.handleSaveValues}
+              onSubmit={(formValues) => this.handleSaveValues(formValues, false)}
               saveValuesStatus={this.state.saveValuesStatus}
+              saveButtonText="Save Config"
             />
           </BodyWrapper>
         </StyledExpandedChart>

+ 7 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/SettingsSection.tsx

@@ -24,6 +24,7 @@ type PropsType = {
   refreshChart: () => void;
   setShowDeleteOverlay: (x: boolean) => void;
   showSource?: boolean;
+  saveButtonText?: string | null;
 };
 
 type StateType = {
@@ -146,6 +147,11 @@ export default class SettingsSection extends Component<PropsType, StateType> {
       _.set(values, "image.tag", this.state.selectedTag);
     }
 
+    // if this is a job, set it to paused
+    if (this.props.currentChart.chart.metadata.name == "job") {
+      _.set(values, "paused", true);
+    }
+
     // Weave in preexisting values and convert to yaml
     let conf = yaml.dump(
       {
@@ -204,7 +210,7 @@ export default class SettingsSection extends Component<PropsType, StateType> {
         </StyledSettingsSection>
         {this.props.showSource && (
           <SaveButton
-            text="Deploy"
+            text={this.props.saveButtonText || "Save Config"}
             status={this.state.saveValuesStatus}
             onClick={this.handleSubmit}
             makeFlush={true}

+ 1 - 0
server/api/release_handler.go

@@ -1055,6 +1055,7 @@ func (app *App) HandleReleaseBatchUpdateImage(w http.ResponseWriter, r *http.Req
 			image["repository"] = releases[index].ImageRepoURI
 			image["tag"] = form.Tag
 			rel.Config["image"] = image
+			rel.Config["paused"] = true
 
 			conf := &helm.UpgradeReleaseConfig{
 				Name:       releases[index].Name,