This is an automated email from the ASF dual-hosted git repository.
eladkal 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 0583150aac Add description to pools view (#34862)
0583150aac is described below
commit 0583150aaca9452e02b8d15b613bfb2451b8e062
Author: Victor Chiapaikeo <[email protected]>
AuthorDate: Fri Oct 20 11:14:19 2023 +0700
Add description to pools view (#34862)
* Add description to pools view
* Truncate description text with css
* Custom list_template in FAB model view
---
airflow/www/templates/airflow/pool_list.html | 28 ++++++++++++++++++++++++++++
airflow/www/views.py | 12 +++++++++++-
tests/www/views/test_views_pool.py | 5 +++++
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/airflow/www/templates/airflow/pool_list.html
b/airflow/www/templates/airflow/pool_list.html
new file mode 100644
index 0000000000..7a08f612be
--- /dev/null
+++ b/airflow/www/templates/airflow/pool_list.html
@@ -0,0 +1,28 @@
+{#
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+#}
+
+{% extends 'appbuilder/general/model/list.html' %}
+
+{% block content %}
+ {{ super() }}
+ <style>
+ td { white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
max-width:1px;}
+ th { resize: horizontal; overflow: auto;}
+ </style>
+{% endblock %}
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 1669413815..f99205db98 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -4625,6 +4625,8 @@ class PoolModelView(AirflowModelView):
route_base = "/pool"
+ list_template = "airflow/pool_list.html"
+
datamodel = AirflowModelView.CustomSQLAInterface(models.Pool) # type:
ignore
class_permission_name = permissions.RESOURCE_POOL
@@ -4644,7 +4646,15 @@ class PoolModelView(AirflowModelView):
permissions.ACTION_CAN_ACCESS_MENU,
]
- list_columns = ["pool", "slots", "running_slots", "queued_slots",
"scheduled_slots", "deferred_slots"]
+ list_columns = [
+ "pool",
+ "description",
+ "slots",
+ "running_slots",
+ "queued_slots",
+ "scheduled_slots",
+ "deferred_slots",
+ ]
add_columns = ["pool", "slots", "description", "include_deferred"]
edit_columns = ["pool", "slots", "description", "include_deferred"]
diff --git a/tests/www/views/test_views_pool.py
b/tests/www/views/test_views_pool.py
index e79ec46c56..dbfaa51fdb 100644
--- a/tests/www/views/test_views_pool.py
+++ b/tests/www/views/test_views_pool.py
@@ -82,6 +82,10 @@ def test_list(app, admin_client, pool_factory):
resp = admin_client.get("/pool/list/")
# We should see this link
with app.test_request_context():
+ description_tag = markupsafe.Markup("<td>{description}</td>").format(
+ description="test-pool-description"
+ )
+
url = flask.url_for("TaskInstanceModelView.list",
_flt_3_pool="test-pool", _flt_3_state="running")
used_tag = markupsafe.Markup("<a
href='{url}'>{slots}</a>").format(url=url, slots=0)
@@ -94,6 +98,7 @@ def test_list(app, admin_client, pool_factory):
url = flask.url_for("TaskInstanceModelView.list",
_flt_3_pool="test-pool", _flt_3_state="deferred")
deferred_tag = markupsafe.Markup("<a
href='{url}'>{slots}</a>").format(url=url, slots=0)
+ check_content_in_response(description_tag, resp)
check_content_in_response(used_tag, resp)
check_content_in_response(queued_tag, resp)
check_content_in_response(scheduled_tag, resp)