yunohost-admin
yunohost-admin copied to clipboard
add action
Implementation of actions in config panels for the web admin.
Changelog
-
add config actions:
- add new
<button-item>
component to render an argtype ="button"
-
<config-panel>
component now handleconfig
andaction
submission and emit the proper (filtered) form and id (+ action if it's an action):- an action will receive a form containing only values specified in its
args
prop - a config apply will receive everything except values present in action sections
- an action will receive a form containing only values specified in its
- top level views can now listen to the
submit
event and call appropriate routes to trigger a config change or an action - an action or a config apply will then update the current panel config values only, any changes in other panels will stay. We may need to revert this if some panels are expected to modify other panels values.
- add new
-
rework a bit the core arg to web-admin field/component:
-
<markdown-item>
,<read-only-alert-item>
and<button-item>
now renders without any "wrapper" (was in a<form-field>
before) - add a new "wrapper"
<read-only-field>
that will just display any value of an arg withreadonly = true
- rework
<file-item
> to avoid promises handling in expression evaluations(visible
/enabled
). Its value is now an object containing theFile
and other needed props for removal/current, and now also contains the file content (fetched asynchronously). This may be a problem for large files since its content will stay in the form but we may leverage this by adding a new arg prop likecontext = false
to instruct not to fetch theFile
content. -
visible
andenabled
are now computed properties of fields/components to be more "Vue" style (you can simply do<component v-if="field.visible" disabled="!field.enabled">
), those properties are evaluated at each form item modification like before.- if someone set an arg
visible
prop tofalse
or'"false"'
it will simply be set tofalse
instead of a computed getter
- if someone set an arg
-
PR Status
Should work on the web-admin but still some stuff to do on the core side to work with CLI, for example:
- implement
readonly
for args to display a non-interactive value (simple display for all args types?). - implement
args
prop oftype = "button"
to filter what arguments are given to the associated function. - actions resulting in errors are not displayed (wrong response HTTP code)
Also i've experienced some weird behaviors with the API/core:
- arg
type = "text"
will double\n
s at each config change (probably a faulty replace) - looks like i can't set an hour above
12
in an argtype = "date"
- i get an error while trying to remove an uploaded file, not sure if it's a regression due to my changes, will investigate. I get this:
DEBUG - + ynh_secure_remove --file=/ynh-dev/temp/file.txt
DEBUG - + ynh_delete_file_checksum --file=/ynh-dev/temp/file.txt --update_only
WARNING - Invalid argument: --
How to test
require: https://github.com/YunoHost/yunohost/pull/1436
go to a domain's config panel and click on button and checkbox. Since the api always return a valid HTTP code, errors are not displayed. But you can check the console to see what's going on.
action in domain config
readonly args