mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] No validate function in config panel
This commit is contained in:
parent
27ba82bd30
commit
5fec35ccea
1 changed files with 24 additions and 17 deletions
|
@ -123,7 +123,7 @@ EOL
|
||||||
local _dot_setting=$(echo "$param_source" | cut -d= -f1)
|
local _dot_setting=$(echo "$param_source" | cut -d= -f1)
|
||||||
local _snake_setting="YNH_CONFIG_$(ynh_lowerdot_to_uppersnake $dot_setting)"
|
local _snake_setting="YNH_CONFIG_$(ynh_lowerdot_to_uppersnake $dot_setting)"
|
||||||
local short_setting=$(echo "$_dot_setting" | cut -d. -f3)
|
local short_setting=$(echo "$_dot_setting" | cut -d. -f3)
|
||||||
local _getter="get__${short_setting}"
|
local getter="get__${short_setting}"
|
||||||
local source="$(echo $param_source | cut -d= -f2)"
|
local source="$(echo $param_source | cut -d= -f2)"
|
||||||
|
|
||||||
# Get value from getter if exists
|
# Get value from getter if exists
|
||||||
|
@ -195,12 +195,12 @@ _ynh_panel_validate() {
|
||||||
for short_setting in "${!dot_settings[@]}"
|
for short_setting in "${!dot_settings[@]}"
|
||||||
do
|
do
|
||||||
#TODO file hash
|
#TODO file hash
|
||||||
file_hash[$setting]=$(sha256sum "$_source" | cut -d' ' -f1)
|
file_hash[$setting]=$(sha256sum "$_source" | cut -d' ' -f1)
|
||||||
file_hash[$form_setting]=$(sha256sum "${!form_setting}" | cut -d' ' -f1)
|
file_hash[$form_setting]=$(sha256sum "${!form_setting}" | cut -d' ' -f1)
|
||||||
if [[ "${file_hash[$setting]}" != "${file_hash[$form_setting]}" ]]
|
if [[ "${file_hash[$setting]}" != "${file_hash[$form_setting]}" ]]
|
||||||
then
|
then
|
||||||
changed[$setting]=true
|
changed[$setting]=true
|
||||||
fi
|
fi
|
||||||
if [[ "$new[$short_setting]" == "$old[$short_setting]" ]]
|
if [[ "$new[$short_setting]" == "$old[$short_setting]" ]]
|
||||||
then
|
then
|
||||||
changed[$short_setting]=false
|
changed[$short_setting]=false
|
||||||
|
@ -216,10 +216,13 @@ _ynh_panel_validate() {
|
||||||
|
|
||||||
for short_setting in "${!dot_settings[@]}"
|
for short_setting in "${!dot_settings[@]}"
|
||||||
do
|
do
|
||||||
local result="$(validate__$short_setting)"
|
local result=""
|
||||||
local key="YNH_ERROR_$(ynh_lowerdot_to_uppersnake $dot_settings[$short_setting])"
|
if type validate__$short_setting | grep -q '^function$' 2>/dev/null; then
|
||||||
|
result="$(validate__$short_setting)"
|
||||||
|
fi
|
||||||
if [ -n "$result" ]
|
if [ -n "$result" ]
|
||||||
then
|
then
|
||||||
|
local key="YNH_ERROR_$(ynh_lowerdot_to_uppersnake $dot_settings[$short_setting])"
|
||||||
ynh_return "$key=$result"
|
ynh_return "$key=$result"
|
||||||
is_error=true
|
is_error=true
|
||||||
fi
|
fi
|
||||||
|
@ -237,14 +240,6 @@ ynh_panel_get() {
|
||||||
_ynh_panel_get
|
_ynh_panel_get
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_panel_init() {
|
|
||||||
declare -A old=()
|
|
||||||
declare -A changed=()
|
|
||||||
declare -A file_hash=()
|
|
||||||
|
|
||||||
ynh_panel_get
|
|
||||||
}
|
|
||||||
|
|
||||||
ynh_panel_show() {
|
ynh_panel_show() {
|
||||||
_ynh_panel_show
|
_ynh_panel_show
|
||||||
}
|
}
|
||||||
|
@ -257,3 +252,15 @@ ynh_panel_apply() {
|
||||||
_ynh_panel_apply
|
_ynh_panel_apply
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ynh_panel_run() {
|
||||||
|
declare -A old=()
|
||||||
|
declare -A changed=()
|
||||||
|
declare -A file_hash=()
|
||||||
|
|
||||||
|
ynh_panel_get
|
||||||
|
case $1 in
|
||||||
|
show) ynh_panel_show;;
|
||||||
|
apply) ynh_panel_validate && ynh_panel_apply;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue