Quellcode durchsuchen

HUE-3161 [oozie] Fix automatic workflow parameter population in Coordinator editor

Note: Earlier we just updated previous params and if the new Workflow has less params
we just left the extra params for the user to delete it.
Now, we delete unused old params and add whatever is new.
krish vor 9 Jahren
Ursprung
Commit
18cfde780b
1 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen
  1. 13 3
      apps/oozie/src/oozie/static/oozie/js/coordinator-editor.ko.js

+ 13 - 3
apps/oozie/src/oozie/static/oozie/js/coordinator-editor.ko.js

@@ -82,12 +82,22 @@ var Coordinator = function (vm, coordinator) {
         "uuid": self.properties.workflow(),
       }, function (data) {
         self.workflowParameters(data.parameters);
-        // Pre-add the variables
+
+        // Remove Uncommon params
+        prev_variables = self.variables.slice();
+        $.each(prev_variables, function (index, variable) {
+          if (data.parameters.filter(function(param) { return param['name'] == variable.workflow_variable() }).length == 0) {
+            self.variables.remove(variable);
+          }
+        });
+
+        // Append the new variables
+        prev_variables = self.variables.slice();
         $.each(data.parameters, function (index, param) {
-          if (self.variables().length < data.parameters.length) {
+          if (prev_variables.filter(function(variable) { return param['name'] == variable.workflow_variable() }).length == 0) {
             self.addVariable();
+            self.variables()[self.variables().length - 1].workflow_variable(param['name']);
           }
-          self.variables()[self.variables().length - 1].workflow_variable(param['name']);
         });
       }).fail(function (xhr, textStatus, errorThrown) {
         $(document).trigger("error", xhr.responseText);