gluon-config-mode-core: allow returning functions from wizard modules
Allow returning functions in addition to the names of UCI packages to commit. Functions are run after all packages have been committed.
This commit is contained in:
parent
345a5de861
commit
0dd03597a6
@ -28,11 +28,18 @@ local s = f:section(Section)
|
||||
s.template = "gluon/config-mode/welcome"
|
||||
|
||||
local commit = {'gluon-setup-mode'}
|
||||
local run = {}
|
||||
|
||||
for _, w in ipairs(wizard) do
|
||||
for _, c in ipairs(w(f, uci) or {}) do
|
||||
if not util.contains(commit, c) then
|
||||
table.insert(commit, c)
|
||||
if type(c) == 'string' then
|
||||
if not util.contains(commit, c) then
|
||||
table.insert(commit, c)
|
||||
end
|
||||
elseif type(c) == 'function' then
|
||||
table.insert(run, c)
|
||||
else
|
||||
error('invalid wizard module return')
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -45,6 +52,9 @@ function f:write()
|
||||
for _, c in ipairs(commit) do
|
||||
uci:commit(c)
|
||||
end
|
||||
for _, r in ipairs(run) do
|
||||
r()
|
||||
end
|
||||
|
||||
f.template = "gluon/config-mode/reboot"
|
||||
f.hidenav = true
|
||||
|
Loading…
Reference in New Issue
Block a user