diff --git a/data/helpers.d/setting b/data/helpers.d/setting index 9e7325d2d..b8c57e158 100644 --- a/data/helpers.d/setting +++ b/data/helpers.d/setting @@ -283,7 +283,7 @@ ynh_permission_create() { if [[ -n ${label:-} ]]; then label=",label='$label'" else - label=",label='$YNH_APP_LABEL ($permission)'" + label=",label='$permission'" fi if [[ -n ${show_tile:-} ]] diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 308032a61..79e9cfdf8 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -429,7 +429,7 @@ def app_upgrade(app=[], url=None, file=None, force=False): """ from packaging import version from yunohost.hook import hook_add, hook_remove, hook_exec, hook_callback - from yunohost.permission import permission_sync_to_user, user_permission_list + from yunohost.permission import permission_sync_to_user from yunohost.regenconf import manually_modified_files apps = app @@ -521,7 +521,6 @@ def app_upgrade(app=[], url=None, file=None, force=False): env_dict["YNH_APP_ID"] = app_id env_dict["YNH_APP_INSTANCE_NAME"] = app_instance_name env_dict["YNH_APP_INSTANCE_NUMBER"] = str(app_instance_nb) - env_dict["YNH_APP_LABEL"] = user_permission_list(full=True, ignore_system_perms=True, full_path=False)['permissions'][app_id+".main"]['label'] env_dict["YNH_APP_UPGRADE_TYPE"] = upgrade_type env_dict["YNH_APP_MANIFEST_VERSION"] = str(app_new_version) env_dict["YNH_APP_CURRENT_VERSION"] = str(app_current_version) @@ -756,7 +755,6 @@ def app_install(operation_logger, app, label=None, args=None, no_remove_on_failu env_dict["YNH_APP_ID"] = app_id env_dict["YNH_APP_INSTANCE_NAME"] = app_instance_name env_dict["YNH_APP_INSTANCE_NUMBER"] = str(instance_number) - env_dict["YNH_APP_LABEL"] = label env_dict["YNH_APP_MANIFEST_VERSION"] = manifest.get("version", "?") # Start register change on system diff --git a/src/yunohost/permission.py b/src/yunohost/permission.py index a5e3a0edb..bed4a2755 100644 --- a/src/yunohost/permission.py +++ b/src/yunohost/permission.py @@ -87,17 +87,25 @@ def user_permission_list(short=False, full=False, ignore_system_perms=False, ful perm["additional_urls"] = infos.get("additionalUrls", []) if full_path: - app_base_path = apps_base_path[app] if app in apps_base_path else "" # Meh in some situation where the app is currently installed/removed, this function may be called and we still need to act as if the corresponding permission indeed exists ... dunno if that's really the right way to proceed but okay. + app_base_path = apps_base_path[app] if app in apps_base_path else "" # Meh in some situation where the app is currently installed/removed, this function may be called and we still need to act as if the corresponding permission indeed exists ... dunno if that's really the right way to proceed but okay. perm["url"] = _get_absolute_url(perm["url"], app_base_path) perm["additional_urls"] = [_get_absolute_url(url, app_base_path) for url in perm["additional_urls"]] permissions[name] = perm + # Make sure labels for sub-permissions are the form " Applabel (Sublabel) " + if full: + for name, infos in {k: v for k, v in permissions if not k.endswith(".main")}: + main_perm_name = name.split(".")[0] + ".main" + main_perm_label = permissions[main_perm_name]["label"] + infos["label"] = "%s (%s)" % (main_perm_label, infos["label"]) + if short: permissions = permissions.keys() return {'permissions': permissions} + @is_unit_operation() def user_permission_update(operation_logger, permission, add=None, remove=None, label=None, show_tile=None,