From 9e87ea88df37bd7e924f5659c6ffe33ded8dbebf Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 27 Sep 2023 19:30:55 +0200 Subject: [PATCH] portal-api: improve semantic for yunohost public portal stuff --- share/config_domain.toml | 2 +- src/portal.py | 20 ++++++++++---------- src/utils/configpanel.py | 2 +- src/utils/form.py | 7 ++++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/share/config_domain.toml b/share/config_domain.toml index 27493b4e7..1239b1fea 100644 --- a/share/config_domain.toml +++ b/share/config_domain.toml @@ -30,7 +30,7 @@ name = "Features" type = "app" filter = "is_webapp" default = "_none" - list_portal = true + add_yunohost_portal_to_choices = true [feature.mail] diff --git a/src/portal.py b/src/portal.py index 61d0c301a..cc6c03e4b 100644 --- a/src/portal.py +++ b/src/portal.py @@ -76,13 +76,13 @@ def _get_portal_settings(domain: Union[str, None] = None): def portal_public(): - settings = _get_portal_settings() - settings["apps"] = {} - settings["public"] = settings.pop("default_app") == "portal_public_apps" + portal_settings = _get_portal_settings() + portal_settings["apps"] = {} + portal_settings["public"] = portal_settings.pop("default_app") == "_yunohost_portal_with_public_apps" - if settings["public"]: + if portal_settings["public"]: ssowat_conf = read_json("/etc/ssowat/conf.json") - settings["apps"] = { + portal_settings["apps"] = { perm.replace(".main", ""): { "label": infos["label"], "url": infos["uris"][0], @@ -91,14 +91,14 @@ def portal_public(): if infos["show_tile"] and infos["public"] } - if not settings["show_other_domains_apps"]: - settings["apps"] = { + if not portal_settings["show_other_domains_apps"]: + portal_settings["apps"] = { name: data - for name, data in settings["apps"].items() - if settings["domain"] in data["url"] + for name, data in portal_settings["apps"].items() + if portal_settings["domain"] in data["url"] } - return settings + return portal_settings def portal_me(): diff --git a/src/utils/configpanel.py b/src/utils/configpanel.py index 30a35e410..86dea2e7d 100644 --- a/src/utils/configpanel.py +++ b/src/utils/configpanel.py @@ -386,7 +386,7 @@ class ConfigPanel: "filter", "readonly", "enabled", - "list_portal", + "add_yunohost_portal_to_choices", # "confirm", # TODO: to ask confirmation before running an action ], "defaults": {}, diff --git a/src/utils/form.py b/src/utils/form.py index c7bc25305..f201f507b 100644 --- a/src/utils/form.py +++ b/src/utils/form.py @@ -914,7 +914,7 @@ class AppOption(BaseChoicesOption): super().__init__(question) self.filter = question.get("filter", None) - self.list_portal = question.get("list_portal", False) + self.add_yunohost_portal_to_choices = question.get("add_yunohost_portal_to_choices", False) apps = app_list(full=True)["apps"] @@ -930,8 +930,9 @@ class AppOption(BaseChoicesOption): return app["label"] + domain_path_or_id self.choices = {"_none": "---"} - if self.list_portal: - self.choices["portal_public_apps"] = "Portal" + if self.add_yunohost_portal_to_choices: + # FIXME: i18n + self.choices["_yunohost_portal_with_public_apps"] = "YunoHost's portal with public apps" self.choices.update({app["id"]: _app_display(app) for app in apps})