This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch v2-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-1-test by this push:
     new 421fbae  fix modal actions (#15896)
421fbae is described below

commit 421fbae35b0a8be05ee5d81388aee6ad39bc3cee
Author: Brent Bovenzi <[email protected]>
AuthorDate: Mon May 17 15:55:43 2021 -0400

    fix modal actions (#15896)
    
    Modal events are triggering twice. once, with an executionDate, and again 
without. Now the submit function will check that an executionDate exists before 
doing an action
    
    (cherry picked from commit a73ba4b3af65ff392a05fe09f656a91b51401c4d)
---
 airflow/www/static/js/dag.js | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/airflow/www/static/js/dag.js b/airflow/www/static/js/dag.js
index 5a14c67..39ffedc 100644
--- a/airflow/www/static/js/dag.js
+++ b/airflow/www/static/js/dag.js
@@ -211,9 +211,10 @@ export function callModal(t, d, extraLinks, tryNumbers, 
sd) {
 export function callModalDag(dag) {
   $('#dagModal').modal({});
   $('#dagModal').css('margin-top', '0');
+  executionDate = dag.execution_date;
   updateButtonUrl(buttons.dag_graph_view, {
-    dag_id: dag && dag.execution_date,
-    execution_date: dag && dag.dag_id,
+    dag_id: dag && dag.dag_id,
+    execution_date: dag && dag.execution_date,
   });
 }
 
@@ -221,25 +222,31 @@ export function callModalDag(dag) {
 $('form[data-action]').on('submit', function submit(e) {
   e.preventDefault();
   const form = $(this).get(0);
-  form.execution_date.value = executionDate;
-  form.origin.value = window.location;
-  if (form.task_id) {
-    form.task_id.value = taskId;
+  // Somehow submit is fired twice. Only once is the executionDate valid
+  if (executionDate) {
+    form.execution_date.value = executionDate;
+    form.origin.value = window.location;
+    if (form.task_id) {
+      form.task_id.value = taskId;
+    }
+    form.action = $(this).data('action');
+    form.submit();
   }
-  form.action = $(this).data('action');
-  form.submit();
 });
 
 // DAG Modal actions
 $('form button[data-action]').on('click', function onClick() {
   const form = $(this).closest('form').get(0);
-  form.execution_date.value = executionDate;
-  form.origin.value = window.location;
-  if (form.task_id) {
-    form.task_id.value = taskId;
+  // Somehow submit is fired twice. Only once is the executionDate valid
+  if (executionDate) {
+    form.execution_date.value = executionDate;
+    form.origin.value = window.location;
+    if (form.task_id) {
+      form.task_id.value = taskId;
+    }
+    form.action = $(this).data('action');
+    form.submit();
   }
-  form.action = $(this).data('action');
-  form.submit();
 });
 
 $('#pause_resume').on('change', function onChange() {

Reply via email to