luci-mod-network: interfaces.js: avoid stray empty device uci sections
authorJo-Philipp Wich <jo@mein.io>
Sun, 5 Feb 2023 18:35:00 +0000 (19:35 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sun, 5 Feb 2023 18:37:28 +0000 (19:37 +0100)
Ensure that just created uci device sections are removed if the edit
option modal is cancelled without saving. This prevents empty, but
harmless `config device` sections from being created on a subsequent
Save & Apply operation.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

index d44b0cf6d0d5d0e130565e64229610341e39651e..d0ffe02ee93b9640287b15bbdf48d0c7443f30b9 100644 (file)
@@ -1347,6 +1347,9 @@ return view.extend({
                                for (var i = 0; i < map.addedVLANs.length; i++)
                                        uci.remove('network', map.addedVLANs[i]);
 
+                       if (this.addedSection)
+                               uci.remove('network', this.addedSection);
+
                        return form.GridSection.prototype.handleModalCancel.apply(this, arguments);
                };