You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/08/17 19:31:22 UTC

[airflow] branch v1-10-test updated: Sort connection type list in add/edit page alphabetically (#8692)

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

kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v1-10-test by this push:
     new 8746f52  Sort connection type list in add/edit page alphabetically (#8692)
8746f52 is described below

commit 8746f52e9c904eb34724b759cc3f2e7fedf66ca7
Author: Xiaodong DENG <xd...@hotmail.com>
AuthorDate: Sun May 3 20:18:01 2020 +0200

    Sort connection type list in add/edit page alphabetically (#8692)
    
    Currently the connection type list in the UI is sorted in the original order of
    `Connection._types`, which may be a bit inconvenient for users.
    
    It would be better if it can be sorted alphabetically.
    
    (cherry picked from commit ffbbbfc1a7c2266a19293e0c06b80d46e394fe57)
---
 airflow/www/views.py      | 3 ++-
 airflow/www_rbac/forms.py | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/airflow/www/views.py b/airflow/www/views.py
index 6087356..0c412d9 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -32,6 +32,7 @@ import traceback
 from collections import defaultdict
 from datetime import timedelta
 from functools import wraps
+from operator import itemgetter
 from textwrap import dedent
 
 import sqlalchemy as sqla
@@ -3186,7 +3187,7 @@ class ConnectionModelView(wwwutils.SuperUserMixin, AirflowModelView):
         'extra__yandexcloud__folder_id': StringField('Default folder ID'),
     }
     form_choices = {
-        'conn_type': Connection._types
+        'conn_type': sorted(Connection._types, key=itemgetter(1))
     }
 
     def on_model_change(self, form, model, is_created):
diff --git a/airflow/www_rbac/forms.py b/airflow/www_rbac/forms.py
index 48b9142..6d8b36a 100644
--- a/airflow/www_rbac/forms.py
+++ b/airflow/www_rbac/forms.py
@@ -24,6 +24,7 @@ from __future__ import unicode_literals
 
 import json
 from datetime import datetime as dt
+from operator import itemgetter
 
 import pendulum
 from flask_appbuilder.fieldwidgets import (
@@ -149,7 +150,7 @@ class ConnectionForm(DynamicForm):
         widget=BS3TextFieldWidget())
     conn_type = SelectField(
         lazy_gettext('Conn Type'),
-        choices=Connection._types,
+        choices=sorted(Connection._types, key=itemgetter(1)),
         widget=Select2Widget())
     host = StringField(
         lazy_gettext('Host'),