potiuk commented on a change in pull request #12558:
URL: https://github.com/apache/airflow/pull/12558#discussion_r537782623



##########
File path: airflow/www/views.py
##########
@@ -2790,6 +2795,40 @@ def pre_update(self, item):
         item.value = XCom.serialize_value(item.value)
 
 
+def lazy_add_provider_discovered_options_to_connection_form():
+    """Adds provider-discovered connection parameters as late as possible"""
+
+    def _get_connection_types() -> List[Tuple[str, str]]:
+        """Returns connection types available."""
+        _connection_types = [
+            ('fs', 'File (path)'),
+            ('mesos_framework-id', 'Mesos Framework ID'),
+        ]
+        providers_manager = ProvidersManager()
+        for connection_type, (_, _, _, hook_name) in 
providers_manager.hooks.items():
+            _connection_types.append((connection_type, hook_name))
+        return _connection_types
+
+    ConnectionForm.conn_type = SelectField(
+        lazy_gettext('Conn Type'),
+        choices=sorted(_get_connection_types(), key=itemgetter(1)),
+        widget=Select2Widget(),
+        validators=[InputRequired()],
+    )
+    for key, value in ProvidersManager().connection_form_widgets.items():
+        setattr(ConnectionForm, key, value.field)
+
+
+# Used to store a dictionary of field behaviours used to dynamically change 
available
+# fields in ConnectionForm based on type of connection chosen
+# See airflow.hooks.base_hook.DiscoverableProtocol for details on how to 
customize your Hooks.
+# those field behaviours are rendered as scripts in the conn_create.html and 
conn_edit.html templates
+class ConnectionFormWidget(FormWidget):

Review comment:
       This is how I pass the "field behaviours" - Connection Form Widget is 
available to the "edit" and "create" templates when rendered so I can pss the 
field_behaviours via the widget.




----------------------------------------------------------------
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.

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


Reply via email to