Skip to content

Commit

Permalink
Make skip of trigger form in UI if no params are defined configurable (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
jscheffl authored Aug 13, 2023
1 parent 4571344 commit c036292
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,15 @@ webserver:
type: string
example: "sha256"
default: "md5"
show_trigger_form_if_no_params:
description: |
Behavior of the trigger DAG run button for DAGs without params. False to skip and trigger
without displaying a form to add a dag_run.conf, True to always display the form.
The form is displayed always if parameters are defined.
version_added: 2.7.0
type: boolean
example: ~
default: "False"
email:
description: |
Configuration email backend and whether to
Expand Down
3 changes: 2 additions & 1 deletion airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION):
form_fields[k]["schema"]["custom_html_form"]
)
ui_fields_defined = any("const" not in f["schema"] for f in form_fields.values())
show_trigger_form_if_no_params = conf.getboolean("webserver", "show_trigger_form_if_no_params")

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

if request.method == "GET" and ui_fields_defined:
if request.method == "GET" and (ui_fields_defined or show_trigger_form_if_no_params):
# Populate conf textarea with conf requests parameter, or dag.params
default_conf = ""

Expand Down
6 changes: 6 additions & 0 deletions newsfragments/33351.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The trigger UI form is skipped in web UI with 2.7.0 if no parameters are defined in a DAG.

If you are using ``dag_run.conf`` dictionary and web UI JSON entry to run your DAG you should either:

* `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>`_
* Enable the new configuration ``show_trigger_form_if_no_params`` to bring back old behaviour

0 comments on commit c036292

Please sign in to comment.