Skip to content

Commit c036292

Browse files
authored
Make skip of trigger form in UI if no params are defined configurable (#33351)
* Make skip of trigger form in UI if no params are defined configurable * Review feedback, remove negating bool * Review feedback, remove negating bool * Add newsfragment
1 parent 4571344 commit c036292

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

airflow/config_templates/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,15 @@ webserver:
17791779
type: string
17801780
example: "sha256"
17811781
default: "md5"
1782+
show_trigger_form_if_no_params:
1783+
description: |
1784+
Behavior of the trigger DAG run button for DAGs without params. False to skip and trigger
1785+
without displaying a form to add a dag_run.conf, True to always display the form.
1786+
The form is displayed always if parameters are defined.
1787+
version_added: 2.7.0
1788+
type: boolean
1789+
example: ~
1790+
default: "False"
17821791
email:
17831792
description: |
17841793
Configuration email backend and whether to

airflow/www/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,6 +2031,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION):
20312031
form_fields[k]["schema"]["custom_html_form"]
20322032
)
20332033
ui_fields_defined = any("const" not in f["schema"] for f in form_fields.values())
2034+
show_trigger_form_if_no_params = conf.getboolean("webserver", "show_trigger_form_if_no_params")
20342035

20352036
if not dag_orm:
20362037
flash(f"Cannot find dag {dag_id}")
@@ -2057,7 +2058,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION):
20572058
if isinstance(run_conf, dict) and any(run_conf)
20582059
}
20592060

2060-
if request.method == "GET" and ui_fields_defined:
2061+
if request.method == "GET" and (ui_fields_defined or show_trigger_form_if_no_params):
20612062
# Populate conf textarea with conf requests parameter, or dag.params
20622063
default_conf = ""
20632064

newsfragments/33351.significant.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The trigger UI form is skipped in web UI with 2.7.0 if no parameters are defined in a DAG.
2+
3+
If you are using ``dag_run.conf`` dictionary and web UI JSON entry to run your DAG you should either:
4+
5+
* `Add params to your DAG <https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/params.html#use-params-to-provide-a-trigger-ui-form>`_
6+
* Enable the new configuration ``show_trigger_form_if_no_params`` to bring back old behaviour

0 commit comments

Comments
 (0)