Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luci-base: force menu to regenerate after uci change #7058

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/luci-base/htdocs/luci-static/resources/uci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions modules/luci-base/htdocs/luci-static/resources/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3516,6 +3516,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
Expand Down
12 changes: 7 additions & 5 deletions modules/luci-base/ucode/dispatcher.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -375,13 +375,15 @@ function build_pagetree() {

for (let file in files) {
let data;

if (substr(file, -5) == '.json')
data = read_jsonfile(file);
else if (load_luabridge(true))
data = runtime.call('luci.dispatcher', 'process_lua_controller', file);
else if (substr(file, -4) == '.lua')
if (load_luabridge(true))
data = runtime.call('luci.dispatcher', 'process_lua_controller', file);
else
warn(`Lua controller ${file} present but no Lua runtime installed.\n`);
else
warn(`Lua controller ${file} present but no Lua runtime installed.\n`);
continue;

if (type(data) == 'object') {
for (let path, spec in data) {
Expand Down
Loading