luci-base: force menu to regenerate after uci change
authorJames Haggerty <james.haggerty@morsemicro.com>
Thu, 8 Jun 2023 01:59:39 +0000 (11:59 +1000)
committerPaul Donald <newtwen@gmail.com>
Sat, 16 Mar 2024 23:23:45 +0000 (00:23 +0100)
Because the menu JSON can have 'depends' in them, uci changes
should force the menu to regenerate.

Closes #6423

Signed-off-by: James Haggerty <james.haggerty@morsemicro.com>
Signed-off-by: Paul Donald <newtwen@gmail.com>
modules/luci-base/htdocs/luci-static/resources/uci.js
modules/luci-base/htdocs/luci-static/resources/ui.js
modules/luci-base/ucode/dispatcher.uc

index 76b274470b19dd6c9698e95b341b80e48b92be3a..c56ce4016a243f78d562b8a8459e81f2369cfb57 100644 (file)
@@ -919,6 +919,8 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
                                                        window.setTimeout(try_confirm, 250);
                                                else
                                                        return Promise.reject(rv);
+                                       } else {
+                                               document.dispatchEvent(new CustomEvent('uci-applied'));
                                        }
 
                                        return rv;
index afb590d8f8a50048602b7c731dc0f30a13b7f65e..b17fdc45fe1ed720c222321800b435939839c71d 100644 (file)
@@ -3478,6 +3478,10 @@ var UITable = baseclass.extend(/** @lends LuCI.ui.table.prototype */ {
        }
 });
 
+// Because the menu can depend on uci values, we need to flush the cache
+// after uci mutations.
+document.addEventListener('uci-applied', () => UIMenu.flushCache());
+
 /**
  * @class ui
  * @memberof LuCI
index 8717385be2170e8eeb41f5f23fce2f1864a9c2d4..694891a90e6aad25b451b8b91dd9ddea37236062 100644 (file)
@@ -358,7 +358,7 @@ function build_pagetree() {
                firstchild_ineligible: 'bool'
        };
 
-       let files = glob('/usr/share/luci/menu.d/*.json', '/usr/lib/lua/luci/controller/*.lua', '/usr/lib/lua/luci/controller/*/*.lua');
+       let files = glob('/usr/share/luci/menu.d/*.json', '/etc/config/*', '/usr/lib/lua/luci/controller/*.lua', '/usr/lib/lua/luci/controller/*/*.lua');
        let cachefile;
 
        if (indexcache) {