mirror of
https://github.com/openwrt/luci.git
synced 2026-06-17 14:50:21 +04:00
luci-app-strongswan-swanctl: fix Tunnel/Remote modal crash
Opening the Tunnel (or Remote) configuration modal threw TypeError: Cannot convert undefined or null to object and the modal never opened. The crypto_proposal MultiValue fields on remote and tunnel sections showed the "Please create a Proposal first" placeholder only when no crypto_proposal sections existed at all. When proposals existed but none matched the required type (IKE/non-ESP for remote, ESP for tunnel), the inner forEach added no choices, leaving keylist empty. An empty keylist makes form.MultiValue.transformChoices() return null, which is then passed to ui.Dropdown. Because typeof null === 'object', the null check in UIDropdown.__init__ does not replace it, and the subsequent Object.keys(this.choices) call throws. Filter the sections list by is_esp before the length check so the placeholder is shown whenever no proposals of the required type exist. Fixes: https://github.com/openwrt/luci/issues/8606 Signed-off-by: Joshua Vlantis <joshvlantis@gmail.com>
This commit is contained in:
committed by
Florian Eckert
parent
e78236d2ee
commit
e639d481eb
+8
-8
@@ -121,14 +121,14 @@ return view.extend({
|
||||
this.keylist = [];
|
||||
this.vallist = [];
|
||||
|
||||
var sections = uci.sections('ipsec', 'crypto_proposal');
|
||||
var sections = uci.sections('ipsec', 'crypto_proposal').filter(function (section) {
|
||||
return section.is_esp != '1';
|
||||
});
|
||||
if (sections.length == 0) {
|
||||
this.value('', _('Please create a Proposal first'));
|
||||
} else {
|
||||
sections.forEach(L.bind(function (section) {
|
||||
if (section.is_esp != '1') {
|
||||
this.value(section['.name']);
|
||||
}
|
||||
this.value(section['.name']);
|
||||
}, this));
|
||||
}
|
||||
|
||||
@@ -318,14 +318,14 @@ return view.extend({
|
||||
this.keylist = [];
|
||||
this.vallist = [];
|
||||
|
||||
var sections = uci.sections('ipsec', 'crypto_proposal');
|
||||
var sections = uci.sections('ipsec', 'crypto_proposal').filter(function (section) {
|
||||
return section.is_esp == '1';
|
||||
});
|
||||
if (sections.length == 0) {
|
||||
this.value('', _('Please create an ESP Proposal first'));
|
||||
} else {
|
||||
sections.forEach(L.bind(function (section) {
|
||||
if (section.is_esp == '1') {
|
||||
this.value(section['.name']);
|
||||
}
|
||||
this.value(section['.name']);
|
||||
}, this));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user