apps/config panel: fix _compute_binds + _dump_options_types_and_binds because of the major changes in config panel workflow in bookworm

This commit is contained in:
Alexandre Aubin 2024-08-28 15:00:06 +02:00
parent 36ffa133de
commit 2cc1e7224e

View file

@ -1921,15 +1921,15 @@ ynh_app_config_run $1
raise YunohostError("app_action_failed", action=action, app=app)
return values
def _get_config_panel(self):
def _get_partial_raw_config(self) -> "RawConfig":
ret = super()._get_config_panel()
raw_config = super()._get_partial_raw_config()
self._compute_binds()
self._compute_binds(raw_config)
return ret
return raw_config
def _compute_binds(self):
def _compute_binds(self, raw_config):
"""
This compute the 'bind' statement for every option
In particular to handle __FOOBAR__ syntax
@ -1938,10 +1938,13 @@ ynh_app_config_run $1
settings = _get_app_settings(self.entity)
for panel, section, option in self._iterate():
for panel_id, panel in raw_config.items():
if not isinstance(panel, dict):
continue
bind_panel = panel.get("bind")
for section_id, section in panel.items():
if not isinstance(section, dict):
continue
bind_section = section.get("bind")
if not bind_section:
bind_section = bind_panel
@ -1951,7 +1954,9 @@ ynh_app_config_run $1
bind_section = bind_section + bind_panel_file
else:
bind_section = selector + bind_section + bind_panel_file
for option_id, option in section.items():
if not isinstance(option, dict):
continue
bind = option.get("bind")
if not bind:
if bind_section:
@ -1966,14 +1971,25 @@ ynh_app_config_run $1
bind = selector + bind + bind_file
if bind == "settings" and option.get("type", "string") == "file":
bind = "null"
if option.get("type", "string") == "button":
bind = "null"
option["bind"] = _hydrate_app_template(bind, settings)
def _dump_options_types_and_binds(self):
raw_config = self._get_partial_raw_config()
lines = []
for _, _, option in self._iterate():
for panel_id, panel in raw_config.items():
if not isinstance(panel, dict):
continue
for section_id, section in panel.items():
if not isinstance(section, dict):
continue
for option_id, option in section.items():
if not isinstance(option, dict):
continue
lines.append(
"|".join([option["id"], option.get("type", "string"), option["bind"]])
"|".join([option_id, option.get("type", "string"), option["bind"]])
)
return "\n".join(lines)