softyoungha opened a new issue, #41010:
URL: https://github.com/apache/airflow/issues/41010

   ### Description
   
   Hi
   While working on the PR https://github.com/apache/airflow/pull/40775 related 
to connection, I tried using `from flask_appbuilder.fieldwidgets import 
BS3TextAreaFieldWidget` to receive input in a textarea.
   
   However, all textareas are being treated as JSON columns and are being 
converted to CodeMirror.
   
https://github.com/apache/airflow/blob/152d03e546ee72b7a73f78f22c40517a2ab8208f/airflow/www/static/js/connection_form.js#L365-L369
   
   
   > Snowflake connection**
   
   
![image](https://github.com/user-attachments/assets/8ed0c9f4-e0f4-4902-b23a-e86bdeaaa87f)
   
   Through the entire Airflow codebase, Snowflake is the only provider using 
`BS3TextAreaFieldWidget` yet.
   However, it would be good for decorating the connection if it could not only 
JSON but also plain string on textarea
   
   
   
   
   
   ### Use case/motivation
   
   it seems like the existing values of get_ui_field_behaviour wouldn't be able 
to solve this issue.
   so It might be possible to add fields like `textarea_languages` to 
`get_ui_field_behaviour`.
   
   ```python
       @classmethod
       def get_ui_field_behaviour(cls) -> dict[str, Any]:        
           return {
               "hidden_fields": ["host", "schema", "port", "login", "password", 
"extra"],
               "relabeling": {},
               "placeholders": {},
               "textarea_languages": {"extra": "json", "requirements": "text", 
"manifest": "yaml"},
           }
   ```
   
   
https://github.com/apache/airflow/blob/b4e82cf66fb4d833a25de5e2688b44e7b4ddf4bb/airflow/customized_form_field_behaviours.schema.json#L4-L26
   
   ```json
       "hidden_fields": {...},
       "relabeling": {...},
       "placeholders": {...},
       "textarea_languages": {
         "type": "object",
         "description": "Languages for the textarea fields(`text`, `json`, 
`yaml`)",
         "additionalProperties": {
           "type": "string"
         }
       }
   ```
   
   
   And I looked into it further, and I think the CodeMirror might also be able 
to accept YAML input,
   so it could handle not just JSON and plain strings, but also YAML
   
   > 
[codemirror/yaml.min.js](https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/yaml/yaml.min.js)
   > 
[codemirror/yaml-lint.min.js](https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/addon/lint/yaml-lint.min.js)
   
   
   
   
   In summary, it would be nice to specify certain columns in languages such as 
JSON or string. 
   (YAML might be too much, so I just wanted to suggest it)
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to