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

jscheffl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 914bccc387 Improve trigger UI for string array format validation 
(#39993)
914bccc387 is described below

commit 914bccc387233b799309499c727074d15e0afbd4
Author: techolga <[email protected]>
AuthorDate: Tue Jun 4 19:02:52 2024 +0200

    Improve trigger UI for string array format validation (#39993)
    
    * Improve trigger UI for string array format validation
    
    The schema argument in a Param definition is used to detemine the
    relevant UI element. When the type of a Param is `array` a simple
    textarea is rendered. When additionally a schema for the items of
    the array is provided, the UI element previously switched to a
    CodeMirror box that expects pure JSON inputs. For strings a textarea
    is presented now, to keep the same behaviour than without a format
    definition.
    
    Besides that the jinja template now accesses the `items` member of the
    schema correctly to avoid problems with empty `items` arrays.
    
    * Add details about the attribute `items` for the type `array`
---
 airflow/www/templates/airflow/trigger.html   | 2 +-
 docs/apache-airflow/core-concepts/params.rst | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/airflow/www/templates/airflow/trigger.html 
b/airflow/www/templates/airflow/trigger.html
index d08ac3cef6..eb098dd21d 100644
--- a/airflow/www/templates/airflow/trigger.html
+++ b/airflow/www/templates/airflow/trigger.html
@@ -86,7 +86,7 @@
         {% endfor -%}
       </select>
     {% elif form_details.schema and "array" in form_details.schema.type %}
-      {% if "items" in form_details.schema and form_details.schema.items %}
+      {% if "items" in form_details.schema and form_details.schema["items"] 
and ("type" not in form_details.schema["items"] or "string" not in 
form_details.schema["items"]["type"]) %}
       <textarea class="form-control" name="element_{{ form_key }}" 
id="element_{{ form_key }}" valuetype="advancedarray" rows="6"
         {%- if not "null" in form_details.schema.type %} required=""{% endif 
-%}>
         {%- if form_details.value is sequence %}
diff --git a/docs/apache-airflow/core-concepts/params.rst 
b/docs/apache-airflow/core-concepts/params.rst
index 5263e36107..621e289cb6 100644
--- a/docs/apache-airflow/core-concepts/params.rst
+++ b/docs/apache-airflow/core-concepts/params.rst
@@ -271,7 +271,9 @@ The following features are supported in the Trigger UI Form:
               | For multi-value selects ``examples`` you can add
               | the attribute ``values_display`` with a dict and
               | map data values to display labels.
-            * | If you add the attribute ``items``, a JSON entry
+            * | If you add the attribute ``items`` with a
+              | dictionary that contains a field ``type``
+              | with a value other than "string", a JSON entry
               | field will be generated for more array types and
               | additional type validation as described in
               | `JSON Schema Array Items 
<https://json-schema.org/understanding-json-schema/reference/array.html#items>`_.
@@ -279,6 +281,8 @@ The following features are supported in the Trigger UI Form:
 
             ``Param(["two", "three"], type="array", examples=["one", "two", 
"three", "four", "five"])``
 
+            ``Param(["[email protected]", "[email protected]"], type="array", 
items={"type": "string", "format": "idn-email"})``
+
         * - ``object``
           - | Generates a JSON entry field with
             | text validation.

Reply via email to