Skip to content

Commit

Permalink
app/permissions: draft new 'core' app config panel to edit the permis…
Browse files Browse the repository at this point in the history
…sion stuff and upgrade/change_url/uninstall the app
  • Loading branch information
alexAubin committed Feb 13, 2025
1 parent 638b405 commit 1536ae1
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 42 deletions.
22 changes: 22 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@
"app_change_url_success": "{app} URL is now {domain}{path}",
"app_config_unable_to_apply": "Failed to apply config panel values.",
"app_config_unable_to_read": "Failed to read config panel values.",
"app_config_permission_label": "Label",
"app_config_permission_description": "Description",
"app_config_permission_description_help": "This is really only useful if you're using the 'descriptive' portal mode",
"app_config_permission_show_tile": "Display tile in portal",
"app_config_permission_url": "Corresponding URL",
"app_config_permission_allowed": "Groups/users allowed to access",
"app_config_permission_logo": "Custom logo to use",
"app_config_permission_logo_help": "Only PNG are supported",
"app_config_permission_main_section_name": "Main permission / tile",
"app_config_permission_extraperm_section_name": "Permission '{perm}'",
"app_config_upgrade": "Upgrade",
"app_config_force_upgrade": "Force-upgrade",
"app_config_force_upgrade_explain": "Force-upgrading the app (to the same version) can be useful to rebuild the app and configurations",
"app_config_change_url": "Change URL",
"app_config_change_url_domain": "New domain",
"app_config_change_url_path": "New path",
"app_config_uninstall": "Uninstall",
"app_config_operations_name": "Operations",
"app_config_upgradable_yes": "The app can be upgraded from version {current_version} to {new_version}",
"app_config_upgradable_no": "This app is up to date. <small>(version `{current_version}`)</small><br/><small><em>Looking for a new version from upstream? Maybe there's a 'testing' version you can help packagers with on the YunoHost package's git repository!</em></small>",
"app_config_upgradable_url_required": "",
"app_config_upgradable_bad_quality": "",
"app_corrupt_source": "YunoHost was able to download the asset '{source_id}' ({url}) for {app}, but the asset doesn't match the expected checksum. This could mean that some temporary network failure happened on your server, OR the asset was somehow changed by the upstream maintainer (or a malicious actor?) and YunoHost packagers need to investigate and perhaps update the app manifest to take this change into account.\n Expected sha256 checksum: {expected_sha256}\n Downloaded sha256 checksum: {computed_sha256}\n Downloaded file size: {size}",
"app_extraction_failed": "Could not extract the installation files",
"app_failed_to_download_asset": "Failed to download asset '{source_id}' ({url}) for {app}: {out}",
Expand Down
6 changes: 6 additions & 0 deletions share/actionsmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,9 @@ app:
full: --export
help: Only export key/values, meant to be reimported using "config set --args-file"
action: store_true
--core:
help: Get the 'core' config for this app, such as permissions stuff. This option is only meant for API.
action: store_true

### app_config_set()
set:
Expand All @@ -1098,6 +1101,9 @@ app:
full: --args-file
help: YAML or JSON file with key/value couples
type: open
--core:
help: Set the 'core' config for this app, such as permissions stuff. This option is only meant for API.
action: store_true

#############################
# Backup #
Expand Down
96 changes: 96 additions & 0 deletions share/config_app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
version = "1.0"
i18n = "app_config"

[_core]

# This is duplicated for each permission and named "permission_main", "permission_admin" etc.
# Keys are also made unique by prefixing them with "permission_main" / "permission_admin",
# for example the label key is "permission_{permid}_label"
[_core.permissions]

[_core.permissions.url]
type = "url"
visible = false

[_core.permissions.location]
type = "markdown"
# Core automatically add a "visible=false" if url is empty (but since the keys are dynamic, can't do it here)

[_core.permissions.label]
type = "string"

[_core.permissions.description]
type = "text"

[_core.permissions.show_tile]
type = "boolean"
# Core automatically add a "visible=false" if url is empty (but since the keys are dynamic, can't do it here)

[_core.permissions.logo]
type = "file"
accept = ["image/png"]

[_core.permissions.allowed]
type = "tags"
# Core automatically add a "readonly" if protected is true

[_core.operations]

[_core.operations.upgradable]
type = "string"
# can be 'yes', 'no', 'bad_quality' or 'url_required
visible = false

[_core.operations.upgradable_msg]
type = "alert"
# upgrade = no : success ?
# but advertise testing ?
# upgrade = yes : info ?
# upgrade = url_required : hmmmmmwarning ? "must be upgraded from CLI"
# upgrade = bad quality : hmmmmwarning ? "upgrade disabled"

[_core.operations.upgrade]
type = "button"
icon = "arrow-up"
style = "success"
visible = "upgradable == 'yes'"

[_core.operations.force_upgrade_explain]
type = "markdown"
visible = "upgradable == 'no'"

[_core.operations.force_upgrade]
type = "button"
icon = "refresh"
style = "info"
visible = "upgradable == 'no'"

[_core.operations.change_url_supported]
type = "string"
# can be 'yes', 'no' or 'not_relevant'
visible = false

[_core.operations.change_url_unsupported_msg]
type = "alert"
visible = "change_url_supported == 'no'"

[_core.operations.change_url_domain]
type = "domain"
visible = "change_url_supported == 'yes'"

[_core.operations.change_url_path]
type = "path"
visible = "change_url_supported == 'yes'"

[_core.operations.change_url]
type = "button"
icon = "truck"
style = "info"
visible = "change_url_supported == 'yes'"

# FIXME: "make default" ? meh

[_core.operations.uninstall]
type = "button"
icon = "trash"
style = "danger"
Loading

0 comments on commit 1536ae1

Please sign in to comment.