From 889453daffc09cdd68b7567aad547bc2ef1dffcc Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 17 Jan 2025 15:39:44 -0800 Subject: [PATCH] names: Simplify showing current and available domains - In the main domains list, only show currently configured domains. Allow operations such as edit/delete/configure on them. Actions are determined by the domain type. - Show domain types that can be added in a separate table. If an domain is present and only of that type can exist, it will not be shown in this table. Show add/configure action based on whether multiple domains can exist. Tests: - Configuring a singleton domain type puts it in the domains tables and removes it from the add domains table. De-configuring it or disabling it does the opposite. - For domain types with multiple domains (static/dynamic), entries are shown in domains if such domains exist. Entry in add domains tables always shows up. - All action buttons for all five domain types work. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/names/templates/names.html | 67 +++++++++++++++++------ plinth/modules/names/views.py | 2 +- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/plinth/modules/names/templates/names.html b/plinth/modules/names/templates/names.html index 8ad3937f9..dc3d3d727 100644 --- a/plinth/modules/names/templates/names.html +++ b/plinth/modules/names/templates/names.html @@ -28,24 +28,27 @@ {{ domain.name }} {{ domain.get_readable_services|join:', ' }} - - {% trans "Configure" %} - - - - {% endfor %} - - {% for domain_type in status.unused_domain_types %} - - {{ domain_type.display_name }} - - - - - - - {% trans "Configure" %} - + {% if domain.domain_type.configuration_url %} + + + {% trans "Configure" %} + + {% endif %} + {% if domain.domain_type.edit_url %} + + + + {% endif %} + {% if domain.domain_type.delete_url %} + + + + {% endif %} {% endfor %} @@ -53,6 +56,34 @@ +

{% trans "Add Domains" %}

+ +
+
+
+ {% for domain_type in status.unused_domain_types %} +
+
{{ domain_type.display_name }}
+ {% if domain_type.configuration_url %} + + + {% trans "Configure" %} + + {% endif %} + {% if domain_type.add_url %} + + + {% trans "Add" %} + + {% endif %} +
+ {% endfor %} +
+
+
+

{% trans "Resolver Status" %}

{% if resolved_installed and resolved_status %} diff --git a/plinth/modules/names/views.py b/plinth/modules/names/views.py index 27d3a6376..102c8b496 100644 --- a/plinth/modules/names/views.py +++ b/plinth/modules/names/views.py @@ -142,7 +142,7 @@ def get_status(): used_domain_types = {domain.domain_type for domain in domains} unused_domain_types = [ domain_type for domain_type in components.DomainType.list().values() - if domain_type not in used_domain_types + if domain_type not in used_domain_types or domain_type.add_url ] return {'domains': domains, 'unused_domain_types': unused_domain_types}