From 6de36183d317449e583fd438f7513d94626e38c9 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 6 Dec 2022 20:39:54 +0100 Subject: [PATCH 1/3] [fix] hotspot config panel fails in webadmin --- src/utils/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/config.py b/src/utils/config.py index 9dc91b83a..9b0181e41 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -682,7 +682,7 @@ class ConfigPanel: section and section.get("visible") and not evaluate_simple_js_expression( - section["visible"], context=self.new_values + section["visible"], context=self.future_values ) ): continue From 744f9635087a22b019acbd34abebeafaf14a29b0 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 6 Dec 2022 22:08:13 +0100 Subject: [PATCH 2/3] [fix] Visible app condition not properly evaluate If the config script returned structured data --- src/utils/config.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/config.py b/src/utils/config.py index 9b0181e41..8e7db6d23 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -651,10 +651,19 @@ class ConfigPanel: raw_msg=True, ) value = self.values[option["name"]] + + # Allow to use value instead of current_value in app config script. + # For example hotspot used it... + # See https://github.com/YunoHost/yunohost/pull/1546 + if isinstance(value, dict) and "value" in value and "current_value" not in value: + value["current_value"] = value["value"] + # In general, the value is just a simple value. # Sometimes it could be a dict used to overwrite the option itself value = value if isinstance(value, dict) else {"current_value": value} option.update(value) + + self.values[option["id"]] = value.get("current_value") return self.values From b47d2c7476736341fce9ffb2ad90f8872486c3df Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 6 Dec 2022 23:21:28 +0100 Subject: [PATCH 3/3] Clarify the thing about current_value vs value --- src/utils/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/config.py b/src/utils/config.py index 8e7db6d23..7e414ac9b 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -653,6 +653,7 @@ class ConfigPanel: value = self.values[option["name"]] # Allow to use value instead of current_value in app config script. + # e.g. apps may write `echo 'value: "foobar"'` in the config file (which is more intuitive that `echo 'current_value: "foobar"'` # For example hotspot used it... # See https://github.com/YunoHost/yunohost/pull/1546 if isinstance(value, dict) and "value" in value and "current_value" not in value: