apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
35.21k stars 13.76k forks source link

Support multiline input for Params of type string in trigger UI form #40414

Open sc-anssi opened 4 days ago

sc-anssi commented 4 days ago

This patch adds the possibility to have a multiline input (textarea) for Params of type "string" in the trigger UI form. The choice between rendering a text input (single line) or a textarea (multiline) is based on the presence of a new line character in any of the examples of the Param. For instance, the following code generates a multiline input:

Param(
    description="a parameter that is rendered better with a textarea",
    type=["string", "null"],
    examples=["first line of text before\na new line"],
)

I know Params of type "array" are rendered as textareas but forcing our end-users to format their multiline text into an array of strings would not be very friendly :). So it seems more practical to leave the Param as a "string" type and work on the rendering options instead.

The patch is merely a PoC to showcase what the feature would look like and by no means a definitive solution. I think that relying on the examples attribute is more a hack than a solution, but adding a new explicit attribute to the Param object is beyond my understanding of Airflow. So feel free to rewrite it completely if you think the feature is worth it.

boring-cyborg[bot] commented 4 days ago

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst) Here are some useful points: