mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
portal: change the way the new 'public apps' page in the portal is configured: add a simple bool toggle instead of having the 'public apps page' as a default app option, which allows to still configure a default app while the portal has the public apps page
This commit is contained in:
parent
8f636561d9
commit
748a20d864
5 changed files with 10 additions and 14 deletions
|
@ -8,6 +8,10 @@ name = "Features"
|
||||||
# Only available for "topest" domains
|
# Only available for "topest" domains
|
||||||
name = "Portal"
|
name = "Portal"
|
||||||
|
|
||||||
|
[feature.portal.enable_public_apps_page]
|
||||||
|
type = "boolean"
|
||||||
|
default = false
|
||||||
|
|
||||||
[feature.portal.show_other_domains_apps]
|
[feature.portal.show_other_domains_apps]
|
||||||
type = "boolean"
|
type = "boolean"
|
||||||
default = false
|
default = false
|
||||||
|
@ -52,7 +56,6 @@ name = "Features"
|
||||||
type = "app"
|
type = "app"
|
||||||
filter = "is_webapp"
|
filter = "is_webapp"
|
||||||
default = "_none"
|
default = "_none"
|
||||||
add_yunohost_portal_to_choices = true
|
|
||||||
|
|
||||||
[feature.mail]
|
[feature.mail]
|
||||||
name = "Email"
|
name = "Email"
|
||||||
|
|
|
@ -1657,9 +1657,7 @@ def app_ssowatconf():
|
||||||
for domain in domains:
|
for domain in domains:
|
||||||
default_app = _get_raw_domain_settings(domain).get("default_app")
|
default_app = _get_raw_domain_settings(domain).get("default_app")
|
||||||
|
|
||||||
if default_app == "_yunohost_portal_with_public_apps":
|
if default_app not in ["_none", None] and _is_installed(default_app):
|
||||||
redirected_urls[domain + "/"] = domain_portal_dict[domain]
|
|
||||||
elif default_app not in ["_none", None] and _is_installed(default_app):
|
|
||||||
app_settings = _get_app_settings(default_app)
|
app_settings = _get_app_settings(default_app)
|
||||||
app_domain = app_settings["domain"]
|
app_domain = app_settings["domain"]
|
||||||
app_path = app_settings["path"]
|
app_path = app_settings["path"]
|
||||||
|
@ -1667,6 +1665,8 @@ def app_ssowatconf():
|
||||||
# Prevent infinite redirect loop...
|
# Prevent infinite redirect loop...
|
||||||
if domain + "/" != app_domain + app_path:
|
if domain + "/" != app_domain + app_path:
|
||||||
redirected_urls[domain + "/"] = app_domain + app_path
|
redirected_urls[domain + "/"] = app_domain + app_path
|
||||||
|
elif bool(_get_raw_domain_settings(domain).get("enable_public_apps_page", False)):
|
||||||
|
redirected_urls[domain + "/"] = domain_portal_dict[domain]
|
||||||
|
|
||||||
# Will organize apps by portal domain
|
# Will organize apps by portal domain
|
||||||
portal_domains_apps = {domain: {} for domain in portal_domains}
|
portal_domains_apps = {domain: {} for domain in portal_domains}
|
||||||
|
|
|
@ -778,7 +778,7 @@ def _get_DomainConfigPanel():
|
||||||
form.custom_css = ""
|
form.custom_css = ""
|
||||||
|
|
||||||
portal_options = [
|
portal_options = [
|
||||||
"default_app",
|
"enable_public_apps_page",
|
||||||
"show_other_domains_apps",
|
"show_other_domains_apps",
|
||||||
"portal_title",
|
"portal_title",
|
||||||
"portal_logo",
|
"portal_logo",
|
||||||
|
@ -832,7 +832,7 @@ def _get_DomainConfigPanel():
|
||||||
super()._apply(form, previous_settings, exclude={"recovery_password"})
|
super()._apply(form, previous_settings, exclude={"recovery_password"})
|
||||||
|
|
||||||
# Reload ssowat if default app changed
|
# Reload ssowat if default app changed
|
||||||
if "default_app" in next_settings:
|
if "default_app" in next_settings or "enable_public_apps_page" in next_settings:
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
|
|
||||||
app_ssowatconf()
|
app_ssowatconf()
|
||||||
|
|
|
@ -81,9 +81,7 @@ def _get_portal_settings(
|
||||||
if portal_settings_path.exists():
|
if portal_settings_path.exists():
|
||||||
settings.update(read_json(str(portal_settings_path)))
|
settings.update(read_json(str(portal_settings_path)))
|
||||||
# Portal may be public (no login required)
|
# Portal may be public (no login required)
|
||||||
settings["public"] = (
|
settings["public"] = bool(settings.pop("enable_public_apps_page", False))
|
||||||
settings.pop("default_app", None) == "_yunohost_portal_with_public_apps"
|
|
||||||
)
|
|
||||||
|
|
||||||
# First clear apps since it may contains private apps
|
# First clear apps since it may contains private apps
|
||||||
apps: dict[str, Any] = settings.pop("apps", {})
|
apps: dict[str, Any] = settings.pop("apps", {})
|
||||||
|
|
|
@ -1672,7 +1672,6 @@ class AppOption(BaseChoicesOption):
|
||||||
|
|
||||||
type: Literal[OptionType.app] = OptionType.app
|
type: Literal[OptionType.app] = OptionType.app
|
||||||
filter: Union[JSExpression, None] = None
|
filter: Union[JSExpression, None] = None
|
||||||
add_yunohost_portal_to_choices: bool = False
|
|
||||||
choices: Union[dict[str, str], None]
|
choices: Union[dict[str, str], None]
|
||||||
|
|
||||||
@validator("choices", pre=True, always=True)
|
@validator("choices", pre=True, always=True)
|
||||||
|
@ -1692,10 +1691,6 @@ class AppOption(BaseChoicesOption):
|
||||||
]
|
]
|
||||||
|
|
||||||
value = {"_none": "---"}
|
value = {"_none": "---"}
|
||||||
|
|
||||||
if values.get("add_yunohost_portal_to_choices", False):
|
|
||||||
value["_yunohost_portal_with_public_apps"] = "YunoHost's portal with public apps"
|
|
||||||
|
|
||||||
value.update(
|
value.update(
|
||||||
{
|
{
|
||||||
app["id"]: f"{app['label']} ({app.get('domain_path', app['id'])})"
|
app["id"]: f"{app['label']} ({app.get('domain_path', app['id'])})"
|
||||||
|
|
Loading…
Add table
Reference in a new issue