diff --git a/package/gluon-config-mode-domain-select/check_site.lua b/package/gluon-config-mode-domain-select/check_site.lua index 18994ecd..6a6fd47b 100644 --- a/package/gluon-config-mode-domain-select/check_site.lua +++ b/package/gluon-config-mode-domain-select/check_site.lua @@ -1 +1,7 @@ -need_boolean(in_domain({'hide_domain'}), false) +local valid_domain_codes = table_keys(need_table(in_domain({'domain_names'}))) + +alternatives(function() + need_boolean(in_domain({'hide_domain'}), false) +end, function() + need_array_of(in_domain({'hide_domain'}), valid_domain_codes, false) +end) diff --git a/package/gluon-config-mode-domain-select/luasrc/lib/gluon/config-mode/wizard/0200-domain-select.lua b/package/gluon-config-mode-domain-select/luasrc/lib/gluon/config-mode/wizard/0200-domain-select.lua index 8046e006..9496e99f 100644 --- a/package/gluon-config-mode-domain-select/luasrc/lib/gluon/config-mode/wizard/0200-domain-select.lua +++ b/package/gluon-config-mode-domain-select/luasrc/lib/gluon/config-mode/wizard/0200-domain-select.lua @@ -1,20 +1,32 @@ + return function(form, uci) local site_i18n = i18n 'gluon-site' local fs = require 'nixio.fs' local json = require 'jsonc' local site = require 'gluon.site' + local util = require 'gluon.util' local selected_domain = uci:get('gluon', 'core', 'domain') local configured = uci:get_first('gluon-setup-mode','setup_mode', 'configured') == '1' or (selected_domain ~= site.default_domain()) + local function hide_domain_code(domain, code) + if configured and code == selected_domain then + return false + elseif type(domain.hide_domain) == 'table' then + return util.contains(domain.hide_domain, code) + else + return domain.hide_domain + end + end + local function get_domain_list() local list = {} for domain_path in fs.glob('/lib/gluon/domains/*.json') do local domain_code = domain_path:match('([^/]+)%.json$') local domain = assert(json.load(domain_path)) - if not domain.hide_domain or (configured and domain.domain_code == selected_domain) then + if not hide_domain_code(domain, domain_code) then table.insert(list, { domain_code = domain_code, domain_name = domain.domain_names[domain_code],