portal-api: improve semantic for yunohost public portal stuff

This commit is contained in:
Alexandre Aubin 2023-09-27 19:30:55 +02:00
parent db30b3acb8
commit 9e87ea88df
4 changed files with 16 additions and 15 deletions

View file

@ -30,7 +30,7 @@ name = "Features"
type = "app" type = "app"
filter = "is_webapp" filter = "is_webapp"
default = "_none" default = "_none"
list_portal = true add_yunohost_portal_to_choices = true
[feature.mail] [feature.mail]

View file

@ -76,13 +76,13 @@ def _get_portal_settings(domain: Union[str, None] = None):
def portal_public(): def portal_public():
settings = _get_portal_settings() portal_settings = _get_portal_settings()
settings["apps"] = {} portal_settings["apps"] = {}
settings["public"] = settings.pop("default_app") == "portal_public_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") ssowat_conf = read_json("/etc/ssowat/conf.json")
settings["apps"] = { portal_settings["apps"] = {
perm.replace(".main", ""): { perm.replace(".main", ""): {
"label": infos["label"], "label": infos["label"],
"url": infos["uris"][0], "url": infos["uris"][0],
@ -91,14 +91,14 @@ def portal_public():
if infos["show_tile"] and infos["public"] if infos["show_tile"] and infos["public"]
} }
if not settings["show_other_domains_apps"]: if not portal_settings["show_other_domains_apps"]:
settings["apps"] = { portal_settings["apps"] = {
name: data name: data
for name, data in settings["apps"].items() for name, data in portal_settings["apps"].items()
if settings["domain"] in data["url"] if portal_settings["domain"] in data["url"]
} }
return settings return portal_settings
def portal_me(): def portal_me():

View file

@ -386,7 +386,7 @@ class ConfigPanel:
"filter", "filter",
"readonly", "readonly",
"enabled", "enabled",
"list_portal", "add_yunohost_portal_to_choices",
# "confirm", # TODO: to ask confirmation before running an action # "confirm", # TODO: to ask confirmation before running an action
], ],
"defaults": {}, "defaults": {},

View file

@ -914,7 +914,7 @@ class AppOption(BaseChoicesOption):
super().__init__(question) super().__init__(question)
self.filter = question.get("filter", None) 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"] apps = app_list(full=True)["apps"]
@ -930,8 +930,9 @@ class AppOption(BaseChoicesOption):
return app["label"] + domain_path_or_id return app["label"] + domain_path_or_id
self.choices = {"_none": "---"} self.choices = {"_none": "---"}
if self.list_portal: if self.add_yunohost_portal_to_choices:
self.choices["portal_public_apps"] = "Portal" # 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}) self.choices.update({app["id"]: _app_display(app) for app in apps})