diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-04-28 16:06:25 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-04-28 16:06:25 +0200 |
commit | 180d39dcd2427e3c32c0ec7ecc3c7bfb48c0d0ab (patch) | |
tree | 638301131a20bf2a5b22445a4913c19baf8f1729 /modules/luci-base/htdocs/luci-static/resources | |
parent | 904c174cafe46a6414058d242df279c09e23be29 (diff) |
luci-base: ui: resolve aliases and rewrites on obtaining menu node children
Extend LuCI.ui.menu.getChildren() to resolve aliases and rewrites prior to
returning the menu nodes. This allows aliasing entire menu trees instead of
just single pages.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/ui.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 5abd3b388d..b8763ef160 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -3125,7 +3125,24 @@ var UIMenu = baseclass.singleton(/** @lends LuCI.ui.menu.prototype */ { if (!node.children[k].hasOwnProperty('title')) continue; - children.push(Object.assign(node.children[k], { name: k })); + var subnode = Object.assign(node.children[k], { name: k }); + + if (L.isObject(subnode.action) && subnode.action.path != null && + (subnode.action.type == 'alias' || subnode.action.type == 'rewrite')) { + var root = this.menu, + path = subnode.action.path.split('/'); + + for (var i = 0; root != null && i < path.length; i++) + root = L.isObject(root.children) ? root.children[path[i]] : null; + + if (root) + subnode = Object.assign({}, subnode, { + children: root.children, + action: root.action + }); + } + + children.push(subnode); } return children.sort(function(a, b) { |